From 23608e4c25923b9ebb2b4ba163ff2bafd2446568 Mon Sep 17 00:00:00 2001 From: Lars-Peter Clausen Date: Thu, 30 Jul 2009 12:04:01 +0000 Subject: glamo: Implement gpiolib for the glamo. Get rid of glamo-spi-gpio and use the generic spi-gpio driver instead. SVN-Revision: 17048 --- .../s3c24xx/files-2.6.30/drivers/mfd/glamo/Kconfig | 17 +- .../files-2.6.30/drivers/mfd/glamo/Makefile | 4 +- .../files-2.6.30/drivers/mfd/glamo/glamo-core.c | 45 +--- .../drivers/mfd/glamo/glamo-spi-gpio.c | 278 --------------------- 4 files changed, 16 insertions(+), 328 deletions(-) delete mode 100644 target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-spi-gpio.c (limited to 'target/linux/s3c24xx/files-2.6.30/drivers') diff --git a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Kconfig b/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Kconfig index 8de1c2f..8c93bcb 100644 --- a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Kconfig +++ b/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Kconfig @@ -23,23 +23,12 @@ config MFD_GLAMO_FB If unsure, say N. -config MFD_GLAMO_FB_XGLAMO_WORKAROUND - bool "Smedia Glamo 336x/337x Xglamo rotation workaround" - depends on MFD_GLAMO_FB - help - This is a workaround for a Xglamo bug. This should be fixed - in Xglamo and not in kernel space. - - If unsure, say N. - - -config MFD_GLAMO_SPI_GPIO - tristate "Glamo GPIO SPI bitbang support" +config MFD_GLAMO_GPIO + tristate "Glamo GPIO support" depends on MFD_GLAMO - select SPI_BITBANG help - Enable a bitbanging SPI adapter driver for the Smedia Glamo. + Enable a bitbanging SPI adapter driver for the Smedia Glamo. config MFD_GLAMO_MCI tristate "Glamo S3C SD/MMC Card Interface support" diff --git a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Makefile b/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Makefile index 99a927a..ebf26f7 100644 --- a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Makefile +++ b/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/Makefile @@ -2,9 +2,9 @@ # Makefile for the Smedia Glamo framebuffer driver # -obj-$(CONFIG_MFD_GLAMO) += glamo-core.o glamo-gpio.o +obj-$(CONFIG_MFD_GLAMO) += glamo-core.o +obj-$(CONFIG_MFD_GLAMO_GPIO) += glamo-gpio.o obj-$(CONFIG_MFD_GLAMO_SPI) += glamo-spi.o -obj-$(CONFIG_MFD_GLAMO_SPI_GPIO) += glamo-spi-gpio.o obj-$(CONFIG_MFD_GLAMO_FB) += glamo-fb.o obj-$(CONFIG_MFD_GLAMO_MCI) += glamo-mci.o diff --git a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-core.c b/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-core.c index 0c6fc58..077a7a8 100644 --- a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-core.c +++ b/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-core.c @@ -89,9 +89,9 @@ struct reg_range reg_range[] = { /* { 0x1500, 0x080, "MPU 0", 0 }, { 0x1580, 0x080, "MPU 1", 0 }, { 0x1600, 0x080, "Cmd Queue", 0 }, - { 0x1680, 0x080, "RISC CPU", 0 }, + { 0x1680, 0x080, "RISC CPU", 0 },*/ { 0x1700, 0x400, "2D Unit", 0 }, - { 0x1b00, 0x900, "3D Unit", 0 }, */ +/* { 0x1b00, 0x900, "3D Unit", 0 }, */ }; static inline void __reg_write(struct glamo_core *glamo, @@ -179,7 +179,7 @@ static struct resource glamo_mmc_resources[] = { enum glamo_cells { GLAMO_CELL_FB, GLAMO_CELL_MMC, - GLAMO_CELL_SPI_GPIO + GLAMO_CELL_GPIO, }; static struct mfd_cell glamo_cells[] = { @@ -193,8 +193,8 @@ static struct mfd_cell glamo_cells[] = { .num_resources = ARRAY_SIZE(glamo_mmc_resources), .resources = glamo_mmc_resources, }, - [GLAMO_CELL_SPI_GPIO] = { - .name = "glamo-spi-gpio", + [GLAMO_CELL_GPIO] = { + .name = "glamo-gpio", }, }; @@ -381,7 +381,8 @@ int __glamo_engine_enable(struct glamo_core *glamo, enum glamo_engine engine) GLAMO_CLOCK_MMC_EN_M9CLK | GLAMO_CLOCK_MMC_EN_TCLK | GLAMO_CLOCK_MMC_DG_M9CLK | - GLAMO_CLOCK_MMC_DG_TCLK, 0xffff); + GLAMO_CLOCK_MMC_DG_TCLK, + 0xffff); /* enable the TCLK divider clk input */ __reg_set_bit_mask(glamo, GLAMO_REG_CLOCK_GEN5_1, GLAMO_CLOCK_GEN51_EN_DIV_TCLK, @@ -604,8 +605,8 @@ static const struct glamo_script reset_regs[] = { void glamo_engine_reset(struct glamo_core *glamo, enum glamo_engine engine) { - uint16_t reg = reset_regs[engine].reg; - uint16_t val = reset_regs[engine].val; + uint16_t reg = reset_regs[engine].reg; + uint16_t val = reset_regs[engine].val; if (engine >= ARRAY_SIZE(reset_regs)) { dev_warn(&glamo->pdev->dev, "unknown engine %u ", engine); @@ -620,17 +621,6 @@ void glamo_engine_reset(struct glamo_core *glamo, enum glamo_engine engine) } EXPORT_SYMBOL_GPL(glamo_engine_reset); -void glamo_lcm_reset(struct platform_device *pdev, int level) -{ - struct glamo_core *glamo = dev_get_drvdata(&pdev->dev); - if (!glamo) - return; - - glamo_gpio_setpin(glamo, GLAMO_GPIO4, level); - glamo_gpio_cfgpin(glamo, GLAMO_GPIO4_OUTPUT); -} -EXPORT_SYMBOL_GPL(glamo_lcm_reset); - int glamo_pll_rate(struct glamo_core *glamo, enum glamo_pll pll) { @@ -707,10 +697,9 @@ int glamo_run_script(struct glamo_core *glamo, const struct glamo_script *script int len, int may_sleep) { int i; + const struct glamo_script *line = script; - for (i = 0; i < len; i++) { - struct glamo_script *line = &script[i]; - + for (i = 0; i < len; ++i, ++line) { switch (line->reg) { case 0xffff: return 0; @@ -859,11 +848,6 @@ static const struct glamo_script glamo_init_script[] = { { GLAMO_REG_MEM_DRAM1, 0xe100 }, { GLAMO_REG_MEM_DRAM2, 0x01d6 }, { GLAMO_REG_CLOCK_MEMORY, 0x000b }, - { GLAMO_REG_GPIO_GEN1, 0x000f }, - { GLAMO_REG_GPIO_GEN2, 0x111e }, - { GLAMO_REG_GPIO_GEN3, 0xccc3 }, - { GLAMO_REG_GPIO_GEN4, 0x111e }, - { GLAMO_REG_GPIO_GEN5, 0x000f }, }; #if 0 static struct glamo_script glamo_resume_script[] = { @@ -1214,12 +1198,6 @@ static int __init glamo_probe(struct platform_device *pdev) glamo_cells[GLAMO_CELL_FB].platform_data = glamo->pdata->fb_data; glamo_cells[GLAMO_CELL_FB].data_size = sizeof(struct glamo_fb_platform_data); - glamo->pdata->spigpio_data->core = glamo; - glamo_cells[GLAMO_CELL_SPI_GPIO].platform_data = - glamo->pdata->spigpio_data; - glamo_cells[GLAMO_CELL_SPI_GPIO].data_size = - sizeof(struct glamo_spigpio_platform_data); - mfd_add_devices(&pdev->dev, pdev->id, glamo_cells, ARRAY_SIZE(glamo_cells), glamo->mem, 0); @@ -1293,7 +1271,6 @@ static int glamo_resume(struct device *dev) struct glamo_core *glamo = dev_get_drvdata(dev); glamo_power(glamo, GLAMO_POWER_ON); glamo->suspending = 0; - return 0; } diff --git a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-spi-gpio.c b/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-spi-gpio.c deleted file mode 100644 index 6316b85..0000000 --- a/target/linux/s3c24xx/files-2.6.30/drivers/mfd/glamo/glamo-spi-gpio.c +++ /dev/null @@ -1,278 +0,0 @@ -/* - * Copyright (C) 2007 Openmoko, Inc. - * Author: Harald Welte - * - * Smedia Glamo GPIO based SPI driver - * - * 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. - * - * This driver currently only implements a minimum subset of the hardware - * features, esp. those features that are required to drive the jbt6k74 - * LCM controller asic in the TD028TTEC1 LCM. - * -*/ - -#define DEBUG - -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#include - -#include - -#include "glamo-core.h" -#include "glamo-regs.h" - -struct glamo_spigpio { - struct spi_bitbang bitbang; - struct spi_master *master; - struct glamo_spigpio_platform_data *info; -}; - -static inline struct glamo_spigpio *to_sg(struct spi_device *spi) -{ - return dev_get_drvdata(&spi->master->dev); -} - -static inline void setsck(struct spi_device *dev, int on) -{ - struct glamo_spigpio *sg = to_sg(dev); - glamo_gpio_setpin(sg->info->core, sg->info->pin_clk, on ? 1 : 0); -} - -static inline void setmosi(struct spi_device *dev, int on) -{ - struct glamo_spigpio *sg = to_sg(dev); - glamo_gpio_setpin(sg->info->core, sg->info->pin_mosi, on ? 1 : 0); -} - -static inline u32 getmiso(struct spi_device *dev) -{ - struct glamo_spigpio *sg = to_sg(dev); - if (sg->info->pin_miso) - return glamo_gpio_getpin(sg->info->core, sg->info->pin_miso) ? 1 : 0; - else - return 0; -} - -#define spidelay(x) ndelay(x) - -#define EXPAND_BITBANG_TXRX -#include - -static u32 glamo_spigpio_txrx_mode0(struct spi_device *spi, - unsigned nsecs, u32 word, u8 bits) -{ - return bitbang_txrx_be_cpha0(spi, nsecs, 0, word, bits); -} - -static u32 glamo_spigpio_txrx_mode1(struct spi_device *spi, - unsigned nsecs, u32 word, u8 bits) -{ - return bitbang_txrx_be_cpha1(spi, nsecs, 0, word, bits); -} - -static u32 glamo_spigpio_txrx_mode2(struct spi_device *spi, - unsigned nsecs, u32 word, u8 bits) -{ - return bitbang_txrx_be_cpha0(spi, nsecs, 1, word, bits); -} - -static u32 glamo_spigpio_txrx_mode3(struct spi_device *spi, - unsigned nsecs, u32 word, u8 bits) -{ - return bitbang_txrx_be_cpha1(spi, nsecs, 1, word, bits); -} - - -#if 0 -static int glamo_spigpio_setupxfer(struct spi_device *spi, - struct spi_transfer *t) -{ - struct glamo_spi *gs = to_sg(spi); - unsigned int bpw; - - bpw = t ? t->bits_per_word : spi->bits_per_word; - - if (bpw != 9 && bpw != 8) { - dev_err(&spi->dev, "invalid bits-per-word (%d)\n", bpw); - return -EINVAL; - } - - return 0; -} -#endif - -static void glamo_spigpio_chipsel(struct spi_device *spi, int value) -{ - struct glamo_spigpio *gs = to_sg(spi); -#if 0 - dev_dbg(&spi->dev, "chipsel %d: spi=%p, gs=%p, info=%p, handle=%p\n", - value, spi, gs, gs->info, gs->info->glamo); -#endif - glamo_gpio_setpin(gs->info->core, gs->info->pin_cs, value ? 0 : 1); -} - - -static int glamo_spigpio_probe(struct platform_device *pdev) -{ - struct spi_master *master; - struct glamo_spigpio *sp; - int ret; - - master = spi_alloc_master(&pdev->dev, sizeof(struct glamo_spigpio)); - if (master == NULL) { - dev_err(&pdev->dev, "failed to allocate spi master\n"); - ret = -ENOMEM; - goto err; - } - - sp = spi_master_get_devdata(master); - platform_set_drvdata(pdev, sp); - sp->info = pdev->dev.platform_data; - if (!sp->info) { - dev_err(&pdev->dev, "can't operate without platform data\n"); - ret = -EIO; - goto err_no_pdev; - } - - master->num_chipselect = 1; - master->bus_num = 2; /* FIXME: use dynamic number */ - - sp->master = spi_master_get(master); - - sp->bitbang.master = sp->master; - sp->bitbang.chipselect = glamo_spigpio_chipsel; - sp->bitbang.txrx_word[SPI_MODE_0] = glamo_spigpio_txrx_mode0; - sp->bitbang.txrx_word[SPI_MODE_1] = glamo_spigpio_txrx_mode1; - sp->bitbang.txrx_word[SPI_MODE_2] = glamo_spigpio_txrx_mode2; - sp->bitbang.txrx_word[SPI_MODE_3] = glamo_spigpio_txrx_mode3; - - /* set state of spi pins */ - glamo_gpio_setpin(sp->info->core, sp->info->pin_clk, 0); - glamo_gpio_setpin(sp->info->core, sp->info->pin_mosi, 0); - glamo_gpio_setpin(sp->info->core, sp->info->pin_cs, 1); - - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_clk); - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_mosi); - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_cs); - if (sp->info->pin_miso) - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_miso); - - /* bring the LCM panel out of reset if it isn't already */ - - glamo_gpio_setpin(sp->info->core, GLAMO_GPIO4, 1); - glamo_gpio_cfgpin(sp->info->core, GLAMO_GPIO4_OUTPUT); - msleep(90); - -#if 0 - sp->dev = &pdev->dev; - - sp->bitbang.setup_transfer = glamo_spi_setupxfer; - sp->bitbang.txrx_bufs = glamo_spi_txrx; - sp->bitbang.master->setup = glamo_spi_setup; -#endif - - dev_set_drvdata(&sp->master->dev, sp); - - ret = spi_bitbang_start(&sp->bitbang); - if (ret) - goto err_no_bitbang; - - return 0; - -err_no_bitbang: - platform_set_drvdata(pdev, NULL); -err_no_pdev: - spi_master_put(sp->bitbang.master); -err: - return ret; - -} - -static int glamo_spigpio_remove(struct platform_device *pdev) -{ - struct glamo_spigpio *sp = platform_get_drvdata(pdev); - - spi_bitbang_stop(&sp->bitbang); - spi_master_put(sp->bitbang.master); - - return 0; -} - - -#ifdef CONFIG_PM -/*static int glamo_spigpio_suspend(struct device *dev) -{ - return 0; -}*/ - -static int glamo_spigpio_resume(struct device *dev) -{ - struct glamo_spigpio *sp = dev_get_drvdata(dev); - - if (!sp) - return 0; - - /* set state of spi pins */ - glamo_gpio_setpin(sp->info->core, sp->info->pin_clk, 0); - glamo_gpio_setpin(sp->info->core, sp->info->pin_mosi, 0); - glamo_gpio_setpin(sp->info->core, sp->info->pin_cs, 1); - - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_clk); - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_mosi); - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_cs); - if (sp->info->pin_miso) - glamo_gpio_cfgpin(sp->info->core, sp->info->pin_miso); - - return 0; -} - -static struct dev_pm_ops glamo_spigpio_pm_ops = { -/* .suspend = glamo_spiogpio_suspend,*/ - .resume_noirq = glamo_spigpio_resume, -}; - -#define GLAMO_SPIGPIO_PM_OPS (&glamo_spigpio_pm_ops) - -#else -#define GLAMO_SPIGPIO_PM_OPS NULL -#endif - -static struct platform_driver glamo_spi_drv = { - .probe = glamo_spigpio_probe, - .remove = glamo_spigpio_remove, - .driver = { - .name = "glamo-spi-gpio", - .owner = THIS_MODULE, - .pm = GLAMO_SPIGPIO_PM_OPS, - }, -}; - -static int __init glamo_spi_init(void) -{ - return platform_driver_register(&glamo_spi_drv); -} - -static void __exit glamo_spi_exit(void) -{ - platform_driver_unregister(&glamo_spi_drv); -} - -module_init(glamo_spi_init); -module_exit(glamo_spi_exit); - -MODULE_DESCRIPTION("Smedia Glamo 336x/337x LCM serial command SPI Driver"); -MODULE_AUTHOR("Harald Welte ") -MODULE_LICENSE("GPL"); -- cgit v1.1