forked from Minki/linux
49cbe78637
"""The Marvell® PXA168 processor is the first in a family of application processors targeted at mass market opportunities in computing and consumer devices. It balances high computing and multimedia performance with low power consumption to support extended battery life, and includes a wealth of integrated peripherals to reduce overall BOM cost .... """ See http://www.marvell.com/featured/pxa168.jsp for more information. 1. Marvell Mohawk core is a hybrid of xscale3 and its own ARM core, there are many enhancements like instructions for flushing the whole D-cache, and so on 2. Clock reuses Russell's common clkdev, and added the basic support for UART1/2. 3. Devices are a bit different from the 'mach-pxa' way, the platform devices are now dynamically allocated only when necessary (i.e. when pxa_register_device() is called). Description for each device are stored in an array of 'struct pxa_device_desc'. Now that: a. this array of device description is marked with __initdata and can be freed up system is fully up b. which means board code has to add all needed devices early in his initializing function c. platform specific data can now be marked as __initdata since they are allocated and copied by platform_device_add_data() 4. only the basic UART1/2/3 are added, more devices will come later. Signed-off-by: Jason Chagas <chagas@marvell.com> Signed-off-by: Eric Miao <eric.miao@marvell.com>
70 lines
1.5 KiB
C
70 lines
1.5 KiB
C
/*
|
|
* linux/arch/arm/mach-mmp/devices.c
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*/
|
|
|
|
#include <linux/init.h>
|
|
#include <linux/platform_device.h>
|
|
#include <linux/dma-mapping.h>
|
|
|
|
#include <asm/irq.h>
|
|
#include <mach/devices.h>
|
|
|
|
int __init pxa_register_device(struct pxa_device_desc *desc,
|
|
void *data, size_t size)
|
|
{
|
|
struct platform_device *pdev;
|
|
struct resource res[2 + MAX_RESOURCE_DMA];
|
|
int i, ret = 0, nres = 0;
|
|
|
|
pdev = platform_device_alloc(desc->drv_name, desc->id);
|
|
if (pdev == NULL)
|
|
return -ENOMEM;
|
|
|
|
pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32);
|
|
|
|
memset(res, 0, sizeof(res));
|
|
|
|
if (desc->start != -1ul && desc->size > 0) {
|
|
res[nres].start = desc->start;
|
|
res[nres].end = desc->start + desc->size - 1;
|
|
res[nres].flags = IORESOURCE_MEM;
|
|
nres++;
|
|
}
|
|
|
|
if (desc->irq != NO_IRQ) {
|
|
res[nres].start = desc->irq;
|
|
res[nres].end = desc->irq;
|
|
res[nres].flags = IORESOURCE_IRQ;
|
|
nres++;
|
|
}
|
|
|
|
for (i = 0; i < MAX_RESOURCE_DMA; i++, nres++) {
|
|
if (desc->dma[i] == 0)
|
|
break;
|
|
|
|
res[nres].start = desc->dma[i];
|
|
res[nres].end = desc->dma[i];
|
|
res[nres].flags = IORESOURCE_DMA;
|
|
}
|
|
|
|
ret = platform_device_add_resources(pdev, res, nres);
|
|
if (ret) {
|
|
platform_device_put(pdev);
|
|
return ret;
|
|
}
|
|
|
|
if (data && size) {
|
|
ret = platform_device_add_data(pdev, data, size);
|
|
if (ret) {
|
|
platform_device_put(pdev);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
return platform_device_add(pdev);
|
|
}
|