All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@baylibre.com>
To: Neil Armstrong <narmstrong@baylibre.com>
Cc: Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Mark Rutland <mark.rutland@arm.com>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
	Will Deacon <will.deacon@arm.com>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Rob Herring <robh+dt@kernel.org>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Carlo Caione <carlo@caione.org>,
	"open list:ARM/Amlogic Meson..."
	<linux-amlogic@lists.infradead.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	Jerome Brunet <jbrunet@baylibre.com>
Subject: Re: [PATCH 1/2] pinctrl: meson: gxl: add the missing PWM pin definitions
Date: Thu, 16 Mar 2017 11:52:37 -0700	[thread overview]
Message-ID: <m2bmt16olm.fsf@baylibre.com> (raw)
In-Reply-To: <c0dad3a3-bdd4-3563-0ca6-0ca9d5a4ce2f@baylibre.com> (Neil Armstrong's message of "Thu, 16 Mar 2017 14:54:03 +0100")

Neil Armstrong <narmstrong@baylibre.com> writes:

> On 03/15/2017 09:11 PM, Martin Blumenstingl wrote:
>> On Wed, Mar 15, 2017 at 8:12 PM, Kevin Hilman <khilman@baylibre.com> wrote:
>>> Neil Armstrong <narmstrong@baylibre.com> writes:
>>>
>>>> On 03/14/2017 04:42 PM, Linus Walleij wrote:
>>>>> On Thu, Mar 9, 2017 at 8:47 PM, Martin Blumenstingl
>>>>> <martin.blumenstingl@googlemail.com> wrote:
>>>>>> On Mon, Mar 6, 2017 at 3:42 PM, Jerome Brunet <jbrunet@baylibre.com> wrote:
>>>>>>> On Sat, 2017-03-04 at 22:23 +0100, Martin Blumenstingl wrote:
>>>>>
>>>>>>>> +     FUNCTION(pwm_f_clk),
>>>>>>>> +     FUNCTION(pwm_f_x),
>>>>>>>
>>>>>>> I wonder if having function named "pwm_f_clk" really makes sense ?
>>>>>>> Shouldn't it be just "pwm_f" ? This is real function, isn't it ?
>>>>>>> The actual pin used will be provided in the dt. Here, I suppose we
>>>>>>> could have this:
>>>>>>>
>>>>>>> +static const char * const pwm_f_groups[] = {
>>>>>>> +       "pwm_f_x", "pwm_f_clk",
>>>>>>> +};
>>>>>>>
>>>>>>> Has far as I can see, on meson arch, the function does not carry much
>>>>>>> information anyway, except for prints.
>>>>>>>
>>>>>>> To be clear, I'm not questioning this change in particular. It looks
>>>>>>> good, and follows what has been done in the past on meson. I know we
>>>>>>> have been this a lot already, but I'm questioning whether we should
>>>>>>> continue to do so ?
>>>>>>>
>>>>>>> I asking because I also have a lot case like this coming up on audio
>>>>>>> for gxl and gxbb, where the same function can use different pins.
>>>>>>
>>>>>> could you please look into Jerome's question?
>>>>>> personally I'm fine with either way, and changing my patch would be
>>>>>> quite trivial. but I'd like to know what's "the way to go" before
>>>>>> changing anything (and reverting that afterwards again).
>>>>>
>>>>> I don't understand the question really.
>>>>>
>>>>> I am not an expert on this system, if the people working with it
>>>>> cannot tell a function from a group I don't know who can... certainly
>>>>> not me.
>>>>>
>>>>> What I can say is that pincontrol combines functions and groups to
>>>>> states using a mapping. The functions should be something you poke
>>>>> into a register, the groups are looser defined but may also be a
>>>>> character of the hardware, but more usual a character of the
>>>>> intended electronic usecase. Groups contain 1..n pins and can
>>>>> be combined with some applicable functions.
>>>>>
>>>>> Please re-read Documentation/pinctrl.txt very closely if anything is
>>>>> unclear, I really put a lot of hours into getting that right. Especially
>>>>> reexamine "Pinmux conventions".
>>>>
>>>> The point pushed by Jerome was purely cosmetic since the groups in the meson
>>>> pinctrl driver are purely cosmetic, since only the GPIO group is handled,
>>>> other groups are all handled the same.
>>>
>>> handled the same... as what?
>>>
>>>> This is because I pushed all the PWM pins in a separate group, but functionnaly
>>>> the internal signal (i.e. PWM F) is the same for multiple pins and should be
>>>> a single "PWM F" group instead of multiple ones.
>>>>
>>>> My advice is to leave the PWM groups as is,
>>>
>>> Do you mean as we have in mainline today?  or as is proposed in $SUBJECT patch?
>>>
>>>> and push new pins/functions/groups
>>>> grouped with the internal signal name if split on multiple pins.
>>>
>>> Can somone do a quick patch for PWM_F for example, also showing how this
>>> will look in the DT if someone wants to switch between the PWM_F on GPIOX
>>> or GPIOCLK?
>> it would look like this (node name, label and group stay the same,
>> function does not contain the _x/_clk suffix anymore):
>> pwm_f_clk_pins: pwm_f_clk {
>>     mux {
>>         groups = "pwm_f_clk";
>>         function = "pwm_f";
>>     };
>> };
>> 
>> pwm_f_x_pins: pwm_f_x {
>>     mux {
>>         groups = "pwm_f_x";
>>         function = "pwm_f";
>>     };
>> };
>> 
>>> We shouldalso verify that the driver is detecting/removing conflicts
>>> properly when something else is already using that pin (e.g. SDIO_IRQ
>>> shares pin GPIOX_7 with PWM_F)
>> if the same pin is assigned to two devices then the pinctrl subsystem
>> will throw an error (we don't have to take care of this, it's how I
>> discovered as GPIOAO_1 was used by uart_rx_ao_a and uart_rx_ao_b).
>> however, I have not tested yet what happens if the same function is
>> assigned to multiple pins (let's say you pass both, pwm_f_clk_pins and
>> pwm_f_x_pins to the pwm_ef node - will this result in the PWM output
>> being routed to *both* pins or just one pin?). if the same function
>> cannot be used by two pins simultaneously then we should probably use
>> function "pwm_f" instead of "pwm_f_x" (just an example) so we can
>> detect these "conflicts".
>> 
>> 
>> Regards,
>> Martin
>> 
>> 
>> [0] https://github.com/torvalds/linux/commit/b27e36482c02a94194fec71fb29696f4c8e9241c
>> 
>
> Let's resume :
> In the mainline meson pinctrl driver, we have :
>  - pins that represent the PAD name (GPIOX_3 or GPIODV_17)
>  - groups that represent each physical "bit" we set in the control registers, each group can group 1 or multiple physical pins
> For example, the "emmc_nand_d07" sets the mode of multiple pins.
>  - functions are a purely logical set of groups
>
> The only C function handling the "function" is :
> static int meson_pmx_set_mux(func_num, group_num)
> {
> ...
> 	struct meson_pmx_func *func = &pc->data->funcs[func_num];
> ...
> 	/* Function 0 (GPIO) doesn't need any additional setting */
> 	if (func_num)
> 		ret = regmap_update_bits(...);
> ...
> }
>
> So we could have only two big functions :
> is_gpio
> is_not_gpio
>
> But now we group every logically similar "groups" into the same function, like :
> static const char * const uart_a_groups[] = {
> 	"uart_tx_a", "uart_rx_a", "uart_cts_a", "uart_rts_a",
> };
>
> When I pushed the PWM pins, I did not knew how to handle the fact that the same signal
> is on multiple physical pins, so I added multiple functions for each physical pin mode.
>
> What jerome pointed is that instead of :
> static const char * const pwm_a_x_groups[] = {
> 	"pwm_a_x",
> };
>
> static const char * const pwm_a_y_groups[] = {
> 	"pwm_a_y",
> };
>
> we could have single :
> static const char * const pwm_a_groups[] = {
> 	"pwm_a_x", "pwm_a_y",
> };
>
> But we should also change the DT accordingly.
>
> So we can see that from different perspective :
> - from the "pin" perspective : they are different functions, so we leave like it's already mainline
> - from the "signal" perspective : they are the same signal, so we should group
> - both, so we set a function per groupable groups.
>
> for example, on the GXL, we can have UART_AO_B TX&RX on multiple pins, so we can have either :
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> 	"uart_tx_ao_b_0", "uart_rx_ao_b_1",
> };
>
> or
>
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> static const char * const uart_ao_b_0_1_groups[] = {
> 	"uart_tx_ao_b_0", "uart_rx_ao_b_1",
> };
>
> or
>
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> static const char * const uart_ao_b_0_1_groups[] = {
>  	"uart_tx_ao_b_0", "uart_rx_ao_b_1", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> The three of these are correct.
> The point Jerome asked was for solution 1, and it what I pushed
> The solution 2 is how functions are today.
>
> The third solution is less easy but still valid.
>
> What I want is :
>  - since it's purely logical, it's not very important and each solution is still valid from
> all perspectives, so leave the PWM functions like this and push new PWMs in the same way
>  - The next functions should behave like solution 1, or solution 3 if better

Thanks for the clarification and examples.

I think solution 1 is fine.

I just want to be sure that flexibilty remains in DT, so it's the DT
files that determine exactly which groups (or pins) will be used.
e.g. it has to stay the case that DT can define a UART without CTS/RTS
signals.

I'm pretty sure that remains the case, since the "groups" property in DT
is selecting from the *available* groups defined in the driver, IIUC.

Kevin

WARNING: multiple messages have this Message-ID (diff)
From: khilman@baylibre.com (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/2] pinctrl: meson: gxl: add the missing PWM pin definitions
Date: Thu, 16 Mar 2017 11:52:37 -0700	[thread overview]
Message-ID: <m2bmt16olm.fsf@baylibre.com> (raw)
In-Reply-To: <c0dad3a3-bdd4-3563-0ca6-0ca9d5a4ce2f@baylibre.com> (Neil Armstrong's message of "Thu, 16 Mar 2017 14:54:03 +0100")

Neil Armstrong <narmstrong@baylibre.com> writes:

> On 03/15/2017 09:11 PM, Martin Blumenstingl wrote:
>> On Wed, Mar 15, 2017 at 8:12 PM, Kevin Hilman <khilman@baylibre.com> wrote:
>>> Neil Armstrong <narmstrong@baylibre.com> writes:
>>>
>>>> On 03/14/2017 04:42 PM, Linus Walleij wrote:
>>>>> On Thu, Mar 9, 2017 at 8:47 PM, Martin Blumenstingl
>>>>> <martin.blumenstingl@googlemail.com> wrote:
>>>>>> On Mon, Mar 6, 2017 at 3:42 PM, Jerome Brunet <jbrunet@baylibre.com> wrote:
>>>>>>> On Sat, 2017-03-04 at 22:23 +0100, Martin Blumenstingl wrote:
>>>>>
>>>>>>>> +     FUNCTION(pwm_f_clk),
>>>>>>>> +     FUNCTION(pwm_f_x),
>>>>>>>
>>>>>>> I wonder if having function named "pwm_f_clk" really makes sense ?
>>>>>>> Shouldn't it be just "pwm_f" ? This is real function, isn't it ?
>>>>>>> The actual pin used will be provided in the dt. Here, I suppose we
>>>>>>> could have this:
>>>>>>>
>>>>>>> +static const char * const pwm_f_groups[] = {
>>>>>>> +       "pwm_f_x", "pwm_f_clk",
>>>>>>> +};
>>>>>>>
>>>>>>> Has far as I can see, on meson arch, the function does not carry much
>>>>>>> information anyway, except for prints.
>>>>>>>
>>>>>>> To be clear, I'm not questioning this change in particular. It looks
>>>>>>> good, and follows what has been done in the past on meson. I know we
>>>>>>> have been this a lot already, but I'm questioning whether we should
>>>>>>> continue to do so ?
>>>>>>>
>>>>>>> I asking because I also have a lot case like this coming up on audio
>>>>>>> for gxl and gxbb, where the same function can use different pins.
>>>>>>
>>>>>> could you please look into Jerome's question?
>>>>>> personally I'm fine with either way, and changing my patch would be
>>>>>> quite trivial. but I'd like to know what's "the way to go" before
>>>>>> changing anything (and reverting that afterwards again).
>>>>>
>>>>> I don't understand the question really.
>>>>>
>>>>> I am not an expert on this system, if the people working with it
>>>>> cannot tell a function from a group I don't know who can... certainly
>>>>> not me.
>>>>>
>>>>> What I can say is that pincontrol combines functions and groups to
>>>>> states using a mapping. The functions should be something you poke
>>>>> into a register, the groups are looser defined but may also be a
>>>>> character of the hardware, but more usual a character of the
>>>>> intended electronic usecase. Groups contain 1..n pins and can
>>>>> be combined with some applicable functions.
>>>>>
>>>>> Please re-read Documentation/pinctrl.txt very closely if anything is
>>>>> unclear, I really put a lot of hours into getting that right. Especially
>>>>> reexamine "Pinmux conventions".
>>>>
>>>> The point pushed by Jerome was purely cosmetic since the groups in the meson
>>>> pinctrl driver are purely cosmetic, since only the GPIO group is handled,
>>>> other groups are all handled the same.
>>>
>>> handled the same... as what?
>>>
>>>> This is because I pushed all the PWM pins in a separate group, but functionnaly
>>>> the internal signal (i.e. PWM F) is the same for multiple pins and should be
>>>> a single "PWM F" group instead of multiple ones.
>>>>
>>>> My advice is to leave the PWM groups as is,
>>>
>>> Do you mean as we have in mainline today?  or as is proposed in $SUBJECT patch?
>>>
>>>> and push new pins/functions/groups
>>>> grouped with the internal signal name if split on multiple pins.
>>>
>>> Can somone do a quick patch for PWM_F for example, also showing how this
>>> will look in the DT if someone wants to switch between the PWM_F on GPIOX
>>> or GPIOCLK?
>> it would look like this (node name, label and group stay the same,
>> function does not contain the _x/_clk suffix anymore):
>> pwm_f_clk_pins: pwm_f_clk {
>>     mux {
>>         groups = "pwm_f_clk";
>>         function = "pwm_f";
>>     };
>> };
>> 
>> pwm_f_x_pins: pwm_f_x {
>>     mux {
>>         groups = "pwm_f_x";
>>         function = "pwm_f";
>>     };
>> };
>> 
>>> We shouldalso verify that the driver is detecting/removing conflicts
>>> properly when something else is already using that pin (e.g. SDIO_IRQ
>>> shares pin GPIOX_7 with PWM_F)
>> if the same pin is assigned to two devices then the pinctrl subsystem
>> will throw an error (we don't have to take care of this, it's how I
>> discovered as GPIOAO_1 was used by uart_rx_ao_a and uart_rx_ao_b).
>> however, I have not tested yet what happens if the same function is
>> assigned to multiple pins (let's say you pass both, pwm_f_clk_pins and
>> pwm_f_x_pins to the pwm_ef node - will this result in the PWM output
>> being routed to *both* pins or just one pin?). if the same function
>> cannot be used by two pins simultaneously then we should probably use
>> function "pwm_f" instead of "pwm_f_x" (just an example) so we can
>> detect these "conflicts".
>> 
>> 
>> Regards,
>> Martin
>> 
>> 
>> [0] https://github.com/torvalds/linux/commit/b27e36482c02a94194fec71fb29696f4c8e9241c
>> 
>
> Let's resume :
> In the mainline meson pinctrl driver, we have :
>  - pins that represent the PAD name (GPIOX_3 or GPIODV_17)
>  - groups that represent each physical "bit" we set in the control registers, each group can group 1 or multiple physical pins
> For example, the "emmc_nand_d07" sets the mode of multiple pins.
>  - functions are a purely logical set of groups
>
> The only C function handling the "function" is :
> static int meson_pmx_set_mux(func_num, group_num)
> {
> ...
> 	struct meson_pmx_func *func = &pc->data->funcs[func_num];
> ...
> 	/* Function 0 (GPIO) doesn't need any additional setting */
> 	if (func_num)
> 		ret = regmap_update_bits(...);
> ...
> }
>
> So we could have only two big functions :
> is_gpio
> is_not_gpio
>
> But now we group every logically similar "groups" into the same function, like :
> static const char * const uart_a_groups[] = {
> 	"uart_tx_a", "uart_rx_a", "uart_cts_a", "uart_rts_a",
> };
>
> When I pushed the PWM pins, I did not knew how to handle the fact that the same signal
> is on multiple physical pins, so I added multiple functions for each physical pin mode.
>
> What jerome pointed is that instead of :
> static const char * const pwm_a_x_groups[] = {
> 	"pwm_a_x",
> };
>
> static const char * const pwm_a_y_groups[] = {
> 	"pwm_a_y",
> };
>
> we could have single :
> static const char * const pwm_a_groups[] = {
> 	"pwm_a_x", "pwm_a_y",
> };
>
> But we should also change the DT accordingly.
>
> So we can see that from different perspective :
> - from the "pin" perspective : they are different functions, so we leave like it's already mainline
> - from the "signal" perspective : they are the same signal, so we should group
> - both, so we set a function per groupable groups.
>
> for example, on the GXL, we can have UART_AO_B TX&RX on multiple pins, so we can have either :
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> 	"uart_tx_ao_b_0", "uart_rx_ao_b_1",
> };
>
> or
>
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> static const char * const uart_ao_b_0_1_groups[] = {
> 	"uart_tx_ao_b_0", "uart_rx_ao_b_1",
> };
>
> or
>
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> static const char * const uart_ao_b_0_1_groups[] = {
>  	"uart_tx_ao_b_0", "uart_rx_ao_b_1", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> The three of these are correct.
> The point Jerome asked was for solution 1, and it what I pushed
> The solution 2 is how functions are today.
>
> The third solution is less easy but still valid.
>
> What I want is :
>  - since it's purely logical, it's not very important and each solution is still valid from
> all perspectives, so leave the PWM functions like this and push new PWMs in the same way
>  - The next functions should behave like solution 1, or solution 3 if better

Thanks for the clarification and examples.

I think solution 1 is fine.

I just want to be sure that flexibilty remains in DT, so it's the DT
files that determine exactly which groups (or pins) will be used.
e.g. it has to stay the case that DT can define a UART without CTS/RTS
signals.

I'm pretty sure that remains the case, since the "groups" property in DT
is selecting from the *available* groups defined in the driver, IIUC.

Kevin

WARNING: multiple messages have this Message-ID (diff)
From: khilman@baylibre.com (Kevin Hilman)
To: linus-amlogic@lists.infradead.org
Subject: [PATCH 1/2] pinctrl: meson: gxl: add the missing PWM pin definitions
Date: Thu, 16 Mar 2017 11:52:37 -0700	[thread overview]
Message-ID: <m2bmt16olm.fsf@baylibre.com> (raw)
In-Reply-To: <c0dad3a3-bdd4-3563-0ca6-0ca9d5a4ce2f@baylibre.com> (Neil Armstrong's message of "Thu, 16 Mar 2017 14:54:03 +0100")

Neil Armstrong <narmstrong@baylibre.com> writes:

> On 03/15/2017 09:11 PM, Martin Blumenstingl wrote:
>> On Wed, Mar 15, 2017 at 8:12 PM, Kevin Hilman <khilman@baylibre.com> wrote:
>>> Neil Armstrong <narmstrong@baylibre.com> writes:
>>>
>>>> On 03/14/2017 04:42 PM, Linus Walleij wrote:
>>>>> On Thu, Mar 9, 2017 at 8:47 PM, Martin Blumenstingl
>>>>> <martin.blumenstingl@googlemail.com> wrote:
>>>>>> On Mon, Mar 6, 2017 at 3:42 PM, Jerome Brunet <jbrunet@baylibre.com> wrote:
>>>>>>> On Sat, 2017-03-04 at 22:23 +0100, Martin Blumenstingl wrote:
>>>>>
>>>>>>>> +     FUNCTION(pwm_f_clk),
>>>>>>>> +     FUNCTION(pwm_f_x),
>>>>>>>
>>>>>>> I wonder if having function named "pwm_f_clk" really makes sense ?
>>>>>>> Shouldn't it be just "pwm_f" ? This is real function, isn't it ?
>>>>>>> The actual pin used will be provided in the dt. Here, I suppose we
>>>>>>> could have this:
>>>>>>>
>>>>>>> +static const char * const pwm_f_groups[] = {
>>>>>>> +       "pwm_f_x", "pwm_f_clk",
>>>>>>> +};
>>>>>>>
>>>>>>> Has far as I can see, on meson arch, the function does not carry much
>>>>>>> information anyway, except for prints.
>>>>>>>
>>>>>>> To be clear, I'm not questioning this change in particular. It looks
>>>>>>> good, and follows what has been done in the past on meson. I know we
>>>>>>> have been this a lot already, but I'm questioning whether we should
>>>>>>> continue to do so ?
>>>>>>>
>>>>>>> I asking because I also have a lot case like this coming up on audio
>>>>>>> for gxl and gxbb, where the same function can use different pins.
>>>>>>
>>>>>> could you please look into Jerome's question?
>>>>>> personally I'm fine with either way, and changing my patch would be
>>>>>> quite trivial. but I'd like to know what's "the way to go" before
>>>>>> changing anything (and reverting that afterwards again).
>>>>>
>>>>> I don't understand the question really.
>>>>>
>>>>> I am not an expert on this system, if the people working with it
>>>>> cannot tell a function from a group I don't know who can... certainly
>>>>> not me.
>>>>>
>>>>> What I can say is that pincontrol combines functions and groups to
>>>>> states using a mapping. The functions should be something you poke
>>>>> into a register, the groups are looser defined but may also be a
>>>>> character of the hardware, but more usual a character of the
>>>>> intended electronic usecase. Groups contain 1..n pins and can
>>>>> be combined with some applicable functions.
>>>>>
>>>>> Please re-read Documentation/pinctrl.txt very closely if anything is
>>>>> unclear, I really put a lot of hours into getting that right. Especially
>>>>> reexamine "Pinmux conventions".
>>>>
>>>> The point pushed by Jerome was purely cosmetic since the groups in the meson
>>>> pinctrl driver are purely cosmetic, since only the GPIO group is handled,
>>>> other groups are all handled the same.
>>>
>>> handled the same... as what?
>>>
>>>> This is because I pushed all the PWM pins in a separate group, but functionnaly
>>>> the internal signal (i.e. PWM F) is the same for multiple pins and should be
>>>> a single "PWM F" group instead of multiple ones.
>>>>
>>>> My advice is to leave the PWM groups as is,
>>>
>>> Do you mean as we have in mainline today?  or as is proposed in $SUBJECT patch?
>>>
>>>> and push new pins/functions/groups
>>>> grouped with the internal signal name if split on multiple pins.
>>>
>>> Can somone do a quick patch for PWM_F for example, also showing how this
>>> will look in the DT if someone wants to switch between the PWM_F on GPIOX
>>> or GPIOCLK?
>> it would look like this (node name, label and group stay the same,
>> function does not contain the _x/_clk suffix anymore):
>> pwm_f_clk_pins: pwm_f_clk {
>>     mux {
>>         groups = "pwm_f_clk";
>>         function = "pwm_f";
>>     };
>> };
>> 
>> pwm_f_x_pins: pwm_f_x {
>>     mux {
>>         groups = "pwm_f_x";
>>         function = "pwm_f";
>>     };
>> };
>> 
>>> We shouldalso verify that the driver is detecting/removing conflicts
>>> properly when something else is already using that pin (e.g. SDIO_IRQ
>>> shares pin GPIOX_7 with PWM_F)
>> if the same pin is assigned to two devices then the pinctrl subsystem
>> will throw an error (we don't have to take care of this, it's how I
>> discovered as GPIOAO_1 was used by uart_rx_ao_a and uart_rx_ao_b).
>> however, I have not tested yet what happens if the same function is
>> assigned to multiple pins (let's say you pass both, pwm_f_clk_pins and
>> pwm_f_x_pins to the pwm_ef node - will this result in the PWM output
>> being routed to *both* pins or just one pin?). if the same function
>> cannot be used by two pins simultaneously then we should probably use
>> function "pwm_f" instead of "pwm_f_x" (just an example) so we can
>> detect these "conflicts".
>> 
>> 
>> Regards,
>> Martin
>> 
>> 
>> [0] https://github.com/torvalds/linux/commit/b27e36482c02a94194fec71fb29696f4c8e9241c
>> 
>
> Let's resume :
> In the mainline meson pinctrl driver, we have :
>  - pins that represent the PAD name (GPIOX_3 or GPIODV_17)
>  - groups that represent each physical "bit" we set in the control registers, each group can group 1 or multiple physical pins
> For example, the "emmc_nand_d07" sets the mode of multiple pins.
>  - functions are a purely logical set of groups
>
> The only C function handling the "function" is :
> static int meson_pmx_set_mux(func_num, group_num)
> {
> ...
> 	struct meson_pmx_func *func = &pc->data->funcs[func_num];
> ...
> 	/* Function 0 (GPIO) doesn't need any additional setting */
> 	if (func_num)
> 		ret = regmap_update_bits(...);
> ...
> }
>
> So we could have only two big functions :
> is_gpio
> is_not_gpio
>
> But now we group every logically similar "groups" into the same function, like :
> static const char * const uart_a_groups[] = {
> 	"uart_tx_a", "uart_rx_a", "uart_cts_a", "uart_rts_a",
> };
>
> When I pushed the PWM pins, I did not knew how to handle the fact that the same signal
> is on multiple physical pins, so I added multiple functions for each physical pin mode.
>
> What jerome pointed is that instead of :
> static const char * const pwm_a_x_groups[] = {
> 	"pwm_a_x",
> };
>
> static const char * const pwm_a_y_groups[] = {
> 	"pwm_a_y",
> };
>
> we could have single :
> static const char * const pwm_a_groups[] = {
> 	"pwm_a_x", "pwm_a_y",
> };
>
> But we should also change the DT accordingly.
>
> So we can see that from different perspective :
> - from the "pin" perspective : they are different functions, so we leave like it's already mainline
> - from the "signal" perspective : they are the same signal, so we should group
> - both, so we set a function per groupable groups.
>
> for example, on the GXL, we can have UART_AO_B TX&RX on multiple pins, so we can have either :
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> 	"uart_tx_ao_b_0", "uart_rx_ao_b_1",
> };
>
> or
>
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> static const char * const uart_ao_b_0_1_groups[] = {
> 	"uart_tx_ao_b_0", "uart_rx_ao_b_1",
> };
>
> or
>
> static const char * const uart_ao_b_groups[] = {
>  	"uart_tx_ao_b", "uart_rx_ao_b", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> static const char * const uart_ao_b_0_1_groups[] = {
>  	"uart_tx_ao_b_0", "uart_rx_ao_b_1", "uart_cts_ao_b", "uart_rts_ao_b",
> };
>
> The three of these are correct.
> The point Jerome asked was for solution 1, and it what I pushed
> The solution 2 is how functions are today.
>
> The third solution is less easy but still valid.
>
> What I want is :
>  - since it's purely logical, it's not very important and each solution is still valid from
> all perspectives, so leave the PWM functions like this and push new PWMs in the same way
>  - The next functions should behave like solution 1, or solution 3 if better

Thanks for the clarification and examples.

I think solution 1 is fine.

I just want to be sure that flexibilty remains in DT, so it's the DT
files that determine exactly which groups (or pins) will be used.
e.g. it has to stay the case that DT can define a UART without CTS/RTS
signals.

I'm pretty sure that remains the case, since the "groups" property in DT
is selecting from the *available* groups defined in the driver, IIUC.

Kevin

  reply	other threads:[~2017-03-16 18:52 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-04 21:23 [PATCH 0/2] meson-gxl pinctrl - add the missing PWM pins Martin Blumenstingl
2017-03-04 21:23 ` Martin Blumenstingl
2017-03-04 21:23 ` Martin Blumenstingl
2017-03-04 21:23 ` [PATCH 1/2] pinctrl: meson: gxl: add the missing PWM pin definitions Martin Blumenstingl
2017-03-04 21:23   ` Martin Blumenstingl
2017-03-04 21:23   ` Martin Blumenstingl
     [not found]   ` <20170304212318.27076-2-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-03-06 14:42     ` Jerome Brunet
2017-03-06 14:42       ` Jerome Brunet
2017-03-06 14:42       ` Jerome Brunet
2017-03-09 19:47       ` Martin Blumenstingl
2017-03-09 19:47         ` Martin Blumenstingl
2017-03-09 19:47         ` Martin Blumenstingl
     [not found]         ` <CAFBinCDty8v80tLxHJPR+SHv32LX834dPJUruRNqr6angx3OOQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-11  0:16           ` Kevin Hilman
2017-03-11  0:16             ` Kevin Hilman
2017-03-11  0:16             ` Kevin Hilman
2017-03-14 15:42           ` Linus Walleij
2017-03-14 15:42             ` Linus Walleij
2017-03-14 15:42             ` Linus Walleij
2017-03-15  9:59             ` Neil Armstrong
2017-03-15  9:59               ` Neil Armstrong
2017-03-15  9:59               ` Neil Armstrong
2017-03-15 19:12               ` Kevin Hilman
2017-03-15 19:12                 ` Kevin Hilman
2017-03-15 19:12                 ` Kevin Hilman
2017-03-15 20:11                 ` Martin Blumenstingl
2017-03-15 20:11                   ` Martin Blumenstingl
2017-03-15 20:11                   ` Martin Blumenstingl
     [not found]                   ` <CAFBinCCCgbSvh8B81nXP6D11d5WZZ+71jDgvsjYDsWTb=V78Xg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-03-16 13:54                     ` Neil Armstrong
2017-03-16 13:54                       ` Neil Armstrong
2017-03-16 13:54                       ` Neil Armstrong
2017-03-16 18:52                       ` Kevin Hilman [this message]
2017-03-16 18:52                         ` Kevin Hilman
2017-03-16 18:52                         ` Kevin Hilman
     [not found] ` <20170304212318.27076-1-martin.blumenstingl-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2017-03-04 21:23   ` [PATCH 2/2] ARM64: dts: amlogic: meson-gxl: add the missing PWM pins Martin Blumenstingl
2017-03-04 21:23     ` Martin Blumenstingl
2017-03-04 21:23     ` Martin Blumenstingl
2017-03-06 16:14 ` [PATCH 0/2] meson-gxl pinctrl - " Neil Armstrong
2017-03-06 16:14   ` Neil Armstrong
2017-03-06 16:14   ` Neil Armstrong
2017-03-18 12:27 ` [PATCH v2 " Martin Blumenstingl
2017-03-18 12:27   ` Martin Blumenstingl
2017-03-18 12:27   ` Martin Blumenstingl
2017-03-18 12:27   ` [PATCH v2 1/2] pinctrl: meson: gxl: add the missing PWM pin definitions Martin Blumenstingl
2017-03-18 12:27     ` Martin Blumenstingl
2017-03-18 12:27     ` Martin Blumenstingl
2017-03-23  8:46     ` Linus Walleij
2017-03-23  8:46       ` Linus Walleij
2017-03-23  8:46       ` Linus Walleij
2017-03-18 12:27   ` [PATCH v2 2/2] ARM64: dts: amlogic: meson-gxl: add the missing PWM pins Martin Blumenstingl
2017-03-18 12:27     ` Martin Blumenstingl
2017-03-18 12:27     ` Martin Blumenstingl
2017-03-23  8:47     ` Linus Walleij
2017-03-23  8:47       ` Linus Walleij
2017-03-23  8:47       ` Linus Walleij
2017-03-23 19:09       ` Kevin Hilman
2017-03-23 19:09         ` Kevin Hilman
2017-03-23 19:09         ` Kevin Hilman

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=m2bmt16olm.fsf@baylibre.com \
    --to=khilman@baylibre.com \
    --cc=carlo@caione.org \
    --cc=catalin.marinas@arm.com \
    --cc=devicetree@vger.kernel.org \
    --cc=jbrunet@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=narmstrong@baylibre.com \
    --cc=robh+dt@kernel.org \
    --cc=will.deacon@arm.com \
    /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 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.