diff mbox

[U-Boot,1/9] exynos4:pinmux:fdt: decode peripheral id

Message ID 1390832143-372-2-git-send-email-p.wilczek@samsung.com
State Changes Requested
Delegated to: Minkyu Kang
Headers show

Commit Message

Piotr Wilczek Jan. 27, 2014, 2:15 p.m. UTC
This patch adds api to decode peripheral id based in interrupt number.

Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
CC: Minkyu Kang <mk7.kang@samsung.com>
---
 arch/arm/cpu/armv7/exynos/pinmux.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

Comments

Jaehoon Chung Jan. 28, 2014, 8:54 a.m. UTC | #1
Hi, Piotr.

On 01/27/2014 11:15 PM, Piotr Wilczek wrote:
> This patch adds api to decode peripheral id based in interrupt number.
> 
> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> CC: Minkyu Kang <mk7.kang@samsung.com>
> ---
>  arch/arm/cpu/armv7/exynos/pinmux.c |   21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c b/arch/arm/cpu/armv7/exynos/pinmux.c
> index 904177a..3201d53 100644
> --- a/arch/arm/cpu/armv7/exynos/pinmux.c
> +++ b/arch/arm/cpu/armv7/exynos/pinmux.c
> @@ -741,6 +741,25 @@ int exynos_pinmux_config(int peripheral, int flags)
>  }
>  
>  #ifdef CONFIG_OF_CONTROL
> +

Remove the white space.

> +static int exynos4_pinmux_decode_periph_id(const void *blob, int node)
> +{
> +	int err;
> +	u32 cell[3];
> +
> +	err = fdtdec_get_int_array(blob, node, "interrupts", cell,
> +					ARRAY_SIZE(cell));
> +	if (err)
> +		return PERIPH_ID_NONE;
> +
> +	/* check for invalid peripheral id */
> +	if ((PERIPH_ID_SDMMC4 > cell[1]) || (cell[1] < PERIPH_ID_UART0))

What's condition checking? i didn't understand this.
PERIPH_ID_SDMMC > cell[1] or PERIPH_ID_UART0 > cell[1] is valid?

Best Regards,
Jaehoon Chung

> +		return cell[1];
> +
> +	debug(" invalid peripheral id\n");
> +	return PERIPH_ID_NONE;
> +}
> +
>  static int exynos5_pinmux_decode_periph_id(const void *blob, int node)
>  {
>  	int err;
> @@ -763,6 +782,8 @@ int pinmux_decode_periph_id(const void *blob, int node)
>  {
>  	if (cpu_is_exynos5())
>  		return  exynos5_pinmux_decode_periph_id(blob, node);
> +	else if (cpu_is_exynos4())
> +		return  exynos4_pinmux_decode_periph_id(blob, node);
>  	else
>  		return PERIPH_ID_NONE;
>  }
>
Piotr Wilczek Jan. 28, 2014, 12:13 p.m. UTC | #2
Hi Jaehoon,

Thanks for review. Please comments below.

> -----Original Message-----
> 
> Hi, Piotr.
> 
> On 01/27/2014 11:15 PM, Piotr Wilczek wrote:
> > This patch adds api to decode peripheral id based in interrupt
> number.
> >
> > Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
> > Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> > CC: Minkyu Kang <mk7.kang@samsung.com>
> > ---
> >  arch/arm/cpu/armv7/exynos/pinmux.c |   21 +++++++++++++++++++++
> >  1 file changed, 21 insertions(+)
> >
> > diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c
> > b/arch/arm/cpu/armv7/exynos/pinmux.c
> > index 904177a..3201d53 100644
> > --- a/arch/arm/cpu/armv7/exynos/pinmux.c
> > +++ b/arch/arm/cpu/armv7/exynos/pinmux.c
> > @@ -741,6 +741,25 @@ int exynos_pinmux_config(int peripheral, int
> > flags)  }
> >
> >  #ifdef CONFIG_OF_CONTROL
> > +
> 
> Remove the white space.
Ok.

> 
> > +static int exynos4_pinmux_decode_periph_id(const void *blob, int
> > +node) {
> > +	int err;
> > +	u32 cell[3];
> > +
> > +	err = fdtdec_get_int_array(blob, node, "interrupts", cell,
> > +					ARRAY_SIZE(cell));
> > +	if (err)
> > +		return PERIPH_ID_NONE;
> > +
> > +	/* check for invalid peripheral id */
> > +	if ((PERIPH_ID_SDMMC4 > cell[1]) || (cell[1] < PERIPH_ID_UART0))
> 
> What's condition checking? i didn't understand this.
> PERIPH_ID_SDMMC > cell[1] or PERIPH_ID_UART0 > cell[1] is valid?
> 
It supposed to check if cell[1] is within supported periph_id range and
should be like this:
If ((cell[1] >= PERIPH_ID_UART0) && (cell[1] < PERIPH_ID_COUNT))

> Best Regards,
> Jaehoon Chung
> 
> > +		return cell[1];
> > +
> > +	debug(" invalid peripheral id\n");
> > +	return PERIPH_ID_NONE;
> > +}
> > +
> >  static int exynos5_pinmux_decode_periph_id(const void *blob, int
> > node)  {
> >  	int err;
> > @@ -763,6 +782,8 @@ int pinmux_decode_periph_id(const void *blob, int
> > node)  {
> >  	if (cpu_is_exynos5())
> >  		return  exynos5_pinmux_decode_periph_id(blob, node);
> > +	else if (cpu_is_exynos4())
> > +		return  exynos4_pinmux_decode_periph_id(blob, node);
> >  	else
> >  		return PERIPH_ID_NONE;
> >  }
> >
Best regards,
Piotr Wilczek
Minkyu Kang Jan. 29, 2014, 8:03 a.m. UTC | #3
On 28/01/14 21:13, Piotr Wilczek wrote:
> Hi Jaehoon,
> 
> Thanks for review. Please comments below.
> 
>> -----Original Message-----
>>
>> Hi, Piotr.
>>
>> On 01/27/2014 11:15 PM, Piotr Wilczek wrote:
>>> This patch adds api to decode peripheral id based in interrupt
>> number.
>>>
>>> Signed-off-by: Piotr Wilczek <p.wilczek@samsung.com>
>>> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
>>> CC: Minkyu Kang <mk7.kang@samsung.com>
>>> ---
>>>  arch/arm/cpu/armv7/exynos/pinmux.c |   21 +++++++++++++++++++++
>>>  1 file changed, 21 insertions(+)
>>>
>>> diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c
>>> b/arch/arm/cpu/armv7/exynos/pinmux.c
>>> index 904177a..3201d53 100644
>>> --- a/arch/arm/cpu/armv7/exynos/pinmux.c
>>> +++ b/arch/arm/cpu/armv7/exynos/pinmux.c
>>> @@ -741,6 +741,25 @@ int exynos_pinmux_config(int peripheral, int
>>> flags)  }
>>>
>>>  #ifdef CONFIG_OF_CONTROL
>>> +
>>
>> Remove the white space.
> Ok.
> 
>>
>>> +static int exynos4_pinmux_decode_periph_id(const void *blob, int
>>> +node) {
>>> +	int err;
>>> +	u32 cell[3];
>>> +
>>> +	err = fdtdec_get_int_array(blob, node, "interrupts", cell,
>>> +					ARRAY_SIZE(cell));
>>> +	if (err)
>>> +		return PERIPH_ID_NONE;
>>> +
>>> +	/* check for invalid peripheral id */
>>> +	if ((PERIPH_ID_SDMMC4 > cell[1]) || (cell[1] < PERIPH_ID_UART0))
>>
>> What's condition checking? i didn't understand this.
>> PERIPH_ID_SDMMC > cell[1] or PERIPH_ID_UART0 > cell[1] is valid?
>>
> It supposed to check if cell[1] is within supported periph_id range and
> should be like this:
> If ((cell[1] >= PERIPH_ID_UART0) && (cell[1] < PERIPH_ID_COUNT))

I know that you refer to exynos5 stuffs.
I think this routine unnecessary.

Thanks,
Minkyu Kang.
diff mbox

Patch

diff --git a/arch/arm/cpu/armv7/exynos/pinmux.c b/arch/arm/cpu/armv7/exynos/pinmux.c
index 904177a..3201d53 100644
--- a/arch/arm/cpu/armv7/exynos/pinmux.c
+++ b/arch/arm/cpu/armv7/exynos/pinmux.c
@@ -741,6 +741,25 @@  int exynos_pinmux_config(int peripheral, int flags)
 }
 
 #ifdef CONFIG_OF_CONTROL
+
+static int exynos4_pinmux_decode_periph_id(const void *blob, int node)
+{
+	int err;
+	u32 cell[3];
+
+	err = fdtdec_get_int_array(blob, node, "interrupts", cell,
+					ARRAY_SIZE(cell));
+	if (err)
+		return PERIPH_ID_NONE;
+
+	/* check for invalid peripheral id */
+	if ((PERIPH_ID_SDMMC4 > cell[1]) || (cell[1] < PERIPH_ID_UART0))
+		return cell[1];
+
+	debug(" invalid peripheral id\n");
+	return PERIPH_ID_NONE;
+}
+
 static int exynos5_pinmux_decode_periph_id(const void *blob, int node)
 {
 	int err;
@@ -763,6 +782,8 @@  int pinmux_decode_periph_id(const void *blob, int node)
 {
 	if (cpu_is_exynos5())
 		return  exynos5_pinmux_decode_periph_id(blob, node);
+	else if (cpu_is_exynos4())
+		return  exynos4_pinmux_decode_periph_id(blob, node);
 	else
 		return PERIPH_ID_NONE;
 }