Android教程網
  1. 首頁
  2. Android 技術
  3. Android 手機
  4. Android 系統教程
  5. Android 游戲
 Android教程網 >> Android技術 >> 關於Android編程 >> I2C 的platform

I2C 的platform

編輯:關於Android編程

注冊到platform總線:


  ../dev-i2c0.c中
  static struct resource s3c_i2c_resource[] = { [0] = { .start = S3C_PA_IIC, .end = S3C_PA_IIC + SZ_4K - 1, .flags = IORESOURCE_MEM, }, [1] = { .start = IRQ_IIC, .end = IRQ_IIC, .flags = IORESOURCE_IRQ, }, };
  struct platform_device s3c_device_i2c0 = { .name = "s3c2410-i2c", .id = 0, .num_resources = ARRAY_SIZE(s3c_i2c_resource), .resource = s3c_i2c_resource, };
  static struct s3c2410_platform_i2c default_i2c_data0 __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_data0;
  npd = kmemdup(pd, sizeof(struct s3c2410_platform_i2c), GFP_KERNEL); if (!npd) printk(KERN_ERR "%s: no memory for platform data\n", __func__); else if (!npd->cfg_gpio) npd->cfg_gpio = s3c_i2c0_cfg_gpio;
  s3c_device_i2c0.dev.platform_data = npd; }
 
  ../mach-smdkv210.c中

static struct platform_device *smdkv210_devices[] __initdata = { ...... &s3c_device_i2c0, ...... }
  /* I2C0 */ static struct i2c_board_info i2c_devs0[] __initdata = { #ifdef CONFIG_SND_SOC_WM8580 { I2C_BOARD_INFO("wm8580", 0x1b), }, #endif };
  static void __init smdkv210_machine_init(void) { ..... /* i2c */ s3c_i2c0_set_platdata(NULL); i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));//注冊I2C設備 i2c_board_info-----> i2c_client .... platform_add_devices(smdkv210_devices, ARRAY_SIZE(smdkv210_devices));//注冊platform_device ..... }
  1. 上一頁:
  2. 下一頁:
熱門文章
閱讀排行版
Copyright © Android教程網 All Rights Reserved