From e5d9f10ca328b63135e021e9d61bdcf15f61a83a Mon Sep 17 00:00:00 2001 From: =?utf8?q?=E5=BC=A0=E6=99=B4?= Date: Wed, 8 Aug 2012 17:01:21 +0800 Subject: [PATCH] rk30:phonepad:support i2c transmission in sram --- arch/arm/mach-rk30/Makefile | 1 + arch/arm/mach-rk30/i2c_sram.c | 344 +++++++++++++++++++++++++++ arch/arm/mach-rk30/include/mach/io.h | 1 + arch/arm/mach-rk30/io.c | 2 + arch/arm/mach-rk30/pm.c | 15 +- arch/arm/plat-rk/Kconfig | 4 + 6 files changed, 364 insertions(+), 3 deletions(-) create mode 100755 arch/arm/mach-rk30/i2c_sram.c mode change 100644 => 100755 arch/arm/mach-rk30/include/mach/io.h mode change 100644 => 100755 arch/arm/mach-rk30/io.c mode change 100644 => 100755 arch/arm/mach-rk30/pm.c diff --git a/arch/arm/mach-rk30/Makefile b/arch/arm/mach-rk30/Makefile index 3871da30b5f3..2167eef284c7 100755 --- a/arch/arm/mach-rk30/Makefile +++ b/arch/arm/mach-rk30/Makefile @@ -19,6 +19,7 @@ obj-$(CONFIG_CPU_IDLE) += cpuidle.o obj-$(CONFIG_CPU_FREQ) += cpufreq.o obj-$(CONFIG_DVFS) += dvfs.o obj-$(CONFIG_DDR_FREQ) += ddr_freq.o +obj-$(CONFIG_RK30_I2C_INSRAM) += i2c_sram.o obj-$(CONFIG_MACH_RK3066_SDK) += board-rk30-sdk.o board-rk30-sdk-key.o obj-$(CONFIG_MACH_RK30_SDK) += board-rk30-sdk.o board-rk30-sdk-key.o diff --git a/arch/arm/mach-rk30/i2c_sram.c b/arch/arm/mach-rk30/i2c_sram.c new file mode 100755 index 000000000000..03fc85e150b1 --- /dev/null +++ b/arch/arm/mach-rk30/i2c_sram.c @@ -0,0 +1,344 @@ +#include +#include +#include +#include +#include +#include +#include + +#define cru_readl(offset) readl_relaxed(RK30_CRU_BASE + offset) +#define cru_writel(v, offset) do { writel_relaxed(v, RK30_CRU_BASE + offset); dsb(); } while (0) + +#if defined(CONFIG_RK30_I2C_INSRAM) + +/******************need set when you use i2c*************************/ +#define I2C_SPEED 100 +#define I2C_SADDR (0x2D) /* slave address ,wm8310 addr is 0x34*/ +#define SRAM_I2C_CH 1 //CH==0, i2c0,CH==1, i2c1,CH==2, i2c2,CH==3, i2c3 +#define SRAM_I2C_ADDRBASE (RK30_I2C1_BASE + SZ_4K )//RK29_I2C0_BASE\RK29_I2C2_BASE\RK29_I2C3_BASE +#define I2C_SLAVE_ADDR_LEN 1 // 2:slav addr is 10bit ,1:slav addr is 7bit +#define I2C_SLAVE_REG_LEN 1 // 2:slav reg addr is 16 bit ,1:is 8 bit +#define SRAM_I2C_DATA_BYTE 1 //i2c transmission data is 1bit(8wei) or 2bit(16wei) +#define GRF_GPIO_IOMUX 0xd4 //GRF_GPIO2D_IOMUX +/*ch=0:GRF_GPIO2L_IOMUX,ch=1:GRF_GPIO1L_IOMUX,ch=2:GRF_GPIO5H_IOMUX,ch=3:GRF_GPIO2L_IOMUX*/ +#define I2C_GRF_GPIO_IOMUX (0x01<<14)|(0x01<<12) +/*CH=0:(~(0x03<<30))&(~(0x03<<28))|(0x01<<30)|(0x01<<28),CH=1:(~(0x03<<14))&(~(0x03<<12))|(0x01<<14)|(0x01<<12), +CH=2:(~(0x03<<24))&(~(0x03<<22))|(0x01<<24)|(0x01<<22),CH=3:(~(0x03<<26))&(~(0x03<<24))|(0x02<<26)|(0x02<<24)*/ +/***************************************/ + +#define I2C_SLAVE_TYPE (((I2C_SLAVE_ADDR_LEN-1)<<4)|((I2C_SLAVE_REG_LEN-1))) + +#define uint8 unsigned char +#define uint16 unsigned short +#define uint32 unsigned int +uint32 __sramdata data[5]; + +#define CRU_CLKGATE0_CON 0xd0 +#define CRU_CLKGATE8_CON 0xf0 +#define CRU_CLKSEL1_CON 0x48 +#define GRF_GPIO5H_IOMUX 0x74 +#define GRF_GPIO2L_IOMUX 0x58 +#define GRF_GPIO1L_IOMUX 0x50 + +#define COMPLETE_READ (1<