From: ryan@bluewatersys.com (Ryan Mallon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 05/14] at91: use structure to store the current soc
Date: Wed, 27 Apr 2011 12:13:28 +1200 [thread overview]
Message-ID: <4DB75FA8.10207@bluewatersys.com> (raw)
In-Reply-To: <20110426234514.GC29103@game.jcrosoft.org>
On 04/27/2011 11:45 AM, Jean-Christophe PLAGNIOL-VILLARD wrote:
>>> yes it's for now we can use one soc at a time I'm working to remove those
>>> issue and make then soc specific
>>> before doint this I need to fix pm, interrupt, earlyprintk, ll_debug, etc...
>>>
>>> for gpio and timers it's already fix so one by one and it will be clean
>>> in those 2 we can now specify on the soc the resource so we do not need to
>>> have the same AT91_PIOx, AT91_ST and AT91_PIT for all soc
>>> they can have their own.
>>>
>>> When this cleanup will be finished we will have
>>> AT91SAM9263_PIOx AT91SAM9263_PIT etc...
>>> and only common define when they are really common
>>>>> all of this work is in preparation to allow multiple soc in the same kernel
>>>>> that's also why I map the system controller the same way on all at91 arm9
>>>> If the __cpu_is macros, which read the registers directly, remain then I
>>>> don't see how this can be generic between the various SoCs?
>>> because they will be use only at the begenning before any drivers or other ip
>>> enable so we can use them later it will not be the case anymore
>>>
>>> Best Regards,
>>> J.
>> I think that a better approach is to have only the cpu_is_ macros which
>> read the shadow value and then have at91_initialize (or some other
>> function which is init called before anything needs the cpu_is_ macros)
>> which just directly reads the cpu id registers and fills in the
>> structure. You won't need a structure that way either, just an id.
>> Something like:
>>
>> /* include/mach/cpu.h */
>>
>> /* Base SoC types */
>>
>> #define AT91_SOC_AT91RM9200 0x1
>> #define AT91_SOC_AT91SAM9260 0x2
>>
>> /* Extended SoC types */
>> #define AT91_SOC_AT91SAM9XE (0x1 << 16)
>>
>> /* Accessor macros */
>> #define AT91_SOC_TYPE(x) ((x) & 0xffff)
>> #define AT91_SOC_EXT_TYPE(x) (((x) >> 16) & 0xffff)
>>
>> extern unsigned long at91_soc_id;
>>
>> #define cpu_is_at91rm9200() (AT91_SOC_TYPE(at91_soc_id) == AT91_SOC_AT91RM9200)
>> #define cpu_is_at91sam9260() (AT91_SOC_TYPE(at91_soc_id) == AT91_SOC_AT91SAM9260)
>> #define cpu_is_at91sam9xe() (AT91_SOC_EXT_TYPE(at91_soc_id) == AT91_SOC_AT91SAM9XE)
>>
>> /* soc.c */
>> unsigned long at91_soc_id = 0;
>>
>> static void at91_detect_cpu(void)
>> {
>> unsigned long cpu_id, full_id, arch_id, exid;
>>
>>
>> full_id = at91_sys_read(AT91_DBGU_CIDR);
>> cpu_id = full_id & !AT91_CIDR_VERSION);
>> arch_id = full_id & AT91_CIDR_ARCH;
>> exid = at91_sys_read(AT91_DBGU_EXID);
>>
>> switch (cpu_id) {
>> case ARCH_ID_AT91RM9200:
>> at91_soc_id = AT91_SOC_AT91RM9200;
>> current_soc = at91rm9200_soc;
>> break;
>>
>> case ARCH_ID_AT91SAM9260:
>> at91_soc_id = AT91_SOC_AT91SAM9260;
>> if (arch_id == ARCH_FAMILY_AT91SAM9XE)
>> at91_soc_id |= AT91_SOC_AT91SAM9XE;
>> current_soc = at91sam9260_soc;
>> break;
>> ...
>>
>> default:
>> panic("Unknown AT91 SoC type\n");
>> }
>> }
>>
>>
>> This way the cpu detection code is much clearer and easier to read and
>> only one set of __cpu_is macros are needed. The values for
>> ARCH_ID_AT91RM9200, etc can be moved into soc.c since they are not
>> needed elsewhere.
> This will never work you do not listen
>
> the DBUG is at DIFFERENT base address on the AT91
> you need to check them one by one
>
> I keep the structure to keep more imformation inside and do not want to be
> limited by a 32bit and complex encoding to maintain
>
> Best Regards,
> J.
You can only be running one machine at a time. Are you implying that
this change breaks at91_sys_read in such a way that it reads the wrong
registers? If so, then its definitely a NAK.
Your patch does this:
static inline unsigned long at91_cpu_identify(void)
{
return (at91_sys_read(AT91_DBGU_CIDR) & ~AT91_CIDR_VERSION);
}
...
#ifdef CONFIG_ARCH_AT91RM9200
#define __cpu_is_at91rm9200() (at91_cpu_identify() == ARCH_ID_AT91RM9200)
#else
#define __cpu_is_at91rm9200() (0)
#endif
...
void __init at91_initialize(unsigned long main_clock)
{
...
if (__cpu_is_at91rm9200()) {
cpu_id.is_at91rm9200_soc;
current_soc = at91rm9200_soc;
}
...
}
So at91_initialize calls the __cpu_is macros, which in turn read the
AT91_DBGU registers via at91_sys_read. What I am proposing above is to
replace the massive collection of if statements with a simpler switch
statement and replacing the __cpu_is macros with direct register reads
via at91_sys_read, which results in far less code and more readable
code. If your version works, then how can mine not?
~Ryan
--
Bluewater Systems Ltd - ARM Technology Solution Centre
Ryan Mallon 5 Amuri Park, 404 Barbadoes St
ryan at bluewatersys.com PO Box 13 889, Christchurch 8013
http://www.bluewatersys.com New Zealand
Phone: +64 3 3779127 Freecall: Australia 1800 148 751
Fax: +64 3 3779135 USA 1800 261 2934
next prev parent reply other threads:[~2011-04-27 0:13 UTC|newest]
Thread overview: 85+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-25 18:08 [PATCH 0/14] at91: factorize soc init and switch to early platform Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 01/14] at91rm9200: introduce at91rm9200_set_type to specficy cpu package Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 02/14] at91: introduce commom AT91_BASE_SYS Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 21:48 ` Ryan Mallon
2011-04-26 4:27 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 03/14] at91: factorize at91 interrupts init to soc Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 21:52 ` Ryan Mallon
2011-04-25 22:11 ` H Hartley Sweeten
2011-04-26 17:29 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-26 22:04 ` Andrew Victor
2011-04-26 23:39 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 11:43 ` Russell King - ARM Linux
2011-04-25 18:31 ` [PATCH 04/14 v2] at91: merge board usb-a9260 and usb-a9263 together Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 05/14] at91: use structure to store the current soc Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 22:08 ` Ryan Mallon
2011-04-26 4:21 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-26 4:44 ` Ryan Mallon
2011-04-26 6:42 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-26 20:22 ` Ryan Mallon
2011-04-26 23:45 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-27 0:13 ` Ryan Mallon [this message]
2011-04-27 1:27 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-27 1:47 ` Ryan Mallon
2011-04-27 3:18 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-27 3:41 ` Ryan Mallon
2011-04-28 14:04 ` Andrew Victor
2011-04-28 14:10 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 20:20 ` Ryan Mallon
2011-04-28 23:06 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 23:24 ` Ryan Mallon
2011-04-29 2:10 ` Ryan Mallon
2011-04-29 8:32 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-29 8:35 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-29 8:50 ` Ryan Mallon
2011-05-02 15:38 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 20:25 ` Ryan Mallon
2011-05-02 20:24 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 20:38 ` Ryan Mallon
2011-05-02 20:51 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 21:27 ` Ryan Mallon
2011-05-02 21:29 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 22:05 ` Ryan Mallon
2011-05-02 22:06 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 22:32 ` Ryan Mallon
2011-05-02 22:41 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-02 23:16 ` Russell King - ARM Linux
2011-05-02 23:16 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 06/14 v3] at91: switch to CLKDEV_LOOKUP Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 07/14] at91: switch gpio to early platfrom device Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 22:51 ` Ryan Mallon
2011-04-26 4:11 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 08/14] at91: move gpio to drivers/gpio Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 09/14] at91: switch pit timer to early platform devices Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 5:07 ` Ryan Mallon
2011-04-28 11:23 ` Andrew Victor
2011-04-28 11:34 ` Russell King - ARM Linux
2011-04-28 13:15 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 16:56 ` Andrew Victor
2011-04-28 17:33 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 18:15 ` Russell King - ARM Linux
2011-04-28 20:47 ` Andrew Victor
2011-04-28 21:46 ` Russell King - ARM Linux
2011-04-28 23:38 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-29 9:28 ` Russell King - ARM Linux
2011-04-30 1:36 ` Jean-Christophe PLAGNIOL-VILLARD
2011-05-08 10:08 ` Russell King - ARM Linux
2011-05-08 10:44 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-29 7:55 ` Greg Ungerer
2011-04-29 6:08 ` Tony Lindgren
2011-04-29 8:31 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:31 ` [PATCH 10/14] at91: switch st " Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 18:40 ` [PATCH 11/14] at91: move pit timer to drivers/clocksource Jean-Christophe PLAGNIOL-VILLARD
2011-04-25 19:14 ` [PATCH 12/14] at91: move st " Jean-Christophe PLAGNIOL-VILLARD
2011-04-26 1:11 ` [PATCH 13/14] at91: move register clocks to soc generic init Jean-Christophe PLAGNIOL-VILLARD
2011-04-26 3:13 ` Ryan Mallon
2011-04-26 1:11 ` [PATCH 14/14] at91: move clock subsystem init " Jean-Christophe PLAGNIOL-VILLARD
2011-04-26 3:13 ` Ryan Mallon
2011-04-26 4:13 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-26 4:32 ` Ryan Mallon
2011-04-26 4:32 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-27 21:13 ` [PATCH 0/14] at91: factorize soc init and switch to early platform Ryan Mallon
2011-04-28 2:26 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 2:41 ` Jean-Christophe PLAGNIOL-VILLARD
2011-04-28 3:59 ` Ryan Mallon
2011-04-28 4:14 ` Jean-Christophe PLAGNIOL-VILLARD
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=4DB75FA8.10207@bluewatersys.com \
--to=ryan@bluewatersys.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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.