sdio_func.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * include/linux/mmc/sdio_func.h
  3. *
  4. * Copyright 2007 Pierre Ossman
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or (at
  9. * your option) any later version.
  10. */
  11. #ifndef MMC_SDIO_FUNC_H
  12. #define MMC_SDIO_FUNC_H
  13. #include <linux/device.h>
  14. #include <linux/mod_devicetable.h>
  15. struct mmc_card;
  16. /*
  17. * SDIO function CIS tuple (unknown to the core)
  18. */
  19. struct sdio_func_tuple {
  20. struct sdio_func_tuple *next;
  21. unsigned char code;
  22. unsigned char size;
  23. unsigned char data[0];
  24. };
  25. /*
  26. * SDIO function devices
  27. */
  28. struct sdio_func {
  29. struct mmc_card *card; /* the card this device belongs to */
  30. struct device dev; /* the device */
  31. unsigned int num; /* function number */
  32. unsigned char class; /* standard interface class */
  33. unsigned short vendor; /* vendor id */
  34. unsigned short device; /* device id */
  35. unsigned short blksize; /* maximum block size */
  36. unsigned int state; /* function state */
  37. #define SDIO_STATE_PRESENT (1<<0) /* present in sysfs */
  38. struct sdio_func_tuple *tuples;
  39. };
  40. #define sdio_func_present(f) ((f)->state & SDIO_STATE_PRESENT)
  41. #define sdio_func_set_present(f) ((f)->state |= SDIO_STATE_PRESENT)
  42. #define sdio_func_id(f) ((f)->dev.bus_id)
  43. #define sdio_get_drvdata(f) dev_get_drvdata(&(f)->dev)
  44. #define sdio_set_drvdata(f,d) dev_set_drvdata(&(f)->dev, d)
  45. /*
  46. * SDIO function device driver
  47. */
  48. struct sdio_driver {
  49. char *name;
  50. const struct sdio_device_id *id_table;
  51. int (*probe)(struct sdio_func *, const struct sdio_device_id *);
  52. void (*remove)(struct sdio_func *);
  53. struct device_driver drv;
  54. };
  55. /**
  56. * SDIO_DEVICE - macro used to describe a specific SDIO device
  57. * @vend: the 16 bit manufacturer code
  58. * @dev: the 16 bit function id
  59. *
  60. * This macro is used to create a struct sdio_device_id that matches a
  61. * specific device. The class field will be set to SDIO_ANY_ID.
  62. */
  63. #define SDIO_DEVICE(vend,dev) \
  64. .class = SDIO_ANY_ID, \
  65. .vendor = (vend), .device = (dev)
  66. /**
  67. * SDIO_DEVICE_CLASS - macro used to describe a specific SDIO device class
  68. * @dev_class: the 8 bit standard interface code
  69. *
  70. * This macro is used to create a struct sdio_device_id that matches a
  71. * specific standard SDIO function type. The vendor and device fields will
  72. * be set to SDIO_ANY_ID.
  73. */
  74. #define SDIO_DEVICE_CLASS(dev_class) \
  75. .class = (dev_class), \
  76. .vendor = SDIO_ANY_ID, .device = SDIO_ANY_ID
  77. extern int sdio_register_driver(struct sdio_driver *);
  78. extern void sdio_unregister_driver(struct sdio_driver *);
  79. /*
  80. * SDIO I/O operations
  81. */
  82. extern void sdio_claim_host(struct sdio_func *func);
  83. extern void sdio_release_host(struct sdio_func *func);
  84. extern int sdio_enable_func(struct sdio_func *func);
  85. extern int sdio_disable_func(struct sdio_func *func);
  86. extern unsigned char sdio_readb(struct sdio_func *func,
  87. unsigned int addr, int *err_ret);
  88. extern void sdio_writeb(struct sdio_func *func, unsigned char b,
  89. unsigned int addr, int *err_ret);
  90. #endif