gpio: pca953x_gpio: Fix style violations
PATCH RESEND v2 1/7 gpio: pca953x_gpio: Fix style violations
Fix some style violations in the pca953x_gpio driver.
---
v1 -> v2:
None
--- drivers/gpio/pca953x_gpio.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-)
drivers/gpio/pca953x_gpio.c +9 -10
@@ -123,7 +123,8 @@ static int pca953x_read_regs(struct udevice *dev, int reg, u8 *val) ret =dm_i2c_read (dev, reg <<1 , val, info->bank_count); }else if (info->gpio_count ==40 ) {/* Auto increment */ - ret =dm_i2c_read (dev, (reg <<3 ) |0x80 , val, info->bank_count); + ret =dm_i2c_read (dev, (reg <<3 ) |0x80 , val, + info->bank_count); }else {dev_err (dev,"Unsupported now\n" );return -EINVAL ;
@@ -143,7 +144,7 @@ static int pca953x_is_output(struct udevice *dev, int offset)return !(info->reg_direction[bank] & (1 << off)); } -static int pca953x_get_value (struct udevice *dev,unsigned offset) +static int pca953x_get_value (struct udevice *dev,uint offset) {int ret;u8 val =0 ;
@@ -157,8 +158,7 @@ static int pca953x_get_value(struct udevice *dev, unsigned offset)return (val >> off) &0x1 ; } -static int pca953x_set_value (struct udevice *dev,unsigned offset, -int value) +static int pca953x_set_value (struct udevice *dev,uint offset,int value) {struct pca953x_info *info =dev_get_platdata (dev);int bank = offset /BANK_SZ ;
@@ -180,7 +180,7 @@ static int pca953x_set_value(struct udevice *dev, unsigned offset,return 0 ; } -static int pca953x_set_direction (struct udevice *dev,unsigned offset,int dir) +static int pca953x_set_direction (struct udevice *dev,uint offset,int dir) {struct pca953x_info *info =dev_get_platdata (dev);int bank = offset /BANK_SZ ;
@@ -202,13 +202,12 @@ static int pca953x_set_direction(struct udevice *dev, unsigned offset, int dir)return 0 ; } -static int pca953x_direction_input (struct udevice *dev,unsigned offset) +static int pca953x_direction_input (struct udevice *dev,uint offset) {return pca953x_set_direction (dev, offset,PCA953X_DIRECTION_IN ); } -static int pca953x_direction_output (struct udevice *dev,unsigned offset, -int value) +static int pca953x_direction_output (struct udevice *dev,uint offset,int value) {/* Configure output value. */ pca953x_set_value (dev, offset, value);
@@ -219,7 +218,7 @@ static int pca953x_direction_output(struct udevice *dev, unsigned offset,return 0 ; } -static int pca953x_get_function (struct udevice *dev,unsigned offset) +static int pca953x_get_function (struct udevice *dev,uint offset) {if (pca953x_is_output (dev, offset))return GPIOF_OUTPUT ;
@@ -231,7 +230,7 @@ static int pca953x_xlate(struct udevice *dev, struct gpio_desc *desc, struct ofnode_phandle_args *args) { desc->offset = args->args[0 ]; - desc->flags = args->args[1 ] &GPIO_ACTIVE_LOW ?GPIOD_ACTIVE_LOW :0 ; + desc->flags = args->args[1 ] & (GPIO_ACTIVE_LOW ?GPIOD_ACTIVE_LOW :0 );return 0 ; }
--
2.11.0
PATCH RESEND v2 2/7 gpio: pca953x_gpio: Make live-tree compatible
Make the pca953x_gpio driver compatible with a live device tree.
---
v1 -> v2:
None
--- drivers/gpio/pca953x_gpio.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/gpio/pca953x_gpio.c +1 -3
@@ -50,8 +50,6 @@ enum {#define MAX_BANK 5#define BANK_SZ 8 -DECLARE_GLOBAL_DATA_PTR ; -/* * struct pca953x_info - Data for pca953x *
@@ -253,7 +251,7 @@ static int pca953x_probe(struct udevice *dev)ulong driver_data;int ret; - addr =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev),"reg" ,0 ); + addr =dev_read_addr (dev);if (addr ==0 )return -ENODEV ;
--
2.11.0
PATCH RESEND v2 2/7 gpio: pca953x_gpio: Make live-tree compatible
Quoted 4 lines · Mario Six
Make the
pca953x_gpiodriver compatible with a live device tree.Reviewed-by Simon Glass <[email protected]>Signed-off-by Mario Six <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/9f5ed190/attachment.sig>
PATCH RESEND v2 3/7 gpio: mpc85xx_gpio: Fix style violations
In reply to Mario SixFix some style violations in the MPC85XX GPIO driver.
---
v1 -> v2:
None
--- drivers/gpio/mpc85xx_gpio.c | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-)
drivers/gpio/mpc85xx_gpio.c +22 -20
@@ -34,11 +34,13 @@ struct mpc85xx_gpio_data {uint gpio_count;/* The GPDAT register cannot be used to determine the value of output * pins on MPC8572/MPC8536, so we shadow it and use the shadowed value -* for output pins */ +* for output pins +*/ u32 dat_shadow; }; -inline u32 gpio_mask (unsigned gpio) { +inline u32 gpio_mask (uint gpio) +{return (1U << (31 - (gpio))); }
@@ -92,7 +94,7 @@ static inline void mpc85xx_gpio_open_drain_off(struct ccsr_gpio *base,clrbits_be32 (&base->gpodr, gpios); } -static int mpc85xx_gpio_direction_input (struct udevice *dev,unsigned gpio) +static int mpc85xx_gpio_direction_input (struct udevice *dev,uint gpio) {struct mpc85xx_gpio_data *data =dev_get_priv (dev);
@@ -100,8 +102,7 @@ static int mpc85xx_gpio_direction_input(struct udevice *dev, unsigned gpio)return 0 ; } -static int mpc85xx_gpio_set_value (struct udevice *dev,unsigned gpio, -int value) +static int mpc85xx_gpio_set_value (struct udevice *dev,uint gpio,int value) {struct mpc85xx_gpio_data *data =dev_get_priv (dev);
@@ -115,46 +116,46 @@ static int mpc85xx_gpio_set_value(struct udevice *dev, unsigned gpio,return 0 ; } -static int mpc85xx_gpio_direction_output (struct udevice *dev,unsigned gpio, +static int mpc85xx_gpio_direction_output (struct udevice *dev,uint gpio,int value) {return mpc85xx_gpio_set_value (dev, gpio, value); } -static int mpc85xx_gpio_get_value (struct udevice *dev,unsigned gpio) +static int mpc85xx_gpio_get_value (struct udevice *dev,uint gpio) {struct mpc85xx_gpio_data *data =dev_get_priv (dev);if (!!mpc85xx_gpio_get_dir (data->base,gpio_mask (gpio))) {/* Output -> use shadowed value */ return !!(data->dat_shadow &gpio_mask (gpio)); - }else { -/* Input -> read value from GPDAT register */ -return !!mpc85xx_gpio_get_val (data->base,gpio_mask (gpio)); } + +/* Input -> read value from GPDAT register */ +return !!mpc85xx_gpio_get_val (data->base,gpio_mask (gpio)); } -static int mpc85xx_gpio_get_open_drain (struct udevice *dev,unsigned gpio) +static int mpc85xx_gpio_get_open_drain (struct udevice *dev,uint gpio) {struct mpc85xx_gpio_data *data =dev_get_priv (dev);return !!mpc85xx_gpio_open_drain_val (data->base,gpio_mask (gpio)); } -static int mpc85xx_gpio_set_open_drain (struct udevice *dev,unsigned gpio, +static int mpc85xx_gpio_set_open_drain (struct udevice *dev,uint gpio,int value) {struct mpc85xx_gpio_data *data =dev_get_priv (dev); -if (value) { +if (value)mpc85xx_gpio_open_drain_on (data->base,gpio_mask (gpio)); - }else { +else mpc85xx_gpio_open_drain_off (data->base,gpio_mask (gpio)); - } +return 0 ; } -static int mpc85xx_gpio_get_function (struct udevice *dev,unsigned gpio) +static int mpc85xx_gpio_get_function (struct udevice *dev,uint gpio) {struct mpc85xx_gpio_data *data =dev_get_priv (dev);int dir;
@@ -164,14 +165,15 @@ static int mpc85xx_gpio_get_function(struct udevice *dev, unsigned gpio) }#if CONFIG_IS_ENABLED (OF_CONTROL ) -static int mpc85xx_gpio_ofdata_to_platdata (struct udevice *dev) { +static int mpc85xx_gpio_ofdata_to_platdata (struct udevice *dev) +{struct mpc85xx_gpio_plat *plat =dev_get_platdata (dev);fdt_addr_t addr;fdt_size_t size; addr =fdtdec_get_addr_size_auto_noparent (gd->fdt_blob, -dev_of_offset (dev),"reg" ,0 , &size, false); - +dev_of_offset (dev), +"reg" ,0 , &size, false); plat->addr = addr; plat->size = size; plat->ngpios = fdtdec_get_int(gd->fdt_blob, dev_of_offset(dev),
@@ -229,7 +231,7 @@ static const struct dm_gpio_ops gpio_mpc85xx_ops = { .set_value = mpc85xx_gpio_set_value, .get_open_drain = mpc85xx_gpio_get_open_drain, .set_open_drain = mpc85xx_gpio_set_open_drain, - .get_function = mpc85xx_gpio_get_function, + .get_function = mpc85xx_gpio_get_function, };static const struct udevice_id mpc85xx_gpio_ids[] = {
--
2.11.0
PATCH RESEND v2 3/7 gpio: mpc85xx_gpio: Fix style violations
Quoted 3 lines · Mario Six
Fix some style violations in the MPC85XX GPIO driver.
Signed-off-by Mario Six <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/a2bf49b9/attachment.sig>
PATCH RESEND v2 4/7 gpio: mpc85xx: Rename driver file to mpc8xxx
In reply to Mario SixIn preparation to making the MPC85xx GPIO driver useable for a broader range of SoCs, rename the driver file.
---
v1 -> v2:
None
---
drivers/gpio/Makefile | 2 +-
drivers/gpio/{mpc85xx_gpio.c => mpc8xxx_gpio.c} | 0
2 files changed, 1 insertion(+), 1 deletion(-)
rename drivers/gpio/{mpc85xx_gpio.c => mpc8xxx_gpio.c} (100%)drivers/gpio/Makefile +1 -1
@@ -38,7 +38,7 @@ obj-$(CONFIG_DA8XX_GPIO) += da8xx_gpio.o obj-$(CONFIG_DM644X_GPIO) += da8xx_gpio.o obj-$(CONFIG_ALTERA_PIO) += altera_pio.o obj-$(CONFIG_MPC83XX_GPIO) += mpc83xx_gpio.o -obj-$(CONFIG_MPC85XX_GPIO) += mpc85xx_gpio.o +obj-$(CONFIG_MPC85XX_GPIO) += mpc8xxx_gpio.o obj-$(CONFIG_SH_GPIO_PFC) += sh_pfc.o obj-$(CONFIG_OMAP_GPIO) += omap_gpio.o obj-$(CONFIG_DB8500_GPIO) += db8500_gpio.o
drivers/gpio/mpc8xxx_gpio.c renamed from drivers/gpio/mpc85xx_gpio.c +0 -0
--
2.11.0
PATCH RESEND v2 4/7 gpio: mpc85xx: Rename driver file to mpc8xxx
Quoted 4 lines · Mario Six
In preparation to making the MPC85xx GPIO driver useable for a broader range of SoCs, rename the driver file.
Signed-off-by Mario Six <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/b688dfc0/attachment.sig>
PATCH RESEND v2 5/7 gpio: mpc8xxx: Rename Kconfig option, structures, and functions
In reply to Mario SixRename the Kconfig option, structures (and their members), as well as functions of the mpc85xx driver to include mpc8xxx to reflect the more generic usage.
---
v1 -> v2:
None
--- arch/powerpc/include/asm/arch-mpc85xx/gpio.h | 2 +- drivers/gpio/Kconfig | 9 +-- drivers/gpio/Makefile | 2 +- drivers/gpio/mpc8xxx_gpio.c | 116 ++++++++++++++------------- 4 files changed, 64 insertions(+), 65 deletions(-)
arch/powerpc/include/asm/arch-mpc85xx/gpio.h +1 -1
@@ -18,7 +18,7 @@#include <asm/mpc85xx_gpio.h> #endif -struct mpc85xx_gpio_plat { +struct mpc8xxx_gpio_plat {ulong addr;unsigned long size;uint ngpios;
drivers/gpio/Kconfig +3 -6
@@ -276,11 +276,11 @@ config DM_PCA953X Now, max 24 bits chips and PCA953X compatible chips are supported -config MPC85XX_GPIO - bool "Freescale MPC85XX GPIO driver" +config MPC8XXX_GPIO + bool "Freescale MPC8XXX GPIO driver" depends on DM_GPIO help - This driver supports the built-in GPIO controller of MPC85XX CPUs. + This driver supports the built-in GPIO controller of MPC8XXX CPUs. Each GPIO bank is identified by its own entry in the device tree, i.e.
@@ -298,7 +298,4 @@ config MPC85XX_GPIO Aside from the standard functions of input/output mode, and output value setting, the open-drain feature, which can configure individual GPIOs to work as open-drain outputs, is supported. - - The driver has been tested on MPC85XX, but it is likely that other - PowerQUICC III devices will work as well. endmenu
drivers/gpio/Makefile +1 -1
@@ -38,7 +38,7 @@ obj-$(CONFIG_DA8XX_GPIO) += da8xx_gpio.o obj-$(CONFIG_DM644X_GPIO) += da8xx_gpio.o obj-$(CONFIG_ALTERA_PIO) += altera_pio.o obj-$(CONFIG_MPC83XX_GPIO) += mpc83xx_gpio.o -obj-$(CONFIG_MPC85XX_GPIO) += mpc8xxx_gpio.o +obj-$(CONFIG_MPC8XXX_GPIO) += mpc8xxx_gpio.o obj-$(CONFIG_SH_GPIO_PFC) += sh_pfc.o obj-$(CONFIG_OMAP_GPIO) += omap_gpio.o obj-$(CONFIG_DB8500_GPIO) += db8500_gpio.o
drivers/gpio/mpc8xxx_gpio.c +59 -57
252 lines not on this page · raw message
--
2.11.0
PATCH RESEND v2 5/7 gpio: mpc8xxx: Rename Kconfig option, structures, and functions
Quoted 5 lines · Mario Six
Rename the
Kconfigoption, structures (and their members), as well as functions of the mpc85xx driver to include mpc8xxx to reflect the more generic usage.Signed-off-by Mario Six <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/89540bac/attachment.sig>
PATCH RESEND v2 6/7 gpio: mpc8xxx: Make compatible with more SoCs
In reply to Mario SixFinally, make the mpc8xxx driver capable of handling more GPIO devices; this entails adding a special case for the MPC5121 SoC, and adding a set of new compatible strings.
---
v1 -> v2:
None
--- drivers/gpio/mpc8xxx_gpio.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/gpio/mpc8xxx_gpio.c +21 -2
@@ -11,8 +11,8 @@#include <common.h> #include <dm.h> -#include <asm/gpio.h> #include <mapmem.h> +#include <asm/gpio.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -37,6 +37,12 @@ struct mpc8xxx_gpio_data {* for output pins */ u32 dat_shadow; +ulong type; +}; + +enum { +MPC8XXX_GPIO_TYPE , +MPC5121_GPIO_TYPE , };inline u32 gpio_mask (uint gpio)
@@ -119,6 +125,12 @@ static int mpc8xxx_gpio_set_value(struct udevice *dev, uint gpio, int value)static int mpc8xxx_gpio_direction_output (struct udevice *dev,uint gpio,int value) { +struct mpc8xxx_gpio_data *data =dev_get_priv (dev); + +/* GPIO 28..31 are input only on MPC5121 */ +if (data->type ==MPC5121_GPIO_TYPE && gpio >=28 ) +return -EINVAL ; +return mpc8xxx_gpio_set_value (dev, gpio, value); }
@@ -188,6 +200,7 @@ static int mpc8xxx_gpio_platdata_to_priv(struct udevice *dev)struct mpc8xxx_gpio_data *priv =dev_get_priv (dev);struct mpc8xxx_gpio_plat *plat =dev_get_platdata (dev);unsigned long size = plat->size; +ulong driver_data =dev_get_driver_data (dev);if (size ==0 ) size =0x100 ;
@@ -237,7 +250,13 @@ static const struct dm_gpio_ops gpio_mpc8xxx_ops = { };static const struct udevice_id mpc8xxx_gpio_ids[] = { - { .compatible ="fsl,pq3-gpio" }, + { .compatible ="fsl,pq3-gpio" , .data =MPC8XXX_GPIO_TYPE }, + { .compatible ="fsl,mpc8308-gpio" , .data =MPC8XXX_GPIO_TYPE }, + { .compatible ="fsl,mpc8349-gpio" , .data =MPC8XXX_GPIO_TYPE }, + { .compatible ="fsl,mpc8572-gpio" , .data =MPC8XXX_GPIO_TYPE }, + { .compatible ="fsl,mpc8610-gpio" , .data =MPC8XXX_GPIO_TYPE }, + { .compatible ="fsl,mpc5121-gpio" , .data =MPC5121_GPIO_TYPE , }, + { .compatible ="fsl,qoriq-gpio" , .data =MPC8XXX_GPIO_TYPE }, {/* sentinel */ } };
--
2.11.0
PATCH RESEND v2 6/7 gpio: mpc8xxx: Make compatible with more SoCs
Quoted 5 lines · Mario Six
Finally, make the mpc8xxx driver capable of handling more GPIO devices; this entails adding a special case for the MPC5121 SoC, and adding a set of new compatible strings.
Signed-off-by Mario Six <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/3ada09c7/attachment.sig>
PATCH RESEND v2 7/7 gpio: mpc8xxx: Make live-tree compatible
In reply to Mario SixMake the MPC8xxx GPIO driver compatible with a live device tree.
---
v1 -> v2:
None
--- drivers/gpio/mpc8xxx_gpio.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpio/mpc8xxx_gpio.c +7 -10
@@ -14,8 +14,6 @@#include <mapmem.h> #include <asm/gpio.h> -DECLARE_GLOBAL_DATA_PTR ; -struct ccsr_gpio {u32 gpdir;u32 gpodr;
@@ -181,15 +179,14 @@ static int mpc8xxx_gpio_ofdata_to_platdata(struct udevice *dev) {struct mpc8xxx_gpio_plat *plat =dev_get_platdata (dev);fdt_addr_t addr; -fdt_size_t size; +u32 reg[2 ]; + +dev_read_u32_array (dev,"reg" , reg,2 ); + addr =dev_translate_address (dev, reg); - addr =fdtdec_get_addr_size_auto_noparent (gd->fdt_blob, -dev_of_offset (dev), -"reg" ,0 , &size, false); plat->addr = addr; - plat->size = size; - plat->ngpios =fdtdec_get_int (gd->fdt_blob,dev_of_offset (dev), -"ngpios" ,32 ); + plat->size = reg[1 ]; + plat->ngpios =dev_read_u32_default (dev,"ngpios" ,32 );return 0 ; }
@@ -206,7 +203,7 @@ static int mpc8xxx_gpio_platdata_to_priv(struct udevice *dev) size =0x100 ; priv->addr = plat->addr; - priv->base =map_sysmem (CONFIG_SYS_IMMR + plat->addr, size); + priv->base =map_sysmem (plat->addr, size);if (!priv->base)return -ENOMEM ;
--
2.11.0
PATCH RESEND v2 7/7 gpio: mpc8xxx: Make live-tree compatible
Quoted 3 lines · Mario Six
Make the MPC8xxx GPIO driver compatible with a live device tree.
Signed-off-by Mario Six <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/4d9d12fa/attachment.sig>
PATCH RESEND v2 1/7 gpio: pca953x_gpio: Fix style violations
In reply to Mario SixQuoted 3 lines · Mario Six
Fix some style violations in the
pca953x_gpiodriver.Signed-off-by Mario Six <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180128/0ff40ee4/attachment.sig>