blob: 9ea66e31f6263020773ca111c741f6ccd9d376ae [file] [log] [blame]
Ben Dooksa21765a2007-02-11 18:31:01 +01001/* linux/arch/arm/mach-s3c2440/dsc.c
Linus Torvalds1da177e2005-04-16 15:20:36 -07002 *
3 * Copyright (c) 2004-2005 Simtec Electronics
4 * Ben Dooks <ben@simtec.co.uk>
5 *
6 * Samsung S3C2440 Drive Strength Control support
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
Linus Torvalds1da177e2005-04-16 15:20:36 -070011*/
12
13#include <linux/kernel.h>
14#include <linux/types.h>
15#include <linux/interrupt.h>
16#include <linux/init.h>
17#include <linux/module.h>
Russell Kingfced80c2008-09-06 12:10:45 +010018#include <linux/io.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019
20#include <asm/mach/arch.h>
21#include <asm/mach/map.h>
22#include <asm/mach/irq.h>
23
Russell Kinga09e64f2008-08-05 16:14:15 +010024#include <mach/hardware.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025#include <asm/irq.h>
26
Russell Kinga09e64f2008-08-05 16:14:15 +010027#include <mach/regs-gpio.h>
28#include <mach/regs-dsc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Ben Dooksa2b7ba92008-10-07 22:26:09 +010030#include <plat/cpu.h>
Ben Dooks84c9b722010-01-26 16:54:21 +090031#include <plat/s3c244x.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070032
33int s3c2440_set_dsc(unsigned int pin, unsigned int value)
34{
35 void __iomem *base;
36 unsigned long val;
37 unsigned long flags;
38 unsigned long mask;
39
40 base = (pin & S3C2440_SELECT_DSC1) ? S3C2440_DSC1 : S3C2440_DSC0;
41 mask = 3 << S3C2440_DSC_GETSHIFT(pin);
42
43 local_irq_save(flags);
44
45 val = __raw_readl(base);
46 val &= ~mask;
47 val |= value & mask;
48 __raw_writel(val, base);
49
50 local_irq_restore(flags);
51 return 0;
52}
53
54EXPORT_SYMBOL(s3c2440_set_dsc);