Samsung S3C24XX Platform Gpio Operation detailed

Source: Internet
Author: User
Tags documentation
Original Source: http://blog.chinaunix.net/uid-22030783-id-3391515.html
First introduced the Samsung S3C24XX platform BSP definition peripheral registers and GPIO related header file to linux-3.4 system as an example, linux2.6.37 system is similar, just keep the directory is different
The header files of the platform are stored in the arch/arm/mach-s3c24xx/include/mach/directory
Memory Map definitions defines the 8-bank address of the Samsung platform, the register base address and size of each peripheral controller, and often uses file names when creating resource for Platform_data: arch/arm/ Mach-s3c24xx/include/mach/map.h such as: #define S3C2410_CS4 (0x20000000)
#define S3C2410_PA_LCD (0x4d000000)
#define S3C24XX_SZ_LCD sz_1m
IRQ definitions defines the interrupt number of the Samsung platform and is often used when creating platform_data resource arch/arm/mach-s3c24xx/include/mach/irqs.h such as: #define Irq_ EINT0 S3C2410_IRQ (0)
#define IRQ_RTC S3C2410_IRQ (30)
s3c2410 GPIO Register definitions defines the Samsung platform GPIO related registers base address and each pin's functional configuration arch/arm/mach-s3c24xx/include/mach/regs-gpio.h such as: #de Fine S3c2410_gpgcon S3c2410_gpioreg (0x60)
#define S3C2410_GPGDAT S3c2410_gpioreg (0x64)
#define S3C2410_GPB0_TOUT0 (0x02 << 0)
S3c2410-gpio Bank numbering arch/arm/mach-s3c24xx/include/mach/gpio-nrs.h such as: #define S3C2410_GPF (_NR) (S3C2410_GPIO_F _start + (_NR))
s3c2440 GPIO J Register definitions arch/arm/mach-s3c24xx/include/mach/regs-gpioj.h such as: #define S3C2413_GPJCON S 3c2410_gpioreg (0x80)
#define S3C2440_GPJ5_OUTP (0x01 << 10)
#define S3C2440_GPJ5_CAMDATA5 (0x02 << 10)
Other header files define a macro such as an IRQ, CLK, LCD, MEM, Power, SDI, and other peripheral registers such as Regs-irq.h regs-lcd.h regs-mem.h
Here's how to do this gpio, either using a generic Gpio library or using the GPIIO library provided by Samsung
The api:drivers/gpio/gpio-samsung.c of Samsung Gpiolib
S3C Platform-gpio pin configuration arch/arm/plat-samsung/include/plat/gpio-cfg.h declares GPIO API functions, such as using Samsung's GPIO API, Need to include this file declaration configuration pin Input output, whether can pull up macros such as: #define S3c_gpio_input
#define S3c_gpio_output
#define S3C_GPIO_PULL_UP
Kernel Help Documentation: Documentation/arm/samsung-s3c24xx/gpio.txt
Configure PIN function: int s3c_gpio_cfgpin (unsigned int pin, unsigned int config) example: set GPB1 to TOUT1 function S3c_gpio_cfgpin (1), S3C2410_GPB1_TOUT1);
where S3C2410_GPB (1) is defined in Gpio-nrs.h, S3C2410_GPB1_TOUT1 defines the set output function in Regs-gpio.h as: s3c_gpio_output setting the input function as: s3c_gpio_input
Set PIN Pull: int s3c_gpio_setpull (unsigned int pin, samsung_gpio_pull_t pull) Example: Set GPG5 pin to pull s3c_gpio_setpull (5) , s3c_gpio_pull_up);
Set output level: void S3c2410_gpio_setpin (unsigned int pin, unsigned int to) example: Set GPF1 pin output High level S3c2410_gpio_setpin (S3C2410_GPF (1), 1);
Detection input level: unsigned int s3c2410_gpio_getpin (unsigned int pin) Example: Detection GPF7 pin level state value = S3c2410_gpio_getpin (S3C2410_GPF (7));

Generic GPIOLIB:DRIVERS/GPIO/GPIOLIB.C need to contain linux/gpio.h when used
Request Gpio:int gpio_request (unsigned gpio, const char *label)
Free gpio:void gpio_free (unsigned GPIO)
Set to output and specify the default level: int gpio_direction_output (unsigned gpio, int value)
Set to input: int gpio_direction_input (unsigned gpio)
Set output level: void __gpio_set_value (unsigned gpio, int value)
Detection input Level:

int __gpio_get_value (unsigned gpio)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.