From 71b9114d2c13a648fbe6523dd859e611c316ad90 Mon Sep 17 00:00:00 2001 From: Arnd Bergmann Date: Mon, 2 Sep 2019 17:47:55 +0200 Subject: ARM: s3c: move into a common directory s3c24xx and s3c64xx have a lot in common, but are split across three separate directories, which makes the interaction of the header files more complicated than necessary. Move all three directories into a new mach-s3c, with a minimal set of changes to each file. Signed-off-by: Arnd Bergmann [krzk: Rebase, add s3c24xx and s3c64xx suffix to several files, add SPDX headers to new files, remove plat-samsung from MAINTAINERS] Co-developed-by: Krzysztof Kozlowski Signed-off-by: Krzysztof Kozlowski https://lore.kernel.org/r/20200806182059.2431-39-krzk@kernel.org --- arch/arm/plat-samsung/Kconfig | 247 ---- arch/arm/plat-samsung/Makefile | 30 - arch/arm/plat-samsung/adc.c | 510 -------- arch/arm/plat-samsung/cpu.c | 31 - arch/arm/plat-samsung/dev-uart.c | 41 - arch/arm/plat-samsung/devs.c | 1199 ------------------ arch/arm/plat-samsung/gpio-samsung.c | 1324 -------------------- arch/arm/plat-samsung/include/plat/adc-core.h | 24 - arch/arm/plat-samsung/include/plat/cpu.h | 128 -- arch/arm/plat-samsung/include/plat/devs.h | 96 -- arch/arm/plat-samsung/include/plat/fb.h | 31 - .../plat-samsung/include/plat/gpio-cfg-helpers.h | 159 --- arch/arm/plat-samsung/include/plat/gpio-cfg.h | 178 --- arch/arm/plat-samsung/include/plat/gpio-core.h | 142 --- arch/arm/plat-samsung/include/plat/iic-core.h | 38 - arch/arm/plat-samsung/include/plat/keypad.h | 27 - arch/arm/plat-samsung/include/plat/map-base.h | 42 - arch/arm/plat-samsung/include/plat/map-s3c.h | 70 -- arch/arm/plat-samsung/include/plat/map-s5p.h | 20 - arch/arm/plat-samsung/include/plat/pm-common.h | 40 - arch/arm/plat-samsung/include/plat/pm.h | 109 -- arch/arm/plat-samsung/include/plat/pwm-core.h | 19 - arch/arm/plat-samsung/include/plat/regs-adc.h | 64 - arch/arm/plat-samsung/include/plat/regs-irqtype.h | 17 - arch/arm/plat-samsung/include/plat/sdhci.h | 162 --- arch/arm/plat-samsung/include/plat/usb-phy.h | 13 - arch/arm/plat-samsung/include/plat/wakeup-mask.h | 39 - arch/arm/plat-samsung/init.c | 173 --- arch/arm/plat-samsung/platformdata.c | 53 - arch/arm/plat-samsung/pm-common.c | 73 -- arch/arm/plat-samsung/pm-gpio.c | 380 ------ arch/arm/plat-samsung/pm.c | 199 --- arch/arm/plat-samsung/wakeup-mask.c | 42 - 33 files changed, 5720 deletions(-) delete mode 100644 arch/arm/plat-samsung/Kconfig delete mode 100644 arch/arm/plat-samsung/Makefile delete mode 100644 arch/arm/plat-samsung/adc.c delete mode 100644 arch/arm/plat-samsung/cpu.c delete mode 100644 arch/arm/plat-samsung/dev-uart.c delete mode 100644 arch/arm/plat-samsung/devs.c delete mode 100644 arch/arm/plat-samsung/gpio-samsung.c delete mode 100644 arch/arm/plat-samsung/include/plat/adc-core.h delete mode 100644 arch/arm/plat-samsung/include/plat/cpu.h delete mode 100644 arch/arm/plat-samsung/include/plat/devs.h delete mode 100644 arch/arm/plat-samsung/include/plat/fb.h delete mode 100644 arch/arm/plat-samsung/include/plat/gpio-cfg-helpers.h delete mode 100644 arch/arm/plat-samsung/include/plat/gpio-cfg.h delete mode 100644 arch/arm/plat-samsung/include/plat/gpio-core.h delete mode 100644 arch/arm/plat-samsung/include/plat/iic-core.h delete mode 100644 arch/arm/plat-samsung/include/plat/keypad.h delete mode 100644 arch/arm/plat-samsung/include/plat/map-base.h delete mode 100644 arch/arm/plat-samsung/include/plat/map-s3c.h delete mode 100644 arch/arm/plat-samsung/include/plat/map-s5p.h delete mode 100644 arch/arm/plat-samsung/include/plat/pm-common.h delete mode 100644 arch/arm/plat-samsung/include/plat/pm.h delete mode 100644 arch/arm/plat-samsung/include/plat/pwm-core.h delete mode 100644 arch/arm/plat-samsung/include/plat/regs-adc.h delete mode 100644 arch/arm/plat-samsung/include/plat/regs-irqtype.h delete mode 100644 arch/arm/plat-samsung/include/plat/sdhci.h delete mode 100644 arch/arm/plat-samsung/include/plat/usb-phy.h delete mode 100644 arch/arm/plat-samsung/include/plat/wakeup-mask.h delete mode 100644 arch/arm/plat-samsung/init.c delete mode 100644 arch/arm/plat-samsung/platformdata.c delete mode 100644 arch/arm/plat-samsung/pm-common.c delete mode 100644 arch/arm/plat-samsung/pm-gpio.c delete mode 100644 arch/arm/plat-samsung/pm.c delete mode 100644 arch/arm/plat-samsung/wakeup-mask.c (limited to 'arch/arm/plat-samsung') diff --git a/arch/arm/plat-samsung/Kconfig b/arch/arm/plat-samsung/Kconfig deleted file mode 100644 index 13b39684b582..000000000000 --- a/arch/arm/plat-samsung/Kconfig +++ /dev/null @@ -1,247 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright 2009 Simtec Electronics - -config PLAT_SAMSUNG - bool - depends on PLAT_S3C24XX || ARCH_S3C64XX - default y - select GENERIC_IRQ_CHIP - select NO_IOPORT_MAP - select SOC_SAMSUNG - help - Base platform code for all Samsung SoC based systems - -config SAMSUNG_PM - bool - depends on PM && (PLAT_S3C24XX || ARCH_S3C64XX) - default y - help - Base platform power management code for samsung code - -if PLAT_SAMSUNG -menu "Samsung Common options" - -# boot configurations - -comment "Boot options" - -config S3C_LOWLEVEL_UART_PORT - int "S3C UART to use for low-level messages" - depends on ARCH_S3C64XX - default 0 - help - Choice of which UART port to use for the low-level messages, - such as the `Uncompressing...` at start time. The value of - this configuration should be between zero and two. The port - must have been initialised by the boot-loader before use. - -config SAMSUNG_ATAGS - def_bool n - depends on ATAGS - help - This option enables ATAGS based boot support code for - Samsung platforms, including static platform devices, legacy - clock, timer and interrupt initialization, etc. - - Platforms that support only DT based boot need not to select - this option. - -if SAMSUNG_ATAGS - -config S3C_GPIO_SPACE - int "Space between gpio banks" - default 0 - help - Add a number of spare GPIO entries between each bank for debugging - purposes. This allows any problems where an counter overflows from - one bank to another to be caught, at the expense of using a little - more memory. - -config S3C_GPIO_TRACK - bool - help - Internal configuration option to enable the s3c specific gpio - chip tracking if the platform requires it. - -# ADC driver - -config S3C_ADC - bool "ADC common driver support" - depends on !ARCH_MULTIPLATFORM - help - Core support for the ADC block found in the Samsung SoC systems - for drivers such as the touchscreen and hwmon to use to share - this resource. - -# device definitions to compile in - -config S3C_DEV_HSMMC - bool - help - Compile in platform device definitions for HSMMC code - -config S3C_DEV_HSMMC1 - bool - help - Compile in platform device definitions for HSMMC channel 1 - -config S3C_DEV_HSMMC2 - bool - help - Compile in platform device definitions for HSMMC channel 2 - -config S3C_DEV_HSMMC3 - bool - help - Compile in platform device definitions for HSMMC channel 3 - -config S3C_DEV_HWMON - bool - help - Compile in platform device definitions for HWMON - -config S3C_DEV_I2C1 - bool - help - Compile in platform device definitions for I2C channel 1 - -config S3C_DEV_I2C2 - bool - help - Compile in platform device definitions for I2C channel 2 - -config S3C_DEV_I2C3 - bool - help - Compile in platform device definition for I2C controller 3 - -config S3C_DEV_I2C4 - bool - help - Compile in platform device definition for I2C controller 4 - -config S3C_DEV_I2C5 - bool - help - Compile in platform device definition for I2C controller 5 - -config S3C_DEV_I2C6 - bool - help - Compile in platform device definition for I2C controller 6 - -config S3C_DEV_I2C7 - bool - help - Compile in platform device definition for I2C controller 7 - -config S3C_DEV_FB - bool - help - Compile in platform device definition for framebuffer - -config S3C_DEV_USB_HOST - bool - help - Compile in platform device definition for USB host. - -config S3C_DEV_USB_HSOTG - bool - help - Compile in platform device definition for USB high-speed OtG - -config S3C_DEV_WDT - bool - default y if ARCH_S3C24XX - help - Compile in platform device definition for Watchdog Timer - -config S3C_DEV_NAND - bool - help - Compile in platform device definition for NAND controller - -config S3C_DEV_ONENAND - bool - help - Compile in platform device definition for OneNAND controller - -config S3C_DEV_RTC - bool - help - Compile in platform device definition for RTC - -config SAMSUNG_DEV_ADC - bool - help - Compile in platform device definition for ADC controller - -config SAMSUNG_DEV_IDE - bool - help - Compile in platform device definitions for IDE - -config S3C64XX_DEV_SPI0 - bool - help - Compile in platform device definitions for S3C64XX's type - SPI controller 0 - -config S3C64XX_DEV_SPI1 - bool - help - Compile in platform device definitions for S3C64XX's type - SPI controller 1 - -config S3C64XX_DEV_SPI2 - bool - help - Compile in platform device definitions for S3C64XX's type - SPI controller 2 - -config SAMSUNG_DEV_TS - bool - help - Common in platform device definitions for touchscreen device - -config SAMSUNG_DEV_KEYPAD - bool - help - Compile in platform device definitions for keypad - -config SAMSUNG_DEV_PWM - bool - default y if ARCH_S3C24XX - help - Compile in platform device definition for PWM Timer - -config S3C24XX_PWM - bool "PWM device support" - select PWM - select PWM_SAMSUNG - help - Support for exporting the PWM timer blocks via the pwm device - system - -config GPIO_SAMSUNG - def_bool y - -config SAMSUNG_PM_GPIO - bool - default y if GPIO_SAMSUNG && PM - help - Include legacy GPIO power management code for platforms not using - pinctrl-samsung driver. -endif - -config SAMSUNG_WAKEMASK - bool - depends on PM - help - Compile support for wakeup-mask controls found on the S3C6400 - and above. This code allows a set of interrupt to wakeup-mask - mappings. See - -endmenu -endif diff --git a/arch/arm/plat-samsung/Makefile b/arch/arm/plat-samsung/Makefile deleted file mode 100644 index feddb42cae51..000000000000 --- a/arch/arm/plat-samsung/Makefile +++ /dev/null @@ -1,30 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -# -# Copyright 2009 Simtec Electronics - -ccflags-$(CONFIG_ARCH_S3C64XX) := -I$(srctree)/arch/arm/mach-s3c64xx/include -ccflags-$(CONFIG_ARCH_MULTIPLATFORM) += -I$(srctree)/$(src)/include - -# Objects we always build independent of SoC choice - -obj-y += init.o cpu.o - -# ADC - -obj-$(CONFIG_S3C_ADC) += adc.o - -# devices - -obj-$(CONFIG_SAMSUNG_ATAGS) += platformdata.o - -obj-$(CONFIG_SAMSUNG_ATAGS) += devs.o -obj-$(CONFIG_SAMSUNG_ATAGS) += dev-uart.o - -obj-$(CONFIG_GPIO_SAMSUNG) += gpio-samsung.o - -# PM support - -obj-$(CONFIG_SAMSUNG_PM) += pm.o pm-common.o -obj-$(CONFIG_SAMSUNG_PM_GPIO) += pm-gpio.o - -obj-$(CONFIG_SAMSUNG_WAKEMASK) += wakeup-mask.o diff --git a/arch/arm/plat-samsung/adc.c b/arch/arm/plat-samsung/adc.c deleted file mode 100644 index e35e04417cce..000000000000 --- a/arch/arm/plat-samsung/adc.c +++ /dev/null @@ -1,510 +0,0 @@ -// SPDX-License-Identifier: GPL-1.0+ -// -// Copyright (c) 2008 Simtec Electronics -// http://armlinux.simtec.co.uk/ -// Ben Dooks , -// -// Samsung ADC device core - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* This driver is designed to control the usage of the ADC block between - * the touchscreen and any other drivers that may need to use it, such as - * the hwmon driver. - * - * Priority will be given to the touchscreen driver, but as this itself is - * rate limited it should not starve other requests which are processed in - * order that they are received. - * - * Each user registers to get a client block which uniquely identifies it - * and stores information such as the necessary functions to callback when - * action is required. - */ - -enum s3c_cpu_type { - TYPE_ADCV1, /* S3C24XX */ - TYPE_ADCV11, /* S3C2443 */ - TYPE_ADCV12, /* S3C2416, S3C2450 */ - TYPE_ADCV2, /* S3C64XX */ - TYPE_ADCV3, /* S5PV210, S5PC110, Exynos4210 */ -}; - -struct s3c_adc_client { - struct platform_device *pdev; - struct list_head pend; - wait_queue_head_t *wait; - - unsigned int nr_samples; - int result; - unsigned char is_ts; - unsigned char channel; - - void (*select_cb)(struct s3c_adc_client *c, unsigned selected); - void (*convert_cb)(struct s3c_adc_client *c, - unsigned val1, unsigned val2, - unsigned *samples_left); -}; - -struct adc_device { - struct platform_device *pdev; - struct platform_device *owner; - struct clk *clk; - struct s3c_adc_client *cur; - struct s3c_adc_client *ts_pend; - void __iomem *regs; - spinlock_t lock; - - unsigned int prescale; - - int irq; - struct regulator *vdd; -}; - -static struct adc_device *adc_dev; - -static LIST_HEAD(adc_pending); /* protected by adc_device.lock */ - -#define adc_dbg(_adc, msg...) dev_dbg(&(_adc)->pdev->dev, msg) - -static inline void s3c_adc_convert(struct adc_device *adc) -{ - unsigned con = readl(adc->regs + S3C2410_ADCCON); - - con |= S3C2410_ADCCON_ENABLE_START; - writel(con, adc->regs + S3C2410_ADCCON); -} - -static inline void s3c_adc_select(struct adc_device *adc, - struct s3c_adc_client *client) -{ - unsigned con = readl(adc->regs + S3C2410_ADCCON); - enum s3c_cpu_type cpu = platform_get_device_id(adc->pdev)->driver_data; - - client->select_cb(client, 1); - - if (cpu == TYPE_ADCV1 || cpu == TYPE_ADCV2) - con &= ~S3C2410_ADCCON_MUXMASK; - con &= ~S3C2410_ADCCON_STDBM; - con &= ~S3C2410_ADCCON_STARTMASK; - - if (!client->is_ts) { - if (cpu == TYPE_ADCV3) - writel(client->channel & 0xf, adc->regs + S5P_ADCMUX); - else if (cpu == TYPE_ADCV11 || cpu == TYPE_ADCV12) - writel(client->channel & 0xf, - adc->regs + S3C2443_ADCMUX); - else - con |= S3C2410_ADCCON_SELMUX(client->channel); - } - - writel(con, adc->regs + S3C2410_ADCCON); -} - -static void s3c_adc_dbgshow(struct adc_device *adc) -{ - adc_dbg(adc, "CON=%08x, TSC=%08x, DLY=%08x\n", - readl(adc->regs + S3C2410_ADCCON), - readl(adc->regs + S3C2410_ADCTSC), - readl(adc->regs + S3C2410_ADCDLY)); -} - -static void s3c_adc_try(struct adc_device *adc) -{ - struct s3c_adc_client *next = adc->ts_pend; - - if (!next && !list_empty(&adc_pending)) { - next = list_first_entry(&adc_pending, - struct s3c_adc_client, pend); - list_del(&next->pend); - } else - adc->ts_pend = NULL; - - if (next) { - adc_dbg(adc, "new client is %p\n", next); - adc->cur = next; - s3c_adc_select(adc, next); - s3c_adc_convert(adc); - s3c_adc_dbgshow(adc); - } -} - -int s3c_adc_start(struct s3c_adc_client *client, - unsigned int channel, unsigned int nr_samples) -{ - struct adc_device *adc = adc_dev; - unsigned long flags; - - if (!adc) { - printk(KERN_ERR "%s: failed to find adc\n", __func__); - return -EINVAL; - } - - spin_lock_irqsave(&adc->lock, flags); - - if (client->is_ts && adc->ts_pend) { - spin_unlock_irqrestore(&adc->lock, flags); - return -EAGAIN; - } - - client->channel = channel; - client->nr_samples = nr_samples; - - if (client->is_ts) - adc->ts_pend = client; - else - list_add_tail(&client->pend, &adc_pending); - - if (!adc->cur) - s3c_adc_try(adc); - - spin_unlock_irqrestore(&adc->lock, flags); - - return 0; -} -EXPORT_SYMBOL_GPL(s3c_adc_start); - -static void s3c_convert_done(struct s3c_adc_client *client, - unsigned v, unsigned u, unsigned *left) -{ - client->result = v; - wake_up(client->wait); -} - -int s3c_adc_read(struct s3c_adc_client *client, unsigned int ch) -{ - DECLARE_WAIT_QUEUE_HEAD_ONSTACK(wake); - int ret; - - client->convert_cb = s3c_convert_done; - client->wait = &wake; - client->result = -1; - - ret = s3c_adc_start(client, ch, 1); - if (ret < 0) - goto err; - - ret = wait_event_timeout(wake, client->result >= 0, HZ / 2); - if (client->result < 0) { - ret = -ETIMEDOUT; - goto err; - } - - client->convert_cb = NULL; - return client->result; - -err: - return ret; -} -EXPORT_SYMBOL_GPL(s3c_adc_read); - -static void s3c_adc_default_select(struct s3c_adc_client *client, - unsigned select) -{ -} - -struct s3c_adc_client *s3c_adc_register(struct platform_device *pdev, - void (*select)(struct s3c_adc_client *client, - unsigned int selected), - void (*conv)(struct s3c_adc_client *client, - unsigned d0, unsigned d1, - unsigned *samples_left), - unsigned int is_ts) -{ - struct s3c_adc_client *client; - - WARN_ON(!pdev); - - if (!select) - select = s3c_adc_default_select; - - if (!pdev) - return ERR_PTR(-EINVAL); - - client = kzalloc(sizeof(*client), GFP_KERNEL); - if (!client) - return ERR_PTR(-ENOMEM); - - client->pdev = pdev; - client->is_ts = is_ts; - client->select_cb = select; - client->convert_cb = conv; - - return client; -} -EXPORT_SYMBOL_GPL(s3c_adc_register); - -void s3c_adc_release(struct s3c_adc_client *client) -{ - unsigned long flags; - - spin_lock_irqsave(&adc_dev->lock, flags); - - /* We should really check that nothing is in progress. */ - if (adc_dev->cur == client) - adc_dev->cur = NULL; - if (adc_dev->ts_pend == client) - adc_dev->ts_pend = NULL; - else { - struct list_head *p, *n; - struct s3c_adc_client *tmp; - - list_for_each_safe(p, n, &adc_pending) { - tmp = list_entry(p, struct s3c_adc_client, pend); - if (tmp == client) - list_del(&tmp->pend); - } - } - - if (adc_dev->cur == NULL) - s3c_adc_try(adc_dev); - - spin_unlock_irqrestore(&adc_dev->lock, flags); - kfree(client); -} -EXPORT_SYMBOL_GPL(s3c_adc_release); - -static irqreturn_t s3c_adc_irq(int irq, void *pw) -{ - struct adc_device *adc = pw; - struct s3c_adc_client *client = adc->cur; - enum s3c_cpu_type cpu = platform_get_device_id(adc->pdev)->driver_data; - unsigned data0, data1; - - if (!client) { - dev_warn(&adc->pdev->dev, "%s: no adc pending\n", __func__); - goto exit; - } - - data0 = readl(adc->regs + S3C2410_ADCDAT0); - data1 = readl(adc->regs + S3C2410_ADCDAT1); - adc_dbg(adc, "read %d: 0x%04x, 0x%04x\n", client->nr_samples, data0, data1); - - client->nr_samples--; - - if (cpu == TYPE_ADCV1 || cpu == TYPE_ADCV11) { - data0 &= 0x3ff; - data1 &= 0x3ff; - } else { - /* S3C2416/S3C64XX/S5P ADC resolution is 12-bit */ - data0 &= 0xfff; - data1 &= 0xfff; - } - - if (client->convert_cb) - (client->convert_cb)(client, data0, data1, &client->nr_samples); - - if (client->nr_samples > 0) { - /* fire another conversion for this */ - - client->select_cb(client, 1); - s3c_adc_convert(adc); - } else { - spin_lock(&adc->lock); - (client->select_cb)(client, 0); - adc->cur = NULL; - - s3c_adc_try(adc); - spin_unlock(&adc->lock); - } - -exit: - if (cpu == TYPE_ADCV2 || cpu == TYPE_ADCV3) { - /* Clear ADC interrupt */ - writel(0, adc->regs + S3C64XX_ADCCLRINT); - } - return IRQ_HANDLED; -} - -static int s3c_adc_probe(struct platform_device *pdev) -{ - struct device *dev = &pdev->dev; - struct adc_device *adc; - enum s3c_cpu_type cpu = platform_get_device_id(pdev)->driver_data; - int ret; - unsigned tmp; - - adc = devm_kzalloc(dev, sizeof(*adc), GFP_KERNEL); - if (!adc) - return -ENOMEM; - - spin_lock_init(&adc->lock); - - adc->pdev = pdev; - adc->prescale = S3C2410_ADCCON_PRSCVL(49); - - adc->vdd = devm_regulator_get(dev, "vdd"); - if (IS_ERR(adc->vdd)) { - dev_err(dev, "operating without regulator \"vdd\" .\n"); - return PTR_ERR(adc->vdd); - } - - adc->irq = platform_get_irq(pdev, 1); - if (adc->irq <= 0) - return -ENOENT; - - ret = devm_request_irq(dev, adc->irq, s3c_adc_irq, 0, dev_name(dev), - adc); - if (ret < 0) { - dev_err(dev, "failed to attach adc irq\n"); - return ret; - } - - adc->clk = devm_clk_get(dev, "adc"); - if (IS_ERR(adc->clk)) { - dev_err(dev, "failed to get adc clock\n"); - return PTR_ERR(adc->clk); - } - - adc->regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(adc->regs)) - return PTR_ERR(adc->regs); - - ret = regulator_enable(adc->vdd); - if (ret) - return ret; - - clk_prepare_enable(adc->clk); - - tmp = adc->prescale | S3C2410_ADCCON_PRSCEN; - - /* Enable 12-bit ADC resolution */ - if (cpu == TYPE_ADCV12) - tmp |= S3C2416_ADCCON_RESSEL; - if (cpu == TYPE_ADCV2 || cpu == TYPE_ADCV3) - tmp |= S3C64XX_ADCCON_RESSEL; - - writel(tmp, adc->regs + S3C2410_ADCCON); - - dev_info(dev, "attached adc driver\n"); - - platform_set_drvdata(pdev, adc); - adc_dev = adc; - - return 0; -} - -static int s3c_adc_remove(struct platform_device *pdev) -{ - struct adc_device *adc = platform_get_drvdata(pdev); - - clk_disable_unprepare(adc->clk); - regulator_disable(adc->vdd); - - return 0; -} - -#ifdef CONFIG_PM -static int s3c_adc_suspend(struct device *dev) -{ - struct adc_device *adc = dev_get_drvdata(dev); - unsigned long flags; - u32 con; - - spin_lock_irqsave(&adc->lock, flags); - - con = readl(adc->regs + S3C2410_ADCCON); - con |= S3C2410_ADCCON_STDBM; - writel(con, adc->regs + S3C2410_ADCCON); - - disable_irq(adc->irq); - spin_unlock_irqrestore(&adc->lock, flags); - clk_disable(adc->clk); - regulator_disable(adc->vdd); - - return 0; -} - -static int s3c_adc_resume(struct device *dev) -{ - struct platform_device *pdev = to_platform_device(dev); - struct adc_device *adc = platform_get_drvdata(pdev); - enum s3c_cpu_type cpu = platform_get_device_id(pdev)->driver_data; - int ret; - unsigned long tmp; - - ret = regulator_enable(adc->vdd); - if (ret) - return ret; - clk_enable(adc->clk); - enable_irq(adc->irq); - - tmp = adc->prescale | S3C2410_ADCCON_PRSCEN; - - /* Enable 12-bit ADC resolution */ - if (cpu == TYPE_ADCV12) - tmp |= S3C2416_ADCCON_RESSEL; - if (cpu == TYPE_ADCV2 || cpu == TYPE_ADCV3) - tmp |= S3C64XX_ADCCON_RESSEL; - - writel(tmp, adc->regs + S3C2410_ADCCON); - - return 0; -} - -#else -#define s3c_adc_suspend NULL -#define s3c_adc_resume NULL -#endif - -static const struct platform_device_id s3c_adc_driver_ids[] = { - { - .name = "s3c24xx-adc", - .driver_data = TYPE_ADCV1, - }, { - .name = "s3c2443-adc", - .driver_data = TYPE_ADCV11, - }, { - .name = "s3c2416-adc", - .driver_data = TYPE_ADCV12, - }, { - .name = "s3c64xx-adc", - .driver_data = TYPE_ADCV2, - }, { - .name = "samsung-adc-v3", - .driver_data = TYPE_ADCV3, - }, - { } -}; -MODULE_DEVICE_TABLE(platform, s3c_adc_driver_ids); - -static const struct dev_pm_ops adc_pm_ops = { - .suspend = s3c_adc_suspend, - .resume = s3c_adc_resume, -}; - -static struct platform_driver s3c_adc_driver = { - .id_table = s3c_adc_driver_ids, - .driver = { - .name = "s3c-adc", - .pm = &adc_pm_ops, - }, - .probe = s3c_adc_probe, - .remove = s3c_adc_remove, -}; - -static int __init adc_init(void) -{ - int ret; - - ret = platform_driver_register(&s3c_adc_driver); - if (ret) - printk(KERN_ERR "%s: failed to add adc driver\n", __func__); - - return ret; -} - -module_init(adc_init); diff --git a/arch/arm/plat-samsung/cpu.c b/arch/arm/plat-samsung/cpu.c deleted file mode 100644 index 8acba21bbf4b..000000000000 --- a/arch/arm/plat-samsung/cpu.c +++ /dev/null @@ -1,31 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// Copyright (c) 2009-2011 Samsung Electronics Co., Ltd. -// http://www.samsung.com -// -// Samsung CPU Support - -#include -#include -#include -#include - -#include -#include - -unsigned long samsung_cpu_id; - -void __init s3c64xx_init_cpu(void) -{ - samsung_cpu_id = readl_relaxed(S3C_VA_SYS + 0x118); - if (!samsung_cpu_id) { - /* - * S3C6400 has the ID register in a different place, - * and needs a write before it can be read. - */ - writel_relaxed(0x0, S3C_VA_SYS + 0xA1C); - samsung_cpu_id = readl_relaxed(S3C_VA_SYS + 0xA1C); - } - - pr_info("Samsung CPU ID: 0x%08lx\n", samsung_cpu_id); -} diff --git a/arch/arm/plat-samsung/dev-uart.c b/arch/arm/plat-samsung/dev-uart.c deleted file mode 100644 index 7476a5dbae77..000000000000 --- a/arch/arm/plat-samsung/dev-uart.c +++ /dev/null @@ -1,41 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// originally from arch/arm/plat-s3c24xx/devs.c -// -// Copyright (c) 2004 Simtec Electronics -// Ben Dooks -// -// Base S3C24XX platform device definitions - -#include -#include - -#include - -/* uart devices */ - -static struct platform_device s3c24xx_uart_device0 = { - .id = 0, -}; - -static struct platform_device s3c24xx_uart_device1 = { - .id = 1, -}; - -static struct platform_device s3c24xx_uart_device2 = { - .id = 2, -}; - -static struct platform_device s3c24xx_uart_device3 = { - .id = 3, -}; - -struct platform_device *s3c24xx_uart_src[4] = { - &s3c24xx_uart_device0, - &s3c24xx_uart_device1, - &s3c24xx_uart_device2, - &s3c24xx_uart_device3, -}; - -struct platform_device *s3c24xx_uart_devs[4] = { -}; diff --git a/arch/arm/plat-samsung/devs.c b/arch/arm/plat-samsung/devs.c deleted file mode 100644 index e23204132b27..000000000000 --- a/arch/arm/plat-samsung/devs.c +++ /dev/null @@ -1,1199 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// Copyright (c) 2011 Samsung Electronics Co., Ltd. -// http://www.samsung.com -// -// Base Samsung platform device definitions - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include - -#ifdef CONFIG_PLAT_S3C24XX -#include -#endif /* CONFIG_PLAT_S3C24XX */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define samsung_device_dma_mask (*((u64[]) { DMA_BIT_MASK(32) })) - -/* AC97 */ -#ifdef CONFIG_CPU_S3C2440 -static struct resource s3c_ac97_resource[] = { - [0] = DEFINE_RES_MEM(S3C2440_PA_AC97, S3C2440_SZ_AC97), - [1] = DEFINE_RES_IRQ(IRQ_S3C244X_AC97), -}; - -struct platform_device s3c_device_ac97 = { - .name = "samsung-ac97", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_ac97_resource), - .resource = s3c_ac97_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - } -}; -#endif /* CONFIG_CPU_S3C2440 */ - -/* ADC */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_adc_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC), - [1] = DEFINE_RES_IRQ(IRQ_TC), - [2] = DEFINE_RES_IRQ(IRQ_ADC), -}; - -struct platform_device s3c_device_adc = { - .name = "s3c24xx-adc", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_adc_resource), - .resource = s3c_adc_resource, -}; -#endif /* CONFIG_PLAT_S3C24XX */ - -#if defined(CONFIG_SAMSUNG_DEV_ADC) -static struct resource s3c_adc_resource[] = { - [0] = DEFINE_RES_MEM(SAMSUNG_PA_ADC, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_ADC), - [2] = DEFINE_RES_IRQ(IRQ_TC), -}; - -struct platform_device s3c_device_adc = { - .name = "exynos-adc", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_adc_resource), - .resource = s3c_adc_resource, -}; -#endif /* CONFIG_SAMSUNG_DEV_ADC */ - -/* Camif Controller */ - -#ifdef CONFIG_CPU_S3C2440 -static struct resource s3c_camif_resource[] = { - [0] = DEFINE_RES_MEM(S3C2440_PA_CAMIF, S3C2440_SZ_CAMIF), - [1] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_C), - [2] = DEFINE_RES_IRQ(IRQ_S3C2440_CAM_P), -}; - -struct platform_device s3c_device_camif = { - .name = "s3c2440-camif", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_camif_resource), - .resource = s3c_camif_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - } -}; -#endif /* CONFIG_CPU_S3C2440 */ - -/* FB */ - -#ifdef CONFIG_S3C_DEV_FB -static struct resource s3c_fb_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_FB, SZ_16K), - [1] = DEFINE_RES_IRQ(IRQ_LCD_VSYNC), - [2] = DEFINE_RES_IRQ(IRQ_LCD_FIFO), - [3] = DEFINE_RES_IRQ(IRQ_LCD_SYSTEM), -}; - -struct platform_device s3c_device_fb = { - .name = "s3c-fb", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_fb_resource), - .resource = s3c_fb_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init s3c_fb_set_platdata(struct s3c_fb_platdata *pd) -{ - s3c_set_platdata(pd, sizeof(struct s3c_fb_platdata), - &s3c_device_fb); -} -#endif /* CONFIG_S3C_DEV_FB */ - -/* HWMON */ - -#ifdef CONFIG_S3C_DEV_HWMON -struct platform_device s3c_device_hwmon = { - .name = "s3c-hwmon", - .id = -1, - .dev.parent = &s3c_device_adc.dev, -}; - -void __init s3c_hwmon_set_platdata(struct s3c_hwmon_pdata *pd) -{ - s3c_set_platdata(pd, sizeof(struct s3c_hwmon_pdata), - &s3c_device_hwmon); -} -#endif /* CONFIG_S3C_DEV_HWMON */ - -/* HSMMC */ - -#ifdef CONFIG_S3C_DEV_HSMMC -static struct resource s3c_hsmmc_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_HSMMC0, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_HSMMC0), -}; - -struct s3c_sdhci_platdata s3c_hsmmc0_def_platdata = { - .max_width = 4, - .host_caps = (MMC_CAP_4_BIT_DATA | - MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), -}; - -struct platform_device s3c_device_hsmmc0 = { - .name = "s3c-sdhci", - .id = 0, - .num_resources = ARRAY_SIZE(s3c_hsmmc_resource), - .resource = s3c_hsmmc_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &s3c_hsmmc0_def_platdata, - }, -}; - -void s3c_sdhci0_set_platdata(struct s3c_sdhci_platdata *pd) -{ - s3c_sdhci_set_platdata(pd, &s3c_hsmmc0_def_platdata); -} -#endif /* CONFIG_S3C_DEV_HSMMC */ - -#ifdef CONFIG_S3C_DEV_HSMMC1 -static struct resource s3c_hsmmc1_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_HSMMC1, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_HSMMC1), -}; - -struct s3c_sdhci_platdata s3c_hsmmc1_def_platdata = { - .max_width = 4, - .host_caps = (MMC_CAP_4_BIT_DATA | - MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), -}; - -struct platform_device s3c_device_hsmmc1 = { - .name = "s3c-sdhci", - .id = 1, - .num_resources = ARRAY_SIZE(s3c_hsmmc1_resource), - .resource = s3c_hsmmc1_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &s3c_hsmmc1_def_platdata, - }, -}; - -void s3c_sdhci1_set_platdata(struct s3c_sdhci_platdata *pd) -{ - s3c_sdhci_set_platdata(pd, &s3c_hsmmc1_def_platdata); -} -#endif /* CONFIG_S3C_DEV_HSMMC1 */ - -/* HSMMC2 */ - -#ifdef CONFIG_S3C_DEV_HSMMC2 -static struct resource s3c_hsmmc2_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_HSMMC2, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_HSMMC2), -}; - -struct s3c_sdhci_platdata s3c_hsmmc2_def_platdata = { - .max_width = 4, - .host_caps = (MMC_CAP_4_BIT_DATA | - MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), -}; - -struct platform_device s3c_device_hsmmc2 = { - .name = "s3c-sdhci", - .id = 2, - .num_resources = ARRAY_SIZE(s3c_hsmmc2_resource), - .resource = s3c_hsmmc2_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &s3c_hsmmc2_def_platdata, - }, -}; - -void s3c_sdhci2_set_platdata(struct s3c_sdhci_platdata *pd) -{ - s3c_sdhci_set_platdata(pd, &s3c_hsmmc2_def_platdata); -} -#endif /* CONFIG_S3C_DEV_HSMMC2 */ - -#ifdef CONFIG_S3C_DEV_HSMMC3 -static struct resource s3c_hsmmc3_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_HSMMC3, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_HSMMC3), -}; - -struct s3c_sdhci_platdata s3c_hsmmc3_def_platdata = { - .max_width = 4, - .host_caps = (MMC_CAP_4_BIT_DATA | - MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED), -}; - -struct platform_device s3c_device_hsmmc3 = { - .name = "s3c-sdhci", - .id = 3, - .num_resources = ARRAY_SIZE(s3c_hsmmc3_resource), - .resource = s3c_hsmmc3_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - .platform_data = &s3c_hsmmc3_def_platdata, - }, -}; - -void s3c_sdhci3_set_platdata(struct s3c_sdhci_platdata *pd) -{ - s3c_sdhci_set_platdata(pd, &s3c_hsmmc3_def_platdata); -} -#endif /* CONFIG_S3C_DEV_HSMMC3 */ - -/* I2C */ - -static struct resource s3c_i2c0_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC), -}; - -struct platform_device s3c_device_i2c0 = { - .name = "s3c2410-i2c", - .id = 0, - .num_resources = ARRAY_SIZE(s3c_i2c0_resource), - .resource = s3c_i2c0_resource, -}; - -struct s3c2410_platform_i2c default_i2c_data __initdata = { - .flags = 0, - .slave_addr = 0x10, - .frequency = 100*1000, - .sda_delay = 100, -}; - -void __init s3c_i2c0_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 0; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c0); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c0_cfg_gpio; -} - -#ifdef CONFIG_S3C_DEV_I2C1 -static struct resource s3c_i2c1_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC1, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC1), -}; - -struct platform_device s3c_device_i2c1 = { - .name = "s3c2410-i2c", - .id = 1, - .num_resources = ARRAY_SIZE(s3c_i2c1_resource), - .resource = s3c_i2c1_resource, -}; - -void __init s3c_i2c1_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 1; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c1); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c1_cfg_gpio; -} -#endif /* CONFIG_S3C_DEV_I2C1 */ - -#ifdef CONFIG_S3C_DEV_I2C2 -static struct resource s3c_i2c2_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC2, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC2), -}; - -struct platform_device s3c_device_i2c2 = { - .name = "s3c2410-i2c", - .id = 2, - .num_resources = ARRAY_SIZE(s3c_i2c2_resource), - .resource = s3c_i2c2_resource, -}; - -void __init s3c_i2c2_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 2; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c2); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c2_cfg_gpio; -} -#endif /* CONFIG_S3C_DEV_I2C2 */ - -#ifdef CONFIG_S3C_DEV_I2C3 -static struct resource s3c_i2c3_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC3, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC3), -}; - -struct platform_device s3c_device_i2c3 = { - .name = "s3c2440-i2c", - .id = 3, - .num_resources = ARRAY_SIZE(s3c_i2c3_resource), - .resource = s3c_i2c3_resource, -}; - -void __init s3c_i2c3_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 3; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c3); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c3_cfg_gpio; -} -#endif /*CONFIG_S3C_DEV_I2C3 */ - -#ifdef CONFIG_S3C_DEV_I2C4 -static struct resource s3c_i2c4_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC4, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC4), -}; - -struct platform_device s3c_device_i2c4 = { - .name = "s3c2440-i2c", - .id = 4, - .num_resources = ARRAY_SIZE(s3c_i2c4_resource), - .resource = s3c_i2c4_resource, -}; - -void __init s3c_i2c4_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 4; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c4); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c4_cfg_gpio; -} -#endif /*CONFIG_S3C_DEV_I2C4 */ - -#ifdef CONFIG_S3C_DEV_I2C5 -static struct resource s3c_i2c5_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC5, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC5), -}; - -struct platform_device s3c_device_i2c5 = { - .name = "s3c2440-i2c", - .id = 5, - .num_resources = ARRAY_SIZE(s3c_i2c5_resource), - .resource = s3c_i2c5_resource, -}; - -void __init s3c_i2c5_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 5; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c5); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c5_cfg_gpio; -} -#endif /*CONFIG_S3C_DEV_I2C5 */ - -#ifdef CONFIG_S3C_DEV_I2C6 -static struct resource s3c_i2c6_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC6, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC6), -}; - -struct platform_device s3c_device_i2c6 = { - .name = "s3c2440-i2c", - .id = 6, - .num_resources = ARRAY_SIZE(s3c_i2c6_resource), - .resource = s3c_i2c6_resource, -}; - -void __init s3c_i2c6_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 6; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c6); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c6_cfg_gpio; -} -#endif /* CONFIG_S3C_DEV_I2C6 */ - -#ifdef CONFIG_S3C_DEV_I2C7 -static struct resource s3c_i2c7_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_IIC7, SZ_4K), - [1] = DEFINE_RES_IRQ(IRQ_IIC7), -}; - -struct platform_device s3c_device_i2c7 = { - .name = "s3c2440-i2c", - .id = 7, - .num_resources = ARRAY_SIZE(s3c_i2c7_resource), - .resource = s3c_i2c7_resource, -}; - -void __init s3c_i2c7_set_platdata(struct s3c2410_platform_i2c *pd) -{ - struct s3c2410_platform_i2c *npd; - - if (!pd) { - pd = &default_i2c_data; - pd->bus_num = 7; - } - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_i2c7); - - if (!npd->cfg_gpio) - npd->cfg_gpio = s3c_i2c7_cfg_gpio; -} -#endif /* CONFIG_S3C_DEV_I2C7 */ - -/* I2S */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_iis_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_IIS, S3C24XX_SZ_IIS), -}; - -struct platform_device s3c_device_iis = { - .name = "s3c24xx-iis", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_iis_resource), - .resource = s3c_iis_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - } -}; -#endif /* CONFIG_PLAT_S3C24XX */ - -/* IDE CFCON */ - -#ifdef CONFIG_SAMSUNG_DEV_IDE -static struct resource s3c_cfcon_resource[] = { - [0] = DEFINE_RES_MEM(SAMSUNG_PA_CFCON, SZ_16K), - [1] = DEFINE_RES_IRQ(IRQ_CFCON), -}; - -struct platform_device s3c_device_cfcon = { - .id = 0, - .num_resources = ARRAY_SIZE(s3c_cfcon_resource), - .resource = s3c_cfcon_resource, -}; - -void __init s3c_ide_set_platdata(struct s3c_ide_platdata *pdata) -{ - s3c_set_platdata(pdata, sizeof(struct s3c_ide_platdata), - &s3c_device_cfcon); -} -#endif /* CONFIG_SAMSUNG_DEV_IDE */ - -/* KEYPAD */ - -#ifdef CONFIG_SAMSUNG_DEV_KEYPAD -static struct resource samsung_keypad_resources[] = { - [0] = DEFINE_RES_MEM(SAMSUNG_PA_KEYPAD, SZ_32), - [1] = DEFINE_RES_IRQ(IRQ_KEYPAD), -}; - -struct platform_device samsung_device_keypad = { - .name = "samsung-keypad", - .id = -1, - .num_resources = ARRAY_SIZE(samsung_keypad_resources), - .resource = samsung_keypad_resources, -}; - -void __init samsung_keypad_set_platdata(struct samsung_keypad_platdata *pd) -{ - struct samsung_keypad_platdata *npd; - - npd = s3c_set_platdata(pd, sizeof(*npd), &samsung_device_keypad); - - if (!npd->cfg_gpio) - npd->cfg_gpio = samsung_keypad_cfg_gpio; -} -#endif /* CONFIG_SAMSUNG_DEV_KEYPAD */ - -/* LCD Controller */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_lcd_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_LCD, S3C24XX_SZ_LCD), - [1] = DEFINE_RES_IRQ(IRQ_LCD), -}; - -struct platform_device s3c_device_lcd = { - .name = "s3c2410-lcd", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_lcd_resource), - .resource = s3c_lcd_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - } -}; - -void __init s3c24xx_fb_set_platdata(struct s3c2410fb_mach_info *pd) -{ - struct s3c2410fb_mach_info *npd; - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_lcd); - if (npd) { - npd->displays = kmemdup(pd->displays, - sizeof(struct s3c2410fb_display) * npd->num_displays, - GFP_KERNEL); - if (!npd->displays) - printk(KERN_ERR "no memory for LCD display data\n"); - } else { - printk(KERN_ERR "no memory for LCD platform data\n"); - } -} -#endif /* CONFIG_PLAT_S3C24XX */ - -/* NAND */ - -#ifdef CONFIG_S3C_DEV_NAND -static struct resource s3c_nand_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_NAND, SZ_1M), -}; - -struct platform_device s3c_device_nand = { - .name = "s3c2410-nand", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_nand_resource), - .resource = s3c_nand_resource, -}; - -/* - * s3c_nand_copy_set() - copy nand set data - * @set: The new structure, directly copied from the old. - * - * Copy all the fields from the NAND set field from what is probably __initdata - * to new kernel memory. The code returns 0 if the copy happened correctly or - * an error code for the calling function to display. - * - * Note, we currently do not try and look to see if we've already copied the - * data in a previous set. - */ -static int __init s3c_nand_copy_set(struct s3c2410_nand_set *set) -{ - void *ptr; - int size; - - size = sizeof(struct mtd_partition) * set->nr_partitions; - if (size) { - ptr = kmemdup(set->partitions, size, GFP_KERNEL); - set->partitions = ptr; - - if (!ptr) - return -ENOMEM; - } - - if (set->nr_map && set->nr_chips) { - size = sizeof(int) * set->nr_chips; - ptr = kmemdup(set->nr_map, size, GFP_KERNEL); - set->nr_map = ptr; - - if (!ptr) - return -ENOMEM; - } - - return 0; -} - -void __init s3c_nand_set_platdata(struct s3c2410_platform_nand *nand) -{ - struct s3c2410_platform_nand *npd; - int size; - int ret; - - /* note, if we get a failure in allocation, we simply drop out of the - * function. If there is so little memory available at initialisation - * time then there is little chance the system is going to run. - */ - - npd = s3c_set_platdata(nand, sizeof(*npd), &s3c_device_nand); - if (!npd) - return; - - /* now see if we need to copy any of the nand set data */ - - size = sizeof(struct s3c2410_nand_set) * npd->nr_sets; - if (size) { - struct s3c2410_nand_set *from = npd->sets; - struct s3c2410_nand_set *to; - int i; - - to = kmemdup(from, size, GFP_KERNEL); - npd->sets = to; /* set, even if we failed */ - - if (!to) { - printk(KERN_ERR "%s: no memory for sets\n", __func__); - return; - } - - for (i = 0; i < npd->nr_sets; i++) { - ret = s3c_nand_copy_set(to); - if (ret) { - printk(KERN_ERR "%s: failed to copy set %d\n", - __func__, i); - return; - } - to++; - } - } -} -#endif /* CONFIG_S3C_DEV_NAND */ - -/* ONENAND */ - -#ifdef CONFIG_S3C_DEV_ONENAND -static struct resource s3c_onenand_resources[] = { - [0] = DEFINE_RES_MEM(S3C_PA_ONENAND, SZ_1K), - [1] = DEFINE_RES_MEM(S3C_PA_ONENAND_BUF, S3C_SZ_ONENAND_BUF), - [2] = DEFINE_RES_IRQ(IRQ_ONENAND), -}; - -struct platform_device s3c_device_onenand = { - .name = "samsung-onenand", - .id = 0, - .num_resources = ARRAY_SIZE(s3c_onenand_resources), - .resource = s3c_onenand_resources, -}; -#endif /* CONFIG_S3C_DEV_ONENAND */ - -#ifdef CONFIG_S3C64XX_DEV_ONENAND1 -static struct resource s3c64xx_onenand1_resources[] = { - [0] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1, SZ_1K), - [1] = DEFINE_RES_MEM(S3C64XX_PA_ONENAND1_BUF, S3C64XX_SZ_ONENAND1_BUF), - [2] = DEFINE_RES_IRQ(IRQ_ONENAND1), -}; - -struct platform_device s3c64xx_device_onenand1 = { - .name = "samsung-onenand", - .id = 1, - .num_resources = ARRAY_SIZE(s3c64xx_onenand1_resources), - .resource = s3c64xx_onenand1_resources, -}; - -void __init s3c64xx_onenand1_set_platdata(struct onenand_platform_data *pdata) -{ - s3c_set_platdata(pdata, sizeof(struct onenand_platform_data), - &s3c64xx_device_onenand1); -} -#endif /* CONFIG_S3C64XX_DEV_ONENAND1 */ - -/* PWM Timer */ - -#ifdef CONFIG_SAMSUNG_DEV_PWM -static struct resource samsung_pwm_resource[] = { - DEFINE_RES_MEM(SAMSUNG_PA_TIMER, SZ_4K), -}; - -struct platform_device samsung_device_pwm = { - .name = "samsung-pwm", - .id = -1, - .num_resources = ARRAY_SIZE(samsung_pwm_resource), - .resource = samsung_pwm_resource, -}; - -void __init samsung_pwm_set_platdata(struct samsung_pwm_variant *pd) -{ - samsung_device_pwm.dev.platform_data = pd; -} -#endif /* CONFIG_SAMSUNG_DEV_PWM */ - -/* RTC */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_rtc_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_RTC, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_RTC), - [2] = DEFINE_RES_IRQ(IRQ_TICK), -}; - -struct platform_device s3c_device_rtc = { - .name = "s3c2410-rtc", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_rtc_resource), - .resource = s3c_rtc_resource, -}; -#endif /* CONFIG_PLAT_S3C24XX */ - -#ifdef CONFIG_S3C_DEV_RTC -static struct resource s3c_rtc_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_RTC, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_RTC_ALARM), - [2] = DEFINE_RES_IRQ(IRQ_RTC_TIC), -}; - -struct platform_device s3c_device_rtc = { - .name = "s3c64xx-rtc", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_rtc_resource), - .resource = s3c_rtc_resource, -}; -#endif /* CONFIG_S3C_DEV_RTC */ - -/* SDI */ - -#ifdef CONFIG_PLAT_S3C24XX -void s3c24xx_mci_def_set_power(unsigned char power_mode, unsigned short vdd) -{ - switch (power_mode) { - case MMC_POWER_ON: - case MMC_POWER_UP: - /* Configure GPE5...GPE10 pins in SD mode */ - s3c_gpio_cfgall_range(S3C2410_GPE(5), 6, S3C_GPIO_SFN(2), - S3C_GPIO_PULL_NONE); - break; - - case MMC_POWER_OFF: - default: - gpio_direction_output(S3C2410_GPE(5), 0); - break; - } -} - -static struct resource s3c_sdi_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_SDI, S3C24XX_SZ_SDI), - [1] = DEFINE_RES_IRQ(IRQ_SDI), -}; - -static struct s3c24xx_mci_pdata s3cmci_def_pdata = { - /* This is currently here to avoid a number of if (host->pdata) - * checks. Any zero fields to ensure reasonable defaults are picked. */ - .no_wprotect = 1, - .no_detect = 1, - .set_power = s3c24xx_mci_def_set_power, -}; - -struct platform_device s3c_device_sdi = { - .name = "s3c2410-sdi", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_sdi_resource), - .resource = s3c_sdi_resource, - .dev.platform_data = &s3cmci_def_pdata, -}; - -void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata) -{ - s3c_set_platdata(pdata, sizeof(struct s3c24xx_mci_pdata), - &s3c_device_sdi); -} -#endif /* CONFIG_PLAT_S3C24XX */ - -/* SPI */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_spi0_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI, SZ_32), - [1] = DEFINE_RES_IRQ(IRQ_SPI0), -}; - -struct platform_device s3c_device_spi0 = { - .name = "s3c2410-spi", - .id = 0, - .num_resources = ARRAY_SIZE(s3c_spi0_resource), - .resource = s3c_spi0_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - } -}; - -static struct resource s3c_spi1_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_SPI1, SZ_32), - [1] = DEFINE_RES_IRQ(IRQ_SPI1), -}; - -struct platform_device s3c_device_spi1 = { - .name = "s3c2410-spi", - .id = 1, - .num_resources = ARRAY_SIZE(s3c_spi1_resource), - .resource = s3c_spi1_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - } -}; -#endif /* CONFIG_PLAT_S3C24XX */ - -/* Touchscreen */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_ts_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_ADC, S3C24XX_SZ_ADC), - [1] = DEFINE_RES_IRQ(IRQ_TC), -}; - -struct platform_device s3c_device_ts = { - .name = "s3c2410-ts", - .id = -1, - .dev.parent = &s3c_device_adc.dev, - .num_resources = ARRAY_SIZE(s3c_ts_resource), - .resource = s3c_ts_resource, -}; - -void __init s3c24xx_ts_set_platdata(struct s3c2410_ts_mach_info *hard_s3c2410ts_info) -{ - s3c_set_platdata(hard_s3c2410ts_info, - sizeof(struct s3c2410_ts_mach_info), &s3c_device_ts); -} -#endif /* CONFIG_PLAT_S3C24XX */ - -#ifdef CONFIG_SAMSUNG_DEV_TS -static struct s3c2410_ts_mach_info default_ts_data __initdata = { - .delay = 10000, - .presc = 49, - .oversampling_shift = 2, -}; - -void __init s3c64xx_ts_set_platdata(struct s3c2410_ts_mach_info *pd) -{ - if (!pd) - pd = &default_ts_data; - - s3c_set_platdata(pd, sizeof(struct s3c2410_ts_mach_info), - &s3c_device_adc); -} -#endif /* CONFIG_SAMSUNG_DEV_TS */ - -/* USB */ - -#ifdef CONFIG_S3C_DEV_USB_HOST -static struct resource s3c_usb_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_USBHOST, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_USBH), -}; - -struct platform_device s3c_device_ohci = { - .name = "s3c2410-ohci", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_usb_resource), - .resource = s3c_usb_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - } -}; - -/* - * s3c_ohci_set_platdata - initialise OHCI device platform data - * @info: The platform data. - * - * This call copies the @info passed in and sets the device .platform_data - * field to that copy. The @info is copied so that the original can be marked - * __initdata. - */ - -void __init s3c_ohci_set_platdata(struct s3c2410_hcd_info *info) -{ - s3c_set_platdata(info, sizeof(struct s3c2410_hcd_info), - &s3c_device_ohci); -} -#endif /* CONFIG_S3C_DEV_USB_HOST */ - -/* USB Device (Gadget) */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_usbgadget_resource[] = { - [0] = DEFINE_RES_MEM(S3C24XX_PA_USBDEV, S3C24XX_SZ_USBDEV), - [1] = DEFINE_RES_IRQ(IRQ_USBD), -}; - -struct platform_device s3c_device_usbgadget = { - .name = "s3c2410-usbgadget", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_usbgadget_resource), - .resource = s3c_usbgadget_resource, -}; - -void __init s3c24xx_udc_set_platdata(struct s3c2410_udc_mach_info *pd) -{ - s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usbgadget); -} -#endif /* CONFIG_PLAT_S3C24XX */ - -/* USB HSOTG */ - -#ifdef CONFIG_S3C_DEV_USB_HSOTG -static struct resource s3c_usb_hsotg_resources[] = { - [0] = DEFINE_RES_MEM(S3C_PA_USB_HSOTG, SZ_128K), - [1] = DEFINE_RES_IRQ(IRQ_OTG), -}; - -struct platform_device s3c_device_usb_hsotg = { - .name = "s3c-hsotg", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_usb_hsotg_resources), - .resource = s3c_usb_hsotg_resources, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init dwc2_hsotg_set_platdata(struct dwc2_hsotg_plat *pd) -{ - struct dwc2_hsotg_plat *npd; - - npd = s3c_set_platdata(pd, sizeof(*npd), &s3c_device_usb_hsotg); - - if (!npd->phy_init) - npd->phy_init = s3c_usb_phy_init; - if (!npd->phy_exit) - npd->phy_exit = s3c_usb_phy_exit; -} -#endif /* CONFIG_S3C_DEV_USB_HSOTG */ - -/* USB High Spped 2.0 Device (Gadget) */ - -#ifdef CONFIG_PLAT_S3C24XX -static struct resource s3c_hsudc_resource[] = { - [0] = DEFINE_RES_MEM(S3C2416_PA_HSUDC, S3C2416_SZ_HSUDC), - [1] = DEFINE_RES_IRQ(IRQ_USBD), -}; - -struct platform_device s3c_device_usb_hsudc = { - .name = "s3c-hsudc", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_hsudc_resource), - .resource = s3c_hsudc_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init s3c24xx_hsudc_set_platdata(struct s3c24xx_hsudc_platdata *pd) -{ - s3c_set_platdata(pd, sizeof(*pd), &s3c_device_usb_hsudc); - pd->phy_init = s3c_hsudc_init_phy; - pd->phy_uninit = s3c_hsudc_uninit_phy; -} -#endif /* CONFIG_PLAT_S3C24XX */ - -/* WDT */ - -#ifdef CONFIG_S3C_DEV_WDT -static struct resource s3c_wdt_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_WDT, SZ_1K), - [1] = DEFINE_RES_IRQ(IRQ_WDT), -}; - -struct platform_device s3c_device_wdt = { - .name = "s3c2410-wdt", - .id = -1, - .num_resources = ARRAY_SIZE(s3c_wdt_resource), - .resource = s3c_wdt_resource, -}; -#endif /* CONFIG_S3C_DEV_WDT */ - -#ifdef CONFIG_S3C64XX_DEV_SPI0 -static struct resource s3c64xx_spi0_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_SPI0, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_SPI0), -}; - -struct platform_device s3c64xx_device_spi0 = { - .name = "s3c6410-spi", - .id = 0, - .num_resources = ARRAY_SIZE(s3c64xx_spi0_resource), - .resource = s3c64xx_spi0_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init s3c64xx_spi0_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, - int num_cs) -{ - struct s3c64xx_spi_info pd; - - /* Reject invalid configuration */ - if (!num_cs || src_clk_nr < 0) { - pr_err("%s: Invalid SPI configuration\n", __func__); - return; - } - - pd.num_cs = num_cs; - pd.src_clk_nr = src_clk_nr; - pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi0_cfg_gpio; - - s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi0); -} -#endif /* CONFIG_S3C64XX_DEV_SPI0 */ - -#ifdef CONFIG_S3C64XX_DEV_SPI1 -static struct resource s3c64xx_spi1_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_SPI1, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_SPI1), -}; - -struct platform_device s3c64xx_device_spi1 = { - .name = "s3c6410-spi", - .id = 1, - .num_resources = ARRAY_SIZE(s3c64xx_spi1_resource), - .resource = s3c64xx_spi1_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init s3c64xx_spi1_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, - int num_cs) -{ - struct s3c64xx_spi_info pd; - - /* Reject invalid configuration */ - if (!num_cs || src_clk_nr < 0) { - pr_err("%s: Invalid SPI configuration\n", __func__); - return; - } - - pd.num_cs = num_cs; - pd.src_clk_nr = src_clk_nr; - pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi1_cfg_gpio; - - s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi1); -} -#endif /* CONFIG_S3C64XX_DEV_SPI1 */ - -#ifdef CONFIG_S3C64XX_DEV_SPI2 -static struct resource s3c64xx_spi2_resource[] = { - [0] = DEFINE_RES_MEM(S3C_PA_SPI2, SZ_256), - [1] = DEFINE_RES_IRQ(IRQ_SPI2), -}; - -struct platform_device s3c64xx_device_spi2 = { - .name = "s3c6410-spi", - .id = 2, - .num_resources = ARRAY_SIZE(s3c64xx_spi2_resource), - .resource = s3c64xx_spi2_resource, - .dev = { - .dma_mask = &samsung_device_dma_mask, - .coherent_dma_mask = DMA_BIT_MASK(32), - }, -}; - -void __init s3c64xx_spi2_set_platdata(int (*cfg_gpio)(void), int src_clk_nr, - int num_cs) -{ - struct s3c64xx_spi_info pd; - - /* Reject invalid configuration */ - if (!num_cs || src_clk_nr < 0) { - pr_err("%s: Invalid SPI configuration\n", __func__); - return; - } - - pd.num_cs = num_cs; - pd.src_clk_nr = src_clk_nr; - pd.cfg_gpio = (cfg_gpio) ? cfg_gpio : s3c64xx_spi2_cfg_gpio; - - s3c_set_platdata(&pd, sizeof(pd), &s3c64xx_device_spi2); -} -#endif /* CONFIG_S3C64XX_DEV_SPI2 */ diff --git a/arch/arm/plat-samsung/gpio-samsung.c b/arch/arm/plat-samsung/gpio-samsung.c deleted file mode 100644 index 8955fd675265..000000000000 --- a/arch/arm/plat-samsung/gpio-samsung.c +++ /dev/null @@ -1,1324 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// -// Copyright (c) 2009-2011 Samsung Electronics Co., Ltd. -// http://www.samsung.com/ -// -// Copyright 2008 Openmoko, Inc. -// Copyright 2008 Simtec Electronics -// Ben Dooks -// http://armlinux.simtec.co.uk/ -// -// Samsung - GPIOlib support - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip, - unsigned int off, samsung_gpio_pull_t pull) -{ - void __iomem *reg = chip->base + 0x08; - int shift = off * 2; - u32 pup; - - pup = __raw_readl(reg); - pup &= ~(3 << shift); - pup |= pull << shift; - __raw_writel(pup, reg); - - return 0; -} - -samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip, - unsigned int off) -{ - void __iomem *reg = chip->base + 0x08; - int shift = off * 2; - u32 pup = __raw_readl(reg); - - pup >>= shift; - pup &= 0x3; - - return (__force samsung_gpio_pull_t)pup; -} - -int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip, - unsigned int off, samsung_gpio_pull_t pull) -{ - switch (pull) { - case S3C_GPIO_PULL_NONE: - pull = 0x01; - break; - case S3C_GPIO_PULL_UP: - pull = 0x00; - break; - case S3C_GPIO_PULL_DOWN: - pull = 0x02; - break; - } - return samsung_gpio_setpull_updown(chip, off, pull); -} - -samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip, - unsigned int off) -{ - samsung_gpio_pull_t pull; - - pull = samsung_gpio_getpull_updown(chip, off); - - switch (pull) { - case 0x00: - pull = S3C_GPIO_PULL_UP; - break; - case 0x01: - case 0x03: - pull = S3C_GPIO_PULL_NONE; - break; - case 0x02: - pull = S3C_GPIO_PULL_DOWN; - break; - } - - return pull; -} - -static int s3c24xx_gpio_setpull_1(struct samsung_gpio_chip *chip, - unsigned int off, samsung_gpio_pull_t pull, - samsung_gpio_pull_t updown) -{ - void __iomem *reg = chip->base + 0x08; - u32 pup = __raw_readl(reg); - - if (pull == updown) - pup &= ~(1 << off); - else if (pull == S3C_GPIO_PULL_NONE) - pup |= (1 << off); - else - return -EINVAL; - - __raw_writel(pup, reg); - return 0; -} - -static samsung_gpio_pull_t s3c24xx_gpio_getpull_1(struct samsung_gpio_chip *chip, - unsigned int off, - samsung_gpio_pull_t updown) -{ - void __iomem *reg = chip->base + 0x08; - u32 pup = __raw_readl(reg); - - pup &= (1 << off); - return pup ? S3C_GPIO_PULL_NONE : updown; -} - -samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip, - unsigned int off) -{ - return s3c24xx_gpio_getpull_1(chip, off, S3C_GPIO_PULL_UP); -} - -int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip, - unsigned int off, samsung_gpio_pull_t pull) -{ - return s3c24xx_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_UP); -} - -samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip, - unsigned int off) -{ - return s3c24xx_gpio_getpull_1(chip, off, S3C_GPIO_PULL_DOWN); -} - -int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip, - unsigned int off, samsung_gpio_pull_t pull) -{ - return s3c24xx_gpio_setpull_1(chip, off, pull, S3C_GPIO_PULL_DOWN); -} - -/* - * samsung_gpio_setcfg_2bit - Samsung 2bit style GPIO configuration. - * @chip: The gpio chip that is being configured. - * @off: The offset for the GPIO being configured. - * @cfg: The configuration value to set. - * - * This helper deal with the GPIO cases where the control register - * has two bits of configuration per gpio, which have the following - * functions: - * 00 = input - * 01 = output - * 1x = special function - */ - -static int samsung_gpio_setcfg_2bit(struct samsung_gpio_chip *chip, - unsigned int off, unsigned int cfg) -{ - void __iomem *reg = chip->base; - unsigned int shift = off * 2; - u32 con; - - if (samsung_gpio_is_cfg_special(cfg)) { - cfg &= 0xf; - if (cfg > 3) - return -EINVAL; - - cfg <<= shift; - } - - con = __raw_readl(reg); - con &= ~(0x3 << shift); - con |= cfg; - __raw_writel(con, reg); - - return 0; -} - -/* - * samsung_gpio_getcfg_2bit - Samsung 2bit style GPIO configuration read. - * @chip: The gpio chip that is being configured. - * @off: The offset for the GPIO being configured. - * - * The reverse of samsung_gpio_setcfg_2bit(). Will return a value which - * could be directly passed back to samsung_gpio_setcfg_2bit(), from the - * S3C_GPIO_SPECIAL() macro. - */ - -static unsigned int samsung_gpio_getcfg_2bit(struct samsung_gpio_chip *chip, - unsigned int off) -{ - u32 con; - - con = __raw_readl(chip->base); - con >>= off * 2; - con &= 3; - - /* this conversion works for IN and OUT as well as special mode */ - return S3C_GPIO_SPECIAL(con); -} - -/* - * samsung_gpio_setcfg_4bit - Samsung 4bit single register GPIO config. - * @chip: The gpio chip that is being configured. - * @off: The offset for the GPIO being configured. - * @cfg: The configuration value to set. - * - * This helper deal with the GPIO cases where the control register has 4 bits - * of control per GPIO, generally in the form of: - * 0000 = Input - * 0001 = Output - * others = Special functions (dependent on bank) - * - * Note, since the code to deal with the case where there are two control - * registers instead of one, we do not have a separate set of functions for - * each case. - */ - -static int samsung_gpio_setcfg_4bit(struct samsung_gpio_chip *chip, - unsigned int off, unsigned int cfg) -{ - void __iomem *reg = chip->base; - unsigned int shift = (off & 7) * 4; - u32 con; - - if (off < 8 && chip->chip.ngpio > 8) - reg -= 4; - - if (samsung_gpio_is_cfg_special(cfg)) { - cfg &= 0xf; - cfg <<= shift; - } - - con = __raw_readl(reg); - con &= ~(0xf << shift); - con |= cfg; - __raw_writel(con, reg); - - return 0; -} - -/* - * samsung_gpio_getcfg_4bit - Samsung 4bit single register GPIO config read. - * @chip: The gpio chip that is being configured. - * @off: The offset for the GPIO being configured. - * - * The reverse of samsung_gpio_setcfg_4bit(), turning a gpio configuration - * register setting into a value the software can use, such as could be passed - * to samsung_gpio_setcfg_4bit(). - * - * @sa samsung_gpio_getcfg_2bit - */ - -static unsigned samsung_gpio_getcfg_4bit(struct samsung_gpio_chip *chip, - unsigned int off) -{ - void __iomem *reg = chip->base; - unsigned int shift = (off & 7) * 4; - u32 con; - - if (off < 8 && chip->chip.ngpio > 8) - reg -= 4; - - con = __raw_readl(reg); - con >>= shift; - con &= 0xf; - - /* this conversion works for IN and OUT as well as special mode */ - return S3C_GPIO_SPECIAL(con); -} - -#ifdef CONFIG_PLAT_S3C24XX -/* - * s3c24xx_gpio_setcfg_abank - S3C24XX style GPIO configuration (Bank A) - * @chip: The gpio chip that is being configured. - * @off: The offset for the GPIO being configured. - * @cfg: The configuration value to set. - * - * This helper deal with the GPIO cases where the control register - * has one bit of configuration for the gpio, where setting the bit - * means the pin is in special function mode and unset means output. - */ - -static int s3c24xx_gpio_setcfg_abank(struct samsung_gpio_chip *chip, - unsigned int off, unsigned int cfg) -{ - void __iomem *reg = chip->base; - unsigned int shift = off; - u32 con; - - if (samsung_gpio_is_cfg_special(cfg)) { - cfg &= 0xf; - - /* Map output to 0, and SFN2 to 1 */ - cfg -= 1; - if (cfg > 1) - return -EINVAL; - - cfg <<= shift; - } - - con = __raw_readl(reg); - con &= ~(0x1 << shift); - con |= cfg; - __raw_writel(con, reg); - - return 0; -} - -/* - * s3c24xx_gpio_getcfg_abank - S3C24XX style GPIO configuration read (Bank A) - * @chip: The gpio chip that is being configured. - * @off: The offset for the GPIO being configured. - * - * The reve