mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-09 20:32:04 +09:00
touchscreen && spi
This commit is contained in:
@@ -760,37 +760,60 @@ struct rk2818_i2s_platform_data rk2818_i2s_platdata = {
|
||||
* author: lhhrock-chips.com
|
||||
*****************************************************************************************/
|
||||
#define SPI_CHIPSELECT_NUM 2
|
||||
static int spi_io_init(void)
|
||||
{
|
||||
//cs0
|
||||
rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME, IOMUXA_GPIO0_B4);
|
||||
//cs1
|
||||
rk2818_mux_api_set(GPIOB0_SPI0CSN1_MMC1PCA_NAME, IOMUXA_GPIO0_B0);
|
||||
//clk
|
||||
rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME, IOMUXA_SPI0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int spi_io_deinit(void)
|
||||
{
|
||||
rk2818_mux_api_mode_resume(GPIOB4_SPI0CS0_MMC0D4_NAME);
|
||||
rk2818_mux_api_mode_resume(GPIOB0_SPI0CSN1_MMC1PCA_NAME);
|
||||
rk2818_mux_api_mode_resume(GPIOB_SPI0_MMC0_NAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spi_cs_gpio rk2818_spi_cs_gpios[SPI_CHIPSELECT_NUM] = {
|
||||
{
|
||||
.name = "spi cs0",
|
||||
.cs_gpio = RK2818_PIN_PB4,
|
||||
.cs_iomux_name = GPIOB4_SPI0CS0_MMC0D4_NAME,//if no iomux,set it NULL
|
||||
.cs_iomux_mode = IOMUXA_GPIO0_B4,
|
||||
},
|
||||
{
|
||||
.name = "spi cs1",
|
||||
.cs_gpio = RK2818_PIN_PB0,
|
||||
.cs_iomux_name = GPIOB0_SPI0CSN1_MMC1PCA_NAME,
|
||||
.cs_iomux_mode = IOMUXA_GPIO0_B0,
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
{
|
||||
int i,j,ret;
|
||||
//clk
|
||||
rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME, IOMUXA_SPI0);
|
||||
//cs
|
||||
if (cs_gpios) {
|
||||
for (i=0; i<cs_num; i++) {
|
||||
rk2818_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
|
||||
ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
|
||||
if (ret) {
|
||||
for (j=0;j<i;j++) {
|
||||
gpio_free(cs_gpios[j].cs_gpio);
|
||||
rk2818_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
|
||||
}
|
||||
printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
{
|
||||
int i;
|
||||
rk2818_mux_api_mode_resume(GPIOB_SPI0_MMC0_NAME);
|
||||
|
||||
if (cs_gpios) {
|
||||
for (i=0; i<cs_num; i++) {
|
||||
gpio_free(cs_gpios[i].cs_gpio);
|
||||
rk2818_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct rk2818_spi_platform_data rk2818_spi_platdata = {
|
||||
.num_chipselect = SPI_CHIPSELECT_NUM,//raho <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ֧<D2AA><D6A7>3<EFBFBD><33>Ƭѡ dxj
|
||||
.chipselect_gpios = rk2818_spi_cs_gpios,
|
||||
@@ -1207,7 +1230,7 @@ void lcd_set_iomux(u8 enable)
|
||||
ret = gpio_request(RK2818_PIN_PH6, NULL);
|
||||
if(0)//(ret != 0)
|
||||
{
|
||||
gpio_free(RK2818_PIN_PA4);
|
||||
gpio_free(RK2818_PIN_PH6);
|
||||
printk(">>>>>> lcd cs gpio_request err \n ");
|
||||
goto pin_err;
|
||||
}
|
||||
@@ -1232,13 +1255,11 @@ void lcd_set_iomux(u8 enable)
|
||||
}
|
||||
else
|
||||
{
|
||||
//gpio_free(RK2818_PIN_PA4);
|
||||
//rk2818_mux_api_set(CXGPIO_HSADC_SEL_NAME, 1);
|
||||
// rk2818_mux_api_mode_resume(CXGPIO_HSADC_SEL_NAME);
|
||||
gpio_free(RK2818_PIN_PH6);
|
||||
rk2818_mux_api_mode_resume(GPIOH6_IQ_SEL_NAME);
|
||||
|
||||
gpio_free(RK2818_PIN_PE7);
|
||||
gpio_free(RK2818_PIN_PE6);
|
||||
//rk2818_mux_api_set(GPIOE_U1IR_I2C1_NAME, 2);
|
||||
rk2818_mux_api_mode_resume(GPIOE_U1IR_I2C1_NAME);
|
||||
}
|
||||
return ;
|
||||
|
||||
@@ -960,43 +960,65 @@ struct rk2818_i2s_platform_data rk2818_i2s_platdata = {
|
||||
* author: lhhrock-chips.com
|
||||
*****************************************************************************************/
|
||||
#define SPI_CHIPSELECT_NUM 3
|
||||
static int spi_io_init(void)
|
||||
{
|
||||
//cs0
|
||||
rk2818_mux_api_set(GPIOB4_SPI0CS0_MMC0D4_NAME, IOMUXA_GPIO0_B4);
|
||||
//cs1
|
||||
rk2818_mux_api_set(GPIOB0_SPI0CSN1_MMC1PCA_NAME, IOMUXA_GPIO0_B0);
|
||||
//clk
|
||||
rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME, IOMUXA_SPI0);
|
||||
//cs2
|
||||
rk2818_mux_api_set(GPIOF5_APWM3_DPWM3_NAME,IOMUXB_GPIO1_B5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
static int spi_io_deinit(void)
|
||||
{
|
||||
rk2818_mux_api_mode_resume(GPIOB4_SPI0CS0_MMC0D4_NAME);
|
||||
rk2818_mux_api_mode_resume(GPIOB0_SPI0CSN1_MMC1PCA_NAME);
|
||||
rk2818_mux_api_mode_resume(GPIOB_SPI0_MMC0_NAME);
|
||||
rk2818_mux_api_mode_resume(GPIOF5_APWM3_DPWM3_NAME);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct spi_cs_gpio rk2818_spi_cs_gpios[SPI_CHIPSELECT_NUM] = {
|
||||
{
|
||||
.name = "spi cs0",
|
||||
.cs_gpio = RK2818_PIN_PB4,
|
||||
.cs_iomux_name = GPIOB4_SPI0CS0_MMC0D4_NAME,//if no iomux,set it NULL
|
||||
.cs_iomux_mode = IOMUXA_GPIO0_B4,
|
||||
},
|
||||
{
|
||||
.name = "spi cs1",
|
||||
.cs_gpio = RK2818_PIN_PB0,
|
||||
.cs_iomux_name = GPIOB0_SPI0CSN1_MMC1PCA_NAME,
|
||||
.cs_iomux_mode = IOMUXA_GPIO0_B0,
|
||||
},
|
||||
{
|
||||
.name = "spi cs2",
|
||||
.cs_gpio = RK2818_PIN_PF5,
|
||||
.cs_iomux_name = GPIOF5_APWM3_DPWM3_NAME,
|
||||
.cs_iomux_mode = IOMUXB_GPIO1_B5,
|
||||
}
|
||||
};
|
||||
|
||||
static int spi_io_init(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
{
|
||||
int i,j,ret;
|
||||
//clk
|
||||
rk2818_mux_api_set(GPIOB_SPI0_MMC0_NAME, IOMUXA_SPI0);
|
||||
//cs
|
||||
if (cs_gpios) {
|
||||
for (i=0; i<cs_num; i++) {
|
||||
rk2818_mux_api_set(cs_gpios[i].cs_iomux_name, cs_gpios[i].cs_iomux_mode);
|
||||
ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
|
||||
if (ret) {
|
||||
for (j=0;j<i;j++) {
|
||||
gpio_free(cs_gpios[j].cs_gpio);
|
||||
rk2818_mux_api_mode_resume(cs_gpios[j].cs_iomux_name);
|
||||
}
|
||||
printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int spi_io_deinit(struct spi_cs_gpio *cs_gpios, int cs_num)
|
||||
{
|
||||
int i;
|
||||
rk2818_mux_api_mode_resume(GPIOB_SPI0_MMC0_NAME);
|
||||
|
||||
if (cs_gpios) {
|
||||
for (i=0; i<cs_num; i++) {
|
||||
gpio_free(cs_gpios[i].cs_gpio);
|
||||
rk2818_mux_api_mode_resume(cs_gpios[i].cs_iomux_name);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct rk2818_spi_platform_data rk2818_spi_platdata = {
|
||||
.num_chipselect = SPI_CHIPSELECT_NUM,//raho <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ֧<D2AA><D6A7>3<EFBFBD><33>Ƭѡ dxj
|
||||
.chipselect_gpios = rk2818_spi_cs_gpios,
|
||||
|
||||
@@ -177,11 +177,13 @@ struct rk2818_i2s_platform_data {
|
||||
struct spi_cs_gpio {
|
||||
const char *name;
|
||||
unsigned int cs_gpio;
|
||||
char *cs_iomux_name;
|
||||
unsigned int cs_iomux_mode;
|
||||
};
|
||||
|
||||
struct rk2818_spi_platform_data {
|
||||
int (*io_init)(void);
|
||||
int (*io_deinit)(void);
|
||||
int (*io_init)(struct spi_cs_gpio*, int);
|
||||
int (*io_deinit)(struct spi_cs_gpio*, int);
|
||||
struct spi_cs_gpio *chipselect_gpios;
|
||||
u16 num_chipselect;
|
||||
};
|
||||
|
||||
13
drivers/input/gsensor/mma7660.c
Normal file → Executable file
13
drivers/input/gsensor/mma7660.c
Normal file → Executable file
@@ -40,8 +40,6 @@
|
||||
#endif
|
||||
static int mma7660_probe(struct i2c_client *client, const struct i2c_device_id *id);
|
||||
|
||||
|
||||
#define MMA7660_GPIO_INT RK2818_PIN_PE0
|
||||
#define MMA7660_SPEED 200 * 1000
|
||||
|
||||
/* Addresses to scan -- protected by sense_data_mutex */
|
||||
@@ -346,9 +344,7 @@ static void mma7660_work_func(struct work_struct *work)
|
||||
if (mma7660_get_data() < 0)
|
||||
rk28printk(KERN_ERR "MMA7660 mma_work_func: Get data failed\n");
|
||||
|
||||
enable_irq(this_client->irq);
|
||||
//GPIOClrearInmarkIntr(MMA7660_GPIO_INT);
|
||||
|
||||
enable_irq(this_client->irq);
|
||||
rk28printk("---------------------------------------mma7660_work_func----------------------------------\n");
|
||||
}
|
||||
|
||||
@@ -357,9 +353,7 @@ static void mma7660_delaywork_func(struct work_struct *work)
|
||||
|
||||
if (mma7660_get_data() < 0)
|
||||
rk28printk(KERN_ERR "MMA7660 mma_work_func: Get data failed\n");
|
||||
enable_irq(this_client->irq);
|
||||
//GPIOClrearInmarkIntr(MMA7660_GPIO_INT);
|
||||
|
||||
enable_irq(this_client->irq);
|
||||
rk28printk("---------------------------------------mma7660_delaywork_func------------------------------\n");
|
||||
|
||||
}
|
||||
@@ -367,9 +361,6 @@ static void mma7660_delaywork_func(struct work_struct *work)
|
||||
static irqreturn_t mma7660_interrupt(int irq, void *dev_id)
|
||||
{
|
||||
struct mma7660_data *data = dev_id;
|
||||
|
||||
///GPIOInmarkIntr(MMA7660_GPIO_INT);
|
||||
//schedule_work(&data->work);
|
||||
disable_irq_nosync(this_client->irq);
|
||||
schedule_delayed_work(&data->delaywork,msecs_to_jiffies(30));
|
||||
rk28printk("--------------------------------------mma7660_interrupt---------------------------------------\n");
|
||||
|
||||
@@ -201,25 +201,6 @@ struct dfr_req {
|
||||
struct spi_transfer xfer[4];
|
||||
};
|
||||
|
||||
static struct xpt2046_platform_data xpt2046_info = {
|
||||
.model = 2046,
|
||||
.keep_vref_on = 1,
|
||||
.swap_xy = 1,
|
||||
.x_min = 0,
|
||||
.x_max = 800,
|
||||
.y_min = 0,
|
||||
.y_max = 480,
|
||||
.debounce_max = 7,
|
||||
.debounce_rep = DEBOUNCE_REPTIME,
|
||||
.debounce_tol = 20,
|
||||
#if defined(CONFIG_MACH_RAHO)
|
||||
.gpio_pendown = RK2818_PIN_PE1,
|
||||
#else
|
||||
.gpio_pendown = RK2818_PIN_PE3,
|
||||
#endif
|
||||
.penirq_recheck_delay_usecs = 1,
|
||||
|
||||
};
|
||||
static void xpt2046_enable(struct xpt2046 *ts);
|
||||
static void xpt2046_disable(struct xpt2046 *ts);
|
||||
|
||||
@@ -698,14 +679,7 @@ static int __devinit xpt2046_probe(struct spi_device *spi)
|
||||
spi->irq = gpio_to_irq(spi->irq);
|
||||
dev_dbg(&spi->dev, "no IRQ?\n");
|
||||
}
|
||||
|
||||
/*
|
||||
if (!pdata) {
|
||||
spi->dev.platform_data = &xpt2046_info;
|
||||
pdata = spi->dev.platform_data;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
if (!pdata) {
|
||||
dev_err(&spi->dev, "empty platform_data\n");
|
||||
return -EFAULT;
|
||||
|
||||
@@ -342,7 +342,8 @@ static void null_wait_for_sync(void)
|
||||
|
||||
static void xpt2046_rx(void *xpt)
|
||||
{
|
||||
struct xpt2046 *ts = xpt;
|
||||
struct xpt2046 *ts = xpt;
|
||||
struct xpt2046_platform_data *pdata = ts->spi->dev.platform_data;
|
||||
struct xpt2046_packet *packet = ts->packet;
|
||||
unsigned Rt = 1;
|
||||
u16 x, y;
|
||||
@@ -421,7 +422,7 @@ static void xpt2046_rx(void *xpt)
|
||||
}
|
||||
|
||||
}
|
||||
else if (y <= xpt2046_info.y_max)
|
||||
else if (y <= pdata->y_max)
|
||||
{
|
||||
if (!ts->pendown) {
|
||||
input_report_key(input, BTN_TOUCH, 1);
|
||||
@@ -768,14 +769,6 @@ static int __devinit xpt2046_probe(struct spi_device *spi)
|
||||
spi->irq = gpio_to_irq(spi->irq);
|
||||
dev_dbg(&spi->dev, "no IRQ?\n");
|
||||
}
|
||||
|
||||
/*
|
||||
if (!pdata) {
|
||||
xpt2046printk("-----------------pdata is null -------------------------\n");
|
||||
spi->dev.platform_data = &xpt2046_info;
|
||||
pdata = spi->dev.platform_data;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!pdata) {
|
||||
dev_err(&spi->dev, "empty platform_data\n");
|
||||
|
||||
@@ -928,25 +928,13 @@ static int __init rk2818_spim_probe(struct platform_device *pdev)
|
||||
int irq;
|
||||
int ret,i,j;
|
||||
struct rk2818_spi_platform_data *pdata = pdev->dev.platform_data;
|
||||
struct spi_cs_gpio *cs_gpios = pdata->chipselect_gpios;
|
||||
|
||||
if (pdata && pdata->io_init) {
|
||||
pdata->io_init();
|
||||
}
|
||||
|
||||
if (cs_gpios) {
|
||||
for (i=0; i<pdata->num_chipselect; i++) {
|
||||
ret = gpio_request(cs_gpios[i].cs_gpio, cs_gpios[i].name);
|
||||
if (ret) {
|
||||
for (j=0;j<i;j++)
|
||||
gpio_free(cs_gpios[j].cs_gpio);
|
||||
printk("[fun:%s, line:%d], gpio request err\n", __func__, __LINE__);
|
||||
if (pdata->io_deinit)
|
||||
pdata->io_deinit();
|
||||
return -1;
|
||||
}
|
||||
ret = pdata->io_init(pdata->chipselect_gpios, pdata->num_chipselect);
|
||||
if (ret) {
|
||||
return -ENXIO;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
regs = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!regs)
|
||||
|
||||
Reference in New Issue
Block a user