ADC - PowerPoint PPT Presentation

1 / 21
About This Presentation
Title:

ADC

Description:

ADC . ADC . platform_driver . Probe (ADC ... – PowerPoint PPT presentation

Number of Views:136
Avg rating:3.0/5.0
Slides: 22
Provided by: tis149
Category:
Tags: adc | mach | number

less

Transcript and Presenter's Notes

Title: ADC


1
ADC
  • ??? MCSL ???

2
???? ??????
  • ????? ?????? ????? ??.
  • ??????? ??? System Call? ??? ???? ?? ??.
  • ???? ????? ????? ???? ???? ??. ??? ? ?? ??? ????
    ??? ?? ??? ??? ??? ????.
  • ???? ????? ??????? ???? ??? ???? System Call? ???
    ???? ??

3
2.6 Kernel
  • system call? ?? ??? ???? ??
  • Processor? App? ???? ?? system call ??? ???
  • ?? ???? ?? ????.
  • ?? ???? device??? data ??? ??
  • ?? ???? process ? ?? ??? ?? wait queue? ???
  • ??? process? ??

4
2.6 Kernel Device Driver
  • - ????? ??? ????? ?? ???? ???? ?????
  • ????? ??? ?? ??? ???? ?? ?????.
  • - ??? 2.6????? kobject?? ???? ?? ??? ???.
  • ??? ??? ?? ??? ??? ????? ???? ?? ????? ?????
    ???? ?? ?? ????? ?? ???? ??.
  • ADC? ?? ?? ?? ? ??? platform_bus_type ?? ??? ???
    ?? ?? ??? ????? ???? ????.
  • (?? ??? ??? ????(Major)??? Device ??(Minor)? ??
    ??)

5
ADC ???? ???? ??
  • ADC ???? ????? ?? ??? ??? ??.
  • platform_driver ??
  • Probe?? ?? (ADC ?? ???? ???)
  • Probe ???? ?? ???? ?? / ??(Clock, platform_data)
  • Miscdevice ?? (Miscdevice name? ??
    platform_driver ??)
  • file_operations ??(.fops name)
  • file_operations?? ??? ?? ???? ??
  • User App?? ??? ???? System Call? ??

6
????? ? ???
  • Struct device_driver
  • Struct platform_device driver
  • Struct miscdevice
  • Struct file_operations

7
struct device_driver ???
  • include ltlinux/device.hgt
  • ?? ?? ??? ????? ??? ??? ??
  • struct device_driver
  • const char name //???? ????? ??(??)
  • struct bus_type bus //?? ??(??)
  • struct kobject kobj //??? ??
  • struct module owner // ?? THIS_MODULE
  • int (probe) (struct device dev) // ??? ??
  • int (remove) (struct device dev) // ???? ??
    ??
  • int (suspend) (struct device dev, pm_message_t
    state, u32 level)
  • //???? (??)
  • int (resume) (struct device dev, u32 level)
    //???? off (??)
  • . ??

8
Struct platform_device
  • include ltplatform_devicegt
  • struct platform_device
  • const char name
  • //platform_driver? ??? ??? ??? ??.
  • int id
  • struct device dev
  • u32 num_resources
  • struct resource resource
  • struct platform_device_id id_entry
  • / arch specific additions /
  • struct pdev_archdata archdata

9
Miscdevice ???
  • include ltlinux/miscdevice.hgt
  • struct miscdevice
  • int minor //Device driver minor number
  • (???? ??? ??? ???? ??)
  • const char name //device file Name
  • const struct file_operations fops
  • // ?? ??? ? ? ??? ?? ??
  • ??

10
struct file_operations ???
  • struct file_operations struct module
    owner //?? THIS_MODULEssize_t (read) (struct
    file , char __user , size_t, loff_t )ssize_t
    (write) (struct file , const char __user ,
    size_t, loff_t )int (ioctl) (struct inode ,
    struct file , unsigned int,
  • unsigned long)
  • // Read? Write??? ???? ??? ??? ??
  • int (open) (struct inode , struct file )
  • // ?? ?????? ????? ?? ???? ??(??)int (release)
    (struct inode , struct file )
  • // ??
  • . ??

11
ADC Platform_driver
  • static struct platform_driver s3c_adc_driver
  • .probe s3c_adc_probe,
  • .remove s3c_adc_remove,
  • .suspend s3c_adc_suspend,
  • .resume s3c_adc_resume,
  • .driver
  • .owner THIS_MODULE,
  • .name "s3c-adc",
  • ,

12
Device Dirver Init
  • ?? ???? ?????? ??? Init ??? ?? ????.
  • int __init s3c_adc_init(void)
  • printk(banner)
  • return platform_driver_register(s3c_adc_driver)
  • // Platform_driver ??
  • module_init(s3c_adc_init)

13
Probe ??? ???? ??!
  • platform_driver_register() ??? call? ???
    xxxx_probe()??? call? ??? ?????? ??? ??
  • ?? platform_add_devices() ??? ??? platform
    device?
  • ??? ?? ??? ??.
  • ?? platform_add_devices ? platform_driver_registe
    r??
  • .name? ?????? ?? ?? ??.

14
Probe ??? ???? ??!
  • /kernel/arch/arm/plat-s5p/devs.c
  • static struct resource s3c_adc_resource
  • 0
  • .start S3C_PA_ADC, // ADC
    Register??
  • .end S3C_PA_ADC SZ_4K - 1,
    // ?? ??? ?
  • .flags IORESOURCE_MEM, //
    resource type ,
  • include ltmach/map.hgt
  • define S3C_PA_ADC S3C_ADDR(0xE1700000) // ??? ??

15
Probe ??? ???? ??!
  • struct platform_device s3c_device_adc
  • .name "s3c-adc",
  • //platform_driver? ??? ??? ??.
  • .id -1,
  • // ?? ?? ??? ????? ???? id? ??
  • .num_resources ARRAY_SIZE(s3c_adc_res
    ource),
  • //??? ??? ?
  • .resource s3c_adc_resource, ???
    ??? ?? ??

16
Probe ??? ???? ??!
  • /kernel/arch/arm/mach-s5pv210/mach-mango210.c
  • static struct platform_device mango210_devices
    __initdata
  • s3c_device_adc, // platform_device name ??
  • static void __init mango210_machine_init(void)
  • s3c_adc_set_platdata(s3c_adc_platform)
  • platform_add_devices(mango210_devices,
    ARRAY_SIZE(mango210_devices)) // ??? ??
  • ???? ????? Platform ???? ????? ??? ??
  • Probe??? ????.

17
ADC Probe
  • ??? ???? ???? Probe??? ?? ??? ??? ??
  • static int __init s3c_adc_probe(struct
    platform_device pdev)
  • struct resource res
  • struct device dev
  • res platform_get_resource(pdev,
    IORESOURCE_MEM, 0)
  • //???(????? ??? ?? ??) ????
  • dev pdev-gtdev
  • //// pdev ?? ??? ????? ???? dev ? ???? cast ???.
    ??? pdev? dev? ???? ??
  • ltplatform_device.hgt
  • extern struct resource platform_get_resource
  • (struct platform_device , //??? ???? ??
  • unsigned int, // flags
  • unsigned int)

18
ADC Probe
  • static struct resource adc_mem // Global define
  • static void __iomem base_addr // Global define
  • ////static void __iomem ??? ??? ?? ??
  • Writel, readl ?? core register?? ??? ???? ??????
    ??? ???? ????.
  • size (res-gtend - res-gtstart) 1 // ??? ??? ??
  • base_addr ioremap(res-gtstart, size) // ?? ???
    ?? ??
  • adc_clock clk_get(pdev-gtdev, "adc") // ?? ???
    ??
  • clk_enable(adc_clock)
  • ?? (?? ?? prescaler, delay ?? register init)
  • ret misc_register(s3c_adc_miscdev)
    //miscdevice? ??? ??.

19
Miscdevice
  • static struct miscdevice s3c_adc_miscdev
  • .minor ADC_MINOR,
  • .name "adc", //device file name
  • .fops s3c_adc_fops,
  • Miscdev ??? ??? FileSystem ??? /dev/adc?? ????
    ??? ??? ????. ??? /etc/udev? ????? ??? ????? ??.

20
User App?? ADC Driver ??
  • ???? ????? File_operation ???? ??
  • Ioctl
  • Read
  • Open
  • ?? ????. ? ??? ??? ?? IOCTL? ADC PORT??
  • READ? buffer???? ADC ??? ??
  • OPEN? ???? ????? ???? ?????? ?? Call??.

21
?????
Write a Comment
User Comments (0)
About PowerShow.com