c2port.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Silicon Labs C2 port Linux support
  4. *
  5. * Copyright (c) 2007 Rodolfo Giometti <giometti@linux.it>
  6. * Copyright (c) 2007 Eurotech S.p.A. <info@eurotech.it>
  7. */
  8. #define C2PORT_NAME_LEN 32
  9. struct device;
  10. /*
  11. * C2 port basic structs
  12. */
  13. /* Main struct */
  14. struct c2port_ops;
  15. struct c2port_device {
  16. unsigned int access:1;
  17. unsigned int flash_access:1;
  18. int id;
  19. char name[C2PORT_NAME_LEN];
  20. struct c2port_ops *ops;
  21. struct mutex mutex; /* prevent races during read/write */
  22. struct device *dev;
  23. void *private_data;
  24. };
  25. /* Basic operations */
  26. struct c2port_ops {
  27. /* Flash layout */
  28. unsigned short block_size; /* flash block size in bytes */
  29. unsigned short blocks_num; /* flash blocks number */
  30. /* Enable or disable the access to C2 port */
  31. void (*access)(struct c2port_device *dev, int status);
  32. /* Set C2D data line as input/output */
  33. void (*c2d_dir)(struct c2port_device *dev, int dir);
  34. /* Read/write C2D data line */
  35. int (*c2d_get)(struct c2port_device *dev);
  36. void (*c2d_set)(struct c2port_device *dev, int status);
  37. /* Write C2CK clock line */
  38. void (*c2ck_set)(struct c2port_device *dev, int status);
  39. };
  40. /*
  41. * Exported functions
  42. */
  43. extern struct c2port_device *c2port_device_register(char *name,
  44. struct c2port_ops *ops, void *devdata);
  45. extern void c2port_device_unregister(struct c2port_device *dev);