Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0-only */
0002 /*
0003  *  Silicon Labs C2 port Linux support
0004  *
0005  *  Copyright (c) 2007 Rodolfo Giometti <giometti@linux.it>
0006  *  Copyright (c) 2007 Eurotech S.p.A. <info@eurotech.it>
0007  */
0008 
0009 #define C2PORT_NAME_LEN         32
0010 
0011 struct device;
0012 
0013 /*
0014  * C2 port basic structs
0015  */
0016 
0017 /* Main struct */
0018 struct c2port_ops;
0019 struct c2port_device {
0020     unsigned int access:1;
0021     unsigned int flash_access:1;
0022 
0023     int id;
0024     char name[C2PORT_NAME_LEN];
0025     struct c2port_ops *ops;
0026     struct mutex mutex;     /* prevent races during read/write */
0027 
0028     struct device *dev;
0029 
0030     void *private_data;
0031 };
0032 
0033 /* Basic operations */
0034 struct c2port_ops {
0035     /* Flash layout */
0036     unsigned short block_size;  /* flash block size in bytes */
0037     unsigned short blocks_num;  /* flash blocks number */
0038 
0039     /* Enable or disable the access to C2 port */
0040     void (*access)(struct c2port_device *dev, int status);
0041 
0042     /* Set C2D data line as input/output */
0043     void (*c2d_dir)(struct c2port_device *dev, int dir);
0044 
0045     /* Read/write C2D data line */
0046     int (*c2d_get)(struct c2port_device *dev);
0047     void (*c2d_set)(struct c2port_device *dev, int status);
0048 
0049     /* Write C2CK clock line */
0050     void (*c2ck_set)(struct c2port_device *dev, int status);
0051 };
0052 
0053 /*
0054  * Exported functions
0055  */
0056 
0057 extern struct c2port_device *c2port_device_register(char *name,
0058                     struct c2port_ops *ops, void *devdata);
0059 extern void c2port_device_unregister(struct c2port_device *dev);