Skip to contentSkip to conversation

gpio: Adds GPIO driver support for Armada100

PATCH New Ajay Bhargav 3 participants 9 messages Jul 20, 2011 1 message not in the archive

lore
Share & tools
lore
#1 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

In reply to a message not in the archive
Quoted 7 lines · ----- "Prafulla Wadaskar

That can be thought of while adding support for othe SoCs. Preferably define register struct in asm/arch/gpio.h

Regards..
Prafulla . .

..snip.. (quoting from another reply..)

Quoted 4 lines

You have to follow all :-), more reviewers more better code output. BASE+OFFSET strictly not recommended.

I think lei and me are suggesting similar things, macros should be used precisely, the code should be small and smarter.

Hi Prafulla,

I agree that macros make code look smaller and smarter. Now if you see the registers of GPIO they are not in order, I mean i cannot group together particular gpio set. can i do it this way,

e.g.

struct armdgpio_gplr_register {
    u32 gplr0;
    u32 gplr1;
    u32 gplr2;
    u8 pad[some_value]; //this padding is going to be big
    u32 gplr3;
}

then while using this particular set i can just use ARMD1_GPLR_BASE ( = ARMD1_GPIO_BASE + GPLR_OFFSET). moreover i am not using all the registers so i define only those register sets which are in use. what you say about this?

Regards,
Ajay Bhargav

#2 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

Dear Ajay Bhargav,

Quoted 9 lines · In message <[email protected]>…

e.g.

struct armdgpio_gplr_register {
    u32 gplr0;
    u32 gplr1;
    u32 gplr2;
    u8 pad[some_value]; //this padding is going to be big
    u32 gplr3;
}

Is there any specific reason for not using u32 for the padding as well?

Quoted 4 lines

then while using this particular set i can just use ARMD1_GPLR_BASE ( ARMD1_GPIO_BASE + GPLR_OFFSET). moreover i am not using all the registers so i define only those register sets which are in use. what you say about this?

Why would you need this BASE + OFFSET notation when using a C struct for the registers? Thi smakes little sense to me.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The thing is, as you progress in the Craft,  you'll  learn  there  is
another rule... When you break rules, break 'em good and hard.
                                    - Terry Pratchett, _Wyrd Sisters_
#3 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

Dear Wolfgang,

Quoted 4 lines

Is there any specific reason for not using u32 for the padding as well?

nothing specific. It makes easy to find number of bytes than words.

Quoted 4 lines

Why would you need this BASE + OFFSET notation when using a C struct for the registers? Thi smakes little sense to me.

Well I did use the C struct method, if you see my patches submitted earlier but according to Prafulla and Lie structure size is too big. so they want me to use a mix of C struct and BASE + OFFSET notation. so I thought to break the big C struct into smaller grouped structures pointing each group with GPIO base + group offset. I would be glad if you can suggest me something better or smarter.

Regards,
Ajay Bhargav

#4 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

Hi Ajay,

Quoted 13 lines · Ajay Bhargav

Dear Wolfgang,

Quoted 4 lines

Is there any specific reason for not using u32 for the padding as well?

nothing specific. It makes easy to find number of bytes than words.

Quoted 4 lines

Why would you need this BASE + OFFSET notation when using a C struct for the registers? Thi smakes little sense to me.

Quoted 6 lines

Well I did use the C struct method, if you see my patches submitted earlier but according to Prafulla and Lie structure size is too big. so they want me to use a mix of C struct and BASE + OFFSET notation. so I thought to break the big C struct into smaller grouped structures pointing each group with GPIO base + group offset. I would be glad if you can suggest me something better or smarter.

I think we make thing complicated here. For GPIO driver, the only structure we need to
define is the GPIO register itself, like GPIO_PLR, GPIO_PDR, etc...

For the previous long huge structure and include your recent short version is still not good
enough. What we want to get is the base address, and based on the register structure
to do explicit work. So either get the base address based on MACRO, or get from a function
I think both should be ok for me. But please not continue work on how to define the base
address into a structure.

Best regards,
Lei

#5 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

Hi Lei,

Quoted 4 lines

I think we make thing complicated here. For GPIO driver, the only structure we need to
define is the GPIO register itself, like GPIO_PLR, GPIO_PDR, etc...

I got your point, but lemme show you where the problem is..

GPIO_PLR0    0x0000
GPIO_PLR1    0x0004
GPIO_PLR2    0x0008
GPIO_PLR3    0x0100

till 3 registers its fine... fourth register is way out of league.

Regards,
Ajay Bhargav

#9 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

In reply to Ajay Bhargav

Dear Ajay Bhargav,

Quoted 5 lines · In message <[email protected]>…
Quoted 4 lines

Is there any specific reason for not using u32 for the padding as well?

nothing specific. It makes easy to find number of bytes than words.

If there is no specific reason (which I could not think of either), then please use u32 consistently.

If you think in number of bytes, feel free to write

	u32	reserved[128/sizeof(u32)];
Quoted 5 lines
Quoted 2 lines

Why would you need this BASE + OFFSET notation when using a C struct for the registers? Thi smakes little sense to me.

Well I did use the C struct method, if you see my patches submitted earlier but according to Prafulla and Lie structure size is too big. so they want me

Who cares about the size of the struct? We never alocate any memory for such a structure - it is just an overlay over the existing register space, so nobody cares if this is 16 kB of 16 MB.

Quoted 3 lines

to use a mix of C struct and BASE + OFFSET notation. so I thought to break the big C struct into smaller grouped structures pointing each group with GPIO base + group offset. I would be glad if you can suggest me something better or smarter.

This may make sense of you have separate, logically independent IP blocks. But the reason for such a desicion is if the data belong together in any way or not.

The "size" of such a structure is completely irrelevant.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Pray to God, but keep rowing to shore. - Russian Proverb
#6 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

In reply to Ajay Bhargav

Hi Ajay,

Quoted 7 lines · Ajay Bhargav

Hi Lei,

Quoted 4 lines

I think we make thing complicated here. For GPIO driver, the only structure we need to
define is the GPIO register itself, like GPIO_PLR, GPIO_PDR, etc...

Quoted 8 lines

I got your point, but lemme show you where the problem is.. GPIO_PLR0 ? ?0x0000
GPIO_PLR1 ? ?0x0004
GPIO_PLR2 ? ?0x0008
GPIO_PLR3 ? ?0x0100

till 3 registers its fine... fourth register is way out of league.

I know this is a bit tricky, but couldn't be included in a logic hidden by MACRO or funcion?

Best regards,
Lei

#8 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

In reply to Ajay Bhargav

Dear Ajay Bhargav,

Quoted 7 lines · In message <[email protected]>…

Hi Lei,

Quoted 4 lines

I think we make thing complicated here. For GPIO driver, the only structure we need to
define is the GPIO register itself, like GPIO_PLR, GPIO_PDR, etc...

Quoted 7 lines

I got your point, but lemme show you where the problem is..

GPIO_PLR0    0x0000
GPIO_PLR1    0x0004
GPIO_PLR2    0x0008
GPIO_PLR3    0x0100

till 3 registers its fine... fourth register is way out of league.

In which way? Just because there is a gap between? No problem. Insert a filler element to your struct.

Best regards,

Wolfgang Denk

Signature · 7 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
How many seconds are there in a year? If I tell you there are 3.155 x
10^7, you won't even try to remember it. On the other hand, who could
forget that, to within half a percent, pi seconds is  a  nanocentury.
                                               -- Tom Duff, Bell Labs
#7 lore raw

PATCH 1/4 gpio: Adds GPIO driver support for Armada100

In reply to Lei Wen
Quoted 18 lines · ----- "Lei Wen

Hi Ajay,

Quoted 5 lines · Ajay Bhargav

Hi Lei,

Quoted 3 lines

I think we make thing complicated here. For GPIO driver, the only structure we need to
define is the GPIO register itself, like GPIO_PLR, GPIO_PDR,

etc...

Quoted 8 lines
Quoted 1 line

I got your point, but lemme show you where the problem is.. GPIO_PLR0 ? ?0x0000
GPIO_PLR1 ? ?0x0004
GPIO_PLR2 ? ?0x0008
GPIO_PLR3 ? ?0x0100

Quoted 9 lines
Quoted 2 lines

till 3 registers its fine... fourth register is way out of league.

I know this is a bit tricky, but couldn't be included in a logic hidden by MACRO or funcion?

Best regards,
Lei

Hi Lei,

I am rewriting the whole logic. Will submit the patch soon :) I will use function to get base address.

Regards,
Ajay Bhargav