X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/3a2bb63f0bb8de2aafb346b53b945c59b3f87a41..1b6d7503d59302cc11198b5cbb001c19a45abc9e:/lincan/include/main.h diff --git a/lincan/include/main.h b/lincan/include/main.h index 4860694..99a493d 100644 --- a/lincan/include/main.h +++ b/lincan/include/main.h @@ -74,13 +74,14 @@ struct candevice_t { char *hwname; /* text board type */ int candev_idx; /* board index in canhardware_t.candevice[] */ unsigned long io_addr; /* IO/physical MEM address */ - unsigned long res_addr; /* optional seset register port */ + unsigned long res_addr; /* optional reset register port */ unsigned long dev_base_addr; /* CPU translated IO/virtual MEM address */ unsigned int flags; int nr_all_chips; int nr_82527_chips; int nr_sja1000_chips; - struct chip_t *chip[MAX_HW_CHIPS]; + can_spinlock_t device_lock; + struct canchip_t *chip[MAX_HW_CHIPS]; struct hwspecops_t *hwspecops; @@ -96,7 +97,7 @@ struct candevice_t { }; /** - * struct chip_t - CAN chip state and type information + * struct canchip_t - CAN chip state and type information * @chip_type: text string describing chip type * @chip_idx: index of the chip in candevice_t.chip[] array * @chip_irq: chip interrupt number if any @@ -149,7 +150,7 @@ struct candevice_t { * chip->hostdevice->hwspecops->read_register) * to speedup can_write_reg() and can_read_reg() functions. */ -struct chip_t { +struct canchip_t { char *chip_type; int chip_idx; /* chip index in candevice_t.chip[] */ int chip_irq; @@ -189,7 +190,7 @@ struct chip_t { * struct msgobj_t - structure holding communication object state * @obj_base_addr: * @minor: associated device minor number - * @object: object number in chip_t structure +1 + * @object: object number in canchip_t structure +1 * @flags: message object flags * @ret: field holding status of the last Tx operation * @qends: pointer to message object corresponding ends structure @@ -201,7 +202,7 @@ struct chip_t { * @tx_timeout: can be used by chip driver to check for the transmission timeout * @rx_msg: temporary storage to hold received messages before * calling to canque_filter_msg2edges() - * @hostchip: pointer to the &chip_t structure this object belongs to + * @hostchip: pointer to the &canchip_t structure this object belongs to * @obj_used: counter of users (associated file structures for Linux * userspace clients) of this object * @obj_users: list of user structures of type &canuser_t. @@ -215,7 +216,7 @@ struct chip_t { struct msgobj_t { unsigned long obj_base_addr; unsigned int minor; /* associated device minor number */ - unsigned int object; /* object number in chip_t +1 for debug printk */ + unsigned int object; /* object number in canchip_t +1 for debug printk */ unsigned long obj_flags; int ret; @@ -228,7 +229,7 @@ struct msgobj_t { struct canmsg_t rx_msg; - struct chip_t *hostchip; + struct canchip_t *hostchip; unsigned long rx_preconfig_id; @@ -278,9 +279,9 @@ struct canuser_t { * @init_hw_data: called to initialize &candevice_t structure, mainly * @res_add, @nr_all_chips, @nr_82527_chips, @nr_sja1000_chips * and @flags fields - * @init_chip_data: called initialize each &chip_t structure, mainly + * @init_chip_data: called initialize each &canchip_t structure, mainly * @chip_type, @chip_base_addr, @clock and chip specific registers. - * It is responsible to setup &chip_t->@chipspecops functions + * It is responsible to setup &canchip_t->@chipspecops functions * for non-standard chip types (type other than "i82527", "sja1000" or "sja1000p") * @init_obj_data: called initialize each &msgobj_t structure, * mainly @obj_base_addr field. @@ -295,7 +296,7 @@ struct hwspecops_t { int (*reset)(struct candevice_t *candev); int (*init_hw_data)(struct candevice_t *candev); int (*init_chip_data)(struct candevice_t *candev, int chipnr); - int (*init_obj_data)(struct chip_t *chip, int objnr); + int (*init_obj_data)(struct canchip_t *chip, int objnr); int (*program_irq)(struct candevice_t *candev); void (*write_register)(unsigned data,unsigned long address); unsigned (*read_register)(unsigned long address); @@ -320,38 +321,44 @@ struct hwspecops_t { * @enable_configuration: enable chip configuration mode * @disable_configuration: disable chip configuration mode * @set_btregs: configures bitrate registers + * @attach_to_chip: attaches to the chip, setups registers and possibly state informations + * @release_chip: called before chip structure removal if %CHIP_ATTACHED is set * @start_chip: starts chip message processing * @stop_chip: stops chip message processing * @irq_handler: interrupt service routine + * @irq_accept: optional fast irq accept routine responsible for blocking further interrupts */ struct chipspecops_t { - int (*chip_config)(struct chip_t *chip); - int (*baud_rate)(struct chip_t *chip, int rate, int clock, int sjw, + int (*chip_config)(struct canchip_t *chip); + int (*baud_rate)(struct canchip_t *chip, int rate, int clock, int sjw, int sampl_pt, int flags); - int (*standard_mask)(struct chip_t *chip, unsigned short code, + int (*standard_mask)(struct canchip_t *chip, unsigned short code, unsigned short mask); - int (*extended_mask)(struct chip_t *chip, unsigned long code, + int (*extended_mask)(struct canchip_t *chip, unsigned long code, unsigned long mask); - int (*message15_mask)(struct chip_t *chip, unsigned long code, + int (*message15_mask)(struct canchip_t *chip, unsigned long code, unsigned long mask); - int (*clear_objects)(struct chip_t *chip); - int (*config_irqs)(struct chip_t *chip, short irqs); - int (*pre_read_config)(struct chip_t *chip, struct msgobj_t *obj); - int (*pre_write_config)(struct chip_t *chip, struct msgobj_t *obj, + int (*clear_objects)(struct canchip_t *chip); + int (*config_irqs)(struct canchip_t *chip, short irqs); + int (*pre_read_config)(struct canchip_t *chip, struct msgobj_t *obj); + int (*pre_write_config)(struct canchip_t *chip, struct msgobj_t *obj, struct canmsg_t *msg); - int (*send_msg)(struct chip_t *chip, struct msgobj_t *obj, + int (*send_msg)(struct canchip_t *chip, struct msgobj_t *obj, struct canmsg_t *msg); - int (*remote_request)(struct chip_t *chip, struct msgobj_t *obj); - int (*check_tx_stat)(struct chip_t *chip); - int (*wakeup_tx)(struct chip_t *chip, struct msgobj_t *obj); - int (*filtch_rq)(struct chip_t *chip, struct msgobj_t *obj); - int (*enable_configuration)(struct chip_t *chip); - int (*disable_configuration)(struct chip_t *chip); - int (*set_btregs)(struct chip_t *chip, unsigned short btr0, + int (*remote_request)(struct canchip_t *chip, struct msgobj_t *obj); + int (*check_tx_stat)(struct canchip_t *chip); + int (*wakeup_tx)(struct canchip_t *chip, struct msgobj_t *obj); + int (*filtch_rq)(struct canchip_t *chip, struct msgobj_t *obj); + int (*enable_configuration)(struct canchip_t *chip); + int (*disable_configuration)(struct canchip_t *chip); + int (*set_btregs)(struct canchip_t *chip, unsigned short btr0, unsigned short btr1); - int (*start_chip)(struct chip_t *chip); - int (*stop_chip)(struct chip_t *chip); - can_irqreturn_t (*irq_handler)(int irq, void *dev_id, struct pt_regs *regs); + int (*attach_to_chip)(struct canchip_t *chip); + int (*release_chip)(struct canchip_t *chip); + int (*start_chip)(struct canchip_t *chip); + int (*stop_chip)(struct canchip_t *chip); + int (*irq_handler)(int irq, struct canchip_t *chip); + int (*irq_accept)(int irq, struct canchip_t *chip); }; struct mem_addr { @@ -378,47 +385,47 @@ extern unsigned long io[MAX_HW_CARDS]; extern int processlocal; extern struct canhardware_t *hardware_p; -extern struct chip_t *chips_p[MAX_TOT_CHIPS]; +extern struct canchip_t *chips_p[MAX_TOT_CHIPS]; extern struct msgobj_t *objects_p[MAX_TOT_MSGOBJS]; extern struct mem_addr *mem_head; #if defined(CONFIG_OC_LINCAN_PORTIO_ONLY) -extern inline void can_write_reg(const struct chip_t *chip, unsigned char data, unsigned address) +extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned address) { outb(data, chip->chip_base_addr+address); } -extern inline unsigned can_read_reg(const struct chip_t *chip, unsigned address) +extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned address) { return inb(chip->chip_base_addr+address); } -extern inline void canobj_write_reg(const struct chip_t *chip, const struct msgobj_t *obj, +extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj, unsigned char data, unsigned address) { outb(data, obj->obj_base_addr+address); } -extern inline unsigned canobj_read_reg(const struct chip_t *chip, const struct msgobj_t *obj, +extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj, unsigned address) { return inb(obj->obj_base_addr+address); } #elif defined(CONFIG_OC_LINCAN_MEMIO_ONLY) -extern inline void can_write_reg(const struct chip_t *chip, unsigned char data, unsigned address) +extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned address) { writeb(data, chip->chip_base_addr+address); } -extern inline unsigned can_read_reg(const struct chip_t *chip, unsigned address) +extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned address) { return readb(chip->chip_base_addr+address); } -extern inline void canobj_write_reg(const struct chip_t *chip, const struct msgobj_t *obj, +extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj, unsigned char data, unsigned address) { writeb(data, obj->obj_base_addr+address); } -extern inline unsigned canobj_read_reg(const struct chip_t *chip, const struct msgobj_t *obj, +extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj, unsigned address) { return readb(obj->obj_base_addr+address); @@ -432,21 +439,21 @@ extern inline unsigned canobj_read_reg(const struct chip_t *chip, const struct m /* Inline function to write to the hardware registers. The argument address is * relative to the memory map of the chip and not the absolute memory address. */ -extern inline void can_write_reg(const struct chip_t *chip, unsigned char data, unsigned address) +extern inline void can_write_reg(const struct canchip_t *chip, unsigned char data, unsigned address) { unsigned long address_to_write; address_to_write = chip->chip_base_addr+address; chip->write_register(data, address_to_write); } -extern inline unsigned can_read_reg(const struct chip_t *chip, unsigned address) +extern inline unsigned can_read_reg(const struct canchip_t *chip, unsigned address) { unsigned long address_to_read; address_to_read = chip->chip_base_addr+address; return chip->read_register(address_to_read); } -extern inline void canobj_write_reg(const struct chip_t *chip, const struct msgobj_t *obj, +extern inline void canobj_write_reg(const struct canchip_t *chip, const struct msgobj_t *obj, unsigned char data, unsigned address) { unsigned long address_to_write; @@ -454,7 +461,7 @@ extern inline void canobj_write_reg(const struct chip_t *chip, const struct msgo chip->write_register(data, address_to_write); } -extern inline unsigned canobj_read_reg(const struct chip_t *chip, const struct msgobj_t *obj, +extern inline unsigned canobj_read_reg(const struct canchip_t *chip, const struct msgobj_t *obj, unsigned address) { unsigned long address_to_read;