diff options
Diffstat (limited to 'arch/arm/mach-davinci')
85 files changed, 4834 insertions, 7378 deletions
diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index b77b860b36d..584e8d4e289 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig @@ -5,10 +5,11 @@ config AINTC  config CP_INTC  	bool +	select IRQ_DOMAIN  config ARCH_DAVINCI_DMx -	select CPU_ARM926T  	bool +	select CPU_ARM926T  menu "TI DaVinci Implementations" @@ -31,36 +32,41 @@ config ARCH_DAVINCI_DM646x  config ARCH_DAVINCI_DA830  	bool "DA830/OMAP-L137/AM17x based system" -	select CP_INTC  	select ARCH_DAVINCI_DA8XX  	select CPU_DCACHE_WRITETHROUGH # needed on silicon revs 1.0, 1.1 +	select CP_INTC  config ARCH_DAVINCI_DA850  	bool "DA850/OMAP-L138/AM18x based system" -	select CP_INTC  	select ARCH_DAVINCI_DA8XX -	select ARCH_HAS_CPUFREQ +	select CP_INTC  config ARCH_DAVINCI_DA8XX -	select CPU_ARM926T  	bool +	select CPU_ARM926T  config ARCH_DAVINCI_DM365  	bool "DaVinci 365 based system"  	select AINTC  	select ARCH_DAVINCI_DMx -config ARCH_DAVINCI_TNETV107X -	select CPU_V6 -	select CP_INTC -	bool "TNETV107X based system" -  comment "DaVinci Board Type" +config MACH_DA8XX_DT +	bool "Support DA8XX platforms using device tree" +	default y +	depends on ARCH_DAVINCI_DA8XX +	select PINCTRL +	help +	  Say y here to include support for TI DaVinci DA850 based using +	  Flattened Device Tree. More information at Documentation/devicetree +  config MACH_DAVINCI_EVM  	bool "TI DM644x EVM"  	default ARCH_DAVINCI_DM644x  	depends on ARCH_DAVINCI_DM644x +	select EEPROM_AT24 +	select I2C  	help  	  Configure this option to specify the whether the board used  	  for development is a DM644x EVM @@ -68,6 +74,8 @@ config MACH_DAVINCI_EVM  config MACH_SFFSDR  	bool "Lyrtech SFFSDR"  	depends on ARCH_DAVINCI_DM644x +	select EEPROM_AT24 +	select I2C  	help  	  Say Y here to select the Lyrtech Small Form Factor  	  Software Defined Radio (SFFSDR) board. @@ -98,6 +106,8 @@ config MACH_DAVINCI_DM6467_EVM  	bool "TI DM6467 EVM"  	default ARCH_DAVINCI_DM646x  	depends on ARCH_DAVINCI_DM646x +	select EEPROM_AT24 +	select I2C  	select MACH_DAVINCI_DM6467TEVM  	help  	  Configure this option to specify the whether the board used @@ -110,6 +120,8 @@ config MACH_DAVINCI_DM365_EVM  	bool "TI DM365 EVM"  	default ARCH_DAVINCI_DM365  	depends on ARCH_DAVINCI_DM365 +	select EEPROM_AT24 +	select I2C  	help  	  Configure this option to specify whether the board used  	  for development is a DM365 EVM @@ -118,7 +130,9 @@ config MACH_DAVINCI_DA830_EVM  	bool "TI DA830/OMAP-L137/AM17x Reference Platform"  	default ARCH_DAVINCI_DA830  	depends on ARCH_DAVINCI_DA830 +	select EEPROM_AT24  	select GPIO_PCF857X +	select I2C  	help  	  Say Y here to select the TI DA830/OMAP-L137/AM17x Evaluation Module. @@ -148,7 +162,6 @@ config MACH_DAVINCI_DA850_EVM  	bool "TI DA850/OMAP-L138/AM18x Reference Platform"  	default ARCH_DAVINCI_DA850  	depends on ARCH_DAVINCI_DA850 -	select GPIO_PCA953X  	help  	  Say Y here to select the TI DA850/OMAP-L138/AM18x Evaluation Module. @@ -176,18 +189,31 @@ config DA850_UI_RMII  	  NOTE: Please take care while choosing this option, MII PHY will  	  not be functional if RMII mode is selected. +config DA850_UI_SD_VIDEO_PORT +	bool "Video Port Interface" +	help +	  Say Y if you want to use Video Port Interface (VPIF) on the +	  DA850/OMAP-L138 EVM. The Video decoders/encoders are found on the +	  UI daughter card that is supplied with the EVM. +  endchoice -config MACH_TNETV107X -	bool "TI TNETV107X Reference Platform" -	default ARCH_DAVINCI_TNETV107X -	depends on ARCH_DAVINCI_TNETV107X +config DA850_WL12XX +	bool "AM18x wl1271 daughter board" +	depends on MACH_DAVINCI_DA850_EVM  	help -	  Say Y here to select the TI TNETV107X Evaluation Module. +	  The wl1271 daughter card for AM18x EVMs is a combo wireless +	  connectivity add-on card, based on the LS Research TiWi module with +	  Texas Instruments' wl1271 solution. +	  Say Y if you want to use a wl1271 expansion card connected to the +	  AM18x EVM. +  config MACH_MITYOMAPL138  	bool "Critical Link MityDSP-L138/MityARM-1808 SoM"  	depends on ARCH_DAVINCI_DA850 +	select EEPROM_AT24 +	select I2C  	help  	  Say Y here to select the Critical Link MityDSP-L138/MityARM-1808  	  System on Module.  Information on this SoM may be found at diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile index 0b87a1ca2bb..2204239ed24 100644 --- a/arch/arm/mach-davinci/Makefile +++ b/arch/arm/mach-davinci/Makefile @@ -4,8 +4,8 @@  #  # Common objects -obj-y 			:= time.o clock.o serial.o io.o psc.o \ -			   gpio.o dma.o usb.o common.o sram.o aemif.o +obj-y 			:= time.o clock.o serial.o psc.o \ +			   usb.o common.o sram.o aemif.o  obj-$(CONFIG_DAVINCI_MUX)		+= mux.o @@ -16,13 +16,12 @@ obj-$(CONFIG_ARCH_DAVINCI_DM646x)       += dm646x.o devices.o  obj-$(CONFIG_ARCH_DAVINCI_DM365)	+= dm365.o devices.o  obj-$(CONFIG_ARCH_DAVINCI_DA830)        += da830.o devices-da8xx.o  obj-$(CONFIG_ARCH_DAVINCI_DA850)        += da850.o devices-da8xx.o -obj-$(CONFIG_ARCH_DAVINCI_TNETV107X)    += tnetv107x.o devices-tnetv107x.o -obj-$(CONFIG_ARCH_DAVINCI_TNETV107X)    += gpio-tnetv107x.o  obj-$(CONFIG_AINTC)			+= irq.o  obj-$(CONFIG_CP_INTC)			+= cp_intc.o  # Board specific +obj-$(CONFIG_MACH_DA8XX_DT)		+= da8xx-dt.o  obj-$(CONFIG_MACH_DAVINCI_EVM)  	+= board-dm644x-evm.o  obj-$(CONFIG_MACH_SFFSDR)		+= board-sffsdr.o  obj-$(CONFIG_MACH_NEUROS_OSD2)		+= board-neuros-osd2.o @@ -32,11 +31,10 @@ obj-$(CONFIG_MACH_DAVINCI_DM6467_EVM)	+= board-dm646x-evm.o cdce949.o  obj-$(CONFIG_MACH_DAVINCI_DM365_EVM)	+= board-dm365-evm.o  obj-$(CONFIG_MACH_DAVINCI_DA830_EVM)	+= board-da830-evm.o  obj-$(CONFIG_MACH_DAVINCI_DA850_EVM)	+= board-da850-evm.o -obj-$(CONFIG_MACH_TNETV107X)		+= board-tnetv107x-evm.o  obj-$(CONFIG_MACH_MITYOMAPL138)		+= board-mityomapl138.o  obj-$(CONFIG_MACH_OMAPL138_HAWKBOARD)	+= board-omapl138-hawk.o  # Power Management -obj-$(CONFIG_CPU_FREQ)			+= cpufreq.o  obj-$(CONFIG_CPU_IDLE)			+= cpuidle.o  obj-$(CONFIG_SUSPEND)			+= pm.o sleep.o +obj-$(CONFIG_HAVE_CLK)			+= pm_domain.o diff --git a/arch/arm/mach-davinci/Makefile.boot b/arch/arm/mach-davinci/Makefile.boot index db97ef2c647..4b81601754a 100644 --- a/arch/arm/mach-davinci/Makefile.boot +++ b/arch/arm/mach-davinci/Makefile.boot @@ -1,13 +1,7 @@ -ifeq ($(CONFIG_ARCH_DAVINCI_DA8XX),y) -ifeq ($(CONFIG_ARCH_DAVINCI_DMx),y) -$(error Cannot enable DaVinci and DA8XX platforms concurrently) -else -   zreladdr-y	:= 0xc0008000 -params_phys-y	:= 0xc0000100 -initrd_phys-y	:= 0xc0800000 -endif -else -   zreladdr-y	:= 0x80008000 -params_phys-y	:= 0x80000100 -initrd_phys-y	:= 0x80800000 -endif +zreladdr-$(CONFIG_ARCH_DAVINCI_DA8XX)		+= 0xc0008000 +params_phys-$(CONFIG_ARCH_DAVINCI_DA8XX)	:= 0xc0000100 +initrd_phys-$(CONFIG_ARCH_DAVINCI_DA8XX)	:= 0xc0800000 + +zreladdr-$(CONFIG_ARCH_DAVINCI_DMx)		+= 0x80008000 +params_phys-$(CONFIG_ARCH_DAVINCI_DMx)		:= 0x80000100 +initrd_phys-$(CONFIG_ARCH_DAVINCI_DMx)		:= 0x80800000 diff --git a/arch/arm/mach-davinci/aemif.c b/arch/arm/mach-davinci/aemif.c index 9c3f500fc12..ff8b7e76b6e 100644 --- a/arch/arm/mach-davinci/aemif.c +++ b/arch/arm/mach-davinci/aemif.c @@ -15,7 +15,8 @@  #include <linux/module.h>  #include <linux/time.h> -#include <mach/aemif.h> +#include <linux/platform_data/mtd-davinci-aemif.h> +#include <linux/platform_data/mtd-davinci.h>  /* Timing value configuration */ @@ -43,6 +44,17 @@  				WSTROBE(WSTROBE_MAX) | \  				WSETUP(WSETUP_MAX)) +static inline unsigned int davinci_aemif_readl(void __iomem *base, int offset) +{ +	return readl_relaxed(base + offset); +} + +static inline void davinci_aemif_writel(void __iomem *base, +					int offset, unsigned long value) +{ +	writel_relaxed(value, base + offset); +} +  /*   * aemif_calc_rate - calculate timing data.   * @wanted: The cycle time needed in nanoseconds. @@ -76,6 +88,7 @@ static int aemif_calc_rate(int wanted, unsigned long clk, int max)   * @t: timing values to be progammed   * @base: The virtual base address of the AEMIF interface   * @cs: chip-select to program the timing values for + * @clkrate: the AEMIF clkrate   *   * This function programs the given timing values (in real clock) into the   * AEMIF registers taking the AEMIF clock into account. @@ -86,24 +99,17 @@ 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, -					void __iomem *base, unsigned cs) +static int davinci_aemif_setup_timing(struct davinci_aemif_timing *t, +					void __iomem *base, unsigned cs, +					unsigned long clkrate)  {  	unsigned set, val; -	unsigned ta, rhold, rstrobe, rsetup, whold, wstrobe, wsetup; +	int ta, rhold, rstrobe, rsetup, whold, wstrobe, wsetup;  	unsigned offset = A1CR_OFFSET + cs * 4; -	struct clk *aemif_clk; -	unsigned long clkrate;  	if (!t)  		return 0;	/* Nothing to do */ -	aemif_clk = clk_get(NULL, "aemif"); -	if (IS_ERR(aemif_clk)) -		return PTR_ERR(aemif_clk); - -	clkrate = clk_get_rate(aemif_clk); -  	clkrate /= 1000;	/* turn clock into kHz for ease of use */  	ta	= aemif_calc_rate(t->ta, clkrate, TA_MAX); @@ -130,4 +136,83 @@ int davinci_aemif_setup_timing(struct davinci_aemif_timing *t,  	return 0;  } -EXPORT_SYMBOL(davinci_aemif_setup_timing); + +/** + * davinci_aemif_setup - setup AEMIF interface by davinci_nand_pdata + * @pdev - link to platform device to setup settings for + * + * This function does not use any locking while programming the AEMIF + * because it is expected that there is only one user of a given + * chip-select. + * + * Returns 0 on success, else negative errno. + */ +int davinci_aemif_setup(struct platform_device *pdev) +{ +	struct davinci_nand_pdata *pdata = dev_get_platdata(&pdev->dev); +	uint32_t val; +	unsigned long clkrate; +	struct resource	*res; +	void __iomem *base; +	struct clk *clk; +	int ret = 0; + +	clk = clk_get(&pdev->dev, "aemif"); +	if (IS_ERR(clk)) { +		ret = PTR_ERR(clk); +		dev_dbg(&pdev->dev, "unable to get AEMIF clock, err %d\n", ret); +		return ret; +	} + +	ret = clk_prepare_enable(clk); +	if (ret < 0) { +		dev_dbg(&pdev->dev, "unable to enable AEMIF clock, err %d\n", +			ret); +		goto err_put; +	} + +	res = platform_get_resource(pdev, IORESOURCE_MEM, 1); +	if (!res) { +		dev_err(&pdev->dev, "cannot get IORESOURCE_MEM\n"); +		ret = -ENOMEM; +		goto err; +	} + +	base = ioremap(res->start, resource_size(res)); +	if (!base) { +		dev_err(&pdev->dev, "ioremap failed for resource %pR\n", res); +		ret = -ENOMEM; +		goto err; +	} + +	/* +	 * Setup Async configuration register in case we did not boot +	 * from NAND and so bootloader did not bother to set it up. +	 */ +	val = davinci_aemif_readl(base, A1CR_OFFSET + pdev->id * 4); +	/* +	 * Extended Wait is not valid and Select Strobe mode is not +	 * used +	 */ +	val &= ~(ACR_ASIZE_MASK | ACR_EW_MASK | ACR_SS_MASK); +	if (pdata->options & NAND_BUSWIDTH_16) +		val |= 0x1; + +	davinci_aemif_writel(base, A1CR_OFFSET + pdev->id * 4, val); + +	clkrate = clk_get_rate(clk); + +	if (pdata->timing) +		ret = davinci_aemif_setup_timing(pdata->timing, base, pdev->id, +						 clkrate); + +	if (ret < 0) +		dev_dbg(&pdev->dev, "NAND timing values setup fail\n"); + +	iounmap(base); +err: +	clk_disable_unprepare(clk); +err_put: +	clk_put(clk); +	return ret; +} diff --git a/arch/arm/mach-davinci/asp.h b/arch/arm/mach-davinci/asp.h new file mode 100644 index 00000000000..d9b2acd1239 --- /dev/null +++ b/arch/arm/mach-davinci/asp.h @@ -0,0 +1,49 @@ +/* + * TI DaVinci Audio definitions + */ +#ifndef __ASM_ARCH_DAVINCI_ASP_H +#define __ASM_ARCH_DAVINCI_ASP_H + +/* Bases of dm644x and dm355 register banks */ +#define DAVINCI_ASP0_BASE	0x01E02000 +#define DAVINCI_ASP1_BASE	0x01E04000 + +/* Bases of dm365 register banks */ +#define DAVINCI_DM365_ASP0_BASE	0x01D02000 + +/* Bases of dm646x register banks */ +#define DAVINCI_DM646X_MCASP0_REG_BASE		0x01D01000 +#define DAVINCI_DM646X_MCASP1_REG_BASE		0x01D01800 + +/* Bases of da850/da830 McASP0  register banks */ +#define DAVINCI_DA8XX_MCASP0_REG_BASE	0x01D00000 + +/* Bases of da830 McASP1 register banks */ +#define DAVINCI_DA830_MCASP1_REG_BASE	0x01D04000 + +/* EDMA channels of dm644x and dm355 */ +#define DAVINCI_DMA_ASP0_TX	2 +#define DAVINCI_DMA_ASP0_RX	3 +#define DAVINCI_DMA_ASP1_TX	8 +#define DAVINCI_DMA_ASP1_RX	9 + +/* EDMA channels of dm646x */ +#define DAVINCI_DM646X_DMA_MCASP0_AXEVT0	6 +#define DAVINCI_DM646X_DMA_MCASP0_AREVT0	9 +#define DAVINCI_DM646X_DMA_MCASP1_AXEVT1	12 + +/* EDMA channels of da850/da830 McASP0 */ +#define DAVINCI_DA8XX_DMA_MCASP0_AREVT	0 +#define DAVINCI_DA8XX_DMA_MCASP0_AXEVT	1 + +/* EDMA channels of da830 McASP1 */ +#define DAVINCI_DA830_DMA_MCASP1_AREVT	2 +#define DAVINCI_DA830_DMA_MCASP1_AXEVT	3 + +/* Interrupts */ +#define DAVINCI_ASP0_RX_INT	IRQ_MBRINT +#define DAVINCI_ASP0_TX_INT	IRQ_MBXINT +#define DAVINCI_ASP1_RX_INT	IRQ_MBRINT +#define DAVINCI_ASP1_TX_INT	IRQ_MBXINT + +#endif /* __ASM_ARCH_DAVINCI_ASP_H */ diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c index b52a3a1abd9..5623131c4f0 100644 --- a/arch/arm/mach-davinci/board-da830-evm.c +++ b/arch/arm/mach-davinci/board-da830-evm.c @@ -17,19 +17,24 @@  #include <linux/platform_device.h>  #include <linux/i2c.h>  #include <linux/i2c/pcf857x.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/mtd/mtd.h>  #include <linux/mtd/partitions.h> +#include <linux/spi/spi.h> +#include <linux/spi/flash.h> +#include <linux/platform_data/gpio-davinci.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/mtd-davinci-aemif.h> +#include <linux/platform_data/spi-davinci.h> +#include <linux/platform_data/usb-davinci.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h> +#include <mach/common.h>  #include <mach/cp_intc.h>  #include <mach/mux.h> -#include <mach/nand.h>  #include <mach/da8xx.h> -#include <mach/usb.h> -#include <mach/aemif.h>  #define DA830_EVM_PHY_ID		""  /* @@ -71,7 +76,7 @@ static int da830_evm_usb_ocic_notify(da8xx_ocic_handler_t handler)  	if (handler != NULL) {  		da830_evm_usb_ocic_handler = handler; -		error = request_irq(irq, da830_evm_usb_ocic_irq, IRQF_DISABLED | +		error = request_irq(irq, da830_evm_usb_ocic_irq,  				    IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,  				    "OHCI over-current indicator", NULL);  		if (error) @@ -182,10 +187,6 @@ static __init void da830_evm_usb_init(void)  			   __func__, ret);  } -static struct davinci_uart_config da830_evm_uart_config __initdata = { -	.enabled_uarts = 0x7, -}; -  static const short da830_evm_mcasp1_pins[] = {  	DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1, DA830_AHCLKR1, DA830_AFSR1,  	DA830_AMUTE1, DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_5, @@ -243,7 +244,6 @@ static struct davinci_mmc_config da830_evm_mmc_config = {  	.wires			= 8,  	.max_freq		= 50000000,  	.caps			= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, -	.version		= MMC_CTLR_VERSION_2,  };  static inline void da830_evm_init_mmc(void) @@ -295,11 +295,7 @@ static const short da830_evm_emif25_pins[] = {  	-1  }; -#if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE) -#define HAS_MMC	1 -#else -#define HAS_MMC	0 -#endif +#define HAS_MMC		IS_ENABLED(CONFIG_MMC_DAVINCI)  #ifdef CONFIG_DA830_UI_NAND  static struct mtd_partition da830_evm_nand_partitions[] = { @@ -374,7 +370,7 @@ static struct davinci_nand_pdata da830_evm_nand_pdata = {  	.nr_parts	= ARRAY_SIZE(da830_evm_nand_partitions),  	.ecc_mode	= NAND_ECC_HW,  	.ecc_bits	= 4, -	.options	= NAND_USE_FLASH_BBT, +	.bbt_options	= NAND_BBT_USE_FLASH,  	.bbt_td		= &da830_evm_nand_bbt_main_descr,  	.bbt_md		= &da830_evm_nand_bbt_mirror_descr,  	.timing         = &da830_evm_nandflash_timing, @@ -423,6 +419,9 @@ static inline void da830_evm_init_nand(int mux_mode)  	if (ret)  		pr_warning("da830_evm_init: NAND device not registered.\n"); +	if (davinci_aemif_setup(&da830_evm_nand_device)) +		pr_warn("%s: Cannot configure AEMIF.\n", __func__); +  	gpio_direction_output(mux_mode, 1);  }  #else @@ -534,11 +533,73 @@ static struct edma_rsv_info da830_edma_rsv[] = {  	},  }; +static struct mtd_partition da830evm_spiflash_part[] = { +	[0] = { +		.name = "DSP-UBL", +		.offset = 0, +		.size = SZ_8K, +		.mask_flags = MTD_WRITEABLE, +	}, +	[1] = { +		.name = "ARM-UBL", +		.offset = MTDPART_OFS_APPEND, +		.size = SZ_16K + SZ_8K, +		.mask_flags = MTD_WRITEABLE, +	}, +	[2] = { +		.name = "U-Boot", +		.offset = MTDPART_OFS_APPEND, +		.size = SZ_256K - SZ_32K, +		.mask_flags = MTD_WRITEABLE, +	}, +	[3] = { +		.name = "U-Boot-Environment", +		.offset = MTDPART_OFS_APPEND, +		.size = SZ_16K, +		.mask_flags = 0, +	}, +	[4] = { +		.name = "Kernel", +		.offset = MTDPART_OFS_APPEND, +		.size = MTDPART_SIZ_FULL, +		.mask_flags = 0, +	}, +}; + +static struct flash_platform_data da830evm_spiflash_data = { +	.name		= "m25p80", +	.parts		= da830evm_spiflash_part, +	.nr_parts	= ARRAY_SIZE(da830evm_spiflash_part), +	.type		= "w25x32", +}; + +static struct davinci_spi_config da830evm_spiflash_cfg = { +	.io_type	= SPI_IO_TYPE_DMA, +	.c2tdelay	= 8, +	.t2cdelay	= 8, +}; + +static struct spi_board_info da830evm_spi_info[] = { +	{ +		.modalias		= "m25p80", +		.platform_data		= &da830evm_spiflash_data, +		.controller_data	= &da830evm_spiflash_cfg, +		.mode			= SPI_MODE_0, +		.max_speed_hz		= 30000000, +		.bus_num		= 0, +		.chip_select		= 0, +	}, +}; +  static __init void da830_evm_init(void)  {  	struct davinci_soc_info *soc_info = &davinci_soc_info;  	int ret; +	ret = da830_register_gpio(); +	if (ret) +		pr_warn("da830_evm_init: GPIO init failed: %d\n", ret); +  	ret = da830_register_edma(da830_edma_rsv);  	if (ret)  		pr_warning("da830_evm_init: edma registration failed: %d\n", @@ -574,7 +635,7 @@ static __init void da830_evm_init(void)  		pr_warning("da830_evm_init: watchdog registration failed: %d\n",  				ret); -	davinci_serial_init(&da830_evm_uart_config); +	davinci_serial_init(da8xx_serial_device);  	i2c_register_board_info(1, da830_evm_i2c_devices,  			ARRAY_SIZE(da830_evm_i2c_devices)); @@ -590,6 +651,17 @@ static __init void da830_evm_init(void)  	ret = da8xx_register_rtc();  	if (ret)  		pr_warning("da830_evm_init: rtc setup failed: %d\n", ret); + +	ret = spi_register_board_info(da830evm_spi_info, +				      ARRAY_SIZE(da830evm_spi_info)); +	if (ret) +		pr_warn("%s: spi info registration failed: %d\n", __func__, +			ret); + +	ret = da8xx_register_spi_bus(0, ARRAY_SIZE(da830evm_spi_info)); +	if (ret) +		pr_warning("da830_evm_init: spi 0 registration failed: %d\n", +			   ret);  }  #ifdef CONFIG_SERIAL_8250_CONSOLE @@ -609,9 +681,12 @@ static void __init da830_evm_map_io(void)  }  MACHINE_START(DAVINCI_DA830_EVM, "DaVinci DA830/OMAP-L137/AM17x EVM") -	.boot_params	= (DA8XX_DDR_BASE + 0x100), +	.atag_offset	= 0x100,  	.map_io		= da830_evm_map_io,  	.init_irq	= cp_intc_init, -	.timer		= &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine	= da830_evm_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= da8xx_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-da850-evm.c b/arch/arm/mach-davinci/board-da850-evm.c index c6e11c682e4..234c5bb091f 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -11,41 +11,149 @@   * is licensed "as is" without any warranty of any kind, whether express   * or implied.   */ -#include <linux/kernel.h> -#include <linux/init.h>  #include <linux/console.h> +#include <linux/delay.h> +#include <linux/gpio.h> +#include <linux/gpio_keys.h> +#include <linux/init.h> +#include <linux/kernel.h>  #include <linux/i2c.h> -#include <linux/i2c/at24.h> -#include <linux/i2c/pca953x.h> +#include <linux/platform_data/at24.h> +#include <linux/platform_data/pca953x.h> +#include <linux/input.h> +#include <linux/input/tps6507x-ts.h>  #include <linux/mfd/tps6507x.h> -#include <linux/gpio.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 <linux/platform_device.h> +#include <linux/platform_data/gpio-davinci.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/mtd-davinci-aemif.h> +#include <linux/platform_data/spi-davinci.h> +#include <linux/platform_data/uio_pruss.h>  #include <linux/regulator/machine.h>  #include <linux/regulator/tps6507x.h> -#include <linux/input/tps6507x-ts.h> - -#include <asm/mach-types.h> -#include <asm/mach/arch.h> +#include <linux/spi/spi.h> +#include <linux/spi/flash.h> +#include <linux/wl12xx.h> +#include <mach/common.h>  #include <mach/cp_intc.h>  #include <mach/da8xx.h> -#include <mach/nand.h>  #include <mach/mux.h> -#include <mach/aemif.h> +#include <mach/sram.h> -#define DA850_EVM_PHY_ID		"0:00" +#include <asm/mach-types.h> +#include <asm/mach/arch.h> +#include <asm/system_info.h> + +#include <media/tvp514x.h> +#include <media/adv7343.h> + +#define DA850_EVM_PHY_ID		"davinci_mdio-0:00"  #define DA850_LCD_PWR_PIN		GPIO_TO_PIN(2, 8)  #define DA850_LCD_BL_PIN		GPIO_TO_PIN(2, 15)  #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)  #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1) +#define DA850_WLAN_EN			GPIO_TO_PIN(6, 9) +#define DA850_WLAN_IRQ			GPIO_TO_PIN(6, 10) +  #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6) +static struct mtd_partition da850evm_spiflash_part[] = { +	[0] = { +		.name = "UBL", +		.offset = 0, +		.size = SZ_64K, +		.mask_flags = MTD_WRITEABLE, +	}, +	[1] = { +		.name = "U-Boot", +		.offset = MTDPART_OFS_APPEND, +		.size = SZ_512K, +		.mask_flags = MTD_WRITEABLE, +	}, +	[2] = { +		.name = "U-Boot-Env", +		.offset = MTDPART_OFS_APPEND, +		.size = SZ_64K, +		.mask_flags = MTD_WRITEABLE, +	}, +	[3] = { +		.name = "Kernel", +		.offset = MTDPART_OFS_APPEND, +		.size = SZ_2M + SZ_512K, +		.mask_flags = 0, +	}, +	[4] = { +		.name = "Filesystem", +		.offset = MTDPART_OFS_APPEND, +		.size = SZ_4M, +		.mask_flags = 0, +	}, +	[5] = { +		.name = "MAC-Address", +		.offset = SZ_8M - SZ_64K, +		.size = SZ_64K, +		.mask_flags = MTD_WRITEABLE, +	}, +}; + +static struct flash_platform_data da850evm_spiflash_data = { +	.name		= "m25p80", +	.parts		= da850evm_spiflash_part, +	.nr_parts	= ARRAY_SIZE(da850evm_spiflash_part), +	.type		= "m25p64", +}; + +static struct davinci_spi_config da850evm_spiflash_cfg = { +	.io_type	= SPI_IO_TYPE_DMA, +	.c2tdelay	= 8, +	.t2cdelay	= 8, +}; + +static struct spi_board_info da850evm_spi_info[] = { +	{ +		.modalias		= "m25p80", +		.platform_data		= &da850evm_spiflash_data, +		.controller_data	= &da850evm_spiflash_cfg, +		.mode			= SPI_MODE_0, +		.max_speed_hz		= 30000000, +		.bus_num		= 1, +		.chip_select		= 0, +	}, +}; + +#ifdef CONFIG_MTD +static void da850_evm_m25p80_notify_add(struct mtd_info *mtd) +{ +	char *mac_addr = davinci_soc_info.emac_pdata->mac_addr; +	size_t retlen; + +	if (!strcmp(mtd->name, "MAC-Address")) { +		mtd_read(mtd, 0, ETH_ALEN, &retlen, mac_addr); +		if (retlen == ETH_ALEN) +			pr_info("Read MAC addr from SPI Flash: %pM\n", +				mac_addr); +	} +} + +static struct mtd_notifier da850evm_spi_notifier = { +	.add	= da850_evm_m25p80_notify_add, +}; + +static void da850_evm_setup_mac_addr(void) +{ +	register_mtd_user(&da850evm_spi_notifier); +} +#else +static void da850_evm_setup_mac_addr(void) { } +#endif +  static struct mtd_partition da850_evm_norflash_partition[] = {  	{  		.name           = "bootloaders + env", @@ -156,7 +264,7 @@ static struct davinci_nand_pdata da850_evm_nandflash_data = {  	.nr_parts	= ARRAY_SIZE(da850_evm_nandflash_partition),  	.ecc_mode	= NAND_ECC_HW,  	.ecc_bits	= 4, -	.options	= NAND_USE_FLASH_BBT, +	.bbt_options	= NAND_BBT_USE_FLASH,  	.timing		= &da850_evm_nandflash_timing,  }; @@ -183,7 +291,7 @@ static struct platform_device da850_evm_nandflash_device = {  	.resource	= da850_evm_nandflash_resource,  }; -static struct platform_device *da850_evm_devices[] __initdata = { +static struct platform_device *da850_evm_devices[] = {  	&da850_evm_nandflash_device,  	&da850_evm_norflash_device,  }; @@ -229,34 +337,30 @@ static const short da850_evm_nor_pins[] = {  	-1  }; -static u32 ui_card_detected; - -#if defined(CONFIG_MMC_DAVINCI) || \ -    defined(CONFIG_MMC_DAVINCI_MODULE) -#define HAS_MMC 1 -#else -#define HAS_MMC 0 -#endif +#define HAS_MMC		IS_ENABLED(CONFIG_MMC_DAVINCI)  static inline void da850_evm_setup_nor_nand(void)  {  	int ret = 0; -	if (ui_card_detected & !HAS_MMC) { +	if (!HAS_MMC) {  		ret = davinci_cfg_reg_list(da850_evm_nand_pins);  		if (ret) -			pr_warning("da850_evm_init: nand mux setup failed: " -					"%d\n", ret); +			pr_warn("%s: NAND mux setup failed: %d\n", +				__func__, ret);  		ret = davinci_cfg_reg_list(da850_evm_nor_pins);  		if (ret) -			pr_warning("da850_evm_init: nor mux setup failed: %d\n", -				ret); +			pr_warn("%s: NOR mux setup failed: %d\n", +				__func__, ret);  		da850_evm_init_nor();  		platform_add_devices(da850_evm_devices,  					ARRAY_SIZE(da850_evm_devices)); + +		if (davinci_aemif_setup(&da850_evm_nandflash_device)) +			pr_warn("%s: Cannot configure AEMIF.\n", __func__);  	}  } @@ -266,36 +370,126 @@ static inline void da850_evm_setup_emac_rmii(int rmii_sel)  	struct davinci_soc_info *soc_info = &davinci_soc_info;  	soc_info->emac_pdata->rmii_en = 1; -	gpio_set_value(rmii_sel, 0); +	gpio_set_value_cansleep(rmii_sel, 0);  }  #else  static inline void da850_evm_setup_emac_rmii(int rmii_sel) { }  #endif + +#define DA850_KEYS_DEBOUNCE_MS	10 +/* + * At 200ms polling interval it is possible to miss an + * event by tapping very lightly on the push button but most + * pushes do result in an event; longer intervals require the + * user to hold the button whereas shorter intervals require + * more CPU time for polling. + */ +#define DA850_GPIO_KEYS_POLL_MS	200 + +enum da850_evm_ui_exp_pins { +	DA850_EVM_UI_EXP_SEL_C = 5, +	DA850_EVM_UI_EXP_SEL_B, +	DA850_EVM_UI_EXP_SEL_A, +	DA850_EVM_UI_EXP_PB8, +	DA850_EVM_UI_EXP_PB7, +	DA850_EVM_UI_EXP_PB6, +	DA850_EVM_UI_EXP_PB5, +	DA850_EVM_UI_EXP_PB4, +	DA850_EVM_UI_EXP_PB3, +	DA850_EVM_UI_EXP_PB2, +	DA850_EVM_UI_EXP_PB1, +}; + +static const char * const da850_evm_ui_exp[] = { +	[DA850_EVM_UI_EXP_SEL_C]        = "sel_c", +	[DA850_EVM_UI_EXP_SEL_B]        = "sel_b", +	[DA850_EVM_UI_EXP_SEL_A]        = "sel_a", +	[DA850_EVM_UI_EXP_PB8]          = "pb8", +	[DA850_EVM_UI_EXP_PB7]          = "pb7", +	[DA850_EVM_UI_EXP_PB6]          = "pb6", +	[DA850_EVM_UI_EXP_PB5]          = "pb5", +	[DA850_EVM_UI_EXP_PB4]          = "pb4", +	[DA850_EVM_UI_EXP_PB3]          = "pb3", +	[DA850_EVM_UI_EXP_PB2]          = "pb2", +	[DA850_EVM_UI_EXP_PB1]          = "pb1", +}; + +#define DA850_N_UI_PB		8 + +static struct gpio_keys_button da850_evm_ui_keys[] = { +	[0 ... DA850_N_UI_PB - 1] = { +		.type			= EV_KEY, +		.active_low		= 1, +		.wakeup			= 0, +		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS, +		.code			= -1, /* assigned at runtime */ +		.gpio			= -1, /* assigned at runtime */ +		.desc			= NULL, /* assigned at runtime */ +	}, +}; + +static struct gpio_keys_platform_data da850_evm_ui_keys_pdata = { +	.buttons = da850_evm_ui_keys, +	.nbuttons = ARRAY_SIZE(da850_evm_ui_keys), +	.poll_interval = DA850_GPIO_KEYS_POLL_MS, +}; + +static struct platform_device da850_evm_ui_keys_device = { +	.name = "gpio-keys-polled", +	.id = 0, +	.dev = { +		.platform_data = &da850_evm_ui_keys_pdata +	}, +}; + +static void da850_evm_ui_keys_init(unsigned gpio) +{ +	int i; +	struct gpio_keys_button *button; + +	for (i = 0; i < DA850_N_UI_PB; i++) { +		button = &da850_evm_ui_keys[i]; +		button->code = KEY_F8 - i; +		button->desc = (char *) +				da850_evm_ui_exp[DA850_EVM_UI_EXP_PB8 + i]; +		button->gpio = gpio + DA850_EVM_UI_EXP_PB8 + i; +	} +} + +#ifdef CONFIG_DA850_UI_SD_VIDEO_PORT +static inline void da850_evm_setup_video_port(int video_sel) +{ +	gpio_set_value_cansleep(video_sel, 0); +} +#else +static inline void da850_evm_setup_video_port(int video_sel) { } +#endif +  static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,  						unsigned ngpio, void *c)  {  	int sel_a, sel_b, sel_c, ret; -	sel_a = gpio + 7; -	sel_b = gpio + 6; -	sel_c = gpio + 5; +	sel_a = gpio + DA850_EVM_UI_EXP_SEL_A; +	sel_b = gpio + DA850_EVM_UI_EXP_SEL_B; +	sel_c = gpio + DA850_EVM_UI_EXP_SEL_C; -	ret = gpio_request(sel_a, "sel_a"); +	ret = gpio_request(sel_a, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_A]);  	if (ret) { -		pr_warning("Cannot open UI expander pin %d\n", sel_a); +		pr_warn("Cannot open UI expander pin %d\n", sel_a);  		goto exp_setup_sela_fail;  	} -	ret = gpio_request(sel_b, "sel_b"); +	ret = gpio_request(sel_b, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_B]);  	if (ret) { -		pr_warning("Cannot open UI expander pin %d\n", sel_b); +		pr_warn("Cannot open UI expander pin %d\n", sel_b);  		goto exp_setup_selb_fail;  	} -	ret = gpio_request(sel_c, "sel_c"); +	ret = gpio_request(sel_c, da850_evm_ui_exp[DA850_EVM_UI_EXP_SEL_C]);  	if (ret) { -		pr_warning("Cannot open UI expander pin %d\n", sel_c); +		pr_warn("Cannot open UI expander pin %d\n", sel_c);  		goto exp_setup_selc_fail;  	} @@ -304,15 +498,25 @@ static int da850_evm_ui_expander_setup(struct i2c_client *client, unsigned gpio,  	gpio_direction_output(sel_b, 1);  	gpio_direction_output(sel_c, 1); -	ui_card_detected = 1; +	da850_evm_ui_keys_init(gpio); +	ret = platform_device_register(&da850_evm_ui_keys_device); +	if (ret) { +		pr_warn("Could not register UI GPIO expander push-buttons"); +		goto exp_setup_keys_fail; +	} +  	pr_info("DA850/OMAP-L138 EVM UI card detected\n");  	da850_evm_setup_nor_nand();  	da850_evm_setup_emac_rmii(sel_a); +	da850_evm_setup_video_port(sel_c); +  	return 0; +exp_setup_keys_fail: +	gpio_free(sel_c);  exp_setup_selc_fail:  	gpio_free(sel_b);  exp_setup_selb_fail: @@ -324,14 +528,192 @@ exp_setup_sela_fail:  static int da850_evm_ui_expander_teardown(struct i2c_client *client,  					unsigned gpio, unsigned ngpio, void *c)  { +	platform_device_unregister(&da850_evm_ui_keys_device); +  	/* deselect all functionalities */ -	gpio_set_value(gpio + 5, 1); -	gpio_set_value(gpio + 6, 1); -	gpio_set_value(gpio + 7, 1); +	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_C, 1); +	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_B, 1); +	gpio_set_value_cansleep(gpio + DA850_EVM_UI_EXP_SEL_A, 1); -	gpio_free(gpio + 5); -	gpio_free(gpio + 6); -	gpio_free(gpio + 7); +	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_C); +	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_B); +	gpio_free(gpio + DA850_EVM_UI_EXP_SEL_A); + +	return 0; +} + +/* assign the baseboard expander's GPIOs after the UI board's */ +#define DA850_UI_EXPANDER_N_GPIOS ARRAY_SIZE(da850_evm_ui_exp) +#define DA850_BB_EXPANDER_GPIO_BASE (DAVINCI_N_GPIO + DA850_UI_EXPANDER_N_GPIOS) + +enum da850_evm_bb_exp_pins { +	DA850_EVM_BB_EXP_DEEP_SLEEP_EN = 0, +	DA850_EVM_BB_EXP_SW_RST, +	DA850_EVM_BB_EXP_TP_23, +	DA850_EVM_BB_EXP_TP_22, +	DA850_EVM_BB_EXP_TP_21, +	DA850_EVM_BB_EXP_USER_PB1, +	DA850_EVM_BB_EXP_USER_LED2, +	DA850_EVM_BB_EXP_USER_LED1, +	DA850_EVM_BB_EXP_USER_SW1, +	DA850_EVM_BB_EXP_USER_SW2, +	DA850_EVM_BB_EXP_USER_SW3, +	DA850_EVM_BB_EXP_USER_SW4, +	DA850_EVM_BB_EXP_USER_SW5, +	DA850_EVM_BB_EXP_USER_SW6, +	DA850_EVM_BB_EXP_USER_SW7, +	DA850_EVM_BB_EXP_USER_SW8 +}; + +static const char * const da850_evm_bb_exp[] = { +	[DA850_EVM_BB_EXP_DEEP_SLEEP_EN]	= "deep_sleep_en", +	[DA850_EVM_BB_EXP_SW_RST]		= "sw_rst", +	[DA850_EVM_BB_EXP_TP_23]		= "tp_23", +	[DA850_EVM_BB_EXP_TP_22]		= "tp_22", +	[DA850_EVM_BB_EXP_TP_21]		= "tp_21", +	[DA850_EVM_BB_EXP_USER_PB1]		= "user_pb1", +	[DA850_EVM_BB_EXP_USER_LED2]		= "user_led2", +	[DA850_EVM_BB_EXP_USER_LED1]		= "user_led1", +	[DA850_EVM_BB_EXP_USER_SW1]		= "user_sw1", +	[DA850_EVM_BB_EXP_USER_SW2]		= "user_sw2", +	[DA850_EVM_BB_EXP_USER_SW3]		= "user_sw3", +	[DA850_EVM_BB_EXP_USER_SW4]		= "user_sw4", +	[DA850_EVM_BB_EXP_USER_SW5]		= "user_sw5", +	[DA850_EVM_BB_EXP_USER_SW6]		= "user_sw6", +	[DA850_EVM_BB_EXP_USER_SW7]		= "user_sw7", +	[DA850_EVM_BB_EXP_USER_SW8]		= "user_sw8", +}; + +#define DA850_N_BB_USER_SW	8 + +static struct gpio_keys_button da850_evm_bb_keys[] = { +	[0] = { +		.type			= EV_KEY, +		.active_low		= 1, +		.wakeup			= 0, +		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS, +		.code			= KEY_PROG1, +		.desc			= NULL, /* assigned at runtime */ +		.gpio			= -1, /* assigned at runtime */ +	}, +	[1 ... DA850_N_BB_USER_SW] = { +		.type			= EV_SW, +		.active_low		= 1, +		.wakeup			= 0, +		.debounce_interval	= DA850_KEYS_DEBOUNCE_MS, +		.code			= -1, /* assigned at runtime */ +		.desc			= NULL, /* assigned at runtime */ +		.gpio			= -1, /* assigned at runtime */ +	}, +}; + +static struct gpio_keys_platform_data da850_evm_bb_keys_pdata = { +	.buttons = da850_evm_bb_keys, +	.nbuttons = ARRAY_SIZE(da850_evm_bb_keys), +	.poll_interval = DA850_GPIO_KEYS_POLL_MS, +}; + +static struct platform_device da850_evm_bb_keys_device = { +	.name = "gpio-keys-polled", +	.id = 1, +	.dev = { +		.platform_data = &da850_evm_bb_keys_pdata +	}, +}; + +static void da850_evm_bb_keys_init(unsigned gpio) +{ +	int i; +	struct gpio_keys_button *button; + +	button = &da850_evm_bb_keys[0]; +	button->desc = (char *) +		da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_PB1]; +	button->gpio = gpio + DA850_EVM_BB_EXP_USER_PB1; + +	for (i = 0; i < DA850_N_BB_USER_SW; i++) { +		button = &da850_evm_bb_keys[i + 1]; +		button->code = SW_LID + i; +		button->desc = (char *) +				da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_SW1 + i]; +		button->gpio = gpio + DA850_EVM_BB_EXP_USER_SW1 + i; +	} +} + +#define DA850_N_BB_USER_LED	2 + +static struct gpio_led da850_evm_bb_leds[] = { +	[0 ... DA850_N_BB_USER_LED - 1] = { +		.active_low = 1, +		.gpio = -1, /* assigned at runtime */ +		.name = NULL, /* assigned at runtime */ +	}, +}; + +static struct gpio_led_platform_data da850_evm_bb_leds_pdata = { +	.leds = da850_evm_bb_leds, +	.num_leds = ARRAY_SIZE(da850_evm_bb_leds), +}; + +static struct platform_device da850_evm_bb_leds_device = { +	.name		= "leds-gpio", +	.id		= -1, +	.dev = { +		.platform_data = &da850_evm_bb_leds_pdata +	} +}; + +static void da850_evm_bb_leds_init(unsigned gpio) +{ +	int i; +	struct gpio_led *led; + +	for (i = 0; i < DA850_N_BB_USER_LED; i++) { +		led = &da850_evm_bb_leds[i]; + +		led->gpio = gpio + DA850_EVM_BB_EXP_USER_LED2 + i; +		led->name = +			da850_evm_bb_exp[DA850_EVM_BB_EXP_USER_LED2 + i]; +	} +} + +static int da850_evm_bb_expander_setup(struct i2c_client *client, +						unsigned gpio, unsigned ngpio, +						void *c) +{ +	int ret; + +	/* +	 * Register the switches and pushbutton on the baseboard as a gpio-keys +	 * device. +	 */ +	da850_evm_bb_keys_init(gpio); +	ret = platform_device_register(&da850_evm_bb_keys_device); +	if (ret) { +		pr_warn("Could not register baseboard GPIO expander keys"); +		goto io_exp_setup_sw_fail; +	} + +	da850_evm_bb_leds_init(gpio); +	ret = platform_device_register(&da850_evm_bb_leds_device); +	if (ret) { +		pr_warn("Could not register baseboard GPIO expander LEDs"); +		goto io_exp_setup_leds_fail; +	} + +	return 0; + +io_exp_setup_leds_fail: +	platform_device_unregister(&da850_evm_bb_keys_device); +io_exp_setup_sw_fail: +	return ret; +} + +static int da850_evm_bb_expander_teardown(struct i2c_client *client, +					unsigned gpio, unsigned ngpio, void *c) +{ +	platform_device_unregister(&da850_evm_bb_leds_device); +	platform_device_unregister(&da850_evm_bb_keys_device);  	return 0;  } @@ -340,6 +722,14 @@ static struct pca953x_platform_data da850_evm_ui_expander_info = {  	.gpio_base	= DAVINCI_N_GPIO,  	.setup		= da850_evm_ui_expander_setup,  	.teardown	= da850_evm_ui_expander_teardown, +	.names		= da850_evm_ui_exp, +}; + +static struct pca953x_platform_data da850_evm_bb_expander_info = { +	.gpio_base	= DA850_BB_EXPANDER_GPIO_BASE, +	.setup		= da850_evm_bb_expander_setup, +	.teardown	= da850_evm_bb_expander_teardown, +	.names		= da850_evm_bb_exp,  };  static struct i2c_board_info __initdata da850_evm_i2c_devices[] = { @@ -350,6 +740,10 @@ static struct i2c_board_info __initdata da850_evm_i2c_devices[] = {  		I2C_BOARD_INFO("tca6416", 0x20),  		.platform_data = &da850_evm_ui_expander_info,  	}, +	{ +		I2C_BOARD_INFO("tca6416", 0x21), +		.platform_data = &da850_evm_bb_expander_info, +	},  };  static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = { @@ -357,10 +751,6 @@ static struct davinci_i2c_platform_data da850_evm_i2c_0_pdata = {  	.bus_delay	= 0,	/* usec */  }; -static struct davinci_uart_config da850_evm_uart_config __initdata = { -	.enabled_uarts = 0x7, -}; -  /* davinci da850 evm audio machine driver */  static u8 da850_iis_serializer_direction[] = {  	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE,	INACTIVE_MODE, @@ -370,16 +760,26 @@ static u8 da850_iis_serializer_direction[] = {  };  static struct snd_platform_data da850_evm_snd_data = { -	.tx_dma_offset	= 0x2000, -	.rx_dma_offset	= 0x2000, -	.op_mode	= DAVINCI_MCASP_IIS_MODE, -	.num_serializer	= ARRAY_SIZE(da850_iis_serializer_direction), -	.tdm_slots	= 2, -	.serial_dir	= da850_iis_serializer_direction, -	.asp_chan_q	= EVENTQ_1, -	.version	= MCASP_VERSION_2, -	.txnumevt	= 1, -	.rxnumevt	= 1, +	.tx_dma_offset		= 0x2000, +	.rx_dma_offset		= 0x2000, +	.op_mode		= DAVINCI_MCASP_IIS_MODE, +	.num_serializer		= ARRAY_SIZE(da850_iis_serializer_direction), +	.tdm_slots		= 2, +	.serial_dir		= da850_iis_serializer_direction, +	.asp_chan_q		= EVENTQ_0, +	.ram_chan_q		= EVENTQ_1, +	.version		= MCASP_VERSION_2, +	.txnumevt		= 1, +	.rxnumevt		= 1, +	.sram_size_playback	= SZ_8K, +	.sram_size_capture	= SZ_8K, +}; + +static const short da850_evm_mcasp_pins[] __initconst = { +	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX, +	DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE, +	DA850_AXR_11, DA850_AXR_12, +	-1  };  static int da850_evm_mmc_get_ro(int index) @@ -398,7 +798,13 @@ static struct davinci_mmc_config da850_mmc_config = {  	.wires		= 4,  	.max_freq	= 50000000,  	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, -	.version	= MMC_CTLR_VERSION_2, +}; + +static const short da850_evm_mmcsd0_pins[] __initconst = { +	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2, +	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD, +	DA850_GPIO4_0, DA850_GPIO4_1, +	-1  };  static void da850_panel_power_ctrl(int val) @@ -540,7 +946,7 @@ static struct regulator_init_data tps65070_regulator_data[] = {  	{  		.constraints = {  			.min_uV = 950000, -			.max_uV = 1320000, +			.max_uV = 1350000,  			.valid_ops_mask = (REGULATOR_CHANGE_VOLTAGE |  				REGULATOR_CHANGE_STATUS),  			.boot_on = 1, @@ -580,7 +986,6 @@ static struct regulator_init_data tps65070_regulator_data[] = {  static struct touchscreen_init_data tps6507x_touchscreen_data = {  	.poll_period =  30,	/* ms between touch samples */  	.min_pressure = 0x30,	/* minimum pressure to trigger touch */ -	.vref = 0,		/* turn off vref when not using A/D */  	.vendor = 0,		/* /sys/class/input/input?/id/vendor */  	.product = 65070,	/* /sys/class/input/input?/id/product */  	.version = 0x100,	/* /sys/class/input/input?/id/version */ @@ -591,7 +996,7 @@ static struct tps6507x_board tps_board = {  	.tps6507x_ts_init_data = &tps6507x_touchscreen_data,  }; -static struct i2c_board_info __initdata da850evm_tps65070_info[] = { +static struct i2c_board_info __initdata da850_evm_tps65070_info[] = {  	{  		I2C_BOARD_INFO("tps6507x", 0x48),  		.platform_data = &tps_board, @@ -600,8 +1005,8 @@ static struct i2c_board_info __initdata da850evm_tps65070_info[] = {  static int __init pmic_tps65070_init(void)  { -	return i2c_register_board_info(1, da850evm_tps65070_info, -					ARRAY_SIZE(da850evm_tps65070_info)); +	return i2c_register_board_info(1, da850_evm_tps65070_info, +					ARRAY_SIZE(da850_evm_tps65070_info));  }  static const short da850_evm_lcdc_pins[] = { @@ -654,21 +1059,19 @@ static int __init da850_evm_config_emac(void)  	}  	if (ret) -		pr_warning("da850_evm_init: cpgmac/rmii mux setup failed: %d\n", -				ret); +		pr_warn("%s: CPGMAC/RMII mux setup failed: %d\n", +			__func__, ret);  	/* configure the CFGCHIP3 register for RMII or MII */  	__raw_writel(val, cfg_chip3_base);  	ret = davinci_cfg_reg(DA850_GPIO2_6);  	if (ret) -		pr_warning("da850_evm_init:GPIO(2,6) mux setup " -							"failed\n"); +		pr_warn("%s:GPIO(2,6) mux setup failed\n", __func__);  	ret = gpio_request(DA850_MII_MDIO_CLKEN_PIN, "mdio_clk_en");  	if (ret) { -		pr_warning("Cannot open GPIO %d\n", -					DA850_MII_MDIO_CLKEN_PIN); +		pr_warn("Cannot open GPIO %d\n", DA850_MII_MDIO_CLKEN_PIN);  		return ret;  	} @@ -679,8 +1082,7 @@ static int __init da850_evm_config_emac(void)  	ret = da8xx_register_emac();  	if (ret) -		pr_warning("da850_evm_init: emac registration failed: %d\n", -				ret); +		pr_warn("%s: EMAC registration failed: %d\n", __func__, ret);  	return 0;  } @@ -736,61 +1138,366 @@ static struct edma_rsv_info *da850_edma_rsv[2] = {  	&da850_edma_cc1_rsv,  }; +#ifdef CONFIG_CPU_FREQ +static __init int da850_evm_init_cpufreq(void) +{ +	switch (system_rev & 0xF) { +	case 3: +		da850_max_speed = 456000; +		break; +	case 2: +		da850_max_speed = 408000; +		break; +	case 1: +		da850_max_speed = 372000; +		break; +	} + +	return da850_register_cpufreq("pll0_sysclk3"); +} +#else +static __init int da850_evm_init_cpufreq(void) { return 0; } +#endif + +#if defined(CONFIG_DA850_UI_SD_VIDEO_PORT) + +#define TVP5147_CH0		"tvp514x-0" +#define TVP5147_CH1		"tvp514x-1" + +/* VPIF capture configuration */ +static struct tvp514x_platform_data tvp5146_pdata = { +		.clk_polarity = 0, +		.hs_polarity  = 1, +		.vs_polarity  = 1, +}; + +#define TVP514X_STD_ALL (V4L2_STD_NTSC | V4L2_STD_PAL) + +static const struct vpif_input da850_ch0_inputs[] = { +	{ +		.input = { +			.index = 0, +			.name  = "Composite", +			.type  = V4L2_INPUT_TYPE_CAMERA, +			.capabilities = V4L2_IN_CAP_STD, +			.std   = TVP514X_STD_ALL, +		}, +		.input_route = INPUT_CVBS_VI2B, +		.output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC, +		.subdev_name = TVP5147_CH0, +	}, +}; + +static const struct vpif_input da850_ch1_inputs[] = { +	{ +		.input = { +			.index = 0, +			.name  = "S-Video", +			.type  = V4L2_INPUT_TYPE_CAMERA, +			.capabilities = V4L2_IN_CAP_STD, +			.std   = TVP514X_STD_ALL, +		}, +		.input_route = INPUT_SVIDEO_VI2C_VI1C, +		.output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC, +		.subdev_name = TVP5147_CH1, +	}, +}; + +static struct vpif_subdev_info da850_vpif_capture_sdev_info[] = { +	{ +		.name = TVP5147_CH0, +		.board_info = { +			I2C_BOARD_INFO("tvp5146", 0x5d), +			.platform_data = &tvp5146_pdata, +		}, +	}, +	{ +		.name = TVP5147_CH1, +		.board_info = { +			I2C_BOARD_INFO("tvp5146", 0x5c), +			.platform_data = &tvp5146_pdata, +		}, +	}, +}; + +static struct vpif_capture_config da850_vpif_capture_config = { +	.subdev_info = da850_vpif_capture_sdev_info, +	.subdev_count = ARRAY_SIZE(da850_vpif_capture_sdev_info), +	.chan_config[0] = { +		.inputs = da850_ch0_inputs, +		.input_count = ARRAY_SIZE(da850_ch0_inputs), +		.vpif_if = { +			.if_type = VPIF_IF_BT656, +			.hd_pol  = 1, +			.vd_pol  = 1, +			.fid_pol = 0, +		}, +	}, +	.chan_config[1] = { +		.inputs = da850_ch1_inputs, +		.input_count = ARRAY_SIZE(da850_ch1_inputs), +		.vpif_if = { +			.if_type = VPIF_IF_BT656, +			.hd_pol  = 1, +			.vd_pol  = 1, +			.fid_pol = 0, +		}, +	}, +	.card_name = "DA850/OMAP-L138 Video Capture", +}; + +/* VPIF display configuration */ + +static struct adv7343_platform_data adv7343_pdata = { +	.mode_config = { +		.dac = { 1, 1, 1 }, +	}, +	.sd_config = { +		.sd_dac_out = { 1 }, +	}, +}; + +static struct vpif_subdev_info da850_vpif_subdev[] = { +	{ +		.name = "adv7343", +		.board_info = { +			I2C_BOARD_INFO("adv7343", 0x2a), +			.platform_data = &adv7343_pdata, +		}, +	}, +}; + +static const struct vpif_output da850_ch0_outputs[] = { +	{ +		.output = { +			.index = 0, +			.name = "Composite", +			.type = V4L2_OUTPUT_TYPE_ANALOG, +			.capabilities = V4L2_OUT_CAP_STD, +			.std = V4L2_STD_ALL, +		}, +		.subdev_name = "adv7343", +		.output_route = ADV7343_COMPOSITE_ID, +	}, +	{ +		.output = { +			.index = 1, +			.name = "S-Video", +			.type = V4L2_OUTPUT_TYPE_ANALOG, +			.capabilities = V4L2_OUT_CAP_STD, +			.std = V4L2_STD_ALL, +		}, +		.subdev_name = "adv7343", +		.output_route = ADV7343_SVIDEO_ID, +	}, +}; + +static struct vpif_display_config da850_vpif_display_config = { +	.subdevinfo   = da850_vpif_subdev, +	.subdev_count = ARRAY_SIZE(da850_vpif_subdev), +	.chan_config[0] = { +		.outputs = da850_ch0_outputs, +		.output_count = ARRAY_SIZE(da850_ch0_outputs), +	}, +	.card_name    = "DA850/OMAP-L138 Video Display", +}; + +static __init void da850_vpif_init(void) +{ +	int ret; + +	ret = da850_register_vpif(); +	if (ret) +		pr_warn("da850_evm_init: VPIF setup failed: %d\n", ret); + +	ret = davinci_cfg_reg_list(da850_vpif_capture_pins); +	if (ret) +		pr_warn("da850_evm_init: VPIF capture mux setup failed: %d\n", +			ret); + +	ret = da850_register_vpif_capture(&da850_vpif_capture_config); +	if (ret) +		pr_warn("da850_evm_init: VPIF capture setup failed: %d\n", ret); + +	ret = davinci_cfg_reg_list(da850_vpif_display_pins); +	if (ret) +		pr_warn("da850_evm_init: VPIF display mux setup failed: %d\n", +			ret); + +	ret = da850_register_vpif_display(&da850_vpif_display_config); +	if (ret) +		pr_warn("da850_evm_init: VPIF display setup failed: %d\n", ret); +} + +#else +static __init void da850_vpif_init(void) {} +#endif + +#ifdef CONFIG_DA850_WL12XX + +static void wl12xx_set_power(int index, bool power_on) +{ +	static bool power_state; + +	pr_debug("Powering %s wl12xx", power_on ? "on" : "off"); + +	if (power_on == power_state) +		return; +	power_state = power_on; + +	if (power_on) { +		/* Power up sequence required for wl127x devices */ +		gpio_set_value(DA850_WLAN_EN, 1); +		usleep_range(15000, 15000); +		gpio_set_value(DA850_WLAN_EN, 0); +		usleep_range(1000, 1000); +		gpio_set_value(DA850_WLAN_EN, 1); +		msleep(70); +	} else { +		gpio_set_value(DA850_WLAN_EN, 0); +	} +} + +static struct davinci_mmc_config da850_wl12xx_mmc_config = { +	.set_power	= wl12xx_set_power, +	.wires		= 4, +	.max_freq	= 25000000, +	.caps		= MMC_CAP_4_BIT_DATA | MMC_CAP_NONREMOVABLE | +			  MMC_CAP_POWER_OFF_CARD, +}; + +static const short da850_wl12xx_pins[] __initconst = { +	DA850_MMCSD1_DAT_0, DA850_MMCSD1_DAT_1, DA850_MMCSD1_DAT_2, +	DA850_MMCSD1_DAT_3, DA850_MMCSD1_CLK, DA850_MMCSD1_CMD, +	DA850_GPIO6_9, DA850_GPIO6_10, +	-1 +}; + +static struct wl12xx_platform_data da850_wl12xx_wlan_data __initdata = { +	.irq			= -1, +	.board_ref_clock	= WL12XX_REFCLOCK_38, +	.platform_quirks	= WL12XX_PLATFORM_QUIRK_EDGE_IRQ, +}; + +static __init int da850_wl12xx_init(void) +{ +	int ret; + +	ret = davinci_cfg_reg_list(da850_wl12xx_pins); +	if (ret) { +		pr_err("wl12xx/mmc mux setup failed: %d\n", ret); +		goto exit; +	} + +	ret = da850_register_mmcsd1(&da850_wl12xx_mmc_config); +	if (ret) { +		pr_err("wl12xx/mmc registration failed: %d\n", ret); +		goto exit; +	} + +	ret = gpio_request_one(DA850_WLAN_EN, GPIOF_OUT_INIT_LOW, "wl12xx_en"); +	if (ret) { +		pr_err("Could not request wl12xx enable gpio: %d\n", ret); +		goto exit; +	} + +	ret = gpio_request_one(DA850_WLAN_IRQ, GPIOF_IN, "wl12xx_irq"); +	if (ret) { +		pr_err("Could not request wl12xx irq gpio: %d\n", ret); +		goto free_wlan_en; +	} + +	da850_wl12xx_wlan_data.irq = gpio_to_irq(DA850_WLAN_IRQ); + +	ret = wl12xx_set_platform_data(&da850_wl12xx_wlan_data); +	if (ret) { +		pr_err("Could not set wl12xx data: %d\n", ret); +		goto free_wlan_irq; +	} + +	return 0; + +free_wlan_irq: +	gpio_free(DA850_WLAN_IRQ); + +free_wlan_en: +	gpio_free(DA850_WLAN_EN); + +exit: +	return ret; +} + +#else /* CONFIG_DA850_WL12XX */ + +static __init int da850_wl12xx_init(void) +{ +	return 0; +} + +#endif /* CONFIG_DA850_WL12XX */ + +#define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000) +  static __init void da850_evm_init(void)  {  	int ret; +	ret = da850_register_gpio(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret); +  	ret = pmic_tps65070_init();  	if (ret) -		pr_warning("da850_evm_init: TPS65070 PMIC init failed: %d\n", -				ret); +		pr_warn("%s: TPS65070 PMIC init failed: %d\n", __func__, ret);  	ret = da850_register_edma(da850_edma_rsv);  	if (ret) -		pr_warning("da850_evm_init: edma registration failed: %d\n", -				ret); +		pr_warn("%s: EDMA registration failed: %d\n", __func__, ret);  	ret = davinci_cfg_reg_list(da850_i2c0_pins);  	if (ret) -		pr_warning("da850_evm_init: i2c0 mux setup failed: %d\n", -				ret); +		pr_warn("%s: I2C0 mux setup failed: %d\n", __func__, ret);  	ret = da8xx_register_i2c(0, &da850_evm_i2c_0_pdata);  	if (ret) -		pr_warning("da850_evm_init: i2c0 registration failed: %d\n", -				ret); +		pr_warn("%s: I2C0 registration failed: %d\n", __func__, ret);  	ret = da8xx_register_watchdog();  	if (ret) -		pr_warning("da830_evm_init: watchdog registration failed: %d\n", -				ret); +		pr_warn("%s: watchdog registration failed: %d\n", +			__func__, ret);  	if (HAS_MMC) { -		ret = davinci_cfg_reg_list(da850_mmcsd0_pins); +		ret = davinci_cfg_reg_list(da850_evm_mmcsd0_pins);  		if (ret) -			pr_warning("da850_evm_init: mmcsd0 mux setup failed:" -					" %d\n", ret); +			pr_warn("%s: MMCSD0 mux setup failed: %d\n", +				__func__, ret);  		ret = gpio_request(DA850_MMCSD_CD_PIN, "MMC CD\n");  		if (ret) -			pr_warning("da850_evm_init: can not open GPIO %d\n", -					DA850_MMCSD_CD_PIN); +			pr_warn("%s: can not open GPIO %d\n", +				__func__, DA850_MMCSD_CD_PIN);  		gpio_direction_input(DA850_MMCSD_CD_PIN);  		ret = gpio_request(DA850_MMCSD_WP_PIN, "MMC WP\n");  		if (ret) -			pr_warning("da850_evm_init: can not open GPIO %d\n", -					DA850_MMCSD_WP_PIN); +			pr_warn("%s: can not open GPIO %d\n", +				__func__, DA850_MMCSD_WP_PIN);  		gpio_direction_input(DA850_MMCSD_WP_PIN);  		ret = da8xx_register_mmcsd0(&da850_mmc_config);  		if (ret) -			pr_warning("da850_evm_init: mmcsd0 registration failed:" -					" %d\n", ret); +			pr_warn("%s: MMCSD0 registration failed: %d\n", +				__func__, ret); + +		ret = da850_wl12xx_init(); +		if (ret) +			pr_warn("%s: WL12xx initialization failed: %d\n", +				__func__, ret);  	} -	davinci_serial_init(&da850_evm_uart_config); +	davinci_serial_init(da8xx_serial_device);  	i2c_register_board_info(1, da850_evm_i2c_devices,  			ARRAY_SIZE(da850_evm_i2c_devices)); @@ -803,53 +1510,75 @@ static __init void da850_evm_init(void)  	__raw_writel(0, IO_ADDRESS(DA8XX_UART1_BASE) + 0x30);  	__raw_writel(0, IO_ADDRESS(DA8XX_UART0_BASE) + 0x30); -	ret = davinci_cfg_reg_list(da850_mcasp_pins); +	ret = davinci_cfg_reg_list(da850_evm_mcasp_pins);  	if (ret) -		pr_warning("da850_evm_init: mcasp mux setup failed: %d\n", -				ret); +		pr_warn("%s: McASP mux setup failed: %d\n", __func__, ret); +	da850_evm_snd_data.sram_pool = sram_get_gen_pool();  	da8xx_register_mcasp(0, &da850_evm_snd_data);  	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);  	if (ret) -		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n", +		pr_warn("%s: LCDC mux setup failed: %d\n", __func__, ret); + +	ret = da8xx_register_uio_pruss(); +	if (ret) +		pr_warn("da850_evm_init: pruss initialization failed: %d\n",  				ret);  	/* Handle board specific muxing for LCD here */  	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);  	if (ret) -		pr_warning("da850_evm_init: evm specific lcd mux setup " -				"failed: %d\n",	ret); +		pr_warn("%s: EVM specific LCD mux setup failed: %d\n", +			__func__, ret);  	ret = da850_lcd_hw_init();  	if (ret) -		pr_warning("da850_evm_init: lcd initialization failed: %d\n", -				ret); +		pr_warn("%s: LCD initialization failed: %d\n", __func__, ret);  	sharp_lk043t1dg01_pdata.panel_power_ctrl = da850_panel_power_ctrl,  	ret = da8xx_register_lcdc(&sharp_lk043t1dg01_pdata);  	if (ret) -		pr_warning("da850_evm_init: lcdc registration failed: %d\n", -				ret); +		pr_warn("%s: LCDC registration failed: %d\n", __func__, ret);  	ret = da8xx_register_rtc();  	if (ret) -		pr_warning("da850_evm_init: rtc setup failed: %d\n", ret); +		pr_warn("%s: RTC setup failed: %d\n", __func__, ret); -	ret = da850_register_cpufreq("pll0_sysclk3"); +	ret = da850_evm_init_cpufreq();  	if (ret) -		pr_warning("da850_evm_init: cpufreq registration failed: %d\n", -				ret); +		pr_warn("%s: cpufreq registration failed: %d\n", __func__, ret);  	ret = da8xx_register_cpuidle();  	if (ret) -		pr_warning("da850_evm_init: cpuidle registration failed: %d\n", -				ret); +		pr_warn("%s: cpuidle registration failed: %d\n", __func__, ret);  	ret = da850_register_pm(&da850_pm_device);  	if (ret) -		pr_warning("da850_evm_init: suspend registration failed: %d\n", -				ret); +		pr_warn("%s: suspend registration failed: %d\n", __func__, ret); + +	da850_vpif_init(); + +	ret = spi_register_board_info(da850evm_spi_info, +				      ARRAY_SIZE(da850evm_spi_info)); +	if (ret) +		pr_warn("%s: spi info registration failed: %d\n", __func__, +			ret); + +	ret = da8xx_register_spi_bus(1, ARRAY_SIZE(da850evm_spi_info)); +	if (ret) +		pr_warn("%s: SPI 1 registration failed: %d\n", __func__, ret); + +	ret = da850_register_sata(DA850EVM_SATA_REFCLKPN_RATE); +	if (ret) +		pr_warn("%s: SATA registration failed: %d\n", __func__, ret); + +	da850_evm_setup_mac_addr(); + +	ret = da8xx_register_rproc(); +	if (ret) +		pr_warn("%s: dsp/rproc registration failed: %d\n", +			__func__, ret);  }  #ifdef CONFIG_SERIAL_8250_CONSOLE @@ -869,9 +1598,13 @@ static void __init da850_evm_map_io(void)  }  MACHINE_START(DAVINCI_DA850_EVM, "DaVinci DA850/OMAP-L138/AM18x EVM") -	.boot_params	= (DA8XX_DDR_BASE + 0x100), +	.atag_offset	= 0x100,  	.map_io		= da850_evm_map_io,  	.init_irq	= cp_intc_init, -	.timer		= &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine	= da850_evm_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= da8xx_restart, +	.reserve	= da8xx_rproc_reserve_cma,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-dm355-evm.c b/arch/arm/mach-davinci/board-dm355-evm.c index 6e7cad13352..06d63d5651f 100644 --- a/arch/arm/mach-davinci/board-dm355-evm.c +++ b/arch/arm/mach-davinci/board-dm355-evm.c @@ -22,16 +22,19 @@  #include <media/tvp514x.h>  #include <linux/spi/spi.h>  #include <linux/spi/eeprom.h> +#include <linux/platform_data/gpio-davinci.h> +#include <linux/platform_data/i2c-davinci.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/mmc-davinci.h> +#include <linux/platform_data/usb-davinci.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h> -#include <mach/dm355.h> -#include <mach/i2c.h>  #include <mach/serial.h> -#include <mach/nand.h> -#include <mach/mmc.h> -#include <mach/usb.h> +#include <mach/common.h> + +#include "davinci.h"  /* NOTE:  this is geared for the standard config, with a socketed   * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors.  If you @@ -77,7 +80,7 @@ static struct davinci_nand_pdata davinci_nand_data = {  	.parts			= davinci_nand_partitions,  	.nr_parts		= ARRAY_SIZE(davinci_nand_partitions),  	.ecc_mode		= NAND_ECC_HW, -	.options		= NAND_USE_FLASH_BBT, +	.bbt_options		= NAND_BBT_USE_FLASH,  	.ecc_bits		= 4,  }; @@ -241,19 +244,80 @@ static struct vpfe_config vpfe_cfg = {  	.ccdc = "DM355 CCDC",  }; +/* venc standards timings */ +static struct vpbe_enc_mode_info dm355evm_enc_preset_timing[] = { +	{ +		.name		= "ntsc", +		.timings_type	= VPBE_ENC_STD, +		.std_id		= V4L2_STD_NTSC, +		.interlaced	= 1, +		.xres		= 720, +		.yres		= 480, +		.aspect		= {11, 10}, +		.fps		= {30000, 1001}, +		.left_margin	= 0x79, +		.upper_margin	= 0x10, +	}, +	{ +		.name		= "pal", +		.timings_type	= VPBE_ENC_STD, +		.std_id		= V4L2_STD_PAL, +		.interlaced	= 1, +		.xres		= 720, +		.yres		= 576, +		.aspect		= {54, 59}, +		.fps		= {25, 1}, +		.left_margin	= 0x7E, +		.upper_margin	= 0x16 +	}, +}; + +#define VENC_STD_ALL	(V4L2_STD_NTSC | V4L2_STD_PAL) + +/* + * The outputs available from VPBE + ecnoders. Keep the + * the order same as that of encoders. First those from venc followed by that + * from encoders. Index in the output refers to index on a particular encoder. + * Driver uses this index to pass it to encoder when it supports more than + * one output. Application uses index of the array to set an output. + */ +static struct vpbe_output dm355evm_vpbe_outputs[] = { +	{ +		.output		= { +			.index		= 0, +			.name		= "Composite", +			.type		= V4L2_OUTPUT_TYPE_ANALOG, +			.std		= VENC_STD_ALL, +			.capabilities	= V4L2_OUT_CAP_STD, +		}, +		.subdev_name	= DM355_VPBE_VENC_SUBDEV_NAME, +		.default_mode	= "ntsc", +		.num_modes	= ARRAY_SIZE(dm355evm_enc_preset_timing), +		.modes		= dm355evm_enc_preset_timing, +		.if_params	= V4L2_MBUS_FMT_FIXED, +	}, +}; + +static struct vpbe_config dm355evm_display_cfg = { +	.module_name	= "dm355-vpbe-display", +	.i2c_adapter_id	= 1, +	.osd		= { +		.module_name	= DM355_VPBE_OSD_SUBDEV_NAME, +	}, +	.venc		= { +		.module_name	= DM355_VPBE_VENC_SUBDEV_NAME, +	}, +	.num_outputs	= ARRAY_SIZE(dm355evm_vpbe_outputs), +	.outputs	= dm355evm_vpbe_outputs, +}; +  static struct platform_device *davinci_evm_devices[] __initdata = {  	&dm355evm_dm9000,  	&davinci_nand_device,  }; -static struct davinci_uart_config uart_config __initdata = { -	.enabled_uarts = (1 << 0), -}; -  static void __init dm355_evm_map_io(void)  { -	/* setup input configuration for VPFE input devices */ -	dm355_set_vpfe_config(&vpfe_cfg);  	dm355_init();  } @@ -279,7 +343,6 @@ static struct davinci_mmc_config dm355evm_mmc_config = {  	.wires		= 4,  	.max_freq       = 50000000,  	.caps           = MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, -	.version	= MMC_CTLR_VERSION_1,  };  /* Don't connect anything to J10 unless you're only using USB host @@ -287,11 +350,7 @@ static struct davinci_mmc_config dm355evm_mmc_config = {   * you have proper Mini-B or Mini-A cables (or Mini-A adapters)   * the ID pin won't need any help.   */ -#ifdef CONFIG_USB_MUSB_PERIPHERAL -#define USB_ID_VALUE	0	/* ID pulled high; *should* float */ -#else  #define USB_ID_VALUE	1	/* ID pulled low */ -#endif  static struct spi_eeprom at25640a = {  	.byte_len	= SZ_64K / 8, @@ -314,6 +373,11 @@ static struct spi_board_info dm355_evm_spi_info[] __initconst = {  static __init void dm355_evm_init(void)  {  	struct clk *aemif; +	int ret; + +	ret = dm355_gpio_register(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);  	gpio_request(1, "dm9000");  	gpio_direction_input(1); @@ -323,12 +387,12 @@ static __init void dm355_evm_init(void)  	if (IS_ERR(aemif))  		WARN("%s: unable to get AEMIF clock\n", __func__);  	else -		clk_enable(aemif); +		clk_prepare_enable(aemif);  	platform_add_devices(davinci_evm_devices,  			     ARRAY_SIZE(davinci_evm_devices));  	evm_init_i2c(); -	davinci_serial_init(&uart_config); +	davinci_serial_init(dm355_serial_device);  	/* NOTE:  NAND flash timings set by the UBL are slower than  	 * needed by MT29F16G08FAA chips ... EMIF.A1CR is 0x40400204 @@ -343,6 +407,8 @@ static __init void dm355_evm_init(void)  	davinci_setup_mmc(0, &dm355evm_mmc_config);  	davinci_setup_mmc(1, &dm355evm_mmc_config); +	dm355_init_video(&vpfe_cfg, &dm355evm_display_cfg); +  	dm355_init_spi0(BIT(0), dm355_evm_spi_info,  			ARRAY_SIZE(dm355_evm_spi_info)); @@ -351,9 +417,12 @@ static __init void dm355_evm_init(void)  }  MACHINE_START(DAVINCI_DM355_EVM, "DaVinci DM355 EVM") -	.boot_params  = (0x80000100), +	.atag_offset  = 0x100,  	.map_io	      = dm355_evm_map_io,  	.init_irq     = davinci_irq_init, -	.timer	      = &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine = dm355_evm_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-dm355-leopard.c b/arch/arm/mach-davinci/board-dm355-leopard.c index 543f9911b28..680a7a2d910 100644 --- a/arch/arm/mach-davinci/board-dm355-leopard.c +++ b/arch/arm/mach-davinci/board-dm355-leopard.c @@ -19,16 +19,18 @@  #include <linux/clk.h>  #include <linux/spi/spi.h>  #include <linux/spi/eeprom.h> +#include <linux/platform_data/i2c-davinci.h> +#include <linux/platform_data/mmc-davinci.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/usb-davinci.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h> -#include <mach/dm355.h> -#include <mach/i2c.h> +#include <mach/common.h>  #include <mach/serial.h> -#include <mach/nand.h> -#include <mach/mmc.h> -#include <mach/usb.h> + +#include "davinci.h"  /* NOTE:  this is geared for the standard config, with a socketed   * 2 GByte Micron NAND (MT29F16G08FAA) using 128KB sectors.  If you @@ -74,7 +76,8 @@ static struct davinci_nand_pdata davinci_nand_data = {  	.parts			= davinci_nand_partitions,  	.nr_parts		= ARRAY_SIZE(davinci_nand_partitions),  	.ecc_mode		= NAND_ECC_HW_SYNDROME, -	.options		= NAND_USE_FLASH_BBT, +	.ecc_bits		= 4, +	.bbt_options		= NAND_BBT_USE_FLASH,  };  static struct resource davinci_nand_resources[] = { @@ -171,10 +174,6 @@ static struct platform_device *davinci_leopard_devices[] __initdata = {  	&davinci_nand_device,  }; -static struct davinci_uart_config uart_config __initdata = { -	.enabled_uarts = (1 << 0), -}; -  static void __init dm355_leopard_map_io(void)  {  	dm355_init(); @@ -209,11 +208,7 @@ static struct davinci_mmc_config dm355leopard_mmc_config = {   * you have proper Mini-B or Mini-A cables (or Mini-A adapters)   * the ID pin won't need any help.   */ -#ifdef CONFIG_USB_MUSB_PERIPHERAL -#define USB_ID_VALUE	0	/* ID pulled high; *should* float */ -#else  #define USB_ID_VALUE	1	/* ID pulled low */ -#endif  static struct spi_eeprom at25640a = {  	.byte_len	= SZ_64K / 8, @@ -236,6 +231,11 @@ static struct spi_board_info dm355_leopard_spi_info[] __initconst = {  static __init void dm355_leopard_init(void)  {  	struct clk *aemif; +	int ret; + +	ret = dm355_gpio_register(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);  	gpio_request(9, "dm9000");  	gpio_direction_input(9); @@ -245,12 +245,12 @@ static __init void dm355_leopard_init(void)  	if (IS_ERR(aemif))  		WARN("%s: unable to get AEMIF clock\n", __func__);  	else -		clk_enable(aemif); +		clk_prepare_enable(aemif);  	platform_add_devices(davinci_leopard_devices,  			     ARRAY_SIZE(davinci_leopard_devices));  	leopard_init_i2c(); -	davinci_serial_init(&uart_config); +	davinci_serial_init(dm355_serial_device);  	/* NOTE:  NAND flash timings set by the UBL are slower than  	 * needed by MT29F16G08FAA chips ... EMIF.A1CR is 0x40400204 @@ -270,9 +270,12 @@ static __init void dm355_leopard_init(void)  }  MACHINE_START(DM355_LEOPARD, "DaVinci DM355 leopard") -	.boot_params  = (0x80000100), +	.atag_offset  = 0x100,  	.map_io	      = dm355_leopard_map_io,  	.init_irq     = davinci_irq_init, -	.timer	      = &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine = dm355_leopard_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index c67f684ee3e..e08a8684ead 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -18,7 +18,7 @@  #include <linux/i2c.h>  #include <linux/io.h>  #include <linux/clk.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/leds.h>  #include <linux/mtd/mtd.h>  #include <linux/mtd/partitions.h> @@ -27,21 +27,24 @@  #include <linux/input.h>  #include <linux/spi/spi.h>  #include <linux/spi/eeprom.h> +#include <linux/v4l2-dv-timings.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h>  #include <mach/mux.h> -#include <mach/dm365.h>  #include <mach/common.h> -#include <mach/i2c.h> +#include <linux/platform_data/i2c-davinci.h>  #include <mach/serial.h> -#include <mach/mmc.h> -#include <mach/nand.h> -#include <mach/keyscan.h> +#include <linux/platform_data/mmc-davinci.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/keyscan-davinci.h> +#include <media/ths7303.h>  #include <media/tvp514x.h> +#include "davinci.h" +  static inline int have_imager(void)  {  	/* REVISIT when it's supported, trigger via Kconfig */ @@ -54,7 +57,7 @@ static inline int have_tvp7002(void)  	return 0;  } -#define DM365_EVM_PHY_ID		"0:01" +#define DM365_EVM_PHY_ID		"davinci_mdio-0:01"  /*   * A MAX-II CPLD is used for various board control functions.   */ @@ -107,7 +110,7 @@ static struct mtd_partition davinci_nand_partitions[] = {  		/* UBL (a few copies) plus U-Boot */  		.name		= "bootloader",  		.offset		= 0, -		.size		= 28 * NAND_BLOCK_SIZE, +		.size		= 30 * NAND_BLOCK_SIZE,  		.mask_flags	= MTD_WRITEABLE, /* force read-only */  	}, {  		/* U-Boot environment */ @@ -139,7 +142,7 @@ static struct davinci_nand_pdata davinci_nand_data = {  	.parts			= davinci_nand_partitions,  	.nr_parts		= ARRAY_SIZE(davinci_nand_partitions),  	.ecc_mode		= NAND_ECC_HW, -	.options		= NAND_USE_FLASH_BBT, +	.bbt_options		= NAND_BBT_USE_FLASH,  	.ecc_bits		= 4,  }; @@ -173,7 +176,7 @@ static struct at24_platform_data eeprom_info = {  	.context	= (void *)0x7f00,  }; -static struct snd_platform_data dm365_evm_snd_data = { +static struct snd_platform_data dm365_evm_snd_data __maybe_unused = {  	.asp_chan_q = EVENTQ_3,  }; @@ -252,7 +255,6 @@ static struct davinci_mmc_config dm365evm_mmc_config = {  	.wires		= 4,  	.max_freq	= 50000000,  	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, -	.version	= MMC_CTLR_VERSION_2,  };  static void dm365evm_emac_configure(void) @@ -373,6 +375,165 @@ static struct vpfe_config vpfe_cfg = {  	.ccdc = "ISIF",  }; +/* venc standards timings */ +static struct vpbe_enc_mode_info dm365evm_enc_std_timing[] = { +	{ +		.name		= "ntsc", +		.timings_type	= VPBE_ENC_STD, +		.std_id		= V4L2_STD_NTSC, +		.interlaced	= 1, +		.xres		= 720, +		.yres		= 480, +		.aspect		= {11, 10}, +		.fps		= {30000, 1001}, +		.left_margin	= 0x79, +		.upper_margin	= 0x10, +	}, +	{ +		.name		= "pal", +		.timings_type	= VPBE_ENC_STD, +		.std_id		= V4L2_STD_PAL, +		.interlaced	= 1, +		.xres		= 720, +		.yres		= 576, +		.aspect		= {54, 59}, +		.fps		= {25, 1}, +		.left_margin	= 0x7E, +		.upper_margin	= 0x16, +	}, +}; + +/* venc dv timings */ +static struct vpbe_enc_mode_info dm365evm_enc_preset_timing[] = { +	{ +		.name		= "480p59_94", +		.timings_type	= VPBE_ENC_DV_TIMINGS, +		.dv_timings	= V4L2_DV_BT_CEA_720X480P59_94, +		.interlaced	= 0, +		.xres		= 720, +		.yres		= 480, +		.aspect		= {1, 1}, +		.fps		= {5994, 100}, +		.left_margin	= 0x8F, +		.upper_margin	= 0x2D, +	}, +	{ +		.name		= "576p50", +		.timings_type	= VPBE_ENC_DV_TIMINGS, +		.dv_timings	= V4L2_DV_BT_CEA_720X576P50, +		.interlaced	= 0, +		.xres		= 720, +		.yres		= 576, +		.aspect		= {1, 1}, +		.fps		= {50, 1}, +		.left_margin	= 0x8C, +		.upper_margin   = 0x36, +	}, +	{ +		.name		= "720p60", +		.timings_type	= VPBE_ENC_DV_TIMINGS, +		.dv_timings	= V4L2_DV_BT_CEA_1280X720P60, +		.interlaced	= 0, +		.xres		= 1280, +		.yres		= 720, +		.aspect		= {1, 1}, +		.fps		= {60, 1}, +		.left_margin	= 0x117, +		.right_margin	= 70, +		.upper_margin	= 38, +		.lower_margin	= 3, +		.hsync_len	= 80, +		.vsync_len	= 5, +	}, +	{ +		.name		= "1080i60", +		.timings_type	= VPBE_ENC_DV_TIMINGS, +		.dv_timings	= V4L2_DV_BT_CEA_1920X1080I60, +		.interlaced	= 1, +		.xres		= 1920, +		.yres		= 1080, +		.aspect		= {1, 1}, +		.fps		= {30, 1}, +		.left_margin	= 0xc9, +		.right_margin	= 80, +		.upper_margin	= 30, +		.lower_margin	= 3, +		.hsync_len	= 88, +		.vsync_len	= 5, +	}, +}; + +#define VENC_STD_ALL	(V4L2_STD_NTSC | V4L2_STD_PAL) + +/* + * The outputs available from VPBE + ecnoders. Keep the + * the order same as that of encoders. First those from venc followed by that + * from encoders. Index in the output refers to index on a particular + * encoder.Driver uses this index to pass it to encoder when it supports more + * than one output. Application uses index of the array to set an output. + */ +static struct vpbe_output dm365evm_vpbe_outputs[] = { +	{ +		.output		= { +			.index		= 0, +			.name		= "Composite", +			.type		= V4L2_OUTPUT_TYPE_ANALOG, +			.std		= VENC_STD_ALL, +			.capabilities	= V4L2_OUT_CAP_STD, +		}, +		.subdev_name	= DM365_VPBE_VENC_SUBDEV_NAME, +		.default_mode	= "ntsc", +		.num_modes	= ARRAY_SIZE(dm365evm_enc_std_timing), +		.modes		= dm365evm_enc_std_timing, +		.if_params	= V4L2_MBUS_FMT_FIXED, +	}, +	{ +		.output		= { +			.index		= 1, +			.name		= "Component", +			.type		= V4L2_OUTPUT_TYPE_ANALOG, +			.capabilities	= V4L2_OUT_CAP_DV_TIMINGS, +		}, +		.subdev_name	= DM365_VPBE_VENC_SUBDEV_NAME, +		.default_mode	= "480p59_94", +		.num_modes	= ARRAY_SIZE(dm365evm_enc_preset_timing), +		.modes		= dm365evm_enc_preset_timing, +		.if_params	= V4L2_MBUS_FMT_FIXED, +	}, +}; + +/* + * Amplifiers on the board + */ +static struct ths7303_platform_data ths7303_pdata = { +	.ch_1 = 3, +	.ch_2 = 3, +	.ch_3 = 3, +}; + +static struct amp_config_info vpbe_amp = { +	.module_name	= "ths7303", +	.is_i2c		= 1, +	.board_info	= { +		I2C_BOARD_INFO("ths7303", 0x2c), +		.platform_data = &ths7303_pdata, +	} +}; + +static struct vpbe_config dm365evm_display_cfg = { +	.module_name	= "dm365-vpbe-display", +	.i2c_adapter_id	= 1, +	.amp		= &vpbe_amp, +	.osd		= { +		.module_name	= DM365_VPBE_OSD_SUBDEV_NAME, +	}, +	.venc		= { +		.module_name	= DM365_VPBE_VENC_SUBDEV_NAME, +	}, +	.num_outputs	= ARRAY_SIZE(dm365evm_vpbe_outputs), +	.outputs	= dm365evm_vpbe_outputs, +}; +  static void __init evm_init_i2c(void)  {  	davinci_init_i2c(&i2c_pdata); @@ -477,7 +638,7 @@ static void __init evm_init_cpld(void)  	aemif_clk = clk_get(NULL, "aemif");  	if (IS_ERR(aemif_clk))  		return; -	clk_enable(aemif_clk); +	clk_prepare_enable(aemif_clk);  	if (request_mem_region(DM365_ASYNC_EMIF_DATA_CE1_BASE, SECTION_SIZE,  			"cpld") == NULL) @@ -488,7 +649,7 @@ static void __init evm_init_cpld(void)  				SECTION_SIZE);  fail:  		pr_err("ERROR: can't map CPLD\n"); -		clk_disable(aemif_clk); +		clk_disable_unprepare(aemif_clk);  		return;  	} @@ -520,7 +681,7 @@ fail:  	 */  	if (have_imager()) {  		label = "HD imager"; -		mux |= 1; +		mux |= 2;  		/* externally mux MMC1/ENET/AIC33 to imager */  		mux |= BIT(6) | BIT(5) | BIT(3); @@ -540,7 +701,7 @@ fail:  		resets &= ~BIT(1);  		if (have_tvp7002()) { -			mux |= 2; +			mux |= 1;  			resets &= ~BIT(2);  			label = "tvp7002 HD";  		} else { @@ -557,14 +718,8 @@ fail:  	/* REVISIT export switches: NTSC/PAL (SW5.6), EXTRA1 (SW5.2), etc */  } -static struct davinci_uart_config uart_config __initdata = { -	.enabled_uarts = (1 << 0), -}; -  static void __init dm365_evm_map_io(void)  { -	/* setup input configuration for VPFE input devices */ -	dm365_set_vpfe_config(&vpfe_cfg);  	dm365_init();  } @@ -588,14 +743,22 @@ static struct spi_board_info dm365_evm_spi_info[] __initconst = {  static __init void dm365_evm_init(void)  { +	int ret; + +	ret = dm365_gpio_register(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret); +  	evm_init_i2c(); -	davinci_serial_init(&uart_config); +	davinci_serial_init(dm365_serial_device);  	dm365evm_emac_configure();  	dm365evm_mmc_configure();  	davinci_setup_mmc(0, &dm365evm_mmc_config); +	dm365_init_video(&vpfe_cfg, &dm365evm_display_cfg); +  	/* maybe setup mmc1/etc ... _after_ mmc0 */  	evm_init_cpld(); @@ -612,10 +775,13 @@ static __init void dm365_evm_init(void)  }  MACHINE_START(DAVINCI_DM365_EVM, "DaVinci DM365 EVM") -	.boot_params	= (0x80000100), +	.atag_offset	= 0x100,  	.map_io		= dm365_evm_map_io,  	.init_irq	= davinci_irq_init, -	.timer		= &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine	= dm365_evm_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-dm644x-evm.c b/arch/arm/mach-davinci/board-dm644x-evm.c index 0ca90b83458..e583e58b5e1 100644 --- a/arch/arm/mach-davinci/board-dm644x-evm.c +++ b/arch/arm/mach-davinci/board-dm644x-evm.c @@ -15,7 +15,7 @@  #include <linux/gpio.h>  #include <linux/i2c.h>  #include <linux/i2c/pcf857x.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/mtd/mtd.h>  #include <linux/mtd/nand.h>  #include <linux/mtd/partitions.h> @@ -23,23 +23,26 @@  #include <linux/phy.h>  #include <linux/clk.h>  #include <linux/videodev2.h> +#include <linux/v4l2-dv-timings.h> +#include <linux/export.h>  #include <media/tvp514x.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h> -#include <mach/dm644x.h>  #include <mach/common.h> -#include <mach/i2c.h> +#include <linux/platform_data/i2c-davinci.h>  #include <mach/serial.h>  #include <mach/mux.h> -#include <mach/nand.h> -#include <mach/mmc.h> -#include <mach/usb.h> -#include <mach/aemif.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/mmc-davinci.h> +#include <linux/platform_data/usb-davinci.h> +#include <linux/platform_data/mtd-davinci-aemif.h> -#define DM644X_EVM_PHY_ID		"0:01" +#include "davinci.h" + +#define DM644X_EVM_PHY_ID		"davinci_mdio-0:01"  #define LXT971_PHY_ID	(0x001378e2)  #define LXT971_PHY_MASK	(0xfffffff0) @@ -150,7 +153,8 @@ static struct davinci_nand_pdata davinci_evm_nandflash_data = {  	.parts		= davinci_evm_nandflash_partition,  	.nr_parts	= ARRAY_SIZE(davinci_evm_nandflash_partition),  	.ecc_mode	= NAND_ECC_HW, -	.options	= NAND_USE_FLASH_BBT, +	.ecc_bits	= 1, +	.bbt_options	= NAND_BBT_USE_FLASH,  	.timing		= &davinci_evm_nandflash_timing,  }; @@ -188,7 +192,7 @@ static struct platform_device davinci_fb_device = {  	.num_resources = 0,  }; -static struct tvp514x_platform_data tvp5146_pdata = { +static struct tvp514x_platform_data dm644xevm_tvp5146_pdata = {  	.clk_polarity = 0,  	.hs_polarity = 1,  	.vs_polarity = 1 @@ -196,7 +200,7 @@ static struct tvp514x_platform_data tvp5146_pdata = {  #define TVP514X_STD_ALL	(V4L2_STD_NTSC | V4L2_STD_PAL)  /* Inputs available at the TVP5146 */ -static struct v4l2_input tvp5146_inputs[] = { +static struct v4l2_input dm644xevm_tvp5146_inputs[] = {  	{  		.index = 0,  		.name = "Composite", @@ -216,7 +220,7 @@ static struct v4l2_input tvp5146_inputs[] = {   * ouput that goes to vpfe. There is a one to one correspondence   * with tvp5146_inputs   */ -static struct vpfe_route tvp5146_routes[] = { +static struct vpfe_route dm644xevm_tvp5146_routes[] = {  	{  		.input = INPUT_CVBS_VI2B,  		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC, @@ -227,13 +231,13 @@ static struct vpfe_route tvp5146_routes[] = {  	},  }; -static struct vpfe_subdev_info vpfe_sub_devs[] = { +static struct vpfe_subdev_info dm644xevm_vpfe_sub_devs[] = {  	{  		.name = "tvp5146",  		.grp_id = 0, -		.num_inputs = ARRAY_SIZE(tvp5146_inputs), -		.inputs = tvp5146_inputs, -		.routes = tvp5146_routes, +		.num_inputs = ARRAY_SIZE(dm644xevm_tvp5146_inputs), +		.inputs = dm644xevm_tvp5146_inputs, +		.routes = dm644xevm_tvp5146_routes,  		.can_route = 1,  		.ccdc_if_params = {  			.if_type = VPFE_BT656, @@ -242,15 +246,15 @@ static struct vpfe_subdev_info vpfe_sub_devs[] = {  		},  		.board_info = {  			I2C_BOARD_INFO("tvp5146", 0x5d), -			.platform_data = &tvp5146_pdata, +			.platform_data = &dm644xevm_tvp5146_pdata,  		},  	},  }; -static struct vpfe_config vpfe_cfg = { -	.num_subdevs = ARRAY_SIZE(vpfe_sub_devs), +static struct vpfe_config dm644xevm_capture_cfg = { +	.num_subdevs = ARRAY_SIZE(dm644xevm_vpfe_sub_devs),  	.i2c_adapter_id = 1, -	.sub_devs = vpfe_sub_devs, +	.sub_devs = dm644xevm_vpfe_sub_devs,  	.card_name = "DM6446 EVM",  	.ccdc = "DM6446 CCDC",  }; @@ -440,11 +444,6 @@ evm_u35_setup(struct i2c_client *client, int gpio, unsigned ngpio, void *c)  	gpio_request(gpio + 7, "nCF_SEL");  	gpio_direction_output(gpio + 7, 1); -	/* irlml6401 switches over 1A, in under 8 msec; -	 * now it can be managed by nDRV_VBUS ... -	 */ -	davinci_setup_usb(1000, 8); -  	return 0;  } @@ -521,13 +520,11 @@ static int dm6444evm_msp430_get_pins(void)  	char buf[4];  	struct i2c_msg msg[2] = {  		{ -			.addr = dm6446evm_msp->addr,  			.flags = 0,  			.len = 2,  			.buf = (void __force *)txbuf,  		},  		{ -			.addr = dm6446evm_msp->addr,  			.flags = I2C_M_RD,  			.len = 4,  			.buf = buf, @@ -538,6 +535,9 @@ static int dm6444evm_msp430_get_pins(void)  	if (!dm6446evm_msp)  		return -ENXIO; +	msg[0].addr = dm6446evm_msp->addr; +	msg[1].addr = dm6446evm_msp->addr; +  	/* Command 4 == get input state, returns port 2 and port3 data  	 *   S Addr W [A] len=2 [A] cmd=4 [A]  	 *   RS Addr R [A] [len=4] A [cmd=4] A [port2] A [port3] N P @@ -571,7 +571,6 @@ static struct davinci_mmc_config dm6446evm_mmc_config = {  	.get_cd		= dm6444evm_mmc_get_cd,  	.get_ro		= dm6444evm_mmc_get_ro,  	.wires		= 4, -	.version	= MMC_CTLR_VERSION_1  };  static struct i2c_board_info __initdata i2c_info[] =  { @@ -616,20 +615,121 @@ static void __init evm_init_i2c(void)  	i2c_register_board_info(1, i2c_info, ARRAY_SIZE(i2c_info));  } +#define VENC_STD_ALL	(V4L2_STD_NTSC | V4L2_STD_PAL) + +/* venc standard timings */ +static struct vpbe_enc_mode_info dm644xevm_enc_std_timing[] = { +	{ +		.name		= "ntsc", +		.timings_type	= VPBE_ENC_STD, +		.std_id		= V4L2_STD_NTSC, +		.interlaced	= 1, +		.xres		= 720, +		.yres		= 480, +		.aspect		= {11, 10}, +		.fps		= {30000, 1001}, +		.left_margin	= 0x79, +		.upper_margin	= 0x10, +	}, +	{ +		.name		= "pal", +		.timings_type	= VPBE_ENC_STD, +		.std_id		= V4L2_STD_PAL, +		.interlaced	= 1, +		.xres		= 720, +		.yres		= 576, +		.aspect		= {54, 59}, +		.fps		= {25, 1}, +		.left_margin	= 0x7e, +		.upper_margin	= 0x16, +	}, +}; + +/* venc dv preset timings */ +static struct vpbe_enc_mode_info dm644xevm_enc_preset_timing[] = { +	{ +		.name		= "480p59_94", +		.timings_type	= VPBE_ENC_DV_TIMINGS, +		.dv_timings	= V4L2_DV_BT_CEA_720X480P59_94, +		.interlaced	= 0, +		.xres		= 720, +		.yres		= 480, +		.aspect		= {1, 1}, +		.fps		= {5994, 100}, +		.left_margin	= 0x80, +		.upper_margin	= 0x20, +	}, +	{ +		.name		= "576p50", +		.timings_type	= VPBE_ENC_DV_TIMINGS, +		.dv_timings	= V4L2_DV_BT_CEA_720X576P50, +		.interlaced	= 0, +		.xres		= 720, +		.yres		= 576, +		.aspect		= {1, 1}, +		.fps		= {50, 1}, +		.left_margin	= 0x7e, +		.upper_margin	= 0x30, +	}, +}; + +/* + * The outputs available from VPBE + encoders. Keep the order same + * as that of encoders. First those from venc followed by that from + * encoders. Index in the output refers to index on a particular encoder. + * Driver uses this index to pass it to encoder when it supports more + * than one output. Userspace applications use index of the array to + * set an output. + */ +static struct vpbe_output dm644xevm_vpbe_outputs[] = { +	{ +		.output		= { +			.index		= 0, +			.name		= "Composite", +			.type		= V4L2_OUTPUT_TYPE_ANALOG, +			.std		= VENC_STD_ALL, +			.capabilities	= V4L2_OUT_CAP_STD, +		}, +		.subdev_name	= DM644X_VPBE_VENC_SUBDEV_NAME, +		.default_mode	= "ntsc", +		.num_modes	= ARRAY_SIZE(dm644xevm_enc_std_timing), +		.modes		= dm644xevm_enc_std_timing, +	}, +	{ +		.output		= { +			.index		= 1, +			.name		= "Component", +			.type		= V4L2_OUTPUT_TYPE_ANALOG, +			.capabilities	= V4L2_OUT_CAP_DV_TIMINGS, +		}, +		.subdev_name	= DM644X_VPBE_VENC_SUBDEV_NAME, +		.default_mode	= "480p59_94", +		.num_modes	= ARRAY_SIZE(dm644xevm_enc_preset_timing), +		.modes		= dm644xevm_enc_preset_timing, +	}, +}; + +static struct vpbe_config dm644xevm_display_cfg = { +	.module_name	= "dm644x-vpbe-display", +	.i2c_adapter_id	= 1, +	.osd		= { +		.module_name	= DM644X_VPBE_OSD_SUBDEV_NAME, +	}, +	.venc		= { +		.module_name	= DM644X_VPBE_VENC_SUBDEV_NAME, +	}, +	.num_outputs	= ARRAY_SIZE(dm644xevm_vpbe_outputs), +	.outputs	= dm644xevm_vpbe_outputs, +}; +  static struct platform_device *davinci_evm_devices[] __initdata = {  	&davinci_fb_device,  	&rtc_dev,  }; -static struct davinci_uart_config uart_config __initdata = { -	.enabled_uarts = (1 << 0), -}; -  static void __init  davinci_evm_map_io(void)  { -	/* setup input configuration for VPFE input devices */ -	dm644x_set_vpfe_config(&vpfe_cfg);  	dm644x_init();  } @@ -646,34 +746,24 @@ static int davinci_phy_fixup(struct phy_device *phydev)  	return 0;  } -#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ -    defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) -#define HAS_ATA 1 -#else -#define HAS_ATA 0 -#endif - -#if defined(CONFIG_MTD_PHYSMAP) || \ -    defined(CONFIG_MTD_PHYSMAP_MODULE) -#define HAS_NOR 1 -#else -#define HAS_NOR 0 -#endif - -#if defined(CONFIG_MTD_NAND_DAVINCI) || \ -    defined(CONFIG_MTD_NAND_DAVINCI_MODULE) -#define HAS_NAND 1 -#else -#define HAS_NAND 0 -#endif +#define HAS_ATA		IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) + +#define HAS_NOR		IS_ENABLED(CONFIG_MTD_PHYSMAP) + +#define HAS_NAND	IS_ENABLED(CONFIG_MTD_NAND_DAVINCI)  static __init void davinci_evm_init(void)  { +	int ret;  	struct clk *aemif_clk;  	struct davinci_soc_info *soc_info = &davinci_soc_info; +	ret = dm644x_gpio_register(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret); +  	aemif_clk = clk_get(NULL, "aemif"); -	clk_enable(aemif_clk); +	clk_prepare_enable(aemif_clk);  	if (HAS_ATA) {  		if (HAS_NAND || HAS_NOR) @@ -688,6 +778,11 @@ static __init void davinci_evm_init(void)  		/* only one device will be jumpered and detected */  		if (HAS_NAND) {  			platform_device_register(&davinci_evm_nandflash_device); + +			if (davinci_aemif_setup(&davinci_evm_nandflash_device)) +				pr_warn("%s: Cannot configure AEMIF.\n", +					__func__); +  			evm_leds[7].default_trigger = "nand-disk";  			if (HAS_NOR)  				pr_warning("WARNING: both NAND and NOR flash " @@ -701,22 +796,30 @@ static __init void davinci_evm_init(void)  	evm_init_i2c();  	davinci_setup_mmc(0, &dm6446evm_mmc_config); +	dm644x_init_video(&dm644xevm_capture_cfg, &dm644xevm_display_cfg); -	davinci_serial_init(&uart_config); +	davinci_serial_init(dm644x_serial_device);  	dm644x_init_asp(&dm644x_evm_snd_data); -	soc_info->emac_pdata->phy_id = DM644X_EVM_PHY_ID; -	/* Register the fixup for PHY on DaVinci */ -	phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, -					davinci_phy_fixup); +	/* irlml6401 switches over 1A, in under 8 msec */ +	davinci_setup_usb(1000, 8); +	if (IS_BUILTIN(CONFIG_PHYLIB)) { +		soc_info->emac_pdata->phy_id = DM644X_EVM_PHY_ID; +		/* Register the fixup for PHY on DaVinci */ +		phy_register_fixup_for_uid(LXT971_PHY_ID, LXT971_PHY_MASK, +						davinci_phy_fixup); +	}  }  MACHINE_START(DAVINCI_EVM, "DaVinci DM644x EVM")  	/* Maintainer: MontaVista Software <source@mvista.com> */ -	.boot_params  = (DAVINCI_DDR_BASE + 0x100), +	.atag_offset  = 0x100,  	.map_io	      = davinci_evm_map_io,  	.init_irq     = davinci_irq_init, -	.timer	      = &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine = davinci_evm_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-dm646x-evm.c b/arch/arm/mach-davinci/board-dm646x-evm.c index f6ac9ba7487..ae129bc4927 100644 --- a/arch/arm/mach-davinci/board-dm646x-evm.c +++ b/arch/arm/mach-davinci/board-dm646x-evm.c @@ -22,28 +22,32 @@  #include <linux/gpio.h>  #include <linux/platform_device.h>  #include <linux/i2c.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/i2c/pcf857x.h>  #include <media/tvp514x.h> +#include <media/adv7343.h>  #include <linux/mtd/mtd.h>  #include <linux/mtd/nand.h>  #include <linux/mtd/partitions.h>  #include <linux/clk.h> +#include <linux/export.h> +#include <linux/platform_data/gpio-davinci.h> +#include <linux/platform_data/i2c-davinci.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/mtd-davinci-aemif.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h> -#include <mach/dm646x.h>  #include <mach/common.h> +#include <mach/irqs.h>  #include <mach/serial.h> -#include <mach/i2c.h> -#include <mach/nand.h>  #include <mach/clock.h>  #include <mach/cdce949.h> -#include <mach/aemif.h> +#include "davinci.h"  #include "clock.h"  #define NAND_BLOCK_SIZE		SZ_128K @@ -88,6 +92,7 @@ static struct davinci_nand_pdata davinci_nand_data = {  	.parts			= davinci_nand_partitions,  	.nr_parts		= ARRAY_SIZE(davinci_nand_partitions),  	.ecc_mode		= NAND_ECC_HW, +	.ecc_bits		= 1,  	.options		= 0,  }; @@ -115,12 +120,7 @@ static struct platform_device davinci_nand_device = {  	},  }; -#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ -    defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) -#define HAS_ATA 1 -#else -#define HAS_ATA 0 -#endif +#define HAS_ATA		IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710)  /* CPLD Register 0 bits to control ATA */  #define DM646X_EVM_ATA_RST		BIT(0) @@ -192,7 +192,7 @@ static int evm_led_setup(struct i2c_client *client, int gpio,  	while (ngpio--) {  		leds->gpio = gpio++;  		leds++; -	}; +	}  	evm_led_dev = platform_device_alloc("leds-gpio", 0);  	platform_device_add_data(evm_led_dev, &evm_led_data, @@ -356,7 +356,7 @@ static int cpld_video_probe(struct i2c_client *client,  	return 0;  } -static int __devexit cpld_video_remove(struct i2c_client *client) +static int cpld_video_remove(struct i2c_client *client)  {  	cpld_client = NULL;  	return 0; @@ -409,8 +409,6 @@ static struct davinci_i2c_platform_data i2c_pdata = {  	.bus_delay      = 0 /* usec */,  }; -#define VIDCLKCTL_OFFSET	(DAVINCI_SYSTEM_MODULE_BASE + 0x38) -#define VSCLKDIS_OFFSET		(DAVINCI_SYSTEM_MODULE_BASE + 0x6c)  #define VCH2CLK_MASK		(BIT_MASK(10) | BIT_MASK(9) | BIT_MASK(8))  #define VCH2CLK_SYSCLK8		(BIT(9))  #define VCH2CLK_AUXCLK		(BIT(9) | BIT(8)) @@ -428,8 +426,6 @@ static struct davinci_i2c_platform_data i2c_pdata = {  #define TVP5147_CH0		"tvp514x-0"  #define TVP5147_CH1		"tvp514x-1" -static void __iomem *vpif_vidclkctl_reg; -static void __iomem *vpif_vsclkdis_reg;  /* spin lock for updating above registers */  static spinlock_t vpif_reg_lock; @@ -440,14 +436,14 @@ static int set_vpif_clock(int mux_mode, int hd)  	int val = 0;  	int err = 0; -	if (!vpif_vidclkctl_reg || !vpif_vsclkdis_reg || !cpld_client) +	if (!cpld_client)  		return -ENXIO;  	/* disable the clock */  	spin_lock_irqsave(&vpif_reg_lock, flags); -	value = __raw_readl(vpif_vsclkdis_reg); +	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));  	value |= (VIDCH3CLK | VIDCH2CLK); -	__raw_writel(value, vpif_vsclkdis_reg); +	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));  	spin_unlock_irqrestore(&vpif_reg_lock, flags);  	val = i2c_smbus_read_byte(cpld_client); @@ -463,7 +459,7 @@ static int set_vpif_clock(int mux_mode, int hd)  	if (err)  		return err; -	value = __raw_readl(vpif_vidclkctl_reg); +	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));  	value &= ~(VCH2CLK_MASK);  	value &= ~(VCH3CLK_MASK); @@ -472,13 +468,13 @@ static int set_vpif_clock(int mux_mode, int hd)  	else  		value |= (VCH2CLK_AUXCLK | VCH3CLK_AUXCLK); -	__raw_writel(value, vpif_vidclkctl_reg); +	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));  	spin_lock_irqsave(&vpif_reg_lock, flags); -	value = __raw_readl(vpif_vsclkdis_reg); +	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));  	/* enable the clock */  	value &= ~(VIDCH3CLK | VIDCH2CLK); -	__raw_writel(value, vpif_vsclkdis_reg); +	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));  	spin_unlock_irqrestore(&vpif_reg_lock, flags);  	return 0; @@ -499,18 +495,49 @@ static struct vpif_subdev_info dm646x_vpif_subdev[] = {  	},  }; -static const char *output[] = { -	"Composite", -	"Component", -	"S-Video", +static const struct vpif_output dm6467_ch0_outputs[] = { +	{ +		.output = { +			.index = 0, +			.name = "Composite", +			.type = V4L2_OUTPUT_TYPE_ANALOG, +			.capabilities = V4L2_OUT_CAP_STD, +			.std = V4L2_STD_ALL, +		}, +		.subdev_name = "adv7343", +		.output_route = ADV7343_COMPOSITE_ID, +	}, +	{ +		.output = { +			.index = 1, +			.name = "Component", +			.type = V4L2_OUTPUT_TYPE_ANALOG, +			.capabilities = V4L2_OUT_CAP_DV_TIMINGS, +		}, +		.subdev_name = "adv7343", +		.output_route = ADV7343_COMPONENT_ID, +	}, +	{ +		.output = { +			.index = 2, +			.name = "S-Video", +			.type = V4L2_OUTPUT_TYPE_ANALOG, +			.capabilities = V4L2_OUT_CAP_STD, +			.std = V4L2_STD_ALL, +		}, +		.subdev_name = "adv7343", +		.output_route = ADV7343_SVIDEO_ID, +	},  };  static struct vpif_display_config dm646x_vpif_display_config = {  	.set_clock	= set_vpif_clock,  	.subdevinfo	= dm646x_vpif_subdev,  	.subdev_count	= ARRAY_SIZE(dm646x_vpif_subdev), -	.output		= output, -	.output_count	= ARRAY_SIZE(output), +	.chan_config[0] = { +		.outputs = dm6467_ch0_outputs, +		.output_count = ARRAY_SIZE(dm6467_ch0_outputs), +	},  	.card_name	= "DM646x EVM",  }; @@ -563,7 +590,7 @@ static int setup_vpif_input_channel_mode(int mux_mode)  	int val;  	u32 value; -	if (!vpif_vsclkdis_reg || !cpld_client) +	if (!cpld_client)  		return -ENXIO;  	val = i2c_smbus_read_byte(cpld_client); @@ -571,7 +598,7 @@ static int setup_vpif_input_channel_mode(int mux_mode)  		return val;  	spin_lock_irqsave(&vpif_reg_lock, flags); -	value = __raw_readl(vpif_vsclkdis_reg); +	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));  	if (mux_mode) {  		val &= VPIF_INPUT_TWO_CHANNEL;  		value |= VIDCH1CLK; @@ -579,7 +606,7 @@ static int setup_vpif_input_channel_mode(int mux_mode)  		val |= VPIF_INPUT_ONE_CHANNEL;  		value &= ~VIDCH1CLK;  	} -	__raw_writel(value, vpif_vsclkdis_reg); +	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VIDCLKCTL));  	spin_unlock_irqrestore(&vpif_reg_lock, flags);  	err = i2c_smbus_write_byte(cpld_client, val); @@ -604,15 +631,6 @@ static struct vpif_subdev_info vpif_capture_sdev_info[] = {  			I2C_BOARD_INFO("tvp5146", 0x5d),  			.platform_data = &tvp5146_pdata,  		}, -		.input = INPUT_CVBS_VI2B, -		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC, -		.can_route = 1, -		.vpif_if = { -			.if_type = VPIF_IF_BT656, -			.hd_pol = 1, -			.vd_pol = 1, -			.fid_pol = 0, -		},  	},  	{  		.name	= TVP5147_CH1, @@ -620,15 +638,6 @@ static struct vpif_subdev_info vpif_capture_sdev_info[] = {  			I2C_BOARD_INFO("tvp5146", 0x5c),  			.platform_data = &tvp5146_pdata,  		}, -		.input = INPUT_SVIDEO_VI2C_VI1C, -		.output = OUTPUT_10BIT_422_EMBEDDED_SYNC, -		.can_route = 1, -		.vpif_if = { -			.if_type = VPIF_IF_BT656, -			.hd_pol = 1, -			.vd_pol = 1, -			.fid_pol = 0, -		},  	},  }; @@ -638,9 +647,12 @@ static const struct vpif_input dm6467_ch0_inputs[] = {  			.index = 0,  			.name = "Composite",  			.type = V4L2_INPUT_TYPE_CAMERA, +			.capabilities = V4L2_IN_CAP_STD,  			.std = TVP514X_STD_ALL,  		},  		.subdev_name = TVP5147_CH0, +		.input_route = INPUT_CVBS_VI2B, +		.output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,  	},  }; @@ -650,9 +662,12 @@ static const struct vpif_input dm6467_ch1_inputs[] = {  			.index = 0,  			.name = "S-Video",  			.type = V4L2_INPUT_TYPE_CAMERA, +			.capabilities = V4L2_IN_CAP_STD,  			.std = TVP514X_STD_ALL,  		},  		.subdev_name = TVP5147_CH1, +		.input_route = INPUT_SVIDEO_VI2C_VI1C, +		.output_route = OUTPUT_10BIT_422_EMBEDDED_SYNC,  	},  }; @@ -664,21 +679,27 @@ static struct vpif_capture_config dm646x_vpif_capture_cfg = {  	.chan_config[0] = {  		.inputs = dm6467_ch0_inputs,  		.input_count = ARRAY_SIZE(dm6467_ch0_inputs), +		.vpif_if = { +			.if_type = VPIF_IF_BT656, +			.hd_pol = 1, +			.vd_pol = 1, +			.fid_pol = 0, +		},  	},  	.chan_config[1] = {  		.inputs = dm6467_ch1_inputs,  		.input_count = ARRAY_SIZE(dm6467_ch1_inputs), +		.vpif_if = { +			.if_type = VPIF_IF_BT656, +			.hd_pol = 1, +			.vd_pol = 1, +			.fid_pol = 0, +		},  	},  };  static void __init evm_init_video(void)  { -	vpif_vidclkctl_reg = ioremap(VIDCLKCTL_OFFSET, 4); -	vpif_vsclkdis_reg = ioremap(VSCLKDIS_OFFSET, 4); -	if (!vpif_vidclkctl_reg || !vpif_vsclkdis_reg) { -		pr_err("Can't map VPIF VIDCLKCTL or VSCLKDIS registers\n"); -		return; -	}  	spin_lock_init(&vpif_reg_lock);  	dm646x_setup_vpif(&dm646x_vpif_display_config, @@ -719,17 +740,19 @@ static void __init cdce_clk_init(void)  	}  } +#define DM6467T_EVM_REF_FREQ		33000000 +  static void __init davinci_map_io(void)  {  	dm646x_init(); + +	if (machine_is_davinci_dm6467tevm()) +		davinci_set_refclk_rate(DM6467T_EVM_REF_FREQ); +  	cdce_clk_init();  } -static struct davinci_uart_config uart_config __initdata = { -	.enabled_uarts = (1 << 0), -}; - -#define DM646X_EVM_PHY_ID		"0:01" +#define DM646X_EVM_PHY_ID		"davinci_mdio-0:01"  /*   * The following EDMA channels/slots are not being used by drivers (for   * example: Timer, GPIO, UART events etc) on dm646x, hence they are being @@ -765,10 +788,15 @@ static struct edma_rsv_info dm646x_edma_rsv[] = {  static __init void evm_init(void)  { +	int ret;  	struct davinci_soc_info *soc_info = &davinci_soc_info; +	ret = dm646x_gpio_register(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret); +  	evm_init_i2c(); -	davinci_serial_init(&uart_config); +	davinci_serial_init(dm646x_serial_device);  	dm646x_init_mcasp0(&dm646x_evm_snd_data[0]);  	dm646x_init_mcasp1(&dm646x_evm_snd_data[1]); @@ -777,6 +805,9 @@ static __init void evm_init(void)  	platform_device_register(&davinci_nand_device); +	if (davinci_aemif_setup(&davinci_nand_device)) +		pr_warn("%s: Cannot configure AEMIF.\n", __func__); +  	dm646x_init_edma(dm646x_edma_rsv);  	if (HAS_ATA) @@ -785,30 +816,25 @@ static __init void evm_init(void)  	soc_info->emac_pdata->phy_id = DM646X_EVM_PHY_ID;  } -#define DM646X_EVM_REF_FREQ		27000000 -#define DM6467T_EVM_REF_FREQ		33000000 - -void __init dm646x_board_setup_refclk(struct clk *clk) -{ -	if (machine_is_davinci_dm6467tevm()) -		clk->rate = DM6467T_EVM_REF_FREQ; -	else -		clk->rate = DM646X_EVM_REF_FREQ; -} -  MACHINE_START(DAVINCI_DM6467_EVM, "DaVinci DM646x EVM") -	.boot_params  = (0x80000100), +	.atag_offset  = 0x100,  	.map_io       = davinci_map_io,  	.init_irq     = davinci_irq_init, -	.timer        = &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine = evm_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END  MACHINE_START(DAVINCI_DM6467TEVM, "DaVinci DM6467T EVM") -	.boot_params  = (0x80000100), +	.atag_offset  = 0x100,  	.map_io       = davinci_map_io,  	.init_irq     = davinci_irq_init, -	.timer        = &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine = evm_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-mityomapl138.c b/arch/arm/mach-davinci/board-mityomapl138.c index 0bb5f0ce4fd..96fc00a167f 100644 --- a/arch/arm/mach-davinci/board-mityomapl138.c +++ b/arch/arm/mach-davinci/board-mityomapl138.c @@ -15,18 +15,23 @@  #include <linux/mtd/partitions.h>  #include <linux/regulator/machine.h>  #include <linux/i2c.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/etherdevice.h> +#include <linux/spi/spi.h> +#include <linux/spi/flash.h> +#include <asm/io.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h>  #include <mach/common.h>  #include <mach/cp_intc.h>  #include <mach/da8xx.h> -#include <mach/nand.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/mtd-davinci-aemif.h>  #include <mach/mux.h> +#include <linux/platform_data/spi-davinci.h> -#define MITYOMAPL138_PHY_ID		"0:03" +#define MITYOMAPL138_PHY_ID		""  #define FACTORY_CONFIG_MAGIC	0x012C0138  #define FACTORY_CONFIG_VERSION	0x00010001 @@ -44,38 +49,109 @@ struct factory_config {  static struct factory_config factory_config; +struct part_no_info { +	const char	*part_no;	/* part number string of interest */ +	int		max_freq;	/* khz */ +}; + +static struct part_no_info mityomapl138_pn_info[] = { +	{ +		.part_no	= "L138-C", +		.max_freq	= 300000, +	}, +	{ +		.part_no	= "L138-D", +		.max_freq	= 375000, +	}, +	{ +		.part_no	= "L138-F", +		.max_freq	= 456000, +	}, +	{ +		.part_no	= "1808-C", +		.max_freq	= 300000, +	}, +	{ +		.part_no	= "1808-D", +		.max_freq	= 375000, +	}, +	{ +		.part_no	= "1808-F", +		.max_freq	= 456000, +	}, +	{ +		.part_no	= "1810-D", +		.max_freq	= 375000, +	}, +}; + +#ifdef CONFIG_CPU_FREQ +static void mityomapl138_cpufreq_init(const char *partnum) +{ +	int i, ret; + +	for (i = 0; partnum && i < ARRAY_SIZE(mityomapl138_pn_info); i++) { +		/* +		 * the part number has additional characters beyond what is +		 * stored in the table.  This information is not needed for +		 * determining the speed grade, and would require several +		 * more table entries.  Only check the first N characters +		 * for a match. +		 */ +		if (!strncmp(partnum, mityomapl138_pn_info[i].part_no, +			     strlen(mityomapl138_pn_info[i].part_no))) { +			da850_max_speed = mityomapl138_pn_info[i].max_freq; +			break; +		} +	} + +	ret = da850_register_cpufreq("pll0_sysclk3"); +	if (ret) +		pr_warning("cpufreq registration failed: %d\n", ret); +} +#else +static void mityomapl138_cpufreq_init(const char *partnum) { } +#endif +  static void read_factory_config(struct memory_accessor *a, void *context)  {  	int ret; +	const char *partnum = NULL;  	struct davinci_soc_info *soc_info = &davinci_soc_info;  	ret = a->read(a, (char *)&factory_config, 0, sizeof(factory_config));  	if (ret != sizeof(struct factory_config)) {  		pr_warning("MityOMAPL138: Read Factory Config Failed: %d\n",  				ret); -		return; +		goto bad_config;  	}  	if (factory_config.magic != FACTORY_CONFIG_MAGIC) {  		pr_warning("MityOMAPL138: Factory Config Magic Wrong (%X)\n",  				factory_config.magic); -		return; +		goto bad_config;  	}  	if (factory_config.version != FACTORY_CONFIG_VERSION) {  		pr_warning("MityOMAPL138: Factory Config Version Wrong (%X)\n",  				factory_config.version); -		return; +		goto bad_config;  	}  	pr_info("MityOMAPL138: Found MAC = %pM\n", factory_config.mac); -	pr_info("MityOMAPL138: Part Number = %s\n", factory_config.partnum);  	if (is_valid_ether_addr(factory_config.mac))  		memcpy(soc_info->emac_pdata->mac_addr,  			factory_config.mac, ETH_ALEN);  	else  		pr_warning("MityOMAPL138: Invalid MAC found "  				"in factory config block\n"); + +	partnum = factory_config.partnum; +	pr_info("MityOMAPL138: Part Number = %s\n", partnum); + +bad_config: +	/* default maximum speed is valid for all platforms */ +	mityomapl138_cpufreq_init(partnum);  }  static struct at24_platform_data mityomapl138_fd_chip = { @@ -223,6 +299,82 @@ static int __init pmic_tps65023_init(void)  }  /* + * SPI Devices: + *	SPI1_CS0: 8M Flash ST-M25P64-VME6G + */ +static struct mtd_partition spi_flash_partitions[] = { +	[0] = { +		.name		= "ubl", +		.offset		= 0, +		.size		= SZ_64K, +		.mask_flags	= MTD_WRITEABLE, +	}, +	[1] = { +		.name		= "u-boot", +		.offset		= MTDPART_OFS_APPEND, +		.size		= SZ_512K, +		.mask_flags	= MTD_WRITEABLE, +	}, +	[2] = { +		.name		= "u-boot-env", +		.offset		= MTDPART_OFS_APPEND, +		.size		= SZ_64K, +		.mask_flags	= MTD_WRITEABLE, +	}, +	[3] = { +		.name		= "periph-config", +		.offset		= MTDPART_OFS_APPEND, +		.size		= SZ_64K, +		.mask_flags	= MTD_WRITEABLE, +	}, +	[4] = { +		.name		= "reserved", +		.offset		= MTDPART_OFS_APPEND, +		.size		= SZ_256K + SZ_64K, +	}, +	[5] = { +		.name		= "kernel", +		.offset		= MTDPART_OFS_APPEND, +		.size		= SZ_2M + SZ_1M, +	}, +	[6] = { +		.name		= "fpga", +		.offset		= MTDPART_OFS_APPEND, +		.size		= SZ_2M, +	}, +	[7] = { +		.name		= "spare", +		.offset		= MTDPART_OFS_APPEND, +		.size		= MTDPART_SIZ_FULL, +	}, +}; + +static struct flash_platform_data mityomapl138_spi_flash_data = { +	.name		= "m25p80", +	.parts		= spi_flash_partitions, +	.nr_parts	= ARRAY_SIZE(spi_flash_partitions), +	.type		= "m24p64", +}; + +static struct davinci_spi_config spi_eprom_config = { +	.io_type	= SPI_IO_TYPE_DMA, +	.c2tdelay	= 8, +	.t2cdelay	= 8, +}; + +static struct spi_board_info mityomapl138_spi_flash_info[] = { +	{ +		.modalias		= "m25p80", +		.platform_data		= &mityomapl138_spi_flash_data, +		.controller_data	= &spi_eprom_config, +		.mode			= SPI_MODE_0, +		.max_speed_hz		= 30000000, +		.bus_num		= 1, +		.chip_select		= 0, +	}, +}; + +/*   * MityDSP-L138 includes a 256 MByte large-page NAND flash   * (128K blocks).   */ @@ -245,7 +397,8 @@ static struct davinci_nand_pdata mityomapl138_nandflash_data = {  	.parts		= mityomapl138_nandflash_partition,  	.nr_parts	= ARRAY_SIZE(mityomapl138_nandflash_partition),  	.ecc_mode	= NAND_ECC_HW, -	.options	= NAND_USE_FLASH_BBT | NAND_BUSWIDTH_16, +	.bbt_options	= NAND_BBT_USE_FLASH, +	.options	= NAND_BUSWIDTH_16,  	.ecc_bits	= 1, /* 4 bit mode is not supported with 16 bit NAND */  }; @@ -264,7 +417,7 @@ static struct resource mityomapl138_nandflash_resource[] = {  static struct platform_device mityomapl138_nandflash_device = {  	.name		= "davinci_nand", -	.id		= 0, +	.id		= 1,  	.dev		= {  		.platform_data	= &mityomapl138_nandflash_data,  	}, @@ -280,11 +433,10 @@ static void __init mityomapl138_setup_nand(void)  {  	platform_add_devices(mityomapl138_devices,  				 ARRAY_SIZE(mityomapl138_devices)); -} -static struct davinci_uart_config mityomapl138_uart_config __initdata = { -	.enabled_uarts = 0x7, -}; +	if (davinci_aemif_setup(&mityomapl138_nandflash_device)) +		pr_warn("%s: Cannot configure AEMIF.\n", __func__); +}  static const short mityomap_mii_pins[] = {  	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3, @@ -365,7 +517,7 @@ static void __init mityomapl138_init(void)  	if (ret)  		pr_warning("watchdog registration failed: %d\n", ret); -	davinci_serial_init(&mityomapl138_uart_config); +	davinci_serial_init(da8xx_serial_device);  	ret = da8xx_register_i2c(0, &mityomap_i2c_0_pdata);  	if (ret) @@ -377,16 +529,22 @@ static void __init mityomapl138_init(void)  	mityomapl138_setup_nand(); +	ret = spi_register_board_info(mityomapl138_spi_flash_info, +				      ARRAY_SIZE(mityomapl138_spi_flash_info)); +	if (ret) +		pr_warn("spi info registration failed: %d\n", ret); + +	ret = da8xx_register_spi_bus(1, +				     ARRAY_SIZE(mityomapl138_spi_flash_info)); +	if (ret) +		pr_warning("spi 1 registration failed: %d\n", ret); +  	mityomapl138_config_emac();  	ret = da8xx_register_rtc();  	if (ret)  		pr_warning("rtc setup failed: %d\n", ret); -	ret = da850_register_cpufreq("pll0_sysclk3"); -	if (ret) -		pr_warning("cpufreq registration failed: %d\n", ret); -  	ret = da8xx_register_cpuidle();  	if (ret)  		pr_warning("cpuidle registration failed: %d\n", ret); @@ -414,9 +572,12 @@ static void __init mityomapl138_map_io(void)  }  MACHINE_START(MITYOMAPL138, "MityDSP-L138/MityARM-1808") -	.boot_params	= (DA8XX_DDR_BASE + 0x100), +	.atag_offset	= 0x100,  	.map_io		= mityomapl138_map_io,  	.init_irq	= cp_intc_init, -	.timer		= &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine	= mityomapl138_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= da8xx_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c index 6c389ff1020..bb680af9837 100644 --- a/arch/arm/mach-davinci/board-neuros-osd2.c +++ b/arch/arm/mach-davinci/board-neuros-osd2.c @@ -11,7 +11,7 @@   * DM644X-EVM board. It has:   * 	DM6446M02 module with 256MB NAND, 256MB RAM, TLV320AIC32 AIC,   * 	USB, Ethernet, SD/MMC, UART, THS8200, TVP7000 for video. - * 	Additionaly realtime clock, IR remote control receiver, + * 	Additionally realtime clock, IR remote control receiver,   * 	IR Blaster based on MSP430 (firmware although is different   * 	from used in DM644X-EVM), internal ATA-6 3.5” HDD drive   * 	with PATA interface, two muxed red-green leds. @@ -26,20 +26,22 @@  #include <linux/platform_device.h>  #include <linux/gpio.h>  #include <linux/mtd/partitions.h> +#include <linux/platform_data/gpio-davinci.h> +#include <linux/platform_data/i2c-davinci.h> +#include <linux/platform_data/mmc-davinci.h> +#include <linux/platform_data/mtd-davinci.h> +#include <linux/platform_data/usb-davinci.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h> -#include <mach/dm644x.h>  #include <mach/common.h> -#include <mach/i2c.h>  #include <mach/serial.h>  #include <mach/mux.h> -#include <mach/nand.h> -#include <mach/mmc.h> -#include <mach/usb.h> -#define NEUROS_OSD2_PHY_ID		"0:01" +#include "davinci.h" + +#define NEUROS_OSD2_PHY_ID		"davinci_mdio-0:01"  #define LXT971_PHY_ID			0x001378e2  #define LXT971_PHY_MASK			0xfffffff0 @@ -87,7 +89,8 @@ static struct davinci_nand_pdata davinci_ntosd2_nandflash_data = {  	.parts		= davinci_ntosd2_nandflash_partition,  	.nr_parts	= ARRAY_SIZE(davinci_ntosd2_nandflash_partition),  	.ecc_mode	= NAND_ECC_HW, -	.options	= NAND_USE_FLASH_BBT, +	.ecc_bits	= 1, +	.bbt_options	= NAND_BBT_USE_FLASH,  };  static struct resource davinci_ntosd2_nandflash_resource[] = { @@ -152,75 +155,31 @@ static struct platform_device *davinci_ntosd2_devices[] __initdata = {  	&ntosd2_leds_dev,  }; -static struct davinci_uart_config uart_config __initdata = { -	.enabled_uarts = (1 << 0), -}; -  static void __init davinci_ntosd2_map_io(void)  {  	dm644x_init();  } -/* - I2C initialization -*/ -static struct davinci_i2c_platform_data ntosd2_i2c_pdata = { -	.bus_freq	= 20 /* kHz */, -	.bus_delay	= 100 /* usec */, -}; - -static struct i2c_board_info __initdata ntosd2_i2c_info[] =  { -}; - -static	int ntosd2_init_i2c(void) -{ -	int	status; - -	davinci_init_i2c(&ntosd2_i2c_pdata); -	status = gpio_request(NTOSD2_MSP430_IRQ, ntosd2_i2c_info[0].type); -	if (status == 0) { -		status = gpio_direction_input(NTOSD2_MSP430_IRQ); -		if (status == 0) { -			status = gpio_to_irq(NTOSD2_MSP430_IRQ); -			if (status > 0) { -				ntosd2_i2c_info[0].irq = status; -				i2c_register_board_info(1, -					ntosd2_i2c_info, -					ARRAY_SIZE(ntosd2_i2c_info)); -			} -		} -	} -	return status; -} -  static struct davinci_mmc_config davinci_ntosd2_mmc_config = {  	.wires		= 4, -	.version	= MMC_CTLR_VERSION_1  }; +#define HAS_ATA		IS_ENABLED(CONFIG_BLK_DEV_PALMCHIP_BK3710) -#if defined(CONFIG_BLK_DEV_PALMCHIP_BK3710) || \ -	defined(CONFIG_BLK_DEV_PALMCHIP_BK3710_MODULE) -#define HAS_ATA 1 -#else -#define HAS_ATA 0 -#endif - -#if defined(CONFIG_MTD_NAND_DAVINCI) || \ -	defined(CONFIG_MTD_NAND_DAVINCI_MODULE) -#define HAS_NAND 1 -#else -#define HAS_NAND 0 -#endif +#define HAS_NAND	IS_ENABLED(CONFIG_MTD_NAND_DAVINCI)  static __init void davinci_ntosd2_init(void)  { +	int ret;  	struct clk *aemif_clk;  	struct davinci_soc_info *soc_info = &davinci_soc_info; -	int	status; + +	ret = dm644x_gpio_register(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret);  	aemif_clk = clk_get(NULL, "aemif"); -	clk_enable(aemif_clk); +	clk_prepare_enable(aemif_clk);  	if (HAS_ATA) {  		if (HAS_NAND) @@ -241,13 +200,7 @@ static __init void davinci_ntosd2_init(void)  	platform_add_devices(davinci_ntosd2_devices,  				ARRAY_SIZE(davinci_ntosd2_devices)); -	/* Initialize I2C interface specific for this board */ -	status = ntosd2_init_i2c(); -	if (status < 0) -		pr_warning("davinci_ntosd2_init: msp430 irq setup failed:" -						"	 %d\n", status); - -	davinci_serial_init(&uart_config); +	davinci_serial_init(dm644x_serial_device);  	dm644x_init_asp(&dm644x_ntosd2_snd_data);  	soc_info->emac_pdata->phy_id = NEUROS_OSD2_PHY_ID; @@ -272,9 +225,12 @@ static __init void davinci_ntosd2_init(void)  MACHINE_START(NEUROS_OSD2, "Neuros OSD2")  	/* Maintainer: Neuros Technologies <neuros@groups.google.com> */ -	.boot_params	= (DAVINCI_DDR_BASE + 0x100), +	.atag_offset	= 0x100,  	.map_io		 = davinci_ntosd2_map_io,  	.init_irq	= davinci_irq_init, -	.timer		= &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine = davinci_ntosd2_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c index 0b8dbdb79fe..2aac51d0e85 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c @@ -13,28 +13,310 @@  #include <linux/init.h>  #include <linux/console.h>  #include <linux/gpio.h> +#include <linux/platform_data/gpio-davinci.h>  #include <asm/mach-types.h>  #include <asm/mach/arch.h> +#include <mach/common.h>  #include <mach/cp_intc.h>  #include <mach/da8xx.h> +#include <mach/mux.h> -static struct davinci_uart_config omapl138_hawk_uart_config __initdata = { -	.enabled_uarts = 0x7, +#define HAWKBOARD_PHY_ID		"davinci_mdio-0:07" +#define DA850_HAWK_MMCSD_CD_PIN		GPIO_TO_PIN(3, 12) +#define DA850_HAWK_MMCSD_WP_PIN		GPIO_TO_PIN(3, 13) + +#define DA850_USB1_VBUS_PIN		GPIO_TO_PIN(2, 4) +#define DA850_USB1_OC_PIN		GPIO_TO_PIN(6, 13) + +static short omapl138_hawk_mii_pins[] __initdata = { +	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3, +	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER, +	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3, +	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK, +	DA850_MDIO_D, +	-1 +}; + +static __init void omapl138_hawk_config_emac(void) +{ +	void __iomem *cfgchip3 = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG); +	int ret; +	u32 val; +	struct davinci_soc_info *soc_info = &davinci_soc_info; + +	val = __raw_readl(cfgchip3); +	val &= ~BIT(8); +	ret = davinci_cfg_reg_list(omapl138_hawk_mii_pins); +	if (ret) { +		pr_warn("%s: CPGMAC/MII mux setup failed: %d\n", __func__, ret); +		return; +	} + +	/* configure the CFGCHIP3 register for MII */ +	__raw_writel(val, cfgchip3); +	pr_info("EMAC: MII PHY configured\n"); + +	soc_info->emac_pdata->phy_id = HAWKBOARD_PHY_ID; + +	ret = da8xx_register_emac(); +	if (ret) +		pr_warn("%s: EMAC registration failed: %d\n", __func__, ret); +} + +/* + * The following EDMA channels/slots are not being used by drivers (for + * example: Timer, GPIO, UART events etc) on da850/omap-l138 EVM/Hawkboard, + * hence they are being reserved for codecs on the DSP side. + */ +static const s16 da850_dma0_rsv_chans[][2] = { +	/* (offset, number) */ +	{ 8,  6}, +	{24,  4}, +	{30,  2}, +	{-1, -1} +}; + +static const s16 da850_dma0_rsv_slots[][2] = { +	/* (offset, number) */ +	{ 8,  6}, +	{24,  4}, +	{30, 50}, +	{-1, -1} +}; + +static const s16 da850_dma1_rsv_chans[][2] = { +	/* (offset, number) */ +	{ 0, 28}, +	{30,  2}, +	{-1, -1} +}; + +static const s16 da850_dma1_rsv_slots[][2] = { +	/* (offset, number) */ +	{ 0, 28}, +	{30, 90}, +	{-1, -1} +}; + +static struct edma_rsv_info da850_edma_cc0_rsv = { +	.rsv_chans	= da850_dma0_rsv_chans, +	.rsv_slots	= da850_dma0_rsv_slots, +}; + +static struct edma_rsv_info da850_edma_cc1_rsv = { +	.rsv_chans	= da850_dma1_rsv_chans, +	.rsv_slots	= da850_dma1_rsv_slots, +}; + +static struct edma_rsv_info *da850_edma_rsv[2] = { +	&da850_edma_cc0_rsv, +	&da850_edma_cc1_rsv, +}; + +static const short hawk_mmcsd0_pins[] = { +	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2, +	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD, +	DA850_GPIO3_12, DA850_GPIO3_13, +	-1 +}; + +static int da850_hawk_mmc_get_ro(int index) +{ +	return gpio_get_value(DA850_HAWK_MMCSD_WP_PIN); +} + +static int da850_hawk_mmc_get_cd(int index) +{ +	return !gpio_get_value(DA850_HAWK_MMCSD_CD_PIN); +} + +static struct davinci_mmc_config da850_mmc_config = { +	.get_ro		= da850_hawk_mmc_get_ro, +	.get_cd		= da850_hawk_mmc_get_cd, +	.wires		= 4, +	.max_freq	= 50000000, +	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, +}; + +static __init void omapl138_hawk_mmc_init(void) +{ +	int ret; + +	ret = davinci_cfg_reg_list(hawk_mmcsd0_pins); +	if (ret) { +		pr_warn("%s: MMC/SD0 mux setup failed: %d\n", __func__, ret); +		return; +	} + +	ret = gpio_request_one(DA850_HAWK_MMCSD_CD_PIN, +			GPIOF_DIR_IN, "MMC CD"); +	if (ret < 0) { +		pr_warn("%s: can not open GPIO %d\n", +			__func__, DA850_HAWK_MMCSD_CD_PIN); +		return; +	} + +	ret = gpio_request_one(DA850_HAWK_MMCSD_WP_PIN, +			GPIOF_DIR_IN, "MMC WP"); +	if (ret < 0) { +		pr_warn("%s: can not open GPIO %d\n", +			__func__, DA850_HAWK_MMCSD_WP_PIN); +		goto mmc_setup_wp_fail; +	} + +	ret = da8xx_register_mmcsd0(&da850_mmc_config); +	if (ret) { +		pr_warn("%s: MMC/SD0 registration failed: %d\n", __func__, ret); +		goto mmc_setup_mmcsd_fail; +	} + +	return; + +mmc_setup_mmcsd_fail: +	gpio_free(DA850_HAWK_MMCSD_WP_PIN); +mmc_setup_wp_fail: +	gpio_free(DA850_HAWK_MMCSD_CD_PIN); +} + +static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id); +static da8xx_ocic_handler_t hawk_usb_ocic_handler; + +static const short da850_hawk_usb11_pins[] = { +	DA850_GPIO2_4, DA850_GPIO6_13, +	-1  }; +static int hawk_usb_set_power(unsigned port, int on) +{ +	gpio_set_value(DA850_USB1_VBUS_PIN, on); +	return 0; +} + +static int hawk_usb_get_power(unsigned port) +{ +	return gpio_get_value(DA850_USB1_VBUS_PIN); +} + +static int hawk_usb_get_oci(unsigned port) +{ +	return !gpio_get_value(DA850_USB1_OC_PIN); +} + +static int hawk_usb_ocic_notify(da8xx_ocic_handler_t handler) +{ +	int irq         = gpio_to_irq(DA850_USB1_OC_PIN); +	int error       = 0; + +	if (handler != NULL) { +		hawk_usb_ocic_handler = handler; + +		error = request_irq(irq, omapl138_hawk_usb_ocic_irq, +					IRQF_TRIGGER_RISING | +					IRQF_TRIGGER_FALLING, +					"OHCI over-current indicator", NULL); +		if (error) +			pr_err("%s: could not request IRQ to watch " +				"over-current indicator changes\n", __func__); +	} else { +		free_irq(irq, NULL); +	} +	return error; +} + +static struct da8xx_ohci_root_hub omapl138_hawk_usb11_pdata = { +	.set_power      = hawk_usb_set_power, +	.get_power      = hawk_usb_get_power, +	.get_oci        = hawk_usb_get_oci, +	.ocic_notify    = hawk_usb_ocic_notify, +	/* TPS2087 switch @ 5V */ +	.potpgt         = (3 + 1) / 2,  /* 3 ms max */ +}; + +static irqreturn_t omapl138_hawk_usb_ocic_irq(int irq, void *dev_id) +{ +	hawk_usb_ocic_handler(&omapl138_hawk_usb11_pdata, 1); +	return IRQ_HANDLED; +} + +static __init void omapl138_hawk_usb_init(void) +{ +	int ret; +	u32 cfgchip2; + +	ret = davinci_cfg_reg_list(da850_hawk_usb11_pins); +	if (ret) { +		pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret); +		return; +	} + +	/* Setup the Ref. clock frequency for the HAWK at 24 MHz. */ + +	cfgchip2 = __raw_readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); +	cfgchip2 &= ~CFGCHIP2_REFFREQ; +	cfgchip2 |=  CFGCHIP2_REFFREQ_24MHZ; +	__raw_writel(cfgchip2, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); + +	ret = gpio_request_one(DA850_USB1_VBUS_PIN, +			GPIOF_DIR_OUT, "USB1 VBUS"); +	if (ret < 0) { +		pr_err("%s: failed to request GPIO for USB 1.1 port " +			"power control: %d\n", __func__, ret); +		return; +	} + +	ret = gpio_request_one(DA850_USB1_OC_PIN, +			GPIOF_DIR_IN, "USB1 OC"); +	if (ret < 0) { +		pr_err("%s: failed to request GPIO for USB 1.1 port " +			"over-current indicator: %d\n", __func__, ret); +		goto usb11_setup_oc_fail; +	} + +	ret = da8xx_register_usb11(&omapl138_hawk_usb11_pdata); +	if (ret) { +		pr_warn("%s: USB 1.1 registration failed: %d\n", __func__, ret); +		goto usb11_setup_fail; +	} + +	return; + +usb11_setup_fail: +	gpio_free(DA850_USB1_OC_PIN); +usb11_setup_oc_fail: +	gpio_free(DA850_USB1_VBUS_PIN); +} +  static __init void omapl138_hawk_init(void)  {  	int ret; -	davinci_serial_init(&omapl138_hawk_uart_config); +	ret = da850_register_gpio(); +	if (ret) +		pr_warn("%s: GPIO init failed: %d\n", __func__, ret); + +	davinci_serial_init(da8xx_serial_device); + +	omapl138_hawk_config_emac(); + +	ret = da850_register_edma(da850_edma_rsv); +	if (ret) +		pr_warn("%s: EDMA registration failed: %d\n", __func__, ret); + +	omapl138_hawk_mmc_init(); + +	omapl138_hawk_usb_init();  	ret = da8xx_register_watchdog();  	if (ret) -		pr_warning("omapl138_hawk_init: " -			"watchdog registration failed: %d\n", -			ret); +		pr_warn("%s: watchdog registration failed: %d\n", +			__func__, ret); + +	ret = da8xx_register_rproc(); +	if (ret) +		pr_warn("%s: dsp/rproc registration failed: %d\n", +			__func__, ret);  }  #ifdef CONFIG_SERIAL_8250_CONSOLE @@ -54,9 +336,13 @@ static void __init omapl138_hawk_map_io(void)  }  MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 Hawkboard") -	.boot_params	= (DA8XX_DDR_BASE + 0x100), +	.atag_offset	= 0x100,  	.map_io		= omapl138_hawk_map_io,  	.init_irq	= cp_intc_init, -	.timer		= &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine	= omapl138_hawk_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= da8xx_restart, +	.reserve	= da8xx_rproc_reserve_cma,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-sffsdr.c b/arch/arm/mach-davinci/board-sffsdr.c index 61ac96d8f00..41c7c961579 100644 --- a/arch/arm/mach-davinci/board-sffsdr.c +++ b/arch/arm/mach-davinci/board-sffsdr.c @@ -26,7 +26,7 @@  #include <linux/init.h>  #include <linux/platform_device.h>  #include <linux/i2c.h> -#include <linux/i2c/at24.h> +#include <linux/platform_data/at24.h>  #include <linux/mtd/mtd.h>  #include <linux/mtd/nand.h>  #include <linux/mtd/partitions.h> @@ -35,14 +35,15 @@  #include <asm/mach/arch.h>  #include <asm/mach/flash.h> -#include <mach/dm644x.h>  #include <mach/common.h> -#include <mach/i2c.h> +#include <linux/platform_data/i2c-davinci.h>  #include <mach/serial.h>  #include <mach/mux.h> -#include <mach/usb.h> +#include <linux/platform_data/usb-davinci.h> -#define SFFSDR_PHY_ID		"0:01" +#include "davinci.h" + +#define SFFSDR_PHY_ID		"davinci_mdio-0:01"  static struct mtd_partition davinci_sffsdr_nandflash_partition[] = {  	/* U-Boot Environment: Block 0  	 * UBL:                Block 1 @@ -124,10 +125,6 @@ static struct platform_device *davinci_sffsdr_devices[] __initdata = {  	&davinci_sffsdr_nandflash_device,  }; -static struct davinci_uart_config uart_config __initdata = { -	.enabled_uarts = (1 << 0), -}; -  static void __init davinci_sffsdr_map_io(void)  {  	dm644x_init(); @@ -140,7 +137,7 @@ static __init void davinci_sffsdr_init(void)  	platform_add_devices(davinci_sffsdr_devices,  			     ARRAY_SIZE(davinci_sffsdr_devices));  	sffsdr_init_i2c(); -	davinci_serial_init(&uart_config); +	davinci_serial_init(dm644x_serial_device);  	soc_info->emac_pdata->phy_id = SFFSDR_PHY_ID;  	davinci_setup_usb(0, 0); /* We support only peripheral mode. */ @@ -150,10 +147,12 @@ static __init void davinci_sffsdr_init(void)  }  MACHINE_START(SFFSDR, "Lyrtech SFFSDR") -	/* Maintainer: Hugo Villeneuve hugo.villeneuve@lyrtech.com */ -	.boot_params  = (DAVINCI_DDR_BASE + 0x100), +	.atag_offset  = 0x100,  	.map_io	      = davinci_sffsdr_map_io,  	.init_irq     = davinci_irq_init, -	.timer	      = &davinci_timer, +	.init_time	= davinci_timer_init,  	.init_machine = davinci_sffsdr_init, +	.init_late	= davinci_init_late, +	.dma_zone_size	= SZ_128M, +	.restart	= davinci_restart,  MACHINE_END diff --git a/arch/arm/mach-davinci/board-tnetv107x-evm.c b/arch/arm/mach-davinci/board-tnetv107x-evm.c deleted file mode 100644 index a6db8546022..00000000000 --- a/arch/arm/mach-davinci/board-tnetv107x-evm.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Texas Instruments TNETV107X EVM Board Support - * - * Copyright (C) 2010 Texas Instruments - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - */ -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/console.h> -#include <linux/dma-mapping.h> -#include <linux/interrupt.h> -#include <linux/gpio.h> -#include <linux/delay.h> -#include <linux/platform_device.h> -#include <linux/ratelimit.h> -#include <linux/mtd/mtd.h> -#include <linux/mtd/partitions.h> -#include <linux/input.h> -#include <linux/input/matrix_keypad.h> - -#include <asm/mach/arch.h> -#include <asm/mach-types.h> - -#include <mach/irqs.h> -#include <mach/edma.h> -#include <mach/mux.h> -#include <mach/cp_intc.h> -#include <mach/tnetv107x.h> - -#define EVM_MMC_WP_GPIO		21 -#define EVM_MMC_CD_GPIO		24 - -static int initialize_gpio(int gpio, char *desc) -{ -	int ret; - -	ret = gpio_request(gpio, desc); -	if (ret < 0) { -		pr_err_ratelimited("cannot open %s gpio\n", desc); -		return -ENOSYS; -	} -	gpio_direction_input(gpio); -	return gpio; -} - -static int mmc_get_cd(int index) -{ -	static int gpio; - -	if (!gpio) -		gpio = initialize_gpio(EVM_MMC_CD_GPIO, "mmc card detect"); - -	if (gpio < 0) -		return gpio; - -	return gpio_get_value(gpio) ? 0 : 1; -} - -static int mmc_get_ro(int index) -{ -	static int gpio; - -	if (!gpio) -		gpio = initialize_gpio(EVM_MMC_WP_GPIO, "mmc write protect"); - -	if (gpio < 0) -		return gpio; - -	return gpio_get_value(gpio) ? 1 : 0; -} - -static struct davinci_mmc_config mmc_config = { -	.get_cd		= mmc_get_cd, -	.get_ro		= mmc_get_ro, -	.wires		= 4, -	.max_freq	= 50000000, -	.caps		= MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED, -	.version	= MMC_CTLR_VERSION_1, -}; - -static const short sdio1_pins[] __initdata = { -	TNETV107X_SDIO1_CLK_1,		TNETV107X_SDIO1_CMD_1, -	TNETV107X_SDIO1_DATA0_1,	TNETV107X_SDIO1_DATA1_1, -	TNETV107X_SDIO1_DATA2_1,	TNETV107X_SDIO1_DATA3_1, -	TNETV107X_GPIO21,		TNETV107X_GPIO24, -	-1 -}; - -static const short uart1_pins[] __initdata = { -	TNETV107X_UART1_RD,		TNETV107X_UART1_TD, -	-1 -}; - -static struct mtd_partition nand_partitions[] = { -	/* bootloader (U-Boot, etc) in first 12 sectors */ -	{ -		.name		= "bootloader", -		.offset		= 0, -		.size		= (12*SZ_128K), -		.mask_flags	= MTD_WRITEABLE,	/* force read-only */ -	}, -	/* bootloader params in the next sector */ -	{ -		.name		= "params", -		.offset		= MTDPART_OFS_NXTBLK, -		.size		= SZ_128K, -		.mask_flags	= MTD_WRITEABLE,	/* force read-only */ -	}, -	/* kernel */ -	{ -		.name		= "kernel", -		.offset		= MTDPART_OFS_NXTBLK, -		.size		= SZ_4M, -		.mask_flags	= 0, -	}, -	/* file system */ -	{ -		.name		= "filesystem", -		.offset		= MTDPART_OFS_NXTBLK, -		.size		= MTDPART_SIZ_FULL, -		.mask_flags	= 0, -	} -}; - -static struct davinci_nand_pdata nand_config = { -	.mask_cle	= 0x4000, -	.mask_ale	= 0x2000, -	.parts		= nand_partitions, -	.nr_parts	= ARRAY_SIZE(nand_partitions), -	.ecc_mode	= NAND_ECC_HW, -	.options	= NAND_USE_FLASH_BBT, -	.ecc_bits	= 1, -}; - -static struct davinci_uart_config serial_config __initconst = { -	.enabled_uarts	= BIT(1), -}; - -static const uint32_t keymap[] = { -	KEY(0, 0, KEY_NUMERIC_1), -	KEY(0, 1, KEY_NUMERIC_2), -	KEY(0, 2, KEY_NUMERIC_3), -	KEY(0, 3, KEY_FN_F1), -	KEY(0, 4, KEY_MENU), - -	KEY(1, 0, KEY_NUMERIC_4), -	KEY(1, 1, KEY_NUMERIC_5), -	KEY(1, 2, KEY_NUMERIC_6), -	KEY(1, 3, KEY_UP), -	KEY(1, 4, KEY_FN_F2), - -	KEY(2, 0, KEY_NUMERIC_7), -	KEY(2, 1, KEY_NUMERIC_8), -	KEY(2, 2, KEY_NUMERIC_9), -	KEY(2, 3, KEY_LEFT), -	KEY(2, 4, KEY_ENTER), - -	KEY(3, 0, KEY_NUMERIC_STAR), -	KEY(3, 1, KEY_NUMERIC_0), -	KEY(3, 2, KEY_NUMERIC_POUND), -	KEY(3, 3, KEY_DOWN), -	KEY(3, 4, KEY_RIGHT), - -	KEY(4, 0, KEY_FN_F3), -	KEY(4, 1, KEY_FN_F4), -	KEY(4, 2, KEY_MUTE), -	KEY(4, 3, KEY_HOME), -	KEY(4, 4, KEY_BACK), - -	KEY(5, 0, KEY_VOLUMEDOWN), -	KEY(5, 1, KEY_VOLUMEUP), -	KEY(5, 2, KEY_F1), -	KEY(5, 3, KEY_F2), -	KEY(5, 4, KEY_F3), -}; - -static const struct matrix_keymap_data keymap_data = { -	.keymap		= keymap, -	.keymap_size	= ARRAY_SIZE(keymap), -}; - -static struct matrix_keypad_platform_data keypad_config = { -	.keymap_data	= &keymap_data, -	.num_row_gpios	= 6, -	.num_col_gpios	= 5, -	.debounce_ms	= 0, /* minimum */ -	.active_low	= 0, /* pull up realization */ -	.no_autorepeat	= 0, -}; - -static struct tnetv107x_device_info evm_device_info __initconst = { -	.serial_config		= &serial_config, -	.mmc_config[1]		= &mmc_config,	/* controller 1 */ -	.nand_config[0]		= &nand_config,	/* chip select 0 */ -	.keypad_config		= &keypad_config, -}; - -static __init void tnetv107x_evm_board_init(void) -{ -	davinci_cfg_reg_list(sdio1_pins); -	davinci_cfg_reg_list(uart1_pins); - -	tnetv107x_devices_init(&evm_device_info); -} - -#ifdef CONFIG_SERIAL_8250_CONSOLE -static int __init tnetv107x_evm_console_init(void) -{ -	return add_preferred_console("ttyS", 0, "115200"); -} -console_initcall(tnetv107x_evm_console_init); -#endif - -MACHINE_START(TNETV107X, "TNETV107X EVM") -	.boot_params	= (TNETV107X_DDR_BASE + 0x100), -	.map_io		= tnetv107x_init, -	.init_irq	= cp_intc_init, -	.timer		= &davinci_timer, -	.init_machine	= tnetv107x_evm_board_init, -MACHINE_END diff --git a/arch/arm/mach-davinci/cdce949.c b/arch/arm/mach-davinci/cdce949.c index ba8b12b2913..abafb92031c 100644 --- a/arch/arm/mach-davinci/cdce949.c +++ b/arch/arm/mach-davinci/cdce949.c @@ -17,6 +17,7 @@  #include <linux/clk.h>  #include <linux/platform_device.h>  #include <linux/i2c.h> +#include <linux/module.h>  #include <mach/clock.h>  #include <mach/cdce949.h> @@ -255,7 +256,7 @@ static int cdce_probe(struct i2c_client *client,  	return 0;  } -static int __devexit cdce_remove(struct i2c_client *client) +static int cdce_remove(struct i2c_client *client)  {  	cdce_i2c_client = NULL;  	return 0; @@ -273,7 +274,7 @@ static struct i2c_driver cdce_driver = {  		.name	= "cdce949",  	},  	.probe		= cdce_probe, -	.remove		= __devexit_p(cdce_remove), +	.remove		= cdce_remove,  	.id_table	= cdce_id,  }; diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c index 01ba080433d..985e5fd00fb 100644 --- a/arch/arm/mach-davinci/clock.c +++ b/arch/arm/mach-davinci/clock.c @@ -31,35 +31,68 @@ static LIST_HEAD(clocks);  static DEFINE_MUTEX(clocks_mutex);  static DEFINE_SPINLOCK(clockfw_lock); -static unsigned psc_domain(struct clk *clk) -{ -	return (clk->flags & PSC_DSP) -		? DAVINCI_GPSC_DSPDOMAIN -		: DAVINCI_GPSC_ARMDOMAIN; -} -  static void __clk_enable(struct clk *clk)  {  	if (clk->parent)  		__clk_enable(clk->parent); -	if (clk->usecount++ == 0 && (clk->flags & CLK_PSC)) -		davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, -				PSC_STATE_ENABLE); +	if (clk->usecount++ == 0) { +		if (clk->flags & CLK_PSC) +			davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, +					   true, clk->flags); +		else if (clk->clk_enable) +			clk->clk_enable(clk); +	}  }  static void __clk_disable(struct clk *clk)  {  	if (WARN_ON(clk->usecount == 0))  		return; -	if (--clk->usecount == 0 && !(clk->flags & CLK_PLL) && -	    (clk->flags & CLK_PSC)) -		davinci_psc_config(psc_domain(clk), clk->gpsc, clk->lpsc, -				(clk->flags & PSC_SWRSTDISABLE) ? -				PSC_STATE_SWRSTDISABLE : PSC_STATE_DISABLE); +	if (--clk->usecount == 0) { +		if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC)) +			davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, +					   false, clk->flags); +		else if (clk->clk_disable) +			clk->clk_disable(clk); +	}  	if (clk->parent)  		__clk_disable(clk->parent);  } +int davinci_clk_reset(struct clk *clk, bool reset) +{ +	unsigned long flags; + +	if (clk == NULL || IS_ERR(clk)) +		return -EINVAL; + +	spin_lock_irqsave(&clockfw_lock, flags); +	if (clk->flags & CLK_PSC) +		davinci_psc_reset(clk->gpsc, clk->lpsc, reset); +	spin_unlock_irqrestore(&clockfw_lock, flags); + +	return 0; +} +EXPORT_SYMBOL(davinci_clk_reset); + +int davinci_clk_reset_assert(struct clk *clk) +{ +	if (clk == NULL || IS_ERR(clk) || !clk->reset) +		return -EINVAL; + +	return clk->reset(clk, true); +} +EXPORT_SYMBOL(davinci_clk_reset_assert); + +int davinci_clk_reset_deassert(struct clk *clk) +{ +	if (clk == NULL || IS_ERR(clk) || !clk->reset) +		return -EINVAL; + +	return clk->reset(clk, false); +} +EXPORT_SYMBOL(davinci_clk_reset_deassert); +  int clk_enable(struct clk *clk)  {  	unsigned long flags; @@ -100,7 +133,7 @@ EXPORT_SYMBOL(clk_get_rate);  long clk_round_rate(struct clk *clk, unsigned long rate)  {  	if (clk == NULL || IS_ERR(clk)) -		return -EINVAL; +		return 0;  	if (clk->round_rate)  		return clk->round_rate(clk, rate); @@ -221,7 +254,7 @@ EXPORT_SYMBOL(clk_unregister);  /*   * Disable any unused clocks left on by the bootloader   */ -static int __init clk_disable_unused(void) +int __init davinci_clk_disable_unused(void)  {  	struct clk *ck; @@ -238,15 +271,13 @@ static int __init clk_disable_unused(void)  		pr_debug("Clocks: disable unused %s\n", ck->name); -		davinci_psc_config(psc_domain(ck), ck->gpsc, ck->lpsc, -				(ck->flags & PSC_SWRSTDISABLE) ? -				PSC_STATE_SWRSTDISABLE : PSC_STATE_DISABLE); +		davinci_psc_config(ck->domain, ck->gpsc, ck->lpsc, +				false, ck->flags);  	}  	spin_unlock_irq(&clockfw_lock);  	return 0;  } -late_initcall(clk_disable_unused);  #endif  static unsigned long clk_sysclk_recalc(struct clk *clk) @@ -336,7 +367,7 @@ int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate)  		ratio--;  	} -	if (ratio > PLLDIV_RATIO_MASK) +	if (ratio > pll->div_ratio_mask)  		return -EINVAL;  	do { @@ -344,7 +375,7 @@ int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate)  	} while (v & PLLSTAT_GOSTAT);  	v = __raw_readl(pll->base + clk->div_reg); -	v &= ~PLLDIV_RATIO_MASK; +	v &= ~pll->div_ratio_mask;  	v |= ratio | PLLDIV_EN;  	__raw_writel(v, pll->base + clk->div_reg); @@ -368,6 +399,12 @@ static unsigned long clk_leafclk_recalc(struct clk *clk)  	return clk->parent->rate;  } +int davinci_simple_set_rate(struct clk *clk, unsigned long rate) +{ +	clk->rate = rate; +	return 0; +} +  static unsigned long clk_pllclk_recalc(struct clk *clk)  {  	u32 ctrl, mult = 1, prediv = 1, postdiv = 1; @@ -506,8 +543,40 @@ int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,  }  EXPORT_SYMBOL(davinci_set_pllrate); +/** + * davinci_set_refclk_rate() - Set the reference clock rate + * @rate:	The new rate. + * + * Sets the reference clock rate to a given value. This will most likely + * result in the entire clock tree getting updated. + * + * This is used to support boards which use a reference clock different + * than that used by default in <soc>.c file. The reference clock rate + * should be updated early in the boot process; ideally soon after the + * clock tree has been initialized once with the default reference clock + * rate (davinci_common_init()). + * + * Returns 0 on success, error otherwise. + */ +int davinci_set_refclk_rate(unsigned long rate) +{ +	struct clk *refclk; + +	refclk = clk_get(NULL, "ref"); +	if (IS_ERR(refclk)) { +		pr_err("%s: failed to get reference clock.\n", __func__); +		return PTR_ERR(refclk); +	} + +	clk_set_rate(refclk, rate); + +	clk_put(refclk); + +	return 0; +} +  int __init davinci_clk_init(struct clk_lookup *clocks) -  { +{  	struct clk_lookup *c;  	struct clk *clk;  	size_t num_clocks = 0; @@ -548,6 +617,9 @@ int __init davinci_clk_init(struct clk_lookup *clocks)  		if (clk->lpsc)  			clk->flags |= CLK_PSC; +		if (clk->flags & PSC_LRST) +			clk->reset = davinci_clk_reset; +  		clk_register(clk);  		num_clocks++; diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h index 11099980b58..1e4e836173a 100644 --- a/arch/arm/mach-davinci/clock.h +++ b/arch/arm/mach-davinci/clock.h @@ -68,7 +68,7 @@  #ifndef __ASSEMBLER__  #include <linux/list.h> -#include <asm/clkdev.h> +#include <linux/clkdev.h>  #define PLLSTAT_GOSTAT	BIT(0)  #define PLLCMD_GOSET	BIT(0) @@ -93,6 +93,7 @@ struct clk {  	u8			usecount;  	u8			lpsc;  	u8			gpsc; +	u8			domain;  	u32			flags;  	struct clk              *parent;  	struct list_head	children; 	/* list of children */ @@ -102,15 +103,19 @@ struct clk {  	unsigned long (*recalc) (struct clk *);  	int (*set_rate) (struct clk *clk, unsigned long rate);  	int (*round_rate) (struct clk *clk, unsigned long rate); +	int (*reset) (struct clk *clk, bool reset); +	void (*clk_enable) (struct clk *clk); +	void (*clk_disable) (struct clk *clk);  };  /* Clock flags: SoC-specific flags start at BIT(16) */  #define ALWAYS_ENABLED		BIT(1)  #define CLK_PSC			BIT(2) -#define PSC_DSP			BIT(3) /* PSC uses DSP domain, not ARM */ -#define CLK_PLL			BIT(4) /* PLL-derived clock */ -#define PRE_PLL			BIT(5) /* source is before PLL mult/div */ -#define PSC_SWRSTDISABLE	BIT(6) /* Disable state is SwRstDisable */ +#define CLK_PLL			BIT(3) /* PLL-derived clock */ +#define PRE_PLL			BIT(4) /* source is before PLL mult/div */ +#define PSC_SWRSTDISABLE	BIT(5) /* Disable state is SwRstDisable */ +#define PSC_FORCE		BIT(6) /* Force module state transtition */ +#define PSC_LRST		BIT(8) /* Use local reset on enable/disable */  #define CLK(dev, con, ck) 	\  	{			\ @@ -123,6 +128,9 @@ int davinci_clk_init(struct clk_lookup *clocks);  int davinci_set_pllrate(struct pll_data *pll, unsigned int prediv,  				unsigned int mult, unsigned int postdiv);  int davinci_set_sysclk_rate(struct clk *clk, unsigned long rate); +int davinci_set_refclk_rate(unsigned long rate); +int davinci_simple_set_rate(struct clk *clk, unsigned long rate); +int davinci_clk_reset(struct clk *clk, bool reset);  extern struct platform_device davinci_wdt_device;  extern void davinci_watchdog_reset(struct platform_device *); diff --git a/arch/arm/mach-davinci/common.c b/arch/arm/mach-davinci/common.c index 1d255739423..a794f6d9d44 100644 --- a/arch/arm/mach-davinci/common.c +++ b/arch/arm/mach-davinci/common.c @@ -12,6 +12,7 @@  #include <linux/io.h>  #include <linux/etherdevice.h>  #include <linux/davinci_emac.h> +#include <linux/dma-mapping.h>  #include <asm/tlb.h>  #include <asm/mach/map.h> @@ -94,9 +95,6 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info)  	local_flush_tlb_all();  	flush_cache_all(); -	if (!davinci_soc_info.reset) -		davinci_soc_info.reset = davinci_watchdog_reset; -  	/*  	 * We want to check CPU revision early for cpu_is_xxxx() macros.  	 * IO space mapping must be initialized before we can do that. @@ -117,3 +115,10 @@ void __init davinci_common_init(struct davinci_soc_info *soc_info)  err:  	panic("davinci_common_init: SoC Initialization failed\n");  } + +void __init davinci_init_late(void) +{ +	davinci_cpufreq_init(); +	davinci_pm_init(); +	davinci_clk_disable_unused(); +} diff --git a/arch/arm/mach-davinci/cp_intc.c b/arch/arm/mach-davinci/cp_intc.c index bb4c40ecb80..006dae8dfe4 100644 --- a/arch/arm/mach-davinci/cp_intc.c +++ b/arch/arm/mach-davinci/cp_intc.c @@ -9,9 +9,14 @@   * kind, whether express or implied.   */ +#include <linux/export.h>  #include <linux/init.h>  #include <linux/irq.h> +#include <linux/irqdomain.h>  #include <linux/io.h> +#include <linux/of.h> +#include <linux/of_address.h> +#include <linux/of_irq.h>  #include <mach/common.h>  #include <mach/cp_intc.h> @@ -26,30 +31,30 @@ static inline void cp_intc_write(unsigned long value, unsigned offset)  	__raw_writel(value, davinci_intc_base + offset);  } -static void cp_intc_ack_irq(unsigned int irq) +static void cp_intc_ack_irq(struct irq_data *d)  { -	cp_intc_write(irq, CP_INTC_SYS_STAT_IDX_CLR); +	cp_intc_write(d->hwirq, CP_INTC_SYS_STAT_IDX_CLR);  }  /* Disable interrupt */ -static void cp_intc_mask_irq(unsigned int irq) +static void cp_intc_mask_irq(struct irq_data *d)  {  	/* XXX don't know why we need to disable nIRQ here... */  	cp_intc_write(1, CP_INTC_HOST_ENABLE_IDX_CLR); -	cp_intc_write(irq, CP_INTC_SYS_ENABLE_IDX_CLR); +	cp_intc_write(d->hwirq, CP_INTC_SYS_ENABLE_IDX_CLR);  	cp_intc_write(1, CP_INTC_HOST_ENABLE_IDX_SET);  }  /* Enable interrupt */ -static void cp_intc_unmask_irq(unsigned int irq) +static void cp_intc_unmask_irq(struct irq_data *d)  { -	cp_intc_write(irq, CP_INTC_SYS_ENABLE_IDX_SET); +	cp_intc_write(d->hwirq, CP_INTC_SYS_ENABLE_IDX_SET);  } -static int cp_intc_set_irq_type(unsigned int irq, unsigned int flow_type) +static int cp_intc_set_irq_type(struct irq_data *d, unsigned int flow_type)  { -	unsigned reg		= BIT_WORD(irq); -	unsigned mask		= BIT_MASK(irq); +	unsigned reg		= BIT_WORD(d->hwirq); +	unsigned mask		= BIT_MASK(d->hwirq);  	unsigned polarity	= cp_intc_read(CP_INTC_SYS_POLARITY(reg));  	unsigned type		= cp_intc_read(CP_INTC_SYS_TYPE(reg)); @@ -85,32 +90,57 @@ static int cp_intc_set_irq_type(unsigned int irq, unsigned int flow_type)   * generic drivers which call {enable|disable}_irq_wake for   * wake up interrupt sources (eg RTC on DA850).   */ -static int cp_intc_set_wake(unsigned int irq, unsigned int on) +static int cp_intc_set_wake(struct irq_data *d, unsigned int on)  {  	return 0;  }  static struct irq_chip cp_intc_irq_chip = {  	.name		= "cp_intc", -	.ack		= cp_intc_ack_irq, -	.mask		= cp_intc_mask_irq, -	.unmask		= cp_intc_unmask_irq, -	.set_type	= cp_intc_set_irq_type, -	.set_wake	= cp_intc_set_wake, +	.irq_ack	= cp_intc_ack_irq, +	.irq_mask	= cp_intc_mask_irq, +	.irq_unmask	= cp_intc_unmask_irq, +	.irq_set_type	= cp_intc_set_irq_type, +	.irq_set_wake	= cp_intc_set_wake,  }; -void __init cp_intc_init(void) +static struct irq_domain *cp_intc_domain; + +static int cp_intc_host_map(struct irq_domain *h, unsigned int virq, +			  irq_hw_number_t hw)  { -	unsigned long num_irq	= davinci_soc_info.intc_irq_num; +	pr_debug("cp_intc_host_map(%d, 0x%lx)\n", virq, hw); + +	irq_set_chip(virq, &cp_intc_irq_chip); +	set_irq_flags(virq, IRQF_VALID | IRQF_PROBE); +	irq_set_handler(virq, handle_edge_irq); +	return 0; +} + +static const struct irq_domain_ops cp_intc_host_ops = { +	.map = cp_intc_host_map, +	.xlate = irq_domain_xlate_onetwocell, +}; + +int __init cp_intc_of_init(struct device_node *node, struct device_node *parent) +{ +	u32 num_irq		= davinci_soc_info.intc_irq_num;  	u8 *irq_prio		= davinci_soc_info.intc_irq_prios;  	u32 *host_map		= davinci_soc_info.intc_host_map;  	unsigned num_reg	= BITS_TO_LONGS(num_irq); -	int i; +	int i, irq_base;  	davinci_intc_type = DAVINCI_INTC_TYPE_CP_INTC; -	davinci_intc_base = ioremap(davinci_soc_info.intc_base, SZ_8K); +	if (node) { +		davinci_intc_base = of_iomap(node, 0); +		if (of_property_read_u32(node, "ti,intc-size", &num_irq)) +			pr_warn("unable to get intc-size, default to %d\n", +				num_irq); +	} else { +		davinci_intc_base = ioremap(davinci_soc_info.intc_base, SZ_8K); +	}  	if (WARN_ON(!davinci_intc_base)) -		return; +		return -EINVAL;  	cp_intc_write(0, CP_INTC_GLOBAL_ENABLE); @@ -165,13 +195,28 @@ void __init cp_intc_init(void)  		for (i = 0; host_map[i] != -1; i++)  			cp_intc_write(host_map[i], CP_INTC_HOST_MAP(i)); -	/* Set up genirq dispatching for cp_intc */ -	for (i = 0; i < num_irq; i++) { -		set_irq_chip(i, &cp_intc_irq_chip); -		set_irq_flags(i, IRQF_VALID | IRQF_PROBE); -		set_irq_handler(i, handle_edge_irq); +	irq_base = irq_alloc_descs(-1, 0, num_irq, 0); +	if (irq_base < 0) { +		pr_warn("Couldn't allocate IRQ numbers\n"); +		irq_base = 0; +	} + +	/* create a legacy host */ +	cp_intc_domain = irq_domain_add_legacy(node, num_irq, +					irq_base, 0, &cp_intc_host_ops, NULL); + +	if (!cp_intc_domain) { +		pr_err("cp_intc: failed to allocate irq host!\n"); +		return -EINVAL;  	}  	/* Enable global interrupt */  	cp_intc_write(1, CP_INTC_GLOBAL_ENABLE); + +	return 0; +} + +void __init cp_intc_init(void) +{ +	cp_intc_of_init(NULL, NULL);  } diff --git a/arch/arm/mach-davinci/cpufreq.c b/arch/arm/mach-davinci/cpufreq.c deleted file mode 100644 index 343de73161f..00000000000 --- a/arch/arm/mach-davinci/cpufreq.c +++ /dev/null @@ -1,250 +0,0 @@ -/* - * CPU frequency scaling for DaVinci - * - * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ - * - * Based on linux/arch/arm/plat-omap/cpu-omap.c. Original Copyright follows: - * - *  Copyright (C) 2005 Nokia Corporation - *  Written by Tony Lindgren <tony@atomide.com> - * - *  Based on cpu-sa1110.c, Copyright (C) 2001 Russell King - * - * Copyright (C) 2007-2008 Texas Instruments, Inc. - * Updated to support OMAP3 - * Rajendra Nayak <rnayak@ti.com> - * - * 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/types.h> -#include <linux/cpufreq.h> -#include <linux/init.h> -#include <linux/err.h> -#include <linux/clk.h> -#include <linux/platform_device.h> - -#include <mach/hardware.h> -#include <mach/cpufreq.h> -#include <mach/common.h> - -#include "clock.h" - -struct davinci_cpufreq { -	struct device *dev; -	struct clk *armclk; -	struct clk *asyncclk; -	unsigned long asyncrate; -}; -static struct davinci_cpufreq cpufreq; - -static int davinci_verify_speed(struct cpufreq_policy *policy) -{ -	struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; -	struct cpufreq_frequency_table *freq_table = pdata->freq_table; -	struct clk *armclk = cpufreq.armclk; - -	if (freq_table) -		return cpufreq_frequency_table_verify(policy, freq_table); - -	if (policy->cpu) -		return -EINVAL; - -	cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, -				     policy->cpuinfo.max_freq); - -	policy->min = clk_round_rate(armclk, policy->min * 1000) / 1000; -	policy->max = clk_round_rate(armclk, policy->max * 1000) / 1000; -	cpufreq_verify_within_limits(policy, policy->cpuinfo.min_freq, -						policy->cpuinfo.max_freq); -	return 0; -} - -static unsigned int davinci_getspeed(unsigned int cpu) -{ -	if (cpu) -		return 0; - -	return clk_get_rate(cpufreq.armclk) / 1000; -} - -static int davinci_target(struct cpufreq_policy *policy, -				unsigned int target_freq, unsigned int relation) -{ -	int ret = 0; -	unsigned int idx; -	struct cpufreq_freqs freqs; -	struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; -	struct clk *armclk = cpufreq.armclk; - -	/* -	 * Ensure desired rate is within allowed range.  Some govenors -	 * (ondemand) will just pass target_freq=0 to get the minimum. -	 */ -	if (target_freq < policy->cpuinfo.min_freq) -		target_freq = policy->cpuinfo.min_freq; -	if (target_freq > policy->cpuinfo.max_freq) -		target_freq = policy->cpuinfo.max_freq; - -	freqs.old = davinci_getspeed(0); -	freqs.new = clk_round_rate(armclk, target_freq * 1000) / 1000; -	freqs.cpu = 0; - -	if (freqs.old == freqs.new) -		return ret; - -	cpufreq_debug_printk(CPUFREQ_DEBUG_DRIVER, -			dev_driver_string(cpufreq.dev), -			"transition: %u --> %u\n", freqs.old, freqs.new); - -	ret = cpufreq_frequency_table_target(policy, pdata->freq_table, -						freqs.new, relation, &idx); -	if (ret) -		return -EINVAL; - -	cpufreq_notify_transition(&freqs, CPUFREQ_PRECHANGE); - -	/* if moving to higher frequency, up the voltage beforehand */ -	if (pdata->set_voltage && freqs.new > freqs.old) { -		ret = pdata->set_voltage(idx); -		if (ret) -			goto out; -	} - -	ret = clk_set_rate(armclk, idx); -	if (ret) -		goto out; - -	if (cpufreq.asyncclk) { -		ret = clk_set_rate(cpufreq.asyncclk, cpufreq.asyncrate); -		if (ret) -			goto out; -	} - -	/* if moving to lower freq, lower the voltage after lowering freq */ -	if (pdata->set_voltage && freqs.new < freqs.old) -		pdata->set_voltage(idx); - -out: -	cpufreq_notify_transition(&freqs, CPUFREQ_POSTCHANGE); - -	return ret; -} - -static int __init davinci_cpu_init(struct cpufreq_policy *policy) -{ -	int result = 0; -	struct davinci_cpufreq_config *pdata = cpufreq.dev->platform_data; -	struct cpufreq_frequency_table *freq_table = pdata->freq_table; - -	if (policy->cpu != 0) -		return -EINVAL; - -	/* Finish platform specific initialization */ -	if (pdata->init) { -		result = pdata->init(); -		if (result) -			return result; -	} - -	policy->cur = policy->min = policy->max = davinci_getspeed(0); - -	if (freq_table) { -		result = cpufreq_frequency_table_cpuinfo(policy, freq_table); -		if (!result) -			cpufreq_frequency_table_get_attr(freq_table, -							policy->cpu); -	} else { -		policy->cpuinfo.min_freq = policy->min; -		policy->cpuinfo.max_freq = policy->max; -	} - -	policy->min = policy->cpuinfo.min_freq; -	policy->max = policy->cpuinfo.max_freq; -	policy->cur = davinci_getspeed(0); - -	/* -	 * Time measurement across the target() function yields ~1500-1800us -	 * time taken with no drivers on notification list. -	 * Setting the latency to 2000 us to accomodate addition of drivers -	 * to pre/post change notification list. -	 */ -	policy->cpuinfo.transition_latency = 2000 * 1000; -	return 0; -} - -static int davinci_cpu_exit(struct cpufreq_policy *policy) -{ -	cpufreq_frequency_table_put_attr(policy->cpu); -	return 0; -} - -static struct freq_attr *davinci_cpufreq_attr[] = { -	&cpufreq_freq_attr_scaling_available_freqs, -	NULL, -}; - -static struct cpufreq_driver davinci_driver = { -	.flags		= CPUFREQ_STICKY, -	.verify		= davinci_verify_speed, -	.target		= davinci_target, -	.get		= davinci_getspeed, -	.init		= davinci_cpu_init, -	.exit		= davinci_cpu_exit, -	.name		= "davinci", -	.attr		= davinci_cpufreq_attr, -}; - -static int __init davinci_cpufreq_probe(struct platform_device *pdev) -{ -	struct davinci_cpufreq_config *pdata = pdev->dev.platform_data; -	struct clk *asyncclk; - -	if (!pdata) -		return -EINVAL; -	if (!pdata->freq_table) -		return -EINVAL; - -	cpufreq.dev = &pdev->dev; - -	cpufreq.armclk = clk_get(NULL, "arm"); -	if (IS_ERR(cpufreq.armclk)) { -		dev_err(cpufreq.dev, "Unable to get ARM clock\n"); -		return PTR_ERR(cpufreq.armclk); -	} - -	asyncclk = clk_get(cpufreq.dev, "async"); -	if (!IS_ERR(asyncclk)) { -		cpufreq.asyncclk = asyncclk; -		cpufreq.asyncrate = clk_get_rate(asyncclk); -	} - -	return cpufreq_register_driver(&davinci_driver); -} - -static int __exit davinci_cpufreq_remove(struct platform_device *pdev) -{ -	clk_put(cpufreq.armclk); - -	if (cpufreq.asyncclk) -		clk_put(cpufreq.asyncclk); - -	return cpufreq_unregister_driver(&davinci_driver); -} - -static struct platform_driver davinci_cpufreq_driver = { -	.driver = { -		.name	 = "cpufreq-davinci", -		.owner	 = THIS_MODULE, -	}, -	.remove = __exit_p(davinci_cpufreq_remove), -}; - -static int __init davinci_cpufreq_init(void) -{ -	return platform_driver_probe(&davinci_cpufreq_driver, -							davinci_cpufreq_probe); -} -late_initcall(davinci_cpufreq_init); - diff --git a/arch/arm/mach-davinci/cpuidle.c b/arch/arm/mach-davinci/cpuidle.c index bd59f31b8a9..f1ac1c94ac0 100644 --- a/arch/arm/mach-davinci/cpuidle.c +++ b/arch/arm/mach-davinci/cpuidle.c @@ -16,29 +16,17 @@  #include <linux/platform_device.h>  #include <linux/cpuidle.h>  #include <linux/io.h> +#include <linux/export.h>  #include <asm/proc-fns.h> +#include <asm/cpuidle.h>  #include <mach/cpuidle.h> -#include <mach/memory.h> +#include <mach/ddr2.h>  #define DAVINCI_CPUIDLE_MAX_STATES	2 -struct davinci_ops { -	void (*enter) (u32 flags); -	void (*exit) (u32 flags); -	u32 flags; -}; - -/* fields in davinci_ops.flags */ -#define DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN	BIT(0) - -static struct cpuidle_driver davinci_idle_driver = { -	.name	= "cpuidle-davinci", -	.owner	= THIS_MODULE, -}; - -static DEFINE_PER_CPU(struct cpuidle_device, davinci_cpuidle_device);  static void __iomem *ddr2_reg_base; +static bool ddr2_pdown;  static void davinci_save_ddr_power(int enter, bool pdown)  { @@ -59,56 +47,36 @@ static void davinci_save_ddr_power(int enter, bool pdown)  	__raw_writel(val, ddr2_reg_base + DDR2_SDRCR_OFFSET);  } -static void davinci_c2state_enter(u32 flags) +/* Actual code that puts the SoC in different idle states */ +static int davinci_enter_idle(struct cpuidle_device *dev, +			      struct cpuidle_driver *drv, int index)  { -	davinci_save_ddr_power(1, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN)); -} +	davinci_save_ddr_power(1, ddr2_pdown); +	cpu_do_idle(); +	davinci_save_ddr_power(0, ddr2_pdown); -static void davinci_c2state_exit(u32 flags) -{ -	davinci_save_ddr_power(0, !!(flags & DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN)); +	return index;  } -static struct davinci_ops davinci_states[DAVINCI_CPUIDLE_MAX_STATES] = { -	[1] = { -		.enter	= davinci_c2state_enter, -		.exit	= davinci_c2state_exit, +static struct cpuidle_driver davinci_idle_driver = { +	.name			= "cpuidle-davinci", +	.owner			= THIS_MODULE, +	.states[0]		= ARM_CPUIDLE_WFI_STATE, +	.states[1]		= { +		.enter			= davinci_enter_idle, +		.exit_latency		= 10, +		.target_residency	= 10000, +		.flags			= CPUIDLE_FLAG_TIME_VALID, +		.name			= "DDR SR", +		.desc			= "WFI and DDR Self Refresh",  	}, +	.state_count = DAVINCI_CPUIDLE_MAX_STATES,  }; -/* Actual code that puts the SoC in different idle states */ -static int davinci_enter_idle(struct cpuidle_device *dev, -						struct cpuidle_state *state) -{ -	struct davinci_ops *ops = cpuidle_get_statedata(state); -	struct timeval before, after; -	int idle_time; - -	local_irq_disable(); -	do_gettimeofday(&before); - -	if (ops && ops->enter) -		ops->enter(ops->flags); -	/* Wait for interrupt state */ -	cpu_do_idle(); -	if (ops && ops->exit) -		ops->exit(ops->flags); - -	do_gettimeofday(&after); -	local_irq_enable(); -	idle_time = (after.tv_sec - before.tv_sec) * USEC_PER_SEC + -			(after.tv_usec - before.tv_usec); -	return idle_time; -} -  static int __init davinci_cpuidle_probe(struct platform_device *pdev)  { -	int ret; -	struct cpuidle_device *device;  	struct davinci_cpuidle_config *pdata = pdev->dev.platform_data; -	device = &per_cpu(davinci_cpuidle_device, smp_processor_id()); -  	if (!pdata) {  		dev_err(&pdev->dev, "cannot get platform data\n");  		return -ENOENT; @@ -116,41 +84,9 @@ static int __init davinci_cpuidle_probe(struct platform_device *pdev)  	ddr2_reg_base = pdata->ddr2_ctlr_base; -	ret = cpuidle_register_driver(&davinci_idle_driver); -	if (ret) { -		dev_err(&pdev->dev, "failed to register driver\n"); -		return ret; -	} - -	/* Wait for interrupt state */ -	device->states[0].enter = davinci_enter_idle; -	device->states[0].exit_latency = 1; -	device->states[0].target_residency = 10000; -	device->states[0].flags = CPUIDLE_FLAG_TIME_VALID; -	strcpy(device->states[0].name, "WFI"); -	strcpy(device->states[0].desc, "Wait for interrupt"); - -	/* Wait for interrupt and DDR self refresh state */ -	device->states[1].enter = davinci_enter_idle; -	device->states[1].exit_latency = 10; -	device->states[1].target_residency = 10000; -	device->states[1].flags = CPUIDLE_FLAG_TIME_VALID; -	strcpy(device->states[1].name, "DDR SR"); -	strcpy(device->states[1].desc, "WFI and DDR Self Refresh"); -	if (pdata->ddr2_pdown) -		davinci_states[1].flags |= DAVINCI_CPUIDLE_FLAGS_DDR2_PWDN; -	cpuidle_set_statedata(&device->states[1], &davinci_states[1]); - -	device->state_count = DAVINCI_CPUIDLE_MAX_STATES; - -	ret = cpuidle_register_device(device); -	if (ret) { -		dev_err(&pdev->dev, "failed to register device\n"); -		cpuidle_unregister_driver(&davinci_idle_driver); -		return ret; -	} +	ddr2_pdown = pdata->ddr2_pdown; -	return 0; +	return cpuidle_register(&davinci_idle_driver, NULL);  }  static struct platform_driver davinci_cpuidle_driver = { diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c index ec23ab47362..115d5736da8 100644 --- a/arch/arm/mach-davinci/da830.c +++ b/arch/arm/mach-davinci/da830.c @@ -8,8 +8,10 @@   * is licensed "as is" without any warranty of any kind, whether express   * or implied.   */ +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/clk.h> +#include <linux/platform_data/gpio-davinci.h>  #include <asm/mach/map.h> @@ -19,7 +21,6 @@  #include <mach/common.h>  #include <mach/time.h>  #include <mach/da8xx.h> -#include <mach/gpio.h>  #include "clock.h"  #include "mux.h" @@ -148,7 +149,7 @@ static struct clk scr2_ss_clk = {  static struct clk dmax_clk = {  	.name		= "dmax",  	.parent		= &pll0_sysclk2, -	.lpsc		= DA8XX_LPSC0_DMAX, +	.lpsc		= DA8XX_LPSC0_PRUSS,  	.flags		= ALWAYS_ENABLED,  }; @@ -384,7 +385,7 @@ static struct clk_lookup da830_clks[] = {  	CLK(NULL,		"pll0_sysclk7",	&pll0_sysclk7),  	CLK("i2c_davinci.1",	NULL,		&i2c0_clk),  	CLK(NULL,		"timer0",	&timerp64_0_clk), -	CLK("watchdog",		NULL,		&timerp64_1_clk), +	CLK("davinci-wdt",	NULL,		&timerp64_1_clk),  	CLK(NULL,		"arm_rom",	&arm_rom_clk),  	CLK(NULL,		"scr0_ss",	&scr0_ss_clk),  	CLK(NULL,		"scr1_ss",	&scr1_ss_clk), @@ -393,12 +394,12 @@ static struct clk_lookup da830_clks[] = {  	CLK(NULL,		"tpcc",		&tpcc_clk),  	CLK(NULL,		"tptc0",	&tptc0_clk),  	CLK(NULL,		"tptc1",	&tptc1_clk), -	CLK("davinci_mmc.0",	NULL,		&mmcsd_clk), -	CLK(NULL,		"uart0",	&uart0_clk), -	CLK(NULL,		"uart1",	&uart1_clk), -	CLK(NULL,		"uart2",	&uart2_clk), -	CLK("dm_spi.0",		NULL,		&spi0_clk), -	CLK("dm_spi.1",		NULL,		&spi1_clk), +	CLK("da830-mmc.0",	NULL,		&mmcsd_clk), +	CLK("serial8250.0",	NULL,		&uart0_clk), +	CLK("serial8250.1",	NULL,		&uart1_clk), +	CLK("serial8250.2",	NULL,		&uart2_clk), +	CLK("spi_davinci.0",	NULL,		&spi0_clk), +	CLK("spi_davinci.1",	NULL,		&spi1_clk),  	CLK(NULL,		"ecap0",	&ecap0_clk),  	CLK(NULL,		"ecap1",	&ecap1_clk),  	CLK(NULL,		"ecap2",	&ecap2_clk), @@ -407,7 +408,7 @@ static struct clk_lookup da830_clks[] = {  	CLK(NULL,		"pwm2",		&pwm2_clk),  	CLK("eqep.0",		NULL,		&eqep0_clk),  	CLK("eqep.1",		NULL,		&eqep1_clk), -	CLK("da8xx_lcdc.0",	NULL,		&lcdc_clk), +	CLK("da8xx_lcdc.0",	"fck",		&lcdc_clk),  	CLK("davinci-mcasp.0",	NULL,		&mcasp0_clk),  	CLK("davinci-mcasp.1",	NULL,		&mcasp1_clk),  	CLK("davinci-mcasp.2",	NULL,		&mcasp2_clk), @@ -416,6 +417,7 @@ static struct clk_lookup da830_clks[] = {  	CLK(NULL,		"aintc",	&aintc_clk),  	CLK(NULL,		"secu_mgr",	&secu_mgr_clk),  	CLK("davinci_emac.1",	NULL,		&emac_clk), +	CLK("davinci_mdio.0",   "fck",          &emac_clk),  	CLK(NULL,		"gpio",		&gpio_clk),  	CLK("i2c_davinci.2",	NULL,		&i2c1_clk),  	CLK(NULL,		"usb11",	&usb11_clk), @@ -837,7 +839,7 @@ static const struct mux_config da830_pins[] = {  #endif  }; -const short da830_emif25_pins[] __initdata = { +const short da830_emif25_pins[] __initconst = {  	DA830_EMA_D_0, DA830_EMA_D_1, DA830_EMA_D_2, DA830_EMA_D_3,  	DA830_EMA_D_4, DA830_EMA_D_5, DA830_EMA_D_6, DA830_EMA_D_7,  	DA830_EMA_D_8, DA830_EMA_D_9, DA830_EMA_D_10, DA830_EMA_D_11, @@ -852,19 +854,19 @@ const short da830_emif25_pins[] __initdata = {  	-1  }; -const short da830_spi0_pins[] __initdata = { +const short da830_spi0_pins[] __initconst = {  	DA830_SPI0_SOMI_0, DA830_SPI0_SIMO_0, DA830_SPI0_CLK, DA830_NSPI0_ENA,  	DA830_NSPI0_SCS_0,  	-1  }; -const short da830_spi1_pins[] __initdata = { +const short da830_spi1_pins[] __initconst = {  	DA830_SPI1_SOMI_0, DA830_SPI1_SIMO_0, DA830_SPI1_CLK, DA830_NSPI1_ENA,  	DA830_NSPI1_SCS_0,  	-1  }; -const short da830_mmc_sd_pins[] __initdata = { +const short da830_mmc_sd_pins[] __initconst = {  	DA830_MMCSD_DAT_0, DA830_MMCSD_DAT_1, DA830_MMCSD_DAT_2,  	DA830_MMCSD_DAT_3, DA830_MMCSD_DAT_4, DA830_MMCSD_DAT_5,  	DA830_MMCSD_DAT_6, DA830_MMCSD_DAT_7, DA830_MMCSD_CLK, @@ -872,32 +874,32 @@ const short da830_mmc_sd_pins[] __initdata = {  	-1  }; -const short da830_uart0_pins[] __initdata = { +const short da830_uart0_pins[] __initconst = {  	DA830_NUART0_CTS, DA830_NUART0_RTS, DA830_UART0_RXD, DA830_UART0_TXD,  	-1  }; -const short da830_uart1_pins[] __initdata = { +const short da830_uart1_pins[] __initconst = {  	DA830_UART1_RXD, DA830_UART1_TXD,  	-1  }; -const short da830_uart2_pins[] __initdata = { +const short da830_uart2_pins[] __initconst = {  	DA830_UART2_RXD, DA830_UART2_TXD,  	-1  }; -const short da830_usb20_pins[] __initdata = { +const short da830_usb20_pins[] __initconst = {  	DA830_USB0_DRVVBUS, DA830_USB_REFCLKIN,  	-1  }; -const short da830_usb11_pins[] __initdata = { +const short da830_usb11_pins[] __initconst = {  	DA830_USB_REFCLKIN,  	-1  }; -const short da830_uhpi_pins[] __initdata = { +const short da830_uhpi_pins[] __initconst = {  	DA830_UHPI_HD_0, DA830_UHPI_HD_1, DA830_UHPI_HD_2, DA830_UHPI_HD_3,  	DA830_UHPI_HD_4, DA830_UHPI_HD_5, DA830_UHPI_HD_6, DA830_UHPI_HD_7,  	DA830_UHPI_HD_8, DA830_UHPI_HD_9, DA830_UHPI_HD_10, DA830_UHPI_HD_11, @@ -908,14 +910,14 @@ const short da830_uhpi_pins[] __initdata = {  	-1  }; -const short da830_cpgmac_pins[] __initdata = { +const short da830_cpgmac_pins[] __initconst = {  	DA830_RMII_TXD_0, DA830_RMII_TXD_1, DA830_RMII_TXEN, DA830_RMII_CRS_DV,  	DA830_RMII_RXD_0, DA830_RMII_RXD_1, DA830_RMII_RXER, DA830_MDIO_CLK,  	DA830_MDIO_D,  	-1  }; -const short da830_emif3c_pins[] __initdata = { +const short da830_emif3c_pins[] __initconst = {  	DA830_EMB_SDCKE, DA830_EMB_CLK_GLUE, DA830_EMB_CLK, DA830_NEMB_CS_0,  	DA830_NEMB_CAS, DA830_NEMB_RAS, DA830_NEMB_WE, DA830_EMB_BA_1,  	DA830_EMB_BA_0, DA830_EMB_A_0, DA830_EMB_A_1, DA830_EMB_A_2, @@ -934,7 +936,7 @@ const short da830_emif3c_pins[] __initdata = {  	-1  }; -const short da830_mcasp0_pins[] __initdata = { +const short da830_mcasp0_pins[] __initconst = {  	DA830_AHCLKX0, DA830_ACLKX0, DA830_AFSX0,  	DA830_AHCLKR0, DA830_ACLKR0, DA830_AFSR0, DA830_AMUTE0,  	DA830_AXR0_0, DA830_AXR0_1, DA830_AXR0_2, DA830_AXR0_3, @@ -944,7 +946,7 @@ const short da830_mcasp0_pins[] __initdata = {  	-1  }; -const short da830_mcasp1_pins[] __initdata = { +const short da830_mcasp1_pins[] __initconst = {  	DA830_AHCLKX1, DA830_ACLKX1, DA830_AFSX1,  	DA830_AHCLKR1, DA830_ACLKR1, DA830_AFSR1, DA830_AMUTE1,  	DA830_AXR1_0, DA830_AXR1_1, DA830_AXR1_2, DA830_AXR1_3, @@ -953,24 +955,24 @@ const short da830_mcasp1_pins[] __initdata = {  	-1  }; -const short da830_mcasp2_pins[] __initdata = { +const short da830_mcasp2_pins[] __initconst = {  	DA830_AHCLKX2, DA830_ACLKX2, DA830_AFSX2,  	DA830_AHCLKR2, DA830_ACLKR2, DA830_AFSR2, DA830_AMUTE2,  	DA830_AXR2_0, DA830_AXR2_1, DA830_AXR2_2, DA830_AXR2_3,  	-1  }; -const short da830_i2c0_pins[] __initdata = { +const short da830_i2c0_pins[] __initconst = {  	DA830_I2C0_SDA, DA830_I2C0_SCL,  	-1  }; -const short da830_i2c1_pins[] __initdata = { +const short da830_i2c1_pins[] __initconst = {  	DA830_I2C1_SCL, DA830_I2C1_SDA,  	-1  }; -const short da830_lcdcntl_pins[] __initdata = { +const short da830_lcdcntl_pins[] __initconst = {  	DA830_LCD_D_0, DA830_LCD_D_1, DA830_LCD_D_2, DA830_LCD_D_3,  	DA830_LCD_D_4, DA830_LCD_D_5, DA830_LCD_D_6, DA830_LCD_D_7,  	DA830_LCD_D_8, DA830_LCD_D_9, DA830_LCD_D_10, DA830_LCD_D_11, @@ -980,34 +982,34 @@ const short da830_lcdcntl_pins[] __initdata = {  	-1  }; -const short da830_pwm_pins[] __initdata = { +const short da830_pwm_pins[] __initconst = {  	DA830_ECAP0_APWM0, DA830_ECAP1_APWM1, DA830_EPWM0B, DA830_EPWM0A,  	DA830_EPWMSYNCI, DA830_EPWMSYNC0, DA830_ECAP2_APWM2, DA830_EHRPWMGLUETZ,  	DA830_EPWM2B, DA830_EPWM2A, DA830_EPWM1B, DA830_EPWM1A,  	-1  }; -const short da830_ecap0_pins[] __initdata = { +const short da830_ecap0_pins[] __initconst = {  	DA830_ECAP0_APWM0,  	-1  }; -const short da830_ecap1_pins[] __initdata = { +const short da830_ecap1_pins[] __initconst = {  	DA830_ECAP1_APWM1,  	-1  }; -const short da830_ecap2_pins[] __initdata = { +const short da830_ecap2_pins[] __initconst = {  	DA830_ECAP2_APWM2,  	-1  }; -const short da830_eqep0_pins[] __initdata = { +const short da830_eqep0_pins[] __initconst = {  	DA830_EQEP0I, DA830_EQEP0S, DA830_EQEP0A, DA830_EQEP0B,  	-1  }; -const short da830_eqep1_pins[] __initdata = { +const short da830_eqep1_pins[] __initconst = {  	DA830_EQEP1I, DA830_EQEP1S, DA830_EQEP1A, DA830_EQEP1B,  	-1  }; @@ -1149,6 +1151,15 @@ static struct davinci_id da830_ids[] = {  	},  }; +static struct davinci_gpio_platform_data da830_gpio_platform_data = { +	.ngpio = 128, +}; + +int __init da830_register_gpio(void) +{ +	return da8xx_register_gpio(&da830_gpio_platform_data); +} +  static struct davinci_timer_instance da830_timer_instance[2] = {  	{  		.base		= DA8XX_TIMER64P0_BASE, @@ -1194,13 +1205,7 @@ static struct davinci_soc_info davinci_soc_info_da830 = {  	.intc_irq_prios		= da830_default_priorities,  	.intc_irq_num		= DA830_N_CP_INTC_IRQ,  	.timer_info		= &da830_timer_info, -	.gpio_type		= GPIO_TYPE_DAVINCI, -	.gpio_base		= DA8XX_GPIO_BASE, -	.gpio_num		= 128, -	.gpio_irq		= IRQ_DA8XX_GPIO0, -	.serial_dev		= &da8xx_serial_device,  	.emac_pdata		= &da8xx_emac_pdata, -	.reset_device		= &da8xx_wdt_device,  };  void __init da830_init(void) diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index 63916b90276..45ce065e717 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c @@ -11,11 +11,13 @@   * is licensed "as is" without any warranty of any kind, whether express   * or implied.   */ +#include <linux/gpio.h>  #include <linux/init.h>  #include <linux/clk.h>  #include <linux/platform_device.h>  #include <linux/cpufreq.h>  #include <linux/regulator/consumer.h> +#include <linux/platform_data/gpio-davinci.h>  #include <asm/mach/map.h> @@ -27,7 +29,6 @@  #include <mach/da8xx.h>  #include <mach/cpufreq.h>  #include <mach/pm.h> -#include <mach/gpio.h>  #include "clock.h"  #include "mux.h" @@ -58,6 +59,7 @@ static struct pll_data pll0_data = {  static struct clk ref_clk = {  	.name		= "ref_clk",  	.rate		= DA850_REF_FREQ, +	.set_rate	= davinci_simple_set_rate,  };  static struct clk pll0_clk = { @@ -74,6 +76,13 @@ static struct clk pll0_aux_clk = {  	.flags		= CLK_PLL | PRE_PLL,  }; +static struct clk pll0_sysclk1 = { +	.name		= "pll0_sysclk1", +	.parent		= &pll0_clk, +	.flags		= CLK_PLL, +	.div_reg	= PLLDIV1, +}; +  static struct clk pll0_sysclk2 = {  	.name		= "pll0_sysclk2",  	.parent		= &pll0_clk, @@ -151,34 +160,6 @@ static struct clk pll1_sysclk3 = {  	.div_reg	= PLLDIV3,  }; -static struct clk pll1_sysclk4 = { -	.name		= "pll1_sysclk4", -	.parent		= &pll1_clk, -	.flags		= CLK_PLL, -	.div_reg	= PLLDIV4, -}; - -static struct clk pll1_sysclk5 = { -	.name		= "pll1_sysclk5", -	.parent		= &pll1_clk, -	.flags		= CLK_PLL, -	.div_reg	= PLLDIV5, -}; - -static struct clk pll1_sysclk6 = { -	.name		= "pll0_sysclk6", -	.parent		= &pll0_clk, -	.flags		= CLK_PLL, -	.div_reg	= PLLDIV6, -}; - -static struct clk pll1_sysclk7 = { -	.name		= "pll1_sysclk7", -	.parent		= &pll1_clk, -	.flags		= CLK_PLL, -	.div_reg	= PLLDIV7, -}; -  static struct clk i2c0_clk = {  	.name		= "i2c0",  	.parent		= &pll0_aux_clk, @@ -238,6 +219,12 @@ static struct clk tptc2_clk = {  	.flags		= ALWAYS_ENABLED,  }; +static struct clk pruss_clk = { +	.name		= "pruss", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA8XX_LPSC0_PRUSS, +}; +  static struct clk uart0_clk = {  	.name		= "uart0",  	.parent		= &pll0_sysclk2, @@ -345,10 +332,105 @@ static struct clk aemif_clk = {  	.flags		= ALWAYS_ENABLED,  }; +static struct clk usb11_clk = { +	.name		= "usb11", +	.parent		= &pll0_sysclk4, +	.lpsc		= DA8XX_LPSC1_USB11, +	.gpsc		= 1, +}; + +static struct clk usb20_clk = { +	.name		= "usb20", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA8XX_LPSC1_USB20, +	.gpsc		= 1, +}; + +static struct clk spi0_clk = { +	.name		= "spi0", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA8XX_LPSC0_SPI0, +}; + +static struct clk spi1_clk = { +	.name		= "spi1", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA8XX_LPSC1_SPI1, +	.gpsc		= 1, +	.flags		= DA850_CLK_ASYNC3, +}; + +static struct clk vpif_clk = { +	.name		= "vpif", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA850_LPSC1_VPIF, +	.gpsc		= 1, +}; + +static struct clk sata_clk = { +	.name		= "sata", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA850_LPSC1_SATA, +	.gpsc		= 1, +	.flags		= PSC_FORCE, +}; + +static struct clk dsp_clk = { +	.name		= "dsp", +	.parent		= &pll0_sysclk1, +	.domain		= DAVINCI_GPSC_DSPDOMAIN, +	.lpsc		= DA8XX_LPSC0_GEM, +	.flags		= PSC_LRST | PSC_FORCE, +}; + +static struct clk ehrpwm_clk = { +	.name		= "ehrpwm", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA8XX_LPSC1_PWM, +	.gpsc		= 1, +	.flags		= DA850_CLK_ASYNC3, +}; + +#define DA8XX_EHRPWM_TBCLKSYNC	BIT(12) + +static void ehrpwm_tblck_enable(struct clk *clk) +{ +	u32 val; + +	val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP1_REG)); +	val |= DA8XX_EHRPWM_TBCLKSYNC; +	writel(val, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP1_REG)); +} + +static void ehrpwm_tblck_disable(struct clk *clk) +{ +	u32 val; + +	val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP1_REG)); +	val &= ~DA8XX_EHRPWM_TBCLKSYNC; +	writel(val, DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP1_REG)); +} + +static struct clk ehrpwm_tbclk = { +	.name		= "ehrpwm_tbclk", +	.parent		= &ehrpwm_clk, +	.clk_enable	= ehrpwm_tblck_enable, +	.clk_disable	= ehrpwm_tblck_disable, +}; + +static struct clk ecap_clk = { +	.name		= "ecap", +	.parent		= &pll0_sysclk2, +	.lpsc		= DA8XX_LPSC1_ECAP, +	.gpsc		= 1, +	.flags		= DA850_CLK_ASYNC3, +}; +  static struct clk_lookup da850_clks[] = {  	CLK(NULL,		"ref",		&ref_clk),  	CLK(NULL,		"pll0",		&pll0_clk),  	CLK(NULL,		"pll0_aux",	&pll0_aux_clk), +	CLK(NULL,		"pll0_sysclk1",	&pll0_sysclk1),  	CLK(NULL,		"pll0_sysclk2",	&pll0_sysclk2),  	CLK(NULL,		"pll0_sysclk3",	&pll0_sysclk3),  	CLK(NULL,		"pll0_sysclk4",	&pll0_sysclk4), @@ -359,22 +441,19 @@ static struct clk_lookup da850_clks[] = {  	CLK(NULL,		"pll1_aux",	&pll1_aux_clk),  	CLK(NULL,		"pll1_sysclk2",	&pll1_sysclk2),  	CLK(NULL,		"pll1_sysclk3",	&pll1_sysclk3), -	CLK(NULL,		"pll1_sysclk4",	&pll1_sysclk4), -	CLK(NULL,		"pll1_sysclk5",	&pll1_sysclk5), -	CLK(NULL,		"pll1_sysclk6",	&pll1_sysclk6), -	CLK(NULL,		"pll1_sysclk7",	&pll1_sysclk7),  	CLK("i2c_davinci.1",	NULL,		&i2c0_clk),  	CLK(NULL,		"timer0",	&timerp64_0_clk), -	CLK("watchdog",		NULL,		&timerp64_1_clk), +	CLK("davinci-wdt",	NULL,		&timerp64_1_clk),  	CLK(NULL,		"arm_rom",	&arm_rom_clk),  	CLK(NULL,		"tpcc0",	&tpcc0_clk),  	CLK(NULL,		"tptc0",	&tptc0_clk),  	CLK(NULL,		"tptc1",	&tptc1_clk),  	CLK(NULL,		"tpcc1",	&tpcc1_clk),  	CLK(NULL,		"tptc2",	&tptc2_clk), -	CLK(NULL,		"uart0",	&uart0_clk), -	CLK(NULL,		"uart1",	&uart1_clk), -	CLK(NULL,		"uart2",	&uart2_clk), +	CLK("pruss_uio",	"pruss",	&pruss_clk), +	CLK("serial8250.0",	NULL,		&uart0_clk), +	CLK("serial8250.1",	NULL,		&uart1_clk), +	CLK("serial8250.2",	NULL,		&uart2_clk),  	CLK(NULL,		"aintc",	&aintc_clk),  	CLK(NULL,		"gpio",		&gpio_clk),  	CLK("i2c_davinci.2",	NULL,		&i2c1_clk), @@ -382,11 +461,22 @@ static struct clk_lookup da850_clks[] = {  	CLK(NULL,		"arm",		&arm_clk),  	CLK(NULL,		"rmii",		&rmii_clk),  	CLK("davinci_emac.1",	NULL,		&emac_clk), +	CLK("davinci_mdio.0",	"fck",		&emac_clk),  	CLK("davinci-mcasp.0",	NULL,		&mcasp_clk), -	CLK("da8xx_lcdc.0",	NULL,		&lcdc_clk), -	CLK("davinci_mmc.0",	NULL,		&mmcsd0_clk), -	CLK("davinci_mmc.1",	NULL,		&mmcsd1_clk), +	CLK("da8xx_lcdc.0",	"fck",		&lcdc_clk), +	CLK("da830-mmc.0",	NULL,		&mmcsd0_clk), +	CLK("da830-mmc.1",	NULL,		&mmcsd1_clk),  	CLK(NULL,		"aemif",	&aemif_clk), +	CLK(NULL,		"usb11",	&usb11_clk), +	CLK(NULL,		"usb20",	&usb20_clk), +	CLK("spi_davinci.0",	NULL,		&spi0_clk), +	CLK("spi_davinci.1",	NULL,		&spi1_clk), +	CLK("vpif",		NULL,		&vpif_clk), +	CLK("ahci_da850",		NULL,		&sata_clk), +	CLK("davinci-rproc.0",	NULL,		&dsp_clk), +	CLK("ehrpwm",		"fck",		&ehrpwm_clk), +	CLK("ehrpwm",		"tbclk",	&ehrpwm_tbclk), +	CLK("ecap",		"fck",		&ecap_clk),  	CLK(NULL,		NULL,		NULL),  }; @@ -493,6 +583,13 @@ static const struct mux_config da850_pins[] = {  	MUX_CFG(DA850, MMCSD0_DAT_3,	10,	20,	15,	2,	false)  	MUX_CFG(DA850, MMCSD0_CLK,	10,	0,	15,	2,	false)  	MUX_CFG(DA850, MMCSD0_CMD,	10,	4,	15,	2,	false) +	/* MMC/SD1 function */ +	MUX_CFG(DA850, MMCSD1_DAT_0,	18,	8,	15,	2,	false) +	MUX_CFG(DA850, MMCSD1_DAT_1,	19,	16,	15,	2,	false) +	MUX_CFG(DA850, MMCSD1_DAT_2,	19,	12,	15,	2,	false) +	MUX_CFG(DA850, MMCSD1_DAT_3,	19,	8,	15,	2,	false) +	MUX_CFG(DA850, MMCSD1_CLK,	18,	12,	15,	2,	false) +	MUX_CFG(DA850, MMCSD1_CMD,	18,	16,	15,	2,	false)  	/* EMIF2.5/EMIFA function */  	MUX_CFG(DA850, EMA_D_7,		9,	0,	15,	1,	false)  	MUX_CFG(DA850, EMA_D_6,		9,	4,	15,	1,	false) @@ -543,59 +640,72 @@ static const struct mux_config da850_pins[] = {  	MUX_CFG(DA850, EMA_WAIT_1,	6,	24,	15,	1,	false)  	MUX_CFG(DA850, NEMA_CS_2,	7,	0,	15,	1,	false)  	/* GPIO function */ +	MUX_CFG(DA850, GPIO2_4,		6,	12,	15,	8,	false)  	MUX_CFG(DA850, GPIO2_6,		6,	4,	15,	8,	false)  	MUX_CFG(DA850, GPIO2_8,		5,	28,	15,	8,	false)  	MUX_CFG(DA850, GPIO2_15,	5,	0,	15,	8,	false) +	MUX_CFG(DA850, GPIO3_12,	7,	12,	15,	8,	false) +	MUX_CFG(DA850, GPIO3_13,	7,	8,	15,	8,	false)  	MUX_CFG(DA850, GPIO4_0,		10,	28,	15,	8,	false)  	MUX_CFG(DA850, GPIO4_1,		10,	24,	15,	8,	false) +	MUX_CFG(DA850, GPIO6_9,		13,	24,	15,	8,	false) +	MUX_CFG(DA850, GPIO6_10,	13,	20,	15,	8,	false) +	MUX_CFG(DA850, GPIO6_13,	13,	8,	15,	8,	false)  	MUX_CFG(DA850, RTC_ALARM,	0,	28,	15,	2,	false) +	/* VPIF Capture */ +	MUX_CFG(DA850, VPIF_DIN0,	15,	4,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN1,	15,	0,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN2,	14,	28,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN3,	14,	24,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN4,	14,	20,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN5,	14,	16,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN6,	14,	12,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN7,	14,	8,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN8,	16,	4,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN9,	16,	0,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN10,	15,	28,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN11,	15,	24,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN12,	15,	20,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN13,	15,	16,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN14,	15,	12,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DIN15,	15,	8,	15,	1,	false) +	MUX_CFG(DA850, VPIF_CLKIN0,	14,	0,	15,	1,	false) +	MUX_CFG(DA850, VPIF_CLKIN1,	14,	4,	15,	1,	false) +	MUX_CFG(DA850, VPIF_CLKIN2,	19,	8,	15,	1,	false) +	MUX_CFG(DA850, VPIF_CLKIN3,	19,	16,	15,	1,	false) +	/* VPIF Display */ +	MUX_CFG(DA850, VPIF_DOUT0,	17,	4,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT1,	17,	0,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT2,	16,	28,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT3,	16,	24,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT4,	16,	20,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT5,	16,	16,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT6,	16,	12,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT7,	16,	8,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT8,	18,	4,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT9,	18,	0,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT10,	17,	28,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT11,	17,	24,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT12,	17,	20,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT13,	17,	16,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT14,	17,	12,	15,	1,	false) +	MUX_CFG(DA850, VPIF_DOUT15,	17,	8,	15,	1,	false) +	MUX_CFG(DA850, VPIF_CLKO2,	19,	12,	15,	1,	false) +	MUX_CFG(DA850, VPIF_CLKO3,	19,	20,	15,	1,	false)  #endif  }; -const short da850_uart0_pins[] __initdata = { -	DA850_NUART0_CTS, DA850_NUART0_RTS, DA850_UART0_RXD, DA850_UART0_TXD, -	-1 -}; - -const short da850_uart1_pins[] __initdata = { -	DA850_UART1_RXD, DA850_UART1_TXD, -	-1 -}; - -const short da850_uart2_pins[] __initdata = { -	DA850_UART2_RXD, DA850_UART2_TXD, -	-1 -}; - -const short da850_i2c0_pins[] __initdata = { +const short da850_i2c0_pins[] __initconst = {  	DA850_I2C0_SDA, DA850_I2C0_SCL,  	-1  }; -const short da850_i2c1_pins[] __initdata = { +const short da850_i2c1_pins[] __initconst = {  	DA850_I2C1_SCL, DA850_I2C1_SDA,  	-1  }; -const short da850_cpgmac_pins[] __initdata = { -	DA850_MII_TXEN, DA850_MII_TXCLK, DA850_MII_COL, DA850_MII_TXD_3, -	DA850_MII_TXD_2, DA850_MII_TXD_1, DA850_MII_TXD_0, DA850_MII_RXER, -	DA850_MII_CRS, DA850_MII_RXCLK, DA850_MII_RXDV, DA850_MII_RXD_3, -	DA850_MII_RXD_2, DA850_MII_RXD_1, DA850_MII_RXD_0, DA850_MDIO_CLK, -	DA850_MDIO_D, DA850_RMII_TXD_0, DA850_RMII_TXD_1, DA850_RMII_TXEN, -	DA850_RMII_CRS_DV, DA850_RMII_RXD_0, DA850_RMII_RXD_1, DA850_RMII_RXER, -	DA850_RMII_MHZ_50_CLK, -	-1 -}; - -const short da850_mcasp_pins[] __initdata = { -	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX, -	DA850_AHCLKR, DA850_ACLKR, DA850_AFSR, DA850_AMUTE, -	DA850_AXR_11, DA850_AXR_12, -	-1 -}; - -const short da850_lcdcntl_pins[] __initdata = { +const short da850_lcdcntl_pins[] __initconst = {  	DA850_LCD_D_0, DA850_LCD_D_1, DA850_LCD_D_2, DA850_LCD_D_3,  	DA850_LCD_D_4, DA850_LCD_D_5, DA850_LCD_D_6, DA850_LCD_D_7,  	DA850_LCD_D_8, DA850_LCD_D_9, DA850_LCD_D_10, DA850_LCD_D_11, @@ -604,26 +714,23 @@ const short da850_lcdcntl_pins[] __initdata = {  	-1  }; -const short da850_mmcsd0_pins[] __initdata = { -	DA850_MMCSD0_DAT_0, DA850_MMCSD0_DAT_1, DA850_MMCSD0_DAT_2, -	DA850_MMCSD0_DAT_3, DA850_MMCSD0_CLK, DA850_MMCSD0_CMD, -	DA850_GPIO4_0, DA850_GPIO4_1, +const short da850_vpif_capture_pins[] __initdata = { +	DA850_VPIF_DIN0, DA850_VPIF_DIN1, DA850_VPIF_DIN2, DA850_VPIF_DIN3, +	DA850_VPIF_DIN4, DA850_VPIF_DIN5, DA850_VPIF_DIN6, DA850_VPIF_DIN7, +	DA850_VPIF_DIN8, DA850_VPIF_DIN9, DA850_VPIF_DIN10, DA850_VPIF_DIN11, +	DA850_VPIF_DIN12, DA850_VPIF_DIN13, DA850_VPIF_DIN14, DA850_VPIF_DIN15, +	DA850_VPIF_CLKIN0, DA850_VPIF_CLKIN1, DA850_VPIF_CLKIN2, +	DA850_VPIF_CLKIN3,  	-1  }; -const short da850_emif25_pins[] __initdata = { -	DA850_EMA_BA_1, DA850_EMA_CLK, DA850_EMA_WAIT_1, DA850_NEMA_CS_2, -	DA850_NEMA_CS_3, DA850_NEMA_CS_4, DA850_NEMA_WE, DA850_NEMA_OE, -	DA850_EMA_D_0, DA850_EMA_D_1, DA850_EMA_D_2, DA850_EMA_D_3, -	DA850_EMA_D_4, DA850_EMA_D_5, DA850_EMA_D_6, DA850_EMA_D_7, -	DA850_EMA_D_8, DA850_EMA_D_9, DA850_EMA_D_10, DA850_EMA_D_11, -	DA850_EMA_D_12, DA850_EMA_D_13, DA850_EMA_D_14, DA850_EMA_D_15, -	DA850_EMA_A_0, DA850_EMA_A_1, DA850_EMA_A_2, DA850_EMA_A_3, -	DA850_EMA_A_4, DA850_EMA_A_5, DA850_EMA_A_6, DA850_EMA_A_7, -	DA850_EMA_A_8, DA850_EMA_A_9, DA850_EMA_A_10, DA850_EMA_A_11, -	DA850_EMA_A_12, DA850_EMA_A_13, DA850_EMA_A_14, DA850_EMA_A_15, -	DA850_EMA_A_16, DA850_EMA_A_17, DA850_EMA_A_18, DA850_EMA_A_19, -	DA850_EMA_A_20, DA850_EMA_A_21, DA850_EMA_A_22, DA850_EMA_A_23, +const short da850_vpif_display_pins[] __initdata = { +	DA850_VPIF_DOUT0, DA850_VPIF_DOUT1, DA850_VPIF_DOUT2, DA850_VPIF_DOUT3, +	DA850_VPIF_DOUT4, DA850_VPIF_DOUT5, DA850_VPIF_DOUT6, DA850_VPIF_DOUT7, +	DA850_VPIF_DOUT8, DA850_VPIF_DOUT9, DA850_VPIF_DOUT10, +	DA850_VPIF_DOUT11, DA850_VPIF_DOUT12, DA850_VPIF_DOUT13, +	DA850_VPIF_DOUT14, DA850_VPIF_DOUT15, DA850_VPIF_CLKO2, +	DA850_VPIF_CLKO3,  	-1  }; @@ -745,12 +852,6 @@ static struct map_desc da850_io_desc[] = {  		.length		= DA8XX_CP_INTC_SIZE,  		.type		= MT_DEVICE  	}, -	{ -		.virtual	= SRAM_VIRT, -		.pfn		= __phys_to_pfn(DA8XX_ARM_RAM_BASE), -		.length		= SZ_8K, -		.type		= MT_DEVICE -	},  };  static u32 da850_psc_bases[] = { DA8XX_PSC0_BASE, DA8XX_PSC1_BASE }; @@ -764,6 +865,13 @@ static struct davinci_id da850_ids[] = {  		.cpu_id		= DAVINCI_CPU_ID_DA850,  		.name		= "da850/omap-l138",  	}, +	{ +		.variant	= 0x1, +		.part_no	= 0xb7d1, +		.manufacturer	= 0x017,	/* 0x02f >> 1 */ +		.cpu_id		= DAVINCI_CPU_ID_DA850, +		.name		= "da850/omap-l138/am18x", +	},  };  static struct davinci_timer_instance da850_timer_instance[4] = { @@ -830,8 +938,7 @@ static void da850_set_async3_src(int pllnum)   * According to the TRM, minimum PLLM results in maximum power savings.   * The OPP definitions below should keep the PLLM as low as possible.   * - * The output of the PLLM must be between 400 to 600 MHz. - * This rules out prediv of anything but divide-by-one for 24Mhz OSC input. + * The output of the PLLM must be between 300 to 600 MHz.   */  struct da850_opp {  	unsigned int	freq;	/* in KHz */ @@ -842,6 +949,33 @@ struct da850_opp {  	unsigned int	cvdd_max; /* in uV */  }; +static const struct da850_opp da850_opp_456 = { +	.freq		= 456000, +	.prediv		= 1, +	.mult		= 19, +	.postdiv	= 1, +	.cvdd_min	= 1300000, +	.cvdd_max	= 1350000, +}; + +static const struct da850_opp da850_opp_408 = { +	.freq		= 408000, +	.prediv		= 1, +	.mult		= 17, +	.postdiv	= 1, +	.cvdd_min	= 1300000, +	.cvdd_max	= 1350000, +}; + +static const struct da850_opp da850_opp_372 = { +	.freq		= 372000, +	.prediv		= 2, +	.mult		= 31, +	.postdiv	= 1, +	.cvdd_min	= 1200000, +	.cvdd_max	= 1320000, +}; +  static const struct da850_opp da850_opp_300 = {  	.freq		= 300000,  	.prediv		= 1, @@ -871,21 +1005,37 @@ static const struct da850_opp da850_opp_96 = {  #define OPP(freq) 		\  	{				\ -		.index = (unsigned int) &da850_opp_##freq,	\ +		.driver_data = (unsigned int) &da850_opp_##freq,	\  		.frequency = freq * 1000, \  	}  static struct cpufreq_frequency_table da850_freq_table[] = { +	OPP(456), +	OPP(408), +	OPP(372),  	OPP(300),  	OPP(200),  	OPP(96),  	{ -		.index		= 0, +		.driver_data		= 0,  		.frequency	= CPUFREQ_TABLE_END,  	},  };  #ifdef CONFIG_REGULATOR +static int da850_set_voltage(unsigned int index); +static int da850_regulator_init(void); +#endif + +static struct davinci_cpufreq_config cpufreq_info = { +	.freq_table = da850_freq_table, +#ifdef CONFIG_REGULATOR +	.init = da850_regulator_init, +	.set_voltage = da850_set_voltage, +#endif +}; + +#ifdef CONFIG_REGULATOR  static struct regulator *cvdd;  static int da850_set_voltage(unsigned int index) @@ -895,7 +1045,7 @@ static int da850_set_voltage(unsigned int index)  	if (!cvdd)  		return -ENODEV; -	opp = (struct da850_opp *) da850_freq_table[index].index; +	opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data;  	return regulator_set_voltage(cvdd, opp->cvdd_min, opp->cvdd_max);  } @@ -912,14 +1062,6 @@ static int da850_regulator_init(void)  }  #endif -static struct davinci_cpufreq_config cpufreq_info = { -	.freq_table = &da850_freq_table[0], -#ifdef CONFIG_REGULATOR -	.init = da850_regulator_init, -	.set_voltage = da850_set_voltage, -#endif -}; -  static struct platform_device da850_cpufreq_device = {  	.name			= "cpufreq-davinci",  	.dev = { @@ -928,31 +1070,43 @@ static struct platform_device da850_cpufreq_device = {  	.id = -1,  }; -int __init da850_register_cpufreq(char *async_clk) +unsigned int da850_max_speed = 300000; + +int da850_register_cpufreq(char *async_clk)  { +	int i; +  	/* cpufreq driver can help keep an "async" clock constant */  	if (async_clk)  		clk_add_alias("async", da850_cpufreq_device.name,  							async_clk, NULL); +	for (i = 0; i < ARRAY_SIZE(da850_freq_table); i++) { +		if (da850_freq_table[i].frequency <= da850_max_speed) { +			cpufreq_info.freq_table = &da850_freq_table[i]; +			break; +		} +	}  	return platform_device_register(&da850_cpufreq_device);  }  static int da850_round_armrate(struct clk *clk, unsigned long rate)  { -	int i, ret = 0, diff; +	int ret = 0, diff;  	unsigned int best = (unsigned int) -1; +	struct cpufreq_frequency_table *table = cpufreq_info.freq_table; +	struct cpufreq_frequency_table *pos;  	rate /= 1000; /* convert to kHz */ -	for (i = 0; da850_freq_table[i].frequency != CPUFREQ_TABLE_END; i++) { -		diff = da850_freq_table[i].frequency - rate; +	cpufreq_for_each_entry(pos, table) { +		diff = pos->frequency - rate;  		if (diff < 0)  			diff = -diff;  		if (diff < best) {  			best = diff; -			ret = da850_freq_table[i].frequency; +			ret = pos->frequency;  		}  	} @@ -973,7 +1127,7 @@ static int da850_set_pll0rate(struct clk *clk, unsigned long index)  	struct pll_data *pll = clk->pll_data;  	int ret; -	opp = (struct da850_opp *) da850_freq_table[index].index; +	opp = (struct da850_opp *) cpufreq_info.freq_table[index].driver_data;  	prediv = opp->prediv;  	mult = opp->mult;  	postdiv = opp->postdiv; @@ -1006,7 +1160,7 @@ static int da850_round_armrate(struct clk *clk, unsigned long rate)  }  #endif -int da850_register_pm(struct platform_device *pdev) +int __init da850_register_pm(struct platform_device *pdev)  {  	int ret;  	struct davinci_pm_config *pdata = pdev->dev.platform_data; @@ -1023,7 +1177,7 @@ int da850_register_pm(struct platform_device *pdev)  	if (!pdata->cpupll_reg_base)  		return -ENOMEM; -	pdata->ddrpll_reg_base = ioremap(DA8XX_PLL1_BASE, SZ_4K); +	pdata->ddrpll_reg_base = ioremap(DA850_PLL1_BASE, SZ_4K);  	if (!pdata->ddrpll_reg_base) {  		ret = -ENOMEM;  		goto no_ddrpll_mem; @@ -1044,6 +1198,99 @@ no_ddrpll_mem:  	return ret;  } +/* VPIF resource, platform data */ +static u64 da850_vpif_dma_mask = DMA_BIT_MASK(32); + +static struct resource da850_vpif_resource[] = { +	{ +		.start = DA8XX_VPIF_BASE, +		.end   = DA8XX_VPIF_BASE + 0xfff, +		.flags = IORESOURCE_MEM, +	} +}; + +static struct platform_device da850_vpif_dev = { +	.name		= "vpif", +	.id		= -1, +	.dev		= { +		.dma_mask		= &da850_vpif_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +	.resource	= da850_vpif_resource, +	.num_resources	= ARRAY_SIZE(da850_vpif_resource), +}; + +static struct resource da850_vpif_display_resource[] = { +	{ +		.start = IRQ_DA850_VPIFINT, +		.end   = IRQ_DA850_VPIFINT, +		.flags = IORESOURCE_IRQ, +	}, +}; + +static struct platform_device da850_vpif_display_dev = { +	.name		= "vpif_display", +	.id		= -1, +	.dev		= { +		.dma_mask		= &da850_vpif_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +	.resource       = da850_vpif_display_resource, +	.num_resources  = ARRAY_SIZE(da850_vpif_display_resource), +}; + +static struct resource da850_vpif_capture_resource[] = { +	{ +		.start = IRQ_DA850_VPIFINT, +		.end   = IRQ_DA850_VPIFINT, +		.flags = IORESOURCE_IRQ, +	}, +	{ +		.start = IRQ_DA850_VPIFINT, +		.end   = IRQ_DA850_VPIFINT, +		.flags = IORESOURCE_IRQ, +	}, +}; + +static struct platform_device da850_vpif_capture_dev = { +	.name		= "vpif_capture", +	.id		= -1, +	.dev		= { +		.dma_mask		= &da850_vpif_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +	.resource       = da850_vpif_capture_resource, +	.num_resources  = ARRAY_SIZE(da850_vpif_capture_resource), +}; + +int __init da850_register_vpif(void) +{ +	return platform_device_register(&da850_vpif_dev); +} + +int __init da850_register_vpif_display(struct vpif_display_config +						*display_config) +{ +	da850_vpif_display_dev.dev.platform_data = display_config; +	return platform_device_register(&da850_vpif_display_dev); +} + +int __init da850_register_vpif_capture(struct vpif_capture_config +							*capture_config) +{ +	da850_vpif_capture_dev.dev.platform_data = capture_config; +	return platform_device_register(&da850_vpif_capture_dev); +} + +static struct davinci_gpio_platform_data da850_gpio_platform_data = { +	.ngpio = 144, +}; + +int __init da850_register_gpio(void) +{ +	return da8xx_register_gpio(&da850_gpio_platform_data); +} +  static struct davinci_soc_info davinci_soc_info_da850 = {  	.io_desc		= da850_io_desc,  	.io_desc_num		= ARRAY_SIZE(da850_io_desc), @@ -1061,15 +1308,9 @@ static struct davinci_soc_info davinci_soc_info_da850 = {  	.intc_irq_prios		= da850_default_priorities,  	.intc_irq_num		= DA850_N_CP_INTC_IRQ,  	.timer_info		= &da850_timer_info, -	.gpio_type		= GPIO_TYPE_DAVINCI, -	.gpio_base		= DA8XX_GPIO_BASE, -	.gpio_num		= 144, -	.gpio_irq		= IRQ_DA8XX_GPIO0, -	.serial_dev		= &da8xx_serial_device,  	.emac_pdata		= &da8xx_emac_pdata, -	.sram_dma		= DA8XX_ARM_RAM_BASE, -	.sram_len		= SZ_8K, -	.reset_device		= &da8xx_wdt_device, +	.sram_dma		= DA8XX_SHARED_RAM_BASE, +	.sram_len		= SZ_128K,  };  void __init da850_init(void) @@ -1091,7 +1332,7 @@ void __init da850_init(void)  	 * This helps keeping the peripherals on this domain insulated  	 * from CPU frequency changes caused by DVFS. The firmware sets  	 * both PLL0 and PLL1 to the same frequency so, there should not -	 * be any noticible change even in non-DVFS use cases. +	 * be any noticeable change even in non-DVFS use cases.  	 */  	da850_set_async3_src(1); diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c new file mode 100644 index 00000000000..ed1928740b5 --- /dev/null +++ b/arch/arm/mach-davinci/da8xx-dt.c @@ -0,0 +1,78 @@ +/* + * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ + * + * Modified from mach-omap/omap2/board-generic.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/io.h> +#include <linux/of_irq.h> +#include <linux/of_platform.h> +#include <linux/irqdomain.h> + +#include <asm/mach/arch.h> + +#include <mach/common.h> +#include <mach/cp_intc.h> +#include <mach/da8xx.h> + +#define DA8XX_NUM_UARTS	3 + +static struct of_device_id da8xx_irq_match[] __initdata = { +	{ .compatible = "ti,cp-intc", .data = cp_intc_of_init, }, +	{ } +}; + +static void __init da8xx_init_irq(void) +{ +	of_irq_init(da8xx_irq_match); +} + +static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = { +	OF_DEV_AUXDATA("ti,davinci-i2c", 0x01c22000, "i2c_davinci.1", NULL), +	OF_DEV_AUXDATA("ti,davinci-wdt", 0x01c21000, "davinci-wdt", NULL), +	OF_DEV_AUXDATA("ti,da830-mmc", 0x01c40000, "da830-mmc.0", NULL), +	OF_DEV_AUXDATA("ti,da850-ehrpwm", 0x01f00000, "ehrpwm", NULL), +	OF_DEV_AUXDATA("ti,da850-ehrpwm", 0x01f02000, "ehrpwm", NULL), +	OF_DEV_AUXDATA("ti,da850-ecap", 0x01f06000, "ecap", NULL), +	OF_DEV_AUXDATA("ti,da850-ecap", 0x01f07000, "ecap", NULL), +	OF_DEV_AUXDATA("ti,da850-ecap", 0x01f08000, "ecap", NULL), +	OF_DEV_AUXDATA("ti,da830-spi", 0x01f0e000, "spi_davinci.1", NULL), +	OF_DEV_AUXDATA("ns16550a", 0x01c42000, "serial8250.0", NULL), +	OF_DEV_AUXDATA("ns16550a", 0x01d0c000, "serial8250.1", NULL), +	OF_DEV_AUXDATA("ns16550a", 0x01d0d000, "serial8250.2", NULL), +	OF_DEV_AUXDATA("ti,davinci_mdio", 0x01e24000, "davinci_mdio.0", NULL), +	OF_DEV_AUXDATA("ti,davinci-dm6467-emac", 0x01e20000, "davinci_emac.1", +		       NULL), +	{} +}; + +#ifdef CONFIG_ARCH_DAVINCI_DA850 + +static void __init da850_init_machine(void) +{ +	of_platform_populate(NULL, of_default_bus_match_table, +			     da850_auxdata_lookup, NULL); + +} + +static const char *da850_boards_compat[] __initdata = { +	"enbw,cmc", +	"ti,da850-evm", +	"ti,da850", +	NULL, +}; + +DT_MACHINE_START(DA850_DT, "Generic DA850/OMAP-L138/AM18x") +	.map_io		= da850_init, +	.init_irq	= da8xx_init_irq, +	.init_time	= davinci_timer_init, +	.init_machine	= da850_init_machine, +	.dt_compat	= da850_boards_compat, +	.init_late	= davinci_init_late, +	.restart	= da8xx_restart, +MACHINE_END + +#endif diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h new file mode 100644 index 00000000000..4ffc37accce --- /dev/null +++ b/arch/arm/mach-davinci/davinci.h @@ -0,0 +1,123 @@ +/* + * This file contains the processor specific definitions + * of the TI DM644x, DM355, DM365, and DM646x. + * + * Copyright (C) 2011 Texas Instruments Incorporated + * Copyright (c) 2007 Deep Root Systems, LLC + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation version 2. + * + * This program is distributed "as is" WITHOUT ANY WARRANTY of any + * kind, whether express or implied; without even the implied warranty + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + * GNU General Public License for more details. + */ +#ifndef __DAVINCI_H +#define __DAVINCI_H + +#include <linux/clk.h> +#include <linux/videodev2.h> +#include <linux/davinci_emac.h> +#include <linux/platform_device.h> +#include <linux/spi/spi.h> +#include <linux/platform_data/davinci_asp.h> +#include <linux/platform_data/edma.h> +#include <linux/platform_data/keyscan-davinci.h> +#include <mach/hardware.h> + +#include <media/davinci/vpfe_capture.h> +#include <media/davinci/vpif_types.h> +#include <media/davinci/vpss.h> +#include <media/davinci/vpbe_types.h> +#include <media/davinci/vpbe_venc.h> +#include <media/davinci/vpbe.h> +#include <media/davinci/vpbe_osd.h> + +#define DAVINCI_SYSTEM_MODULE_BASE	0x01c40000 +#define SYSMOD_VDAC_CONFIG		0x2c +#define SYSMOD_VIDCLKCTL		0x38 +#define SYSMOD_VPSS_CLKCTL		0x44 +#define SYSMOD_VDD3P3VPWDN		0x48 +#define SYSMOD_VSCLKDIS			0x6c +#define SYSMOD_PUPDCTL1			0x7c + +/* VPSS CLKCTL bit definitions */ +#define VPSS_MUXSEL_EXTCLK_ENABLE	BIT(1) +#define VPSS_VENCCLKEN_ENABLE		BIT(3) +#define VPSS_DACCLKEN_ENABLE		BIT(4) +#define VPSS_PLLC2SYSCLK5_ENABLE	BIT(5) + +extern void __iomem *davinci_sysmod_base; +#define DAVINCI_SYSMOD_VIRT(x)	(davinci_sysmod_base + (x)) +void davinci_map_sysmod(void); + +#define DAVINCI_GPIO_BASE 0x01C67000 +int davinci_gpio_register(struct resource *res, int size, void *pdata); + +/* DM355 base addresses */ +#define DM355_ASYNC_EMIF_CONTROL_BASE	0x01e10000 +#define DM355_ASYNC_EMIF_DATA_CE0_BASE	0x02000000 + +#define ASP1_TX_EVT_EN	1 +#define ASP1_RX_EVT_EN	2 + +/* DM365 base addresses */ +#define DM365_ASYNC_EMIF_CONTROL_BASE	0x01d10000 +#define DM365_ASYNC_EMIF_DATA_CE0_BASE	0x02000000 +#define DM365_ASYNC_EMIF_DATA_CE1_BASE	0x04000000 + +/* DM644x base addresses */ +#define DM644X_ASYNC_EMIF_CONTROL_BASE	0x01e00000 +#define DM644X_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 +#define DM644X_ASYNC_EMIF_DATA_CE1_BASE 0x04000000 +#define DM644X_ASYNC_EMIF_DATA_CE2_BASE 0x06000000 +#define DM644X_ASYNC_EMIF_DATA_CE3_BASE 0x08000000 + +/* DM646x base addresses */ +#define DM646X_ASYNC_EMIF_CONTROL_BASE	0x20008000 +#define DM646X_ASYNC_EMIF_CS2_SPACE_BASE 0x42000000 + +int davinci_init_wdt(void); + +/* DM355 function declarations */ +void dm355_init(void); +void dm355_init_spi0(unsigned chipselect_mask, +		const struct spi_board_info *info, unsigned len); +void dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata); +int dm355_init_video(struct vpfe_config *, struct vpbe_config *); +int dm355_gpio_register(void); + +/* DM365 function declarations */ +void dm365_init(void); +void dm365_init_asp(struct snd_platform_data *pdata); +void dm365_init_vc(struct snd_platform_data *pdata); +void dm365_init_ks(struct davinci_ks_platform_data *pdata); +void dm365_init_rtc(void); +void dm365_init_spi0(unsigned chipselect_mask, +			const struct spi_board_info *info, unsigned len); +int dm365_init_video(struct vpfe_config *, struct vpbe_config *); +int dm365_gpio_register(void); + +/* DM644x function declarations */ +void dm644x_init(void); +void dm644x_init_asp(struct snd_platform_data *pdata); +int dm644x_init_video(struct vpfe_config *, struct vpbe_config *); +int dm644x_gpio_register(void); + +/* DM646x function declarations */ +void dm646x_init(void); +void dm646x_init_mcasp0(struct snd_platform_data *pdata); +void dm646x_init_mcasp1(struct snd_platform_data *pdata); +int dm646x_init_edma(struct edma_rsv_info *rsv); +void dm646x_video_init(void); +void dm646x_setup_vpif(struct vpif_display_config *, +		       struct vpif_capture_config *); +int dm646x_gpio_register(void); + +extern struct platform_device dm365_serial_device[]; +extern struct platform_device dm355_serial_device[]; +extern struct platform_device dm644x_serial_device[]; +extern struct platform_device dm646x_serial_device[]; +#endif /*__DAVINCI_H */ diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 9eec63070e0..b85b781b05f 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -12,42 +12,63 @@   */  #include <linux/init.h>  #include <linux/platform_device.h> -#include <linux/dma-mapping.h> +#include <linux/dma-contiguous.h>  #include <linux/serial_8250.h> +#include <linux/ahci_platform.h> +#include <linux/clk.h> +#include <linux/reboot.h>  #include <mach/cputype.h>  #include <mach/common.h>  #include <mach/time.h>  #include <mach/da8xx.h>  #include <mach/cpuidle.h> +#include <mach/sram.h>  #include "clock.h" +#include "asp.h"  #define DA8XX_TPCC_BASE			0x01c00000 -#define DA850_MMCSD1_BASE		0x01e1b000 -#define DA850_TPCC1_BASE		0x01e30000  #define DA8XX_TPTC0_BASE		0x01c08000  #define DA8XX_TPTC1_BASE		0x01c08400 -#define DA850_TPTC2_BASE		0x01e38000  #define DA8XX_WDOG_BASE			0x01c21000 /* DA8XX_TIMER64P1_BASE */  #define DA8XX_I2C0_BASE			0x01c22000 -#define DA8XX_RTC_BASE			0x01C23000 +#define DA8XX_RTC_BASE			0x01c23000 +#define DA8XX_PRUSS_MEM_BASE		0x01c30000 +#define DA8XX_MMCSD0_BASE		0x01c40000 +#define DA8XX_SPI0_BASE			0x01c41000 +#define DA830_SPI1_BASE			0x01e12000 +#define DA8XX_LCD_CNTRL_BASE		0x01e13000 +#define DA850_SATA_BASE			0x01e18000 +#define DA850_MMCSD1_BASE		0x01e1b000  #define DA8XX_EMAC_CPPI_PORT_BASE	0x01e20000  #define DA8XX_EMAC_CPGMACSS_BASE	0x01e22000  #define DA8XX_EMAC_CPGMAC_BASE		0x01e23000  #define DA8XX_EMAC_MDIO_BASE		0x01e24000 -#define DA8XX_GPIO_BASE			0x01e26000  #define DA8XX_I2C1_BASE			0x01e28000 +#define DA850_TPCC1_BASE		0x01e30000 +#define DA850_TPTC2_BASE		0x01e38000 +#define DA850_SPI1_BASE			0x01f0e000 +#define DA8XX_DDR2_CTL_BASE		0xb0000000  #define DA8XX_EMAC_CTRL_REG_OFFSET	0x3000  #define DA8XX_EMAC_MOD_REG_OFFSET	0x2000  #define DA8XX_EMAC_RAM_OFFSET		0x0000  #define DA8XX_EMAC_CTRL_RAM_SIZE	SZ_8K +#define DA8XX_DMA_SPI0_RX	EDMA_CTLR_CHAN(0, 14) +#define DA8XX_DMA_SPI0_TX	EDMA_CTLR_CHAN(0, 15) +#define DA8XX_DMA_MMCSD0_RX	EDMA_CTLR_CHAN(0, 16) +#define DA8XX_DMA_MMCSD0_TX	EDMA_CTLR_CHAN(0, 17) +#define DA8XX_DMA_SPI1_RX	EDMA_CTLR_CHAN(0, 18) +#define DA8XX_DMA_SPI1_TX	EDMA_CTLR_CHAN(0, 19) +#define DA850_DMA_MMCSD1_RX	EDMA_CTLR_CHAN(1, 28) +#define DA850_DMA_MMCSD1_TX	EDMA_CTLR_CHAN(1, 29) +  void __iomem *da8xx_syscfg0_base;  void __iomem *da8xx_syscfg1_base; -static struct plat_serial8250_port da8xx_serial_pdata[] = { +static struct plat_serial8250_port da8xx_serial0_pdata[] = {  	{  		.mapbase	= DA8XX_UART0_BASE,  		.irq		= IRQ_DA8XX_UARTINT0, @@ -57,6 +78,11 @@ static struct plat_serial8250_port da8xx_serial_pdata[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port da8xx_serial1_pdata[] = { +	{  		.mapbase	= DA8XX_UART1_BASE,  		.irq		= IRQ_DA8XX_UARTINT1,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -65,6 +91,11 @@ static struct plat_serial8250_port da8xx_serial_pdata[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port da8xx_serial2_pdata[] = { +	{  		.mapbase	= DA8XX_UART2_BASE,  		.irq		= IRQ_DA8XX_UARTINT2,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -74,51 +105,51 @@ static struct plat_serial8250_port da8xx_serial_pdata[] = {  	},  	{  		.flags	= 0, -	}, +	}  }; -struct platform_device da8xx_serial_device = { -	.name	= "serial8250", -	.id	= PLAT8250_DEV_PLATFORM, -	.dev	= { -		.platform_data	= da8xx_serial_pdata, +struct platform_device da8xx_serial_device[] = { +	{ +		.name	= "serial8250", +		.id	= PLAT8250_DEV_PLATFORM, +		.dev	= { +			.platform_data	= da8xx_serial0_pdata, +		}  	}, +	{ +		.name	= "serial8250", +		.id	= PLAT8250_DEV_PLATFORM1, +		.dev	= { +			.platform_data	= da8xx_serial1_pdata, +		} +	}, +	{ +		.name	= "serial8250", +		.id	= PLAT8250_DEV_PLATFORM2, +		.dev	= { +			.platform_data	= da8xx_serial2_pdata, +		} +	}, +	{ +	}  }; -static const s8 da8xx_queue_tc_mapping[][2] = { -	/* {event queue no, TC no} */ -	{0, 0}, -	{1, 1}, -	{-1, -1} -}; - -static const s8 da8xx_queue_priority_mapping[][2] = { +static s8 da8xx_queue_priority_mapping[][2] = {  	/* {event queue no, Priority} */  	{0, 3},  	{1, 7},  	{-1, -1}  }; -static const s8 da850_queue_tc_mapping[][2] = { -	/* {event queue no, TC no} */ -	{0, 0}, -	{-1, -1} -}; - -static const s8 da850_queue_priority_mapping[][2] = { +static s8 da850_queue_priority_mapping[][2] = {  	/* {event queue no, Priority} */  	{0, 3},  	{-1, -1}  };  static struct edma_soc_info da830_edma_cc0_info = { -	.n_channel		= 32, -	.n_region		= 4, -	.n_slot			= 128, -	.n_tc			= 2, -	.n_cc			= 1, -	.queue_tc_mapping	= da8xx_queue_tc_mapping,  	.queue_priority_mapping	= da8xx_queue_priority_mapping, +	.default_queue		= EVENTQ_1,  };  static struct edma_soc_info *da830_edma_info[EDMA_MAX_CC] = { @@ -127,22 +158,12 @@ static struct edma_soc_info *da830_edma_info[EDMA_MAX_CC] = {  static struct edma_soc_info da850_edma_cc_info[] = {  	{ -		.n_channel		= 32, -		.n_region		= 4, -		.n_slot			= 128, -		.n_tc			= 2, -		.n_cc			= 1, -		.queue_tc_mapping	= da8xx_queue_tc_mapping,  		.queue_priority_mapping	= da8xx_queue_priority_mapping, +		.default_queue		= EVENTQ_1,  	},  	{ -		.n_channel		= 32, -		.n_region		= 4, -		.n_slot			= 128, -		.n_tc			= 1, -		.n_cc			= 1, -		.queue_tc_mapping	= da850_queue_tc_mapping,  		.queue_priority_mapping	= da850_queue_priority_mapping, +		.default_queue		= EVENTQ_0,  	},  }; @@ -336,13 +357,26 @@ static struct resource da8xx_watchdog_resources[] = {  	},  }; -struct platform_device da8xx_wdt_device = { -	.name		= "watchdog", +static struct platform_device da8xx_wdt_device = { +	.name		= "davinci-wdt",  	.id		= -1,  	.num_resources	= ARRAY_SIZE(da8xx_watchdog_resources),  	.resource	= da8xx_watchdog_resources,  }; +void da8xx_restart(enum reboot_mode mode, const char *cmd) +{ +	struct device *dev; + +	dev = bus_find_device_by_name(&platform_bus_type, NULL, "davinci-wdt"); +	if (!dev) { +		pr_err("%s: failed to find watchdog device\n", __func__); +		return; +	} + +	davinci_watchdog_reset(to_platform_device(dev)); +} +  int __init da8xx_register_watchdog(void)  {  	return platform_device_register(&da8xx_wdt_device); @@ -416,17 +450,13 @@ int __init da8xx_register_emac(void)  	ret = platform_device_register(&da8xx_mdio_device);  	if (ret < 0)  		return ret; -	ret = platform_device_register(&da8xx_emac_device); -	if (ret < 0) -		return ret; -	ret = clk_add_alias(NULL, dev_name(&da8xx_mdio_device.dev), -			    NULL, &da8xx_emac_device.dev); -	return ret; + +	return platform_device_register(&da8xx_emac_device);  }  static struct resource da830_mcasp1_resources[] = {  	{ -		.name	= "mcasp1", +		.name	= "mpu",  		.start	= DAVINCI_DA830_MCASP1_REG_BASE,  		.end	= DAVINCI_DA830_MCASP1_REG_BASE + (SZ_1K * 12) - 1,  		.flags	= IORESOURCE_MEM, @@ -454,7 +484,7 @@ static struct platform_device da830_mcasp1_device = {  static struct resource da850_mcasp_resources[] = {  	{ -		.name	= "mcasp", +		.name	= "mpu",  		.start	= DAVINCI_DA8XX_MCASP0_REG_BASE,  		.end	= DAVINCI_DA8XX_MCASP0_REG_BASE + (SZ_1K * 12) - 1,  		.flags	= IORESOURCE_MEM, @@ -492,28 +522,78 @@ void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)  	}  } -static const struct display_panel disp_panel = { -	QVGA, -	16, -	16, -	COLOR_ACTIVE, +static struct resource da8xx_pruss_resources[] = { +	{ +		.start	= DA8XX_PRUSS_MEM_BASE, +		.end	= DA8XX_PRUSS_MEM_BASE + 0xFFFF, +		.flags	= IORESOURCE_MEM, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT0, +		.end	= IRQ_DA8XX_EVTOUT0, +		.flags	= IORESOURCE_IRQ, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT1, +		.end	= IRQ_DA8XX_EVTOUT1, +		.flags	= IORESOURCE_IRQ, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT2, +		.end	= IRQ_DA8XX_EVTOUT2, +		.flags	= IORESOURCE_IRQ, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT3, +		.end	= IRQ_DA8XX_EVTOUT3, +		.flags	= IORESOURCE_IRQ, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT4, +		.end	= IRQ_DA8XX_EVTOUT4, +		.flags	= IORESOURCE_IRQ, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT5, +		.end	= IRQ_DA8XX_EVTOUT5, +		.flags	= IORESOURCE_IRQ, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT6, +		.end	= IRQ_DA8XX_EVTOUT6, +		.flags	= IORESOURCE_IRQ, +	}, +	{ +		.start	= IRQ_DA8XX_EVTOUT7, +		.end	= IRQ_DA8XX_EVTOUT7, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct uio_pruss_pdata da8xx_uio_pruss_pdata = { +	.pintc_base	= 0x4000, +}; + +static struct platform_device da8xx_uio_pruss_dev = { +	.name		= "pruss_uio", +	.id		= -1, +	.num_resources	= ARRAY_SIZE(da8xx_pruss_resources), +	.resource	= da8xx_pruss_resources, +	.dev		= { +		.coherent_dma_mask	= DMA_BIT_MASK(32), +		.platform_data		= &da8xx_uio_pruss_pdata, +	}  }; +int __init da8xx_register_uio_pruss(void) +{ +	da8xx_uio_pruss_pdata.sram_pool = sram_get_gen_pool(); +	return platform_device_register(&da8xx_uio_pruss_dev); +} +  static struct lcd_ctrl_config lcd_cfg = { -	&disp_panel, -	.ac_bias		= 255, -	.ac_bias_intrpt		= 0, -	.dma_burst_sz		= 16, +	.panel_shade		= COLOR_ACTIVE,  	.bpp			= 16, -	.fdd			= 255, -	.tft_alt_mode		= 0, -	.stn_565_mode		= 0, -	.mono_8bit_mode		= 0, -	.invert_line_clock	= 1, -	.invert_frm_clock	= 1, -	.sync_edge		= 0, -	.sync_ctrl		= 1, -	.raster_order		= 0,  };  struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata = { @@ -554,6 +634,32 @@ int __init da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata)  	return platform_device_register(&da8xx_lcdc_device);  } +static struct resource da8xx_gpio_resources[] = { +	{ /* registers */ +		.start	= DA8XX_GPIO_BASE, +		.end	= DA8XX_GPIO_BASE + SZ_4K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	{ /* interrupt */ +		.start	= IRQ_DA8XX_GPIO0, +		.end	= IRQ_DA8XX_GPIO8, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device da8xx_gpio_device = { +	.name		= "davinci_gpio", +	.id		= -1, +	.num_resources	= ARRAY_SIZE(da8xx_gpio_resources), +	.resource	= da8xx_gpio_resources, +}; + +int __init da8xx_register_gpio(void *pdata) +{ +	da8xx_gpio_device.dev.platform_data = pdata; +	return platform_device_register(&da8xx_gpio_device); +} +  static struct resource da8xx_mmcsd0_resources[] = {  	{		/* registers */  		.start	= DA8XX_MMCSD0_BASE, @@ -566,19 +672,19 @@ static struct resource da8xx_mmcsd0_resources[] = {  		.flags	= IORESOURCE_IRQ,  	},  	{		/* DMA RX */ -		.start	= EDMA_CTLR_CHAN(0, 16), -		.end	= EDMA_CTLR_CHAN(0, 16), +		.start	= DA8XX_DMA_MMCSD0_RX, +		.end	= DA8XX_DMA_MMCSD0_RX,  		.flags	= IORESOURCE_DMA,  	},  	{		/* DMA TX */ -		.start	= EDMA_CTLR_CHAN(0, 17), -		.end	= EDMA_CTLR_CHAN(0, 17), +		.start	= DA8XX_DMA_MMCSD0_TX, +		.end	= DA8XX_DMA_MMCSD0_TX,  		.flags	= IORESOURCE_DMA,  	},  };  static struct platform_device da8xx_mmcsd0_device = { -	.name		= "davinci_mmc", +	.name		= "da830-mmc",  	.id		= 0,  	.num_resources	= ARRAY_SIZE(da8xx_mmcsd0_resources),  	.resource	= da8xx_mmcsd0_resources, @@ -603,19 +709,19 @@ static struct resource da850_mmcsd1_resources[] = {  		.flags	= IORESOURCE_IRQ,  	},  	{		/* DMA RX */ -		.start	= EDMA_CTLR_CHAN(1, 28), -		.end	= EDMA_CTLR_CHAN(1, 28), +		.start	= DA850_DMA_MMCSD1_RX, +		.end	= DA850_DMA_MMCSD1_RX,  		.flags	= IORESOURCE_DMA,  	},  	{		/* DMA TX */ -		.start	= EDMA_CTLR_CHAN(1, 29), -		.end	= EDMA_CTLR_CHAN(1, 29), +		.start	= DA850_DMA_MMCSD1_TX, +		.end	= DA850_DMA_MMCSD1_TX,  		.flags	= IORESOURCE_DMA,  	},  };  static struct platform_device da850_mmcsd1_device = { -	.name		= "davinci_mmc", +	.name		= "da830-mmc",  	.id		= 1,  	.num_resources	= ARRAY_SIZE(da850_mmcsd1_resources),  	.resource	= da850_mmcsd1_resources, @@ -628,6 +734,92 @@ int __init da850_register_mmcsd1(struct davinci_mmc_config *config)  }  #endif +static struct resource da8xx_rproc_resources[] = { +	{ /* DSP boot address */ +		.start		= DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG, +		.end		= DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG + 3, +		.flags		= IORESOURCE_MEM, +	}, +	{ /* DSP interrupt registers */ +		.start		= DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG, +		.end		= DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG + 7, +		.flags		= IORESOURCE_MEM, +	}, +	{ /* dsp irq */ +		.start		= IRQ_DA8XX_CHIPINT0, +		.end		= IRQ_DA8XX_CHIPINT0, +		.flags		= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device da8xx_dsp = { +	.name	= "davinci-rproc", +	.dev	= { +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +	.num_resources	= ARRAY_SIZE(da8xx_rproc_resources), +	.resource	= da8xx_rproc_resources, +}; + +#if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC) + +static phys_addr_t rproc_base __initdata; +static unsigned long rproc_size __initdata; + +static int __init early_rproc_mem(char *p) +{ +	char *endp; + +	if (p == NULL) +		return 0; + +	rproc_size = memparse(p, &endp); +	if (*endp == '@') +		rproc_base = memparse(endp + 1, NULL); + +	return 0; +} +early_param("rproc_mem", early_rproc_mem); + +void __init da8xx_rproc_reserve_cma(void) +{ +	int ret; + +	if (!rproc_base || !rproc_size) { +		pr_err("%s: 'rproc_mem=nn@address' badly specified\n" +		       "    'nn' and 'address' must both be non-zero\n", +		       __func__); + +		return; +	} + +	pr_info("%s: reserving 0x%lx @ 0x%lx...\n", +		__func__, rproc_size, (unsigned long)rproc_base); + +	ret = dma_declare_contiguous(&da8xx_dsp.dev, rproc_size, rproc_base, 0); +	if (ret) +		pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret); +} + +#else + +void __init da8xx_rproc_reserve_cma(void) +{ +} + +#endif + +int __init da8xx_register_rproc(void) +{ +	int ret; + +	ret = platform_device_register(&da8xx_dsp); +	if (ret) +		pr_err("%s: can't register DSP device: %d\n", __func__, ret); + +	return ret; +}; +  static struct resource da8xx_rtc_resources[] = {  	{  		.start		= DA8XX_RTC_BASE, @@ -647,7 +839,7 @@ static struct resource da8xx_rtc_resources[] = {  };  static struct platform_device da8xx_rtc_device = { -	.name           = "omap_rtc", +	.name           = "da830-rtc",  	.id             = -1,  	.num_resources	= ARRAY_SIZE(da8xx_rtc_resources),  	.resource	= da8xx_rtc_resources, @@ -655,25 +847,7 @@ static struct platform_device da8xx_rtc_device = {  int da8xx_register_rtc(void)  { -	int ret; -	void __iomem *base; - -	base = ioremap(DA8XX_RTC_BASE, SZ_4K); -	if (WARN_ON(!base)) -		return -ENOMEM; - -	/* Unlock the rtc's registers */ -	__raw_writel(0x83e70b13, base + 0x6c); -	__raw_writel(0x95a4f1e0, base + 0x70); - -	iounmap(base); - -	ret = platform_device_register(&da8xx_rtc_device); -	if (!ret) -		/* Atleast on DA850, RTC is a wakeup source */ -		device_init_wakeup(&da8xx_rtc_device.dev, true); - -	return ret; +	return platform_device_register(&da8xx_rtc_device);  }  static void __iomem *da8xx_ddr2_ctlr_base; @@ -684,7 +858,7 @@ void __iomem * __init da8xx_get_mem_ctlr(void)  	da8xx_ddr2_ctlr_base = ioremap(DA8XX_DDR2_CTL_BASE, SZ_32K);  	if (!da8xx_ddr2_ctlr_base) -		pr_warning("%s: Unable to map DDR2 controller",	__func__); +		pr_warn("%s: Unable to map DDR2 controller", __func__);  	return da8xx_ddr2_ctlr_base;  } @@ -718,3 +892,138 @@ int __init da8xx_register_cpuidle(void)  	return platform_device_register(&da8xx_cpuidle_device);  } + +static struct resource da8xx_spi0_resources[] = { +	[0] = { +		.start	= DA8XX_SPI0_BASE, +		.end	= DA8XX_SPI0_BASE + SZ_4K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= IRQ_DA8XX_SPINT0, +		.end	= IRQ_DA8XX_SPINT0, +		.flags	= IORESOURCE_IRQ, +	}, +	[2] = { +		.start	= DA8XX_DMA_SPI0_RX, +		.end	= DA8XX_DMA_SPI0_RX, +		.flags	= IORESOURCE_DMA, +	}, +	[3] = { +		.start	= DA8XX_DMA_SPI0_TX, +		.end	= DA8XX_DMA_SPI0_TX, +		.flags	= IORESOURCE_DMA, +	}, +}; + +static struct resource da8xx_spi1_resources[] = { +	[0] = { +		.start	= DA830_SPI1_BASE, +		.end	= DA830_SPI1_BASE + SZ_4K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	[1] = { +		.start	= IRQ_DA8XX_SPINT1, +		.end	= IRQ_DA8XX_SPINT1, +		.flags	= IORESOURCE_IRQ, +	}, +	[2] = { +		.start	= DA8XX_DMA_SPI1_RX, +		.end	= DA8XX_DMA_SPI1_RX, +		.flags	= IORESOURCE_DMA, +	}, +	[3] = { +		.start	= DA8XX_DMA_SPI1_TX, +		.end	= DA8XX_DMA_SPI1_TX, +		.flags	= IORESOURCE_DMA, +	}, +}; + +static struct davinci_spi_platform_data da8xx_spi_pdata[] = { +	[0] = { +		.version	= SPI_VERSION_2, +		.intr_line	= 1, +		.dma_event_q	= EVENTQ_0, +	}, +	[1] = { +		.version	= SPI_VERSION_2, +		.intr_line	= 1, +		.dma_event_q	= EVENTQ_0, +	}, +}; + +static struct platform_device da8xx_spi_device[] = { +	[0] = { +		.name		= "spi_davinci", +		.id		= 0, +		.num_resources	= ARRAY_SIZE(da8xx_spi0_resources), +		.resource	= da8xx_spi0_resources, +		.dev		= { +			.platform_data = &da8xx_spi_pdata[0], +		}, +	}, +	[1] = { +		.name		= "spi_davinci", +		.id		= 1, +		.num_resources	= ARRAY_SIZE(da8xx_spi1_resources), +		.resource	= da8xx_spi1_resources, +		.dev		= { +			.platform_data = &da8xx_spi_pdata[1], +		}, +	}, +}; + +int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect) +{ +	if (instance < 0 || instance > 1) +		return -EINVAL; + +	da8xx_spi_pdata[instance].num_chipselect = num_chipselect; + +	if (instance == 1 && cpu_is_davinci_da850()) { +		da8xx_spi1_resources[0].start = DA850_SPI1_BASE; +		da8xx_spi1_resources[0].end = DA850_SPI1_BASE + SZ_4K - 1; +	} + +	return platform_device_register(&da8xx_spi_device[instance]); +} + +#ifdef CONFIG_ARCH_DAVINCI_DA850 +static struct resource da850_sata_resources[] = { +	{ +		.start	= DA850_SATA_BASE, +		.end	= DA850_SATA_BASE + 0x1fff, +		.flags	= IORESOURCE_MEM, +	}, +	{ +		.start	= DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG, +		.end	= DA8XX_SYSCFG1_BASE + DA8XX_PWRDN_REG + 0x3, +		.flags	= IORESOURCE_MEM, +	}, +	{ +		.start	= IRQ_DA850_SATAINT, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static u64 da850_sata_dmamask = DMA_BIT_MASK(32); + +static struct platform_device da850_sata_device = { +	.name	= "ahci_da850", +	.id	= -1, +	.dev	= { +		.dma_mask		= &da850_sata_dmamask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +	.num_resources	= ARRAY_SIZE(da850_sata_resources), +	.resource	= da850_sata_resources, +}; + +int __init da850_register_sata(unsigned long refclkpn) +{ +	/* please see comment in drivers/ata/ahci_da850.c */ +	BUG_ON(refclkpn != 100 * 1000 * 1000); + +	return platform_device_register(&da850_sata_device); +} +#endif diff --git a/arch/arm/mach-davinci/devices-tnetv107x.c b/arch/arm/mach-davinci/devices-tnetv107x.c deleted file mode 100644 index c9a86d8130d..00000000000 --- a/arch/arm/mach-davinci/devices-tnetv107x.c +++ /dev/null @@ -1,370 +0,0 @@ -/* - * Texas Instruments TNETV107X SoC devices - * - * Copyright (C) 2010 Texas Instruments - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - */ -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/platform_device.h> -#include <linux/dma-mapping.h> -#include <linux/clk.h> -#include <linux/slab.h> - -#include <mach/common.h> -#include <mach/irqs.h> -#include <mach/edma.h> -#include <mach/tnetv107x.h> - -#include "clock.h" - -/* Base addresses for on-chip devices */ -#define TNETV107X_TPCC_BASE			0x01c00000 -#define TNETV107X_TPTC0_BASE			0x01c10000 -#define TNETV107X_TPTC1_BASE			0x01c10400 -#define TNETV107X_WDOG_BASE			0x08086700 -#define TNETV107X_TSC_BASE			0x08088500 -#define TNETV107X_SDIO0_BASE			0x08088700 -#define TNETV107X_SDIO1_BASE			0x08088800 -#define TNETV107X_KEYPAD_BASE			0x08088a00 -#define TNETV107X_ASYNC_EMIF_CNTRL_BASE		0x08200000 -#define TNETV107X_ASYNC_EMIF_DATA_CE0_BASE	0x30000000 -#define TNETV107X_ASYNC_EMIF_DATA_CE1_BASE	0x40000000 -#define TNETV107X_ASYNC_EMIF_DATA_CE2_BASE	0x44000000 -#define TNETV107X_ASYNC_EMIF_DATA_CE3_BASE	0x48000000 - -/* TNETV107X specific EDMA3 information */ -#define EDMA_TNETV107X_NUM_DMACH	64 -#define EDMA_TNETV107X_NUM_TCC		64 -#define EDMA_TNETV107X_NUM_PARAMENTRY	128 -#define EDMA_TNETV107X_NUM_EVQUE	2 -#define EDMA_TNETV107X_NUM_TC		2 -#define EDMA_TNETV107X_CHMAP_EXIST	0 -#define EDMA_TNETV107X_NUM_REGIONS	4 -#define TNETV107X_DMACH2EVENT_MAP0	0x3C0CE000u -#define TNETV107X_DMACH2EVENT_MAP1	0x000FFFFFu - -#define TNETV107X_DMACH_SDIO0_RX		26 -#define TNETV107X_DMACH_SDIO0_TX		27 -#define TNETV107X_DMACH_SDIO1_RX		28 -#define TNETV107X_DMACH_SDIO1_TX		29 - -static const s8 edma_tc_mapping[][2] = { -	/* event queue no	TC no	*/ -	{	 0,		 0	}, -	{	 1,		 1	}, -	{	-1,		-1	} -}; - -static const s8 edma_priority_mapping[][2] = { -	/* event queue no	Prio	*/ -	{	 0,		 3	}, -	{	 1,		 7	}, -	{	-1,		-1	} -}; - -static struct edma_soc_info edma_cc0_info = { -	.n_channel		= EDMA_TNETV107X_NUM_DMACH, -	.n_region		= EDMA_TNETV107X_NUM_REGIONS, -	.n_slot			= EDMA_TNETV107X_NUM_PARAMENTRY, -	.n_tc			= EDMA_TNETV107X_NUM_TC, -	.n_cc			= 1, -	.queue_tc_mapping	= edma_tc_mapping, -	.queue_priority_mapping	= edma_priority_mapping, -}; - -static struct edma_soc_info *tnetv107x_edma_info[EDMA_MAX_CC] = { -	&edma_cc0_info, -}; - -static struct resource edma_resources[] = { -	{ -		.name	= "edma_cc0", -		.start	= TNETV107X_TPCC_BASE, -		.end	= TNETV107X_TPCC_BASE + SZ_32K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	{ -		.name	= "edma_tc0", -		.start	= TNETV107X_TPTC0_BASE, -		.end	= TNETV107X_TPTC0_BASE + SZ_1K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	{ -		.name	= "edma_tc1", -		.start	= TNETV107X_TPTC1_BASE, -		.end	= TNETV107X_TPTC1_BASE + SZ_1K - 1, -		.flags	= IORESOURCE_MEM, -	}, -	{ -		.name	= "edma0", -		.start	= IRQ_TNETV107X_TPCC, -		.flags	= IORESOURCE_IRQ, -	}, -	{ -		.name	= "edma0_err", -		.start	= IRQ_TNETV107X_TPCC_ERR, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device edma_device = { -	.name		= "edma", -	.id		= -1, -	.num_resources	= ARRAY_SIZE(edma_resources), -	.resource	= edma_resources, -	.dev.platform_data = tnetv107x_edma_info, -}; - -static struct plat_serial8250_port serial_data[] = { -	{ -		.mapbase	= TNETV107X_UART0_BASE, -		.irq		= IRQ_TNETV107X_UART0, -		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | -					UPF_FIXED_TYPE | UPF_IOREMAP, -		.type		= PORT_AR7, -		.iotype		= UPIO_MEM32, -		.regshift	= 2, -	}, -	{ -		.mapbase	= TNETV107X_UART1_BASE, -		.irq		= IRQ_TNETV107X_UART1, -		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | -					UPF_FIXED_TYPE | UPF_IOREMAP, -		.type		= PORT_AR7, -		.iotype		= UPIO_MEM32, -		.regshift	= 2, -	}, -	{ -		.mapbase	= TNETV107X_UART2_BASE, -		.irq		= IRQ_TNETV107X_UART2, -		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | -					UPF_FIXED_TYPE | UPF_IOREMAP, -		.type		= PORT_AR7, -		.iotype		= UPIO_MEM32, -		.regshift	= 2, -	}, -	{ -		.flags	= 0, -	}, -}; - -struct platform_device tnetv107x_serial_device = { -	.name			= "serial8250", -	.id			= PLAT8250_DEV_PLATFORM, -	.dev.platform_data	= serial_data, -}; - -static struct resource mmc0_resources[] = { -	{ /* Memory mapped registers */ -		.start	= TNETV107X_SDIO0_BASE, -		.end	= TNETV107X_SDIO0_BASE + 0x0ff, -		.flags	= IORESOURCE_MEM -	}, -	{ /* MMC interrupt */ -		.start	= IRQ_TNETV107X_MMC0, -		.flags	= IORESOURCE_IRQ -	}, -	{ /* SDIO interrupt */ -		.start	= IRQ_TNETV107X_SDIO0, -		.flags	= IORESOURCE_IRQ -	}, -	{ /* DMA RX */ -		.start	= EDMA_CTLR_CHAN(0, TNETV107X_DMACH_SDIO0_RX), -		.flags	= IORESOURCE_DMA -	}, -	{ /* DMA TX */ -		.start	= EDMA_CTLR_CHAN(0, TNETV107X_DMACH_SDIO0_TX), -		.flags	= IORESOURCE_DMA -	}, -}; - -static struct resource mmc1_resources[] = { -	{ /* Memory mapped registers */ -		.start	= TNETV107X_SDIO1_BASE, -		.end	= TNETV107X_SDIO1_BASE + 0x0ff, -		.flags	= IORESOURCE_MEM -	}, -	{ /* MMC interrupt */ -		.start	= IRQ_TNETV107X_MMC1, -		.flags	= IORESOURCE_IRQ -	}, -	{ /* SDIO interrupt */ -		.start	= IRQ_TNETV107X_SDIO1, -		.flags	= IORESOURCE_IRQ -	}, -	{ /* DMA RX */ -		.start	= EDMA_CTLR_CHAN(0, TNETV107X_DMACH_SDIO1_RX), -		.flags	= IORESOURCE_DMA -	}, -	{ /* DMA TX */ -		.start	= EDMA_CTLR_CHAN(0, TNETV107X_DMACH_SDIO1_TX), -		.flags	= IORESOURCE_DMA -	}, -}; - -static u64 mmc0_dma_mask = DMA_BIT_MASK(32); -static u64 mmc1_dma_mask = DMA_BIT_MASK(32); - -static struct platform_device mmc_devices[2] = { -	{ -		.name		= "davinci_mmc", -		.id		= 0, -		.dev		= { -			.dma_mask		= &mmc0_dma_mask, -			.coherent_dma_mask	= DMA_BIT_MASK(32), -		}, -		.num_resources	= ARRAY_SIZE(mmc0_resources), -		.resource	= mmc0_resources -	}, -	{ -		.name		= "davinci_mmc", -		.id		= 1, -		.dev		= { -			.dma_mask		= &mmc1_dma_mask, -			.coherent_dma_mask	= DMA_BIT_MASK(32), -		}, -		.num_resources	= ARRAY_SIZE(mmc1_resources), -		.resource	= mmc1_resources -	}, -}; - -static const u32 emif_windows[] = { -	TNETV107X_ASYNC_EMIF_DATA_CE0_BASE, TNETV107X_ASYNC_EMIF_DATA_CE1_BASE, -	TNETV107X_ASYNC_EMIF_DATA_CE2_BASE, TNETV107X_ASYNC_EMIF_DATA_CE3_BASE, -}; - -static const u32 emif_window_sizes[] = { SZ_256M, SZ_64M, SZ_64M, SZ_64M }; - -static struct resource wdt_resources[] = { -	{ -		.start	= TNETV107X_WDOG_BASE, -		.end	= TNETV107X_WDOG_BASE + SZ_4K - 1, -		.flags	= IORESOURCE_MEM, -	}, -}; - -struct platform_device tnetv107x_wdt_device = { -	.name		= "tnetv107x_wdt", -	.id		= 0, -	.num_resources	= ARRAY_SIZE(wdt_resources), -	.resource	= wdt_resources, -}; - -static int __init nand_init(int chipsel, struct davinci_nand_pdata *data) -{ -	struct resource res[2]; -	struct platform_device *pdev; -	u32	range; -	int	ret; - -	/* Figure out the resource range from the ale/cle masks */ -	range = max(data->mask_cle, data->mask_ale); -	range = PAGE_ALIGN(range + 4) - 1; - -	if (range >= emif_window_sizes[chipsel]) -		return -EINVAL; - -	pdev = kzalloc(sizeof(*pdev), GFP_KERNEL); -	if (!pdev) -		return -ENOMEM; - -	pdev->name		= "davinci_nand"; -	pdev->id		= chipsel; -	pdev->dev.platform_data	= data; - -	memset(res, 0, sizeof(res)); - -	res[0].start	= emif_windows[chipsel]; -	res[0].end	= res[0].start + range; -	res[0].flags	= IORESOURCE_MEM; - -	res[1].start	= TNETV107X_ASYNC_EMIF_CNTRL_BASE; -	res[1].end	= res[1].start + SZ_4K - 1; -	res[1].flags	= IORESOURCE_MEM; - -	ret = platform_device_add_resources(pdev, res, ARRAY_SIZE(res)); -	if (ret < 0) { -		kfree(pdev); -		return ret; -	} - -	return platform_device_register(pdev); -} - -static struct resource keypad_resources[] = { -	{ -		.start	= TNETV107X_KEYPAD_BASE, -		.end	= TNETV107X_KEYPAD_BASE + 0xff, -		.flags	= IORESOURCE_MEM, -	}, -	{ -		.start	= IRQ_TNETV107X_KEYPAD, -		.flags	= IORESOURCE_IRQ, -		.name	= "press", -	}, -	{ -		.start	= IRQ_TNETV107X_KEYPAD_FREE, -		.flags	= IORESOURCE_IRQ, -		.name	= "release", -	}, -}; - -static struct platform_device keypad_device = { -	.name		= "tnetv107x-keypad", -	.num_resources	= ARRAY_SIZE(keypad_resources), -	.resource	= keypad_resources, -}; - -static struct resource tsc_resources[] = { -	{ -		.start	= TNETV107X_TSC_BASE, -		.end	= TNETV107X_TSC_BASE + 0xff, -		.flags	= IORESOURCE_MEM, -	}, -	{ -		.start	= IRQ_TNETV107X_TSC, -		.flags	= IORESOURCE_IRQ, -	}, -}; - -static struct platform_device tsc_device = { -	.name		= "tnetv107x-ts", -	.num_resources	= ARRAY_SIZE(tsc_resources), -	.resource	= tsc_resources, -}; - -void __init tnetv107x_devices_init(struct tnetv107x_device_info *info) -{ -	int i; - -	platform_device_register(&edma_device); -	platform_device_register(&tnetv107x_wdt_device); -	platform_device_register(&tsc_device); - -	if (info->serial_config) -		davinci_serial_init(info->serial_config); - -	for (i = 0; i < 2; i++) -		if (info->mmc_config[i]) { -			mmc_devices[i].dev.platform_data = info->mmc_config[i]; -			platform_device_register(&mmc_devices[i]); -		} - -	for (i = 0; i < 4; i++) -		if (info->nand_config[i]) -			nand_init(i, info->nand_config[i]); - -	if (info->keypad_config) { -		keypad_device.dev.platform_data = info->keypad_config; -		platform_device_register(&keypad_device); -	} -} diff --git a/arch/arm/mach-davinci/devices.c b/arch/arm/mach-davinci/devices.c index 22ebc64bc9d..6257aa45256 100644 --- a/arch/arm/mach-davinci/devices.c +++ b/arch/arm/mach-davinci/devices.c @@ -13,16 +13,19 @@  #include <linux/platform_device.h>  #include <linux/dma-mapping.h>  #include <linux/io.h> +#include <linux/reboot.h>  #include <mach/hardware.h> -#include <mach/i2c.h> +#include <linux/platform_data/i2c-davinci.h>  #include <mach/irqs.h>  #include <mach/cputype.h>  #include <mach/mux.h> -#include <mach/edma.h> -#include <mach/mmc.h> +#include <linux/platform_data/mmc-davinci.h>  #include <mach/time.h> +#include <linux/platform_data/edma.h> + +#include "davinci.h"  #include "clock.h"  #define DAVINCI_I2C_BASE	     0x01C21000 @@ -33,6 +36,23 @@  #define DM365_MMCSD0_BASE	     0x01D11000  #define DM365_MMCSD1_BASE	     0x01D00000 +#define DAVINCI_DMA_MMCRXEVT	26 +#define DAVINCI_DMA_MMCTXEVT	27 + +void __iomem  *davinci_sysmod_base; + +void davinci_map_sysmod(void) +{ +	davinci_sysmod_base = ioremap_nocache(DAVINCI_SYSTEM_MODULE_BASE, +					      0x800); +	/* +	 * Throw a bug since a lot of board initialization code depends +	 * on system module availability. ioremap() failing this early +	 * need careful looking into anyway. +	 */ +	BUG_ON(!davinci_sysmod_base); +} +  static struct resource i2c_resources[] = {  	{  		.start		= DAVINCI_I2C_BASE, @@ -104,7 +124,7 @@ void __init davinci_init_ide(void)  	platform_device_register(&ide_device);  } -#if	defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE) +#if IS_ENABLED(CONFIG_MMC_DAVINCI)  static u64 mmcsd0_dma_mask = DMA_BIT_MASK(32); @@ -135,7 +155,7 @@ static struct resource mmcsd0_resources[] = {  };  static struct platform_device davinci_mmcsd0_device = { -	.name = "davinci_mmc", +	.name = "dm6441-mmc",  	.id = 0,  	.dev = {  		.dma_mask = &mmcsd0_dma_mask, @@ -172,7 +192,7 @@ static struct resource mmcsd1_resources[] = {  };  static struct platform_device davinci_mmcsd1_device = { -	.name = "davinci_mmc", +	.name = "dm6441-mmc",  	.id = 1,  	.dev = {  		.dma_mask = &mmcsd1_dma_mask, @@ -209,17 +229,18 @@ void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)  			davinci_cfg_reg(DM355_SD1_DATA2);  			davinci_cfg_reg(DM355_SD1_DATA3);  		} else if (cpu_is_davinci_dm365()) { -			void __iomem *pupdctl1 = -				IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE + 0x7c); -  			/* Configure pull down control */ -			__raw_writel((__raw_readl(pupdctl1) & ~0xfc0), -					pupdctl1); +			unsigned v; + +			v = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1)); +			__raw_writel(v & ~0xfc0, +					DAVINCI_SYSMOD_VIRT(SYSMOD_PUPDCTL1));  			mmcsd1_resources[0].start = DM365_MMCSD1_BASE;  			mmcsd1_resources[0].end = DM365_MMCSD1_BASE +  							SZ_4K - 1;  			mmcsd1_resources[2].start = IRQ_DM365_SDIOINT1; +			davinci_mmcsd1_device.name = "da830-mmc";  		} else  			break; @@ -241,13 +262,12 @@ void __init davinci_setup_mmc(int module, struct davinci_mmc_config *config)  			mmcsd0_resources[0].end = DM365_MMCSD0_BASE +  							SZ_4K - 1;  			mmcsd0_resources[2].start = IRQ_DM365_SDIOINT0; +			davinci_mmcsd0_device.name = "da830-mmc";  		} else if (cpu_is_davinci_dm644x()) {  			/* REVISIT: should this be in board-init code? */ -			void __iomem *base = -				IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE); -  			/* Power-on 3.3V IO cells */ -			__raw_writel(0, base + DM64XX_VDD3P3V_PWDN); +			__raw_writel(0, +				DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));  			/*Set up the pull regiter for MMC */  			davinci_cfg_reg(DM644X_MSTK);  		} @@ -282,31 +302,39 @@ static struct resource wdt_resources[] = {  };  struct platform_device davinci_wdt_device = { -	.name		= "watchdog", +	.name		= "davinci-wdt",  	.id		= -1,  	.num_resources	= ARRAY_SIZE(wdt_resources),  	.resource	= wdt_resources,  }; -static void davinci_init_wdt(void) +void davinci_restart(enum reboot_mode mode, const char *cmd)  { -	platform_device_register(&davinci_wdt_device); +	davinci_watchdog_reset(&davinci_wdt_device);  } -/*-------------------------------------------------------------------------*/ +int davinci_init_wdt(void) +{ +	return platform_device_register(&davinci_wdt_device); +} -struct platform_device davinci_pcm_device = { -	.name		= "davinci-pcm-audio", -	.id		= -1, +static struct platform_device davinci_gpio_device = { +	.name	= "davinci_gpio", +	.id	= -1,  }; -static void davinci_init_pcm(void) +int davinci_gpio_register(struct resource *res, int size, void *pdata)  { -	platform_device_register(&davinci_pcm_device); +	davinci_gpio_device.resource = res; +	davinci_gpio_device.num_resources = size; +	davinci_gpio_device.dev.platform_data = pdata; +	return platform_device_register(&davinci_gpio_device);  }  /*-------------------------------------------------------------------------*/ +/*-------------------------------------------------------------------------*/ +  struct davinci_timer_instance davinci_timer_instance[2] = {  	{  		.base		= DAVINCI_TIMER0_BASE, @@ -320,17 +348,3 @@ struct davinci_timer_instance davinci_timer_instance[2] = {  	},  }; -/*-------------------------------------------------------------------------*/ - -static int __init davinci_init_devices(void) -{ -	/* please keep these calls, and their implementations above, -	 * in alphabetical order so they're easier to sort through. -	 */ -	davinci_init_pcm(); -	davinci_init_wdt(); - -	return 0; -} -arch_initcall(davinci_init_devices); - diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index 9be261beae7..2f3ed3a58d5 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c @@ -13,28 +13,29 @@  #include <linux/serial_8250.h>  #include <linux/platform_device.h>  #include <linux/dma-mapping.h> -#include <linux/gpio.h> -  #include <linux/spi/spi.h> +#include <linux/platform_data/edma.h> +#include <linux/platform_data/gpio-davinci.h> +#include <linux/platform_data/spi-davinci.h>  #include <asm/mach/map.h> -#include <mach/dm355.h>  #include <mach/cputype.h> -#include <mach/edma.h>  #include <mach/psc.h>  #include <mach/mux.h>  #include <mach/irqs.h>  #include <mach/time.h>  #include <mach/serial.h>  #include <mach/common.h> -#include <mach/asp.h> -#include <mach/spi.h> +#include "davinci.h"  #include "clock.h"  #include "mux.h" +#include "asp.h"  #define DM355_UART2_BASE	(IO_PHYS + 0x206000) +#define DM355_OSD_BASE		(IO_PHYS + 0x70200) +#define DM355_VENC_BASE		(IO_PHYS + 0x70400)  /*   * Device specific clocks @@ -314,7 +315,7 @@ static struct clk timer2_clk = {  	.name = "timer2",  	.parent = &pll1_aux_clk,  	.lpsc = DAVINCI_LPSC_TIMER2, -	.usecount = 1,              /* REVISIT: why cant' this be disabled? */ +	.usecount = 1,              /* REVISIT: why can't this be disabled? */  };  static struct clk timer3_clk = { @@ -345,8 +346,8 @@ static struct clk_lookup dm355_clks[] = {  	CLK(NULL, "pll1_aux", &pll1_aux_clk),  	CLK(NULL, "pll1_sysclkbp", &pll1_sysclkbp),  	CLK(NULL, "vpss_dac", &vpss_dac_clk), -	CLK(NULL, "vpss_master", &vpss_master_clk), -	CLK(NULL, "vpss_slave", &vpss_slave_clk), +	CLK("vpss", "master", &vpss_master_clk), +	CLK("vpss", "slave", &vpss_slave_clk),  	CLK(NULL, "clkout1", &clkout1_clk),  	CLK(NULL, "clkout2", &clkout2_clk),  	CLK(NULL, "pll2", &pll2_clk), @@ -355,14 +356,14 @@ static struct clk_lookup dm355_clks[] = {  	CLK(NULL, "clkout3", &clkout3_clk),  	CLK(NULL, "arm", &arm_clk),  	CLK(NULL, "mjcp", &mjcp_clk), -	CLK(NULL, "uart0", &uart0_clk), -	CLK(NULL, "uart1", &uart1_clk), -	CLK(NULL, "uart2", &uart2_clk), +	CLK("serial8250.0", NULL, &uart0_clk), +	CLK("serial8250.1", NULL, &uart1_clk), +	CLK("serial8250.2", NULL, &uart2_clk),  	CLK("i2c_davinci.1", NULL, &i2c_clk), -	CLK("davinci-asp.0", NULL, &asp0_clk), -	CLK("davinci-asp.1", NULL, &asp1_clk), -	CLK("davinci_mmc.0", NULL, &mmcsd0_clk), -	CLK("davinci_mmc.1", NULL, &mmcsd1_clk), +	CLK("davinci-mcbsp.0", NULL, &asp0_clk), +	CLK("davinci-mcbsp.1", NULL, &asp1_clk), +	CLK("dm6441-mmc.0", NULL, &mmcsd0_clk), +	CLK("dm6441-mmc.1", NULL, &mmcsd1_clk),  	CLK("spi_davinci.0", NULL, &spi0_clk),  	CLK("spi_davinci.1", NULL, &spi1_clk),  	CLK("spi_davinci.2", NULL, &spi2_clk), @@ -374,7 +375,7 @@ static struct clk_lookup dm355_clks[] = {  	CLK(NULL, "pwm3", &pwm3_clk),  	CLK(NULL, "timer0", &timer0_clk),  	CLK(NULL, "timer1", &timer1_clk), -	CLK("watchdog", NULL, &timer2_clk), +	CLK("davinci-wdt", NULL, &timer2_clk),  	CLK(NULL, "timer3", &timer3_clk),  	CLK(NULL, "rto", &rto_clk),  	CLK(NULL, "usb", &usb_clk), @@ -403,21 +404,13 @@ static struct resource dm355_spi0_resources[] = {  		.start = 16,  		.flags = IORESOURCE_DMA,  	}, -	{ -		.start = EVENTQ_1, -		.flags = IORESOURCE_DMA, -	},  };  static struct davinci_spi_platform_data dm355_spi0_pdata = {  	.version 	= SPI_VERSION_1,  	.num_chipselect = 2, -	.clk_internal	= 1, -	.cs_hold	= 1, -	.intr_level	= 0, -	.poll_mode	= 1,	/* 0 -> interrupt mode 1-> polling mode */ -	.c2tdelay	= 0, -	.t2cdelay	= 0, +	.cshold_bug	= true, +	.dma_event_q	= EVENTQ_1,  };  static struct platform_device dm355_spi0_device = {  	.name = "spi_davinci", @@ -432,7 +425,7 @@ static struct platform_device dm355_spi0_device = {  };  void __init dm355_init_spi0(unsigned chipselect_mask, -		struct spi_board_info *info, unsigned len) +		const struct spi_board_info *info, unsigned len)  {  	/* for now, assume we need MISO */  	davinci_cfg_reg(DM355_SPI0_SDI); @@ -575,15 +568,7 @@ static u8 dm355_default_priorities[DAVINCI_N_AINTC_IRQ] = {  /*----------------------------------------------------------------------*/ -static const s8 -queue_tc_mapping[][2] = { -	/* {event queue no, TC no} */ -	{0, 0}, -	{1, 1}, -	{-1, -1}, -}; - -static const s8 +static s8  queue_priority_mapping[][2] = {  	/* {event queue no, Priority} */  	{0, 3}, @@ -592,13 +577,8 @@ queue_priority_mapping[][2] = {  };  static struct edma_soc_info edma_cc0_info = { -	.n_channel		= 64, -	.n_region		= 4, -	.n_slot			= 128, -	.n_tc			= 2, -	.n_cc			= 1, -	.queue_tc_mapping	= queue_tc_mapping,  	.queue_priority_mapping	= queue_priority_mapping, +	.default_queue		= EVENTQ_1,  };  static struct edma_soc_info *dm355_edma_info[EDMA_MAX_CC] = { @@ -647,6 +627,7 @@ static struct platform_device dm355_edma_device = {  static struct resource dm355_asp1_resources[] = {  	{ +		.name	= "mpu",  		.start	= DAVINCI_ASP1_BASE,  		.end	= DAVINCI_ASP1_BASE + SZ_8K - 1,  		.flags	= IORESOURCE_MEM, @@ -664,7 +645,7 @@ static struct resource dm355_asp1_resources[] = {  };  static struct platform_device dm355_asp1_device = { -	.name		= "davinci-asp", +	.name		= "davinci-mcbsp",  	.id		= 1,  	.num_resources	= ARRAY_SIZE(dm355_asp1_resources),  	.resource	= dm355_asp1_resources, @@ -751,11 +732,169 @@ static struct platform_device vpfe_capture_dev = {  	},  }; -void dm355_set_vpfe_config(struct vpfe_config *cfg) +static struct resource dm355_osd_resources[] = { +	{ +		.start	= DM355_OSD_BASE, +		.end	= DM355_OSD_BASE + 0x17f, +		.flags	= IORESOURCE_MEM, +	}, +}; + +static struct platform_device dm355_osd_dev = { +	.name		= DM355_VPBE_OSD_SUBDEV_NAME, +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm355_osd_resources), +	.resource	= dm355_osd_resources, +	.dev		= { +		.dma_mask		= &vpfe_capture_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +static struct resource dm355_venc_resources[] = { +	{ +		.start	= IRQ_VENCINT, +		.end	= IRQ_VENCINT, +		.flags	= IORESOURCE_IRQ, +	}, +	/* venc registers io space */ +	{ +		.start	= DM355_VENC_BASE, +		.end	= DM355_VENC_BASE + 0x17f, +		.flags	= IORESOURCE_MEM, +	}, +	/* VDAC config register io space */ +	{ +		.start	= DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG, +		.end	= DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG + 3, +		.flags	= IORESOURCE_MEM, +	}, +}; + +static struct resource dm355_v4l2_disp_resources[] = { +	{ +		.start	= IRQ_VENCINT, +		.end	= IRQ_VENCINT, +		.flags	= IORESOURCE_IRQ, +	}, +	/* venc registers io space */ +	{ +		.start	= DM355_VENC_BASE, +		.end	= DM355_VENC_BASE + 0x17f, +		.flags	= IORESOURCE_MEM, +	}, +}; + +static int dm355_vpbe_setup_pinmux(enum v4l2_mbus_pixelcode if_type, +			    int field) +{ +	switch (if_type) { +	case V4L2_MBUS_FMT_SGRBG8_1X8: +		davinci_cfg_reg(DM355_VOUT_FIELD_G70); +		break; +	case V4L2_MBUS_FMT_YUYV10_1X20: +		if (field) +			davinci_cfg_reg(DM355_VOUT_FIELD); +		else +			davinci_cfg_reg(DM355_VOUT_FIELD_G70); +		break; +	default: +		return -EINVAL; +	} + +	davinci_cfg_reg(DM355_VOUT_COUTL_EN); +	davinci_cfg_reg(DM355_VOUT_COUTH_EN); + +	return 0; +} + +static int dm355_venc_setup_clock(enum vpbe_enc_timings_type type, +				   unsigned int pclock)  { -	vpfe_capture_dev.dev.platform_data = cfg; +	void __iomem *vpss_clk_ctrl_reg; + +	vpss_clk_ctrl_reg = DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL); + +	switch (type) { +	case VPBE_ENC_STD: +		writel(VPSS_DACCLKEN_ENABLE | VPSS_VENCCLKEN_ENABLE, +		       vpss_clk_ctrl_reg); +		break; +	case VPBE_ENC_DV_TIMINGS: +		if (pclock > 27000000) +			/* +			 * For HD, use external clock source since we cannot +			 * support HD mode with internal clocks. +			 */ +			writel(VPSS_MUXSEL_EXTCLK_ENABLE, vpss_clk_ctrl_reg); +		break; +	default: +		return -EINVAL; +	} + +	return 0;  } +static struct platform_device dm355_vpbe_display = { +	.name		= "vpbe-v4l2", +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm355_v4l2_disp_resources), +	.resource	= dm355_v4l2_disp_resources, +	.dev		= { +		.dma_mask		= &vpfe_capture_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +static struct venc_platform_data dm355_venc_pdata = { +	.setup_pinmux	= dm355_vpbe_setup_pinmux, +	.setup_clock	= dm355_venc_setup_clock, +}; + +static struct platform_device dm355_venc_dev = { +	.name		= DM355_VPBE_VENC_SUBDEV_NAME, +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm355_venc_resources), +	.resource	= dm355_venc_resources, +	.dev		= { +		.dma_mask		= &vpfe_capture_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +		.platform_data		= (void *)&dm355_venc_pdata, +	}, +}; + +static struct platform_device dm355_vpbe_dev = { +	.name		= "vpbe_controller", +	.id		= -1, +	.dev		= { +		.dma_mask		= &vpfe_capture_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +static struct resource dm355_gpio_resources[] = { +	{	/* registers */ +		.start	= DAVINCI_GPIO_BASE, +		.end	= DAVINCI_GPIO_BASE + SZ_4K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	{	/* interrupt */ +		.start	= IRQ_DM355_GPIOBNK0, +		.end	= IRQ_DM355_GPIOBNK6, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct davinci_gpio_platform_data dm355_gpio_platform_data = { +	.ngpio		= 104, +}; + +int __init dm355_gpio_register(void) +{ +	return davinci_gpio_register(dm355_gpio_resources, +				     ARRAY_SIZE(dm355_gpio_resources), +				     &dm355_gpio_platform_data); +}  /*----------------------------------------------------------------------*/  static struct map_desc dm355_io_desc[] = { @@ -765,12 +904,6 @@ static struct map_desc dm355_io_desc[] = {  		.length		= IO_SIZE,  		.type		= MT_DEVICE  	}, -	{ -		.virtual	= SRAM_VIRT, -		.pfn		= __phys_to_pfn(0x00010000), -		.length		= SZ_32K, -		.type		= MT_MEMORY_NONCACHED, -	},  };  /* Contents of JTAG ID register used to identify exact cpu type */ @@ -798,7 +931,7 @@ static struct davinci_timer_info dm355_timer_info = {  	.clocksource_id	= T0_TOP,  }; -static struct plat_serial8250_port dm355_serial_platform_data[] = { +static struct plat_serial8250_port dm355_serial0_platform_data[] = {  	{  		.mapbase	= DAVINCI_UART0_BASE,  		.irq		= IRQ_UARTINT0, @@ -808,6 +941,11 @@ static struct plat_serial8250_port dm355_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port dm355_serial1_platform_data[] = { +	{  		.mapbase	= DAVINCI_UART1_BASE,  		.irq		= IRQ_UARTINT1,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -816,6 +954,11 @@ static struct plat_serial8250_port dm355_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port dm355_serial2_platform_data[] = { +	{  		.mapbase	= DM355_UART2_BASE,  		.irq		= IRQ_DM355_UARTINT2,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -824,16 +967,34 @@ static struct plat_serial8250_port dm355_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ -		.flags		= 0 -	}, +		.flags	= 0, +	}  }; -static struct platform_device dm355_serial_device = { -	.name			= "serial8250", -	.id			= PLAT8250_DEV_PLATFORM, -	.dev			= { -		.platform_data	= dm355_serial_platform_data, +struct platform_device dm355_serial_device[] = { +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM, +		.dev			= { +			.platform_data	= dm355_serial0_platform_data, +		} +	}, +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM1, +		.dev			= { +			.platform_data	= dm355_serial1_platform_data, +		}  	}, +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM2, +		.dev			= { +			.platform_data	= dm355_serial2_platform_data, +		} +	}, +	{ +	}  };  static struct davinci_soc_info davinci_soc_info_dm355 = { @@ -853,14 +1014,8 @@ static struct davinci_soc_info davinci_soc_info_dm355 = {  	.intc_irq_prios		= dm355_default_priorities,  	.intc_irq_num		= DAVINCI_N_AINTC_IRQ,  	.timer_info		= &dm355_timer_info, -	.gpio_type		= GPIO_TYPE_DAVINCI, -	.gpio_base		= DAVINCI_GPIO_BASE, -	.gpio_num		= 104, -	.gpio_irq		= IRQ_DM355_GPIOBNK0, -	.serial_dev		= &dm355_serial_device,  	.sram_dma		= 0x00010000,  	.sram_len		= SZ_32K, -	.reset_device		= &davinci_wdt_device,  };  void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata) @@ -879,22 +1034,46 @@ void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata)  void __init dm355_init(void)  {  	davinci_common_init(&davinci_soc_info_dm355); +	davinci_map_sysmod(); +} + +int __init dm355_init_video(struct vpfe_config *vpfe_cfg, +				struct vpbe_config *vpbe_cfg) +{ +	if (vpfe_cfg || vpbe_cfg) +		platform_device_register(&dm355_vpss_device); + +	if (vpfe_cfg) { +		vpfe_capture_dev.dev.platform_data = vpfe_cfg; +		platform_device_register(&dm355_ccdc_dev); +		platform_device_register(&vpfe_capture_dev); +	} + +	if (vpbe_cfg) { +		dm355_vpbe_dev.dev.platform_data = vpbe_cfg; +		platform_device_register(&dm355_osd_dev); +		platform_device_register(&dm355_venc_dev); +		platform_device_register(&dm355_vpbe_dev); +		platform_device_register(&dm355_vpbe_display); +	} + +	return 0;  }  static int __init dm355_init_devices(void)  { +	int ret = 0; +  	if (!cpu_is_davinci_dm355())  		return 0; -	/* Add ccdc clock aliases */ -	clk_add_alias("master", dm355_ccdc_dev.name, "vpss_master", NULL); -	clk_add_alias("slave", dm355_ccdc_dev.name, "vpss_master", NULL);  	davinci_cfg_reg(DM355_INT_EDMA_CC);  	platform_device_register(&dm355_edma_device); -	platform_device_register(&dm355_vpss_device); -	platform_device_register(&dm355_ccdc_dev); -	platform_device_register(&vpfe_capture_dev); -	return 0; +	ret = davinci_init_wdt(); +	if (ret) +		pr_warn("%s: watchdog init failed: %d\n", __func__, ret); + +	return ret;  }  postcore_initcall(dm355_init_devices); diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index a12065e8726..0ae8114f5cc 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -17,29 +17,41 @@  #include <linux/serial_8250.h>  #include <linux/platform_device.h>  #include <linux/dma-mapping.h> -#include <linux/gpio.h>  #include <linux/spi/spi.h> +#include <linux/platform_data/edma.h> +#include <linux/platform_data/gpio-davinci.h> +#include <linux/platform_data/keyscan-davinci.h> +#include <linux/platform_data/spi-davinci.h>  #include <asm/mach/map.h> -#include <mach/dm365.h>  #include <mach/cputype.h> -#include <mach/edma.h>  #include <mach/psc.h>  #include <mach/mux.h>  #include <mach/irqs.h>  #include <mach/time.h>  #include <mach/serial.h>  #include <mach/common.h> -#include <mach/asp.h> -#include <mach/keyscan.h> -#include <mach/spi.h> - +#include "davinci.h"  #include "clock.h"  #include "mux.h" +#include "asp.h"  #define DM365_REF_FREQ		24000000	/* 24 MHz on the DM365 EVM */ +#define DM365_RTC_BASE			0x01c69000 +#define DM365_KEYSCAN_BASE		0x01c69400 +#define DM365_OSD_BASE			0x01c71c00 +#define DM365_VENC_BASE			0x01c71e00 +#define DAVINCI_DM365_VC_BASE		0x01d0c000 +#define DAVINCI_DMA_VC_TX		2 +#define DAVINCI_DMA_VC_RX		3 +#define DM365_EMAC_BASE			0x01d07000 +#define DM365_EMAC_MDIO_BASE		(DM365_EMAC_BASE + 0x4000) +#define DM365_EMAC_CNTRL_OFFSET		0x0000 +#define DM365_EMAC_CNTRL_MOD_OFFSET	0x3000 +#define DM365_EMAC_CNTRL_RAM_OFFSET	0x1000 +#define DM365_EMAC_CNTRL_RAM_SIZE	0x2000  static struct pll_data pll1_data = {  	.num		= 1, @@ -242,6 +254,12 @@ static struct clk vpss_master_clk = {  	.flags		= CLK_PSC,  }; +static struct clk vpss_slave_clk = { +	.name		= "vpss_slave", +	.parent		= &pll1_sysclk5, +	.lpsc		= DAVINCI_LPSC_VPSSSLV, +}; +  static struct clk arm_clk = {  	.name		= "arm_clk",  	.parent		= &pll2_sysclk2, @@ -434,13 +452,14 @@ static struct clk_lookup dm365_clks[] = {  	CLK(NULL, "pll2_sysclk8", &pll2_sysclk8),  	CLK(NULL, "pll2_sysclk9", &pll2_sysclk9),  	CLK(NULL, "vpss_dac", &vpss_dac_clk), -	CLK(NULL, "vpss_master", &vpss_master_clk), +	CLK("vpss", "master", &vpss_master_clk), +	CLK("vpss", "slave", &vpss_slave_clk),  	CLK(NULL, "arm", &arm_clk), -	CLK(NULL, "uart0", &uart0_clk), -	CLK(NULL, "uart1", &uart1_clk), +	CLK("serial8250.0", NULL, &uart0_clk), +	CLK("serial8250.1", NULL, &uart1_clk),  	CLK("i2c_davinci.1", NULL, &i2c_clk), -	CLK("davinci_mmc.0", NULL, &mmcsd0_clk), -	CLK("davinci_mmc.1", NULL, &mmcsd1_clk), +	CLK("da830-mmc.0", NULL, &mmcsd0_clk), +	CLK("da830-mmc.1", NULL, &mmcsd1_clk),  	CLK("spi_davinci.0", NULL, &spi0_clk),  	CLK("spi_davinci.1", NULL, &spi1_clk),  	CLK("spi_davinci.2", NULL, &spi2_clk), @@ -454,12 +473,13 @@ static struct clk_lookup dm365_clks[] = {  	CLK(NULL, "pwm3", &pwm3_clk),  	CLK(NULL, "timer0", &timer0_clk),  	CLK(NULL, "timer1", &timer1_clk), -	CLK("watchdog", NULL, &timer2_clk), +	CLK("davinci-wdt", NULL, &timer2_clk),  	CLK(NULL, "timer3", &timer3_clk),  	CLK(NULL, "usb", &usb_clk),  	CLK("davinci_emac.1", NULL, &emac_clk), +	CLK("davinci_mdio.0", "fck", &emac_clk),  	CLK("davinci_voicecodec", NULL, &voicecodec_clk), -	CLK("davinci-asp.0", NULL, &asp0_clk), +	CLK("davinci-mcbsp", NULL, &asp0_clk),  	CLK(NULL, "rto", &rto_clk),  	CLK(NULL, "mjcp", &mjcp_clk),  	CLK(NULL, NULL, NULL), @@ -625,12 +645,7 @@ static u64 dm365_spi0_dma_mask = DMA_BIT_MASK(32);  static struct davinci_spi_platform_data dm365_spi0_pdata = {  	.version 	= SPI_VERSION_1,  	.num_chipselect = 2, -	.clk_internal	= 1, -	.cs_hold	= 1, -	.intr_level	= 0, -	.poll_mode	= 1,	/* 0 -> interrupt mode 1-> polling mode */ -	.c2tdelay	= 0, -	.t2cdelay	= 0, +	.dma_event_q	= EVENTQ_3,  };  static struct resource dm365_spi0_resources[] = { @@ -651,10 +666,6 @@ static struct resource dm365_spi0_resources[] = {  		.start = 16,  		.flags = IORESOURCE_DMA,  	}, -	{ -		.start = EVENTQ_3, -		.flags = IORESOURCE_DMA, -	},  };  static struct platform_device dm365_spi0_device = { @@ -670,7 +681,7 @@ static struct platform_device dm365_spi0_device = {  };  void __init dm365_init_spi0(unsigned chipselect_mask, -		struct spi_board_info *info, unsigned len) +		const struct spi_board_info *info, unsigned len)  {  	davinci_cfg_reg(DM365_SPI0_SCLK);  	davinci_cfg_reg(DM365_SPI0_SDI); @@ -687,6 +698,31 @@ void __init dm365_init_spi0(unsigned chipselect_mask,  	platform_device_register(&dm365_spi0_device);  } +static struct resource dm365_gpio_resources[] = { +	{	/* registers */ +		.start	= DAVINCI_GPIO_BASE, +		.end	= DAVINCI_GPIO_BASE + SZ_4K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	{	/* interrupt */ +		.start	= IRQ_DM365_GPIO0, +		.end	= IRQ_DM365_GPIO7, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct davinci_gpio_platform_data dm365_gpio_platform_data = { +	.ngpio		= 104, +	.gpio_unbanked	= 8, +}; + +int __init dm365_gpio_register(void) +{ +	return davinci_gpio_register(dm365_gpio_resources, +				     ARRAY_SIZE(dm365_gpio_resources), +				     &dm365_gpio_platform_data); +} +  static struct emac_platform_data dm365_emac_pdata = {  	.ctrl_reg_offset	= DM365_EMAC_CNTRL_OFFSET,  	.ctrl_mod_reg_offset	= DM365_EMAC_CNTRL_MOD_OFFSET, @@ -816,17 +852,7 @@ static u8 dm365_default_priorities[DAVINCI_N_AINTC_IRQ] = {  };  /* Four Transfer Controllers on DM365 */ -static const s8 -dm365_queue_tc_mapping[][2] = { -	/* {event queue no, TC no} */ -	{0, 0}, -	{1, 1}, -	{2, 2}, -	{3, 3}, -	{-1, -1}, -}; - -static const s8 +static s8  dm365_queue_priority_mapping[][2] = {  	/* {event queue no, Priority} */  	{0, 7}, @@ -837,12 +863,6 @@ dm365_queue_priority_mapping[][2] = {  };  static struct edma_soc_info edma_cc0_info = { -	.n_channel		= 64, -	.n_region		= 4, -	.n_slot			= 256, -	.n_tc			= 4, -	.n_cc			= 1, -	.queue_tc_mapping	= dm365_queue_tc_mapping,  	.queue_priority_mapping	= dm365_queue_priority_mapping,  	.default_queue		= EVENTQ_3,  }; @@ -905,6 +925,7 @@ static struct platform_device dm365_edma_device = {  static struct resource dm365_asp_resources[] = {  	{ +		.name	= "mpu",  		.start	= DAVINCI_DM365_ASP0_BASE,  		.end	= DAVINCI_DM365_ASP0_BASE + SZ_8K - 1,  		.flags	= IORESOURCE_MEM, @@ -922,8 +943,8 @@ static struct resource dm365_asp_resources[] = {  };  static struct platform_device dm365_asp_device = { -	.name		= "davinci-asp", -	.id		= 0, +	.name		= "davinci-mcbsp", +	.id		= -1,  	.num_resources	= ARRAY_SIZE(dm365_asp_resources),  	.resource	= dm365_asp_resources,  }; @@ -979,12 +1000,6 @@ static struct map_desc dm365_io_desc[] = {  		.length		= IO_SIZE,  		.type		= MT_DEVICE  	}, -	{ -		.virtual	= SRAM_VIRT, -		.pfn		= __phys_to_pfn(0x00010000), -		.length		= SZ_32K, -		.type		= MT_MEMORY_NONCACHED, -	},  };  static struct resource dm365_ks_resources[] = { @@ -1037,7 +1052,7 @@ static struct davinci_timer_info dm365_timer_info = {  #define DM365_UART1_BASE	(IO_PHYS + 0x106000) -static struct plat_serial8250_port dm365_serial_platform_data[] = { +static struct plat_serial8250_port dm365_serial0_platform_data[] = {  	{  		.mapbase	= DAVINCI_UART0_BASE,  		.irq		= IRQ_UARTINT0, @@ -1047,6 +1062,11 @@ static struct plat_serial8250_port dm365_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port dm365_serial1_platform_data[] = { +	{  		.mapbase	= DM365_UART1_BASE,  		.irq		= IRQ_UARTINT1,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -1055,16 +1075,27 @@ static struct plat_serial8250_port dm365_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ -		.flags		= 0 -	}, +		.flags	= 0, +	}  }; -static struct platform_device dm365_serial_device = { -	.name			= "serial8250", -	.id			= PLAT8250_DEV_PLATFORM, -	.dev			= { -		.platform_data	= dm365_serial_platform_data, +struct platform_device dm365_serial_device[] = { +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM, +		.dev			= { +			.platform_data	= dm365_serial0_platform_data, +		} +	}, +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM1, +		.dev			= { +			.platform_data	= dm365_serial1_platform_data, +		}  	}, +	{ +	}  };  static struct davinci_soc_info davinci_soc_info_dm365 = { @@ -1084,16 +1115,9 @@ static struct davinci_soc_info davinci_soc_info_dm365 = {  	.intc_irq_prios		= dm365_default_priorities,  	.intc_irq_num		= DAVINCI_N_AINTC_IRQ,  	.timer_info		= &dm365_timer_info, -	.gpio_type		= GPIO_TYPE_DAVINCI, -	.gpio_base		= DAVINCI_GPIO_BASE, -	.gpio_num		= 104, -	.gpio_irq		= IRQ_DM365_GPIO0, -	.gpio_unbanked		= 8,	/* really 16 ... skip muxed GPIOs */ -	.serial_dev		= &dm365_serial_device,  	.emac_pdata		= &dm365_emac_pdata,  	.sram_dma		= 0x00010000,  	.sram_len		= SZ_32K, -	.reset_device		= &davinci_wdt_device,  };  void __init dm365_init_asp(struct snd_platform_data *pdata) @@ -1133,6 +1157,7 @@ void __init dm365_init_rtc(void)  void __init dm365_init(void)  {  	davinci_common_init(&davinci_soc_info_dm365); +	davinci_map_sysmod();  }  static struct resource dm365_vpss_resources[] = { @@ -1226,8 +1251,177 @@ static struct platform_device dm365_isif_dev = {  	},  }; +static struct resource dm365_osd_resources[] = { +	{ +		.start = DM365_OSD_BASE, +		.end   = DM365_OSD_BASE + 0xff, +		.flags = IORESOURCE_MEM, +	}, +}; + +static u64 dm365_video_dma_mask = DMA_BIT_MASK(32); + +static struct platform_device dm365_osd_dev = { +	.name		= DM365_VPBE_OSD_SUBDEV_NAME, +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm365_osd_resources), +	.resource	= dm365_osd_resources, +	.dev		= { +		.dma_mask		= &dm365_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +static struct resource dm365_venc_resources[] = { +	{ +		.start = IRQ_VENCINT, +		.end   = IRQ_VENCINT, +		.flags = IORESOURCE_IRQ, +	}, +	/* venc registers io space */ +	{ +		.start = DM365_VENC_BASE, +		.end   = DM365_VENC_BASE + 0x177, +		.flags = IORESOURCE_MEM, +	}, +	/* vdaccfg registers io space */ +	{ +		.start = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG, +		.end   = DAVINCI_SYSTEM_MODULE_BASE + SYSMOD_VDAC_CONFIG + 3, +		.flags = IORESOURCE_MEM, +	}, +}; + +static struct resource dm365_v4l2_disp_resources[] = { +	{ +		.start = IRQ_VENCINT, +		.end   = IRQ_VENCINT, +		.flags = IORESOURCE_IRQ, +	}, +	/* venc registers io space */ +	{ +		.start = DM365_VENC_BASE, +		.end   = DM365_VENC_BASE + 0x177, +		.flags = IORESOURCE_MEM, +	}, +}; + +static int dm365_vpbe_setup_pinmux(enum v4l2_mbus_pixelcode if_type, +			    int field) +{ +	switch (if_type) { +	case V4L2_MBUS_FMT_SGRBG8_1X8: +		davinci_cfg_reg(DM365_VOUT_FIELD_G81); +		davinci_cfg_reg(DM365_VOUT_COUTL_EN); +		davinci_cfg_reg(DM365_VOUT_COUTH_EN); +		break; +	case V4L2_MBUS_FMT_YUYV10_1X20: +		if (field) +			davinci_cfg_reg(DM365_VOUT_FIELD); +		else +			davinci_cfg_reg(DM365_VOUT_FIELD_G81); +		davinci_cfg_reg(DM365_VOUT_COUTL_EN); +		davinci_cfg_reg(DM365_VOUT_COUTH_EN); +		break; +	default: +		return -EINVAL; +	} + +	return 0; +} + +static int dm365_venc_setup_clock(enum vpbe_enc_timings_type type, +				  unsigned int pclock) +{ +	void __iomem *vpss_clkctl_reg; +	u32 val; + +	vpss_clkctl_reg = DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL); + +	switch (type) { +	case VPBE_ENC_STD: +		val = VPSS_VENCCLKEN_ENABLE | VPSS_DACCLKEN_ENABLE; +		break; +	case VPBE_ENC_DV_TIMINGS: +		if (pclock <= 27000000) { +			val = VPSS_VENCCLKEN_ENABLE | VPSS_DACCLKEN_ENABLE; +		} else { +			/* set sysclk4 to output 74.25 MHz from pll1 */ +			val = VPSS_PLLC2SYSCLK5_ENABLE | VPSS_DACCLKEN_ENABLE | +			      VPSS_VENCCLKEN_ENABLE; +		} +		break; +	default: +		return -EINVAL; +	} +	writel(val, vpss_clkctl_reg); + +	return 0; +} + +static struct platform_device dm365_vpbe_display = { +	.name		= "vpbe-v4l2", +	.id		= -1, +	.num_resources  = ARRAY_SIZE(dm365_v4l2_disp_resources), +	.resource	= dm365_v4l2_disp_resources, +	.dev		= { +		.dma_mask		= &dm365_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +static struct venc_platform_data dm365_venc_pdata = { +	.setup_pinmux	= dm365_vpbe_setup_pinmux, +	.setup_clock	= dm365_venc_setup_clock, +}; + +static struct platform_device dm365_venc_dev = { +	.name		= DM365_VPBE_VENC_SUBDEV_NAME, +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm365_venc_resources), +	.resource	= dm365_venc_resources, +	.dev		= { +		.dma_mask		= &dm365_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +		.platform_data		= (void *)&dm365_venc_pdata, +	}, +}; + +static struct platform_device dm365_vpbe_dev = { +	.name		= "vpbe_controller", +	.id		= -1, +	.dev		= { +		.dma_mask		= &dm365_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +int __init dm365_init_video(struct vpfe_config *vpfe_cfg, +				struct vpbe_config *vpbe_cfg) +{ +	if (vpfe_cfg || vpbe_cfg) +		platform_device_register(&dm365_vpss_device); + +	if (vpfe_cfg) { +		vpfe_capture_dev.dev.platform_data = vpfe_cfg; +		platform_device_register(&dm365_isif_dev); +		platform_device_register(&vpfe_capture_dev); +	} +	if (vpbe_cfg) { +		dm365_vpbe_dev.dev.platform_data = vpbe_cfg; +		platform_device_register(&dm365_osd_dev); +		platform_device_register(&dm365_venc_dev); +		platform_device_register(&dm365_vpbe_dev); +		platform_device_register(&dm365_vpbe_display); +	} + +	return 0; +} +  static int __init dm365_init_devices(void)  { +	int ret = 0; +  	if (!cpu_is_davinci_dm365())  		return 0; @@ -1236,19 +1430,11 @@ static int __init dm365_init_devices(void)  	platform_device_register(&dm365_mdio_device);  	platform_device_register(&dm365_emac_device); -	clk_add_alias(NULL, dev_name(&dm365_mdio_device.dev), -		      NULL, &dm365_emac_device.dev); - -	/* Add isif clock alias */ -	clk_add_alias("master", dm365_isif_dev.name, "vpss_master", NULL); -	platform_device_register(&dm365_vpss_device); -	platform_device_register(&dm365_isif_dev); -	platform_device_register(&vpfe_capture_dev); -	return 0; -} -postcore_initcall(dm365_init_devices); -void dm365_set_vpfe_config(struct vpfe_config *cfg) -{ -       vpfe_capture_dev.dev.platform_data = cfg; +	ret = davinci_init_wdt(); +	if (ret) +		pr_warn("%s: watchdog init failed: %d\n", __func__, ret); + +	return ret;  } +postcore_initcall(dm365_init_devices); diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c index 0608dd776a1..dc52657909c 100644 --- a/arch/arm/mach-davinci/dm644x.c +++ b/arch/arm/mach-davinci/dm644x.c @@ -12,29 +12,36 @@  #include <linux/clk.h>  #include <linux/serial_8250.h>  #include <linux/platform_device.h> -#include <linux/gpio.h> +#include <linux/platform_data/edma.h> +#include <linux/platform_data/gpio-davinci.h>  #include <asm/mach/map.h> -#include <mach/dm644x.h>  #include <mach/cputype.h> -#include <mach/edma.h>  #include <mach/irqs.h>  #include <mach/psc.h>  #include <mach/mux.h>  #include <mach/time.h>  #include <mach/serial.h>  #include <mach/common.h> -#include <mach/asp.h> +#include "davinci.h"  #include "clock.h"  #include "mux.h" +#include "asp.h"  /*   * Device specific clocks   */  #define DM644X_REF_FREQ		27000000 +#define DM644X_EMAC_BASE		0x01c80000 +#define DM644X_EMAC_MDIO_BASE		(DM644X_EMAC_BASE + 0x4000) +#define DM644X_EMAC_CNTRL_OFFSET	0x0000 +#define DM644X_EMAC_CNTRL_MOD_OFFSET	0x1000 +#define DM644X_EMAC_CNTRL_RAM_OFFSET	0x2000 +#define DM644X_EMAC_CNTRL_RAM_SIZE	0x2000 +  static struct pll_data pll1_data = {  	.num       = 1,  	.phys_base = DAVINCI_PLL1_BASE, @@ -130,7 +137,7 @@ static struct clk dsp_clk = {  	.name = "dsp",  	.parent = &pll1_sysclk1,  	.lpsc = DAVINCI_LPSC_GEM, -	.flags = PSC_DSP, +	.domain = DAVINCI_GPSC_DSPDOMAIN,  	.usecount = 1,			/* REVISIT how to disable? */  }; @@ -145,7 +152,7 @@ static struct clk vicp_clk = {  	.name = "vicp",  	.parent = &pll1_sysclk2,  	.lpsc = DAVINCI_LPSC_IMCOP, -	.flags = PSC_DSP, +	.domain = DAVINCI_GPSC_DSPDOMAIN,  	.usecount = 1,			/* REVISIT how to disable? */  }; @@ -274,7 +281,7 @@ static struct clk timer2_clk = {  	.name = "timer2",  	.parent = &pll1_aux_clk,  	.lpsc = DAVINCI_LPSC_TIMER2, -	.usecount = 1,              /* REVISIT: why cant' this be disabled? */ +	.usecount = 1,              /* REVISIT: why can't this be disabled? */  };  static struct clk_lookup dm644x_clks[] = { @@ -293,17 +300,18 @@ static struct clk_lookup dm644x_clks[] = {  	CLK(NULL, "dsp", &dsp_clk),  	CLK(NULL, "arm", &arm_clk),  	CLK(NULL, "vicp", &vicp_clk), -	CLK(NULL, "vpss_master", &vpss_master_clk), -	CLK(NULL, "vpss_slave", &vpss_slave_clk), +	CLK("vpss", "master", &vpss_master_clk), +	CLK("vpss", "slave", &vpss_slave_clk),  	CLK(NULL, "arm", &arm_clk), -	CLK(NULL, "uart0", &uart0_clk), -	CLK(NULL, "uart1", &uart1_clk), -	CLK(NULL, "uart2", &uart2_clk), +	CLK("serial8250.0", NULL, &uart0_clk), +	CLK("serial8250.1", NULL, &uart1_clk), +	CLK("serial8250.2", NULL, &uart2_clk),  	CLK("davinci_emac.1", NULL, &emac_clk), +	CLK("davinci_mdio.0", "fck", &emac_clk),  	CLK("i2c_davinci.1", NULL, &i2c_clk),  	CLK("palm_bk3710", NULL, &ide_clk), -	CLK("davinci-asp", NULL, &asp_clk), -	CLK("davinci_mmc.0", NULL, &mmcsd_clk), +	CLK("davinci-mcbsp", NULL, &asp_clk), +	CLK("dm6441-mmc.0", NULL, &mmcsd_clk),  	CLK(NULL, "spi", &spi_clk),  	CLK(NULL, "gpio", &gpio_clk),  	CLK(NULL, "usb", &usb_clk), @@ -314,7 +322,7 @@ static struct clk_lookup dm644x_clks[] = {  	CLK(NULL, "pwm2", &pwm2_clk),  	CLK(NULL, "timer0", &timer0_clk),  	CLK(NULL, "timer1", &timer1_clk), -	CLK("watchdog", NULL, &timer2_clk), +	CLK("davinci-wdt", NULL, &timer2_clk),  	CLK(NULL, NULL, NULL),  }; @@ -490,15 +498,7 @@ static u8 dm644x_default_priorities[DAVINCI_N_AINTC_IRQ] = {  /*----------------------------------------------------------------------*/ -static const s8 -queue_tc_mapping[][2] = { -	/* {event queue no, TC no} */ -	{0, 0}, -	{1, 1}, -	{-1, -1}, -}; - -static const s8 +static s8  queue_priority_mapping[][2] = {  	/* {event queue no, Priority} */  	{0, 3}, @@ -507,13 +507,8 @@ queue_priority_mapping[][2] = {  };  static struct edma_soc_info edma_cc0_info = { -	.n_channel		= 64, -	.n_region		= 4, -	.n_slot			= 128, -	.n_tc			= 2, -	.n_cc			= 1, -	.queue_tc_mapping	= queue_tc_mapping,  	.queue_priority_mapping	= queue_priority_mapping, +	.default_queue		= EVENTQ_1,  };  static struct edma_soc_info *dm644x_edma_info[EDMA_MAX_CC] = { @@ -563,6 +558,7 @@ static struct platform_device dm644x_edma_device = {  /* DM6446 EVM uses ASP0; line-out is a pair of RCA jacks */  static struct resource dm644x_asp_resources[] = {  	{ +		.name	= "mpu",  		.start	= DAVINCI_ASP0_BASE,  		.end	= DAVINCI_ASP0_BASE + SZ_8K - 1,  		.flags	= IORESOURCE_MEM, @@ -580,19 +576,21 @@ static struct resource dm644x_asp_resources[] = {  };  static struct platform_device dm644x_asp_device = { -	.name		= "davinci-asp", +	.name		= "davinci-mcbsp",  	.id		= -1,  	.num_resources	= ARRAY_SIZE(dm644x_asp_resources),  	.resource	= dm644x_asp_resources,  }; +#define DM644X_VPSS_BASE	0x01c73400 +  static struct resource dm644x_vpss_resources[] = {  	{  		/* VPSS Base address */  		.name		= "vpss", -		.start          = 0x01c73400, -		.end            = 0x01c73400 + 0xff, -		.flags          = IORESOURCE_MEM, +		.start		= DM644X_VPSS_BASE, +		.end		= DM644X_VPSS_BASE + 0xff, +		.flags		= IORESOURCE_MEM,  	},  }; @@ -604,7 +602,7 @@ static struct platform_device dm644x_vpss_device = {  	.resource		= dm644x_vpss_resources,  }; -static struct resource vpfe_resources[] = { +static struct resource dm644x_vpfe_resources[] = {  	{  		.start          = IRQ_VDINT0,  		.end            = IRQ_VDINT0, @@ -617,7 +615,7 @@ static struct resource vpfe_resources[] = {  	},  }; -static u64 vpfe_capture_dma_mask = DMA_BIT_MASK(32); +static u64 dm644x_video_dma_mask = DMA_BIT_MASK(32);  static struct resource dm644x_ccdc_resource[] = {  	/* CCDC Base address */  	{ @@ -633,27 +631,156 @@ static struct platform_device dm644x_ccdc_dev = {  	.num_resources  = ARRAY_SIZE(dm644x_ccdc_resource),  	.resource       = dm644x_ccdc_resource,  	.dev = { -		.dma_mask               = &vpfe_capture_dma_mask, +		.dma_mask               = &dm644x_video_dma_mask,  		.coherent_dma_mask      = DMA_BIT_MASK(32),  	},  }; -static struct platform_device vpfe_capture_dev = { +static struct platform_device dm644x_vpfe_dev = {  	.name		= CAPTURE_DRV_NAME,  	.id		= -1, -	.num_resources	= ARRAY_SIZE(vpfe_resources), -	.resource	= vpfe_resources, +	.num_resources	= ARRAY_SIZE(dm644x_vpfe_resources), +	.resource	= dm644x_vpfe_resources,  	.dev = { -		.dma_mask		= &vpfe_capture_dma_mask, +		.dma_mask		= &dm644x_video_dma_mask,  		.coherent_dma_mask	= DMA_BIT_MASK(32),  	},  }; -void dm644x_set_vpfe_config(struct vpfe_config *cfg) +#define DM644X_OSD_BASE		0x01c72600 + +static struct resource dm644x_osd_resources[] = { +	{ +		.start	= DM644X_OSD_BASE, +		.end	= DM644X_OSD_BASE + 0x1ff, +		.flags	= IORESOURCE_MEM, +	}, +}; + +static struct platform_device dm644x_osd_dev = { +	.name		= DM644X_VPBE_OSD_SUBDEV_NAME, +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm644x_osd_resources), +	.resource	= dm644x_osd_resources, +	.dev		= { +		.dma_mask		= &dm644x_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +#define DM644X_VENC_BASE		0x01c72400 + +static struct resource dm644x_venc_resources[] = { +	{ +		.start	= DM644X_VENC_BASE, +		.end	= DM644X_VENC_BASE + 0x17f, +		.flags	= IORESOURCE_MEM, +	}, +}; + +#define DM644X_VPSS_MUXSEL_PLL2_MODE          BIT(0) +#define DM644X_VPSS_MUXSEL_VPBECLK_MODE       BIT(1) +#define DM644X_VPSS_VENCLKEN                  BIT(3) +#define DM644X_VPSS_DACCLKEN                  BIT(4) + +static int dm644x_venc_setup_clock(enum vpbe_enc_timings_type type, +				   unsigned int pclock)  { -	vpfe_capture_dev.dev.platform_data = cfg; +	int ret = 0; +	u32 v = DM644X_VPSS_VENCLKEN; + +	switch (type) { +	case VPBE_ENC_STD: +		v |= DM644X_VPSS_DACCLKEN; +		writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL)); +		break; +	case VPBE_ENC_DV_TIMINGS: +		if (pclock <= 27000000) { +			v |= DM644X_VPSS_DACCLKEN; +			writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL)); +		} else { +			/* +			 * For HD, use external clock source since +			 * HD requires higher clock rate +			 */ +			v |= DM644X_VPSS_MUXSEL_VPBECLK_MODE; +			writel(v, DAVINCI_SYSMOD_VIRT(SYSMOD_VPSS_CLKCTL)); +		} +		break; +	default: +		ret  = -EINVAL; +	} + +	return ret;  } +static struct resource dm644x_v4l2_disp_resources[] = { +	{ +		.start	= IRQ_VENCINT, +		.end	= IRQ_VENCINT, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct platform_device dm644x_vpbe_display = { +	.name		= "vpbe-v4l2", +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm644x_v4l2_disp_resources), +	.resource	= dm644x_v4l2_disp_resources, +	.dev		= { +		.dma_mask		= &dm644x_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +static struct venc_platform_data dm644x_venc_pdata = { +	.setup_clock	= dm644x_venc_setup_clock, +}; + +static struct platform_device dm644x_venc_dev = { +	.name		= DM644X_VPBE_VENC_SUBDEV_NAME, +	.id		= -1, +	.num_resources	= ARRAY_SIZE(dm644x_venc_resources), +	.resource	= dm644x_venc_resources, +	.dev		= { +		.dma_mask		= &dm644x_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +		.platform_data		= &dm644x_venc_pdata, +	}, +}; + +static struct platform_device dm644x_vpbe_dev = { +	.name		= "vpbe_controller", +	.id		= -1, +	.dev		= { +		.dma_mask		= &dm644x_video_dma_mask, +		.coherent_dma_mask	= DMA_BIT_MASK(32), +	}, +}; + +static struct resource dm644_gpio_resources[] = { +	{	/* registers */ +		.start	= DAVINCI_GPIO_BASE, +		.end	= DAVINCI_GPIO_BASE + SZ_4K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	{	/* interrupt */ +		.start	= IRQ_GPIOBNK0, +		.end	= IRQ_GPIOBNK4, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct davinci_gpio_platform_data dm644_gpio_platform_data = { +	.ngpio		= 71, +}; + +int __init dm644x_gpio_register(void) +{ +	return davinci_gpio_register(dm644_gpio_resources, +				     ARRAY_SIZE(dm644_gpio_resources), +				     &dm644_gpio_platform_data); +}  /*----------------------------------------------------------------------*/  static struct map_desc dm644x_io_desc[] = { @@ -663,12 +790,6 @@ static struct map_desc dm644x_io_desc[] = {  		.length		= IO_SIZE,  		.type		= MT_DEVICE  	}, -	{ -		.virtual	= SRAM_VIRT, -		.pfn		= __phys_to_pfn(0x00008000), -		.length		= SZ_16K, -		.type		= MT_MEMORY_NONCACHED, -	},  };  /* Contents of JTAG ID register used to identify exact cpu type */ @@ -703,7 +824,7 @@ static struct davinci_timer_info dm644x_timer_info = {  	.clocksource_id	= T0_TOP,  }; -static struct plat_serial8250_port dm644x_serial_platform_data[] = { +static struct plat_serial8250_port dm644x_serial0_platform_data[] = {  	{  		.mapbase	= DAVINCI_UART0_BASE,  		.irq		= IRQ_UARTINT0, @@ -713,6 +834,11 @@ static struct plat_serial8250_port dm644x_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port dm644x_serial1_platform_data[] = { +	{  		.mapbase	= DAVINCI_UART1_BASE,  		.irq		= IRQ_UARTINT1,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -721,6 +847,11 @@ static struct plat_serial8250_port dm644x_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port dm644x_serial2_platform_data[] = { +	{  		.mapbase	= DAVINCI_UART2_BASE,  		.irq		= IRQ_UARTINT2,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -729,16 +860,34 @@ static struct plat_serial8250_port dm644x_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ -		.flags		= 0 -	}, +		.flags	= 0, +	}  }; -static struct platform_device dm644x_serial_device = { -	.name			= "serial8250", -	.id			= PLAT8250_DEV_PLATFORM, -	.dev			= { -		.platform_data	= dm644x_serial_platform_data, +struct platform_device dm644x_serial_device[] = { +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM, +		.dev			= { +			.platform_data	= dm644x_serial0_platform_data, +		}  	}, +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM1, +		.dev			= { +			.platform_data	= dm644x_serial1_platform_data, +		} +	}, +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM2, +		.dev			= { +			.platform_data	= dm644x_serial2_platform_data, +		} +	}, +	{ +	}  };  static struct davinci_soc_info davinci_soc_info_dm644x = { @@ -758,15 +907,9 @@ static struct davinci_soc_info davinci_soc_info_dm644x = {  	.intc_irq_prios 	= dm644x_default_priorities,  	.intc_irq_num		= DAVINCI_N_AINTC_IRQ,  	.timer_info		= &dm644x_timer_info, -	.gpio_type		= GPIO_TYPE_DAVINCI, -	.gpio_base		= DAVINCI_GPIO_BASE, -	.gpio_num		= 71, -	.gpio_irq		= IRQ_GPIOBNK0, -	.serial_dev		= &dm644x_serial_device,  	.emac_pdata		= &dm644x_emac_pdata,  	.sram_dma		= 0x00008000,  	.sram_len		= SZ_16K, -	.reset_device		= &davinci_wdt_device,  };  void __init dm644x_init_asp(struct snd_platform_data *pdata) @@ -779,27 +922,48 @@ void __init dm644x_init_asp(struct snd_platform_data *pdata)  void __init dm644x_init(void)  {  	davinci_common_init(&davinci_soc_info_dm644x); +	davinci_map_sysmod(); +} + +int __init dm644x_init_video(struct vpfe_config *vpfe_cfg, +				struct vpbe_config *vpbe_cfg) +{ +	if (vpfe_cfg || vpbe_cfg) +		platform_device_register(&dm644x_vpss_device); + +	if (vpfe_cfg) { +		dm644x_vpfe_dev.dev.platform_data = vpfe_cfg; +		platform_device_register(&dm644x_ccdc_dev); +		platform_device_register(&dm644x_vpfe_dev); +	} + +	if (vpbe_cfg) { +		dm644x_vpbe_dev.dev.platform_data = vpbe_cfg; +		platform_device_register(&dm644x_osd_dev); +		platform_device_register(&dm644x_venc_dev); +		platform_device_register(&dm644x_vpbe_dev); +		platform_device_register(&dm644x_vpbe_display); +	} + +	return 0;  }  static int __init dm644x_init_devices(void)  { +	int ret = 0; +  	if (!cpu_is_davinci_dm644x())  		return 0; -	/* Add ccdc clock aliases */ -	clk_add_alias("master", dm644x_ccdc_dev.name, "vpss_master", NULL); -	clk_add_alias("slave", dm644x_ccdc_dev.name, "vpss_slave", NULL);  	platform_device_register(&dm644x_edma_device);  	platform_device_register(&dm644x_mdio_device);  	platform_device_register(&dm644x_emac_device); -	clk_add_alias(NULL, dev_name(&dm644x_mdio_device.dev), -		      NULL, &dm644x_emac_device.dev); -	platform_device_register(&dm644x_vpss_device); -	platform_device_register(&dm644x_ccdc_dev); -	platform_device_register(&vpfe_capture_dev); +	ret = davinci_init_wdt(); +	if (ret) +		pr_warn("%s: watchdog init failed: %d\n", __func__, ret); -	return 0; +	return ret;  }  postcore_initcall(dm644x_init_devices); diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c index 1e0f809644b..6c3bbea7d77 100644 --- a/arch/arm/mach-davinci/dm646x.c +++ b/arch/arm/mach-davinci/dm646x.c @@ -8,31 +8,30 @@   * is licensed "as is" without any warranty of any kind, whether express   * or implied.   */ +#include <linux/dma-mapping.h>  #include <linux/init.h>  #include <linux/clk.h>  #include <linux/serial_8250.h>  #include <linux/platform_device.h> -#include <linux/gpio.h> +#include <linux/platform_data/edma.h> +#include <linux/platform_data/gpio-davinci.h>  #include <asm/mach/map.h> -#include <mach/dm646x.h>  #include <mach/cputype.h> -#include <mach/edma.h>  #include <mach/irqs.h>  #include <mach/psc.h>  #include <mach/mux.h>  #include <mach/time.h>  #include <mach/serial.h>  #include <mach/common.h> -#include <mach/asp.h> +#include "davinci.h"  #include "clock.h"  #include "mux.h" +#include "asp.h"  #define DAVINCI_VPIF_BASE       (0x01C12000) -#define VDD3P3V_PWDN_OFFSET	(0x48) -#define VSCLKDIS_OFFSET		(0x6C)  #define VDD3P3V_VID_MASK	(BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\  					BIT_MASK(0)) @@ -42,8 +41,16 @@  /*   * Device specific clocks   */ +#define DM646X_REF_FREQ		27000000  #define DM646X_AUX_FREQ		24000000 +#define DM646X_EMAC_BASE		0x01c80000 +#define DM646X_EMAC_MDIO_BASE		(DM646X_EMAC_BASE + 0x4000) +#define DM646X_EMAC_CNTRL_OFFSET	0x0000 +#define DM646X_EMAC_CNTRL_MOD_OFFSET	0x1000 +#define DM646X_EMAC_CNTRL_RAM_OFFSET	0x2000 +#define DM646X_EMAC_CNTRL_RAM_SIZE	0x2000 +  static struct pll_data pll1_data = {  	.num       = 1,  	.phys_base = DAVINCI_PLL1_BASE, @@ -56,6 +63,8 @@ static struct pll_data pll2_data = {  static struct clk ref_clk = {  	.name = "ref_clk", +	.rate = DM646X_REF_FREQ, +	.set_rate = davinci_simple_set_rate,  };  static struct clk aux_clkin = { @@ -157,7 +166,6 @@ static struct clk dsp_clk = {  	.name = "dsp",  	.parent = &pll1_sysclk1,  	.lpsc = DM646X_LPSC_C64X_CPU, -	.flags = PSC_DSP,  	.usecount = 1,			/* REVISIT how to disable? */  }; @@ -334,20 +342,21 @@ static struct clk_lookup dm646x_clks[] = {  	CLK(NULL, "edma_tc1", &edma_tc1_clk),  	CLK(NULL, "edma_tc2", &edma_tc2_clk),  	CLK(NULL, "edma_tc3", &edma_tc3_clk), -	CLK(NULL, "uart0", &uart0_clk), -	CLK(NULL, "uart1", &uart1_clk), -	CLK(NULL, "uart2", &uart2_clk), +	CLK("serial8250.0", NULL, &uart0_clk), +	CLK("serial8250.1", NULL, &uart1_clk), +	CLK("serial8250.2", NULL, &uart2_clk),  	CLK("i2c_davinci.1", NULL, &i2c_clk),  	CLK(NULL, "gpio", &gpio_clk),  	CLK("davinci-mcasp.0", NULL, &mcasp0_clk),  	CLK("davinci-mcasp.1", NULL, &mcasp1_clk),  	CLK(NULL, "aemif", &aemif_clk),  	CLK("davinci_emac.1", NULL, &emac_clk), +	CLK("davinci_mdio.0", "fck", &emac_clk),  	CLK(NULL, "pwm0", &pwm0_clk),  	CLK(NULL, "pwm1", &pwm1_clk),  	CLK(NULL, "timer0", &timer0_clk),  	CLK(NULL, "timer1", &timer1_clk), -	CLK("watchdog", NULL, &timer2_clk), +	CLK("davinci-wdt", NULL, &timer2_clk),  	CLK("palm_bk3710", NULL, &ide_clk),  	CLK(NULL, "vpif0", &vpif0_clk),  	CLK(NULL, "vpif1", &vpif1_clk), @@ -523,17 +532,7 @@ static u8 dm646x_default_priorities[DAVINCI_N_AINTC_IRQ] = {  /*----------------------------------------------------------------------*/  /* Four Transfer Controllers on DM646x */ -static const s8 -dm646x_queue_tc_mapping[][2] = { -	/* {event queue no, TC no} */ -	{0, 0}, -	{1, 1}, -	{2, 2}, -	{3, 3}, -	{-1, -1}, -}; - -static const s8 +static s8  dm646x_queue_priority_mapping[][2] = {  	/* {event queue no, Priority} */  	{0, 4}, @@ -544,13 +543,8 @@ dm646x_queue_priority_mapping[][2] = {  };  static struct edma_soc_info edma_cc0_info = { -	.n_channel		= 64, -	.n_region		= 6,	/* 0-1, 4-7 */ -	.n_slot			= 512, -	.n_tc			= 4, -	.n_cc			= 1, -	.queue_tc_mapping	= dm646x_queue_tc_mapping,  	.queue_priority_mapping	= dm646x_queue_priority_mapping, +	.default_queue		= EVENTQ_1,  };  static struct edma_soc_info *dm646x_edma_info[EDMA_MAX_CC] = { @@ -611,7 +605,7 @@ static struct platform_device dm646x_edma_device = {  static struct resource dm646x_mcasp0_resources[] = {  	{ -		.name	= "mcasp0", +		.name	= "mpu",  		.start 	= DAVINCI_DM646X_MCASP0_REG_BASE,  		.end 	= DAVINCI_DM646X_MCASP0_REG_BASE + (SZ_1K << 1) - 1,  		.flags 	= IORESOURCE_MEM, @@ -631,7 +625,7 @@ static struct resource dm646x_mcasp0_resources[] = {  static struct resource dm646x_mcasp1_resources[] = {  	{ -		.name	= "mcasp1", +		.name	= "mpu",  		.start	= DAVINCI_DM646X_MCASP1_REG_BASE,  		.end	= DAVINCI_DM646X_MCASP1_REG_BASE + (SZ_1K << 1) - 1,  		.flags	= IORESOURCE_MEM, @@ -738,6 +732,29 @@ static struct platform_device vpif_capture_dev = {  	.num_resources	= ARRAY_SIZE(vpif_capture_resource),  }; +static struct resource dm646x_gpio_resources[] = { +	{	/* registers */ +		.start	= DAVINCI_GPIO_BASE, +		.end	= DAVINCI_GPIO_BASE + SZ_4K - 1, +		.flags	= IORESOURCE_MEM, +	}, +	{	/* interrupt */ +		.start	= IRQ_DM646X_GPIOBNK0, +		.end	= IRQ_DM646X_GPIOBNK2, +		.flags	= IORESOURCE_IRQ, +	}, +}; + +static struct davinci_gpio_platform_data dm646x_gpio_platform_data = { +	.ngpio		= 43, +}; + +int __init dm646x_gpio_register(void) +{ +	return davinci_gpio_register(dm646x_gpio_resources, +				     ARRAY_SIZE(dm646x_gpio_resources), +				     &dm646x_gpio_platform_data); +}  /*----------------------------------------------------------------------*/  static struct map_desc dm646x_io_desc[] = { @@ -747,12 +764,6 @@ static struct map_desc dm646x_io_desc[] = {  		.length		= IO_SIZE,  		.type		= MT_DEVICE  	}, -	{ -		.virtual	= SRAM_VIRT, -		.pfn		= __phys_to_pfn(0x00010000), -		.length		= SZ_32K, -		.type		= MT_MEMORY_NONCACHED, -	},  };  /* Contents of JTAG ID register used to identify exact cpu type */ @@ -787,7 +798,7 @@ static struct davinci_timer_info dm646x_timer_info = {  	.clocksource_id	= T0_TOP,  }; -static struct plat_serial8250_port dm646x_serial_platform_data[] = { +static struct plat_serial8250_port dm646x_serial0_platform_data[] = {  	{  		.mapbase	= DAVINCI_UART0_BASE,  		.irq		= IRQ_UARTINT0, @@ -797,6 +808,11 @@ static struct plat_serial8250_port dm646x_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port dm646x_serial1_platform_data[] = { +	{  		.mapbase	= DAVINCI_UART1_BASE,  		.irq		= IRQ_UARTINT1,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -805,6 +821,11 @@ static struct plat_serial8250_port dm646x_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ +		.flags	= 0, +	} +}; +static struct plat_serial8250_port dm646x_serial2_platform_data[] = { +	{  		.mapbase	= DAVINCI_UART2_BASE,  		.irq		= IRQ_DM646X_UARTINT2,  		.flags		= UPF_BOOT_AUTOCONF | UPF_SKIP_TEST | @@ -813,16 +834,34 @@ static struct plat_serial8250_port dm646x_serial_platform_data[] = {  		.regshift	= 2,  	},  	{ -		.flags		= 0 -	}, +		.flags	= 0, +	}  }; -static struct platform_device dm646x_serial_device = { -	.name			= "serial8250", -	.id			= PLAT8250_DEV_PLATFORM, -	.dev			= { -		.platform_data	= dm646x_serial_platform_data, +struct platform_device dm646x_serial_device[] = { +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM, +		.dev			= { +			.platform_data	= dm646x_serial0_platform_data, +		}  	}, +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM1, +		.dev			= { +			.platform_data	= dm646x_serial1_platform_data, +		} +	}, +	{ +		.name			= "serial8250", +		.id			= PLAT8250_DEV_PLATFORM2, +		.dev			= { +			.platform_data	= dm646x_serial2_platform_data, +		} +	}, +	{ +	}  };  static struct davinci_soc_info davinci_soc_info_dm646x = { @@ -842,15 +881,9 @@ static struct davinci_soc_info davinci_soc_info_dm646x = {  	.intc_irq_prios		= dm646x_default_priorities,  	.intc_irq_num		= DAVINCI_N_AINTC_IRQ,  	.timer_info		= &dm646x_timer_info, -	.gpio_type		= GPIO_TYPE_DAVINCI, -	.gpio_base		= DAVINCI_GPIO_BASE, -	.gpio_num		= 43, /* Only 33 usable */ -	.gpio_irq		= IRQ_DM646X_GPIOBNK0, -	.serial_dev		= &dm646x_serial_device,  	.emac_pdata		= &dm646x_emac_pdata,  	.sram_dma		= 0x10010000,  	.sram_len		= SZ_32K, -	.reset_device		= &davinci_wdt_device,  };  void __init dm646x_init_mcasp0(struct snd_platform_data *pdata) @@ -870,15 +903,14 @@ void dm646x_setup_vpif(struct vpif_display_config *display_config,  		       struct vpif_capture_config *capture_config)  {  	unsigned int value; -	void __iomem *base = IO_ADDRESS(DAVINCI_SYSTEM_MODULE_BASE); -	value = __raw_readl(base + VSCLKDIS_OFFSET); +	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS));  	value &= ~VSCLKDIS_MASK; -	__raw_writel(value, base + VSCLKDIS_OFFSET); +	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VSCLKDIS)); -	value = __raw_readl(base + VDD3P3V_PWDN_OFFSET); +	value = __raw_readl(DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));  	value &= ~VDD3P3V_VID_MASK; -	__raw_writel(value, base + VDD3P3V_PWDN_OFFSET); +	__raw_writel(value, DAVINCI_SYSMOD_VIRT(SYSMOD_VDD3P3VPWDN));  	davinci_cfg_reg(DM646X_STSOMUX_DISABLE);  	davinci_cfg_reg(DM646X_STSIMUX_DISABLE); @@ -901,20 +933,24 @@ int __init dm646x_init_edma(struct edma_rsv_info *rsv)  void __init dm646x_init(void)  { -	dm646x_board_setup_refclk(&ref_clk);  	davinci_common_init(&davinci_soc_info_dm646x); +	davinci_map_sysmod();  }  static int __init dm646x_init_devices(void)  { +	int ret = 0; +  	if (!cpu_is_davinci_dm646x())  		return 0;  	platform_device_register(&dm646x_mdio_device);  	platform_device_register(&dm646x_emac_device); -	clk_add_alias(NULL, dev_name(&dm646x_mdio_device.dev), -		      NULL, &dm646x_emac_device.dev); -	return 0; +	ret = davinci_init_wdt(); +	if (ret) +		pr_warn("%s: watchdog init failed: %d\n", __func__, ret); + +	return ret;  }  postcore_initcall(dm646x_init_devices); diff --git a/arch/arm/mach-davinci/dma.c b/arch/arm/mach-davinci/dma.c deleted file mode 100644 index 6b9669869c4..00000000000 --- a/arch/arm/mach-davinci/dma.c +++ /dev/null @@ -1,1596 +0,0 @@ -/* - * EDMA3 support for DaVinci - * - * Copyright (C) 2006-2009 Texas Instruments. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/module.h> -#include <linux/interrupt.h> -#include <linux/platform_device.h> -#include <linux/io.h> -#include <linux/slab.h> - -#include <mach/edma.h> - -/* Offsets matching "struct edmacc_param" */ -#define PARM_OPT		0x00 -#define PARM_SRC		0x04 -#define PARM_A_B_CNT		0x08 -#define PARM_DST		0x0c -#define PARM_SRC_DST_BIDX	0x10 -#define PARM_LINK_BCNTRLD	0x14 -#define PARM_SRC_DST_CIDX	0x18 -#define PARM_CCNT		0x1c - -#define PARM_SIZE		0x20 - -/* Offsets for EDMA CC global channel registers and their shadows */ -#define SH_ER		0x00	/* 64 bits */ -#define SH_ECR		0x08	/* 64 bits */ -#define SH_ESR		0x10	/* 64 bits */ -#define SH_CER		0x18	/* 64 bits */ -#define SH_EER		0x20	/* 64 bits */ -#define SH_EECR		0x28	/* 64 bits */ -#define SH_EESR		0x30	/* 64 bits */ -#define SH_SER		0x38	/* 64 bits */ -#define SH_SECR		0x40	/* 64 bits */ -#define SH_IER		0x50	/* 64 bits */ -#define SH_IECR		0x58	/* 64 bits */ -#define SH_IESR		0x60	/* 64 bits */ -#define SH_IPR		0x68	/* 64 bits */ -#define SH_ICR		0x70	/* 64 bits */ -#define SH_IEVAL	0x78 -#define SH_QER		0x80 -#define SH_QEER		0x84 -#define SH_QEECR	0x88 -#define SH_QEESR	0x8c -#define SH_QSER		0x90 -#define SH_QSECR	0x94 -#define SH_SIZE		0x200 - -/* Offsets for EDMA CC global registers */ -#define EDMA_REV	0x0000 -#define EDMA_CCCFG	0x0004 -#define EDMA_QCHMAP	0x0200	/* 8 registers */ -#define EDMA_DMAQNUM	0x0240	/* 8 registers (4 on OMAP-L1xx) */ -#define EDMA_QDMAQNUM	0x0260 -#define EDMA_QUETCMAP	0x0280 -#define EDMA_QUEPRI	0x0284 -#define EDMA_EMR	0x0300	/* 64 bits */ -#define EDMA_EMCR	0x0308	/* 64 bits */ -#define EDMA_QEMR	0x0310 -#define EDMA_QEMCR	0x0314 -#define EDMA_CCERR	0x0318 -#define EDMA_CCERRCLR	0x031c -#define EDMA_EEVAL	0x0320 -#define EDMA_DRAE	0x0340	/* 4 x 64 bits*/ -#define EDMA_QRAE	0x0380	/* 4 registers */ -#define EDMA_QUEEVTENTRY	0x0400	/* 2 x 16 registers */ -#define EDMA_QSTAT	0x0600	/* 2 registers */ -#define EDMA_QWMTHRA	0x0620 -#define EDMA_QWMTHRB	0x0624 -#define EDMA_CCSTAT	0x0640 - -#define EDMA_M		0x1000	/* global channel registers */ -#define EDMA_ECR	0x1008 -#define EDMA_ECRH	0x100C -#define EDMA_SHADOW0	0x2000	/* 4 regions shadowing global channels */ -#define EDMA_PARM	0x4000	/* 128 param entries */ - -#define PARM_OFFSET(param_no)	(EDMA_PARM + ((param_no) << 5)) - -#define EDMA_DCHMAP	0x0100  /* 64 registers */ -#define CHMAP_EXIST	BIT(24) - -#define EDMA_MAX_DMACH           64 -#define EDMA_MAX_PARAMENTRY     512 - -/*****************************************************************************/ - -static void __iomem *edmacc_regs_base[EDMA_MAX_CC]; - -static inline unsigned int edma_read(unsigned ctlr, int offset) -{ -	return (unsigned int)__raw_readl(edmacc_regs_base[ctlr] + offset); -} - -static inline void edma_write(unsigned ctlr, int offset, int val) -{ -	__raw_writel(val, edmacc_regs_base[ctlr] + offset); -} -static inline void edma_modify(unsigned ctlr, int offset, unsigned and, -		unsigned or) -{ -	unsigned val = edma_read(ctlr, offset); -	val &= and; -	val |= or; -	edma_write(ctlr, offset, val); -} -static inline void edma_and(unsigned ctlr, int offset, unsigned and) -{ -	unsigned val = edma_read(ctlr, offset); -	val &= and; -	edma_write(ctlr, offset, val); -} -static inline void edma_or(unsigned ctlr, int offset, unsigned or) -{ -	unsigned val = edma_read(ctlr, offset); -	val |= or; -	edma_write(ctlr, offset, val); -} -static inline unsigned int edma_read_array(unsigned ctlr, int offset, int i) -{ -	return edma_read(ctlr, offset + (i << 2)); -} -static inline void edma_write_array(unsigned ctlr, int offset, int i, -		unsigned val) -{ -	edma_write(ctlr, offset + (i << 2), val); -} -static inline void edma_modify_array(unsigned ctlr, int offset, int i, -		unsigned and, unsigned or) -{ -	edma_modify(ctlr, offset + (i << 2), and, or); -} -static inline void edma_or_array(unsigned ctlr, int offset, int i, unsigned or) -{ -	edma_or(ctlr, offset + (i << 2), or); -} -static inline void edma_or_array2(unsigned ctlr, int offset, int i, int j, -		unsigned or) -{ -	edma_or(ctlr, offset + ((i*2 + j) << 2), or); -} -static inline void edma_write_array2(unsigned ctlr, int offset, int i, int j, -		unsigned val) -{ -	edma_write(ctlr, offset + ((i*2 + j) << 2), val); -} -static inline unsigned int edma_shadow0_read(unsigned ctlr, int offset) -{ -	return edma_read(ctlr, EDMA_SHADOW0 + offset); -} -static inline unsigned int edma_shadow0_read_array(unsigned ctlr, int offset, -		int i) -{ -	return edma_read(ctlr, EDMA_SHADOW0 + offset + (i << 2)); -} -static inline void edma_shadow0_write(unsigned ctlr, int offset, unsigned val) -{ -	edma_write(ctlr, EDMA_SHADOW0 + offset, val); -} -static inline void edma_shadow0_write_array(unsigned ctlr, int offset, int i, -		unsigned val) -{ -	edma_write(ctlr, EDMA_SHADOW0 + offset + (i << 2), val); -} -static inline unsigned int edma_parm_read(unsigned ctlr, int offset, -		int param_no) -{ -	return edma_read(ctlr, EDMA_PARM + offset + (param_no << 5)); -} -static inline void edma_parm_write(unsigned ctlr, int offset, int param_no, -		unsigned val) -{ -	edma_write(ctlr, EDMA_PARM + offset + (param_no << 5), val); -} -static inline void edma_parm_modify(unsigned ctlr, int offset, int param_no, -		unsigned and, unsigned or) -{ -	edma_modify(ctlr, EDMA_PARM + offset + (param_no << 5), and, or); -} -static inline void edma_parm_and(unsigned ctlr, int offset, int param_no, -		unsigned and) -{ -	edma_and(ctlr, EDMA_PARM + offset + (param_no << 5), and); -} -static inline void edma_parm_or(unsigned ctlr, int offset, int param_no, -		unsigned or) -{ -	edma_or(ctlr, EDMA_PARM + offset + (param_no << 5), or); -} - -static inline void set_bits(int offset, int len, unsigned long *p) -{ -	for (; len > 0; len--) -		set_bit(offset + (len - 1), p); -} - -static inline void clear_bits(int offset, int len, unsigned long *p) -{ -	for (; len > 0; len--) -		clear_bit(offset + (len - 1), p); -} - -/*****************************************************************************/ - -/* actual number of DMA channels and slots on this silicon */ -struct edma { -	/* how many dma resources of each type */ -	unsigned	num_channels; -	unsigned	num_region; -	unsigned	num_slots; -	unsigned	num_tc; -	unsigned	num_cc; -	enum dma_event_q 	default_queue; - -	/* list of channels with no even trigger; terminated by "-1" */ -	const s8	*noevent; - -	/* The edma_inuse bit for each PaRAM slot is clear unless the -	 * channel is in use ... by ARM or DSP, for QDMA, or whatever. -	 */ -	DECLARE_BITMAP(edma_inuse, EDMA_MAX_PARAMENTRY); - -	/* The edma_unused bit for each channel is clear unless -	 * it is not being used on this platform. It uses a bit -	 * of SOC-specific initialization code. -	 */ -	DECLARE_BITMAP(edma_unused, EDMA_MAX_DMACH); - -	unsigned	irq_res_start; -	unsigned	irq_res_end; - -	struct dma_interrupt_data { -		void (*callback)(unsigned channel, unsigned short ch_status, -				void *data); -		void *data; -	} intr_data[EDMA_MAX_DMACH]; -}; - -static struct edma *edma_cc[EDMA_MAX_CC]; -static int arch_num_cc; - -/* dummy param set used to (re)initialize parameter RAM slots */ -static const struct edmacc_param dummy_paramset = { -	.link_bcntrld = 0xffff, -	.ccnt = 1, -}; - -/*****************************************************************************/ - -static void map_dmach_queue(unsigned ctlr, unsigned ch_no, -		enum dma_event_q queue_no) -{ -	int bit = (ch_no & 0x7) * 4; - -	/* default to low priority queue */ -	if (queue_no == EVENTQ_DEFAULT) -		queue_no = edma_cc[ctlr]->default_queue; - -	queue_no &= 7; -	edma_modify_array(ctlr, EDMA_DMAQNUM, (ch_no >> 3), -			~(0x7 << bit), queue_no << bit); -} - -static void __init map_queue_tc(unsigned ctlr, int queue_no, int tc_no) -{ -	int bit = queue_no * 4; -	edma_modify(ctlr, EDMA_QUETCMAP, ~(0x7 << bit), ((tc_no & 0x7) << bit)); -} - -static void __init assign_priority_to_queue(unsigned ctlr, int queue_no, -		int priority) -{ -	int bit = queue_no * 4; -	edma_modify(ctlr, EDMA_QUEPRI, ~(0x7 << bit), -			((priority & 0x7) << bit)); -} - -/** - * map_dmach_param - Maps channel number to param entry number - * - * This maps the dma channel number to param entry numberter. In - * other words using the DMA channel mapping registers a param entry - * can be mapped to any channel - * - * Callers are responsible for ensuring the channel mapping logic is - * included in that particular EDMA variant (Eg : dm646x) - * - */ -static void __init map_dmach_param(unsigned ctlr) -{ -	int i; -	for (i = 0; i < EDMA_MAX_DMACH; i++) -		edma_write_array(ctlr, EDMA_DCHMAP , i , (i << 5)); -} - -static inline void -setup_dma_interrupt(unsigned lch, -	void (*callback)(unsigned channel, u16 ch_status, void *data), -	void *data) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(lch); -	lch = EDMA_CHAN_SLOT(lch); - -	if (!callback) -		edma_shadow0_write_array(ctlr, SH_IECR, lch >> 5, -				BIT(lch & 0x1f)); - -	edma_cc[ctlr]->intr_data[lch].callback = callback; -	edma_cc[ctlr]->intr_data[lch].data = data; - -	if (callback) { -		edma_shadow0_write_array(ctlr, SH_ICR, lch >> 5, -				BIT(lch & 0x1f)); -		edma_shadow0_write_array(ctlr, SH_IESR, lch >> 5, -				BIT(lch & 0x1f)); -	} -} - -static int irq2ctlr(int irq) -{ -	if (irq >= edma_cc[0]->irq_res_start && irq <= edma_cc[0]->irq_res_end) -		return 0; -	else if (irq >= edma_cc[1]->irq_res_start && -		irq <= edma_cc[1]->irq_res_end) -		return 1; - -	return -1; -} - -/****************************************************************************** - * - * DMA interrupt handler - * - *****************************************************************************/ -static irqreturn_t dma_irq_handler(int irq, void *data) -{ -	int i; -	int ctlr; -	unsigned int cnt = 0; - -	ctlr = irq2ctlr(irq); -	if (ctlr < 0) -		return IRQ_NONE; - -	dev_dbg(data, "dma_irq_handler\n"); - -	if ((edma_shadow0_read_array(ctlr, SH_IPR, 0) == 0) && -	    (edma_shadow0_read_array(ctlr, SH_IPR, 1) == 0)) -		return IRQ_NONE; - -	while (1) { -		int j; -		if (edma_shadow0_read_array(ctlr, SH_IPR, 0) & -				edma_shadow0_read_array(ctlr, SH_IER, 0)) -			j = 0; -		else if (edma_shadow0_read_array(ctlr, SH_IPR, 1) & -				edma_shadow0_read_array(ctlr, SH_IER, 1)) -			j = 1; -		else -			break; -		dev_dbg(data, "IPR%d %08x\n", j, -				edma_shadow0_read_array(ctlr, SH_IPR, j)); -		for (i = 0; i < 32; i++) { -			int k = (j << 5) + i; -			if ((edma_shadow0_read_array(ctlr, SH_IPR, j) & BIT(i)) -					&& (edma_shadow0_read_array(ctlr, -							SH_IER, j) & BIT(i))) { -				/* Clear the corresponding IPR bits */ -				edma_shadow0_write_array(ctlr, SH_ICR, j, -							BIT(i)); -				if (edma_cc[ctlr]->intr_data[k].callback) -					edma_cc[ctlr]->intr_data[k].callback( -						k, DMA_COMPLETE, -						edma_cc[ctlr]->intr_data[k]. -						data); -			} -		} -		cnt++; -		if (cnt > 10) -			break; -	} -	edma_shadow0_write(ctlr, SH_IEVAL, 1); -	return IRQ_HANDLED; -} - -/****************************************************************************** - * - * DMA error interrupt handler - * - *****************************************************************************/ -static irqreturn_t dma_ccerr_handler(int irq, void *data) -{ -	int i; -	int ctlr; -	unsigned int cnt = 0; - -	ctlr = irq2ctlr(irq); -	if (ctlr < 0) -		return IRQ_NONE; - -	dev_dbg(data, "dma_ccerr_handler\n"); - -	if ((edma_read_array(ctlr, EDMA_EMR, 0) == 0) && -	    (edma_read_array(ctlr, EDMA_EMR, 1) == 0) && -	    (edma_read(ctlr, EDMA_QEMR) == 0) && -	    (edma_read(ctlr, EDMA_CCERR) == 0)) -		return IRQ_NONE; - -	while (1) { -		int j = -1; -		if (edma_read_array(ctlr, EDMA_EMR, 0)) -			j = 0; -		else if (edma_read_array(ctlr, EDMA_EMR, 1)) -			j = 1; -		if (j >= 0) { -			dev_dbg(data, "EMR%d %08x\n", j, -					edma_read_array(ctlr, EDMA_EMR, j)); -			for (i = 0; i < 32; i++) { -				int k = (j << 5) + i; -				if (edma_read_array(ctlr, EDMA_EMR, j) & -							BIT(i)) { -					/* Clear the corresponding EMR bits */ -					edma_write_array(ctlr, EDMA_EMCR, j, -							BIT(i)); -					/* Clear any SER */ -					edma_shadow0_write_array(ctlr, SH_SECR, -								j, BIT(i)); -					if (edma_cc[ctlr]->intr_data[k]. -								callback) { -						edma_cc[ctlr]->intr_data[k]. -						callback(k, -						DMA_CC_ERROR, -						edma_cc[ctlr]->intr_data -						[k].data); -					} -				} -			} -		} else if (edma_read(ctlr, EDMA_QEMR)) { -			dev_dbg(data, "QEMR %02x\n", -				edma_read(ctlr, EDMA_QEMR)); -			for (i = 0; i < 8; i++) { -				if (edma_read(ctlr, EDMA_QEMR) & BIT(i)) { -					/* Clear the corresponding IPR bits */ -					edma_write(ctlr, EDMA_QEMCR, BIT(i)); -					edma_shadow0_write(ctlr, SH_QSECR, -								BIT(i)); - -					/* NOTE:  not reported!! */ -				} -			} -		} else if (edma_read(ctlr, EDMA_CCERR)) { -			dev_dbg(data, "CCERR %08x\n", -				edma_read(ctlr, EDMA_CCERR)); -			/* FIXME:  CCERR.BIT(16) ignored!  much better -			 * to just write CCERRCLR with CCERR value... -			 */ -			for (i = 0; i < 8; i++) { -				if (edma_read(ctlr, EDMA_CCERR) & BIT(i)) { -					/* Clear the corresponding IPR bits */ -					edma_write(ctlr, EDMA_CCERRCLR, BIT(i)); - -					/* NOTE:  not reported!! */ -				} -			} -		} -		if ((edma_read_array(ctlr, EDMA_EMR, 0) == 0) && -		    (edma_read_array(ctlr, EDMA_EMR, 1) == 0) && -		    (edma_read(ctlr, EDMA_QEMR) == 0) && -		    (edma_read(ctlr, EDMA_CCERR) == 0)) -			break; -		cnt++; -		if (cnt > 10) -			break; -	} -	edma_write(ctlr, EDMA_EEVAL, 1); -	return IRQ_HANDLED; -} - -/****************************************************************************** - * - * Transfer controller error interrupt handlers - * - *****************************************************************************/ - -#define tc_errs_handled	false	/* disabled as long as they're NOPs */ - -static irqreturn_t dma_tc0err_handler(int irq, void *data) -{ -	dev_dbg(data, "dma_tc0err_handler\n"); -	return IRQ_HANDLED; -} - -static irqreturn_t dma_tc1err_handler(int irq, void *data) -{ -	dev_dbg(data, "dma_tc1err_handler\n"); -	return IRQ_HANDLED; -} - -static int reserve_contiguous_slots(int ctlr, unsigned int id, -				     unsigned int num_slots, -				     unsigned int start_slot) -{ -	int i, j; -	unsigned int count = num_slots; -	int stop_slot = start_slot; -	DECLARE_BITMAP(tmp_inuse, EDMA_MAX_PARAMENTRY); - -	for (i = start_slot; i < edma_cc[ctlr]->num_slots; ++i) { -		j = EDMA_CHAN_SLOT(i); -		if (!test_and_set_bit(j, edma_cc[ctlr]->edma_inuse)) { -			/* Record our current beginning slot */ -			if (count == num_slots) -				stop_slot = i; - -			count--; -			set_bit(j, tmp_inuse); - -			if (count == 0) -				break; -		} else { -			clear_bit(j, tmp_inuse); - -			if (id == EDMA_CONT_PARAMS_FIXED_EXACT) { -				stop_slot = i; -				break; -			} else { -				count = num_slots; -			} -		} -	} - -	/* -	 * We have to clear any bits that we set -	 * if we run out parameter RAM slots, i.e we do find a set -	 * of contiguous parameter RAM slots but do not find the exact number -	 * requested as we may reach the total number of parameter RAM slots -	 */ -	if (i == edma_cc[ctlr]->num_slots) -		stop_slot = i; - -	for (j = start_slot; j < stop_slot; j++) -		if (test_bit(j, tmp_inuse)) -			clear_bit(j, edma_cc[ctlr]->edma_inuse); - -	if (count) -		return -EBUSY; - -	for (j = i - num_slots + 1; j <= i; ++j) -		memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(j), -			&dummy_paramset, PARM_SIZE); - -	return EDMA_CTLR_CHAN(ctlr, i - num_slots + 1); -} - -static int prepare_unused_channel_list(struct device *dev, void *data) -{ -	struct platform_device *pdev = to_platform_device(dev); -	int i, ctlr; - -	for (i = 0; i < pdev->num_resources; i++) { -		if ((pdev->resource[i].flags & IORESOURCE_DMA) && -				(int)pdev->resource[i].start >= 0) { -			ctlr = EDMA_CTLR(pdev->resource[i].start); -			clear_bit(EDMA_CHAN_SLOT(pdev->resource[i].start), -					edma_cc[ctlr]->edma_unused); -		} -	} - -	return 0; -} - -/*-----------------------------------------------------------------------*/ - -static bool unused_chan_list_done; - -/* Resource alloc/free:  dma channels, parameter RAM slots */ - -/** - * edma_alloc_channel - allocate DMA channel and paired parameter RAM - * @channel: specific channel to allocate; negative for "any unmapped channel" - * @callback: optional; to be issued on DMA completion or errors - * @data: passed to callback - * @eventq_no: an EVENTQ_* constant, used to choose which Transfer - *	Controller (TC) executes requests using this channel.  Use - *	EVENTQ_DEFAULT unless you really need a high priority queue. - * - * This allocates a DMA channel and its associated parameter RAM slot. - * The parameter RAM is initialized to hold a dummy transfer. - * - * Normal use is to pass a specific channel number as @channel, to make - * use of hardware events mapped to that channel.  When the channel will - * be used only for software triggering or event chaining, channels not - * mapped to hardware events (or mapped to unused events) are preferable. - * - * DMA transfers start from a channel using edma_start(), or by - * chaining.  When the transfer described in that channel's parameter RAM - * slot completes, that slot's data may be reloaded through a link. - * - * DMA errors are only reported to the @callback associated with the - * channel driving that transfer, but transfer completion callbacks can - * be sent to another channel under control of the TCC field in - * the option word of the transfer's parameter RAM set.  Drivers must not - * use DMA transfer completion callbacks for channels they did not allocate. - * (The same applies to TCC codes used in transfer chaining.) - * - * Returns the number of the channel, else negative errno. - */ -int edma_alloc_channel(int channel, -		void (*callback)(unsigned channel, u16 ch_status, void *data), -		void *data, -		enum dma_event_q eventq_no) -{ -	unsigned i, done = 0, ctlr = 0; -	int ret = 0; - -	if (!unused_chan_list_done) { -		/* -		 * Scan all the platform devices to find out the EDMA channels -		 * used and clear them in the unused list, making the rest -		 * available for ARM usage. -		 */ -		ret = bus_for_each_dev(&platform_bus_type, NULL, NULL, -				prepare_unused_channel_list); -		if (ret < 0) -			return ret; - -		unused_chan_list_done = true; -	} - -	if (channel >= 0) { -		ctlr = EDMA_CTLR(channel); -		channel = EDMA_CHAN_SLOT(channel); -	} - -	if (channel < 0) { -		for (i = 0; i < arch_num_cc; i++) { -			channel = 0; -			for (;;) { -				channel = find_next_bit(edma_cc[i]->edma_unused, -						edma_cc[i]->num_channels, -						channel); -				if (channel == edma_cc[i]->num_channels) -					break; -				if (!test_and_set_bit(channel, -						edma_cc[i]->edma_inuse)) { -					done = 1; -					ctlr = i; -					break; -				} -				channel++; -			} -			if (done) -				break; -		} -		if (!done) -			return -ENOMEM; -	} else if (channel >= edma_cc[ctlr]->num_channels) { -		return -EINVAL; -	} else if (test_and_set_bit(channel, edma_cc[ctlr]->edma_inuse)) { -		return -EBUSY; -	} - -	/* ensure access through shadow region 0 */ -	edma_or_array2(ctlr, EDMA_DRAE, 0, channel >> 5, BIT(channel & 0x1f)); - -	/* ensure no events are pending */ -	edma_stop(EDMA_CTLR_CHAN(ctlr, channel)); -	memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(channel), -			&dummy_paramset, PARM_SIZE); - -	if (callback) -		setup_dma_interrupt(EDMA_CTLR_CHAN(ctlr, channel), -					callback, data); - -	map_dmach_queue(ctlr, channel, eventq_no); - -	return EDMA_CTLR_CHAN(ctlr, channel); -} -EXPORT_SYMBOL(edma_alloc_channel); - - -/** - * edma_free_channel - deallocate DMA channel - * @channel: dma channel returned from edma_alloc_channel() - * - * This deallocates the DMA channel and associated parameter RAM slot - * allocated by edma_alloc_channel(). - * - * Callers are responsible for ensuring the channel is inactive, and - * will not be reactivated by linking, chaining, or software calls to - * edma_start(). - */ -void edma_free_channel(unsigned channel) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(channel); -	channel = EDMA_CHAN_SLOT(channel); - -	if (channel >= edma_cc[ctlr]->num_channels) -		return; - -	setup_dma_interrupt(channel, NULL, NULL); -	/* REVISIT should probably take out of shadow region 0 */ - -	memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(channel), -			&dummy_paramset, PARM_SIZE); -	clear_bit(channel, edma_cc[ctlr]->edma_inuse); -} -EXPORT_SYMBOL(edma_free_channel); - -/** - * edma_alloc_slot - allocate DMA parameter RAM - * @slot: specific slot to allocate; negative for "any unused slot" - * - * This allocates a parameter RAM slot, initializing it to hold a - * dummy transfer.  Slots allocated using this routine have not been - * mapped to a hardware DMA channel, and will normally be used by - * linking to them from a slot associated with a DMA channel. - * - * Normal use is to pass EDMA_SLOT_ANY as the @slot, but specific - * slots may be allocated on behalf of DSP firmware. - * - * Returns the number of the slot, else negative errno. - */ -int edma_alloc_slot(unsigned ctlr, int slot) -{ -	if (slot >= 0) -		slot = EDMA_CHAN_SLOT(slot); - -	if (slot < 0) { -		slot = edma_cc[ctlr]->num_channels; -		for (;;) { -			slot = find_next_zero_bit(edma_cc[ctlr]->edma_inuse, -					edma_cc[ctlr]->num_slots, slot); -			if (slot == edma_cc[ctlr]->num_slots) -				return -ENOMEM; -			if (!test_and_set_bit(slot, edma_cc[ctlr]->edma_inuse)) -				break; -		} -	} else if (slot < edma_cc[ctlr]->num_channels || -			slot >= edma_cc[ctlr]->num_slots) { -		return -EINVAL; -	} else if (test_and_set_bit(slot, edma_cc[ctlr]->edma_inuse)) { -		return -EBUSY; -	} - -	memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot), -			&dummy_paramset, PARM_SIZE); - -	return EDMA_CTLR_CHAN(ctlr, slot); -} -EXPORT_SYMBOL(edma_alloc_slot); - -/** - * edma_free_slot - deallocate DMA parameter RAM - * @slot: parameter RAM slot returned from edma_alloc_slot() - * - * This deallocates the parameter RAM slot allocated by edma_alloc_slot(). - * Callers are responsible for ensuring the slot is inactive, and will - * not be activated. - */ -void edma_free_slot(unsigned slot) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot < edma_cc[ctlr]->num_channels || -		slot >= edma_cc[ctlr]->num_slots) -		return; - -	memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot), -			&dummy_paramset, PARM_SIZE); -	clear_bit(slot, edma_cc[ctlr]->edma_inuse); -} -EXPORT_SYMBOL(edma_free_slot); - - -/** - * edma_alloc_cont_slots- alloc contiguous parameter RAM slots - * The API will return the starting point of a set of - * contiguous parameter RAM slots that have been requested - * - * @id: can only be EDMA_CONT_PARAMS_ANY or EDMA_CONT_PARAMS_FIXED_EXACT - * or EDMA_CONT_PARAMS_FIXED_NOT_EXACT - * @count: number of contiguous Paramter RAM slots - * @slot  - the start value of Parameter RAM slot that should be passed if id - * is EDMA_CONT_PARAMS_FIXED_EXACT or EDMA_CONT_PARAMS_FIXED_NOT_EXACT - * - * If id is EDMA_CONT_PARAMS_ANY then the API starts looking for a set of - * contiguous Parameter RAM slots from parameter RAM 64 in the case of - * DaVinci SOCs and 32 in the case of DA8xx SOCs. - * - * If id is EDMA_CONT_PARAMS_FIXED_EXACT then the API starts looking for a - * set of contiguous parameter RAM slots from the "slot" that is passed as an - * argument to the API. - * - * If id is EDMA_CONT_PARAMS_FIXED_NOT_EXACT then the API initially tries - * starts looking for a set of contiguous parameter RAMs from the "slot" - * that is passed as an argument to the API. On failure the API will try to - * find a set of contiguous Parameter RAM slots from the remaining Parameter - * RAM slots - */ -int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count) -{ -	/* -	 * The start slot requested should be greater than -	 * the number of channels and lesser than the total number -	 * of slots -	 */ -	if ((id != EDMA_CONT_PARAMS_ANY) && -		(slot < edma_cc[ctlr]->num_channels || -		slot >= edma_cc[ctlr]->num_slots)) -		return -EINVAL; - -	/* -	 * The number of parameter RAM slots requested cannot be less than 1 -	 * and cannot be more than the number of slots minus the number of -	 * channels -	 */ -	if (count < 1 || count > -		(edma_cc[ctlr]->num_slots - edma_cc[ctlr]->num_channels)) -		return -EINVAL; - -	switch (id) { -	case EDMA_CONT_PARAMS_ANY: -		return reserve_contiguous_slots(ctlr, id, count, -						 edma_cc[ctlr]->num_channels); -	case EDMA_CONT_PARAMS_FIXED_EXACT: -	case EDMA_CONT_PARAMS_FIXED_NOT_EXACT: -		return reserve_contiguous_slots(ctlr, id, count, slot); -	default: -		return -EINVAL; -	} - -} -EXPORT_SYMBOL(edma_alloc_cont_slots); - -/** - * edma_free_cont_slots - deallocate DMA parameter RAM slots - * @slot: first parameter RAM of a set of parameter RAM slots to be freed - * @count: the number of contiguous parameter RAM slots to be freed - * - * This deallocates the parameter RAM slots allocated by - * edma_alloc_cont_slots. - * Callers/applications need to keep track of sets of contiguous - * parameter RAM slots that have been allocated using the edma_alloc_cont_slots - * API. - * Callers are responsible for ensuring the slots are inactive, and will - * not be activated. - */ -int edma_free_cont_slots(unsigned slot, int count) -{ -	unsigned ctlr, slot_to_free; -	int i; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot < edma_cc[ctlr]->num_channels || -		slot >= edma_cc[ctlr]->num_slots || -		count < 1) -		return -EINVAL; - -	for (i = slot; i < slot + count; ++i) { -		ctlr = EDMA_CTLR(i); -		slot_to_free = EDMA_CHAN_SLOT(i); - -		memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot_to_free), -			&dummy_paramset, PARM_SIZE); -		clear_bit(slot_to_free, edma_cc[ctlr]->edma_inuse); -	} - -	return 0; -} -EXPORT_SYMBOL(edma_free_cont_slots); - -/*-----------------------------------------------------------------------*/ - -/* Parameter RAM operations (i) -- read/write partial slots */ - -/** - * edma_set_src - set initial DMA source address in parameter RAM slot - * @slot: parameter RAM slot being configured - * @src_port: physical address of source (memory, controller FIFO, etc) - * @addressMode: INCR, except in very rare cases - * @fifoWidth: ignored unless @addressMode is FIFO, else specifies the - *	width to use when addressing the fifo (e.g. W8BIT, W32BIT) - * - * Note that the source address is modified during the DMA transfer - * according to edma_set_src_index(). - */ -void edma_set_src(unsigned slot, dma_addr_t src_port, -				enum address_mode mode, enum fifo_width width) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot < edma_cc[ctlr]->num_slots) { -		unsigned int i = edma_parm_read(ctlr, PARM_OPT, slot); - -		if (mode) { -			/* set SAM and program FWID */ -			i = (i & ~(EDMA_FWID)) | (SAM | ((width & 0x7) << 8)); -		} else { -			/* clear SAM */ -			i &= ~SAM; -		} -		edma_parm_write(ctlr, PARM_OPT, slot, i); - -		/* set the source port address -		   in source register of param structure */ -		edma_parm_write(ctlr, PARM_SRC, slot, src_port); -	} -} -EXPORT_SYMBOL(edma_set_src); - -/** - * edma_set_dest - set initial DMA destination address in parameter RAM slot - * @slot: parameter RAM slot being configured - * @dest_port: physical address of destination (memory, controller FIFO, etc) - * @addressMode: INCR, except in very rare cases - * @fifoWidth: ignored unless @addressMode is FIFO, else specifies the - *	width to use when addressing the fifo (e.g. W8BIT, W32BIT) - * - * Note that the destination address is modified during the DMA transfer - * according to edma_set_dest_index(). - */ -void edma_set_dest(unsigned slot, dma_addr_t dest_port, -				 enum address_mode mode, enum fifo_width width) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot < edma_cc[ctlr]->num_slots) { -		unsigned int i = edma_parm_read(ctlr, PARM_OPT, slot); - -		if (mode) { -			/* set DAM and program FWID */ -			i = (i & ~(EDMA_FWID)) | (DAM | ((width & 0x7) << 8)); -		} else { -			/* clear DAM */ -			i &= ~DAM; -		} -		edma_parm_write(ctlr, PARM_OPT, slot, i); -		/* set the destination port address -		   in dest register of param structure */ -		edma_parm_write(ctlr, PARM_DST, slot, dest_port); -	} -} -EXPORT_SYMBOL(edma_set_dest); - -/** - * edma_get_position - returns the current transfer points - * @slot: parameter RAM slot being examined - * @src: pointer to source port position - * @dst: pointer to destination port position - * - * Returns current source and destination addresses for a particular - * parameter RAM slot.  Its channel should not be active when this is called. - */ -void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst) -{ -	struct edmacc_param temp; -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	edma_read_slot(EDMA_CTLR_CHAN(ctlr, slot), &temp); -	if (src != NULL) -		*src = temp.src; -	if (dst != NULL) -		*dst = temp.dst; -} -EXPORT_SYMBOL(edma_get_position); - -/** - * edma_set_src_index - configure DMA source address indexing - * @slot: parameter RAM slot being configured - * @src_bidx: byte offset between source arrays in a frame - * @src_cidx: byte offset between source frames in a block - * - * Offsets are specified to support either contiguous or discontiguous - * memory transfers, or repeated access to a hardware register, as needed. - * When accessing hardware registers, both offsets are normally zero. - */ -void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot < edma_cc[ctlr]->num_slots) { -		edma_parm_modify(ctlr, PARM_SRC_DST_BIDX, slot, -				0xffff0000, src_bidx); -		edma_parm_modify(ctlr, PARM_SRC_DST_CIDX, slot, -				0xffff0000, src_cidx); -	} -} -EXPORT_SYMBOL(edma_set_src_index); - -/** - * edma_set_dest_index - configure DMA destination address indexing - * @slot: parameter RAM slot being configured - * @dest_bidx: byte offset between destination arrays in a frame - * @dest_cidx: byte offset between destination frames in a block - * - * Offsets are specified to support either contiguous or discontiguous - * memory transfers, or repeated access to a hardware register, as needed. - * When accessing hardware registers, both offsets are normally zero. - */ -void edma_set_dest_index(unsigned slot, s16 dest_bidx, s16 dest_cidx) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot < edma_cc[ctlr]->num_slots) { -		edma_parm_modify(ctlr, PARM_SRC_DST_BIDX, slot, -				0x0000ffff, dest_bidx << 16); -		edma_parm_modify(ctlr, PARM_SRC_DST_CIDX, slot, -				0x0000ffff, dest_cidx << 16); -	} -} -EXPORT_SYMBOL(edma_set_dest_index); - -/** - * edma_set_transfer_params - configure DMA transfer parameters - * @slot: parameter RAM slot being configured - * @acnt: how many bytes per array (at least one) - * @bcnt: how many arrays per frame (at least one) - * @ccnt: how many frames per block (at least one) - * @bcnt_rld: used only for A-Synchronized transfers; this specifies - *	the value to reload into bcnt when it decrements to zero - * @sync_mode: ASYNC or ABSYNC - * - * See the EDMA3 documentation to understand how to configure and link - * transfers using the fields in PaRAM slots.  If you are not doing it - * all at once with edma_write_slot(), you will use this routine - * plus two calls each for source and destination, setting the initial - * address and saying how to index that address. - * - * An example of an A-Synchronized transfer is a serial link using a - * single word shift register.  In that case, @acnt would be equal to - * that word size; the serial controller issues a DMA synchronization - * event to transfer each word, and memory access by the DMA transfer - * controller will be word-at-a-time. - * - * An example of an AB-Synchronized transfer is a device using a FIFO. - * In that case, @acnt equals the FIFO width and @bcnt equals its depth. - * The controller with the FIFO issues DMA synchronization events when - * the FIFO threshold is reached, and the DMA transfer controller will - * transfer one frame to (or from) the FIFO.  It will probably use - * efficient burst modes to access memory. - */ -void edma_set_transfer_params(unsigned slot, -		u16 acnt, u16 bcnt, u16 ccnt, -		u16 bcnt_rld, enum sync_dimension sync_mode) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot < edma_cc[ctlr]->num_slots) { -		edma_parm_modify(ctlr, PARM_LINK_BCNTRLD, slot, -				0x0000ffff, bcnt_rld << 16); -		if (sync_mode == ASYNC) -			edma_parm_and(ctlr, PARM_OPT, slot, ~SYNCDIM); -		else -			edma_parm_or(ctlr, PARM_OPT, slot, SYNCDIM); -		/* Set the acount, bcount, ccount registers */ -		edma_parm_write(ctlr, PARM_A_B_CNT, slot, (bcnt << 16) | acnt); -		edma_parm_write(ctlr, PARM_CCNT, slot, ccnt); -	} -} -EXPORT_SYMBOL(edma_set_transfer_params); - -/** - * edma_link - link one parameter RAM slot to another - * @from: parameter RAM slot originating the link - * @to: parameter RAM slot which is the link target - * - * The originating slot should not be part of any active DMA transfer. - */ -void edma_link(unsigned from, unsigned to) -{ -	unsigned ctlr_from, ctlr_to; - -	ctlr_from = EDMA_CTLR(from); -	from = EDMA_CHAN_SLOT(from); -	ctlr_to = EDMA_CTLR(to); -	to = EDMA_CHAN_SLOT(to); - -	if (from >= edma_cc[ctlr_from]->num_slots) -		return; -	if (to >= edma_cc[ctlr_to]->num_slots) -		return; -	edma_parm_modify(ctlr_from, PARM_LINK_BCNTRLD, from, 0xffff0000, -				PARM_OFFSET(to)); -} -EXPORT_SYMBOL(edma_link); - -/** - * edma_unlink - cut link from one parameter RAM slot - * @from: parameter RAM slot originating the link - * - * The originating slot should not be part of any active DMA transfer. - * Its link is set to 0xffff. - */ -void edma_unlink(unsigned from) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(from); -	from = EDMA_CHAN_SLOT(from); - -	if (from >= edma_cc[ctlr]->num_slots) -		return; -	edma_parm_or(ctlr, PARM_LINK_BCNTRLD, from, 0xffff); -} -EXPORT_SYMBOL(edma_unlink); - -/*-----------------------------------------------------------------------*/ - -/* Parameter RAM operations (ii) -- read/write whole parameter sets */ - -/** - * edma_write_slot - write parameter RAM data for slot - * @slot: number of parameter RAM slot being modified - * @param: data to be written into parameter RAM slot - * - * Use this to assign all parameters of a transfer at once.  This - * allows more efficient setup of transfers than issuing multiple - * calls to set up those parameters in small pieces, and provides - * complete control over all transfer options. - */ -void edma_write_slot(unsigned slot, const struct edmacc_param *param) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot >= edma_cc[ctlr]->num_slots) -		return; -	memcpy_toio(edmacc_regs_base[ctlr] + PARM_OFFSET(slot), param, -			PARM_SIZE); -} -EXPORT_SYMBOL(edma_write_slot); - -/** - * edma_read_slot - read parameter RAM data from slot - * @slot: number of parameter RAM slot being copied - * @param: where to store copy of parameter RAM data - * - * Use this to read data from a parameter RAM slot, perhaps to - * save them as a template for later reuse. - */ -void edma_read_slot(unsigned slot, struct edmacc_param *param) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(slot); -	slot = EDMA_CHAN_SLOT(slot); - -	if (slot >= edma_cc[ctlr]->num_slots) -		return; -	memcpy_fromio(param, edmacc_regs_base[ctlr] + PARM_OFFSET(slot), -			PARM_SIZE); -} -EXPORT_SYMBOL(edma_read_slot); - -/*-----------------------------------------------------------------------*/ - -/* Various EDMA channel control operations */ - -/** - * edma_pause - pause dma on a channel - * @channel: on which edma_start() has been called - * - * This temporarily disables EDMA hardware events on the specified channel, - * preventing them from triggering new transfers on its behalf - */ -void edma_pause(unsigned channel) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(channel); -	channel = EDMA_CHAN_SLOT(channel); - -	if (channel < edma_cc[ctlr]->num_channels) { -		unsigned int mask = BIT(channel & 0x1f); - -		edma_shadow0_write_array(ctlr, SH_EECR, channel >> 5, mask); -	} -} -EXPORT_SYMBOL(edma_pause); - -/** - * edma_resume - resumes dma on a paused channel - * @channel: on which edma_pause() has been called - * - * This re-enables EDMA hardware events on the specified channel. - */ -void edma_resume(unsigned channel) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(channel); -	channel = EDMA_CHAN_SLOT(channel); - -	if (channel < edma_cc[ctlr]->num_channels) { -		unsigned int mask = BIT(channel & 0x1f); - -		edma_shadow0_write_array(ctlr, SH_EESR, channel >> 5, mask); -	} -} -EXPORT_SYMBOL(edma_resume); - -/** - * edma_start - start dma on a channel - * @channel: channel being activated - * - * Channels with event associations will be triggered by their hardware - * events, and channels without such associations will be triggered by - * software.  (At this writing there is no interface for using software - * triggers except with channels that don't support hardware triggers.) - * - * Returns zero on success, else negative errno. - */ -int edma_start(unsigned channel) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(channel); -	channel = EDMA_CHAN_SLOT(channel); - -	if (channel < edma_cc[ctlr]->num_channels) { -		int j = channel >> 5; -		unsigned int mask = BIT(channel & 0x1f); - -		/* EDMA channels without event association */ -		if (test_bit(channel, edma_cc[ctlr]->edma_unused)) { -			pr_debug("EDMA: ESR%d %08x\n", j, -				edma_shadow0_read_array(ctlr, SH_ESR, j)); -			edma_shadow0_write_array(ctlr, SH_ESR, j, mask); -			return 0; -		} - -		/* EDMA channel with event association */ -		pr_debug("EDMA: ER%d %08x\n", j, -			edma_shadow0_read_array(ctlr, SH_ER, j)); -		/* Clear any pending event or error */ -		edma_write_array(ctlr, EDMA_ECR, j, mask); -		edma_write_array(ctlr, EDMA_EMCR, j, mask); -		/* Clear any SER */ -		edma_shadow0_write_array(ctlr, SH_SECR, j, mask); -		edma_shadow0_write_array(ctlr, SH_EESR, j, mask); -		pr_debug("EDMA: EER%d %08x\n", j, -			edma_shadow0_read_array(ctlr, SH_EER, j)); -		return 0; -	} - -	return -EINVAL; -} -EXPORT_SYMBOL(edma_start); - -/** - * edma_stop - stops dma on the channel passed - * @channel: channel being deactivated - * - * When @lch is a channel, any active transfer is paused and - * all pending hardware events are cleared.  The current transfer - * may not be resumed, and the channel's Parameter RAM should be - * reinitialized before being reused. - */ -void edma_stop(unsigned channel) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(channel); -	channel = EDMA_CHAN_SLOT(channel); - -	if (channel < edma_cc[ctlr]->num_channels) { -		int j = channel >> 5; -		unsigned int mask = BIT(channel & 0x1f); - -		edma_shadow0_write_array(ctlr, SH_EECR, j, mask); -		edma_shadow0_write_array(ctlr, SH_ECR, j, mask); -		edma_shadow0_write_array(ctlr, SH_SECR, j, mask); -		edma_write_array(ctlr, EDMA_EMCR, j, mask); - -		pr_debug("EDMA: EER%d %08x\n", j, -				edma_shadow0_read_array(ctlr, SH_EER, j)); - -		/* REVISIT:  consider guarding against inappropriate event -		 * chaining by overwriting with dummy_paramset. -		 */ -	} -} -EXPORT_SYMBOL(edma_stop); - -/****************************************************************************** - * - * It cleans ParamEntry qand bring back EDMA to initial state if media has - * been removed before EDMA has finished.It is usedful for removable media. - * Arguments: - *      ch_no     - channel no - * - * Return: zero on success, or corresponding error no on failure - * - * FIXME this should not be needed ... edma_stop() should suffice. - * - *****************************************************************************/ - -void edma_clean_channel(unsigned channel) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(channel); -	channel = EDMA_CHAN_SLOT(channel); - -	if (channel < edma_cc[ctlr]->num_channels) { -		int j = (channel >> 5); -		unsigned int mask = BIT(channel & 0x1f); - -		pr_debug("EDMA: EMR%d %08x\n", j, -				edma_read_array(ctlr, EDMA_EMR, j)); -		edma_shadow0_write_array(ctlr, SH_ECR, j, mask); -		/* Clear the corresponding EMR bits */ -		edma_write_array(ctlr, EDMA_EMCR, j, mask); -		/* Clear any SER */ -		edma_shadow0_write_array(ctlr, SH_SECR, j, mask); -		edma_write(ctlr, EDMA_CCERRCLR, BIT(16) | BIT(1) | BIT(0)); -	} -} -EXPORT_SYMBOL(edma_clean_channel); - -/* - * edma_clear_event - clear an outstanding event on the DMA channel - * Arguments: - *	channel - channel number - */ -void edma_clear_event(unsigned channel) -{ -	unsigned ctlr; - -	ctlr = EDMA_CTLR(channel); -	channel = EDMA_CHAN_SLOT(channel); - -	if (channel >= edma_cc[ctlr]->num_channels) -		return; -	if (channel < 32) -		edma_write(ctlr, EDMA_ECR, BIT(channel)); -	else -		edma_write(ctlr, EDMA_ECRH, BIT(channel - 32)); -} -EXPORT_SYMBOL(edma_clear_event); - -/*-----------------------------------------------------------------------*/ - -static int __init edma_probe(struct platform_device *pdev) -{ -	struct edma_soc_info	**info = pdev->dev.platform_data; -	const s8		(*queue_priority_mapping)[2]; -	const s8		(*queue_tc_mapping)[2]; -	int			i, j, off, ln, found = 0; -	int			status = -1; -	const s16		(*rsv_chans)[2]; -	const s16		(*rsv_slots)[2]; -	int			irq[EDMA_MAX_CC] = {0, 0}; -	int			err_irq[EDMA_MAX_CC] = {0, 0}; -	struct resource		*r[EDMA_MAX_CC] = {NULL}; -	resource_size_t		len[EDMA_MAX_CC]; -	char			res_name[10]; -	char			irq_name[10]; - -	if (!info) -		return -ENODEV; - -	for (j = 0; j < EDMA_MAX_CC; j++) { -		sprintf(res_name, "edma_cc%d", j); -		r[j] = platform_get_resource_byname(pdev, IORESOURCE_MEM, -						res_name); -		if (!r[j] || !info[j]) { -			if (found) -				break; -			else -				return -ENODEV; -		} else { -			found = 1; -		} - -		len[j] = resource_size(r[j]); - -		r[j] = request_mem_region(r[j]->start, len[j], -			dev_name(&pdev->dev)); -		if (!r[j]) { -			status = -EBUSY; -			goto fail1; -		} - -		edmacc_regs_base[j] = ioremap(r[j]->start, len[j]); -		if (!edmacc_regs_base[j]) { -			status = -EBUSY; -			goto fail1; -		} - -		edma_cc[j] = kmalloc(sizeof(struct edma), GFP_KERNEL); -		if (!edma_cc[j]) { -			status = -ENOMEM; -			goto fail1; -		} -		memset(edma_cc[j], 0, sizeof(struct edma)); - -		edma_cc[j]->num_channels = min_t(unsigned, info[j]->n_channel, -							EDMA_MAX_DMACH); -		edma_cc[j]->num_slots = min_t(unsigned, info[j]->n_slot, -							EDMA_MAX_PARAMENTRY); -		edma_cc[j]->num_cc = min_t(unsigned, info[j]->n_cc, -							EDMA_MAX_CC); - -		edma_cc[j]->default_queue = info[j]->default_queue; -		if (!edma_cc[j]->default_queue) -			edma_cc[j]->default_queue = EVENTQ_1; - -		dev_dbg(&pdev->dev, "DMA REG BASE ADDR=%p\n", -			edmacc_regs_base[j]); - -		for (i = 0; i < edma_cc[j]->num_slots; i++) -			memcpy_toio(edmacc_regs_base[j] + PARM_OFFSET(i), -					&dummy_paramset, PARM_SIZE); - -		/* Mark all channels as unused */ -		memset(edma_cc[j]->edma_unused, 0xff, -			sizeof(edma_cc[j]->edma_unused)); - -		if (info[j]->rsv) { - -			/* Clear the reserved channels in unused list */ -			rsv_chans = info[j]->rsv->rsv_chans; -			if (rsv_chans) { -				for (i = 0; rsv_chans[i][0] != -1; i++) { -					off = rsv_chans[i][0]; -					ln = rsv_chans[i][1]; -					clear_bits(off, ln, -						edma_cc[j]->edma_unused); -				} -			} - -			/* Set the reserved slots in inuse list */ -			rsv_slots = info[j]->rsv->rsv_slots; -			if (rsv_slots) { -				for (i = 0; rsv_slots[i][0] != -1; i++) { -					off = rsv_slots[i][0]; -					ln = rsv_slots[i][1]; -					set_bits(off, ln, -						edma_cc[j]->edma_inuse); -				} -			} -		} - -		sprintf(irq_name, "edma%d", j); -		irq[j] = platform_get_irq_byname(pdev, irq_name); -		edma_cc[j]->irq_res_start = irq[j]; -		status = request_irq(irq[j], dma_irq_handler, 0, "edma", -					&pdev->dev); -		if (status < 0) { -			dev_dbg(&pdev->dev, "request_irq %d failed --> %d\n", -				irq[j], status); -			goto fail; -		} - -		sprintf(irq_name, "edma%d_err", j); -		err_irq[j] = platform_get_irq_byname(pdev, irq_name); -		edma_cc[j]->irq_res_end = err_irq[j]; -		status = request_irq(err_irq[j], dma_ccerr_handler, 0, -					"edma_error", &pdev->dev); -		if (status < 0) { -			dev_dbg(&pdev->dev, "request_irq %d failed --> %d\n", -				err_irq[j], status); -			goto fail; -		} - -		/* Everything lives on transfer controller 1 until otherwise -		 * specified. This way, long transfers on the low priority queue -		 * started by the codec engine will not cause audio defects. -		 */ -		for (i = 0; i < edma_cc[j]->num_channels; i++) -			map_dmach_queue(j, i, EVENTQ_1); - -		queue_tc_mapping = info[j]->queue_tc_mapping; -		queue_priority_mapping = info[j]->queue_priority_mapping; - -		/* Event queue to TC mapping */ -		for (i = 0; queue_tc_mapping[i][0] != -1; i++) -			map_queue_tc(j, queue_tc_mapping[i][0], -					queue_tc_mapping[i][1]); - -		/* Event queue priority mapping */ -		for (i = 0; queue_priority_mapping[i][0] != -1; i++) -			assign_priority_to_queue(j, -						queue_priority_mapping[i][0], -						queue_priority_mapping[i][1]); - -		/* Map the channel to param entry if channel mapping logic -		 * exist -		 */ -		if (edma_read(j, EDMA_CCCFG) & CHMAP_EXIST) -			map_dmach_param(j); - -		for (i = 0; i < info[j]->n_region; i++) { -			edma_write_array2(j, EDMA_DRAE, i, 0, 0x0); -			edma_write_array2(j, EDMA_DRAE, i, 1, 0x0); -			edma_write_array(j, EDMA_QRAE, i, 0x0); -		} -		arch_num_cc++; -	} - -	if (tc_errs_handled) { -		status = request_irq(IRQ_TCERRINT0, dma_tc0err_handler, 0, -					"edma_tc0", &pdev->dev); -		if (status < 0) { -			dev_dbg(&pdev->dev, "request_irq %d failed --> %d\n", -				IRQ_TCERRINT0, status); -			return status; -		} -		status = request_irq(IRQ_TCERRINT, dma_tc1err_handler, 0, -					"edma_tc1", &pdev->dev); -		if (status < 0) { -			dev_dbg(&pdev->dev, "request_irq %d --> %d\n", -				IRQ_TCERRINT, status); -			return status; -		} -	} - -	return 0; - -fail: -	for (i = 0; i < EDMA_MAX_CC; i++) { -		if (err_irq[i]) -			free_irq(err_irq[i], &pdev->dev); -		if (irq[i]) -			free_irq(irq[i], &pdev->dev); -	} -fail1: -	for (i = 0; i < EDMA_MAX_CC; i++) { -		if (r[i]) -			release_mem_region(r[i]->start, len[i]); -		if (edmacc_regs_base[i]) -			iounmap(edmacc_regs_base[i]); -		kfree(edma_cc[i]); -	} -	return status; -} - - -static struct platform_driver edma_driver = { -	.driver.name	= "edma", -}; - -static int __init edma_init(void) -{ -	return platform_driver_probe(&edma_driver, edma_probe); -} -arch_initcall(edma_init); - diff --git a/arch/arm/mach-davinci/gpio-tnetv107x.c b/arch/arm/mach-davinci/gpio-tnetv107x.c deleted file mode 100644 index d10298620e2..00000000000 --- a/arch/arm/mach-davinci/gpio-tnetv107x.c +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Texas Instruments TNETV107X GPIO Controller - * - * Copyright (C) 2010 Texas Instruments - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - */ -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/gpio.h> - -#include <mach/common.h> -#include <mach/tnetv107x.h> - -struct tnetv107x_gpio_regs { -	u32	idver; -	u32	data_in[3]; -	u32	data_out[3]; -	u32	direction[3]; -	u32	enable[3]; -}; - -#define gpio_reg_index(gpio)	((gpio) >> 5) -#define gpio_reg_bit(gpio)	BIT((gpio) & 0x1f) - -#define gpio_reg_rmw(reg, mask, val)	\ -	__raw_writel((__raw_readl(reg) & ~(mask)) | (val), (reg)) - -#define gpio_reg_set_bit(reg, gpio)	\ -	gpio_reg_rmw((reg) + gpio_reg_index(gpio), 0, gpio_reg_bit(gpio)) - -#define gpio_reg_clear_bit(reg, gpio)	\ -	gpio_reg_rmw((reg) + gpio_reg_index(gpio), gpio_reg_bit(gpio), 0) - -#define gpio_reg_get_bit(reg, gpio)	\ -	(__raw_readl((reg) + gpio_reg_index(gpio)) & gpio_reg_bit(gpio)) - -#define chip2controller(chip)		\ -	container_of(chip, struct davinci_gpio_controller, chip) - -#define TNETV107X_GPIO_CTLRS	DIV_ROUND_UP(TNETV107X_N_GPIO, 32) - -static struct davinci_gpio_controller chips[TNETV107X_GPIO_CTLRS]; - -static int tnetv107x_gpio_request(struct gpio_chip *chip, unsigned offset) -{ -	struct davinci_gpio_controller *ctlr = chip2controller(chip); -	struct tnetv107x_gpio_regs __iomem *regs = ctlr->regs; -	unsigned gpio = chip->base + offset; -	unsigned long flags; - -	spin_lock_irqsave(&ctlr->lock, flags); - -	gpio_reg_set_bit(®s->enable, gpio); - -	spin_unlock_irqrestore(&ctlr->lock, flags); - -	return 0; -} - -static void tnetv107x_gpio_free(struct gpio_chip *chip, unsigned offset) -{ -	struct davinci_gpio_controller *ctlr = chip2controller(chip); -	struct tnetv107x_gpio_regs __iomem *regs = ctlr->regs; -	unsigned gpio = chip->base + offset; -	unsigned long flags; - -	spin_lock_irqsave(&ctlr->lock, flags); - -	gpio_reg_clear_bit(®s->enable, gpio); - -	spin_unlock_irqrestore(&ctlr->lock, flags); -} - -static int tnetv107x_gpio_dir_in(struct gpio_chip *chip, unsigned offset) -{ -	struct davinci_gpio_controller *ctlr = chip2controller(chip); -	struct tnetv107x_gpio_regs __iomem *regs = ctlr->regs; -	unsigned gpio = chip->base + offset; -	unsigned long flags; - -	spin_lock_irqsave(&ctlr->lock, flags); - -	gpio_reg_set_bit(®s->direction, gpio); - -	spin_unlock_irqrestore(&ctlr->lock, flags); - -	return 0; -} - -static int tnetv107x_gpio_dir_out(struct gpio_chip *chip, -		unsigned offset, int value) -{ -	struct davinci_gpio_controller *ctlr = chip2controller(chip); -	struct tnetv107x_gpio_regs __iomem *regs = ctlr->regs; -	unsigned gpio = chip->base + offset; -	unsigned long flags; - -	spin_lock_irqsave(&ctlr->lock, flags); - -	if (value) -		gpio_reg_set_bit(®s->data_out, gpio); -	else -		gpio_reg_clear_bit(®s->data_out, gpio); - -	gpio_reg_clear_bit(®s->direction, gpio); - -	spin_unlock_irqrestore(&ctlr->lock, flags); - -	return 0; -} - -static int tnetv107x_gpio_get(struct gpio_chip *chip, unsigned offset) -{ -	struct davinci_gpio_controller *ctlr = chip2controller(chip); -	struct tnetv107x_gpio_regs __iomem *regs = ctlr->regs; -	unsigned gpio = chip->base + offset; -	int ret; - -	ret = gpio_reg_get_bit(®s->data_in, gpio); - -	return ret ? 1 : 0; -} - -static void tnetv107x_gpio_set(struct gpio_chip *chip, -		unsigned offset, int value) -{ -	struct davinci_gpio_controller *ctlr = chip2controller(chip); -	struct tnetv107x_gpio_regs __iomem *regs = ctlr->regs; -	unsigned gpio = chip->base + offset; -	unsigned long flags; - -	spin_lock_irqsave(&ctlr->lock, flags); - -	if (value) -		gpio_reg_set_bit(®s->data_out, gpio); -	else -		gpio_reg_clear_bit(®s->data_out, gpio); - -	spin_unlock_irqrestore(&ctlr->lock, flags); -} - -static int __init tnetv107x_gpio_setup(void) -{ -	int i, base; -	unsigned ngpio; -	struct davinci_soc_info *soc_info = &davinci_soc_info; -	struct tnetv107x_gpio_regs *regs; -	struct davinci_gpio_controller *ctlr; - -	if (soc_info->gpio_type != GPIO_TYPE_TNETV107X) -		return 0; - -	ngpio = soc_info->gpio_num; -	if (ngpio == 0) { -		pr_err("GPIO setup:  how many GPIOs?\n"); -		return -EINVAL; -	} - -	if (WARN_ON(TNETV107X_N_GPIO < ngpio)) -		ngpio = TNETV107X_N_GPIO; - -	regs = ioremap(soc_info->gpio_base, SZ_4K); -	if (WARN_ON(!regs)) -		return -EINVAL; - -	for (i = 0, base = 0; base < ngpio; i++, base += 32) { -		ctlr = &chips[i]; - -		ctlr->chip.label	= "tnetv107x"; -		ctlr->chip.can_sleep	= 0; -		ctlr->chip.base		= base; -		ctlr->chip.ngpio	= ngpio - base; -		if (ctlr->chip.ngpio > 32) -			ctlr->chip.ngpio = 32; - -		ctlr->chip.request		= tnetv107x_gpio_request; -		ctlr->chip.free			= tnetv107x_gpio_free; -		ctlr->chip.direction_input	= tnetv107x_gpio_dir_in; -		ctlr->chip.get			= tnetv107x_gpio_get; -		ctlr->chip.direction_output	= tnetv107x_gpio_dir_out; -		ctlr->chip.set			= tnetv107x_gpio_set; - -		spin_lock_init(&ctlr->lock); - -		ctlr->regs	= regs; -		ctlr->set_data	= ®s->data_out[i]; -		ctlr->clr_data	= ®s->data_out[i]; -		ctlr->in_data	= ®s->data_in[i]; - -		gpiochip_add(&ctlr->chip); -	} - -	soc_info->gpio_ctlrs = chips; -	soc_info->gpio_ctlrs_num = DIV_ROUND_UP(ngpio, 32); -	return 0; -} -pure_initcall(tnetv107x_gpio_setup); diff --git a/arch/arm/mach-davinci/gpio.c b/arch/arm/mach-davinci/gpio.c deleted file mode 100644 index bf0ff587e46..00000000000 --- a/arch/arm/mach-davinci/gpio.c +++ /dev/null @@ -1,457 +0,0 @@ -/* - * TI DaVinci GPIO Support - * - * Copyright (c) 2006-2007 David Brownell - * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include <linux/errno.h> -#include <linux/kernel.h> -#include <linux/clk.h> -#include <linux/err.h> -#include <linux/io.h> - -#include <mach/gpio.h> - -#include <asm/mach/irq.h> - -struct davinci_gpio_regs { -	u32	dir; -	u32	out_data; -	u32	set_data; -	u32	clr_data; -	u32	in_data; -	u32	set_rising; -	u32	clr_rising; -	u32	set_falling; -	u32	clr_falling; -	u32	intstat; -}; - -#define chip2controller(chip)	\ -	container_of(chip, struct davinci_gpio_controller, chip) - -static struct davinci_gpio_controller chips[DIV_ROUND_UP(DAVINCI_N_GPIO, 32)]; -static void __iomem *gpio_base; - -static struct davinci_gpio_regs __iomem __init *gpio2regs(unsigned gpio) -{ -	void __iomem *ptr; - -	if (gpio < 32 * 1) -		ptr = gpio_base + 0x10; -	else if (gpio < 32 * 2) -		ptr = gpio_base + 0x38; -	else if (gpio < 32 * 3) -		ptr = gpio_base + 0x60; -	else if (gpio < 32 * 4) -		ptr = gpio_base + 0x88; -	else if (gpio < 32 * 5) -		ptr = gpio_base + 0xb0; -	else -		ptr = NULL; -	return ptr; -} - -static inline struct davinci_gpio_regs __iomem *irq2regs(int irq) -{ -	struct davinci_gpio_regs __iomem *g; - -	g = (__force struct davinci_gpio_regs __iomem *)get_irq_chip_data(irq); - -	return g; -} - -static int __init davinci_gpio_irq_setup(void); - -/*--------------------------------------------------------------------------*/ - -/* board setup code *MUST* setup pinmux and enable the GPIO clock. */ -static inline int __davinci_direction(struct gpio_chip *chip, -			unsigned offset, bool out, int value) -{ -	struct davinci_gpio_controller *d = chip2controller(chip); -	struct davinci_gpio_regs __iomem *g = d->regs; -	unsigned long flags; -	u32 temp; -	u32 mask = 1 << offset; - -	spin_lock_irqsave(&d->lock, flags); -	temp = __raw_readl(&g->dir); -	if (out) { -		temp &= ~mask; -		__raw_writel(mask, value ? &g->set_data : &g->clr_data); -	} else { -		temp |= mask; -	} -	__raw_writel(temp, &g->dir); -	spin_unlock_irqrestore(&d->lock, flags); - -	return 0; -} - -static int davinci_direction_in(struct gpio_chip *chip, unsigned offset) -{ -	return __davinci_direction(chip, offset, false, 0); -} - -static int -davinci_direction_out(struct gpio_chip *chip, unsigned offset, int value) -{ -	return __davinci_direction(chip, offset, true, value); -} - -/* - * Read the pin's value (works even if it's set up as output); - * returns zero/nonzero. - * - * Note that changes are synched to the GPIO clock, so reading values back - * right after you've set them may give old values. - */ -static int davinci_gpio_get(struct gpio_chip *chip, unsigned offset) -{ -	struct davinci_gpio_controller *d = chip2controller(chip); -	struct davinci_gpio_regs __iomem *g = d->regs; - -	return (1 << offset) & __raw_readl(&g->in_data); -} - -/* - * Assuming the pin is muxed as a gpio output, set its output value. - */ -static void -davinci_gpio_set(struct gpio_chip *chip, unsigned offset, int value) -{ -	struct davinci_gpio_controller *d = chip2controller(chip); -	struct davinci_gpio_regs __iomem *g = d->regs; - -	__raw_writel((1 << offset), value ? &g->set_data : &g->clr_data); -} - -static int __init davinci_gpio_setup(void) -{ -	int i, base; -	unsigned ngpio; -	struct davinci_soc_info *soc_info = &davinci_soc_info; -	struct davinci_gpio_regs *regs; - -	if (soc_info->gpio_type != GPIO_TYPE_DAVINCI) -		return 0; - -	/* -	 * The gpio banks conceptually expose a segmented bitmap, -	 * and "ngpio" is one more than the largest zero-based -	 * bit index that's valid. -	 */ -	ngpio = soc_info->gpio_num; -	if (ngpio == 0) { -		pr_err("GPIO setup:  how many GPIOs?\n"); -		return -EINVAL; -	} - -	if (WARN_ON(DAVINCI_N_GPIO < ngpio)) -		ngpio = DAVINCI_N_GPIO; - -	gpio_base = ioremap(soc_info->gpio_base, SZ_4K); -	if (WARN_ON(!gpio_base)) -		return -ENOMEM; - -	for (i = 0, base = 0; base < ngpio; i++, base += 32) { -		chips[i].chip.label = "DaVinci"; - -		chips[i].chip.direction_input = davinci_direction_in; -		chips[i].chip.get = davinci_gpio_get; -		chips[i].chip.direction_output = davinci_direction_out; -		chips[i].chip.set = davinci_gpio_set; - -		chips[i].chip.base = base; -		chips[i].chip.ngpio = ngpio - base; -		if (chips[i].chip.ngpio > 32) -			chips[i].chip.ngpio = 32; - -		spin_lock_init(&chips[i].lock); - -		regs = gpio2regs(base); -		chips[i].regs = regs; -		chips[i].set_data = ®s->set_data; -		chips[i].clr_data = ®s->clr_data; -		chips[i].in_data = ®s->in_data; - -		gpiochip_add(&chips[i].chip); -	} - -	soc_info->gpio_ctlrs = chips; -	soc_info->gpio_ctlrs_num = DIV_ROUND_UP(ngpio, 32); - -	davinci_gpio_irq_setup(); -	return 0; -} -pure_initcall(davinci_gpio_setup); - -/*--------------------------------------------------------------------------*/ -/* - * We expect irqs will normally be set up as input pins, but they can also be - * used as output pins ... which is convenient for testing. - * - * NOTE:  The first few GPIOs also have direct INTC hookups in addition - * to their GPIOBNK0 irq, with a bit less overhead. - * - * All those INTC hookups (direct, plus several IRQ banks) can also - * serve as EDMA event triggers. - */ - -static void gpio_irq_disable(unsigned irq) -{ -	struct davinci_gpio_regs __iomem *g = irq2regs(irq); -	u32 mask = (u32) get_irq_data(irq); - -	__raw_writel(mask, &g->clr_falling); -	__raw_writel(mask, &g->clr_rising); -} - -static void gpio_irq_enable(unsigned irq) -{ -	struct davinci_gpio_regs __iomem *g = irq2regs(irq); -	u32 mask = (u32) get_irq_data(irq); -	unsigned status = irq_desc[irq].status; - -	status &= IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING; -	if (!status) -		status = IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING; - -	if (status & IRQ_TYPE_EDGE_FALLING) -		__raw_writel(mask, &g->set_falling); -	if (status & IRQ_TYPE_EDGE_RISING) -		__raw_writel(mask, &g->set_rising); -} - -static int gpio_irq_type(unsigned irq, unsigned trigger) -{ -	struct davinci_gpio_regs __iomem *g = irq2regs(irq); -	u32 mask = (u32) get_irq_data(irq); - -	if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) -		return -EINVAL; - -	irq_desc[irq].status &= ~IRQ_TYPE_SENSE_MASK; -	irq_desc[irq].status |= trigger; - -	/* don't enable the IRQ if it's currently disabled */ -	if (irq_desc[irq].depth == 0) { -		__raw_writel(mask, (trigger & IRQ_TYPE_EDGE_FALLING) -			     ? &g->set_falling : &g->clr_falling); -		__raw_writel(mask, (trigger & IRQ_TYPE_EDGE_RISING) -			     ? &g->set_rising : &g->clr_rising); -	} -	return 0; -} - -static struct irq_chip gpio_irqchip = { -	.name		= "GPIO", -	.enable		= gpio_irq_enable, -	.disable	= gpio_irq_disable, -	.set_type	= gpio_irq_type, -}; - -static void -gpio_irq_handler(unsigned irq, struct irq_desc *desc) -{ -	struct davinci_gpio_regs __iomem *g = irq2regs(irq); -	u32 mask = 0xffff; - -	/* we only care about one bank */ -	if (irq & 1) -		mask <<= 16; - -	/* temporarily mask (level sensitive) parent IRQ */ -	desc->chip->mask(irq); -	desc->chip->ack(irq); -	while (1) { -		u32		status; -		int		n; -		int		res; - -		/* ack any irqs */ -		status = __raw_readl(&g->intstat) & mask; -		if (!status) -			break; -		__raw_writel(status, &g->intstat); -		if (irq & 1) -			status >>= 16; - -		/* now demux them to the right lowlevel handler */ -		n = (int)get_irq_data(irq); -		while (status) { -			res = ffs(status); -			n += res; -			generic_handle_irq(n - 1); -			status >>= res; -		} -	} -	desc->chip->unmask(irq); -	/* now it may re-trigger */ -} - -static int gpio_to_irq_banked(struct gpio_chip *chip, unsigned offset) -{ -	struct davinci_gpio_controller *d = chip2controller(chip); - -	if (d->irq_base >= 0) -		return d->irq_base + offset; -	else -		return -ENODEV; -} - -static int gpio_to_irq_unbanked(struct gpio_chip *chip, unsigned offset) -{ -	struct davinci_soc_info *soc_info = &davinci_soc_info; - -	/* NOTE:  we assume for now that only irqs in the first gpio_chip -	 * can provide direct-mapped IRQs to AINTC (up to 32 GPIOs). -	 */ -	if (offset < soc_info->gpio_unbanked) -		return soc_info->gpio_irq + offset; -	else -		return -ENODEV; -} - -static int gpio_irq_type_unbanked(unsigned irq, unsigned trigger) -{ -	struct davinci_gpio_regs __iomem *g = irq2regs(irq); -	u32 mask = (u32) get_irq_data(irq); - -	if (trigger & ~(IRQ_TYPE_EDGE_FALLING | IRQ_TYPE_EDGE_RISING)) -		return -EINVAL; - -	__raw_writel(mask, (trigger & IRQ_TYPE_EDGE_FALLING) -		     ? &g->set_falling : &g->clr_falling); -	__raw_writel(mask, (trigger & IRQ_TYPE_EDGE_RISING) -		     ? &g->set_rising : &g->clr_rising); - -	return 0; -} - -/* - * NOTE:  for suspend/resume, probably best to make a platform_device with - * suspend_late/resume_resume calls hooking into results of the set_wake() - * calls ... so if no gpios are wakeup events the clock can be disabled, - * with outputs left at previously set levels, and so that VDD3P3V.IOPWDN0 - * (dm6446) can be set appropriately for GPIOV33 pins. - */ - -static int __init davinci_gpio_irq_setup(void) -{ -	unsigned	gpio, irq, bank; -	struct clk	*clk; -	u32		binten = 0; -	unsigned	ngpio, bank_irq; -	struct davinci_soc_info *soc_info = &davinci_soc_info; -	struct davinci_gpio_regs	__iomem *g; - -	ngpio = soc_info->gpio_num; - -	bank_irq = soc_info->gpio_irq; -	if (bank_irq == 0) { -		printk(KERN_ERR "Don't know first GPIO bank IRQ.\n"); -		return -EINVAL; -	} - -	clk = clk_get(NULL, "gpio"); -	if (IS_ERR(clk)) { -		printk(KERN_ERR "Error %ld getting gpio clock?\n", -		       PTR_ERR(clk)); -		return PTR_ERR(clk); -	} -	clk_enable(clk); - -	/* Arrange gpio_to_irq() support, handling either direct IRQs or -	 * banked IRQs.  Having GPIOs in the first GPIO bank use direct -	 * IRQs, while the others use banked IRQs, would need some setup -	 * tweaks to recognize hardware which can do that. -	 */ -	for (gpio = 0, bank = 0; gpio < ngpio; bank++, gpio += 32) { -		chips[bank].chip.to_irq = gpio_to_irq_banked; -		chips[bank].irq_base = soc_info->gpio_unbanked -			? -EINVAL -			: (soc_info->intc_irq_num + gpio); -	} - -	/* -	 * AINTC can handle direct/unbanked IRQs for GPIOs, with the GPIO -	 * controller only handling trigger modes.  We currently assume no -	 * IRQ mux conflicts; gpio_irq_type_unbanked() is only for GPIOs. -	 */ -	if (soc_info->gpio_unbanked) { -		static struct irq_chip gpio_irqchip_unbanked; - -		/* pass "bank 0" GPIO IRQs to AINTC */ -		chips[0].chip.to_irq = gpio_to_irq_unbanked; -		binten = BIT(0); - -		/* AINTC handles mask/unmask; GPIO handles triggering */ -		irq = bank_irq; -		gpio_irqchip_unbanked = *get_irq_desc_chip(irq_to_desc(irq)); -		gpio_irqchip_unbanked.name = "GPIO-AINTC"; -		gpio_irqchip_unbanked.set_type = gpio_irq_type_unbanked; - -		/* default trigger: both edges */ -		g = gpio2regs(0); -		__raw_writel(~0, &g->set_falling); -		__raw_writel(~0, &g->set_rising); - -		/* set the direct IRQs up to use that irqchip */ -		for (gpio = 0; gpio < soc_info->gpio_unbanked; gpio++, irq++) { -			set_irq_chip(irq, &gpio_irqchip_unbanked); -			set_irq_data(irq, (void *) __gpio_mask(gpio)); -			set_irq_chip_data(irq, (__force void *) g); -			irq_desc[irq].status |= IRQ_TYPE_EDGE_BOTH; -		} - -		goto done; -	} - -	/* -	 * Or, AINTC can handle IRQs for banks of 16 GPIO IRQs, which we -	 * then chain through our own handler. -	 */ -	for (gpio = 0, irq = gpio_to_irq(0), bank = 0; -			gpio < ngpio; -			bank++, bank_irq++) { -		unsigned		i; - -		/* disabled by default, enabled only as needed */ -		g = gpio2regs(gpio); -		__raw_writel(~0, &g->clr_falling); -		__raw_writel(~0, &g->clr_rising); - -		/* set up all irqs in this bank */ -		set_irq_chained_handler(bank_irq, gpio_irq_handler); -		set_irq_chip_data(bank_irq, (__force void *) g); -		set_irq_data(bank_irq, (void *) irq); - -		for (i = 0; i < 16 && gpio < ngpio; i++, irq++, gpio++) { -			set_irq_chip(irq, &gpio_irqchip); -			set_irq_chip_data(irq, (__force void *) g); -			set_irq_data(irq, (void *) __gpio_mask(gpio)); -			set_irq_handler(irq, handle_simple_irq); -			set_irq_flags(irq, IRQF_VALID); -		} - -		binten |= BIT(bank); -	} - -done: -	/* BINTEN -- per-bank interrupt enable. genirq would also let these -	 * bits be set/cleared dynamically. -	 */ -	__raw_writel(binten, gpio_base + 0x08); - -	printk(KERN_INFO "DaVinci: %d gpio irqs\n", irq - gpio_to_irq(0)); - -	return 0; -} diff --git a/arch/arm/mach-davinci/include/mach/aemif.h b/arch/arm/mach-davinci/include/mach/aemif.h deleted file mode 100644 index 05b29344309..00000000000 --- a/arch/arm/mach-davinci/include/mach/aemif.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * TI DaVinci AEMIF support - * - * Copyright 2010 (C) Texas Instruments, Inc. http://www.ti.com/ - * - * 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. - */ -#ifndef _MACH_DAVINCI_AEMIF_H -#define _MACH_DAVINCI_AEMIF_H - -#define NRCSR_OFFSET		0x00 -#define AWCCR_OFFSET		0x04 -#define A1CR_OFFSET		0x10 - -#define ACR_ASIZE_MASK		0x3 -#define ACR_EW_MASK		BIT(30) -#define ACR_SS_MASK		BIT(31) - -/* All timings in nanoseconds */ -struct davinci_aemif_timing { -	u8	wsetup; -	u8	wstrobe; -	u8	whold; - -	u8	rsetup; -	u8	rstrobe; -	u8	rhold; - -	u8	ta; -}; - -int davinci_aemif_setup_timing(struct davinci_aemif_timing *t, -					void __iomem *base, unsigned cs); -#endif diff --git a/arch/arm/mach-davinci/include/mach/asp.h b/arch/arm/mach-davinci/include/mach/asp.h deleted file mode 100644 index 9aa240909a2..00000000000 --- a/arch/arm/mach-davinci/include/mach/asp.h +++ /dev/null @@ -1,137 +0,0 @@ -/* - * <mach/asp.h> - DaVinci Audio Serial Port support - */ -#ifndef __ASM_ARCH_DAVINCI_ASP_H -#define __ASM_ARCH_DAVINCI_ASP_H - -#include <mach/irqs.h> -#include <mach/edma.h> - -/* Bases of dm644x and dm355 register banks */ -#define DAVINCI_ASP0_BASE	0x01E02000 -#define DAVINCI_ASP1_BASE	0x01E04000 - -/* Bases of dm365 register banks */ -#define DAVINCI_DM365_ASP0_BASE	0x01D02000 - -/* Bases of dm646x register banks */ -#define	DAVINCI_DM646X_MCASP0_REG_BASE		0x01D01000 -#define DAVINCI_DM646X_MCASP1_REG_BASE		0x01D01800 - -/* Bases of da850/da830 McASP0  register banks */ -#define DAVINCI_DA8XX_MCASP0_REG_BASE	0x01D00000 - -/* Bases of da830 McASP1 register banks */ -#define DAVINCI_DA830_MCASP1_REG_BASE	0x01D04000 - -/* EDMA channels of dm644x and dm355 */ -#define DAVINCI_DMA_ASP0_TX	2 -#define DAVINCI_DMA_ASP0_RX	3 -#define DAVINCI_DMA_ASP1_TX	8 -#define DAVINCI_DMA_ASP1_RX	9 - -/* EDMA channels of dm646x */ -#define	DAVINCI_DM646X_DMA_MCASP0_AXEVT0	6 -#define	DAVINCI_DM646X_DMA_MCASP0_AREVT0	9 -#define	DAVINCI_DM646X_DMA_MCASP1_AXEVT1	12 - -/* EDMA channels of da850/da830 McASP0 */ -#define	DAVINCI_DA8XX_DMA_MCASP0_AREVT	0 -#define	DAVINCI_DA8XX_DMA_MCASP0_AXEVT	1 - -/* EDMA channels of da830 McASP1 */ -#define	DAVINCI_DA830_DMA_MCASP1_AREVT	2 -#define	DAVINCI_DA830_DMA_MCASP1_AXEVT	3 - -/* Interrupts */ -#define DAVINCI_ASP0_RX_INT	IRQ_MBRINT -#define DAVINCI_ASP0_TX_INT	IRQ_MBXINT -#define DAVINCI_ASP1_RX_INT	IRQ_MBRINT -#define DAVINCI_ASP1_TX_INT	IRQ_MBXINT - -struct snd_platform_data { -	u32 tx_dma_offset; -	u32 rx_dma_offset; -	enum dma_event_q asp_chan_q;	/* event queue number for ASP channel */ -	enum dma_event_q ram_chan_q;	/* event queue number for RAM channel */ -	unsigned int codec_fmt; -	/* -	 * Allowing this is more efficient and eliminates left and right swaps -	 * caused by underruns, but will swap the left and right channels -	 * when compared to previous behavior. -	 */ -	unsigned enable_channel_combine:1; -	unsigned sram_size_playback; -	unsigned sram_size_capture; - -	/* -	 * If McBSP peripheral gets the clock from an external pin, -	 * there are three chooses, that are MCBSP_CLKX, MCBSP_CLKR -	 * and MCBSP_CLKS. -	 * Depending on different hardware connections it is possible -	 * to use this setting to change the behaviour of McBSP -	 * driver. The dm365_clk_input_pin enum is available for dm365 -	 */ -	int clk_input_pin; - -	/* -	 * This flag works when both clock and FS are outputs for the cpu -	 * and makes clock more accurate (FS is not symmetrical and the -	 * clock is very fast. -	 * The clock becoming faster is named -	 * i2s continuous serial clock (I2S_SCK) and it is an externally -	 * visible bit clock. -	 * -	 * first line : WordSelect -	 * second line : ContinuousSerialClock -	 * third line: SerialData -	 * -	 * SYMMETRICAL APPROACH: -	 *   _______________________          LEFT -	 * _|         RIGHT         |______________________| -	 *     _   _         _   _   _   _         _   _ -	 *   _| |_| |_ x16 _| |_| |_| |_| |_ x16 _| |_| |_ -	 *     _   _         _   _   _   _         _   _ -	 *   _/ \_/ \_ ... _/ \_/ \_/ \_/ \_ ... _/ \_/ \_ -	 *    \_/ \_/       \_/ \_/ \_/ \_/       \_/ \_/ -	 * -	 * ACCURATE CLOCK APPROACH: -	 *   ______________          LEFT -	 * _|     RIGHT    |_______________________________| -	 *     _         _   _         _   _   _   _   _   _ -	 *   _| |_ x16 _| |_| |_ x16 _| |_| |_| |_| |_| |_| | -	 *     _         _   _          _      dummy cycles -	 *   _/ \_ ... _/ \_/ \_  ... _/ \__________________ -	 *    \_/       \_/ \_/        \_/ -	 * -	 */ -	bool i2s_accurate_sck; - -	/* McASP specific fields */ -	int tdm_slots; -	u8 op_mode; -	u8 num_serializer; -	u8 *serial_dir; -	u8 version; -	u8 txnumevt; -	u8 rxnumevt; -}; - -enum { -	MCASP_VERSION_1 = 0,	/* DM646x */ -	MCASP_VERSION_2,	/* DA8xx/OMAPL1x */ -}; - -enum dm365_clk_input_pin { -	MCBSP_CLKR = 0,		/* DM365 */ -	MCBSP_CLKS, -}; - -#define INACTIVE_MODE	0 -#define TX_MODE		1 -#define RX_MODE		2 - -#define DAVINCI_MCASP_IIS_MODE	0 -#define DAVINCI_MCASP_DIT_MODE	1 - -#endif /* __ASM_ARCH_DAVINCI_ASP_H */ diff --git a/arch/arm/mach-davinci/include/mach/clkdev.h b/arch/arm/mach-davinci/include/mach/clkdev.h deleted file mode 100644 index 730c49d1ebd..00000000000 --- a/arch/arm/mach-davinci/include/mach/clkdev.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef __MACH_CLKDEV_H -#define __MACH_CLKDEV_H - -static inline int __clk_get(struct clk *clk) -{ -	return 1; -} - -static inline void __clk_put(struct clk *clk) -{ -} - -#endif diff --git a/arch/arm/mach-davinci/include/mach/clock.h b/arch/arm/mach-davinci/include/mach/clock.h index a3b04021987..3e8af6a0b64 100644 --- a/arch/arm/mach-davinci/include/mach/clock.h +++ b/arch/arm/mach-davinci/include/mach/clock.h @@ -18,4 +18,7 @@ struct clk;  extern int clk_register(struct clk *clk);  extern void clk_unregister(struct clk *clk); +int davinci_clk_reset_assert(struct clk *c); +int davinci_clk_reset_deassert(struct clk *c); +  #endif diff --git a/arch/arm/mach-davinci/include/mach/common.h b/arch/arm/mach-davinci/include/mach/common.h index a57cba21e21..0b3c169758e 100644 --- a/arch/arm/mach-davinci/include/mach/common.h +++ b/arch/arm/mach-davinci/include/mach/common.h @@ -14,10 +14,9 @@  #include <linux/compiler.h>  #include <linux/types.h> +#include <linux/reboot.h> -struct sys_timer; - -extern struct sys_timer davinci_timer; +extern void davinci_timer_init(void);  extern void davinci_irq_init(void);  extern void __iomem *davinci_intc_base; @@ -73,21 +72,36 @@ struct davinci_soc_info {  	unsigned			gpio_unbanked;  	struct davinci_gpio_controller	*gpio_ctlrs;  	int				gpio_ctlrs_num; -	struct platform_device		*serial_dev;  	struct emac_platform_data	*emac_pdata;  	dma_addr_t			sram_dma;  	unsigned			sram_len; -	struct platform_device		*reset_device; -	void				(*reset)(struct platform_device *);  };  extern struct davinci_soc_info davinci_soc_info;  extern void davinci_common_init(struct davinci_soc_info *soc_info);  extern void davinci_init_ide(void); +void davinci_restart(enum reboot_mode mode, const char *cmd); +void davinci_init_late(void); + +#ifdef CONFIG_DAVINCI_RESET_CLOCKS +int davinci_clk_disable_unused(void); +#else +static inline int davinci_clk_disable_unused(void) { return 0; } +#endif + +#ifdef CONFIG_CPU_FREQ +int davinci_cpufreq_init(void); +#else +static inline int davinci_cpufreq_init(void) { return 0; } +#endif + +#ifdef CONFIG_SUSPEND +int davinci_pm_init(void); +#else +static inline int davinci_pm_init(void) { return 0; } +#endif -/* standard place to map on-chip SRAMs; they *may* support DMA */ -#define SRAM_VIRT	0xfffe0000  #define SRAM_SIZE	SZ_128K  #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */ diff --git a/arch/arm/mach-davinci/include/mach/cp_intc.h b/arch/arm/mach-davinci/include/mach/cp_intc.h index 4e8190eed67..827bbe9baed 100644 --- a/arch/arm/mach-davinci/include/mach/cp_intc.h +++ b/arch/arm/mach-davinci/include/mach/cp_intc.h @@ -51,6 +51,7 @@  #define CP_INTC_HOST_PRIO_VECTOR(n)	(0x1600 + (n << 2))  #define CP_INTC_VECTOR_ADDR(n)		(0x2000 + (n << 2)) -void __init cp_intc_init(void); +void cp_intc_init(void); +int cp_intc_of_init(struct device_node *, struct device_node *);  #endif	/* __ASM_HARDWARE_CP_INTC_H */ diff --git a/arch/arm/mach-davinci/include/mach/cputype.h b/arch/arm/mach-davinci/include/mach/cputype.h index cea6b897204..1fc84e21664 100644 --- a/arch/arm/mach-davinci/include/mach/cputype.h +++ b/arch/arm/mach-davinci/include/mach/cputype.h @@ -4,7 +4,7 @@   * Author: Kevin Hilman, Deep Root Systems, LLC   *   * Defines the cpu_is_*() macros for runtime detection of DaVinci - * device type.  In addtion, if support for a given device is not + * device type.  In addition, if support for a given device is not   * compiled in to the kernel, the macros return 0 so that   * resulting code can be optimized out.   * @@ -33,7 +33,6 @@ struct davinci_id {  #define	DAVINCI_CPU_ID_DM365		0x03650000  #define	DAVINCI_CPU_ID_DA830		0x08300000  #define	DAVINCI_CPU_ID_DA850		0x08500000 -#define	DAVINCI_CPU_ID_TNETV107X	0x0b8a0000  #define IS_DAVINCI_CPU(type, id)					\  static inline int is_davinci_ ##type(void)				\ @@ -47,7 +46,6 @@ IS_DAVINCI_CPU(dm355, DAVINCI_CPU_ID_DM355)  IS_DAVINCI_CPU(dm365, DAVINCI_CPU_ID_DM365)  IS_DAVINCI_CPU(da830, DAVINCI_CPU_ID_DA830)  IS_DAVINCI_CPU(da850, DAVINCI_CPU_ID_DA850) -IS_DAVINCI_CPU(tnetv107x, DAVINCI_CPU_ID_TNETV107X)  #ifdef CONFIG_ARCH_DAVINCI_DM644x  #define cpu_is_davinci_dm644x() is_davinci_dm644x() @@ -85,10 +83,4 @@ IS_DAVINCI_CPU(tnetv107x, DAVINCI_CPU_ID_TNETV107X)  #define cpu_is_davinci_da850() 0  #endif -#ifdef CONFIG_ARCH_DAVINCI_TNETV107X -#define cpu_is_davinci_tnetv107x() is_davinci_tnetv107x() -#else -#define cpu_is_davinci_tnetv107x() 0 -#endif -  #endif diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h index 4247b3f53b3..39e58b48e82 100644 --- a/arch/arm/mach-davinci/include/mach/da8xx.h +++ b/arch/arm/mach-davinci/include/mach/da8xx.h @@ -15,19 +15,33 @@  #include <linux/platform_device.h>  #include <linux/davinci_emac.h> +#include <linux/spi/spi.h> +#include <linux/platform_data/davinci_asp.h> +#include <linux/reboot.h> +#include <linux/videodev2.h>  #include <mach/serial.h> -#include <mach/edma.h> -#include <mach/i2c.h> -#include <mach/asp.h> -#include <mach/mmc.h> -#include <mach/usb.h>  #include <mach/pm.h> +#include <linux/platform_data/edma.h> +#include <linux/platform_data/i2c-davinci.h> +#include <linux/platform_data/mmc-davinci.h> +#include <linux/platform_data/usb-davinci.h> +#include <linux/platform_data/spi-davinci.h> +#include <linux/platform_data/uio_pruss.h> + +#include <media/davinci/vpif_types.h>  extern void __iomem *da8xx_syscfg0_base;  extern void __iomem *da8xx_syscfg1_base;  /* + * If the DA850/OMAP-L138/AM18x SoC on board is of a higher speed grade + * (than the regular 300Mhz variant), the board code should set this up + * with the supported speed before calling da850_register_cpufreq(). + */ +extern unsigned int da850_max_speed; + +/*   * The cp_intc interrupt controller for the da8xx isn't in the same   * chunk of physical memory space as the other registers (like it is   * on the davincis) so it needs to be mapped separately.  It will be @@ -41,55 +55,70 @@ extern void __iomem *da8xx_syscfg1_base;  #define DA8XX_SYSCFG0_BASE	(IO_PHYS + 0x14000)  #define DA8XX_SYSCFG0_VIRT(x)	(da8xx_syscfg0_base + (x))  #define DA8XX_JTAG_ID_REG	0x18 +#define DA8XX_HOST1CFG_REG	0x44 +#define DA8XX_CHIPSIG_REG	0x174  #define DA8XX_CFGCHIP0_REG	0x17c +#define DA8XX_CFGCHIP1_REG	0x180  #define DA8XX_CFGCHIP2_REG	0x184  #define DA8XX_CFGCHIP3_REG	0x188  #define DA8XX_SYSCFG1_BASE	(IO_PHYS + 0x22C000)  #define DA8XX_SYSCFG1_VIRT(x)	(da8xx_syscfg1_base + (x))  #define DA8XX_DEEPSLEEP_REG	0x8 +#define DA8XX_PWRDN_REG		0x18  #define DA8XX_PSC0_BASE		0x01c10000  #define DA8XX_PLL0_BASE		0x01c11000  #define DA8XX_TIMER64P0_BASE	0x01c20000  #define DA8XX_TIMER64P1_BASE	0x01c21000 +#define DA8XX_VPIF_BASE		0x01e17000  #define DA8XX_GPIO_BASE		0x01e26000  #define DA8XX_PSC1_BASE		0x01e27000 -#define DA8XX_LCD_CNTRL_BASE	0x01e13000 -#define DA8XX_PLL1_BASE		0x01e1a000 -#define DA8XX_MMCSD0_BASE	0x01c40000  #define DA8XX_AEMIF_CS2_BASE	0x60000000  #define DA8XX_AEMIF_CS3_BASE	0x62000000  #define DA8XX_AEMIF_CTL_BASE	0x68000000 -#define DA8XX_DDR2_CTL_BASE	0xb0000000 +#define DA8XX_SHARED_RAM_BASE	0x80000000  #define DA8XX_ARM_RAM_BASE	0xffff0000 -void __init da830_init(void); -void __init da850_init(void); +void da830_init(void); +void da850_init(void);  int da830_register_edma(struct edma_rsv_info *rsv);  int da850_register_edma(struct edma_rsv_info *rsv[2]);  int da8xx_register_i2c(int instance, struct davinci_i2c_platform_data *pdata); +int da8xx_register_spi_bus(int instance, unsigned num_chipselect);  int da8xx_register_watchdog(void);  int da8xx_register_usb20(unsigned mA, unsigned potpgt);  int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);  int da8xx_register_emac(void); +int da8xx_register_uio_pruss(void);  int da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata);  int da8xx_register_mmcsd0(struct davinci_mmc_config *config);  int da850_register_mmcsd1(struct davinci_mmc_config *config); -void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata); +void da8xx_register_mcasp(int id, struct snd_platform_data *pdata);  int da8xx_register_rtc(void); +int da8xx_register_gpio(void *pdata);  int da850_register_cpufreq(char *async_clk);  int da8xx_register_cpuidle(void); -void __iomem * __init da8xx_get_mem_ctlr(void); +void __iomem *da8xx_get_mem_ctlr(void);  int da850_register_pm(struct platform_device *pdev); +int da850_register_sata(unsigned long refclkpn); +int da850_register_vpif(void); +int da850_register_vpif_display +			(struct vpif_display_config *display_config); +int da850_register_vpif_capture +			(struct vpif_capture_config *capture_config); +void da8xx_restart(enum reboot_mode mode, const char *cmd); +void da8xx_rproc_reserve_cma(void); +int da8xx_register_rproc(void); +int da850_register_gpio(void); +int da830_register_gpio(void); -extern struct platform_device da8xx_serial_device; +extern struct platform_device da8xx_serial_device[];  extern struct emac_platform_data da8xx_emac_pdata;  extern struct da8xx_lcdc_platform_data sharp_lcd035q3dg01_pdata;  extern struct da8xx_lcdc_platform_data sharp_lk043t1dg01_pdata; -extern struct platform_device da8xx_wdt_device;  extern const short da830_emif25_pins[];  extern const short da830_spi0_pins[]; @@ -115,16 +144,11 @@ extern const short da830_ecap1_pins[];  extern const short da830_ecap2_pins[];  extern const short da830_eqep0_pins[];  extern const short da830_eqep1_pins[]; +extern const short da850_vpif_capture_pins[]; +extern const short da850_vpif_display_pins[]; -extern const short da850_uart0_pins[]; -extern const short da850_uart1_pins[]; -extern const short da850_uart2_pins[];  extern const short da850_i2c0_pins[];  extern const short da850_i2c1_pins[]; -extern const short da850_cpgmac_pins[]; -extern const short da850_mcasp_pins[];  extern const short da850_lcdcntl_pins[]; -extern const short da850_mmcsd0_pins[]; -extern const short da850_emif25_pins[];  #endif /* __ASM_ARCH_DAVINCI_DA8XX_H */ diff --git a/arch/arm/mach-davinci/include/mach/ddr2.h b/arch/arm/mach-davinci/include/mach/ddr2.h new file mode 100644 index 00000000000..c19e047d0e6 --- /dev/null +++ b/arch/arm/mach-davinci/include/mach/ddr2.h @@ -0,0 +1,4 @@ +#define DDR2_SDRCR_OFFSET	0xc +#define DDR2_SRPD_BIT		(1 << 23) +#define DDR2_MCLKSTOPEN_BIT	(1 << 30) +#define DDR2_LPMODEN_BIT	(1 << 31) diff --git a/arch/arm/mach-davinci/include/mach/debug-macro.S b/arch/arm/mach-davinci/include/mach/debug-macro.S deleted file mode 100644 index 9f1befc5ac3..00000000000 --- a/arch/arm/mach-davinci/include/mach/debug-macro.S +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Debugging macro for DaVinci - * - * 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. - */ - -/* Modifications - * Jan 2009	Chaithrika U S	Added senduart, busyuart, waituart - *				macros, based on debug-8250.S file - *				but using 32-bit accesses required for - *                              some davinci devices. - */ - -#include <linux/serial_reg.h> - -#include <asm/memory.h> - -#include <mach/serial.h> - -#define UART_SHIFT	2 - -		.pushsection .data -davinci_uart_phys:	.word	0 -davinci_uart_virt:	.word	0 -		.popsection - -		.macro addruart, rp, rv - -		/* Use davinci_uart_phys/virt if already configured */ -10:		mrc	p15, 0, \rp, c1, c0 -		tst	\rp, #1			@ MMU enabled? -		ldreq	\rp, =__virt_to_phys(davinci_uart_phys) -		ldrne	\rp, =davinci_uart_phys -		add	\rv, \rp, #4		@ davinci_uart_virt -		ldr	\rp, [\rp, #0] -		ldr	\rv, [\rv, #0] -		cmp	\rp, #0			@ is port configured? -		cmpne	\rv, #0 -		bne	99f			@ already configured - -		/* Check the debug UART address set in uncompress.h */ -		mrc	p15, 0, \rp, c1, c0 -		tst	\rp, #1			@ MMU enabled? - -		/* Copy uart phys address from decompressor uart info */ -		ldreq	\rv, =__virt_to_phys(davinci_uart_phys) -		ldrne	\rv, =davinci_uart_phys -		ldreq	\rp, =DAVINCI_UART_INFO -		ldrne	\rp, =__phys_to_virt(DAVINCI_UART_INFO) -		ldr	\rp, [\rp, #0] -		str	\rp, [\rv] - -		/* Copy uart virt address from decompressor uart info */ -		ldreq	\rv, =__virt_to_phys(davinci_uart_virt) -		ldrne	\rv, =davinci_uart_virt -		ldreq	\rp, =DAVINCI_UART_INFO -		ldrne	\rp, =__phys_to_virt(DAVINCI_UART_INFO) -		ldr	\rp, [\rp, #4] -		str	\rp, [\rv] - -		b	10b -99: -		.endm - -		.macro	senduart,rd,rx -		str	\rd, [\rx, #UART_TX << UART_SHIFT] -		.endm - -		.macro	busyuart,rd,rx -1002:		ldr	\rd, [\rx, #UART_LSR << UART_SHIFT] -		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE -		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE -		bne	1002b -		.endm - -		.macro	waituart,rd,rx -#ifdef FLOW_CONTROL -1001:		ldr	\rd, [\rx, #UART_MSR << UART_SHIFT] -		tst	\rd, #UART_MSR_CTS -		beq	1001b -#endif -		.endm - diff --git a/arch/arm/mach-davinci/include/mach/dm355.h b/arch/arm/mach-davinci/include/mach/dm355.h deleted file mode 100644 index 36dff4a0ce3..00000000000 --- a/arch/arm/mach-davinci/include/mach/dm355.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Chip specific defines for DM355 SoC - * - * Author: Kevin Hilman, Deep Root Systems, LLC - * - * 2007 (c) Deep Root Systems, LLC. 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. - */ -#ifndef __ASM_ARCH_DM355_H -#define __ASM_ARCH_DM355_H - -#include <mach/hardware.h> -#include <mach/asp.h> -#include <media/davinci/vpfe_capture.h> - -#define DM355_ASYNC_EMIF_CONTROL_BASE	0x01E10000 -#define DM355_ASYNC_EMIF_DATA_CE0_BASE	0x02000000 - -#define ASP1_TX_EVT_EN	1 -#define ASP1_RX_EVT_EN	2 - -struct spi_board_info; - -void __init dm355_init(void); -void dm355_init_spi0(unsigned chipselect_mask, -		struct spi_board_info *info, unsigned len); -void __init dm355_init_asp1(u32 evt_enable, struct snd_platform_data *pdata); -void dm355_set_vpfe_config(struct vpfe_config *cfg); - -#endif /* __ASM_ARCH_DM355_H */ diff --git a/arch/arm/mach-davinci/include/mach/dm365.h b/arch/arm/mach-davinci/include/mach/dm365.h deleted file mode 100644 index 2563bf4e93a..00000000000 --- a/arch/arm/mach-davinci/include/mach/dm365.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (C) 2009 Texas Instruments Incorporated - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - */ -#ifndef __ASM_ARCH_DM365_H -#define __ASM_ARCH_DM665_H - -#include <linux/platform_device.h> -#include <linux/davinci_emac.h> -#include <mach/hardware.h> -#include <mach/asp.h> -#include <mach/keyscan.h> -#include <media/davinci/vpfe_capture.h> - -#define DM365_EMAC_BASE			(0x01D07000) -#define DM365_EMAC_MDIO_BASE		(DM365_EMAC_BASE + 0x4000) -#define DM365_EMAC_CNTRL_OFFSET		(0x0000) -#define DM365_EMAC_CNTRL_MOD_OFFSET	(0x3000) -#define DM365_EMAC_CNTRL_RAM_OFFSET	(0x1000) -#define DM365_EMAC_CNTRL_RAM_SIZE	(0x2000) - -/* Base of key scan register bank */ -#define DM365_KEYSCAN_BASE		(0x01C69400) - -#define DM365_RTC_BASE			(0x01C69000) - -#define DAVINCI_DM365_VC_BASE		(0x01D0C000) -#define DAVINCI_DMA_VC_TX		2 -#define DAVINCI_DMA_VC_RX		3 - -#define DM365_ASYNC_EMIF_CONTROL_BASE	0x01D10000 -#define DM365_ASYNC_EMIF_DATA_CE0_BASE	0x02000000 -#define DM365_ASYNC_EMIF_DATA_CE1_BASE	0x04000000 - -void __init dm365_init(void); -void __init dm365_init_asp(struct snd_platform_data *pdata); -void __init dm365_init_vc(struct snd_platform_data *pdata); -void __init dm365_init_ks(struct davinci_ks_platform_data *pdata); -void __init dm365_init_rtc(void); -void dm365_init_spi0(unsigned chipselect_mask, -			struct spi_board_info *info, unsigned len); - -void dm365_set_vpfe_config(struct vpfe_config *cfg); -#endif /* __ASM_ARCH_DM365_H */ diff --git a/arch/arm/mach-davinci/include/mach/dm644x.h b/arch/arm/mach-davinci/include/mach/dm644x.h deleted file mode 100644 index 5a1b26d4e68..00000000000 --- a/arch/arm/mach-davinci/include/mach/dm644x.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * This file contains the processor specific definitions - * of the TI DM644x. - * - * Copyright (C) 2008 Texas Instruments. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA - * - */ -#ifndef __ASM_ARCH_DM644X_H -#define __ASM_ARCH_DM644X_H - -#include <linux/davinci_emac.h> -#include <mach/hardware.h> -#include <mach/asp.h> -#include <media/davinci/vpfe_capture.h> - -#define DM644X_EMAC_BASE		(0x01C80000) -#define DM644X_EMAC_MDIO_BASE		(DM644X_EMAC_BASE + 0x4000) -#define DM644X_EMAC_CNTRL_OFFSET	(0x0000) -#define DM644X_EMAC_CNTRL_MOD_OFFSET	(0x1000) -#define DM644X_EMAC_CNTRL_RAM_OFFSET	(0x2000) -#define DM644X_EMAC_CNTRL_RAM_SIZE	(0x2000) - -#define DM644X_ASYNC_EMIF_CONTROL_BASE	0x01E00000 -#define DM644X_ASYNC_EMIF_DATA_CE0_BASE 0x02000000 -#define DM644X_ASYNC_EMIF_DATA_CE1_BASE 0x04000000 -#define DM644X_ASYNC_EMIF_DATA_CE2_BASE 0x06000000 -#define DM644X_ASYNC_EMIF_DATA_CE3_BASE 0x08000000 - -void __init dm644x_init(void); -void __init dm644x_init_asp(struct snd_platform_data *pdata); -void dm644x_set_vpfe_config(struct vpfe_config *cfg); - -#endif /* __ASM_ARCH_DM644X_H */ diff --git a/arch/arm/mach-davinci/include/mach/dm646x.h b/arch/arm/mach-davinci/include/mach/dm646x.h deleted file mode 100644 index 7a27f3f1391..00000000000 --- a/arch/arm/mach-davinci/include/mach/dm646x.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Chip specific defines for DM646x SoC - * - * Author: Kevin Hilman, Deep Root Systems, LLC - * - * 2007 (c) Deep Root Systems, LLC. 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. - */ -#ifndef __ASM_ARCH_DM646X_H -#define __ASM_ARCH_DM646X_H - -#include <mach/hardware.h> -#include <mach/asp.h> -#include <linux/i2c.h> -#include <linux/videodev2.h> -#include <linux/clk.h> -#include <linux/davinci_emac.h> - -#define DM646X_EMAC_BASE		(0x01C80000) -#define DM646X_EMAC_MDIO_BASE		(DM646X_EMAC_BASE + 0x4000) -#define DM646X_EMAC_CNTRL_OFFSET	(0x0000) -#define DM646X_EMAC_CNTRL_MOD_OFFSET	(0x1000) -#define DM646X_EMAC_CNTRL_RAM_OFFSET	(0x2000) -#define DM646X_EMAC_CNTRL_RAM_SIZE	(0x2000) - -#define DM646X_ASYNC_EMIF_CONTROL_BASE	0x20008000 -#define DM646X_ASYNC_EMIF_CS2_SPACE_BASE 0x42000000 - -void __init dm646x_init(void); -void __init dm646x_init_mcasp0(struct snd_platform_data *pdata); -void __init dm646x_init_mcasp1(struct snd_platform_data *pdata); -void __init dm646x_board_setup_refclk(struct clk *clk); -int __init dm646x_init_edma(struct edma_rsv_info *rsv); - -void dm646x_video_init(void); - -enum vpif_if_type { -	VPIF_IF_BT656, -	VPIF_IF_BT1120, -	VPIF_IF_RAW_BAYER -}; - -struct vpif_interface { -	enum vpif_if_type if_type; -	unsigned hd_pol:1; -	unsigned vd_pol:1; -	unsigned fid_pol:1; -}; - -struct vpif_subdev_info { -	const char *name; -	struct i2c_board_info board_info; -	u32 input; -	u32 output; -	unsigned can_route:1; -	struct vpif_interface vpif_if; -}; - -struct vpif_display_config { -	int (*set_clock)(int, int); -	struct vpif_subdev_info *subdevinfo; -	int subdev_count; -	const char **output; -	int output_count; -	const char *card_name; -}; - -struct vpif_input { -	struct v4l2_input input; -	const char *subdev_name; -}; - -#define VPIF_CAPTURE_MAX_CHANNELS	2 - -struct vpif_capture_chan_config { -	const struct vpif_input *inputs; -	int input_count; -}; - -struct vpif_capture_config { -	int (*setup_input_channel_mode)(int); -	int (*setup_input_path)(int, const char *); -	struct vpif_capture_chan_config chan_config[VPIF_CAPTURE_MAX_CHANNELS]; -	struct vpif_subdev_info *subdev_info; -	int subdev_count; -	const char *card_name; -}; - -void dm646x_setup_vpif(struct vpif_display_config *, -		       struct vpif_capture_config *); - -#endif /* __ASM_ARCH_DM646X_H */ diff --git a/arch/arm/mach-davinci/include/mach/edma.h b/arch/arm/mach-davinci/include/mach/edma.h deleted file mode 100644 index dc10ef6cf57..00000000000 --- a/arch/arm/mach-davinci/include/mach/edma.h +++ /dev/null @@ -1,298 +0,0 @@ -/* - *  TI DAVINCI dma definitions - * - *  Copyright (C) 2006-2009 Texas Instruments. - * - *  This program is free software; you can redistribute  it and/or modify it - *  under  the terms of  the GNU General  Public License as published by the - *  Free Software Foundation;  either version 2 of the  License, or (at your - *  option) any later version. - * - *  THIS  SOFTWARE  IS PROVIDED   ``AS  IS'' AND   ANY  EXPRESS OR IMPLIED - *  WARRANTIES,   INCLUDING, BUT NOT  LIMITED  TO, THE IMPLIED WARRANTIES OF - *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN - *  NO  EVENT  SHALL   THE AUTHOR  BE    LIABLE FOR ANY   DIRECT, INDIRECT, - *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - *  NOT LIMITED   TO, PROCUREMENT OF  SUBSTITUTE GOODS  OR SERVICES; LOSS OF - *  USE, DATA,  OR PROFITS; OR  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON - *  ANY THEORY OF LIABILITY, WHETHER IN  CONTRACT, STRICT LIABILITY, OR TORT - *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - *  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - *  You should have received a copy of the  GNU General Public License along - *  with this program; if not, write  to the Free Software Foundation, Inc., - *  675 Mass Ave, Cambridge, MA 02139, USA. - * - */ - -/* - * This EDMA3 programming framework exposes two basic kinds of resource: - * - *  Channel	Triggers transfers, usually from a hardware event but - *		also manually or by "chaining" from DMA completions. - *		Each channel is coupled to a Parameter RAM (PaRAM) slot. - * - *  Slot	Each PaRAM slot holds a DMA transfer descriptor (PaRAM - *		"set"), source and destination addresses, a link to a - *		next PaRAM slot (if any), options for the transfer, and - *		instructions for updating those addresses.  There are - *		more than twice as many slots as event channels. - * - * Each PaRAM set describes a sequence of transfers, either for one large - * buffer or for several discontiguous smaller buffers.  An EDMA transfer - * is driven only from a channel, which performs the transfers specified - * in its PaRAM slot until there are no more transfers.  When that last - * transfer completes, the "link" field may be used to reload the channel's - * PaRAM slot with a new transfer descriptor. - * - * The EDMA Channel Controller (CC) maps requests from channels into physical - * Transfer Controller (TC) requests when the channel triggers (by hardware - * or software events, or by chaining).  The two physical DMA channels provided - * by the TCs are thus shared by many logical channels. - * - * DaVinci hardware also has a "QDMA" mechanism which is not currently - * supported through this interface.  (DSP firmware uses it though.) - */ - -#ifndef EDMA_H_ -#define EDMA_H_ - -/* PaRAM slots are laid out like this */ -struct edmacc_param { -	unsigned int opt; -	unsigned int src; -	unsigned int a_b_cnt; -	unsigned int dst; -	unsigned int src_dst_bidx; -	unsigned int link_bcntrld; -	unsigned int src_dst_cidx; -	unsigned int ccnt; -}; - -#define CCINT0_INTERRUPT     16 -#define CCERRINT_INTERRUPT   17 -#define TCERRINT0_INTERRUPT   18 -#define TCERRINT1_INTERRUPT   19 - -/* fields in edmacc_param.opt */ -#define SAM		BIT(0) -#define DAM		BIT(1) -#define SYNCDIM		BIT(2) -#define STATIC		BIT(3) -#define EDMA_FWID	(0x07 << 8) -#define TCCMODE		BIT(11) -#define EDMA_TCC(t)	((t) << 12) -#define TCINTEN		BIT(20) -#define ITCINTEN	BIT(21) -#define TCCHEN		BIT(22) -#define ITCCHEN		BIT(23) - -#define TRWORD (0x7<<2) -#define PAENTRY (0x1ff<<5) - -/* Drivers should avoid using these symbolic names for dm644x - * channels, and use platform_device IORESOURCE_DMA resources - * instead.  (Other DaVinci chips have different peripherals - * and thus have different DMA channel mappings.) - */ -#define DAVINCI_DMA_MCBSP_TX              2 -#define DAVINCI_DMA_MCBSP_RX              3 -#define DAVINCI_DMA_VPSS_HIST             4 -#define DAVINCI_DMA_VPSS_H3A              5 -#define DAVINCI_DMA_VPSS_PRVU             6 -#define DAVINCI_DMA_VPSS_RSZ              7 -#define DAVINCI_DMA_IMCOP_IMXINT          8 -#define DAVINCI_DMA_IMCOP_VLCDINT         9 -#define DAVINCI_DMA_IMCO_PASQINT         10 -#define DAVINCI_DMA_IMCOP_DSQINT         11 -#define DAVINCI_DMA_SPI_SPIX             16 -#define DAVINCI_DMA_SPI_SPIR             17 -#define DAVINCI_DMA_UART0_URXEVT0        18 -#define DAVINCI_DMA_UART0_UTXEVT0        19 -#define DAVINCI_DMA_UART1_URXEVT1        20 -#define DAVINCI_DMA_UART1_UTXEVT1        21 -#define DAVINCI_DMA_UART2_URXEVT2        22 -#define DAVINCI_DMA_UART2_UTXEVT2        23 -#define DAVINCI_DMA_MEMSTK_MSEVT         24 -#define DAVINCI_DMA_MMCRXEVT             26 -#define DAVINCI_DMA_MMCTXEVT             27 -#define DAVINCI_DMA_I2C_ICREVT           28 -#define DAVINCI_DMA_I2C_ICXEVT           29 -#define DAVINCI_DMA_GPIO_GPINT0          32 -#define DAVINCI_DMA_GPIO_GPINT1          33 -#define DAVINCI_DMA_GPIO_GPINT2          34 -#define DAVINCI_DMA_GPIO_GPINT3          35 -#define DAVINCI_DMA_GPIO_GPINT4          36 -#define DAVINCI_DMA_GPIO_GPINT5          37 -#define DAVINCI_DMA_GPIO_GPINT6          38 -#define DAVINCI_DMA_GPIO_GPINT7          39 -#define DAVINCI_DMA_GPIO_GPBNKINT0       40 -#define DAVINCI_DMA_GPIO_GPBNKINT1       41 -#define DAVINCI_DMA_GPIO_GPBNKINT2       42 -#define DAVINCI_DMA_GPIO_GPBNKINT3       43 -#define DAVINCI_DMA_GPIO_GPBNKINT4       44 -#define DAVINCI_DMA_TIMER0_TINT0         48 -#define DAVINCI_DMA_TIMER1_TINT1         49 -#define DAVINCI_DMA_TIMER2_TINT2         50 -#define DAVINCI_DMA_TIMER3_TINT3         51 -#define DAVINCI_DMA_PWM0                 52 -#define DAVINCI_DMA_PWM1                 53 -#define DAVINCI_DMA_PWM2                 54 - -/* DA830 specific EDMA3 information */ -#define EDMA_DA830_NUM_DMACH		32 -#define EDMA_DA830_NUM_TCC		32 -#define EDMA_DA830_NUM_PARAMENTRY	128 -#define EDMA_DA830_NUM_EVQUE		2 -#define EDMA_DA830_NUM_TC		2 -#define EDMA_DA830_CHMAP_EXIST		0 -#define EDMA_DA830_NUM_REGIONS		4 -#define DA830_DMACH2EVENT_MAP0		0x000FC03Fu -#define DA830_DMACH2EVENT_MAP1		0x00000000u -#define DA830_EDMA_ARM_OWN		0x30FFCCFFu - -/* DA830 specific EDMA3 Events Information */ -enum DA830_edma_ch { -	DA830_DMACH_MCASP0_RX, -	DA830_DMACH_MCASP0_TX, -	DA830_DMACH_MCASP1_RX, -	DA830_DMACH_MCASP1_TX, -	DA830_DMACH_MCASP2_RX, -	DA830_DMACH_MCASP2_TX, -	DA830_DMACH_GPIO_BNK0INT, -	DA830_DMACH_GPIO_BNK1INT, -	DA830_DMACH_UART0_RX, -	DA830_DMACH_UART0_TX, -	DA830_DMACH_TMR64P0_EVTOUT12, -	DA830_DMACH_TMR64P0_EVTOUT34, -	DA830_DMACH_UART1_RX, -	DA830_DMACH_UART1_TX, -	DA830_DMACH_SPI0_RX, -	DA830_DMACH_SPI0_TX, -	DA830_DMACH_MMCSD_RX, -	DA830_DMACH_MMCSD_TX, -	DA830_DMACH_SPI1_RX, -	DA830_DMACH_SPI1_TX, -	DA830_DMACH_DMAX_EVTOUT6, -	DA830_DMACH_DMAX_EVTOUT7, -	DA830_DMACH_GPIO_BNK2INT, -	DA830_DMACH_GPIO_BNK3INT, -	DA830_DMACH_I2C0_RX, -	DA830_DMACH_I2C0_TX, -	DA830_DMACH_I2C1_RX, -	DA830_DMACH_I2C1_TX, -	DA830_DMACH_GPIO_BNK4INT, -	DA830_DMACH_GPIO_BNK5INT, -	DA830_DMACH_UART2_RX, -	DA830_DMACH_UART2_TX -}; - -/*ch_status paramater of callback function possible values*/ -#define DMA_COMPLETE 1 -#define DMA_CC_ERROR 2 -#define DMA_TC1_ERROR 3 -#define DMA_TC2_ERROR 4 - -enum address_mode { -	INCR = 0, -	FIFO = 1 -}; - -enum fifo_width { -	W8BIT = 0, -	W16BIT = 1, -	W32BIT = 2, -	W64BIT = 3, -	W128BIT = 4, -	W256BIT = 5 -}; - -enum dma_event_q { -	EVENTQ_0 = 0, -	EVENTQ_1 = 1, -	EVENTQ_2 = 2, -	EVENTQ_3 = 3, -	EVENTQ_DEFAULT = -1 -}; - -enum sync_dimension { -	ASYNC = 0, -	ABSYNC = 1 -}; - -#define EDMA_CTLR_CHAN(ctlr, chan)	(((ctlr) << 16) | (chan)) -#define EDMA_CTLR(i)			((i) >> 16) -#define EDMA_CHAN_SLOT(i)		((i) & 0xffff) - -#define EDMA_CHANNEL_ANY		-1	/* for edma_alloc_channel() */ -#define EDMA_SLOT_ANY			-1	/* for edma_alloc_slot() */ -#define EDMA_CONT_PARAMS_ANY		 1001 -#define EDMA_CONT_PARAMS_FIXED_EXACT	 1002 -#define EDMA_CONT_PARAMS_FIXED_NOT_EXACT 1003 - -#define EDMA_MAX_CC               2 - -/* alloc/free DMA channels and their dedicated parameter RAM slots */ -int edma_alloc_channel(int channel, -	void (*callback)(unsigned channel, u16 ch_status, void *data), -	void *data, enum dma_event_q); -void edma_free_channel(unsigned channel); - -/* alloc/free parameter RAM slots */ -int edma_alloc_slot(unsigned ctlr, int slot); -void edma_free_slot(unsigned slot); - -/* alloc/free a set of contiguous parameter RAM slots */ -int edma_alloc_cont_slots(unsigned ctlr, unsigned int id, int slot, int count); -int edma_free_cont_slots(unsigned slot, int count); - -/* calls that operate on part of a parameter RAM slot */ -void edma_set_src(unsigned slot, dma_addr_t src_port, -				enum address_mode mode, enum fifo_width); -void edma_set_dest(unsigned slot, dma_addr_t dest_port, -				 enum address_mode mode, enum fifo_width); -void edma_get_position(unsigned slot, dma_addr_t *src, dma_addr_t *dst); -void edma_set_src_index(unsigned slot, s16 src_bidx, s16 src_cidx); -void edma_set_dest_index(unsigned slot, s16 dest_bidx, s16 dest_cidx); -void edma_set_transfer_params(unsigned slot, u16 acnt, u16 bcnt, u16 ccnt, -		u16 bcnt_rld, enum sync_dimension sync_mode); -void edma_link(unsigned from, unsigned to); -void edma_unlink(unsigned from); - -/* calls that operate on an entire parameter RAM slot */ -void edma_write_slot(unsigned slot, const struct edmacc_param *params); -void edma_read_slot(unsigned slot, struct edmacc_param *params); - -/* channel control operations */ -int edma_start(unsigned channel); -void edma_stop(unsigned channel); -void edma_clean_channel(unsigned channel); -void edma_clear_event(unsigned channel); -void edma_pause(unsigned channel); -void edma_resume(unsigned channel); - -struct edma_rsv_info { - -	const s16	(*rsv_chans)[2]; -	const s16	(*rsv_slots)[2]; -}; - -/* platform_data for EDMA driver */ -struct edma_soc_info { - -	/* how many dma resources of each type */ -	unsigned	n_channel; -	unsigned	n_region; -	unsigned	n_slot; -	unsigned	n_tc; -	unsigned	n_cc; -	enum dma_event_q	default_queue; - -	/* Resource reservation for other cores */ -	struct edma_rsv_info	*rsv; - -	const s8	(*queue_tc_mapping)[2]; -	const s8	(*queue_priority_mapping)[2]; -}; - -#endif diff --git a/arch/arm/mach-davinci/include/mach/entry-macro.S b/arch/arm/mach-davinci/include/mach/entry-macro.S index fbdebc7cb40..cf5f573eb5f 100644 --- a/arch/arm/mach-davinci/include/mach/entry-macro.S +++ b/arch/arm/mach-davinci/include/mach/entry-macro.S @@ -8,20 +8,13 @@   * is licensed "as is" without any warranty of any kind, whether express   * or implied.   */ -#include <mach/io.h>  #include <mach/irqs.h> -		.macro	disable_fiq -		.endm -  		.macro  get_irqnr_preamble, base, tmp  		ldr \base, =davinci_intc_base  		ldr \base, [\base]  		.endm -		.macro  arch_ret_to_user, tmp1, tmp2 -		.endm -  		.macro	get_irqnr_and_base, irqnr, irqstat, base, tmp  #if defined(CONFIG_AINTC) && defined(CONFIG_CP_INTC)  		ldr \tmp, =davinci_intc_type @@ -37,15 +30,10 @@  #endif  #if defined(CONFIG_CP_INTC)  1001:		ldr \irqnr, [\base, #0x80] /* get irq number */ +		mov \tmp, \irqnr, lsr #31  		and \irqnr, \irqnr, #0xff  /* irq is in bits 0-9 */ -		mov \tmp, \irqnr, lsr #3 -		and \tmp, \tmp, #0xfc -		add \tmp, \tmp, #0x280 /* get the register offset */ -		ldr \irqstat, [\base, \tmp] /* get the intc status */ -		cmp \irqstat, #0x0 +		and \tmp, \tmp, #0x1 +		cmp \tmp, #0x1  #endif  1002:  		.endm - -		.macro	irq_prio_table -		.endm diff --git a/arch/arm/mach-davinci/include/mach/gpio.h b/arch/arm/mach-davinci/include/mach/gpio.h deleted file mode 100644 index fbece126c2b..00000000000 --- a/arch/arm/mach-davinci/include/mach/gpio.h +++ /dev/null @@ -1,161 +0,0 @@ -/* - * TI DaVinci GPIO Support - * - * Copyright (c) 2006 David Brownell - * Copyright (c) 2007, MontaVista Software, Inc. <source@mvista.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#ifndef	__DAVINCI_GPIO_H -#define	__DAVINCI_GPIO_H - -#include <linux/io.h> -#include <linux/spinlock.h> - -#include <asm-generic/gpio.h> - -#include <mach/irqs.h> -#include <mach/common.h> - -#define DAVINCI_GPIO_BASE 0x01C67000 - -enum davinci_gpio_type { -	GPIO_TYPE_DAVINCI = 0, -	GPIO_TYPE_TNETV107X, -}; - -/* - * basic gpio routines - * - * board-specific init should be done by arch/.../.../board-XXX.c (maybe - * initializing banks together) rather than boot loaders; kexec() won't - * go through boot loaders. - * - * the gpio clock will be turned on when gpios are used, and you may also - * need to pay attention to PINMUX registers to be sure those pins are - * used as gpios, not with other peripherals. - * - * On-chip GPIOs are numbered 0..(DAVINCI_N_GPIO-1).  For documentation, - * and maybe for later updates, code may write GPIO(N).  These may be - * all 1.8V signals, all 3.3V ones, or a mix of the two.  A given chip - * may not support all the GPIOs in that range. - * - * GPIOs can also be on external chips, numbered after the ones built-in - * to the DaVinci chip.  For now, they won't be usable as IRQ sources. - */ -#define	GPIO(X)		(X)		/* 0 <= X <= (DAVINCI_N_GPIO - 1) */ - -/* Convert GPIO signal to GPIO pin number */ -#define GPIO_TO_PIN(bank, gpio)	(16 * (bank) + (gpio)) - -struct davinci_gpio_controller { -	struct gpio_chip	chip; -	int			irq_base; -	spinlock_t		lock; -	void __iomem		*regs; -	void __iomem		*set_data; -	void __iomem		*clr_data; -	void __iomem		*in_data; -}; - -/* The __gpio_to_controller() and __gpio_mask() functions inline to constants - * with constant parameters; or in outlined code they execute at runtime. - * - * You'd access the controller directly when reading or writing more than - * one gpio value at a time, and to support wired logic where the value - * being driven by the cpu need not match the value read back. - * - * These are NOT part of the cross-platform GPIO interface - */ -static inline struct davinci_gpio_controller * -__gpio_to_controller(unsigned gpio) -{ -	struct davinci_gpio_controller *ctlrs = davinci_soc_info.gpio_ctlrs; -	int index = gpio / 32; - -	if (!ctlrs || index >= davinci_soc_info.gpio_ctlrs_num) -		return NULL; - -	return ctlrs + index; -} - -static inline u32 __gpio_mask(unsigned gpio) -{ -	return 1 << (gpio % 32); -} - -/* - * The get/set/clear functions will inline when called with constant - * parameters referencing built-in GPIOs, for low-overhead bitbanging. - * - * gpio_set_value() will inline only on traditional Davinci style controllers - * with distinct set/clear registers. - * - * Otherwise, calls with variable parameters or referencing external - * GPIOs (e.g. on GPIO expander chips) use outlined functions. - */ -static inline void gpio_set_value(unsigned gpio, int value) -{ -	if (__builtin_constant_p(value) && gpio < davinci_soc_info.gpio_num) { -		struct davinci_gpio_controller *ctlr; -		u32				mask; - -		ctlr = __gpio_to_controller(gpio); - -		if (ctlr->set_data != ctlr->clr_data) { -			mask = __gpio_mask(gpio); -			if (value) -				__raw_writel(mask, ctlr->set_data); -			else -				__raw_writel(mask, ctlr->clr_data); -			return; -		} -	} - -	__gpio_set_value(gpio, value); -} - -/* Returns zero or nonzero; works for gpios configured as inputs OR - * as outputs, at least for built-in GPIOs. - * - * NOTE: for built-in GPIOs, changes in reported values are synchronized - * to the GPIO clock.  This is easily seen after calling gpio_set_value() - * and then immediately gpio_get_value(), where the gpio_get_value() will - * return the old value until the GPIO clock ticks and the new value gets - * latched. - */ -static inline int gpio_get_value(unsigned gpio) -{ -	struct davinci_gpio_controller *ctlr; - -	if (!__builtin_constant_p(gpio) || gpio >= davinci_soc_info.gpio_num) -		return __gpio_get_value(gpio); - -	ctlr = __gpio_to_controller(gpio); -	return __gpio_mask(gpio) & __raw_readl(ctlr->in_data); -} - -static inline int gpio_cansleep(unsigned gpio) -{ -	if (__builtin_constant_p(gpio) && gpio < davinci_soc_info.gpio_num) -		return 0; -	else -		return __gpio_cansleep(gpio); -} - -static inline int gpio_to_irq(unsigned gpio) -{ -	return __gpio_to_irq(gpio); -} - -static inline int irq_to_gpio(unsigned irq) -{ -	/* don't support the reverse mapping */ -	return -ENOSYS; -} - -#endif				/* __DAVINCI_GPIO_H */ diff --git a/arch/arm/mach-davinci/include/mach/hardware.h b/arch/arm/mach-davinci/include/mach/hardware.h index c45ba1f62a1..16bb42291d3 100644 --- a/arch/arm/mach-davinci/include/mach/hardware.h +++ b/arch/arm/mach-davinci/include/mach/hardware.h @@ -19,15 +19,10 @@   * and the chip/board init code should then explicitly include   * <chipname>.h   */ -#define DAVINCI_SYSTEM_MODULE_BASE        0x01C40000 - -/* System control register offsets */ -#define DM64XX_VDD3P3V_PWDN	0x48 -  /*   * I/O mapping   */ -#define IO_PHYS				0x01c00000UL +#define IO_PHYS				UL(0x01c00000)  #define IO_OFFSET			0xfd000000 /* Virtual IO = 0xfec00000 */  #define IO_SIZE				0x00400000  #define IO_VIRT				(IO_PHYS + IO_OFFSET) @@ -35,10 +30,4 @@  #define __IO_ADDRESS(x)			((x) + IO_OFFSET)  #define IO_ADDRESS(pa)			IOMEM(__IO_ADDRESS(pa)) -#ifdef __ASSEMBLER__ -#define IOMEM(x)                	x -#else -#define IOMEM(x)                	((void __force __iomem *)(x)) -#endif -  #endif /* __ASM_ARCH_HARDWARE_H */ diff --git a/arch/arm/mach-davinci/include/mach/i2c.h b/arch/arm/mach-davinci/include/mach/i2c.h deleted file mode 100644 index 2312d197dfb..00000000000 --- a/arch/arm/mach-davinci/include/mach/i2c.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * DaVinci I2C controller platform_device info - * - * Author: Vladimir Barinov, 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. -*/ - -#ifndef __ASM_ARCH_I2C_H -#define __ASM_ARCH_I2C_H - -/* All frequencies are expressed in kHz */ -struct davinci_i2c_platform_data { -	unsigned int	bus_freq;	/* standard bus frequency (kHz) */ -	unsigned int	bus_delay;	/* post-transaction delay (usec) */ -	unsigned int    sda_pin;        /* GPIO pin ID to use for SDA */ -	unsigned int    scl_pin;        /* GPIO pin ID to use for SCL */ -}; - -/* for board setup code */ -void davinci_init_i2c(struct davinci_i2c_platform_data *); - -#endif /* __ASM_ARCH_I2C_H */ diff --git a/arch/arm/mach-davinci/include/mach/io.h b/arch/arm/mach-davinci/include/mach/io.h deleted file mode 100644 index 62b0a90309a..00000000000 --- a/arch/arm/mach-davinci/include/mach/io.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - * DaVinci IO address definitions - * - * Copied from include/asm/arm/arch-omap/io.h - * - * 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. - */ -#ifndef __ASM_ARCH_IO_H -#define __ASM_ARCH_IO_H - -#define IO_SPACE_LIMIT 0xffffffff - -/* - * We don't actually have real ISA nor PCI buses, but there is so many - * drivers out there that might just work if we fake them... - */ -#define __io(a)			__typesafe_io(a) -#define __mem_pci(a)		(a) -#define __mem_isa(a)		(a) - -#ifndef __ASSEMBLER__ -#define __arch_ioremap(p, s, t)	davinci_ioremap(p, s, t) -#define __arch_iounmap(v)	davinci_iounmap(v) - -void __iomem *davinci_ioremap(unsigned long phys, size_t size, -			      unsigned int type); -void davinci_iounmap(volatile void __iomem *addr); -#endif -#endif /* __ASM_ARCH_IO_H */ diff --git a/arch/arm/mach-davinci/include/mach/irqs.h b/arch/arm/mach-davinci/include/mach/irqs.h index ec76c7775c2..354af71798d 100644 --- a/arch/arm/mach-davinci/include/mach/irqs.h +++ b/arch/arm/mach-davinci/include/mach/irqs.h @@ -401,103 +401,6 @@  #define DA850_N_CP_INTC_IRQ		101 - -/* TNETV107X specific interrupts */ -#define IRQ_TNETV107X_TDM1_TXDMA		0 -#define IRQ_TNETV107X_EXT_INT_0			1 -#define IRQ_TNETV107X_EXT_INT_1			2 -#define IRQ_TNETV107X_GPIO_INT12		3 -#define IRQ_TNETV107X_GPIO_INT13		4 -#define IRQ_TNETV107X_TIMER_0_TINT12		5 -#define IRQ_TNETV107X_TIMER_1_TINT12		6 -#define IRQ_TNETV107X_UART0			7 -#define IRQ_TNETV107X_TDM1_RXDMA		8 -#define IRQ_TNETV107X_MCDMA_INT0		9 -#define IRQ_TNETV107X_MCDMA_INT1		10 -#define IRQ_TNETV107X_TPCC			11 -#define IRQ_TNETV107X_TPCC_INT0			12 -#define IRQ_TNETV107X_TPCC_INT1			13 -#define IRQ_TNETV107X_TPCC_INT2			14 -#define IRQ_TNETV107X_TPCC_INT3			15 -#define IRQ_TNETV107X_TPTC0			16 -#define IRQ_TNETV107X_TPTC1			17 -#define IRQ_TNETV107X_TIMER_0_TINT34		18 -#define IRQ_TNETV107X_ETHSS			19 -#define IRQ_TNETV107X_TIMER_1_TINT34		20 -#define IRQ_TNETV107X_DSP2ARM_INT0		21 -#define IRQ_TNETV107X_DSP2ARM_INT1		22 -#define IRQ_TNETV107X_ARM_NPMUIRQ		23 -#define IRQ_TNETV107X_USB1			24 -#define IRQ_TNETV107X_VLYNQ			25 -#define IRQ_TNETV107X_UART0_DMATX		26 -#define IRQ_TNETV107X_UART0_DMARX		27 -#define IRQ_TNETV107X_TDM1_TXMCSP		28 -#define IRQ_TNETV107X_SSP			29 -#define IRQ_TNETV107X_MCDMA_INT2		30 -#define IRQ_TNETV107X_MCDMA_INT3		31 -#define IRQ_TNETV107X_TDM_CODECIF_EOT		32 -#define IRQ_TNETV107X_IMCOP_SQR_ARM		33 -#define IRQ_TNETV107X_USB0			34 -#define IRQ_TNETV107X_USB_CDMA			35 -#define IRQ_TNETV107X_LCD			36 -#define IRQ_TNETV107X_KEYPAD			37 -#define IRQ_TNETV107X_KEYPAD_FREE		38 -#define IRQ_TNETV107X_RNG			39 -#define IRQ_TNETV107X_PKA			40 -#define IRQ_TNETV107X_TDM0_TXDMA		41 -#define IRQ_TNETV107X_TDM0_RXDMA		42 -#define IRQ_TNETV107X_TDM0_TXMCSP		43 -#define IRQ_TNETV107X_TDM0_RXMCSP		44 -#define IRQ_TNETV107X_TDM1_RXMCSP		45 -#define IRQ_TNETV107X_SDIO1			46 -#define IRQ_TNETV107X_SDIO0			47 -#define IRQ_TNETV107X_TSC			48 -#define IRQ_TNETV107X_TS			49 -#define IRQ_TNETV107X_UART1			50 -#define IRQ_TNETV107X_MBX_LITE			51 -#define IRQ_TNETV107X_GPIO_INT00		52 -#define IRQ_TNETV107X_GPIO_INT01		53 -#define IRQ_TNETV107X_GPIO_INT02		54 -#define IRQ_TNETV107X_GPIO_INT03		55 -#define IRQ_TNETV107X_UART2			56 -#define IRQ_TNETV107X_UART2_DMATX		57 -#define IRQ_TNETV107X_UART2_DMARX		58 -#define IRQ_TNETV107X_IMCOP_IMX			59 -#define IRQ_TNETV107X_IMCOP_VLCD		60 -#define IRQ_TNETV107X_AES			61 -#define IRQ_TNETV107X_DES			62 -#define IRQ_TNETV107X_SHAMD5			63 -#define IRQ_TNETV107X_TPCC_ERR			68 -#define IRQ_TNETV107X_TPCC_PROT			69 -#define IRQ_TNETV107X_TPTC0_ERR			70 -#define IRQ_TNETV107X_TPTC1_ERR			71 -#define IRQ_TNETV107X_UART0_ERR			72 -#define IRQ_TNETV107X_UART1_ERR			73 -#define IRQ_TNETV107X_AEMIF_ERR			74 -#define IRQ_TNETV107X_DDR_ERR			75 -#define IRQ_TNETV107X_WDTARM_INT0		76 -#define IRQ_TNETV107X_MCDMA_ERR			77 -#define IRQ_TNETV107X_GPIO_ERR			78 -#define IRQ_TNETV107X_MPU_ADDR			79 -#define IRQ_TNETV107X_MPU_PROT			80 -#define IRQ_TNETV107X_IOPU_ADDR			81 -#define IRQ_TNETV107X_IOPU_PROT			82 -#define IRQ_TNETV107X_KEYPAD_ADDR_ERR		83 -#define IRQ_TNETV107X_WDT0_ADDR_ERR		84 -#define IRQ_TNETV107X_WDT1_ADDR_ERR		85 -#define IRQ_TNETV107X_CLKCTL_ADDR_ERR		86 -#define IRQ_TNETV107X_PLL_UNLOCK		87 -#define IRQ_TNETV107X_WDTDSP_INT0		88 -#define IRQ_TNETV107X_SEC_CTRL_VIOLATION	89 -#define IRQ_TNETV107X_KEY_MNG_VIOLATION		90 -#define IRQ_TNETV107X_PBIST_CPU			91 -#define IRQ_TNETV107X_WDTARM			92 -#define IRQ_TNETV107X_PSC			93 -#define IRQ_TNETV107X_MMC0			94 -#define IRQ_TNETV107X_MMC1			95 - -#define TNETV107X_N_CP_INTC_IRQ			96 -  /* da850 currently has the most gpio pins (144) */  #define DAVINCI_N_GPIO			144  /* da850 currently has the most irqs so use DA850_N_CP_INTC_IRQ */ diff --git a/arch/arm/mach-davinci/include/mach/keyscan.h b/arch/arm/mach-davinci/include/mach/keyscan.h deleted file mode 100644 index 7a560e05bda..00000000000 --- a/arch/arm/mach-davinci/include/mach/keyscan.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2009 Texas Instruments, Inc - * - * Author: Miguel Aguilar <miguel.aguilar@ridgerun.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef DAVINCI_KEYSCAN_H -#define DAVINCI_KEYSCAN_H - -#include <linux/io.h> - -enum davinci_matrix_types { -	DAVINCI_KEYSCAN_MATRIX_4X4, -	DAVINCI_KEYSCAN_MATRIX_5X3, -}; - -struct davinci_ks_platform_data { -	int		(*device_enable)(struct device *dev); -	unsigned short	*keymap; -	u32		keymapsize; -	u8		rep:1; -	u8		strobe; -	u8		interval; -	u8		matrix_type; -}; - -#endif - diff --git a/arch/arm/mach-davinci/include/mach/memory.h b/arch/arm/mach-davinci/include/mach/memory.h deleted file mode 100644 index 22eb97c1c30..00000000000 --- a/arch/arm/mach-davinci/include/mach/memory.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * DaVinci memory space definitions - * - * 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. - */ -#ifndef __ASM_ARCH_MEMORY_H -#define __ASM_ARCH_MEMORY_H - -/************************************************************************** - * Included Files - **************************************************************************/ -#include <asm/page.h> -#include <asm/sizes.h> - -/************************************************************************** - * Definitions - **************************************************************************/ -#define DAVINCI_DDR_BASE	0x80000000 -#define DA8XX_DDR_BASE		0xc0000000 - -#if defined(CONFIG_ARCH_DAVINCI_DA8XX) && defined(CONFIG_ARCH_DAVINCI_DMx) -#error Cannot enable DaVinci and DA8XX platforms concurrently -#elif defined(CONFIG_ARCH_DAVINCI_DA8XX) -#define PHYS_OFFSET DA8XX_DDR_BASE -#else -#define PHYS_OFFSET DAVINCI_DDR_BASE -#endif - -#define DDR2_SDRCR_OFFSET	0xc -#define DDR2_SRPD_BIT		BIT(23) -#define DDR2_MCLKSTOPEN_BIT	BIT(30) -#define DDR2_LPMODEN_BIT	BIT(31) - -/* - * Increase size of DMA-consistent memory region - */ -#define CONSISTENT_DMA_SIZE (14<<20) - -#ifndef __ASSEMBLY__ -/* - * Restrict DMA-able region to workaround silicon bug.  The bug - * restricts buffers available for DMA to video hardware to be - * below 128M - */ -static inline void -__arch_adjust_zones(unsigned long *size, unsigned long *holes) -{ -	unsigned int sz = (128<<20) >> PAGE_SHIFT; - -	size[1] = size[0] - sz; -	size[0] = sz; -} - -#define arch_adjust_zones(zone_size, holes) \ -        if ((meminfo.bank[0].size >> 20) > 128) __arch_adjust_zones(zone_size, holes) - -#define ISA_DMA_THRESHOLD	(PHYS_OFFSET + (128<<20) - 1) -#define MAX_DMA_ADDRESS		(PAGE_OFFSET + (128<<20)) - -#endif - -#endif /* __ASM_ARCH_MEMORY_H */ diff --git a/arch/arm/mach-davinci/include/mach/mmc.h b/arch/arm/mach-davinci/include/mach/mmc.h deleted file mode 100644 index d4f1e967506..00000000000 --- a/arch/arm/mach-davinci/include/mach/mmc.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - *  Board-specific MMC configuration - */ - -#ifndef _DAVINCI_MMC_H -#define _DAVINCI_MMC_H - -#include <linux/types.h> -#include <linux/mmc/host.h> - -struct davinci_mmc_config { -	/* get_cd()/get_wp() may sleep */ -	int	(*get_cd)(int module); -	int	(*get_ro)(int module); -	/* wires == 0 is equivalent to wires == 4 (4-bit parallel) */ -	u8	wires; - -	u32     max_freq; - -	/* any additional host capabilities: OR'd in to mmc->f_caps */ -	u32     caps; - -	/* Version of the MMC/SD controller */ -	u8	version; - -	/* Number of sg segments */ -	u8	nr_sg; -}; -void davinci_setup_mmc(int module, struct davinci_mmc_config *config); - -enum { -	MMC_CTLR_VERSION_1 = 0,	/* DM644x and DM355 */ -	MMC_CTLR_VERSION_2,	/* DA830 */ -}; - -#endif diff --git a/arch/arm/mach-davinci/include/mach/mux.h b/arch/arm/mach-davinci/include/mach/mux.h index de11aac76a8..631655e68ae 100644 --- a/arch/arm/mach-davinci/include/mach/mux.h +++ b/arch/arm/mach-davinci/include/mach/mux.h @@ -857,6 +857,14 @@ enum davinci_da850_index {  	DA850_MMCSD0_CLK,  	DA850_MMCSD0_CMD, +	/* MMC/SD1 function */ +	DA850_MMCSD1_DAT_0, +	DA850_MMCSD1_DAT_1, +	DA850_MMCSD1_DAT_2, +	DA850_MMCSD1_DAT_3, +	DA850_MMCSD1_CLK, +	DA850_MMCSD1_CMD, +  	/* EMIF2.5/EMIFA function */  	DA850_EMA_D_7,  	DA850_EMA_D_6, @@ -908,281 +916,60 @@ enum davinci_da850_index {  	DA850_NEMA_CS_2,  	/* GPIO function */ +	DA850_GPIO2_4,  	DA850_GPIO2_6,  	DA850_GPIO2_8,  	DA850_GPIO2_15, +	DA850_GPIO3_12, +	DA850_GPIO3_13,  	DA850_GPIO4_0,  	DA850_GPIO4_1, +	DA850_GPIO6_9, +	DA850_GPIO6_10, +	DA850_GPIO6_13,  	DA850_RTC_ALARM, -}; -enum davinci_tnetv107x_index { -	TNETV107X_ASR_A00, -	TNETV107X_GPIO32, -	TNETV107X_ASR_A01, -	TNETV107X_GPIO33, -	TNETV107X_ASR_A02, -	TNETV107X_GPIO34, -	TNETV107X_ASR_A03, -	TNETV107X_GPIO35, -	TNETV107X_ASR_A04, -	TNETV107X_GPIO36, -	TNETV107X_ASR_A05, -	TNETV107X_GPIO37, -	TNETV107X_ASR_A06, -	TNETV107X_GPIO38, -	TNETV107X_ASR_A07, -	TNETV107X_GPIO39, -	TNETV107X_ASR_A08, -	TNETV107X_GPIO40, -	TNETV107X_ASR_A09, -	TNETV107X_GPIO41, -	TNETV107X_ASR_A10, -	TNETV107X_GPIO42, -	TNETV107X_ASR_A11, -	TNETV107X_BOOT_STRP_0, -	TNETV107X_ASR_A12, -	TNETV107X_BOOT_STRP_1, -	TNETV107X_ASR_A13, -	TNETV107X_GPIO43, -	TNETV107X_ASR_A14, -	TNETV107X_GPIO44, -	TNETV107X_ASR_A15, -	TNETV107X_GPIO45, -	TNETV107X_ASR_A16, -	TNETV107X_GPIO46, -	TNETV107X_ASR_A17, -	TNETV107X_GPIO47, -	TNETV107X_ASR_A18, -	TNETV107X_GPIO48, -	TNETV107X_SDIO1_DATA3_0, -	TNETV107X_ASR_A19, -	TNETV107X_GPIO49, -	TNETV107X_SDIO1_DATA2_0, -	TNETV107X_ASR_A20, -	TNETV107X_GPIO50, -	TNETV107X_SDIO1_DATA1_0, -	TNETV107X_ASR_A21, -	TNETV107X_GPIO51, -	TNETV107X_SDIO1_DATA0_0, -	TNETV107X_ASR_A22, -	TNETV107X_GPIO52, -	TNETV107X_SDIO1_CMD_0, -	TNETV107X_ASR_A23, -	TNETV107X_GPIO53, -	TNETV107X_SDIO1_CLK_0, -	TNETV107X_ASR_BA_1, -	TNETV107X_GPIO54, -	TNETV107X_SYS_PLL_CLK, -	TNETV107X_ASR_CS0, -	TNETV107X_ASR_CS1, -	TNETV107X_ASR_CS2, -	TNETV107X_TDM_PLL_CLK, -	TNETV107X_ASR_CS3, -	TNETV107X_ETH_PHY_CLK, -	TNETV107X_ASR_D00, -	TNETV107X_GPIO55, -	TNETV107X_ASR_D01, -	TNETV107X_GPIO56, -	TNETV107X_ASR_D02, -	TNETV107X_GPIO57, -	TNETV107X_ASR_D03, -	TNETV107X_GPIO58, -	TNETV107X_ASR_D04, -	TNETV107X_GPIO59_0, -	TNETV107X_ASR_D05, -	TNETV107X_GPIO60_0, -	TNETV107X_ASR_D06, -	TNETV107X_GPIO61_0, -	TNETV107X_ASR_D07, -	TNETV107X_GPIO62_0, -	TNETV107X_ASR_D08, -	TNETV107X_GPIO63_0, -	TNETV107X_ASR_D09, -	TNETV107X_GPIO64_0, -	TNETV107X_ASR_D10, -	TNETV107X_SDIO1_DATA3_1, -	TNETV107X_ASR_D11, -	TNETV107X_SDIO1_DATA2_1, -	TNETV107X_ASR_D12, -	TNETV107X_SDIO1_DATA1_1, -	TNETV107X_ASR_D13, -	TNETV107X_SDIO1_DATA0_1, -	TNETV107X_ASR_D14, -	TNETV107X_SDIO1_CMD_1, -	TNETV107X_ASR_D15, -	TNETV107X_SDIO1_CLK_1, -	TNETV107X_ASR_OE, -	TNETV107X_BOOT_STRP_2, -	TNETV107X_ASR_RNW, -	TNETV107X_GPIO29_0, -	TNETV107X_ASR_WAIT, -	TNETV107X_GPIO30_0, -	TNETV107X_ASR_WE, -	TNETV107X_BOOT_STRP_3, -	TNETV107X_ASR_WE_DQM0, -	TNETV107X_GPIO31, -	TNETV107X_LCD_PD17_0, -	TNETV107X_ASR_WE_DQM1, -	TNETV107X_ASR_BA0_0, -	TNETV107X_VLYNQ_CLK, -	TNETV107X_GPIO14, -	TNETV107X_LCD_PD19_0, -	TNETV107X_VLYNQ_RXD0, -	TNETV107X_GPIO15, -	TNETV107X_LCD_PD20_0, -	TNETV107X_VLYNQ_RXD1, -	TNETV107X_GPIO16, -	TNETV107X_LCD_PD21_0, -	TNETV107X_VLYNQ_TXD0, -	TNETV107X_GPIO17, -	TNETV107X_LCD_PD22_0, -	TNETV107X_VLYNQ_TXD1, -	TNETV107X_GPIO18, -	TNETV107X_LCD_PD23_0, -	TNETV107X_SDIO0_CLK, -	TNETV107X_GPIO19, -	TNETV107X_SDIO0_CMD, -	TNETV107X_GPIO20, -	TNETV107X_SDIO0_DATA0, -	TNETV107X_GPIO21, -	TNETV107X_SDIO0_DATA1, -	TNETV107X_GPIO22, -	TNETV107X_SDIO0_DATA2, -	TNETV107X_GPIO23, -	TNETV107X_SDIO0_DATA3, -	TNETV107X_GPIO24, -	TNETV107X_EMU0, -	TNETV107X_EMU1, -	TNETV107X_RTCK, -	TNETV107X_TRST_N, -	TNETV107X_TCK, -	TNETV107X_TDI, -	TNETV107X_TDO, -	TNETV107X_TMS, -	TNETV107X_TDM1_CLK, -	TNETV107X_TDM1_RX, -	TNETV107X_TDM1_TX, -	TNETV107X_TDM1_FS, -	TNETV107X_KEYPAD_R0, -	TNETV107X_KEYPAD_R1, -	TNETV107X_KEYPAD_R2, -	TNETV107X_KEYPAD_R3, -	TNETV107X_KEYPAD_R4, -	TNETV107X_KEYPAD_R5, -	TNETV107X_KEYPAD_R6, -	TNETV107X_GPIO12, -	TNETV107X_KEYPAD_R7, -	TNETV107X_GPIO10, -	TNETV107X_KEYPAD_C0, -	TNETV107X_KEYPAD_C1, -	TNETV107X_KEYPAD_C2, -	TNETV107X_KEYPAD_C3, -	TNETV107X_KEYPAD_C4, -	TNETV107X_KEYPAD_C5, -	TNETV107X_KEYPAD_C6, -	TNETV107X_GPIO13, -	TNETV107X_TEST_CLK_IN, -	TNETV107X_KEYPAD_C7, -	TNETV107X_GPIO11, -	TNETV107X_SSP0_0, -	TNETV107X_SCC_DCLK, -	TNETV107X_LCD_PD20_1, -	TNETV107X_SSP0_1, -	TNETV107X_SCC_CS_N, -	TNETV107X_LCD_PD21_1, -	TNETV107X_SSP0_2, -	TNETV107X_SCC_D, -	TNETV107X_LCD_PD22_1, -	TNETV107X_SSP0_3, -	TNETV107X_SCC_RESETN, -	TNETV107X_LCD_PD23_1, -	TNETV107X_SSP1_0, -	TNETV107X_GPIO25, -	TNETV107X_UART2_CTS, -	TNETV107X_SSP1_1, -	TNETV107X_GPIO26, -	TNETV107X_UART2_RD, -	TNETV107X_SSP1_2, -	TNETV107X_GPIO27, -	TNETV107X_UART2_RTS, -	TNETV107X_SSP1_3, -	TNETV107X_GPIO28, -	TNETV107X_UART2_TD, -	TNETV107X_UART0_CTS, -	TNETV107X_UART0_RD, -	TNETV107X_UART0_RTS, -	TNETV107X_UART0_TD, -	TNETV107X_UART1_RD, -	TNETV107X_UART1_TD, -	TNETV107X_LCD_AC_NCS, -	TNETV107X_LCD_HSYNC_RNW, -	TNETV107X_LCD_VSYNC_A0, -	TNETV107X_LCD_MCLK, -	TNETV107X_LCD_PD16_0, -	TNETV107X_LCD_PCLK_E, -	TNETV107X_LCD_PD00, -	TNETV107X_LCD_PD01, -	TNETV107X_LCD_PD02, -	TNETV107X_LCD_PD03, -	TNETV107X_LCD_PD04, -	TNETV107X_LCD_PD05, -	TNETV107X_LCD_PD06, -	TNETV107X_LCD_PD07, -	TNETV107X_LCD_PD08, -	TNETV107X_GPIO59_1, -	TNETV107X_LCD_PD09, -	TNETV107X_GPIO60_1, -	TNETV107X_LCD_PD10, -	TNETV107X_ASR_BA0_1, -	TNETV107X_GPIO61_1, -	TNETV107X_LCD_PD11, -	TNETV107X_GPIO62_1, -	TNETV107X_LCD_PD12, -	TNETV107X_GPIO63_1, -	TNETV107X_LCD_PD13, -	TNETV107X_GPIO64_1, -	TNETV107X_LCD_PD14, -	TNETV107X_GPIO29_1, -	TNETV107X_LCD_PD15, -	TNETV107X_GPIO30_1, -	TNETV107X_EINT0, -	TNETV107X_GPIO08, -	TNETV107X_EINT1, -	TNETV107X_GPIO09, -	TNETV107X_GPIO00, -	TNETV107X_LCD_PD20_2, -	TNETV107X_TDM_CLK_IN_2, -	TNETV107X_GPIO01, -	TNETV107X_LCD_PD21_2, -	TNETV107X_24M_CLK_OUT_1, -	TNETV107X_GPIO02, -	TNETV107X_LCD_PD22_2, -	TNETV107X_GPIO03, -	TNETV107X_LCD_PD23_2, -	TNETV107X_GPIO04, -	TNETV107X_LCD_PD16_1, -	TNETV107X_USB0_RXERR, -	TNETV107X_GPIO05, -	TNETV107X_LCD_PD17_1, -	TNETV107X_TDM_CLK_IN_1, -	TNETV107X_GPIO06, -	TNETV107X_LCD_PD18, -	TNETV107X_24M_CLK_OUT_2, -	TNETV107X_GPIO07, -	TNETV107X_LCD_PD19_1, -	TNETV107X_USB1_RXERR, -	TNETV107X_ETH_PLL_CLK, -	TNETV107X_MDIO, -	TNETV107X_MDC, -	TNETV107X_AIC_MUTE_STAT_N, -	TNETV107X_TDM0_CLK, -	TNETV107X_AIC_HNS_EN_N, -	TNETV107X_TDM0_FS, -	TNETV107X_AIC_HDS_EN_STAT_N, -	TNETV107X_TDM0_TX, -	TNETV107X_AIC_HNF_EN_STAT_N, -	TNETV107X_TDM0_RX, +	/* VPIF Capture */ +	DA850_VPIF_DIN0, +	DA850_VPIF_DIN1, +	DA850_VPIF_DIN2, +	DA850_VPIF_DIN3, +	DA850_VPIF_DIN4, +	DA850_VPIF_DIN5, +	DA850_VPIF_DIN6, +	DA850_VPIF_DIN7, +	DA850_VPIF_DIN8, +	DA850_VPIF_DIN9, +	DA850_VPIF_DIN10, +	DA850_VPIF_DIN11, +	DA850_VPIF_DIN12, +	DA850_VPIF_DIN13, +	DA850_VPIF_DIN14, +	DA850_VPIF_DIN15, +	DA850_VPIF_CLKIN0, +	DA850_VPIF_CLKIN1, +	DA850_VPIF_CLKIN2, +	DA850_VPIF_CLKIN3, + +	/* VPIF Display */ +	DA850_VPIF_DOUT0, +	DA850_VPIF_DOUT1, +	DA850_VPIF_DOUT2, +	DA850_VPIF_DOUT3, +	DA850_VPIF_DOUT4, +	DA850_VPIF_DOUT5, +	DA850_VPIF_DOUT6, +	DA850_VPIF_DOUT7, +	DA850_VPIF_DOUT8, +	DA850_VPIF_DOUT9, +	DA850_VPIF_DOUT10, +	DA850_VPIF_DOUT11, +	DA850_VPIF_DOUT12, +	DA850_VPIF_DOUT13, +	DA850_VPIF_DOUT14, +	DA850_VPIF_DOUT15, +	DA850_VPIF_CLKO2, +	DA850_VPIF_CLKO3,  };  #define PINMUX(x)		(4 * (x)) diff --git a/arch/arm/mach-davinci/include/mach/nand.h b/arch/arm/mach-davinci/include/mach/nand.h deleted file mode 100644 index 025151049f0..00000000000 --- a/arch/arm/mach-davinci/include/mach/nand.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * mach-davinci/nand.h - * - * Copyright © 2006 Texas Instruments. - * - * Ported to 2.6.23 Copyright © 2008 by - *   Sander Huijsen <Shuijsen@optelecom-nkf.com> - *   Troy Kisky <troy.kisky@boundarydevices.com> - *   Dirk Behme <Dirk.Behme@gmail.com> - * - * -------------------------------------------------------------------------- - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __ARCH_ARM_DAVINCI_NAND_H -#define __ARCH_ARM_DAVINCI_NAND_H - -#include <linux/mtd/nand.h> - -#define NANDFCR_OFFSET		0x60 -#define NANDFSR_OFFSET		0x64 -#define NANDF1ECC_OFFSET	0x70 - -/* 4-bit ECC syndrome registers */ -#define NAND_4BIT_ECC_LOAD_OFFSET	0xbc -#define NAND_4BIT_ECC1_OFFSET		0xc0 -#define NAND_4BIT_ECC2_OFFSET		0xc4 -#define NAND_4BIT_ECC3_OFFSET		0xc8 -#define NAND_4BIT_ECC4_OFFSET		0xcc -#define NAND_ERR_ADD1_OFFSET		0xd0 -#define NAND_ERR_ADD2_OFFSET		0xd4 -#define NAND_ERR_ERRVAL1_OFFSET		0xd8 -#define NAND_ERR_ERRVAL2_OFFSET		0xdc - -/* NOTE:  boards don't need to use these address bits - * for ALE/CLE unless they support booting from NAND. - * They're used unless platform data overrides them. - */ -#define	MASK_ALE		0x08 -#define	MASK_CLE		0x10 - -struct davinci_nand_pdata {		/* platform_data */ -	uint32_t		mask_ale; -	uint32_t		mask_cle; - -	/* for packages using two chipselects */ -	uint32_t		mask_chipsel; - -	/* board's default static partition info */ -	struct mtd_partition	*parts; -	unsigned		nr_parts; - -	/* none  == NAND_ECC_NONE (strongly *not* advised!!) -	 * soft  == NAND_ECC_SOFT -	 * else  == NAND_ECC_HW, according to ecc_bits -	 * -	 * All DaVinci-family chips support 1-bit hardware ECC. -	 * Newer ones also support 4-bit ECC, but are awkward -	 * using it with large page chips. -	 */ -	nand_ecc_modes_t	ecc_mode; -	u8			ecc_bits; - -	/* e.g. NAND_BUSWIDTH_16 or NAND_USE_FLASH_BBT */ -	unsigned		options; - -	/* Main and mirror bbt descriptor overrides */ -	struct nand_bbt_descr	*bbt_td; -	struct nand_bbt_descr	*bbt_md; - -	/* Access timings */ -	struct davinci_aemif_timing	*timing; -}; - -#endif	/* __ARCH_ARM_DAVINCI_NAND_H */ diff --git a/arch/arm/mach-davinci/include/mach/psc.h b/arch/arm/mach-davinci/include/mach/psc.h index 62b0858f68c..99d47cfa301 100644 --- a/arch/arm/mach-davinci/include/mach/psc.h +++ b/arch/arm/mach-davinci/include/mach/psc.h @@ -30,47 +30,47 @@  #define	DAVINCI_PWR_SLEEP_CNTRL_BASE	0x01C41000  /* Power and Sleep Controller (PSC) Domains */ -#define DAVINCI_GPSC_ARMDOMAIN      0 -#define DAVINCI_GPSC_DSPDOMAIN      1 - -#define DAVINCI_LPSC_VPSSMSTR       0 -#define DAVINCI_LPSC_VPSSSLV        1 -#define DAVINCI_LPSC_TPCC           2 -#define DAVINCI_LPSC_TPTC0          3 -#define DAVINCI_LPSC_TPTC1          4 -#define DAVINCI_LPSC_EMAC           5 -#define DAVINCI_LPSC_EMAC_WRAPPER   6 -#define DAVINCI_LPSC_USB            9 -#define DAVINCI_LPSC_ATA            10 -#define DAVINCI_LPSC_VLYNQ          11 -#define DAVINCI_LPSC_UHPI           12 -#define DAVINCI_LPSC_DDR_EMIF       13 -#define DAVINCI_LPSC_AEMIF          14 -#define DAVINCI_LPSC_MMC_SD         15 -#define DAVINCI_LPSC_McBSP          17 -#define DAVINCI_LPSC_I2C            18 -#define DAVINCI_LPSC_UART0          19 -#define DAVINCI_LPSC_UART1          20 -#define DAVINCI_LPSC_UART2          21 -#define DAVINCI_LPSC_SPI            22 -#define DAVINCI_LPSC_PWM0           23 -#define DAVINCI_LPSC_PWM1           24 -#define DAVINCI_LPSC_PWM2           25 -#define DAVINCI_LPSC_GPIO           26 -#define DAVINCI_LPSC_TIMER0         27 -#define DAVINCI_LPSC_TIMER1         28 -#define DAVINCI_LPSC_TIMER2         29 -#define DAVINCI_LPSC_SYSTEM_SUBSYS  30 -#define DAVINCI_LPSC_ARM            31 -#define DAVINCI_LPSC_SCR2           32 -#define DAVINCI_LPSC_SCR3           33 -#define DAVINCI_LPSC_SCR4           34 -#define DAVINCI_LPSC_CROSSBAR       35 -#define DAVINCI_LPSC_CFG27          36 -#define DAVINCI_LPSC_CFG3           37 -#define DAVINCI_LPSC_CFG5           38 -#define DAVINCI_LPSC_GEM            39 -#define DAVINCI_LPSC_IMCOP          40 +#define DAVINCI_GPSC_ARMDOMAIN		0 +#define DAVINCI_GPSC_DSPDOMAIN		1 + +#define DAVINCI_LPSC_VPSSMSTR		0 +#define DAVINCI_LPSC_VPSSSLV		1 +#define DAVINCI_LPSC_TPCC		2 +#define DAVINCI_LPSC_TPTC0		3 +#define DAVINCI_LPSC_TPTC1		4 +#define DAVINCI_LPSC_EMAC		5 +#define DAVINCI_LPSC_EMAC_WRAPPER	6 +#define DAVINCI_LPSC_USB		9 +#define DAVINCI_LPSC_ATA		10 +#define DAVINCI_LPSC_VLYNQ		11 +#define DAVINCI_LPSC_UHPI		12 +#define DAVINCI_LPSC_DDR_EMIF		13 +#define DAVINCI_LPSC_AEMIF		14 +#define DAVINCI_LPSC_MMC_SD		15 +#define DAVINCI_LPSC_McBSP		17 +#define DAVINCI_LPSC_I2C		18 +#define DAVINCI_LPSC_UART0		19 +#define DAVINCI_LPSC_UART1		20 +#define DAVINCI_LPSC_UART2		21 +#define DAVINCI_LPSC_SPI		22 +#define DAVINCI_LPSC_PWM0		23 +#define DAVINCI_LPSC_PWM1		24 +#define DAVINCI_LPSC_PWM2		25 +#define DAVINCI_LPSC_GPIO		26 +#define DAVINCI_LPSC_TIMER0		27 +#define DAVINCI_LPSC_TIMER1		28 +#define DAVINCI_LPSC_TIMER2		29 +#define DAVINCI_LPSC_SYSTEM_SUBSYS	30 +#define DAVINCI_LPSC_ARM		31 +#define DAVINCI_LPSC_SCR2		32 +#define DAVINCI_LPSC_SCR3		33 +#define DAVINCI_LPSC_SCR4		34 +#define DAVINCI_LPSC_CROSSBAR		35 +#define DAVINCI_LPSC_CFG27		36 +#define DAVINCI_LPSC_CFG3		37 +#define DAVINCI_LPSC_CFG5		38 +#define DAVINCI_LPSC_GEM		39 +#define DAVINCI_LPSC_IMCOP		40  #define DM355_LPSC_TIMER3		5  #define DM355_LPSC_SPI1			6 @@ -102,39 +102,39 @@  /*   * LPSC Assignments   */ -#define DM646X_LPSC_ARM            0 -#define DM646X_LPSC_C64X_CPU       1 -#define DM646X_LPSC_HDVICP0        2 -#define DM646X_LPSC_HDVICP1        3 -#define DM646X_LPSC_TPCC           4 -#define DM646X_LPSC_TPTC0          5 -#define DM646X_LPSC_TPTC1          6 -#define DM646X_LPSC_TPTC2          7 -#define DM646X_LPSC_TPTC3          8 -#define DM646X_LPSC_PCI            13 -#define DM646X_LPSC_EMAC           14 -#define DM646X_LPSC_VDCE           15 -#define DM646X_LPSC_VPSSMSTR       16 -#define DM646X_LPSC_VPSSSLV        17 -#define DM646X_LPSC_TSIF0          18 -#define DM646X_LPSC_TSIF1          19 -#define DM646X_LPSC_DDR_EMIF       20 -#define DM646X_LPSC_AEMIF          21 -#define DM646X_LPSC_McASP0         22 -#define DM646X_LPSC_McASP1         23 -#define DM646X_LPSC_CRGEN0         24 -#define DM646X_LPSC_CRGEN1         25 -#define DM646X_LPSC_UART0          26 -#define DM646X_LPSC_UART1          27 -#define DM646X_LPSC_UART2          28 -#define DM646X_LPSC_PWM0           29 -#define DM646X_LPSC_PWM1           30 -#define DM646X_LPSC_I2C            31 -#define DM646X_LPSC_SPI            32 -#define DM646X_LPSC_GPIO           33 -#define DM646X_LPSC_TIMER0         34 -#define DM646X_LPSC_TIMER1         35 -#define DM646X_LPSC_ARM_INTC       45 +#define DM646X_LPSC_ARM		0 +#define DM646X_LPSC_C64X_CPU	1 +#define DM646X_LPSC_HDVICP0	2 +#define DM646X_LPSC_HDVICP1	3 +#define DM646X_LPSC_TPCC	4 +#define DM646X_LPSC_TPTC0	5 +#define DM646X_LPSC_TPTC1	6 +#define DM646X_LPSC_TPTC2	7 +#define DM646X_LPSC_TPTC3	8 +#define DM646X_LPSC_PCI		13 +#define DM646X_LPSC_EMAC	14 +#define DM646X_LPSC_VDCE	15 +#define DM646X_LPSC_VPSSMSTR	16 +#define DM646X_LPSC_VPSSSLV	17 +#define DM646X_LPSC_TSIF0	18 +#define DM646X_LPSC_TSIF1	19 +#define DM646X_LPSC_DDR_EMIF	20 +#define DM646X_LPSC_AEMIF	21 +#define DM646X_LPSC_McASP0	22 +#define DM646X_LPSC_McASP1	23 +#define DM646X_LPSC_CRGEN0	24 +#define DM646X_LPSC_CRGEN1	25 +#define DM646X_LPSC_UART0	26 +#define DM646X_LPSC_UART1	27 +#define DM646X_LPSC_UART2	28 +#define DM646X_LPSC_PWM0	29 +#define DM646X_LPSC_PWM1	30 +#define DM646X_LPSC_I2C		31 +#define DM646X_LPSC_SPI		32 +#define DM646X_LPSC_GPIO	33 +#define DM646X_LPSC_TIMER0	34 +#define DM646X_LPSC_TIMER1	35 +#define DM646X_LPSC_ARM_INTC	45  /* PSC0 defines */  #define DA8XX_LPSC0_TPCC		0 @@ -150,7 +150,7 @@  #define DA8XX_LPSC0_SCR0_SS		10  #define DA8XX_LPSC0_SCR1_SS		11  #define DA8XX_LPSC0_SCR2_SS		12 -#define DA8XX_LPSC0_DMAX		13 +#define DA8XX_LPSC0_PRUSS		13  #define DA8XX_LPSC0_ARM			14  #define DA8XX_LPSC0_GEM			15 @@ -166,6 +166,7 @@  #define DA830_LPSC1_McASP1		8  #define DA850_LPSC1_SATA		8  #define DA830_LPSC1_McASP2		9 +#define DA850_LPSC1_VPIF		9  #define DA8XX_LPSC1_SPI1		10  #define DA8XX_LPSC1_I2C			11  #define DA8XX_LPSC1_UART1		12 @@ -181,59 +182,12 @@  #define DA8XX_LPSC1_CR_P3_SS		26  #define DA8XX_LPSC1_L3_CBA_RAM		31 -/* TNETV107X LPSC Assignments */ -#define TNETV107X_LPSC_ARM			0 -#define TNETV107X_LPSC_GEM			1 -#define TNETV107X_LPSC_DDR2_PHY			2 -#define TNETV107X_LPSC_TPCC			3 -#define TNETV107X_LPSC_TPTC0			4 -#define TNETV107X_LPSC_TPTC1			5 -#define TNETV107X_LPSC_RAM			6 -#define TNETV107X_LPSC_MBX_LITE			7 -#define TNETV107X_LPSC_LCD			8 -#define TNETV107X_LPSC_ETHSS			9 -#define TNETV107X_LPSC_AEMIF			10 -#define TNETV107X_LPSC_CHIP_CFG			11 -#define TNETV107X_LPSC_TSC			12 -#define TNETV107X_LPSC_ROM			13 -#define TNETV107X_LPSC_UART2			14 -#define TNETV107X_LPSC_PKTSEC			15 -#define TNETV107X_LPSC_SECCTL			16 -#define TNETV107X_LPSC_KEYMGR			17 -#define TNETV107X_LPSC_KEYPAD			18 -#define TNETV107X_LPSC_GPIO			19 -#define TNETV107X_LPSC_MDIO			20 -#define TNETV107X_LPSC_SDIO0			21 -#define TNETV107X_LPSC_UART0			22 -#define TNETV107X_LPSC_UART1			23 -#define TNETV107X_LPSC_TIMER0			24 -#define TNETV107X_LPSC_TIMER1			25 -#define TNETV107X_LPSC_WDT_ARM			26 -#define TNETV107X_LPSC_WDT_DSP			27 -#define TNETV107X_LPSC_SSP			28 -#define TNETV107X_LPSC_TDM0			29 -#define TNETV107X_LPSC_VLYNQ			30 -#define TNETV107X_LPSC_MCDMA			31 -#define TNETV107X_LPSC_USB0			32 -#define TNETV107X_LPSC_TDM1			33 -#define TNETV107X_LPSC_DEBUGSS			34 -#define TNETV107X_LPSC_ETHSS_RGMII		35 -#define TNETV107X_LPSC_SYSTEM			36 -#define TNETV107X_LPSC_IMCOP			37 -#define TNETV107X_LPSC_SPARE			38 -#define TNETV107X_LPSC_SDIO1			39 -#define TNETV107X_LPSC_USB1			40 -#define TNETV107X_LPSC_USBSS			41 -#define TNETV107X_LPSC_DDR2_EMIF1_VRST		42 -#define TNETV107X_LPSC_DDR2_EMIF2_VCTL_RST	43 -#define TNETV107X_LPSC_MAX			44 -  /* PSC register offsets */  #define EPCPR		0x070  #define PTCMD		0x120  #define PTSTAT		0x128  #define PDSTAT		0x200 -#define PDCTL1		0x304 +#define PDCTL		0x300  #define MDSTAT		0x800  #define MDCTL		0xA00 @@ -243,13 +197,20 @@  #define PSC_STATE_DISABLE	2  #define PSC_STATE_ENABLE	3 -#define MDSTAT_STATE_MASK 0x1f +#define MDSTAT_STATE_MASK	0x3f +#define PDSTAT_STATE_MASK	0x1f +#define MDCTL_LRST		BIT(8) +#define MDCTL_FORCE		BIT(31) +#define PDCTL_NEXT		BIT(0) +#define PDCTL_EPCGOOD		BIT(8)  #ifndef __ASSEMBLER__  extern int davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id); +extern void davinci_psc_reset(unsigned int ctlr, unsigned int id, +		bool reset);  extern void davinci_psc_config(unsigned int domain, unsigned int ctlr, -		unsigned int id, u32 next_state); +		unsigned int id, bool enable, u32 flags);  #endif diff --git a/arch/arm/mach-davinci/include/mach/serial.h b/arch/arm/mach-davinci/include/mach/serial.h index 8051110b8ac..d4b4aa87964 100644 --- a/arch/arm/mach-davinci/include/mach/serial.h +++ b/arch/arm/mach-davinci/include/mach/serial.h @@ -15,15 +15,6 @@  #include <mach/hardware.h> -/* - * Stolen area that contains debug uart physical and virtual addresses.  These - * addresses are filled in by the uncompress.h code, and are used by the debug - * macros in debug-macro.S. - * - * This area sits just below the page tables (see arch/arm/kernel/head.S). - */ -#define DAVINCI_UART_INFO	(PHYS_OFFSET + 0x3ff8) -  #define DAVINCI_UART0_BASE	(IO_PHYS + 0x20000)  #define DAVINCI_UART1_BASE	(IO_PHYS + 0x20400)  #define DAVINCI_UART2_BASE	(IO_PHYS + 0x20800) @@ -32,26 +23,15 @@  #define DA8XX_UART1_BASE	(IO_PHYS + 0x10c000)  #define DA8XX_UART2_BASE	(IO_PHYS + 0x10d000) -#define TNETV107X_UART0_BASE	0x08108100 -#define TNETV107X_UART1_BASE	0x08088400 -#define TNETV107X_UART2_BASE	0x08108300 - -#define TNETV107X_UART0_VIRT	IOMEM(0xfee08100) -#define TNETV107X_UART1_VIRT	IOMEM(0xfed88400) -#define TNETV107X_UART2_VIRT	IOMEM(0xfee08300) -  /* DaVinci UART register offsets */  #define UART_DAVINCI_PWREMU		0x0c  #define UART_DM646X_SCR			0x10  #define UART_DM646X_SCR_TX_WATERMARK	0x08  #ifndef __ASSEMBLY__ -struct davinci_uart_config { -	/* Bit field of UARTs present; bit 0 --> UART1 */ -	unsigned int enabled_uarts; -}; +#include <linux/platform_device.h> -extern int davinci_serial_init(struct davinci_uart_config *); +extern int davinci_serial_init(struct platform_device *);  #endif  #endif /* __ASM_ARCH_SERIAL_H */ diff --git a/arch/arm/mach-davinci/include/mach/spi.h b/arch/arm/mach-davinci/include/mach/spi.h deleted file mode 100644 index 910efbf099c..00000000000 --- a/arch/arm/mach-davinci/include/mach/spi.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2009 Texas Instruments. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#ifndef __ARCH_ARM_DAVINCI_SPI_H -#define __ARCH_ARM_DAVINCI_SPI_H - -enum { -	SPI_VERSION_1, /* For DM355/DM365/DM6467 */ -	SPI_VERSION_2, /* For DA8xx */ -}; - -struct davinci_spi_platform_data { -	u8	version; -	u8	num_chipselect; -	u8	wdelay; -	u8	odd_parity; -	u8	parity_enable; -	u8	wait_enable; -	u8	timer_disable; -	u8	clk_internal; -	u8	cs_hold; -	u8	intr_level; -	u8	poll_mode; -	u8	use_dma; -	u8	c2tdelay; -	u8	t2cdelay; -}; - -#endif	/* __ARCH_ARM_DAVINCI_SPI_H */ diff --git a/arch/arm/mach-davinci/include/mach/sram.h b/arch/arm/mach-davinci/include/mach/sram.h index 111f7cc71e0..4e5db56218b 100644 --- a/arch/arm/mach-davinci/include/mach/sram.h +++ b/arch/arm/mach-davinci/include/mach/sram.h @@ -24,4 +24,7 @@  extern void *sram_alloc(size_t len, dma_addr_t *dma);  extern void sram_free(void *addr, size_t len); +/* Get the struct gen_pool * for use in platform data */ +extern struct gen_pool *sram_get_gen_pool(void); +  #endif /* __MACH_SRAM_H */ diff --git a/arch/arm/mach-davinci/include/mach/system.h b/arch/arm/mach-davinci/include/mach/system.h deleted file mode 100644 index e65629c2076..00000000000 --- a/arch/arm/mach-davinci/include/mach/system.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * DaVinci system defines - * - * 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. - */ -#ifndef __ASM_ARCH_SYSTEM_H -#define __ASM_ARCH_SYSTEM_H - -#include <mach/common.h> - -static inline void arch_idle(void) -{ -	cpu_do_idle(); -} - -static inline void arch_reset(char mode, const char *cmd) -{ -	if (davinci_soc_info.reset) -		davinci_soc_info.reset(davinci_soc_info.reset_device); -} - -#endif /* __ASM_ARCH_SYSTEM_H */ diff --git a/arch/arm/mach-davinci/include/mach/timex.h b/arch/arm/mach-davinci/include/mach/timex.h deleted file mode 100644 index 9b885298f10..00000000000 --- a/arch/arm/mach-davinci/include/mach/timex.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * DaVinci timer defines - * - * 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. - */ -#ifndef __ASM_ARCH_TIMEX_H -#define __ASM_ARCH_TIMEX_H - -/* - * Alert: Not all timers of the DaVinci family run at a frequency of 27MHz, - * but we should be fine as long as CLOCK_TICK_RATE or LATCH (see include/ - * linux/jiffies.h) are not used directly in code. Currently none of the - * code relevant to DaVinci platform depends on these values directly. - */ -#define CLOCK_TICK_RATE 27000000 - -#endif /* __ASM_ARCH_TIMEX_H__ */ diff --git a/arch/arm/mach-davinci/include/mach/tnetv107x.h b/arch/arm/mach-davinci/include/mach/tnetv107x.h deleted file mode 100644 index 5a681d880dc..00000000000 --- a/arch/arm/mach-davinci/include/mach/tnetv107x.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Texas Instruments TNETV107X SoC Specific Defines - * - * Copyright (C) 2010 Texas Instruments - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - */ -#ifndef __ASM_ARCH_DAVINCI_TNETV107X_H -#define __ASM_ARCH_DAVINCI_TNETV107X_H - -#include <asm/sizes.h> - -#define TNETV107X_DDR_BASE	0x80000000 - -/* - * Fixed mapping for early init starts here. If low-level debug is enabled, - * this area also gets mapped via io_pg_offset and io_phys by the boot code. - * To fit in with the io_pg_offset calculation, the io base address selected - * here _must_ be a multiple of 2^20. - */ -#define TNETV107X_IO_BASE	0x08000000 -#define TNETV107X_IO_VIRT	(IO_VIRT + SZ_1M) - -#define TNETV107X_N_GPIO	65 - -#ifndef __ASSEMBLY__ - -#include <linux/serial_8250.h> -#include <linux/input/matrix_keypad.h> - -#include <mach/mmc.h> -#include <mach/nand.h> -#include <mach/serial.h> - -struct tnetv107x_device_info { -	struct davinci_uart_config	*serial_config; -	struct davinci_mmc_config	*mmc_config[2];  /* 2 controllers */ -	struct davinci_nand_pdata	*nand_config[4]; /* 4 chipsels */ -	struct matrix_keypad_platform_data *keypad_config; -}; - -extern struct platform_device tnetv107x_wdt_device; -extern struct platform_device tnetv107x_serial_device; - -extern void __init tnetv107x_init(void); -extern void __init tnetv107x_devices_init(struct tnetv107x_device_info *); -extern void __init tnetv107x_irq_init(void); - -#endif - -#endif /* __ASM_ARCH_DAVINCI_TNETV107X_H */ diff --git a/arch/arm/mach-davinci/include/mach/uncompress.h b/arch/arm/mach-davinci/include/mach/uncompress.h index 47723e8d75a..8fb97b93b6b 100644 --- a/arch/arm/mach-davinci/include/mach/uncompress.h +++ b/arch/arm/mach-davinci/include/mach/uncompress.h @@ -25,12 +25,16 @@  #include <mach/serial.h> -static u32 *uart; -static u32 *uart_info = (u32 *)(DAVINCI_UART_INFO); +#define IOMEM(x)	((void __force __iomem *)(x)) + +u32 *uart;  /* PORT_16C550A, in polled non-fifo mode */  static void putc(char c)  { +	if (!uart) +		return; +  	while (!(uart[UART_LSR] & UART_LSR_THRE))  		barrier();  	uart[UART_TX] = c; @@ -38,34 +42,31 @@ static void putc(char c)  static inline void flush(void)  { +	if (!uart) +		return; +  	while (!(uart[UART_LSR] & UART_LSR_THRE))  		barrier();  } -static inline void set_uart_info(u32 phys, void * __iomem virt) +static inline void set_uart_info(u32 phys)  {  	uart = (u32 *)phys; -	uart_info[0] = phys; -	uart_info[1] = (u32)virt;  } -#define _DEBUG_LL_ENTRY(machine, phys, virt)			\ -	if (machine_is_##machine()) {				\ -		set_uart_info(phys, virt);			\ -		break;						\ +#define _DEBUG_LL_ENTRY(machine, phys)				\ +	{							\ +		if (machine_is_##machine()) {			\ +			set_uart_info(phys);			\ +			break;					\ +		}						\  	}  #define DEBUG_LL_DAVINCI(machine, port)				\ -	_DEBUG_LL_ENTRY(machine, DAVINCI_UART##port##_BASE,	\ -			IO_ADDRESS(DAVINCI_UART##port##_BASE)) +	_DEBUG_LL_ENTRY(machine, DAVINCI_UART##port##_BASE)  #define DEBUG_LL_DA8XX(machine, port)				\ -	_DEBUG_LL_ENTRY(machine, DA8XX_UART##port##_BASE,	\ -			IO_ADDRESS(DA8XX_UART##port##_BASE)) - -#define DEBUG_LL_TNETV107X(machine, port)			\ -	_DEBUG_LL_ENTRY(machine, TNETV107X_UART##port##_BASE,	\ -			TNETV107X_UART##port##_VIRT) +	_DEBUG_LL_ENTRY(machine, DA8XX_UART##port##_BASE)  static inline void __arch_decomp_setup(unsigned long arch_id)  { @@ -90,11 +91,7 @@ static inline void __arch_decomp_setup(unsigned long arch_id)  		DEBUG_LL_DA8XX(davinci_da850_evm,	2);  		DEBUG_LL_DA8XX(mityomapl138,		1);  		DEBUG_LL_DA8XX(omapl138_hawkboard,	2); - -		/* TNETV107x boards */ -		DEBUG_LL_TNETV107X(tnetv107x,		1);  	} while (0);  }  #define arch_decomp_setup()	__arch_decomp_setup(arch_id) -#define arch_decomp_wdog() diff --git a/arch/arm/mach-davinci/include/mach/usb.h b/arch/arm/mach-davinci/include/mach/usb.h deleted file mode 100644 index e0bc4abe69c..00000000000 --- a/arch/arm/mach-davinci/include/mach/usb.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * USB related definitions - * - * Copyright (C) 2009 MontaVista Software, Inc. <source@mvista.com> - * - * 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. - */ - -#ifndef __ASM_ARCH_USB_H -#define __ASM_ARCH_USB_H - -/* DA8xx CFGCHIP2 (USB 2.0 PHY Control) register bits */ -#define CFGCHIP2_PHYCLKGD	(1 << 17) -#define CFGCHIP2_VBUSSENSE	(1 << 16) -#define CFGCHIP2_RESET		(1 << 15) -#define CFGCHIP2_OTGMODE	(3 << 13) -#define CFGCHIP2_NO_OVERRIDE	(0 << 13) -#define CFGCHIP2_FORCE_HOST	(1 << 13) -#define CFGCHIP2_FORCE_DEVICE 	(2 << 13) -#define CFGCHIP2_FORCE_HOST_VBUS_LOW (3 << 13) -#define CFGCHIP2_USB1PHYCLKMUX	(1 << 12) -#define CFGCHIP2_USB2PHYCLKMUX	(1 << 11) -#define CFGCHIP2_PHYPWRDN	(1 << 10) -#define CFGCHIP2_OTGPWRDN	(1 << 9) -#define CFGCHIP2_DATPOL 	(1 << 8) -#define CFGCHIP2_USB1SUSPENDM	(1 << 7) -#define CFGCHIP2_PHY_PLLON	(1 << 6)	/* override PLL suspend */ -#define CFGCHIP2_SESENDEN	(1 << 5)	/* Vsess_end comparator */ -#define CFGCHIP2_VBDTCTEN	(1 << 4)	/* Vbus comparator */ -#define CFGCHIP2_REFFREQ	(0xf << 0) -#define CFGCHIP2_REFFREQ_12MHZ	(1 << 0) -#define CFGCHIP2_REFFREQ_24MHZ	(2 << 0) -#define CFGCHIP2_REFFREQ_48MHZ	(3 << 0) - -struct	da8xx_ohci_root_hub; - -typedef void (*da8xx_ocic_handler_t)(struct da8xx_ohci_root_hub *hub, -				     unsigned port); - -/* Passed as the platform data to the OHCI driver */ -struct	da8xx_ohci_root_hub { -	/* Switch the port power on/off */ -	int	(*set_power)(unsigned port, int on); -	/* Read the port power status */ -	int	(*get_power)(unsigned port); -	/* Read the port over-current indicator */ -	int	(*get_oci)(unsigned port); -	/* Over-current indicator change notification (pass NULL to disable) */ -	int	(*ocic_notify)(da8xx_ocic_handler_t handler); - -	/* Time from power on to power good (in 2 ms units) */ -	u8	potpgt; -}; - -void davinci_setup_usb(unsigned mA, unsigned potpgt_ms); - -#endif	/* ifndef __ASM_ARCH_USB_H */ diff --git a/arch/arm/mach-davinci/include/mach/vmalloc.h b/arch/arm/mach-davinci/include/mach/vmalloc.h deleted file mode 100644 index d49646a8e20..00000000000 --- a/arch/arm/mach-davinci/include/mach/vmalloc.h +++ /dev/null @@ -1,14 +0,0 @@ -/* - * DaVinci vmalloc definitions - * - * 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 <mach/hardware.h> - -/* Allow vmalloc range until the IO virtual range minus a 2M "hole" */ -#define VMALLOC_END	  (IO_VIRT - (2<<20)) diff --git a/arch/arm/mach-davinci/io.c b/arch/arm/mach-davinci/io.c deleted file mode 100644 index 8ea60a8b249..00000000000 --- a/arch/arm/mach-davinci/io.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * DaVinci I/O mapping code - * - * Copyright (C) 2005-2006 Texas Instruments - * - * 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/module.h> -#include <linux/io.h> - -#include <asm/tlb.h> -#include <asm/mach/map.h> - -#include <mach/common.h> - -/* - * Intercept ioremap() requests for addresses in our fixed mapping regions. - */ -void __iomem *davinci_ioremap(unsigned long p, size_t size, unsigned int type) -{ -	struct map_desc *desc = davinci_soc_info.io_desc; -	int desc_num = davinci_soc_info.io_desc_num; -	int i; - -	for (i = 0; i < desc_num; i++, desc++) { -		unsigned long iophys = __pfn_to_phys(desc->pfn); -		unsigned long iosize = desc->length; - -		if (p >= iophys && (p + size) <= (iophys + iosize)) -			return __io(desc->virtual + p - iophys); -	} - -	return __arm_ioremap_caller(p, size, type, -					__builtin_return_address(0)); -} -EXPORT_SYMBOL(davinci_ioremap); - -void davinci_iounmap(volatile void __iomem *addr) -{ -	unsigned long virt = (unsigned long)addr; - -	if (virt >= VMALLOC_START && virt < VMALLOC_END) -		__iounmap(addr); -} -EXPORT_SYMBOL(davinci_iounmap); diff --git a/arch/arm/mach-davinci/irq.c b/arch/arm/mach-davinci/irq.c index 784ddf3c5ad..952dc126c39 100644 --- a/arch/arm/mach-davinci/irq.c +++ b/arch/arm/mach-davinci/irq.c @@ -29,8 +29,6 @@  #include <mach/common.h>  #include <asm/mach/irq.h> -#define IRQ_BIT(irq)		((irq) & 0x1f) -  #define FIQ_REG0_OFFSET		0x0000  #define FIQ_REG1_OFFSET		0x0004  #define IRQ_REG0_OFFSET		0x0008 @@ -42,78 +40,39 @@  #define IRQ_INTPRI0_REG_OFFSET	0x0030  #define IRQ_INTPRI7_REG_OFFSET	0x004C -static inline unsigned int davinci_irq_readl(int offset) -{ -	return __raw_readl(davinci_intc_base + offset); -} -  static inline void davinci_irq_writel(unsigned long value, int offset)  {  	__raw_writel(value, davinci_intc_base + offset);  } -/* Disable interrupt */ -static void davinci_mask_irq(unsigned int irq) +static __init void +davinci_alloc_gc(void __iomem *base, unsigned int irq_start, unsigned int num)  { -	unsigned int mask; -	u32 l; - -	mask = 1 << IRQ_BIT(irq); - -	if (irq > 31) { -		l = davinci_irq_readl(IRQ_ENT_REG1_OFFSET); -		l &= ~mask; -		davinci_irq_writel(l, IRQ_ENT_REG1_OFFSET); -	} else { -		l = davinci_irq_readl(IRQ_ENT_REG0_OFFSET); -		l &= ~mask; -		davinci_irq_writel(l, IRQ_ENT_REG0_OFFSET); -	} -} +	struct irq_chip_generic *gc; +	struct irq_chip_type *ct; -/* Enable interrupt */ -static void davinci_unmask_irq(unsigned int irq) -{ -	unsigned int mask; -	u32 l; - -	mask = 1 << IRQ_BIT(irq); - -	if (irq > 31) { -		l = davinci_irq_readl(IRQ_ENT_REG1_OFFSET); -		l |= mask; -		davinci_irq_writel(l, IRQ_ENT_REG1_OFFSET); -	} else { -		l = davinci_irq_readl(IRQ_ENT_REG0_OFFSET); -		l |= mask; -		davinci_irq_writel(l, IRQ_ENT_REG0_OFFSET); +	gc = irq_alloc_generic_chip("AINTC", 1, irq_start, base, handle_edge_irq); +	if (!gc) { +		pr_err("%s: irq_alloc_generic_chip for IRQ %u failed\n", +		       __func__, irq_start); +		return;  	} -} - -/* EOI interrupt */ -static void davinci_ack_irq(unsigned int irq) -{ -	unsigned int mask; -	mask = 1 << IRQ_BIT(irq); +	ct = gc->chip_types; +	ct->chip.irq_ack = irq_gc_ack_set_bit; +	ct->chip.irq_mask = irq_gc_mask_clr_bit; +	ct->chip.irq_unmask = irq_gc_mask_set_bit; -	if (irq > 31) -		davinci_irq_writel(mask, IRQ_REG1_OFFSET); -	else -		davinci_irq_writel(mask, IRQ_REG0_OFFSET); +	ct->regs.ack = IRQ_REG0_OFFSET; +	ct->regs.mask = IRQ_ENT_REG0_OFFSET; +	irq_setup_generic_chip(gc, IRQ_MSK(num), IRQ_GC_INIT_MASK_CACHE, +			       IRQ_NOREQUEST | IRQ_NOPROBE, 0);  } -static struct irq_chip davinci_irq_chip_0 = { -	.name	= "AINTC", -	.ack	= davinci_ack_irq, -	.mask	= davinci_mask_irq, -	.unmask = davinci_unmask_irq, -}; -  /* ARM Interrupt Controller Initialization */  void __init davinci_irq_init(void)  { -	unsigned i; +	unsigned i, j;  	const u8 *davinci_def_priorities = davinci_soc_info.intc_irq_prios;  	davinci_intc_type = DAVINCI_INTC_TYPE_AINTC; @@ -144,7 +103,6 @@ void __init davinci_irq_init(void)  	davinci_irq_writel(~0x0, IRQ_REG1_OFFSET);  	for (i = IRQ_INTPRI0_REG_OFFSET; i <= IRQ_INTPRI7_REG_OFFSET; i += 4) { -		unsigned	j;  		u32		pri;  		for (j = 0, pri = 0; j < 32; j += 4, davinci_def_priorities++) @@ -152,13 +110,8 @@ void __init davinci_irq_init(void)  		davinci_irq_writel(pri, i);  	} -	/* set up genirq dispatch for ARM INTC */ -	for (i = 0; i < davinci_soc_info.intc_irq_num; i++) { -		set_irq_chip(i, &davinci_irq_chip_0); -		set_irq_flags(i, IRQF_VALID | IRQF_PROBE); -		if (i != IRQ_TINT1_TINT34) -			set_irq_handler(i, handle_edge_irq); -		else -			set_irq_handler(i, handle_level_irq); -	} +	for (i = 0, j = 0; i < davinci_soc_info.intc_irq_num; i += 32, j += 0x04) +		davinci_alloc_gc(davinci_intc_base + j, i, 32); + +	irq_set_handler(IRQ_TINT1_TINT34, handle_level_irq);  } diff --git a/arch/arm/mach-davinci/pm.c b/arch/arm/mach-davinci/pm.c index fab953b43de..a508fe587af 100644 --- a/arch/arm/mach-davinci/pm.c +++ b/arch/arm/mach-davinci/pm.c @@ -17,7 +17,9 @@  #include <asm/cacheflush.h>  #include <asm/delay.h> +#include <asm/io.h> +#include <mach/common.h>  #include <mach/da8xx.h>  #include <mach/sram.h>  #include <mach/pm.h> @@ -110,7 +112,7 @@ static int davinci_pm_enter(suspend_state_t state)  	return ret;  } -static struct platform_suspend_ops davinci_pm_ops = { +static const struct platform_suspend_ops davinci_pm_ops = {  	.enter		= davinci_pm_enter,  	.valid		= suspend_valid_only_mem,  }; @@ -151,8 +153,7 @@ static struct platform_driver davinci_pm_driver = {  	.remove = __exit_p(davinci_pm_remove),  }; -static int __init davinci_pm_init(void) +int __init davinci_pm_init(void)  {  	return platform_driver_probe(&davinci_pm_driver, davinci_pm_probe);  } -late_initcall(davinci_pm_init); diff --git a/arch/arm/mach-davinci/pm_domain.c b/arch/arm/mach-davinci/pm_domain.c new file mode 100644 index 00000000000..6b98413cebd --- /dev/null +++ b/arch/arm/mach-davinci/pm_domain.c @@ -0,0 +1,65 @@ +/* + * Runtime PM support code for DaVinci + * + * Author: Kevin Hilman + * + * Copyright (C) 2012 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/pm_runtime.h> +#include <linux/pm_clock.h> +#include <linux/platform_device.h> + +#ifdef CONFIG_PM_RUNTIME +static int davinci_pm_runtime_suspend(struct device *dev) +{ +	int ret; + +	dev_dbg(dev, "%s\n", __func__); + +	ret = pm_generic_runtime_suspend(dev); +	if (ret) +		return ret; + +	ret = pm_clk_suspend(dev); +	if (ret) { +		pm_generic_runtime_resume(dev); +		return ret; +	} + +	return 0; +} + +static int davinci_pm_runtime_resume(struct device *dev) +{ +	dev_dbg(dev, "%s\n", __func__); + +	pm_clk_resume(dev); +	return pm_generic_runtime_resume(dev); +} +#endif + +static struct dev_pm_domain davinci_pm_domain = { +	.ops = { +		SET_RUNTIME_PM_OPS(davinci_pm_runtime_suspend, +				   davinci_pm_runtime_resume, NULL) +		USE_PLATFORM_PM_SLEEP_OPS +	}, +}; + +static struct pm_clk_notifier_block platform_bus_notifier = { +	.pm_domain = &davinci_pm_domain, +	.con_ids = { "fck", "master", "slave", NULL }, +}; + +static int __init davinci_pm_runtime_init(void) +{ +	pm_clk_add_notifier(&platform_bus_type, &platform_bus_notifier); + +	return 0; +} +core_initcall(davinci_pm_runtime_init); diff --git a/arch/arm/mach-davinci/psc.c b/arch/arm/mach-davinci/psc.c index 1b15dbd0a77..82fdc69d572 100644 --- a/arch/arm/mach-davinci/psc.c +++ b/arch/arm/mach-davinci/psc.c @@ -25,6 +25,8 @@  #include <mach/cputype.h>  #include <mach/psc.h> +#include "clock.h" +  /* Return nonzero iff the domain's clock is active */  int __init davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id)  { @@ -33,7 +35,7 @@ int __init davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id)  	struct davinci_soc_info *soc_info = &davinci_soc_info;  	if (!soc_info->psc_bases || (ctlr >= soc_info->psc_bases_num)) { -		pr_warning("PSC: Bad psc data: 0x%x[%d]\n", +		pr_warn("PSC: Bad psc data: 0x%x[%d]\n",  				(int)soc_info->psc_bases, ctlr);  		return 0;  	} @@ -46,32 +48,67 @@ int __init davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id)  	return mdstat & BIT(12);  } +/* Control "reset" line associated with PSC domain */ +void davinci_psc_reset(unsigned int ctlr, unsigned int id, bool reset) +{ +	u32 mdctl; +	void __iomem *psc_base; +	struct davinci_soc_info *soc_info = &davinci_soc_info; + +	if (!soc_info->psc_bases || (ctlr >= soc_info->psc_bases_num)) { +		pr_warn("PSC: Bad psc data: 0x%x[%d]\n", +				(int)soc_info->psc_bases, ctlr); +		return; +	} + +	psc_base = ioremap(soc_info->psc_bases[ctlr], SZ_4K); + +	mdctl = readl(psc_base + MDCTL + 4 * id); +	if (reset) +		mdctl &= ~MDCTL_LRST; +	else +		mdctl |= MDCTL_LRST; +	writel(mdctl, psc_base + MDCTL + 4 * id); + +	iounmap(psc_base); +} +  /* Enable or disable a PSC domain */  void davinci_psc_config(unsigned int domain, unsigned int ctlr, -		unsigned int id, u32 next_state) +		unsigned int id, bool enable, u32 flags)  { -	u32 epcpr, ptcmd, ptstat, pdstat, pdctl1, mdstat, mdctl; +	u32 epcpr, ptcmd, ptstat, pdstat, pdctl, mdstat, mdctl;  	void __iomem *psc_base;  	struct davinci_soc_info *soc_info = &davinci_soc_info; +	u32 next_state = PSC_STATE_ENABLE;  	if (!soc_info->psc_bases || (ctlr >= soc_info->psc_bases_num)) { -		pr_warning("PSC: Bad psc data: 0x%x[%d]\n", +		pr_warn("PSC: Bad psc data: 0x%x[%d]\n",  				(int)soc_info->psc_bases, ctlr);  		return;  	}  	psc_base = ioremap(soc_info->psc_bases[ctlr], SZ_4K); +	if (!enable) { +		if (flags & PSC_SWRSTDISABLE) +			next_state = PSC_STATE_SWRSTDISABLE; +		else +			next_state = PSC_STATE_DISABLE; +	} +  	mdctl = __raw_readl(psc_base + MDCTL + 4 * id);  	mdctl &= ~MDSTAT_STATE_MASK;  	mdctl |= next_state; +	if (flags & PSC_FORCE) +		mdctl |= MDCTL_FORCE;  	__raw_writel(mdctl, psc_base + MDCTL + 4 * id); -	pdstat = __raw_readl(psc_base + PDSTAT); -	if ((pdstat & 0x00000001) == 0) { -		pdctl1 = __raw_readl(psc_base + PDCTL1); -		pdctl1 |= 0x1; -		__raw_writel(pdctl1, psc_base + PDCTL1); +	pdstat = __raw_readl(psc_base + PDSTAT + 4 * domain); +	if ((pdstat & PDSTAT_STATE_MASK) == 0) { +		pdctl = __raw_readl(psc_base + PDCTL + 4 * domain); +		pdctl |= PDCTL_NEXT; +		__raw_writel(pdctl, psc_base + PDCTL + 4 * domain);  		ptcmd = 1 << domain;  		__raw_writel(ptcmd, psc_base + PTCMD); @@ -80,24 +117,19 @@ void davinci_psc_config(unsigned int domain, unsigned int ctlr,  			epcpr = __raw_readl(psc_base + EPCPR);  		} while ((((epcpr >> domain) & 1) == 0)); -		pdctl1 = __raw_readl(psc_base + PDCTL1); -		pdctl1 |= 0x100; -		__raw_writel(pdctl1, psc_base + PDCTL1); - -		do { -			ptstat = __raw_readl(psc_base + -					       PTSTAT); -		} while (!(((ptstat >> domain) & 1) == 0)); +		pdctl = __raw_readl(psc_base + PDCTL + 4 * domain); +		pdctl |= PDCTL_EPCGOOD; +		__raw_writel(pdctl, psc_base + PDCTL + 4 * domain);  	} else {  		ptcmd = 1 << domain;  		__raw_writel(ptcmd, psc_base + PTCMD); - -		do { -			ptstat = __raw_readl(psc_base + PTSTAT); -		} while (!(((ptstat >> domain) & 1) == 0));  	}  	do { +		ptstat = __raw_readl(psc_base + PTSTAT); +	} while (!(((ptstat >> domain) & 1) == 0)); + +	do {  		mdstat = __raw_readl(psc_base + MDSTAT + 4 * id);  	} while (!((mdstat & MDSTAT_STATE_MASK) == next_state)); diff --git a/arch/arm/mach-davinci/serial.c b/arch/arm/mach-davinci/serial.c index 1875740fe27..5e93a734c85 100644 --- a/arch/arm/mach-davinci/serial.c +++ b/arch/arm/mach-davinci/serial.c @@ -70,33 +70,35 @@ static void __init davinci_serial_reset(struct plat_serial8250_port *p)  				 UART_DM646X_SCR_TX_WATERMARK);  } -int __init davinci_serial_init(struct davinci_uart_config *info) +int __init davinci_serial_init(struct platform_device *serial_dev)  { -	int i; -	char name[16]; -	struct clk *uart_clk; -	struct davinci_soc_info *soc_info = &davinci_soc_info; -	struct device *dev = &soc_info->serial_dev->dev; -	struct plat_serial8250_port *p = dev->platform_data; +	int i, ret = 0; +	struct device *dev; +	struct plat_serial8250_port *p; +	struct clk *clk;  	/*  	 * Make sure the serial ports are muxed on at this point.  	 * You have to mux them off in device drivers later on if not needed.  	 */ -	for (i = 0; p->flags; i++, p++) { -		if (!(info->enabled_uarts & (1 << i))) +	for (i = 0; serial_dev[i].dev.platform_data != NULL; i++) { +		dev = &serial_dev[i].dev; +		p = dev->platform_data; + +		ret = platform_device_register(&serial_dev[i]); +		if (ret)  			continue; -		sprintf(name, "uart%d", i); -		uart_clk = clk_get(dev, name); -		if (IS_ERR(uart_clk)) { -			printk(KERN_ERR "%s:%d: failed to get UART%d clock\n", -					__func__, __LINE__, i); +		clk = clk_get(dev, NULL); +		if (IS_ERR(clk)) { +			pr_err("%s:%d: failed to get UART%d clock\n", +			       __func__, __LINE__, i);  			continue;  		} -		clk_enable(uart_clk); -		p->uartclk = clk_get_rate(uart_clk); +		clk_prepare_enable(clk); + +		p->uartclk = clk_get_rate(clk);  		if (!p->membase && p->mapbase) {  			p->membase = ioremap(p->mapbase, SZ_4K); @@ -110,6 +112,5 @@ int __init davinci_serial_init(struct davinci_uart_config *info)  		if (p->membase && p->type != PORT_AR7)  			davinci_serial_reset(p);  	} - -	return platform_device_register(soc_info->serial_dev); +	return ret;  } diff --git a/arch/arm/mach-davinci/sleep.S b/arch/arm/mach-davinci/sleep.S index fb5e72b532b..d4e9316ecac 100644 --- a/arch/arm/mach-davinci/sleep.S +++ b/arch/arm/mach-davinci/sleep.S @@ -22,7 +22,7 @@  #include <linux/linkage.h>  #include <asm/assembler.h>  #include <mach/psc.h> -#include <mach/memory.h> +#include <mach/ddr2.h>  #include "clock.h" @@ -217,7 +217,11 @@ ddr2clk_stop_done:  ENDPROC(davinci_ddr_psc_config)  CACHE_FLUSH: -	.word	arm926_flush_kern_cache_all +#ifdef CONFIG_CPU_V6 +	.word	v6_flush_kern_cache_all +#else +	.word   arm926_flush_kern_cache_all +#endif  ENTRY(davinci_cpu_suspend_sz)  	.word	. - davinci_cpu_suspend diff --git a/arch/arm/mach-davinci/sram.c b/arch/arm/mach-davinci/sram.c index db0f7787faf..8540dddf1fb 100644 --- a/arch/arm/mach-davinci/sram.c +++ b/arch/arm/mach-davinci/sram.c @@ -10,6 +10,7 @@   */  #include <linux/module.h>  #include <linux/init.h> +#include <linux/io.h>  #include <linux/genalloc.h>  #include <mach/common.h> @@ -17,9 +18,13 @@  static struct gen_pool *sram_pool; +struct gen_pool *sram_get_gen_pool(void) +{ +	return sram_pool; +} +  void *sram_alloc(size_t len, dma_addr_t *dma)  { -	unsigned long vaddr;  	dma_addr_t dma_base = davinci_soc_info.sram_dma;  	if (dma) @@ -27,13 +32,7 @@ void *sram_alloc(size_t len, dma_addr_t *dma)  	if (!sram_pool || (dma && !dma_base))  		return NULL; -	vaddr = gen_pool_alloc(sram_pool, len); -	if (!vaddr) -		return NULL; - -	if (dma) -		*dma = dma_base + (vaddr - SRAM_VIRT); -	return (void *)vaddr; +	return gen_pool_dma_alloc(sram_pool, len, dma);  }  EXPORT_SYMBOL(sram_alloc); @@ -53,8 +52,10 @@ EXPORT_SYMBOL(sram_free);   */  static int __init sram_init(void)  { +	phys_addr_t phys = davinci_soc_info.sram_dma;  	unsigned len = davinci_soc_info.sram_len;  	int status = 0; +	void __iomem *addr;  	if (len) {  		len = min_t(unsigned, len, SRAM_SIZE); @@ -62,8 +63,17 @@ static int __init sram_init(void)  		if (!sram_pool)  			status = -ENOMEM;  	} -	if (sram_pool) -		status = gen_pool_add(sram_pool, SRAM_VIRT, len, -1); + +	if (sram_pool) { +		addr = ioremap(phys, len); +		if (!addr) +			return -ENOMEM; +		status = gen_pool_add_virt(sram_pool, (unsigned long) addr, +					   phys, len, -1); +		if (status < 0) +			iounmap(addr); +	} +  	WARN_ON(status < 0);  	return status;  } diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index 0f21c36e65d..24ad30f32ae 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -18,12 +18,15 @@  #include <linux/clk.h>  #include <linux/err.h>  #include <linux/platform_device.h> +#include <linux/sched_clock.h> -#include <mach/hardware.h>  #include <asm/mach/irq.h>  #include <asm/mach/time.h> +  #include <mach/cputype.h> +#include <mach/hardware.h>  #include <mach/time.h> +  #include "clock.h"  static struct clock_event_device clockevent_davinci; @@ -178,7 +181,7 @@ static struct timer_s timers[] = {  		.name      = "clockevent",  		.opts      = TIMER_OPTS_DISABLED,  		.irqaction = { -			.flags   = IRQF_DISABLED | IRQF_TIMER, +			.flags   = IRQF_TIMER,  			.handler = timer_interrupt,  		}  	}, @@ -187,7 +190,7 @@ static struct timer_s timers[] = {  		.period     = ~0,  		.opts       = TIMER_OPTS_PERIODIC,  		.irqaction = { -			.flags   = IRQF_DISABLED | IRQF_TIMER, +			.flags   = IRQF_TIMER,  			.handler = freerun_interrupt,  		}  	}, @@ -276,11 +279,18 @@ static struct clocksource clocksource_davinci = {  	.rating		= 300,  	.read		= read_cycles,  	.mask		= CLOCKSOURCE_MASK(32), -	.shift		= 24,  	.flags		= CLOCK_SOURCE_IS_CONTINUOUS,  };  /* + * Overwrite weak default sched_clock with something more precise + */ +static u64 notrace davinci_read_sched_clock(void) +{ +	return timer32_read(&timers[TID_CLOCKSOURCE]); +} + +/*   * clockevent   */  static int davinci_set_next_event(unsigned long cycles, @@ -321,13 +331,12 @@ static void davinci_set_mode(enum clock_event_mode mode,  static struct clock_event_device clockevent_davinci = {  	.features       = CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, -	.shift		= 32,  	.set_next_event	= davinci_set_next_event,  	.set_mode	= davinci_set_mode,  }; -static void __init davinci_timer_init(void) +void __init davinci_timer_init(void)  {  	struct clk *timer_clk;  	struct davinci_soc_info *soc_info = &davinci_soc_info; @@ -369,7 +378,7 @@ static void __init davinci_timer_init(void)  	timer_clk = clk_get(NULL, "timer0");  	BUG_ON(IS_ERR(timer_clk)); -	clk_enable(timer_clk); +	clk_prepare_enable(timer_clk);  	/* init timer hw */  	timer_init(); @@ -378,32 +387,24 @@ static void __init davinci_timer_init(void)  	/* setup clocksource */  	clocksource_davinci.name = id_to_name[clocksource_id]; -	clocksource_davinci.mult = -		clocksource_khz2mult(davinci_clock_tick_rate/1000, -				     clocksource_davinci.shift); -	if (clocksource_register(&clocksource_davinci)) +	if (clocksource_register_hz(&clocksource_davinci, +				    davinci_clock_tick_rate))  		printk(err, clocksource_davinci.name); +	sched_clock_register(davinci_read_sched_clock, 32, +			  davinci_clock_tick_rate); +  	/* setup clockevent */  	clockevent_davinci.name = id_to_name[timers[TID_CLOCKEVENT].id]; -	clockevent_davinci.mult = div_sc(davinci_clock_tick_rate, NSEC_PER_SEC, -					 clockevent_davinci.shift); -	clockevent_davinci.max_delta_ns = -		clockevent_delta2ns(0xfffffffe, &clockevent_davinci); -	clockevent_davinci.min_delta_ns = 50000; /* 50 usec */  	clockevent_davinci.cpumask = cpumask_of(0); -	clockevents_register_device(&clockevent_davinci); +	clockevents_config_and_register(&clockevent_davinci, +					davinci_clock_tick_rate, 1, 0xfffffffe);  	for (i=0; i< ARRAY_SIZE(timers); i++)  		timer32_config(&timers[i]);  } -struct sys_timer davinci_timer = { -	.init   = davinci_timer_init, -}; - -  /* reset board using watchdog timer */  void davinci_watchdog_reset(struct platform_device *pdev)  { @@ -418,7 +419,7 @@ void davinci_watchdog_reset(struct platform_device *pdev)  	wd_clk = clk_get(&pdev->dev, NULL);  	if (WARN_ON(IS_ERR(wd_clk)))  		return; -	clk_enable(wd_clk); +	clk_prepare_enable(wd_clk);  	/* disable, internal clock source */  	__raw_writel(0, base + TCR); diff --git a/arch/arm/mach-davinci/tnetv107x.c b/arch/arm/mach-davinci/tnetv107x.c deleted file mode 100644 index daeae06430b..00000000000 --- a/arch/arm/mach-davinci/tnetv107x.c +++ /dev/null @@ -1,760 +0,0 @@ -/* - * Texas Instruments TNETV107X SoC Support - * - * Copyright (C) 2010 Texas Instruments - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation version 2. - * - * This program is distributed "as is" WITHOUT ANY WARRANTY of any - * kind, whether express or implied; without even the implied warranty - * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the - * GNU General Public License for more details. - */ -#include <linux/kernel.h> -#include <linux/init.h> -#include <linux/clk.h> -#include <linux/io.h> -#include <linux/err.h> -#include <linux/platform_device.h> - -#include <asm/mach/map.h> - -#include <mach/common.h> -#include <mach/time.h> -#include <mach/cputype.h> -#include <mach/psc.h> -#include <mach/cp_intc.h> -#include <mach/irqs.h> -#include <mach/gpio.h> -#include <mach/hardware.h> -#include <mach/tnetv107x.h> - -#include "clock.h" -#include "mux.h" - -/* Base addresses for on-chip devices */ -#define TNETV107X_INTC_BASE			0x03000000 -#define TNETV107X_TIMER0_BASE			0x08086500 -#define TNETV107X_TIMER1_BASE			0x08086600 -#define TNETV107X_CHIP_CFG_BASE			0x08087000 -#define TNETV107X_GPIO_BASE			0x08088000 -#define TNETV107X_CLOCK_CONTROL_BASE		0x0808a000 -#define TNETV107X_PSC_BASE			0x0808b000 - -/* Reference clock frequencies */ -#define OSC_FREQ_ONCHIP		(24000 * 1000) -#define OSC_FREQ_OFFCHIP_SYS	(25000 * 1000) -#define OSC_FREQ_OFFCHIP_ETH	(25000 * 1000) -#define OSC_FREQ_OFFCHIP_TDM	(19200 * 1000) - -#define N_PLLS	3 - -/* Clock Control Registers */ -struct clk_ctrl_regs { -	u32	pll_bypass; -	u32	_reserved0; -	u32	gem_lrst; -	u32	_reserved1; -	u32	pll_unlock_stat; -	u32	sys_unlock; -	u32	eth_unlock; -	u32	tdm_unlock; -}; - -/* SSPLL Registers */ -struct sspll_regs { -	u32	modes; -	u32	post_div; -	u32	pre_div; -	u32	mult_factor; -	u32	divider_range; -	u32	bw_divider; -	u32	spr_amount; -	u32	spr_rate_div; -	u32	diag; -}; - -/* Watchdog Timer Registers */ -struct wdt_regs { -	u32	kick_lock; -	u32	kick; -	u32	change_lock; -	u32	change ; -	u32	disable_lock; -	u32	disable; -	u32	prescale_lock; -	u32	prescale; -}; - -static struct clk_ctrl_regs __iomem *clk_ctrl_regs; - -static struct sspll_regs __iomem *sspll_regs[N_PLLS]; -static int sspll_regs_base[N_PLLS] = { 0x40, 0x80, 0xc0 }; - -/* PLL bypass bit shifts in clk_ctrl_regs->pll_bypass register */ -static u32 bypass_mask[N_PLLS] = { BIT(0), BIT(2), BIT(1) }; - -/* offchip (external) reference clock frequencies */ -static u32 pll_ext_freq[] = { -	OSC_FREQ_OFFCHIP_SYS, -	OSC_FREQ_OFFCHIP_TDM, -	OSC_FREQ_OFFCHIP_ETH -}; - -/* PSC control registers */ -static u32 psc_regs[] = { TNETV107X_PSC_BASE }; - -/* Host map for interrupt controller */ -static u32 intc_host_map[] = { 0x01010000, 0x01010101, -1 }; - -static unsigned long clk_sspll_recalc(struct clk *clk); - -/* Level 1 - the PLLs */ -#define define_pll_clk(cname, pll, divmask, base)	\ -	static struct pll_data pll_##cname##_data = {	\ -		.num		= pll,			\ -		.div_ratio_mask	= divmask,		\ -		.phys_base	= base +		\ -			TNETV107X_CLOCK_CONTROL_BASE,	\ -	};						\ -	static struct clk pll_##cname##_clk = {		\ -		.name		= "pll_" #cname "_clk",	\ -		.pll_data	= &pll_##cname##_data,	\ -		.flags		= CLK_PLL,		\ -		.recalc		= clk_sspll_recalc,	\ -	} - -define_pll_clk(sys, 0, 0x1ff, 0x600); -define_pll_clk(tdm, 1, 0x0ff, 0x200); -define_pll_clk(eth, 2, 0x0ff, 0x400); - -/* Level 2 - divided outputs from the PLLs */ -#define define_pll_div_clk(pll, cname, div)		\ -	static struct clk pll##_##cname##_clk = {	\ -		.name		= #pll "_" #cname "_clk",\ -		.parent		= &pll_##pll##_clk,	\ -		.flags		= CLK_PLL,		\ -		.div_reg	= PLLDIV##div,		\ -	} - -define_pll_div_clk(sys, arm1176,	1); -define_pll_div_clk(sys, dsp,		2); -define_pll_div_clk(sys, ddr,		3); -define_pll_div_clk(sys, full,		4); -define_pll_div_clk(sys, lcd,		5); -define_pll_div_clk(sys, vlynq_ref,	6); -define_pll_div_clk(sys, tsc,		7); -define_pll_div_clk(sys, half,		8); - -define_pll_div_clk(eth, 5mhz,		1); -define_pll_div_clk(eth, 50mhz,		2); -define_pll_div_clk(eth, 125mhz,		3); -define_pll_div_clk(eth, 250mhz,		4); -define_pll_div_clk(eth, 25mhz,		5); - -define_pll_div_clk(tdm, 0,		1); -define_pll_div_clk(tdm, extra,		2); -define_pll_div_clk(tdm, 1,		3); - - -/* Level 3 - LPSC gated clocks */ -#define __lpsc_clk(cname, _parent, mod, flg)		\ -	static struct clk clk_##cname = {		\ -		.name		= #cname,		\ -		.parent		= &_parent,		\ -		.lpsc		= TNETV107X_LPSC_##mod,\ -		.flags		= flg,			\ -	} - -#define lpsc_clk_enabled(cname, parent, mod)		\ -	__lpsc_clk(cname, parent, mod, ALWAYS_ENABLED) - -#define lpsc_clk(cname, parent, mod)			\ -	__lpsc_clk(cname, parent, mod, 0) - -lpsc_clk_enabled(arm,		sys_arm1176_clk, ARM); -lpsc_clk_enabled(gem,		sys_dsp_clk,	GEM); -lpsc_clk_enabled(ddr2_phy,	sys_ddr_clk,	DDR2_PHY); -lpsc_clk_enabled(tpcc,		sys_full_clk,	TPCC); -lpsc_clk_enabled(tptc0,		sys_full_clk,	TPTC0); -lpsc_clk_enabled(tptc1,		sys_full_clk,	TPTC1); -lpsc_clk_enabled(ram,		sys_full_clk,	RAM); -lpsc_clk_enabled(aemif,		sys_full_clk,	AEMIF); -lpsc_clk_enabled(chipcfg,	sys_half_clk,	CHIP_CFG); -lpsc_clk_enabled(rom,		sys_half_clk,	ROM); -lpsc_clk_enabled(secctl,	sys_half_clk,	SECCTL); -lpsc_clk_enabled(keymgr,	sys_half_clk,	KEYMGR); -lpsc_clk_enabled(gpio,		sys_half_clk,	GPIO); -lpsc_clk_enabled(debugss,	sys_half_clk,	DEBUGSS); -lpsc_clk_enabled(system,	sys_half_clk,	SYSTEM); -lpsc_clk_enabled(ddr2_vrst,	sys_ddr_clk,	DDR2_EMIF1_VRST); -lpsc_clk_enabled(ddr2_vctl_rst,	sys_ddr_clk,	DDR2_EMIF2_VCTL_RST); -lpsc_clk_enabled(wdt_arm,	sys_half_clk,	WDT_ARM); - -lpsc_clk(mbx_lite,	sys_arm1176_clk,	MBX_LITE); -lpsc_clk(ethss,		eth_125mhz_clk,		ETHSS); -lpsc_clk(tsc,		sys_tsc_clk,		TSC); -lpsc_clk(uart0,		sys_half_clk,		UART0); -lpsc_clk(uart1,		sys_half_clk,		UART1); -lpsc_clk(uart2,		sys_half_clk,		UART2); -lpsc_clk(pktsec,	sys_half_clk,		PKTSEC); -lpsc_clk(keypad,	sys_half_clk,		KEYPAD); -lpsc_clk(mdio,		sys_half_clk,		MDIO); -lpsc_clk(sdio0,		sys_half_clk,		SDIO0); -lpsc_clk(sdio1,		sys_half_clk,		SDIO1); -lpsc_clk(timer0,	sys_half_clk,		TIMER0); -lpsc_clk(timer1,	sys_half_clk,		TIMER1); -lpsc_clk(wdt_dsp,	sys_half_clk,		WDT_DSP); -lpsc_clk(ssp,		sys_half_clk,		SSP); -lpsc_clk(tdm0,		tdm_0_clk,		TDM0); -lpsc_clk(tdm1,		tdm_1_clk,		TDM1); -lpsc_clk(vlynq,		sys_vlynq_ref_clk,	VLYNQ); -lpsc_clk(mcdma,		sys_half_clk,		MCDMA); -lpsc_clk(usb0,		sys_half_clk,		USB0); -lpsc_clk(usb1,		sys_half_clk,		USB1); -lpsc_clk(usbss,		sys_half_clk,		USBSS); -lpsc_clk(ethss_rgmii,	eth_250mhz_clk,		ETHSS_RGMII); -lpsc_clk(imcop,		sys_dsp_clk,		IMCOP); -lpsc_clk(spare,		sys_half_clk,		SPARE); - -/* LCD needs a full power down to clear controller state */ -__lpsc_clk(lcd, sys_lcd_clk, LCD, PSC_SWRSTDISABLE); - - -/* Level 4 - leaf clocks for LPSC modules shared across drivers */ -static struct clk clk_rng = { .name = "rng", .parent = &clk_pktsec }; -static struct clk clk_pka = { .name = "pka", .parent = &clk_pktsec }; - -static struct clk_lookup clks[] = { -	CLK(NULL,		"pll_sys_clk",		&pll_sys_clk), -	CLK(NULL,		"pll_eth_clk",		&pll_eth_clk), -	CLK(NULL,		"pll_tdm_clk",		&pll_tdm_clk), -	CLK(NULL,		"sys_arm1176_clk",	&sys_arm1176_clk), -	CLK(NULL,		"sys_dsp_clk",		&sys_dsp_clk), -	CLK(NULL,		"sys_ddr_clk",		&sys_ddr_clk), -	CLK(NULL,		"sys_full_clk",		&sys_full_clk), -	CLK(NULL,		"sys_lcd_clk",		&sys_lcd_clk), -	CLK(NULL,		"sys_vlynq_ref_clk",	&sys_vlynq_ref_clk), -	CLK(NULL,		"sys_tsc_clk",		&sys_tsc_clk), -	CLK(NULL,		"sys_half_clk",		&sys_half_clk), -	CLK(NULL,		"eth_5mhz_clk",		ð_5mhz_clk), -	CLK(NULL,		"eth_50mhz_clk",	ð_50mhz_clk), -	CLK(NULL,		"eth_125mhz_clk",	ð_125mhz_clk), -	CLK(NULL,		"eth_250mhz_clk",	ð_250mhz_clk), -	CLK(NULL,		"eth_25mhz_clk",	ð_25mhz_clk), -	CLK(NULL,		"tdm_0_clk",		&tdm_0_clk), -	CLK(NULL,		"tdm_extra_clk",	&tdm_extra_clk), -	CLK(NULL,		"tdm_1_clk",		&tdm_1_clk), -	CLK(NULL,		"clk_arm",		&clk_arm), -	CLK(NULL,		"clk_gem",		&clk_gem), -	CLK(NULL,		"clk_ddr2_phy",		&clk_ddr2_phy), -	CLK(NULL,		"clk_tpcc",		&clk_tpcc), -	CLK(NULL,		"clk_tptc0",		&clk_tptc0), -	CLK(NULL,		"clk_tptc1",		&clk_tptc1), -	CLK(NULL,		"clk_ram",		&clk_ram), -	CLK(NULL,		"clk_mbx_lite",		&clk_mbx_lite), -	CLK("tnetv107x-fb.0",	NULL,			&clk_lcd), -	CLK(NULL,		"clk_ethss",		&clk_ethss), -	CLK(NULL,		"aemif",		&clk_aemif), -	CLK(NULL,		"clk_chipcfg",		&clk_chipcfg), -	CLK("tnetv107x-ts.0",	NULL,			&clk_tsc), -	CLK(NULL,		"clk_rom",		&clk_rom), -	CLK(NULL,		"uart2",		&clk_uart2), -	CLK(NULL,		"clk_pktsec",		&clk_pktsec), -	CLK("tnetv107x-rng.0",	NULL,			&clk_rng), -	CLK("tnetv107x-pka.0",	NULL,			&clk_pka), -	CLK(NULL,		"clk_secctl",		&clk_secctl), -	CLK(NULL,		"clk_keymgr",		&clk_keymgr), -	CLK("tnetv107x-keypad.0", NULL,			&clk_keypad), -	CLK(NULL,		"clk_gpio",		&clk_gpio), -	CLK(NULL,		"clk_mdio",		&clk_mdio), -	CLK("davinci_mmc.0",	NULL,			&clk_sdio0), -	CLK(NULL,		"uart0",		&clk_uart0), -	CLK(NULL,		"uart1",		&clk_uart1), -	CLK(NULL,		"timer0",		&clk_timer0), -	CLK(NULL,		"timer1",		&clk_timer1), -	CLK("tnetv107x_wdt.0",	NULL,			&clk_wdt_arm), -	CLK(NULL,		"clk_wdt_dsp",		&clk_wdt_dsp), -	CLK("ti-ssp.0",		NULL,			&clk_ssp), -	CLK(NULL,		"clk_tdm0",		&clk_tdm0), -	CLK(NULL,		"clk_vlynq",		&clk_vlynq), -	CLK(NULL,		"clk_mcdma",		&clk_mcdma), -	CLK(NULL,		"clk_usb0",		&clk_usb0), -	CLK(NULL,		"clk_tdm1",		&clk_tdm1), -	CLK(NULL,		"clk_debugss",		&clk_debugss), -	CLK(NULL,		"clk_ethss_rgmii",	&clk_ethss_rgmii), -	CLK(NULL,		"clk_system",		&clk_system), -	CLK(NULL,		"clk_imcop",		&clk_imcop), -	CLK(NULL,		"clk_spare",		&clk_spare), -	CLK("davinci_mmc.1",	NULL,			&clk_sdio1), -	CLK(NULL,		"clk_usb1",		&clk_usb1), -	CLK(NULL,		"clk_usbss",		&clk_usbss), -	CLK(NULL,		"clk_ddr2_vrst",	&clk_ddr2_vrst), -	CLK(NULL,		"clk_ddr2_vctl_rst",	&clk_ddr2_vctl_rst), -	CLK(NULL,		NULL,			NULL), -}; - -static const struct mux_config pins[] = { -#ifdef CONFIG_DAVINCI_MUX -	MUX_CFG(TNETV107X, ASR_A00,		0, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO32,		0, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A01,		0, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO33,		0, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A02,		0, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO34,		0, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A03,		0, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO35,		0, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A04,		0, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO36,		0, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A05,		0, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO37,		0, 25, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A06,		1, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO38,		1, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A07,		1, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO39,		1, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A08,		1, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO40,		1, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A09,		1, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO41,		1, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A10,		1, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO42,		1, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A11,		1, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, BOOT_STRP_0,		1, 25, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A12,		2, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, BOOT_STRP_1,		2, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A13,		2, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO43,		2, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A14,		2, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO44,		2, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A15,		2, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO45,		2, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A16,		2, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO46,		2, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A17,		2, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO47,		2, 25, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_A18,		3, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO48,		3, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO1_DATA3_0,	3, 0, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_A19,		3, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO49,		3, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO1_DATA2_0,	3, 5, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_A20,		3, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO50,		3, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO1_DATA1_0,	3, 10, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_A21,		3, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO51,		3, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO1_DATA0_0,	3, 15, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_A22,		3, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO52,		3, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO1_CMD_0,		3, 20, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_A23,		3, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO53,		3, 25, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO1_CLK_0,		3, 25, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_BA_1,		4, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO54,		4, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SYS_PLL_CLK,		4, 0, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_CS0,		4, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, ASR_CS1,		4, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, ASR_CS2,		4, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM_PLL_CLK,		4, 15, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_CS3,		4, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, ETH_PHY_CLK,		4, 20, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, ASR_D00,		4, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO55,		4, 25, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D01,		5, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO56,		5, 0, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D02,		5, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO57,		5, 5, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D03,		5, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO58,		5, 10, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D04,		5, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO59_0,		5, 15, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D05,		5, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO60_0,		5, 20, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D06,		5, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO61_0,		5, 25, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D07,		6, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO62_0,		6, 0, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D08,		6, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO63_0,		6, 5, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D09,		6, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO64_0,		6, 10, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D10,		6, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SDIO1_DATA3_1,	6, 15, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D11,		6, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SDIO1_DATA2_1,	6, 20, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D12,		6, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SDIO1_DATA1_1,	6, 25, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D13,		7, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SDIO1_DATA0_1,	7, 0, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D14,		7, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SDIO1_CMD_1,		7, 5, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_D15,		7, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SDIO1_CLK_1,		7, 10, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_OE,		7, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, BOOT_STRP_2,		7, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_RNW,		7, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO29_0,		7, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_WAIT,		7, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO30_0,		7, 25, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_WE,		8, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, BOOT_STRP_3,		8, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, ASR_WE_DQM0,		8, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO31,		8, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD17_0,		8, 5, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, ASR_WE_DQM1,		8, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, ASR_BA0_0,		8, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, VLYNQ_CLK,		9, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO14,		9, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD19_0,		9, 0, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, VLYNQ_RXD0,		9, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO15,		9, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD20_0,		9, 5, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, VLYNQ_RXD1,		9, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO16,		9, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD21_0,		9, 10, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, VLYNQ_TXD0,		9, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO17,		9, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD22_0,		9, 15, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, VLYNQ_TXD1,		9, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO18,		9, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD23_0,		9, 20, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, SDIO0_CLK,		10, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO19,		10, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO0_CMD,		10, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO20,		10, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO0_DATA0,		10, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO21,		10, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO0_DATA1,		10, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO22,		10, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO0_DATA2,		10, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO23,		10, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SDIO0_DATA3,		10, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO24,		10, 25, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, EMU0,		11, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, EMU1,		11, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, RTCK,		12, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TRST_N,		12, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TCK,			12, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDI,			12, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDO,			12, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TMS,			12, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM1_CLK,		13, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM1_RX,		13, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM1_TX,		13, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM1_FS,		13, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_R0,		14, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_R1,		14, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_R2,		14, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_R3,		14, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_R4,		14, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_R5,		14, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_R6,		15, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO12,		15, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, KEYPAD_R7,		15, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO10,		15, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, KEYPAD_C0,		15, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_C1,		15, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_C2,		15, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_C3,		15, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_C4,		16, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_C5,		16, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, KEYPAD_C6,		16, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO13,		16, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, TEST_CLK_IN,		16, 10, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, KEYPAD_C7,		16, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO11,		16, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, SSP0_0,		17, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SCC_DCLK,		17, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD20_1,		17, 0, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, SSP0_1,		17, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SCC_CS_N,		17, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD21_1,		17, 5, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, SSP0_2,		17, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SCC_D,		17, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD22_1,		17, 10, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, SSP0_3,		17, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, SCC_RESETN,		17, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, LCD_PD23_1,		17, 15, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, SSP1_0,		18, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO25,		18, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, UART2_CTS,		18, 0, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, SSP1_1,		18, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO26,		18, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, UART2_RD,		18, 5, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, SSP1_2,		18, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO27,		18, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, UART2_RTS,		18, 10, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, SSP1_3,		18, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO28,		18, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, UART2_TD,		18, 15, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, UART0_CTS,		19, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, UART0_RD,		19, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, UART0_RTS,		19, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, UART0_TD,		19, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, UART1_RD,		19, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, UART1_TD,		19, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_AC_NCS,		20, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_HSYNC_RNW,	20, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_VSYNC_A0,	20, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_MCLK,		20, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD16_0,		20, 15, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PCLK_E,		20, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD00,		20, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD01,		21, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD02,		21, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD03,		21, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD04,		21, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD05,		21, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD06,		21, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD07,		22, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD08,		22, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO59_1,		22, 5, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PD09,		22, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO60_1,		22, 10, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PD10,		22, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, ASR_BA0_1,		22, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, GPIO61_1,		22, 15, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PD11,		22, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO62_1,		22, 20, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PD12,		22, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO63_1,		22, 25, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PD13,		23, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO64_1,		23, 0, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PD14,		23, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO29_1,		23, 5, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, LCD_PD15,		23, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO30_1,		23, 10, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, EINT0,		24, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO08,		24, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, EINT1,		24, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, GPIO09,		24, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, GPIO00,		24, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD20_2,		24, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, TDM_CLK_IN_2,	24, 10, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, GPIO01,		24, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD21_2,		24, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, 24M_CLK_OUT_1,	24, 15, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, GPIO02,		24, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD22_2,		24, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, GPIO03,		24, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD23_2,		24, 25, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, GPIO04,		25, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD16_1,		25, 0, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, USB0_RXERR,		25, 0, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, GPIO05,		25, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD17_1,		25, 5, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, TDM_CLK_IN_1,	25, 5, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, GPIO06,		25, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD18,		25, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, 24M_CLK_OUT_2,	25, 10, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, GPIO07,		25, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, LCD_PD19_1,		25, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, USB1_RXERR,		25, 15, 0x1f, 0x0c, false) -	MUX_CFG(TNETV107X, ETH_PLL_CLK,		25, 15, 0x1f, 0x1c, false) -	MUX_CFG(TNETV107X, MDIO,		26, 0, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, MDC,			26, 5, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, AIC_MUTE_STAT_N,	26, 10, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM0_CLK,		26, 10, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, AIC_HNS_EN_N,	26, 15, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM0_FS,		26, 15, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, AIC_HDS_EN_STAT_N,	26, 20, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM0_TX,		26, 20, 0x1f, 0x04, false) -	MUX_CFG(TNETV107X, AIC_HNF_EN_STAT_N,	26, 25, 0x1f, 0x00, false) -	MUX_CFG(TNETV107X, TDM0_RX,		26, 25, 0x1f, 0x04, false) -#endif -}; - -/* FIQ are pri 0-1; otherwise 2-7, with 7 lowest priority */ -static u8 irq_prios[TNETV107X_N_CP_INTC_IRQ] = { -	/* fill in default priority 7 */ -	[0 ... (TNETV107X_N_CP_INTC_IRQ - 1)]	= 7, -	/* now override as needed, e.g. [xxx] = 5 */ -}; - -/* Contents of JTAG ID register used to identify exact cpu type */ -static struct davinci_id ids[] = { -	{ -		.variant	= 0x0, -		.part_no	= 0xb8a1, -		.manufacturer	= 0x017, -		.cpu_id		= DAVINCI_CPU_ID_TNETV107X, -		.name		= "tnetv107x rev 1.0", -	}, -	{ -		.variant	= 0x1, -		.part_no	= 0xb8a1, -		.manufacturer	= 0x017, -		.cpu_id		= DAVINCI_CPU_ID_TNETV107X, -		.name		= "tnetv107x rev 1.1/1.2", -	}, -}; - -static struct davinci_timer_instance timer_instance[2] = { -	{ -		.base		= TNETV107X_TIMER0_BASE, -		.bottom_irq	= IRQ_TNETV107X_TIMER_0_TINT12, -		.top_irq	= IRQ_TNETV107X_TIMER_0_TINT34, -	}, -	{ -		.base		= TNETV107X_TIMER1_BASE, -		.bottom_irq	= IRQ_TNETV107X_TIMER_1_TINT12, -		.top_irq	= IRQ_TNETV107X_TIMER_1_TINT34, -	}, -}; - -static struct davinci_timer_info timer_info = { -	.timers		= timer_instance, -	.clockevent_id	= T0_BOT, -	.clocksource_id	= T0_TOP, -}; - -/* - * TNETV107X platforms do not use the static mappings from Davinci - * IO_PHYS/IO_VIRT. This SOC's interesting MMRs are at different addresses, - * and changing IO_PHYS would break away from existing Davinci SOCs. - * - * The primary impact of the current model is that IO_ADDRESS() is not to be - * used to map registers on TNETV107X. - * - * 1.	The first chunk is for INTC:  This needs to be mapped in via iotable - *	because ioremap() does not seem to be operational at the time when - *	irqs are initialized.  Without this, consistent dma init bombs. - * - * 2.	The second chunk maps in register areas that need to be populated into - *	davinci_soc_info.  Note that alignment restrictions come into play if - *	low-level debug is enabled (see note in <mach/tnetv107x.h>). - */ -static struct map_desc io_desc[] = { -	{	/* INTC */ -		.virtual	= IO_VIRT, -		.pfn		= __phys_to_pfn(TNETV107X_INTC_BASE), -		.length		= SZ_16K, -		.type		= MT_DEVICE -	}, -	{	/* Most of the rest */ -		.virtual	= TNETV107X_IO_VIRT, -		.pfn		= __phys_to_pfn(TNETV107X_IO_BASE), -		.length		= IO_SIZE - SZ_1M, -		.type		= MT_DEVICE -	}, -}; - -static unsigned long clk_sspll_recalc(struct clk *clk) -{ -	int		pll; -	unsigned long	mult = 0, prediv = 1, postdiv = 1; -	unsigned long	ref = OSC_FREQ_ONCHIP, ret; -	u32		tmp; - -	if (WARN_ON(!clk->pll_data)) -		return clk->rate; - -	if (!clk_ctrl_regs) { -		void __iomem *tmp; - -		tmp = ioremap(TNETV107X_CLOCK_CONTROL_BASE, SZ_4K); - -		if (WARN(!tmp, "failed ioremap for clock control regs\n")) -			return clk->parent ? clk->parent->rate : 0; - -		for (pll = 0; pll < N_PLLS; pll++) -			sspll_regs[pll] = tmp + sspll_regs_base[pll]; - -		clk_ctrl_regs = tmp; -	} - -	pll = clk->pll_data->num; - -	tmp = __raw_readl(&clk_ctrl_regs->pll_bypass); -	if (!(tmp & bypass_mask[pll])) { -		mult	= __raw_readl(&sspll_regs[pll]->mult_factor); -		prediv	= __raw_readl(&sspll_regs[pll]->pre_div) + 1; -		postdiv	= __raw_readl(&sspll_regs[pll]->post_div) + 1; -	} - -	tmp = __raw_readl(clk->pll_data->base + PLLCTL); -	if (tmp & PLLCTL_CLKMODE) -		ref = pll_ext_freq[pll]; - -	clk->pll_data->input_rate = ref; - -	tmp = __raw_readl(clk->pll_data->base + PLLCTL); -	if (!(tmp & PLLCTL_PLLEN)) -		return ref; - -	ret = ref; -	if (mult) -		ret += ((unsigned long long)ref * mult) / 256; - -	ret /= (prediv * postdiv); - -	return ret; -} - -static void tnetv107x_watchdog_reset(struct platform_device *pdev) -{ -	struct wdt_regs __iomem *regs; - -	regs = ioremap(pdev->resource[0].start, SZ_4K); - -	/* disable watchdog */ -	__raw_writel(0x7777, ®s->disable_lock); -	__raw_writel(0xcccc, ®s->disable_lock); -	__raw_writel(0xdddd, ®s->disable_lock); -	__raw_writel(0, ®s->disable); - -	/* program prescale */ -	__raw_writel(0x5a5a, ®s->prescale_lock); -	__raw_writel(0xa5a5, ®s->prescale_lock); -	__raw_writel(0, ®s->prescale); - -	/* program countdown */ -	__raw_writel(0x6666, ®s->change_lock); -	__raw_writel(0xbbbb, ®s->change_lock); -	__raw_writel(1, ®s->change); - -	/* enable watchdog */ -	__raw_writel(0x7777, ®s->disable_lock); -	__raw_writel(0xcccc, ®s->disable_lock); -	__raw_writel(0xdddd, ®s->disable_lock); -	__raw_writel(1, ®s->disable); - -	/* kick */ -	__raw_writel(0x5555, ®s->kick_lock); -	__raw_writel(0xaaaa, ®s->kick_lock); -	__raw_writel(1, ®s->kick); -} - -static struct davinci_soc_info tnetv107x_soc_info = { -	.io_desc		= io_desc, -	.io_desc_num		= ARRAY_SIZE(io_desc), -	.ids			= ids, -	.ids_num		= ARRAY_SIZE(ids), -	.jtag_id_reg		= TNETV107X_CHIP_CFG_BASE + 0x018, -	.cpu_clks		= clks, -	.psc_bases		= psc_regs, -	.psc_bases_num		= ARRAY_SIZE(psc_regs), -	.pinmux_base		= TNETV107X_CHIP_CFG_BASE + 0x150, -	.pinmux_pins		= pins, -	.pinmux_pins_num	= ARRAY_SIZE(pins), -	.intc_type		= DAVINCI_INTC_TYPE_CP_INTC, -	.intc_base		= TNETV107X_INTC_BASE, -	.intc_irq_prios		= irq_prios, -	.intc_irq_num		= TNETV107X_N_CP_INTC_IRQ, -	.intc_host_map		= intc_host_map, -	.gpio_base		= TNETV107X_GPIO_BASE, -	.gpio_type		= GPIO_TYPE_TNETV107X, -	.gpio_num		= TNETV107X_N_GPIO, -	.timer_info		= &timer_info, -	.serial_dev		= &tnetv107x_serial_device, -	.reset			= tnetv107x_watchdog_reset, -	.reset_device		= &tnetv107x_wdt_device, -}; - -void __init tnetv107x_init(void) -{ -	davinci_common_init(&tnetv107x_soc_info); -} diff --git a/arch/arm/mach-davinci/usb.c b/arch/arm/mach-davinci/usb.c index 31f0cbea0ca..b0a6b522575 100644 --- a/arch/arm/mach-davinci/usb.c +++ b/arch/arm/mach-davinci/usb.c @@ -10,14 +10,15 @@  #include <mach/common.h>  #include <mach/irqs.h>  #include <mach/cputype.h> -#include <mach/usb.h> +#include <mach/da8xx.h> +#include <linux/platform_data/usb-davinci.h>  #define DAVINCI_USB_OTG_BASE	0x01c64000  #define DA8XX_USB0_BASE 	0x01e00000  #define DA8XX_USB1_BASE 	0x01e25000 -#if defined(CONFIG_USB_MUSB_HDRC) || defined(CONFIG_USB_MUSB_HDRC_MODULE) +#if IS_ENABLED(CONFIG_USB_MUSB_HDRC)  static struct musb_hdrc_eps_bits musb_eps[] = {  	{ "ep1_tx", 8, },  	{ "ep1_rx", 8, }, @@ -42,14 +43,8 @@ static struct musb_hdrc_config musb_config = {  };  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  	.clock		= "usb",  	.config		= &musb_config,  }; @@ -64,17 +59,19 @@ static struct resource usb_resources[] = {  	{  		.start          = IRQ_USBINT,  		.flags          = IORESOURCE_IRQ, +		.name		= "mc"  	},  	{  		/* placeholder for the dedicated CPPI IRQ */  		.flags          = IORESOURCE_IRQ, +		.name		= "dma"  	},  };  static u64 usb_dmamask = DMA_BIT_MASK(32);  static struct platform_device usb_dev = { -	.name           = "musb_hdrc", +	.name           = "musb-davinci",  	.id             = -1,  	.dev = {  		.platform_data		= &usb_data, @@ -110,6 +107,7 @@ static struct resource da8xx_usb20_resources[] = {  	{  		.start		= IRQ_DA8XX_USB_INT,  		.flags		= IORESOURCE_IRQ, +		.name		= "mc",  	},  }; @@ -121,6 +119,7 @@ int __init da8xx_register_usb20(unsigned mA, unsigned potpgt)  	usb_dev.resource = da8xx_usb20_resources;  	usb_dev.num_resources = ARRAY_SIZE(da8xx_usb20_resources); +	usb_dev.name = "musb-da8xx";  	return platform_device_register(&usb_dev);  }  | 
