[U-Boot] [PATCH 10/21] sunxi: gpio: Change axp_gpio_foo prototype to match gpio uclass ops
Simon Glass
sjg at chromium.org
Sat Apr 25 01:24:18 CEST 2015
Hi Hans,
On 24 April 2015 at 07:48, Hans de Goede <hdegoede at redhat.com> wrote:
> Change the axp_gpio_foo function prototypes to match the gpio uclass op
> prototypes, so that they can be used directly when adding device-model
> support for the axp gpios.
>
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>
> ---
> drivers/gpio/sunxi_gpio.c | 8 ++++----
> drivers/power/axp209.c | 10 +++++-----
> drivers/power/axp221.c | 10 +++++-----
> include/axp209.h | 10 ++++++----
> include/axp221.h | 10 ++++++----
> 5 files changed, 26 insertions(+), 22 deletions(-)
This AXP think should be a separate GPIO driver.
>
> diff --git a/drivers/gpio/sunxi_gpio.c b/drivers/gpio/sunxi_gpio.c
> index 91af1a5..0774b70 100644
> --- a/drivers/gpio/sunxi_gpio.c
> +++ b/drivers/gpio/sunxi_gpio.c
> @@ -81,7 +81,7 @@ int gpio_direction_input(unsigned gpio)
> {
> #ifdef AXP_GPIO
> if (gpio >= SUNXI_GPIO_AXP0_START)
> - return axp_gpio_direction_input(gpio - SUNXI_GPIO_AXP0_START);
> + return axp_gpio_direction_input(NULL, gpio - SUNXI_GPIO_AXP0_START);
> #endif
> sunxi_gpio_set_cfgpin(gpio, SUNXI_GPIO_INPUT);
>
> @@ -92,7 +92,7 @@ int gpio_direction_output(unsigned gpio, int value)
> {
> #ifdef AXP_GPIO
> if (gpio >= SUNXI_GPIO_AXP0_START)
> - return axp_gpio_direction_output(gpio - SUNXI_GPIO_AXP0_START,
> + return axp_gpio_direction_output(NULL, gpio - SUNXI_GPIO_AXP0_START,
> value);
> #endif
> sunxi_gpio_set_cfgpin(gpio, SUNXI_GPIO_OUTPUT);
> @@ -104,7 +104,7 @@ int gpio_get_value(unsigned gpio)
> {
> #ifdef AXP_GPIO
> if (gpio >= SUNXI_GPIO_AXP0_START)
> - return axp_gpio_get_value(gpio - SUNXI_GPIO_AXP0_START);
> + return axp_gpio_get_value(NULL, gpio - SUNXI_GPIO_AXP0_START);
> #endif
> return sunxi_gpio_input(gpio);
> }
> @@ -113,7 +113,7 @@ int gpio_set_value(unsigned gpio, int value)
> {
> #ifdef AXP_GPIO
> if (gpio >= SUNXI_GPIO_AXP0_START)
> - return axp_gpio_set_value(gpio - SUNXI_GPIO_AXP0_START, value);
> + return axp_gpio_set_value(NULL, gpio - SUNXI_GPIO_AXP0_START, value);
> #endif
> return sunxi_gpio_output(gpio, value);
> }
> diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c
> index 1d7be49..98c214f 100644
> --- a/drivers/power/axp209.c
> +++ b/drivers/power/axp209.c
> @@ -167,7 +167,7 @@ static u8 axp209_get_gpio_ctrl_reg(unsigned int pin)
> return 0;
> }
>
> -int axp_gpio_direction_input(unsigned int pin)
> +int axp_gpio_direction_input(struct udevice *dev, unsigned pin)
> {
> if (pin == SUNXI_GPIO_AXP0_VBUS_DETECT)
> return 0;
> @@ -179,7 +179,7 @@ int axp_gpio_direction_input(unsigned int pin)
> return axp209_write(reg, val);
> }
>
> -int axp_gpio_direction_output(unsigned int pin, unsigned int val)
> +int axp_gpio_direction_output(struct udevice *dev, unsigned pin, int val)
> {
> u8 reg = axp209_get_gpio_ctrl_reg(pin);
>
> @@ -194,7 +194,7 @@ int axp_gpio_direction_output(unsigned int pin, unsigned int val)
> return axp209_write(reg, val);
> }
>
> -int axp_gpio_get_value(unsigned int pin)
> +int axp_gpio_get_value(struct udevice *dev, unsigned pin)
> {
> u8 val, mask;
> int rc;
> @@ -215,7 +215,7 @@ int axp_gpio_get_value(unsigned int pin)
> return (val & mask) ? 1 : 0;
> }
>
> -int axp_gpio_set_value(unsigned int pin, unsigned int val)
> +int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val)
> {
> - return axp_gpio_direction_output(pin, val);
> + return axp_gpio_direction_output(dev, pin, val);
> }
> diff --git a/drivers/power/axp221.c b/drivers/power/axp221.c
> index dc3a7f1..4970ab4 100644
> --- a/drivers/power/axp221.c
> +++ b/drivers/power/axp221.c
> @@ -386,7 +386,7 @@ int axp221_get_sid(unsigned int *sid)
> return 0;
> }
>
> -int axp_gpio_direction_input(unsigned int pin)
> +int axp_gpio_direction_input(struct udevice *dev, unsigned pin)
> {
> switch (pin) {
> case SUNXI_GPIO_AXP0_VBUS_DETECT:
> @@ -396,7 +396,7 @@ int axp_gpio_direction_input(unsigned int pin)
> }
> }
>
> -int axp_gpio_direction_output(unsigned int pin, unsigned int val)
> +int axp_gpio_direction_output(struct udevice *dev, unsigned pin, int val)
> {
> int ret;
>
> @@ -407,13 +407,13 @@ int axp_gpio_direction_output(unsigned int pin, unsigned int val)
> if (ret)
> return ret;
>
> - return axp_gpio_set_value(pin, val);
> + return axp_gpio_set_value(dev, pin, val);
> default:
> return -EINVAL;
> }
> }
>
> -int axp_gpio_get_value(unsigned int pin)
> +int axp_gpio_get_value(struct udevice *dev, unsigned pin)
> {
> int ret;
> u8 val;
> @@ -430,7 +430,7 @@ int axp_gpio_get_value(unsigned int pin)
> }
> }
>
> -int axp_gpio_set_value(unsigned int pin, unsigned int val)
> +int axp_gpio_set_value(struct udevice *dev, unsigned pin, int val)
> {
> int ret;
>
> diff --git a/include/axp209.h b/include/axp209.h
> index d36da41..fe4a169 100644
> --- a/include/axp209.h
> +++ b/include/axp209.h
> @@ -4,6 +4,8 @@
> * SPDX-License-Identifier: GPL-2.0+
> */
>
> +struct udevice;
> +
> enum axp209_reg {
> AXP209_POWER_STATUS = 0x00,
> AXP209_CHIP_VERSION = 0x03,
> @@ -53,7 +55,7 @@ extern int axp209_init(void);
> extern int axp209_poweron_by_dc(void);
> extern int axp209_power_button(void);
>
> -extern int axp_gpio_direction_input(unsigned int pin);
> -extern int axp_gpio_direction_output(unsigned int pin, unsigned int val);
> -extern int axp_gpio_get_value(unsigned int pin);
> -extern int axp_gpio_set_value(unsigned int pin, unsigned int val);
> +extern int axp_gpio_direction_input(struct udevice *dev, unsigned offset);
> +extern int axp_gpio_direction_output(struct udevice *dev, unsigned offset, int val);
> +extern int axp_gpio_get_value(struct udevice *dev, unsigned offset);
> +extern int axp_gpio_set_value(struct udevice *dev, unsigned offset, int val);
> diff --git a/include/axp221.h b/include/axp221.h
> index 0aac04d..e826ca8 100644
> --- a/include/axp221.h
> +++ b/include/axp221.h
> @@ -6,6 +6,8 @@
> * SPDX-License-Identifier: GPL-2.0+
> */
>
> +struct udevice;
> +
> #define AXP221_CHIP_ADDR 0x68
> #define AXP221_CTRL_ADDR 0x3e
> #define AXP221_INIT_DATA 0x3e
> @@ -80,7 +82,7 @@ int axp221_set_eldo(int eldo_num, unsigned int mvolt);
> int axp221_init(void);
> int axp221_get_sid(unsigned int *sid);
>
> -int axp_gpio_direction_input(unsigned int pin);
> -int axp_gpio_direction_output(unsigned int pin, unsigned int val);
> -int axp_gpio_get_value(unsigned int pin);
> -int axp_gpio_set_value(unsigned int pin, unsigned int val);
> +int axp_gpio_direction_input(struct udevice *dev, unsigned offset);
> +int axp_gpio_direction_output(struct udevice *dev, unsigned offset, int val);
> +int axp_gpio_get_value(struct udevice *dev, unsigned offset);
> +int axp_gpio_set_value(struct udevice *dev, unsigned offset, int val);
> --
> 2.3.5
>
Regards,
Simon
More information about the U-Boot
mailing list