Re: [PATCH v2] ARM: davinci: aemif: get rid of davinci-nand driverdependency on aemif

From: Sekhar Nori
Date: Thu Nov 28 2013 - 23:41:17 EST


On Wednesday 27 November 2013 08:01 PM, Ivan Khoronzhuk wrote:
> The problem that the set timings code contains the call of Davinci
> platform function davinci_aemif_setup_timing() which is not
> accessible if kernel is built for another platform like Keystone.
>
> The Keysone platform is going to use TI AEMIF driver.
> If TI AEMIF is used we don't need to set timings and bus width.
> It is done by AEMIF driver.
>
> To get rid of davinci-nand driver dependency on aemif platform code
> we moved aemif code to davinci platform.
>
> The platform AEMIF code (aemif.c) has to be removed once Davinci
> will be converted to DT and use ti-aemif.c driver.
>
> The long device name "davinci_ntosd2_nandflash_device" was renamed
> to "ntosd2_nandflash" as requested by Sekhar Nori, because after
> adding changes the line is so broken that its almost unreadable.
>
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@xxxxxx>

This patch can be simplified in some places.

> ---
> v2..v1:
> - enabled AEMIF clock
> - removed EXPORT_SYMBOL(davinci_aemif_setup)
> - renamed ugly name davinci_ntosd2_nandflash_device
>
> CC:
> Sekhar Nori <nsekhar@xxxxxx>
>
> arch/arm/mach-davinci/aemif.c | 89 ++++++++++++++++++++++-
> arch/arm/mach-davinci/board-da830-evm.c | 3 +
> arch/arm/mach-davinci/board-da850-evm.c | 3 +
> arch/arm/mach-davinci/board-dm355-evm.c | 5 ++
> arch/arm/mach-davinci/board-dm355-leopard.c | 5 ++
> arch/arm/mach-davinci/board-dm365-evm.c | 4 +
> arch/arm/mach-davinci/board-dm644x-evm.c | 5 ++
> arch/arm/mach-davinci/board-dm646x-evm.c | 3 +
> arch/arm/mach-davinci/board-mityomapl138.c | 3 +
> arch/arm/mach-davinci/board-neuros-osd2.c | 13 +++-
> arch/arm/mach-davinci/devices-tnetv107x.c | 3 +
> drivers/mtd/nand/davinci_nand.c | 23 ------
> include/linux/platform_data/mtd-davinci-aemif.h | 5 +-

Most of these boards dont really have a timing structure defined.
Instead of blindly calling AEMIF setup on all boards, it can be
done only on boards that actually need it.

> /*
> * aemif_calc_rate - calculate timing data.
> * @wanted: The cycle time needed in nanoseconds.
> @@ -86,7 +98,7 @@ static int aemif_calc_rate(int wanted, unsigned long clk, int max)
> *
> * Returns 0 on success, else negative errno.
> */
> -int davinci_aemif_setup_timing(struct davinci_aemif_timing *t,
> +static int davinci_aemif_setup_timing(struct davinci_aemif_timing *t,

passing the clkrate to this function helps avoid a repeated clk_get().
I made these changes locally and here is the updated patch:

---8<---