public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ryan Mallon <ryan@bluewatersys.com>
To: Christian Glindkamp <christian.glindkamp@taskit.de>
Cc: Nicolas Ferre <nicolas.ferre@atmel.com>,
	Igor Plyatov <plyatov@gmail.com>,
	linux@arm.linux.org.uk, costa.antonior@gmail.com,
	linux-kernel@vger.kernel.org, plagnioj@jcrosoft.com,
	linux@maxim.org.za, linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2] mach-at91: Support for gms board added
Date: Thu, 09 Dec 2010 09:08:09 +1300	[thread overview]
Message-ID: <4CFFE5A9.4040407@bluewatersys.com> (raw)
In-Reply-To: <20101208145037.GA16435@taskit.de>

On 12/09/2010 03:50 AM, Christian Glindkamp wrote:
> On 2010-12-08 09:53, Nicolas Ferre wrote:
>> Hi Igor,
>>
>> Le 07/12/2010 20:53, Ryan Mallon :
>>> On 12/08/2010 03:42 AM, Igor Plyatov wrote:
>>>> * The gms is a board from GeoSIG Ltd company.
>>>>   It is based on the Stamp9G20 module from Taskit company.
>>>> * This is a second version of the patch with adjustments according
>>>>   to comments from Ryan Mallon.
>>>> * This patch made for Linux 2.6.37-rc5.
>>
>> First thank you for submitting this board support.
>>
>>>> Signed-off-by: Igor Plyatov <plyatov@gmail.com>
>>>> ---
>>
>> [..]
>>
>>> Couple more comments below.
>>> Looking at this a bit more closely, the Stamp9G20 is a system on module
>>> (SoM) board. The MACH_STAMP9G20 option supports the Stamp9G20 on
>>> taskits's evaluation board and the MACH_PCONTROL_G20 option supports it
>>> on the PControl carrier board. There is a reasonable amount of code
>>> replication in each of the board files for the UARTs, NAND, MMC, etc.
>>>
>>> Would it be better to have MACH_STAMPG20/board-stamp-9g20.c contain the
>>> core support for the Stamp9G20 module and then each of the carrier board
>>> files contain only the setup/devices found on the carrier board?
>>
>> I have exactly the same feeling as Ryan. We should make sure 
>> to factorize as much code as possible for maintenance reasons.
>>
>> If you need to distinguish between board features, you can 
>> pass information in system_rev as implemented in this 
>> board merging commit:
>> http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=a6e016f19d393fbe4e040bee8155b03b840fa689
>>
> 
> I don't think system_rev is such a good idea for carrier boards from
> different vendors. Somebody would have to control the assigned numbers.
> 
> This is what I would do:
> 1. Refactor board-stamp9g20.c have three board init functions:
> - portuxg20_board_init for PortuxG20 SBC (MACH_PORTUXG20)

I don't like the idea of having all of the carrier boards in the same
file as the SoM. Carrier boards may be developed by different people and
if there are a large number of them then the board files will start to
get quite big and confusing.

I think we need a standardised architecture for managing SoMs. A simple,
crude way would be to export the init functions from the SoM, i.e:
stam9g20_map_io and stamp9g20_board_init. Have the core SoM
functionality in those functions, for example in board-stamp9g20.c:

void __init stamp9g20_map_io(void)
{	
	/* Initialize processor: 18.432 MHz crystal */
	at91sam9260_initialize(18432000);

	/* DGBU on ttyS0. (Rx & Tx only) */
	at91_register_uart(0, 0, 0);

	/* USART0 on ttyS1. (Rx, Tx, CTS, RTS, DTR, DSR, DCD, RI) */
	at91_register_uart(AT91SAM9260_ID_US0, 1, ATMEL_UART_CTS
			| ATMEL_UART_RTS | ATMEL_UART_DTR
			| ATMEL_UART_DSR | ATMEL_UART_DCD
			| ATMEL_UART_RI);

	/* set serial console to ttyS0 (ie, DBGU) */
	at91_set_serial_console(0);
}
EXPORT_SYMBOL(stamp9g20_map_io);

and then have the carrier specific initialisation in board-portuxg20.c:

static void __init portuxg20_map_io(void)
{
	stamp9g20_map_io();
		
	/* USART1 on ttyS2. (Rx, Tx, CTS, RTS) */
	at91_register_uart(AT91SAM9260_ID_US1, 2,
			ATMEL_UART_CTS | ATMEL_UART_RTS);

	/* USART2 on ttyS3. (Rx, Tx, CTS, RTS) */
	at91_register_uart(AT91SAM9260_ID_US2, 3,
			 ATMEL_UART_CTS | ATMEL_UART_RTS);

	/* USART4 on ttyS5. (Rx, Tx only) */
	at91_register_uart(AT91SAM9260_ID_US4, 5, 0);
	
	/* USART5 on ttyS6. (Rx, Tx only) */
	at91_register_uart(AT91SAM9260_ID_US5, 6, 0);
}

This reduces code reuse, and also means that if the carrier board has
some esoteric setup it can do its own initialisation rather than calling
stamp9g20_map_io. The downsides to this approach are the necessity of
having the exported functions and the relationship between the SoM and
the carrier board is not completely clear.

Maybe having additional macros similar to MACHINE_START for SoMs so that
we can have a machine_desc type struct for the SoM and can do things
like som->map_io()?

> - stamp9g20_board_init only containing the functions used on the
>   Stamp9G20 alone

Agreed.

> - stamp9g20evb_board_init calling stamp9g20_board_init and adding
>   functionality of the evaluation board (MACH_STAMP9G20)
>
> 2. Modify board-pcontrol-g20.c to use stamp9g20_board_init

Okay, I think we are both for the same approach :-).

> This would still duplicate the UART config (there is not much to share,
> only the DBGU would be configured on all boards), but share NAND, MMC,
> 1-wire. Everything else can't be shared as it is carrier board specific.
> 
> The gms board would then have to have its own machine number and call
> stamp9g20_board_init.

~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

Ryan Mallon         		5 Amuri Park, 404 Barbadoes St
ryan@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

  reply	other threads:[~2010-12-08 20:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-07 14:42 [PATCH v2] mach-at91: Support for gms board added Igor Plyatov
2010-12-07 19:53 ` Ryan Mallon
2010-12-08  8:53   ` Nicolas Ferre
2010-12-08 14:03     ` Jean-Christophe PLAGNIOL-VILLARD
2010-12-08 19:29       ` Igor Plyatov
2010-12-08 14:50     ` Christian Glindkamp
2010-12-08 20:08       ` Ryan Mallon [this message]
2010-12-09 10:15         ` [PATCH] at91: Refactor Stamp9G20 and PControl G20 board file Christian Glindkamp
2010-12-10  3:38           ` Jean-Christophe PLAGNIOL-VILLARD
2010-12-10  9:03             ` Christian Glindkamp
2010-12-10  6:19           ` Igor Plyatov
     [not found]           ` <1291909193.6251.32.camel@homepc>
2010-12-10  8:44             ` Christian Glindkamp
2010-12-10  9:45               ` Nicolas Ferre
2010-12-08 19:26   ` [PATCH v2] mach-at91: Support for gms board added Igor Plyatov

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=4CFFE5A9.4040407@bluewatersys.com \
    --to=ryan@bluewatersys.com \
    --cc=christian.glindkamp@taskit.de \
    --cc=costa.antonior@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@arm.linux.org.uk \
    --cc=linux@maxim.org.za \
    --cc=nicolas.ferre@atmel.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=plyatov@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox