Lines Matching refs:hw
77 #define DMSG(stuff...) do {printk(KERN_DEBUG "hermes @ %p: " , hw->iobase); \
105 static int hermes_issue_cmd(struct hermes *hw, u16 cmd, u16 param0, in hermes_issue_cmd() argument
112 reg = hermes_read_regn(hw, CMD); in hermes_issue_cmd()
116 reg = hermes_read_regn(hw, CMD); in hermes_issue_cmd()
121 hermes_write_regn(hw, PARAM2, param2); in hermes_issue_cmd()
122 hermes_write_regn(hw, PARAM1, param1); in hermes_issue_cmd()
123 hermes_write_regn(hw, PARAM0, param0); in hermes_issue_cmd()
124 hermes_write_regn(hw, CMD, cmd); in hermes_issue_cmd()
134 static int hermes_doicmd_wait(struct hermes *hw, u16 cmd, in hermes_doicmd_wait() argument
142 err = hermes_issue_cmd(hw, cmd, parm0, parm1, parm2); in hermes_doicmd_wait()
146 reg = hermes_read_regn(hw, EVSTAT); in hermes_doicmd_wait()
151 reg = hermes_read_regn(hw, EVSTAT); in hermes_doicmd_wait()
154 hermes_write_regn(hw, SWSUPPORT0, HERMES_MAGIC); in hermes_doicmd_wait()
156 if (!hermes_present(hw)) { in hermes_doicmd_wait()
158 hw->iobase); in hermes_doicmd_wait()
166 hw->iobase, reg); in hermes_doicmd_wait()
171 status = hermes_read_regn(hw, STATUS); in hermes_doicmd_wait()
174 resp->resp0 = hermes_read_regn(hw, RESP0); in hermes_doicmd_wait()
175 resp->resp1 = hermes_read_regn(hw, RESP1); in hermes_doicmd_wait()
176 resp->resp2 = hermes_read_regn(hw, RESP2); in hermes_doicmd_wait()
179 hermes_write_regn(hw, EVACK, HERMES_EV_CMD); in hermes_doicmd_wait()
187 void hermes_struct_init(struct hermes *hw, void __iomem *address, in hermes_struct_init() argument
190 hw->iobase = address; in hermes_struct_init()
191 hw->reg_spacing = reg_spacing; in hermes_struct_init()
192 hw->inten = 0x0; in hermes_struct_init()
193 hw->eeprom_pda = false; in hermes_struct_init()
194 hw->ops = &hermes_ops_local; in hermes_struct_init()
198 static int hermes_init(struct hermes *hw) in hermes_init() argument
205 hw->inten = 0x0; in hermes_init()
206 hermes_write_regn(hw, INTEN, 0); in hermes_init()
207 hermes_write_regn(hw, EVACK, 0xffff); in hermes_init()
216 reg = hermes_read_regn(hw, CMD); in hermes_init()
224 reg = hermes_read_regn(hw, CMD); in hermes_init()
233 reg = hermes_read_regn(hw, EVSTAT); in hermes_init()
234 hermes_write_regn(hw, EVACK, reg); in hermes_init()
238 err = hermes_doicmd_wait(hw, HERMES_CMD_INIT, 0, 0, 0, NULL); in hermes_init()
252 static int hermes_docmd_wait(struct hermes *hw, u16 cmd, u16 parm0, in hermes_docmd_wait() argument
260 err = hermes_issue_cmd(hw, cmd, parm0, 0, 0); in hermes_docmd_wait()
262 if (!hermes_present(hw)) { in hermes_docmd_wait()
266 "0x%04x.\n", hw->iobase, cmd); in hermes_docmd_wait()
272 hw->iobase, err, cmd); in hermes_docmd_wait()
276 reg = hermes_read_regn(hw, EVSTAT); in hermes_docmd_wait()
281 reg = hermes_read_regn(hw, EVSTAT); in hermes_docmd_wait()
284 if (!hermes_present(hw)) { in hermes_docmd_wait()
287 hw->iobase, cmd); in hermes_docmd_wait()
294 "command 0x%04x completion.\n", hw->iobase, cmd); in hermes_docmd_wait()
299 status = hermes_read_regn(hw, STATUS); in hermes_docmd_wait()
302 resp->resp0 = hermes_read_regn(hw, RESP0); in hermes_docmd_wait()
303 resp->resp1 = hermes_read_regn(hw, RESP1); in hermes_docmd_wait()
304 resp->resp2 = hermes_read_regn(hw, RESP2); in hermes_docmd_wait()
307 hermes_write_regn(hw, EVACK, HERMES_EV_CMD); in hermes_docmd_wait()
316 static int hermes_allocate(struct hermes *hw, u16 size, u16 *fid) in hermes_allocate() argument
325 err = hermes_docmd_wait(hw, HERMES_CMD_ALLOC, size, NULL); in hermes_allocate()
329 reg = hermes_read_regn(hw, EVSTAT); in hermes_allocate()
334 reg = hermes_read_regn(hw, EVSTAT); in hermes_allocate()
337 if (!hermes_present(hw)) { in hermes_allocate()
340 hw->iobase); in hermes_allocate()
347 hw->iobase); in hermes_allocate()
351 *fid = hermes_read_regn(hw, ALLOCFID); in hermes_allocate()
352 hermes_write_regn(hw, EVACK, HERMES_EV_ALLOC); in hermes_allocate()
366 static int hermes_bap_seek(struct hermes *hw, int bap, u16 id, u16 offset) in hermes_bap_seek() argument
378 reg = hermes_read_reg(hw, oreg); in hermes_bap_seek()
382 reg = hermes_read_reg(hw, oreg); in hermes_bap_seek()
389 hermes_write_reg(hw, sreg, id); in hermes_bap_seek()
390 hermes_write_reg(hw, oreg, offset); in hermes_bap_seek()
394 reg = hermes_read_reg(hw, oreg); in hermes_bap_seek()
398 reg = hermes_read_reg(hw, oreg); in hermes_bap_seek()
403 "reg=0x%x id=0x%x offset=0x%x\n", hw->iobase, bap, in hermes_bap_seek()
425 static int hermes_bap_pread(struct hermes *hw, int bap, void *buf, int len, in hermes_bap_pread() argument
434 err = hermes_bap_seek(hw, bap, id, offset); in hermes_bap_pread()
439 hermes_read_words(hw, dreg, buf, len / 2); in hermes_bap_pread()
453 static int hermes_bap_pwrite(struct hermes *hw, int bap, const void *buf, in hermes_bap_pwrite() argument
462 err = hermes_bap_seek(hw, bap, id, offset); in hermes_bap_pwrite()
467 hermes_write_bytes(hw, dreg, buf, len); in hermes_bap_pwrite()
481 static int hermes_read_ltv(struct hermes *hw, int bap, u16 rid, in hermes_read_ltv() argument
492 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS, rid, NULL); in hermes_read_ltv()
496 err = hermes_bap_seek(hw, bap, rid, 0); in hermes_read_ltv()
500 rlength = hermes_read_reg(hw, dreg); in hermes_read_ltv()
505 rtype = hermes_read_reg(hw, dreg); in hermes_read_ltv()
513 hw->iobase, __func__, rid, rtype); in hermes_read_ltv()
517 "(rid=0x%04x, len=0x%04x)\n", hw->iobase, in hermes_read_ltv()
521 hermes_read_words(hw, dreg, buf, nwords); in hermes_read_ltv()
526 static int hermes_write_ltv(struct hermes *hw, int bap, u16 rid, in hermes_write_ltv() argument
536 err = hermes_bap_seek(hw, bap, rid, 0); in hermes_write_ltv()
540 hermes_write_reg(hw, dreg, length); in hermes_write_ltv()
541 hermes_write_reg(hw, dreg, rid); in hermes_write_ltv()
545 hermes_write_bytes(hw, dreg, value, count << 1); in hermes_write_ltv()
547 err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS | HERMES_CMD_WRITE, in hermes_write_ltv()
556 hermes_aux_setaddr(struct hermes *hw, u32 addr) in hermes_aux_setaddr() argument
558 hermes_write_reg(hw, HERMES_AUXPAGE, (u16) (addr >> 7)); in hermes_aux_setaddr()
559 hermes_write_reg(hw, HERMES_AUXOFFSET, (u16) (addr & 0x7F)); in hermes_aux_setaddr()
563 hermes_aux_control(struct hermes *hw, int enabled) in hermes_aux_control() argument
570 if (hermes_read_reg(hw, HERMES_CONTROL) == desired_state) in hermes_aux_control()
573 hermes_write_reg(hw, HERMES_PARAM0, HERMES_AUX_PW0); in hermes_aux_control()
574 hermes_write_reg(hw, HERMES_PARAM1, HERMES_AUX_PW1); in hermes_aux_control()
575 hermes_write_reg(hw, HERMES_PARAM2, HERMES_AUX_PW2); in hermes_aux_control()
576 hermes_write_reg(hw, HERMES_CONTROL, action); in hermes_aux_control()
580 if (hermes_read_reg(hw, HERMES_CONTROL) == in hermes_aux_control()
597 static int hermesi_program_init(struct hermes *hw, u32 offset) in hermesi_program_init() argument
607 hermes_write_regn(hw, EVACK, 0xFFFF); in hermesi_program_init()
610 err = hw->ops->init_cmd_wait(hw, in hermesi_program_init()
616 err = hw->ops->init_cmd_wait(hw, in hermesi_program_init()
622 err = hermes_aux_control(hw, 1); in hermesi_program_init()
629 err = hw->ops->init_cmd_wait(hw, in hermesi_program_init()
646 static int hermesi_program_end(struct hermes *hw) in hermesi_program_end() argument
652 rc = hw->ops->cmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp); in hermesi_program_end()
662 err = hermes_aux_control(hw, 0); in hermesi_program_end()
666 hermes_write_regn(hw, EVACK, 0xFFFF); in hermesi_program_end()
669 (void) hw->ops->init_cmd_wait(hw, 0x0000 | HERMES_CMD_INIT, in hermesi_program_end()
675 static int hermes_program_bytes(struct hermes *hw, const char *data, in hermes_program_bytes() argument
681 hermes_aux_setaddr(hw, addr); in hermes_program_bytes()
682 hermes_write_bytes(hw, HERMES_AUXDATA, data, len); in hermes_program_bytes()
687 static int hermes_read_pda(struct hermes *hw, __le16 *pda, u32 pda_addr, in hermes_read_pda() argument
695 if (hw->eeprom_pda) { in hermes_read_pda()
699 ret = hw->ops->cmd_wait(hw, HERMES_CMD_READMIF, 0, NULL); in hermes_read_pda()
714 ret = hermes_aux_control(hw, 1); in hermes_read_pda()
720 hermes_aux_setaddr(hw, pda_addr); in hermes_read_pda()
721 hermes_read_words(hw, HERMES_AUXDATA, data, data_len / 2); in hermes_read_pda()
724 ret = hermes_aux_control(hw, 0); in hermes_read_pda()