From: Hans de Goede <hdegoede@redhat.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] power: axp209: VBUS detect
Date: Sat, 21 Mar 2015 13:01:57 +0100 [thread overview]
Message-ID: <550D5DB5.3060907@redhat.com> (raw)
In-Reply-To: <1426440562-4640-1-git-send-email-contact@paulk.fr>
Hi Paul,
On 15-03-15 18:29, Paul Kocialkowski wrote:
> Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
> ---
> drivers/power/axp209.c | 13 +++++++++++++
> include/axp209.h | 3 +++
> 2 files changed, 16 insertions(+)
>
> diff --git a/drivers/power/axp209.c b/drivers/power/axp209.c
> index 4565398..11fe9d7 100644
> --- a/drivers/power/axp209.c
> +++ b/drivers/power/axp209.c
> @@ -31,6 +31,7 @@ enum axp209_reg {
> };
>
> #define AXP209_POWER_STATUS_ON_BY_DC (1 << 0)
> +#define AXP209_POWER_STATUS_VBUS_USABLE (1 << 4)
>
> #define AXP209_IRQ5_PEK_UP (1 << 6)
> #define AXP209_IRQ5_PEK_DOWN (1 << 5)
> @@ -249,3 +250,15 @@ int axp_gpio_set_value(unsigned int pin, unsigned int val)
> {
> return axp_gpio_direction_output(pin, val);
> }
> +
> +int axp_get_vbus(void)
> +{
> + u8 val;
> + int rc;
> +
> + rc = axp209_read(AXP209_POWER_STATUS, &val);
> + if (rc)
> + return rc;
> +
> + return (val & AXP209_POWER_STATUS_VBUS_USABLE) ? 1 : 0;
> +}
> diff --git a/include/axp209.h b/include/axp209.h
> index 0436249..a007958 100644
> --- a/include/axp209.h
> +++ b/include/axp209.h
> @@ -5,6 +5,7 @@
> */
>
> #define AXP_GPIO
> +#define AXP_VBUS_DETECT
>
> extern int axp209_set_dcdc2(int mvolt);
> extern int axp209_set_dcdc3(int mvolt);
> @@ -19,3 +20,5 @@ 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_get_vbus(void);
>
Thanks for this patch and for all your other sunxi u-boot patches, unfortunately
I'm afraid that I cannot take this patch as is, this stuff with all the special
axp handling is becoming too messy IMHO.
I know I started doing things this way myself, but we need to fix this and it
is better to draw a line here, and fix things right now before they become even
more messy.
What I would like to see is to have the axp vbus detect / ctrl code changed to
simply export the axp_vbus detect as a read only gpio, and vbus ctrl as a
regular gpio.
I would like to see 2 defines added to arch/arm/include/asm/arch-sunxi/gpio.h:
#define SUNXI_GPIO_AXP_VBUS_DETECT 8
#define SUNXI_GPIO_AXP_VBUS_ENABLE 9
And then in drivers/gpio/sunxi_gpio.c: sunxi_name_to_gpio() :
if (strncasecmp(name, "AXP0-", 5) == 0) {
name += 5;
if (strcmp(name, "VBUS-DETECT") == 0)
return SUNXI_GPIO_AXP0_START + SUNXI_GPIO_AXP_VBUS_DETECT;
if (strcmp(name, "VBUS-ENABLE") == 0)
return SUNXI_GPIO_AXP0_START + SUNXI_GPIO_AXP_VBUS_ENABLE;
pin = simple_strtol(name, &eptr, 10);
...
}
Where the 2 "if (strcmp(...) ..." blocks are new.
And then in drivers/power/axp221.c add gpio functions which only handle the vbus stuff
for now, e.g. :
int axp_gpio_direction_input(unsigned int pin)
{
switch (pin) {
case SUNXI_GPIO_AXP_VBUS_DETECT:
case SUNXI_GPIO_AXP_VBUS_ENABLE:
return 0;
default:
return -EINVAL;
}
}
int axp_gpio_direction_output(unsigned int pin, unsigned int val)
{
int ret;
switch (pin) {
case SUNXI_GPIO_AXP_VBUS_ENABLE:
/* Set N_VBUSEN pin to output / DRIVEBUS function */
ret = axp221_clrbits(AXP221_MISC_CTRL, AXP221_MISC_CTRL_N_VBUSEN_FUNC);
if (ret)
return ret;
return axp_gpio_set_value(pin, val);
default:
return -EINVAL;
}
}
And similar additions of axp_gpio_get_value / axp_gpio_set_value
And the remove the axp handling magic (and the includes) from
drivers/usb/musb-new/sunxi.c, only leaving regular gpio calls in there.
You may not have access to an axp221 using device, that is no problem, if
you can prepare a compile-tested (build for Ippo_q8h_v1_2_defconfig) patch-set
with this cleanup then I can test it and fix it up if necessary.
And then on top of this cleanup you can add axp209 vbus detect support
extending the existing axp209 gpio functions.
Regards,
Hans
prev parent reply other threads:[~2015-03-21 12:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-15 17:29 [U-Boot] [PATCH 1/2] power: axp209: VBUS detect Paul Kocialkowski
2015-03-15 17:29 ` [U-Boot] [PATCH 2/2] sunxi: Ainol AW1 support Paul Kocialkowski
2015-03-21 12:03 ` Hans de Goede
2015-03-21 12:01 ` Hans de Goede [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=550D5DB5.3060907@redhat.com \
--to=hdegoede@redhat.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox