Use of ADC in Linux Device Drivers

Source: Internet
Author: User

Kernel source code arch \ Arm \ plat-s3c24xx \ s3c2410-clock.c

/* standard clock definitions */static struct clk init_clocks_off[] = {{.name= "nand",.id= -1,.parent= &clk_h,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_NAND,}, {.name= "sdi",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_SDI,}, {.name= "adc",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_ADC,}, {.name= "i2c",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_IIC,}, {.name= "iis",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_IIS,}, {.name= "spi",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_SPI,}};static struct clk init_clocks[] = {{.name= "lcd",.id= -1,.parent= &clk_h,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_LCDC,}, {.name= "gpio",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_GPIO,}, {.name= "usb-host",.id= -1,.parent= &clk_h,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_USBH,}, {.name= "usb-device",.id= -1,.parent= &clk_h,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_USBD,}, {.name= "timers",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_PWMT,}, {.name= "uart",.id= 0,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_UART0,}, {.name= "uart",.id= 1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_UART1,}, {.name= "uart",.id= 2,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_UART2,}, {.name= "rtc",.id= -1,.parent= &clk_p,.enable= s3c2410_clkcon_enable,.ctrlbit= S3C2410_CLKCON_RTC,}, {.name= "watchdog",.id= -1,.parent= &clk_p,.ctrlbit= 0,}, {.name= "usb-bus-host",.id= -1,.parent= &clk_usb_bus,}, {.name= "usb-bus-gadget",.id= -1,.parent= &clk_usb_bus,},};

Here we can see the clock enable and disabled at system startup, so our ADC clock cannot be used after system startup.

To use the ADC clock, first we need to obtain the ADC clock and then enable it.

Obtain clock functions

Struct CLK * clk_get (struct device * Dev, const char * ID)

In the first parameter, because CLK-> ID is generally-1, you can directly input null.

If CLK-> ID is not-1, the function will get Dev-> bus_id through the dev passed in by the first parameter.

The second parameter is a string used to specify the name of the clock you want to obtain. After the parameter is passed in, the kernel finds whether a Dev-> ID (or-1) is consistent with CLK-> ID, and the con_id and CLK-> name are consistent clock, if they are inconsistent, the query fails. Therefore, my function here should be clk_get (null,
"ADC ").

Enable clock functions

Int clk_enable (struct CLK * CLK)

Disable clock functions

Void clk_disable (struct CLK * CLK)

Then we can use the ADC.

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.