From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752234AbbCWHkZ (ORCPT ); Mon, 23 Mar 2015 03:40:25 -0400 Received: from metis.ext.pengutronix.de ([92.198.50.35]:35862 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751416AbbCWHkV (ORCPT ); Mon, 23 Mar 2015 03:40:21 -0400 Date: Mon, 23 Mar 2015 08:39:05 +0100 From: Sascha Hauer To: Eddie Huang Cc: Wolfram Sang , Matthias Brugger , Uwe =?iso-8859-15?Q?Kleine-K=F6nig?= , Mark Rutland , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, David Box , Lee Jones , Jean Delvare , Xudong Chen , Boris BREZILLON , Arnd Bergmann , Liguo Zhang , Wei Yan , Bjorn Andersson , Neelesh Gupta , devicetree@vger.kernel.org, Pawel Moll , Ian Campbell , Beniamino Galvani , Rob Herring , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, srv_heupstream@mediatek.com, Anders Berg , Jim Cromie , Simon Glass , Max Schwarz , Doug Anderson , Sascha Hauer , Kumar Gala Subject: Re: [PATCH v5 3/3] I2C: mediatek: Add driver for MediaTek MT8173 I2C controller Message-ID: <20150323073905.GF9742@pengutronix.de> References: <1426917922-61356-1-git-send-email-eddie.huang@mediatek.com> <1426917922-61356-4-git-send-email-eddie.huang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1426917922-61356-4-git-send-email-eddie.huang@mediatek.com> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-IRC: #ptxdist @freenode X-Accept-Language: de,en X-Accept-Content-Type: text/plain X-Uptime: 08:27:04 up 6 days, 19:18, 43 users, load average: 0.36, 0.24, 0.17 User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 21, 2015 at 02:05:22PM +0800, Eddie Huang wrote: > Add mediatek MT8173 I2C controller driver. Compare to I2C controller > of earlier mediatek SoC, MT8173 fix write-then-read limitation, and > also increase message size to 64kb. > [...] > +static const struct i2c_adapter_quirks mt8173_i2c_quirks = { > + .max_num_msgs = MAX_MSG_NUM_MT8173, > + .max_write_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_read_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_comb_1st_msg_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_comb_2nd_msg_len = MAX_WRRD_TRANS_SIZE_MT8173, > +}; > + > static int mtk_i2c_probe(struct platform_device *pdev) > { > int ret = 0; > @@ -587,7 +626,8 @@ static int mtk_i2c_probe(struct platform_device *pdev) > return -EINVAL; > > i2c->platform_compat = mtk_get_device_prop(pdev); > - if (i2c->have_pmic && (i2c->platform_compat & COMPAT_MT6577)) > + if (i2c->have_pmic && (i2c->platform_compat & > + (COMPAT_MT6577 | COMPAT_MT8173))) > return -EINVAL; > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > @@ -613,7 +653,10 @@ static int mtk_i2c_probe(struct platform_device *pdev) > i2c->adap.dev.parent = &pdev->dev; > i2c->adap.owner = THIS_MODULE; > i2c->adap.algo = &mtk_i2c_algorithm; > - i2c->adap.quirks = &mt6577_i2c_quirks; > + if (i2c->platform_compat & COMPAT_MT8173) > + i2c->adap.quirks = &mt8173_i2c_quirks; > + else > + i2c->adap.quirks = &mt6577_i2c_quirks; Instead of putting an integer into struct of_device_id you should introduce a struct mtk_i2c_data { struct i2c_adapter_quirks quirks; int compat; /* Additional SoC specific data */ }; and put a pointer to this directly into the of_device_id. This way you need less casting and can put newly discovered differences diretly into some data struct and don't have to introduce if(socxy) ... else ... everytime. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sascha Hauer Subject: Re: [PATCH v5 3/3] I2C: mediatek: Add driver for MediaTek MT8173 I2C controller Date: Mon, 23 Mar 2015 08:39:05 +0100 Message-ID: <20150323073905.GF9742@pengutronix.de> References: <1426917922-61356-1-git-send-email-eddie.huang@mediatek.com> <1426917922-61356-4-git-send-email-eddie.huang@mediatek.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1426917922-61356-4-git-send-email-eddie.huang@mediatek.com> Sender: linux-kernel-owner@vger.kernel.org To: Eddie Huang Cc: Wolfram Sang , Matthias Brugger , Uwe =?iso-8859-15?Q?Kleine-K=F6nig?= , Mark Rutland , linux-kernel@vger.kernel.org, linux-i2c@vger.kernel.org, David Box , Lee Jones , Jean Delvare , Xudong Chen , Boris BREZILLON , Arnd Bergmann , Liguo Zhang , Wei Yan , Bjorn Andersson , Neelesh Gupta , devicetree@vger.kernel.org, Pawel Moll , Ian Campbell , Beniamino Galvani , Rob Herring , linux-mediatek@lists.infradead.org, linux-arm- List-Id: devicetree@vger.kernel.org On Sat, Mar 21, 2015 at 02:05:22PM +0800, Eddie Huang wrote: > Add mediatek MT8173 I2C controller driver. Compare to I2C controller > of earlier mediatek SoC, MT8173 fix write-then-read limitation, and > also increase message size to 64kb. > [...] > +static const struct i2c_adapter_quirks mt8173_i2c_quirks = { > + .max_num_msgs = MAX_MSG_NUM_MT8173, > + .max_write_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_read_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_comb_1st_msg_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_comb_2nd_msg_len = MAX_WRRD_TRANS_SIZE_MT8173, > +}; > + > static int mtk_i2c_probe(struct platform_device *pdev) > { > int ret = 0; > @@ -587,7 +626,8 @@ static int mtk_i2c_probe(struct platform_device *pdev) > return -EINVAL; > > i2c->platform_compat = mtk_get_device_prop(pdev); > - if (i2c->have_pmic && (i2c->platform_compat & COMPAT_MT6577)) > + if (i2c->have_pmic && (i2c->platform_compat & > + (COMPAT_MT6577 | COMPAT_MT8173))) > return -EINVAL; > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > @@ -613,7 +653,10 @@ static int mtk_i2c_probe(struct platform_device *pdev) > i2c->adap.dev.parent = &pdev->dev; > i2c->adap.owner = THIS_MODULE; > i2c->adap.algo = &mtk_i2c_algorithm; > - i2c->adap.quirks = &mt6577_i2c_quirks; > + if (i2c->platform_compat & COMPAT_MT8173) > + i2c->adap.quirks = &mt8173_i2c_quirks; > + else > + i2c->adap.quirks = &mt6577_i2c_quirks; Instead of putting an integer into struct of_device_id you should introduce a struct mtk_i2c_data { struct i2c_adapter_quirks quirks; int compat; /* Additional SoC specific data */ }; and put a pointer to this directly into the of_device_id. This way you need less casting and can put newly discovered differences diretly into some data struct and don't have to introduce if(socxy) ... else ... everytime. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | From mboxrd@z Thu Jan 1 00:00:00 1970 From: s.hauer@pengutronix.de (Sascha Hauer) Date: Mon, 23 Mar 2015 08:39:05 +0100 Subject: [PATCH v5 3/3] I2C: mediatek: Add driver for MediaTek MT8173 I2C controller In-Reply-To: <1426917922-61356-4-git-send-email-eddie.huang@mediatek.com> References: <1426917922-61356-1-git-send-email-eddie.huang@mediatek.com> <1426917922-61356-4-git-send-email-eddie.huang@mediatek.com> Message-ID: <20150323073905.GF9742@pengutronix.de> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org On Sat, Mar 21, 2015 at 02:05:22PM +0800, Eddie Huang wrote: > Add mediatek MT8173 I2C controller driver. Compare to I2C controller > of earlier mediatek SoC, MT8173 fix write-then-read limitation, and > also increase message size to 64kb. > [...] > +static const struct i2c_adapter_quirks mt8173_i2c_quirks = { > + .max_num_msgs = MAX_MSG_NUM_MT8173, > + .max_write_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_read_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_comb_1st_msg_len = MAX_DMA_TRANS_SIZE_MT8173, > + .max_comb_2nd_msg_len = MAX_WRRD_TRANS_SIZE_MT8173, > +}; > + > static int mtk_i2c_probe(struct platform_device *pdev) > { > int ret = 0; > @@ -587,7 +626,8 @@ static int mtk_i2c_probe(struct platform_device *pdev) > return -EINVAL; > > i2c->platform_compat = mtk_get_device_prop(pdev); > - if (i2c->have_pmic && (i2c->platform_compat & COMPAT_MT6577)) > + if (i2c->have_pmic && (i2c->platform_compat & > + (COMPAT_MT6577 | COMPAT_MT8173))) > return -EINVAL; > > res = platform_get_resource(pdev, IORESOURCE_MEM, 0); > @@ -613,7 +653,10 @@ static int mtk_i2c_probe(struct platform_device *pdev) > i2c->adap.dev.parent = &pdev->dev; > i2c->adap.owner = THIS_MODULE; > i2c->adap.algo = &mtk_i2c_algorithm; > - i2c->adap.quirks = &mt6577_i2c_quirks; > + if (i2c->platform_compat & COMPAT_MT8173) > + i2c->adap.quirks = &mt8173_i2c_quirks; > + else > + i2c->adap.quirks = &mt6577_i2c_quirks; Instead of putting an integer into struct of_device_id you should introduce a struct mtk_i2c_data { struct i2c_adapter_quirks quirks; int compat; /* Additional SoC specific data */ }; and put a pointer to this directly into the of_device_id. This way you need less casting and can put newly discovered differences diretly into some data struct and don't have to introduce if(socxy) ... else ... everytime. Sascha -- Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |