Commit f0a46f7a authored by Michael Gao's avatar Michael Gao Committed by Terry.Qiu

ARM: Davinci: created NTOSD_644XA machine

Signed-off-by: default avatarTerry.Qiu <tqiu@neuros.com.cn>
parent 6b8cb1a5
This diff is collapsed.
......@@ -10,6 +10,14 @@ config ARCH_DAVINCI644x
comment "DaVinci Board Type"
config MACH_DAVINCI_NTOSD_644XA
bool "Neuros OSD (644x Revision A)"
default n
depends on ARCH_DAVINCI644x
help
Configure this option to use Neuros OSD dm644x revision A
hardware.
config MACH_DAVINCI_EVM
bool "TI DaVinci EVM"
default y
......
......@@ -8,10 +8,12 @@ obj-y := time.o irq.o clock.o serial.o io.o id.o psc.o \
gpio.o mux.o dma.o devices.o
# Board specific
obj-$(CONFIG_MACH_DAVINCI_NTOSD_644XA) += board-ntosd-644xA.o i2c-emac.o
obj-$(CONFIG_MACH_DAVINCI_EVM) += board-evm.o i2c-emac.o
obj-$(CONFIG_DAVINCI_MCBSP) += mcbsp.o
obj-$(CONFIG_DAVINCI_I2C_EXPANDER) += i2c-client.o
ifeq ($(CONFIG_LEDS),y)
obj-$(CONFIG_MACH_DAVINCI_NTOSD_644XA) += leds-ntosd-644xA.o
obj-$(CONFIG_MACH_DAVINCI_EVM) += leds-evm.o
endif
/*
* Neuros OSD 644xA board support
*
* Modified from original EVM board support (see below).
* ----------------------------------------- 03/06, 2008 <mgao@neuros>
* 2008 (c) Neuros Technology, LLC.
*
* Author: Kevin Hilman, MontaVista Software, Inc. <source@mvista.com>
*
* 2007 (c) MontaVista Software, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/dma-mapping.h>
#include <linux/platform_device.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/mtd/physmap.h>
#include <asm/setup.h>
#include <asm/io.h>
#include <asm/mach-types.h>
#include <asm/hardware.h>
#include <asm/mach/arch.h>
#include <asm/mach/map.h>
#include <asm/mach/flash.h>
#include <asm/arch/common.h>
#include <asm/arch/hardware.h>
#include <asm/arch/psc.h>
/* other misc. init functions */
void __init davinci_psc_init(void);
void __init davinci_irq_init(void);
void __init davinci_map_common_io(void);
void __init davinci_init_common_hw(void);
/* NOR Flash base address set to CS0 by default */
#define NOR_FLASH_PHYS 0x02000000
static struct mtd_partition ntosd_644xa_norflash_partitions[] = {
/* bootloader (U-Boot, etc) in first 4 sectors */
{
.name = "bootloader",
.offset = 0,
.size = 4 * SZ_64K,
.mask_flags = MTD_WRITEABLE, /* force read-only */
},
/* bootloader params in the next 1 sectors */
{
.name = "params",
.offset = MTDPART_OFS_APPEND,
.size = SZ_64K,
.mask_flags = 0,
},
/* kernel */
{
.name = "kernel",
.offset = MTDPART_OFS_APPEND,
.size = SZ_2M,
.mask_flags = 0
},
/* file system */
{
.name = "filesystem",
.offset = MTDPART_OFS_APPEND,
.size = MTDPART_SIZ_FULL,
.mask_flags = 0
}
};
static struct physmap_flash_data ntosd_644xa_norflash_data = {
.width = 2,
.parts = ntosd_644xa_norflash_partitions,
.nr_parts = ARRAY_SIZE(ntosd_644xa_norflash_partitions),
};
/* NOTE: CFI probe will correctly detect flash part as 32M, but EMIF
* limits addresses to 16M, so using addresses past 16M will wrap */
static struct resource ntosd_644xa_norflash_resource = {
.start = NOR_FLASH_PHYS,
.end = NOR_FLASH_PHYS + SZ_16M - 1,
.flags = IORESOURCE_MEM,
};
static struct platform_device ntosd_644xa_norflash_device = {
.name = "physmap-flash",
.id = 0,
.dev = {
.platform_data = &ntosd_644xa_norflash_data,
},
.num_resources = 1,
.resource = &ntosd_644xa_norflash_resource,
};
#if defined(CONFIG_MTD_NAND_DAVINCI) || defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
struct mtd_partition ntosd_644xa_nandflash_partition[] = {
/* 5 MB space at the beginning for bootloader and kernel */
{
.name = "NAND filesystem",
.offset = 5 * SZ_1M,
.size = MTDPART_SIZ_FULL,
.mask_flags = 0,
}
};
static struct nand_platform_data ntosd_644xa_nandflash_data = {
.parts = ntosd_644xa_nandflash_partition,
.nr_parts = ARRAY_SIZE(ntosd_644xa_nandflash_partition),
};
static struct resource ntosd_644xa_nandflash_resource = {
.start = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE,
.end = DAVINCI_ASYNC_EMIF_DATA_CE0_BASE + SZ_16K - 1,
.flags = IORESOURCE_MEM,
};
static struct platform_device ntosd_644xa_nandflash_device = {
.name = "davinci_nand",
.id = 0,
.dev = {
.platform_data = &ntosd_644xa_nandflash_data,
},
.num_resources = 1,
.resource = &ntosd_644xa_nandflash_resource,
};
#endif
#if defined(CONFIG_FB_DAVINCI) || defined(CONFIG_FB_DAVINCI_MODULE)
static u64 davinci_fb_dma_mask = DMA_32BIT_MASK;
static struct platform_device davinci_fb_device = {
.name = "davincifb",
.id = -1,
.dev = {
.dma_mask = &davinci_fb_dma_mask,
.coherent_dma_mask = DMA_32BIT_MASK,
},
.num_resources = 0,
};
#endif
/*
* USB
*/
#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
#include <linux/usb/musb.h>
static struct musb_hdrc_platform_data usb_data = {
#if defined(CONFIG_USB_MUSB_OTG)
/* OTG requires a Mini-AB connector */
.mode = MUSB_OTG,
#elif defined(CONFIG_USB_MUSB_PERIPHERAL)
.mode = MUSB_PERIPHERAL,
#elif defined(CONFIG_USB_MUSB_HOST)
.mode = MUSB_HOST,
#endif
/* irlml6401 switches 5V */
.power = 250, /* sustains 3.0+ Amps (!) */
.potpgt = 4, /* ~8 msec */
/* REVISIT multipoint is a _chip_ capability; not board specific */
.multipoint = 1,
};
static struct resource usb_resources [] = {
{
/* physical address */
.start = DAVINCI_USB_OTG_BASE,
.end = DAVINCI_USB_OTG_BASE + 0x5ff,
.flags = IORESOURCE_MEM,
},
{
.start = IRQ_USBINT,
.flags = IORESOURCE_IRQ,
},
};
static u64 usb_dmamask = DMA_32BIT_MASK;
static struct platform_device usb_dev = {
.name = "musb_hdrc",
.id = -1,
.dev = {
.platform_data = &usb_data,
.dma_mask = &usb_dmamask,
.coherent_dma_mask = DMA_32BIT_MASK,
},
.resource = usb_resources,
.num_resources = ARRAY_SIZE(usb_resources),
};
#define setup_usb(void) do {} while(0)
#endif /* CONFIG_USB_MUSB_HDRC */
static struct platform_device rtc_dev = {
.name = "rtc_ntosd_644xa",
.id = -1,
};
static struct platform_device *ntosd_644xa_devices[] __initdata = {
&ntosd_644xa_norflash_device,
#if defined(CONFIG_MTD_NAND_DAVINCI) || defined(CONFIG_MTD_NAND_DAVINCI_MODULE)
&ntosd_644xa_nandflash_device,
#endif
#if defined(CONFIG_FB_DAVINCI) || defined(CONFIG_FB_DAVINCI_MODULE)
&davinci_fb_device,
#endif
#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE)
&usb_dev,
#endif
&rtc_dev,
};
static void __init
ntosd_644xa_map_io(void)
{
davinci_map_common_io();
}
static __init void ntosd_644xa_init(void)
{
davinci_psc_init();
#if defined(CONFIG_BLK_DEV_DAVINCI) || defined(CONFIG_BLK_DEV_DAVINCI_MODULE)
printk(KERN_WARNING "WARNING: both IDE and NOR flash are enabled, "
"but share pins.\n\t Disable IDE for NOR support.\n");
#endif
platform_add_devices(ntosd_644xa_devices,
ARRAY_SIZE(ntosd_644xa_devices));
setup_usb();
}
static __init void ntosd_644xa_irq_init(void)
{
davinci_init_common_hw();
davinci_irq_init();
}
MACHINE_START(NTOSD_644XA, "Neuros OSD 644x Revision A")
/* Maintainer: Neuros Technology, LLC */
.phys_io = IO_PHYS,
.io_pg_offst = (io_p2v(IO_PHYS) >> 18) & 0xfffc,
.boot_params = (DAVINCI_DDR_BASE + 0x100),
.map_io = ntosd_644xa_map_io,
.init_irq = ntosd_644xa_irq_init,
.timer = &davinci_timer,
.init_machine = ntosd_644xa_init,
MACHINE_END
/*
* <arch/arm/mach-davinci/leds-ntosd-644xA.c>
*
* LED support for Neuros OSD 644x revision A hardware.
*
* Modified from original TI code (see below).
* ----------------------------------------- 03/06, 2008 <mgao@neuros>
* 2008 (c) Neuros Technology, LLC.
*
* 2006 (c) Texas Instruments, Inc. This file is licensed under
* the terms of the GNU General Public License version 2. This program
* is licensed "as is" without any warranty of any kind, whether express
* or implied.
*/
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/types.h>
#include <linux/i2c.h>
#include <linux/errno.h>
#include <asm/mach-types.h>
#include <asm/hardware.h>
#include <asm/leds.h>
#include <asm/system.h>
/* eight leds on a pcf8574a I2C gpio expander; 0 == ON, 1 == OFF
* - drivers can use leds_event(led_{green,amber,red,blue}_{on,off})
* - userspace can do the same with /sys/devices/leds/leds0/event
*/
#define LED_DS8 (1 << 0)
#define LED_DS7 (1 << 1)
#define LED_DS6 (1 << 2)
#define LED_DS5 (1 << 3)
#define LED_DS4 (1 << 4)
#define LED_DS3 (1 << 5)
#define LED_DS2 (1 << 6)
#define LED_DS1 (1 << 7)
#define LED_STATE_ENABLED (1 << 8)
#define LED_STATE_CLAIMED (1 << 9)
static u16 hw_led_state;
static u8 leds_change;
/* these leds use I2C not GPIO, so we can't change values
* and remain "idle" ... so there's no "idle" LED.
*/
#define TIMER_LED LED_DS8
#define GREEN_LED LED_DS1
#define AMBER_LED LED_DS2
#define RED_LED LED_DS3
#define BLUE_LED LED_DS4
#define APP_LEDS (GREEN_LED | AMBER_LED | RED_LED | BLUE_LED)
static DEFINE_SPINLOCK(lock);
#define OSD_I2C_ADDR 0x38
static void pcf_work(struct work_struct *unused)
{
struct i2c_adapter *adap;
int err;
struct i2c_msg msg;
adap = i2c_get_adapter(0);
if (!adap)
return;
for (;;) {
static u8 leds;
spin_lock_irq(&lock);
leds = (u8) hw_led_state;
err= leds_change;
leds_change = 0;
spin_unlock_irq(&lock);
if (!err)
break;
msg.addr = OSD_I2C_ADDR;
msg.flags = 0;
msg.len = 1;
msg.buf = &leds;
err = i2c_transfer(adap, &msg, 1);
if (err < 0)
pr_debug("LED: set to %02x, err %d\n", leds, err);
}
}
static DECLARE_WORK(work, pcf_work);
static void osd_leds_event(led_event_t evt)
{
unsigned long flags;
u16 leds;
spin_lock_irqsave(&lock, flags);
if (!(hw_led_state & LED_STATE_ENABLED) && evt != led_start)
goto done;
leds = hw_led_state;
switch (evt) {
case led_start:
hw_led_state = LED_STATE_ENABLED | 0xff;
leds = 0;
break;
case led_halted:
case led_stop:
hw_led_state = 0xff;
// NOTE: work may still be pending!!
break;
case led_claim:
hw_led_state |= LED_STATE_CLAIMED;
hw_led_state |= APP_LEDS;
break;
case led_release:
hw_led_state &= ~LED_STATE_CLAIMED;
hw_led_state |= APP_LEDS;
break;
#ifdef CONFIG_LEDS_TIMER
case led_timer:
hw_led_state ^= TIMER_LED;
break;
#endif
/* actually all the LEDs are green */
case led_green_on:
if (leds & LED_STATE_CLAIMED)
hw_led_state &= ~GREEN_LED;
break;
case led_green_off:
if (leds & LED_STATE_CLAIMED)
hw_led_state |= GREEN_LED;
break;
case led_amber_on:
if (leds & LED_STATE_CLAIMED)
hw_led_state &= ~AMBER_LED;
break;
case led_amber_off:
if (leds & LED_STATE_CLAIMED)
hw_led_state |= AMBER_LED;
break;
case led_red_on:
if (leds & LED_STATE_CLAIMED)
hw_led_state &= ~RED_LED;
break;
case led_red_off:
if (leds & LED_STATE_CLAIMED)
hw_led_state |= RED_LED;
break;
case led_blue_on:
if (leds & LED_STATE_CLAIMED)
hw_led_state &= ~BLUE_LED;
break;
case led_blue_off:
if (leds & LED_STATE_CLAIMED)
hw_led_state |= BLUE_LED;
break;
default:
break;
}
leds ^= hw_led_state;
if (leds & 0xff) {
leds_change = (u8) leds;
schedule_work(&work);
}
done:
spin_unlock_irqrestore(&lock, flags);
}
static int __init osd_leds_init(void)
{
if (!machine_is_ntosd_644xa())
return 0;
leds_event = osd_leds_event;
leds_event(led_start);
return 0;
}
/* i2c is subsys_initcall, davinci i2c is device_initcall;
* this needs to follow both of them (sigh)
*/
late_initcall(osd_leds_init);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment