* pinctrl: mediatek: questions about gpio/pinctrl/eint
@ 2016-01-28 2:35 ` biao huang
0 siblings, 0 replies; 4+ messages in thread
From: biao huang @ 2016-01-28 2:35 UTC (permalink / raw)
To: Linus Walleij
Cc: linux-mediatek, linux-gpio, linux-arm-kernel, Yingjoe Chen,
Hongzhou Yang
Hi Linus,
We have two questions associate with mediatek pinctrl/gpio in linux
kernel to asking for your help.
First, when user call GPIO API to control medaitek gpio, they should
call pinctrl API to set pinmux to mode 0 ahead, so this pin is function
as gpio. And this makes things a little complicated. Is there any simple
API can solve this problem? How about add pinmux setting in
gpio_request?
Second, here is our request_irq flow in mkd eint driver:
request_irq --> mtk_pinctrl_irq_request_resources--> mtk_pmx_set_mode,
Normally, it'll set pinmux to eint mode (usually is mode 0) in
mtk_pmx_set_mode function. But for special case, such as iddig (connect
to usb), when iddig request_irq, it should set pinmux to iddig mode
(mode 2 in mt8163).
Is there a better way than changing
MTK_PIN(
PINCTRL_PIN(16, "IDDIG"),
NULL, "mt8173",
MTK_EINT_FUNCTION(0, 16),
MTK_FUNCTION(0, "GPIO16"),
MTK_FUNCTION(1, "IDDIG"),
MTK_FUNCTION(2, "CMFLASH"),
MTK_FUNCTION(4, "PWM5")
),
to
MTK_PIN(
PINCTRL_PIN(16, "IDDIG"),
NULL, "mt8173",
MTK_EINT_FUNCTION(2, 16),
MTK_FUNCTION(0, "GPIO16"),
MTK_FUNCTION(1, "IDDIG"),
MTK_FUNCTION(2, "CMFLASH"),
MTK_FUNCTION(4, "PWM5")
),
in drivers/pinctrl/mediatek/pinctrl-mtk-mt8163.h?
We are looking forward for your help, thanks very much!
Best Regards!
Yours,
Biao Huang
^ permalink raw reply [flat|nested] 4+ messages in thread
* pinctrl: mediatek: questions about gpio/pinctrl/eint
@ 2016-01-28 2:35 ` biao huang
0 siblings, 0 replies; 4+ messages in thread
From: biao huang @ 2016-01-28 2:35 UTC (permalink / raw)
To: linux-arm-kernel
Hi Linus,
We have two questions associate with mediatek pinctrl/gpio in linux
kernel to asking for your help.
First, when user call GPIO API to control medaitek gpio, they should
call pinctrl API to set pinmux to mode 0 ahead, so this pin is function
as gpio. And this makes things a little complicated. Is there any simple
API can solve this problem? How about add pinmux setting in
gpio_request?
Second, here is our request_irq flow in mkd eint driver:
request_irq --> mtk_pinctrl_irq_request_resources--> mtk_pmx_set_mode,
Normally, it'll set pinmux to eint mode (usually is mode 0) in
mtk_pmx_set_mode function. But for special case, such as iddig (connect
to usb), when iddig request_irq, it should set pinmux to iddig mode
(mode 2 in mt8163).
Is there a better way than changing
MTK_PIN(
PINCTRL_PIN(16, "IDDIG"),
NULL, "mt8173",
MTK_EINT_FUNCTION(0, 16),
MTK_FUNCTION(0, "GPIO16"),
MTK_FUNCTION(1, "IDDIG"),
MTK_FUNCTION(2, "CMFLASH"),
MTK_FUNCTION(4, "PWM5")
),
to
MTK_PIN(
PINCTRL_PIN(16, "IDDIG"),
NULL, "mt8173",
MTK_EINT_FUNCTION(2, 16),
MTK_FUNCTION(0, "GPIO16"),
MTK_FUNCTION(1, "IDDIG"),
MTK_FUNCTION(2, "CMFLASH"),
MTK_FUNCTION(4, "PWM5")
),
in drivers/pinctrl/mediatek/pinctrl-mtk-mt8163.h?
We are looking forward for your help, thanks very much!
Best Regards!
Yours,
Biao Huang
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: pinctrl: mediatek: questions about gpio/pinctrl/eint
2016-01-28 2:35 ` biao huang
@ 2016-01-28 11:22 ` Linus Walleij
-1 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2016-01-28 11:22 UTC (permalink / raw)
To: biao huang
Cc: moderated list:ARM/Mediatek SoC support, linux-gpio,
linux-arm-kernel, Yingjoe Chen, Hongzhou Yang
On Thu, Jan 28, 2016 at 3:35 AM, biao huang <biao.huang@mediatek.com> wrote:
> First, when user call GPIO API to control medaitek gpio, they should
> call pinctrl API to set pinmux to mode 0 ahead, so this pin is function
> as gpio. And this makes things a little complicated. Is there any simple
> API can solve this problem? How about add pinmux setting in
> gpio_request?
This is what the
pinctrl_request_gpio, pinctrl_free_gpio, pinctrl_gpio_direction_input
andpinctrl_gpio_direction_output calls are for.
Look for example in drivers/gpio/gpio-pl061.c:
if (of_property_read_bool(dev->of_node, "gpio-ranges")) {
chip->gc.request = gpiochip_generic_request;
chip->gc.free = gpiochip_generic_free;
}
What does that do:
/**
* gpiochip_generic_request() - request the gpio function for a pin
* @chip: the gpiochip owning the GPIO
* @offset: the offset of the GPIO to request for GPIO function
*/
int gpiochip_generic_request(struct gpio_chip *chip, unsigned offset)
{
return pinctrl_request_gpio(chip->base + offset);
}
EXPORT_SYMBOL_GPL(gpiochip_generic_request);
/**
* gpiochip_generic_free() - free the gpio function from a pin
* @chip: the gpiochip to request the gpio function for
* @offset: the offset of the GPIO to free from GPIO function
*/
void gpiochip_generic_free(struct gpio_chip *chip, unsigned offset)
{
pinctrl_free_gpio(chip->base + offset);
}
EXPORT_SYMBOL_GPL(gpiochip_generic_free);
Yes....
Your pinctrl driver needs to implement the
.gpio_request_enable()
.gpio_disable_free()
.gpio_set_direction()
callbacks in struct pinmux_ops.
Also read in Documentation/pinctrl.txt about pinctrl/GPIO interaction.
> Second, here is our request_irq flow in mkd eint driver:
> request_irq --> mtk_pinctrl_irq_request_resources--> mtk_pmx_set_mode,
> Normally, it'll set pinmux to eint mode (usually is mode 0) in
> mtk_pmx_set_mode function. But for special case, such as iddig (connect
> to usb), when iddig request_irq, it should set pinmux to iddig mode
> (mode 2 in mt8163).
> Is there a better way than changing
> MTK_PIN(
> PINCTRL_PIN(16, "IDDIG"),
> NULL, "mt8173",
> MTK_EINT_FUNCTION(0, 16),
> MTK_FUNCTION(0, "GPIO16"),
> MTK_FUNCTION(1, "IDDIG"),
> MTK_FUNCTION(2, "CMFLASH"),
> MTK_FUNCTION(4, "PWM5")
> ),
> to
> MTK_PIN(
> PINCTRL_PIN(16, "IDDIG"),
> NULL, "mt8173",
> MTK_EINT_FUNCTION(2, 16),
> MTK_FUNCTION(0, "GPIO16"),
> MTK_FUNCTION(1, "IDDIG"),
> MTK_FUNCTION(2, "CMFLASH"),
> MTK_FUNCTION(4, "PWM5")
> ),
> in drivers/pinctrl/mediatek/pinctrl-mtk-mt8163.h?
This is the mediatek driver internals, I don't understand that.
Your guess is as good as mine, ask help from the other
driver authors is my hint, I can only help with the framework...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* pinctrl: mediatek: questions about gpio/pinctrl/eint
@ 2016-01-28 11:22 ` Linus Walleij
0 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2016-01-28 11:22 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Jan 28, 2016 at 3:35 AM, biao huang <biao.huang@mediatek.com> wrote:
> First, when user call GPIO API to control medaitek gpio, they should
> call pinctrl API to set pinmux to mode 0 ahead, so this pin is function
> as gpio. And this makes things a little complicated. Is there any simple
> API can solve this problem? How about add pinmux setting in
> gpio_request?
This is what the
pinctrl_request_gpio, pinctrl_free_gpio, pinctrl_gpio_direction_input
andpinctrl_gpio_direction_output calls are for.
Look for example in drivers/gpio/gpio-pl061.c:
if (of_property_read_bool(dev->of_node, "gpio-ranges")) {
chip->gc.request = gpiochip_generic_request;
chip->gc.free = gpiochip_generic_free;
}
What does that do:
/**
* gpiochip_generic_request() - request the gpio function for a pin
* @chip: the gpiochip owning the GPIO
* @offset: the offset of the GPIO to request for GPIO function
*/
int gpiochip_generic_request(struct gpio_chip *chip, unsigned offset)
{
return pinctrl_request_gpio(chip->base + offset);
}
EXPORT_SYMBOL_GPL(gpiochip_generic_request);
/**
* gpiochip_generic_free() - free the gpio function from a pin
* @chip: the gpiochip to request the gpio function for
* @offset: the offset of the GPIO to free from GPIO function
*/
void gpiochip_generic_free(struct gpio_chip *chip, unsigned offset)
{
pinctrl_free_gpio(chip->base + offset);
}
EXPORT_SYMBOL_GPL(gpiochip_generic_free);
Yes....
Your pinctrl driver needs to implement the
.gpio_request_enable()
.gpio_disable_free()
.gpio_set_direction()
callbacks in struct pinmux_ops.
Also read in Documentation/pinctrl.txt about pinctrl/GPIO interaction.
> Second, here is our request_irq flow in mkd eint driver:
> request_irq --> mtk_pinctrl_irq_request_resources--> mtk_pmx_set_mode,
> Normally, it'll set pinmux to eint mode (usually is mode 0) in
> mtk_pmx_set_mode function. But for special case, such as iddig (connect
> to usb), when iddig request_irq, it should set pinmux to iddig mode
> (mode 2 in mt8163).
> Is there a better way than changing
> MTK_PIN(
> PINCTRL_PIN(16, "IDDIG"),
> NULL, "mt8173",
> MTK_EINT_FUNCTION(0, 16),
> MTK_FUNCTION(0, "GPIO16"),
> MTK_FUNCTION(1, "IDDIG"),
> MTK_FUNCTION(2, "CMFLASH"),
> MTK_FUNCTION(4, "PWM5")
> ),
> to
> MTK_PIN(
> PINCTRL_PIN(16, "IDDIG"),
> NULL, "mt8173",
> MTK_EINT_FUNCTION(2, 16),
> MTK_FUNCTION(0, "GPIO16"),
> MTK_FUNCTION(1, "IDDIG"),
> MTK_FUNCTION(2, "CMFLASH"),
> MTK_FUNCTION(4, "PWM5")
> ),
> in drivers/pinctrl/mediatek/pinctrl-mtk-mt8163.h?
This is the mediatek driver internals, I don't understand that.
Your guess is as good as mine, ask help from the other
driver authors is my hint, I can only help with the framework...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-28 11:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-28 2:35 pinctrl: mediatek: questions about gpio/pinctrl/eint biao huang
2016-01-28 2:35 ` biao huang
2016-01-28 11:22 ` Linus Walleij
2016-01-28 11:22 ` Linus Walleij
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.