From patchwork Thu Nov 16 11:57:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Machek X-Patchwork-Id: 10061001 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id ECD0E60230 for ; Thu, 16 Nov 2017 11:57:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E24E6267EC for ; Thu, 16 Nov 2017 11:57:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D6D7A2A913; Thu, 16 Nov 2017 11:57:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 69856267EC for ; Thu, 16 Nov 2017 11:57:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: MIME-Version:Message-ID:Subject:To:From:Date:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=6PPP7ycb0xqF0JHUeJuR7Cc8RHcKxdZtIcEJkdAOA1Q=; b=hQE 9/DrUjTTr7ygnOYdMHZ8V08wud3bpK86Seg8cecWwI7zsumc6+6oymlh3MvIQY7tg5jPFtZ3Qsut5 ouzmwVhNzr5hzKnjVpgEVPiat+HzBEmVCbhCEpiF5Se+0D1tUOGguwf1fd9rzGcA/E7xmSN04415C Jv1ty3m9U61hsxNvy/8TPYr8+eD/4axDo66zb8DkKf/RmQuCAC9bhuvTm9piOr007xyN+kHcrDK+0 XbY+cJ7YiGVnxCpJHvTNN6m67sVNhmC9LRgFQU0eHpgDPPVQPQuOUcNJ9cm2vCbLhD7EWQGomn6kY i/kqYQwz3l/GZWxkjElHd0rvlvOQiQA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1eFInW-0005ZN-L2; Thu, 16 Nov 2017 11:57:34 +0000 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1eFInP-0005In-BM for linux-arm-kernel@lists.infradead.org; Thu, 16 Nov 2017 11:57:32 +0000 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id BF7C581569; Thu, 16 Nov 2017 12:57:03 +0100 (CET) Date: Thu, 16 Nov 2017 12:57:03 +0100 From: Pavel Machek To: pali.rohar@gmail.com, sre@kernel.org, kernel list , linux-arm-kernel , linux-omap@vger.kernel.org, tony@atomide.com, khilman@kernel.org, aaro.koskinen@iki.fi, ivo.g.dimitrov.75@gmail.com, patrikbachan@gmail.com, serge@hallyn.com, abcloriens@gmail.com, clayton@craftyguy.net, martijn@brixit.nl, sakari.ailus@linux.intel.com, arnd@arndb.de, Filip =?utf-8?Q?Matijevi=C4=87?= Subject: bh1770 hacks: get it to work on n950 Message-ID: <20171116115703.GA26735@amd> MIME-Version: 1.0 User-Agent: Mutt/1.5.23 (2014-03-12) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171116_035727_989436_366F8AA9 X-CRM114-Status: GOOD ( 16.95 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi! Ok, not for application, but I can get light sensor to work. Signed-off-by: Pavel Machek diff --git a/arch/arm/boot/dts/omap3-n950.dts b/arch/arm/boot/dts/omap3-n950.dts index 50c4fc6..15841f7 100644 --- a/arch/arm/boot/dts/omap3-n950.dts +++ b/arch/arm/boot/dts/omap3-n950.dts @@ -150,6 +150,23 @@ }; }; + bh1770@38 { + compatible = "bh1770glc"; + reg = <0x38>; + + vdd-supply = <&vaux1>; + leds-supply = <&vaux1>; /* FIXME: really on vbat */ + + /* GPIO 83 on n950. + .leds = BHSFH_LED1, + .led_max_curr = BHSFH_LED_100mA, + .led_def_curr = BHSFH_LED_50mA, + .glass_attenuation = (16384 * 385) / 100, ... about 3.85x filtering + */ + }; + + /* Also TLV320DAC33 and TPA6130A2 */ + touch@4b { compatible = "atmel,maxtouch"; reg = <0x4b>; diff --git a/drivers/misc/bh1770glc.c b/drivers/misc/bh1770glc.c index 9c62bf0..f08df29 100644 --- a/drivers/misc/bh1770glc.c +++ b/drivers/misc/bh1770glc.c @@ -22,6 +22,7 @@ * */ +#define DEBUG #include #include #include @@ -525,16 +526,22 @@ static int bh1770_detect(struct bh1770_chip *chip) s32 ret; u8 manu, part; + printk("Detect...\n"); + ret = i2c_smbus_read_byte_data(client, BH1770_MANUFACT_ID); if (ret < 0) goto error; manu = (u8)ret; + printk("Detect... manufact\n"); + ret = i2c_smbus_read_byte_data(client, BH1770_PART_ID); if (ret < 0) goto error; part = (u8)ret; + printk("Detect... part ... got %x %x\n", manu, part); + chip->revision = (part & BH1770_REV_MASK) >> BH1770_REV_SHIFT; chip->prox_coef = BH1770_COEF_SCALER; chip->prox_const = 0; @@ -1179,6 +1186,8 @@ static const struct attribute_group bh1770_attribute_group = { .attrs = sysfs_attrs }; +struct bh1770_platform_data def = {}; + static int bh1770_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1189,6 +1198,8 @@ static int bh1770_probe(struct i2c_client *client, if (!chip) return -ENOMEM; + printk("bh1770: probe\n"); + i2c_set_clientdata(client, chip); chip->client = client; @@ -1198,10 +1209,12 @@ static int bh1770_probe(struct i2c_client *client, if (client->dev.platform_data == NULL) { dev_err(&client->dev, "platform data is mandatory\n"); - return -EINVAL; + //return -EINVAL; } chip->pdata = client->dev.platform_data; + if (!chip->pdata) + chip->pdata = &def; chip->lux_calib = BH1770_LUX_NEUTRAL_CALIB_VALUE; chip->lux_rate_index = BH1770_LUX_DEFAULT_RATE; chip->lux_threshold_lo = BH1770_LUX_DEF_THRES; @@ -1220,6 +1233,8 @@ static int bh1770_probe(struct i2c_client *client, chip->prox_rate = BH1770_PROX_DEFAULT_RATE; chip->prox_data = 0; + printk("bh1770: regulators\n"); + chip->regs[0].supply = reg_vcc; chip->regs[1].supply = reg_vleds; @@ -1227,14 +1242,12 @@ static int bh1770_probe(struct i2c_client *client, ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot get regulators\n"); - return err; } err = regulator_bulk_enable(ARRAY_SIZE(chip->regs), chip->regs); if (err < 0) { dev_err(&client->dev, "Cannot enable regulators\n"); - return err; } usleep_range(BH1770_STARTUP_DELAY, BH1770_STARTUP_DELAY * 2); @@ -1242,6 +1255,8 @@ static int bh1770_probe(struct i2c_client *client, if (err < 0) goto fail0; + printk("bh1770: detected\n"); + /* Start chip */ bh1770_chip_on(chip); pm_runtime_set_active(&client->dev); @@ -1269,6 +1284,8 @@ static int bh1770_probe(struct i2c_client *client, goto fail1; } + printk("bh1770: sysfs ok\n"); + /* * Chip needs level triggered interrupt to work. However, * level triggering doesn't work always correctly with power @@ -1282,8 +1299,12 @@ static int bh1770_probe(struct i2c_client *client, if (err) { dev_err(&client->dev, "could not get IRQ %d\n", client->irq); - goto fail2; + //goto fail2; } + + printk("bh1770: irq ok, all done\n"); + err = 0; + regulator_bulk_disable(ARRAY_SIZE(chip->regs), chip->regs); return err; fail2: @@ -1393,10 +1414,18 @@ static const struct dev_pm_ops bh1770_pm_ops = { SET_RUNTIME_PM_OPS(bh1770_runtime_suspend, bh1770_runtime_resume, NULL) }; +#ifdef CONFIG_OF +static const struct of_device_id bh1770_of_match_table[] = { + { .compatible = "bq27200" }, +}; +MODULE_DEVICE_TABLE(of, bh1770_of_match_table); +#endif + static struct i2c_driver bh1770_driver = { .driver = { .name = "bh1770glc", .pm = &bh1770_pm_ops, + .of_match_table = of_match_ptr(bh1770_of_match_table), }, .probe = bh1770_probe, .remove = bh1770_remove,