Lines Matching refs:master
88 struct fsi_master master; member
120 #define to_fsi_master_acf(m) container_of(m, struct fsi_master_acf, master)
159 static bool check_same_address(struct fsi_master_acf *master, int id, in check_same_address() argument
163 return master->last_addr == (((id & 0x3) << 21) | (addr & ~0x3)); in check_same_address()
166 static bool check_relative_address(struct fsi_master_acf *master, int id, in check_relative_address() argument
169 uint32_t last_addr = master->last_addr; in check_relative_address()
196 static void last_address_update(struct fsi_master_acf *master, in last_address_update() argument
200 master->last_addr = LAST_ADDR_INVALID; in last_address_update()
202 master->last_addr = ((id & 0x3) << 21) | (addr & ~0x3); in last_address_update()
208 static void build_ar_command(struct fsi_master_acf *master, in build_ar_command() argument
227 if (check_same_address(master, id, addr)) { in build_ar_command()
232 trace_fsi_master_acf_cmd_same_addr(master); in build_ar_command()
234 } else if (check_relative_address(master, id, addr, &rel_addr)) { in build_ar_command()
239 trace_fsi_master_acf_cmd_rel_addr(master, rel_addr); in build_ar_command()
244 trace_fsi_master_acf_cmd_abs_addr(master, addr); in build_ar_command()
307 static int do_copro_command(struct fsi_master_acf *master, uint32_t op) in do_copro_command() argument
312 trace_fsi_master_acf_copro_command(master, op); in do_copro_command()
315 iowrite32be(op, master->sram + CMD_STAT_REG); in do_copro_command()
318 if (master->cvic) in do_copro_command()
319 iowrite32(0x2, master->cvic + CVIC_TRIG_REG); in do_copro_command()
324 dev_warn(master->dev, in do_copro_command()
328 stat = ioread8(master->sram + CMD_STAT_REG); in do_copro_command()
344 static int clock_zeros(struct fsi_master_acf *master, int count) in clock_zeros() argument
349 rc = do_copro_command(master, in clock_zeros()
358 static int send_request(struct fsi_master_acf *master, struct fsi_msg *cmd, in send_request() argument
363 trace_fsi_master_acf_send_request(master, cmd, resp_bits); in send_request()
366 iowrite32be((cmd->msg >> 32), master->sram + CMD_DATA); in send_request()
367 iowrite32be((cmd->msg & 0xffffffff), master->sram + CMD_DATA + 4); in send_request()
374 return do_copro_command(master, op); in send_request()
377 static int read_copro_response(struct fsi_master_acf *master, uint8_t size, in read_copro_response() argument
380 uint8_t rtag = ioread8(master->sram + STAT_RTAG) & 0xf; in read_copro_response()
381 uint8_t rcrc = ioread8(master->sram + STAT_RCRC) & 0xf; in read_copro_response()
392 rdata = ioread32be(master->sram + RSP_DATA); in read_copro_response()
399 trace_fsi_master_acf_copro_response(master, rtag, rcrc, rdata, crc == 0); in read_copro_response()
408 dev_dbg(master->dev, "Bad response CRC !\n"); in read_copro_response()
414 static int send_term(struct fsi_master_acf *master, uint8_t slave) in send_term() argument
422 rc = send_request(master, &cmd, 0); in send_term()
424 dev_warn(master->dev, "Error %d sending term\n", rc); in send_term()
428 rc = read_copro_response(master, 0, NULL, &tag); in send_term()
430 dev_err(master->dev, in send_term()
434 dev_err(master->dev, "TERM failed; response %d\n", tag); in send_term()
440 static void dump_ucode_trace(struct fsi_master_acf *master) in dump_ucode_trace() argument
446 dev_dbg(master->dev, in dump_ucode_trace()
448 ioread32be(master->sram + CMD_STAT_REG), in dump_ucode_trace()
449 ioread8(master->sram + STAT_RTAG), in dump_ucode_trace()
450 ioread8(master->sram + STAT_RCRC), in dump_ucode_trace()
451 ioread32be(master->sram + RSP_DATA), in dump_ucode_trace()
452 ioread32be(master->sram + INT_CNT)); in dump_ucode_trace()
458 v = ioread8(master->sram + TRACEBUF + i); in dump_ucode_trace()
461 dev_dbg(master->dev, "%s\n", trbuf); in dump_ucode_trace()
467 static int handle_response(struct fsi_master_acf *master, in handle_response() argument
476 rc = read_copro_response(master, size, &response, &tag); in handle_response()
489 trace_fsi_master_acf_crc_rsp_error(master, crc_err_retries); in handle_response()
490 if (master->trace_enabled) in handle_response()
491 dump_ucode_trace(master); in handle_response()
492 rc = clock_zeros(master, FSI_MASTER_EPOLL_CLOCKS); in handle_response()
494 dev_warn(master->dev, in handle_response()
499 rc = send_request(master, &cmd, size); in handle_response()
501 dev_warn(master->dev, "Error %d sending E_POLL\n", rc); in handle_response()
526 dev_dbg(master->dev, "Busy, retrying...\n"); in handle_response()
527 if (master->trace_enabled) in handle_response()
528 dump_ucode_trace(master); in handle_response()
529 rc = clock_zeros(master, FSI_MASTER_DPOLL_CLOCKS); in handle_response()
531 dev_warn(master->dev, in handle_response()
537 rc = send_request(master, &cmd, size); in handle_response()
539 dev_warn(master->dev, "Error %d sending D_POLL\n", rc); in handle_response()
544 dev_dbg(master->dev, in handle_response()
546 send_term(master, slave); in handle_response()
551 dev_dbg(master->dev, "ERRA received\n"); in handle_response()
552 if (master->trace_enabled) in handle_response()
553 dump_ucode_trace(master); in handle_response()
557 dev_dbg(master->dev, "ERRC received\n"); in handle_response()
558 if (master->trace_enabled) in handle_response()
559 dump_ucode_trace(master); in handle_response()
565 trace_fsi_master_acf_poll_response_busy(master, busy_count); in handle_response()
571 static int fsi_master_acf_xfer(struct fsi_master_acf *master, uint8_t slave, in fsi_master_acf_xfer() argument
578 rc = send_request(master, cmd, resp_len); in fsi_master_acf_xfer()
581 dev_warn(master->dev, "Error %d sending command\n", rc); in fsi_master_acf_xfer()
584 rc = handle_response(master, slave, resp_len, resp); in fsi_master_acf_xfer()
588 dev_dbg(master->dev, "ECRC retry %d\n", retries); in fsi_master_acf_xfer()
601 struct fsi_master_acf *master = to_fsi_master_acf(_master); in fsi_master_acf_read() local
608 mutex_lock(&master->lock); in fsi_master_acf_read()
609 dev_dbg(master->dev, "read id %d addr %x size %zd\n", id, addr, size); in fsi_master_acf_read()
610 build_ar_command(master, &cmd, id, addr, size, NULL); in fsi_master_acf_read()
611 rc = fsi_master_acf_xfer(master, id, &cmd, size, val); in fsi_master_acf_read()
612 last_address_update(master, id, rc == 0, addr); in fsi_master_acf_read()
614 dev_dbg(master->dev, "read id %d addr 0x%08x err: %d\n", in fsi_master_acf_read()
616 mutex_unlock(&master->lock); in fsi_master_acf_read()
625 struct fsi_master_acf *master = to_fsi_master_acf(_master); in fsi_master_acf_write() local
632 mutex_lock(&master->lock); in fsi_master_acf_write()
633 build_ar_command(master, &cmd, id, addr, size, val); in fsi_master_acf_write()
634 dev_dbg(master->dev, "write id %d addr %x size %zd raw_data: %08x\n", in fsi_master_acf_write()
636 rc = fsi_master_acf_xfer(master, id, &cmd, 0, NULL); in fsi_master_acf_write()
637 last_address_update(master, id, rc == 0, addr); in fsi_master_acf_write()
639 dev_dbg(master->dev, "write id %d addr 0x%08x err: %d\n", in fsi_master_acf_write()
641 mutex_unlock(&master->lock); in fsi_master_acf_write()
649 struct fsi_master_acf *master = to_fsi_master_acf(_master); in fsi_master_acf_term() local
656 mutex_lock(&master->lock); in fsi_master_acf_term()
658 dev_dbg(master->dev, "term id %d\n", id); in fsi_master_acf_term()
659 rc = fsi_master_acf_xfer(master, id, &cmd, 0, NULL); in fsi_master_acf_term()
660 last_address_update(master, id, false, 0); in fsi_master_acf_term()
661 mutex_unlock(&master->lock); in fsi_master_acf_term()
668 struct fsi_master_acf *master = to_fsi_master_acf(_master); in fsi_master_acf_break() local
674 mutex_lock(&master->lock); in fsi_master_acf_break()
675 if (master->external_mode) { in fsi_master_acf_break()
676 mutex_unlock(&master->lock); in fsi_master_acf_break()
679 dev_dbg(master->dev, "sending BREAK\n"); in fsi_master_acf_break()
680 rc = do_copro_command(master, CMD_BREAK); in fsi_master_acf_break()
681 last_address_update(master, 0, false, 0); in fsi_master_acf_break()
682 mutex_unlock(&master->lock); in fsi_master_acf_break()
690 static void reset_cf(struct fsi_master_acf *master) in reset_cf() argument
692 regmap_write(master->scu, SCU_COPRO_CTRL, SCU_COPRO_RESET); in reset_cf()
694 regmap_write(master->scu, SCU_COPRO_CTRL, 0); in reset_cf()
698 static void start_cf(struct fsi_master_acf *master) in start_cf() argument
700 regmap_write(master->scu, SCU_COPRO_CTRL, SCU_COPRO_CLK_EN); in start_cf()
703 static void setup_ast2500_cf_maps(struct fsi_master_acf *master) in setup_ast2500_cf_maps() argument
722 regmap_write(master->scu, SCU_2500_COPRO_SEG0, master->cf_mem_addr | in setup_ast2500_cf_maps()
726 regmap_write(master->scu, SCU_2500_COPRO_SEG2, SYSREG_BASE | in setup_ast2500_cf_maps()
728 regmap_write(master->scu, SCU_2500_COPRO_SEG3, SYSREG_BASE | 0x100000 | in setup_ast2500_cf_maps()
732 regmap_write(master->scu, SCU_2500_COPRO_SEG6, SYSREG_BASE); in setup_ast2500_cf_maps()
733 regmap_write(master->scu, SCU_2500_COPRO_SEG7, SYSREG_BASE | 0x100000); in setup_ast2500_cf_maps()
736 regmap_write(master->scu, SCU_2500_COPRO_CACHE_CTL, in setup_ast2500_cf_maps()
740 static void setup_ast2400_cf_maps(struct fsi_master_acf *master) in setup_ast2400_cf_maps() argument
743 regmap_write(master->scu, SCU_2400_COPRO_SEG0, master->cf_mem_addr | in setup_ast2400_cf_maps()
747 regmap_write(master->scu, SCU_2400_COPRO_SEG2, SYSREG_BASE | in setup_ast2400_cf_maps()
751 regmap_write(master->scu, SCU_2400_COPRO_SEG6, SYSREG_BASE); in setup_ast2400_cf_maps()
754 regmap_write(master->scu, SCU_2400_COPRO_CACHE_CTL, in setup_ast2400_cf_maps()
758 static void setup_common_fw_config(struct fsi_master_acf *master, in setup_common_fw_config() argument
761 iowrite16be(master->gpio_clk_vreg, base + HDR_CLOCK_GPIO_VADDR); in setup_common_fw_config()
762 iowrite16be(master->gpio_clk_dreg, base + HDR_CLOCK_GPIO_DADDR); in setup_common_fw_config()
763 iowrite16be(master->gpio_dat_vreg, base + HDR_DATA_GPIO_VADDR); in setup_common_fw_config()
764 iowrite16be(master->gpio_dat_dreg, base + HDR_DATA_GPIO_DADDR); in setup_common_fw_config()
765 iowrite16be(master->gpio_tra_vreg, base + HDR_TRANS_GPIO_VADDR); in setup_common_fw_config()
766 iowrite16be(master->gpio_tra_dreg, base + HDR_TRANS_GPIO_DADDR); in setup_common_fw_config()
767 iowrite8(master->gpio_clk_bit, base + HDR_CLOCK_GPIO_BIT); in setup_common_fw_config()
768 iowrite8(master->gpio_dat_bit, base + HDR_DATA_GPIO_BIT); in setup_common_fw_config()
769 iowrite8(master->gpio_tra_bit, base + HDR_TRANS_GPIO_BIT); in setup_common_fw_config()
772 static void setup_ast2500_fw_config(struct fsi_master_acf *master) in setup_ast2500_fw_config() argument
774 void __iomem *base = master->cf_mem + HDR_OFFSET; in setup_ast2500_fw_config()
776 setup_common_fw_config(master, base); in setup_ast2500_fw_config()
780 static void setup_ast2400_fw_config(struct fsi_master_acf *master) in setup_ast2400_fw_config() argument
782 void __iomem *base = master->cf_mem + HDR_OFFSET; in setup_ast2400_fw_config()
784 setup_common_fw_config(master, base); in setup_ast2400_fw_config()
788 static int setup_gpios_for_copro(struct fsi_master_acf *master) in setup_gpios_for_copro() argument
794 gpiod_direction_output(master->gpio_mux, 1); in setup_gpios_for_copro()
795 gpiod_direction_output(master->gpio_enable, 1); in setup_gpios_for_copro()
798 rc = aspeed_gpio_copro_grab_gpio(master->gpio_clk, &master->gpio_clk_vreg, in setup_gpios_for_copro()
799 &master->gpio_clk_dreg, &master->gpio_clk_bit); in setup_gpios_for_copro()
801 dev_err(master->dev, "failed to assign clock gpio to coprocessor\n"); in setup_gpios_for_copro()
804 rc = aspeed_gpio_copro_grab_gpio(master->gpio_data, &master->gpio_dat_vreg, in setup_gpios_for_copro()
805 &master->gpio_dat_dreg, &master->gpio_dat_bit); in setup_gpios_for_copro()
807 dev_err(master->dev, "failed to assign data gpio to coprocessor\n"); in setup_gpios_for_copro()
808 aspeed_gpio_copro_release_gpio(master->gpio_clk); in setup_gpios_for_copro()
811 rc = aspeed_gpio_copro_grab_gpio(master->gpio_trans, &master->gpio_tra_vreg, in setup_gpios_for_copro()
812 &master->gpio_tra_dreg, &master->gpio_tra_bit); in setup_gpios_for_copro()
814 dev_err(master->dev, "failed to assign trans gpio to coprocessor\n"); in setup_gpios_for_copro()
815 aspeed_gpio_copro_release_gpio(master->gpio_clk); in setup_gpios_for_copro()
816 aspeed_gpio_copro_release_gpio(master->gpio_data); in setup_gpios_for_copro()
822 static void release_copro_gpios(struct fsi_master_acf *master) in release_copro_gpios() argument
824 aspeed_gpio_copro_release_gpio(master->gpio_clk); in release_copro_gpios()
825 aspeed_gpio_copro_release_gpio(master->gpio_data); in release_copro_gpios()
826 aspeed_gpio_copro_release_gpio(master->gpio_trans); in release_copro_gpios()
829 static int load_copro_firmware(struct fsi_master_acf *master) in load_copro_firmware() argument
838 rc = request_firmware(&fw, FW_FILE_NAME, master->dev); in load_copro_firmware()
841 master->dev, "Error %d to load firmware '%s' !\n", in load_copro_firmware()
847 if (master->gpio_clk_vreg == master->gpio_dat_vreg) in load_copro_firmware()
851 dev_dbg(master->dev, "Looking for image sig %04x\n", wanted_sig); in load_copro_firmware()
862 dev_err(master->dev, "Failed to locate image sig %04x in FW blob\n", in load_copro_firmware()
867 if (size > master->cf_mem_size) { in load_copro_firmware()
868 dev_err(master->dev, "FW size (%zd) bigger than memory reserve (%zd)\n", in load_copro_firmware()
869 fw->size, master->cf_mem_size); in load_copro_firmware()
872 memcpy_toio(master->cf_mem, data, size); in load_copro_firmware()
880 static int check_firmware_image(struct fsi_master_acf *master) in check_firmware_image() argument
884 fw_vers = ioread16be(master->cf_mem + HDR_OFFSET + HDR_FW_VERS); in check_firmware_image()
885 fw_api = ioread16be(master->cf_mem + HDR_OFFSET + HDR_API_VERS); in check_firmware_image()
886 fw_options = ioread32be(master->cf_mem + HDR_OFFSET + HDR_FW_OPTIONS); in check_firmware_image()
887 master->trace_enabled = !!(fw_options & FW_OPTION_TRACE_EN); in check_firmware_image()
890 dev_info(master->dev, "ColdFire initialized, firmware v%d API v%d.%d (trace %s)\n", in check_firmware_image()
892 master->trace_enabled ? "enabled" : "disabled"); in check_firmware_image()
895 dev_err(master->dev, "Unsupported coprocessor API version !\n"); in check_firmware_image()
902 static int copro_enable_sw_irq(struct fsi_master_acf *master) in copro_enable_sw_irq() argument
912 iowrite32(0x2, master->cvic + CVIC_EN_REG); in copro_enable_sw_irq()
913 val = ioread32(master->cvic + CVIC_EN_REG); in copro_enable_sw_irq()
919 dev_err(master->dev, "Failed to enable coprocessor interrupt !\n"); in copro_enable_sw_irq()
925 static int fsi_master_acf_setup(struct fsi_master_acf *master) in fsi_master_acf_setup() argument
931 reset_cf(master); in fsi_master_acf_setup()
937 memset_io(master->sram, 0, SRAM_SIZE); in fsi_master_acf_setup()
940 rc = setup_gpios_for_copro(master); in fsi_master_acf_setup()
945 rc = load_copro_firmware(master); in fsi_master_acf_setup()
950 rc = check_firmware_image(master); in fsi_master_acf_setup()
955 if (master->is_ast2500) { in fsi_master_acf_setup()
956 setup_ast2500_cf_maps(master); in fsi_master_acf_setup()
957 setup_ast2500_fw_config(master); in fsi_master_acf_setup()
959 setup_ast2400_cf_maps(master); in fsi_master_acf_setup()
960 setup_ast2400_fw_config(master); in fsi_master_acf_setup()
964 start_cf(master); in fsi_master_acf_setup()
970 val = ioread8(master->sram + CF_STARTED); in fsi_master_acf_setup()
976 dev_err(master->dev, "Coprocessor startup timeout !\n"); in fsi_master_acf_setup()
982 iowrite8(master->t_send_delay, master->sram + SEND_DLY_REG); in fsi_master_acf_setup()
983 iowrite8(master->t_echo_delay, master->sram + ECHO_DLY_REG); in fsi_master_acf_setup()
986 if (master->cvic) { in fsi_master_acf_setup()
987 rc = copro_enable_sw_irq(master); in fsi_master_acf_setup()
994 reset_cf(master); in fsi_master_acf_setup()
997 release_copro_gpios(master); in fsi_master_acf_setup()
1003 static void fsi_master_acf_terminate(struct fsi_master_acf *master) in fsi_master_acf_terminate() argument
1016 reset_cf(master); in fsi_master_acf_terminate()
1019 iowrite32(0, master->sram + CF_STARTED); in fsi_master_acf_terminate()
1024 iowrite8(ARB_ARM_ACK, master->sram + ARB_REG); in fsi_master_acf_terminate()
1029 release_copro_gpios(master); in fsi_master_acf_terminate()
1032 static void fsi_master_acf_setup_external(struct fsi_master_acf *master) in fsi_master_acf_setup_external() argument
1035 gpiod_direction_output(master->gpio_mux, 0); in fsi_master_acf_setup_external()
1036 gpiod_direction_output(master->gpio_trans, 0); in fsi_master_acf_setup_external()
1037 gpiod_direction_output(master->gpio_enable, 1); in fsi_master_acf_setup_external()
1038 gpiod_direction_input(master->gpio_clk); in fsi_master_acf_setup_external()
1039 gpiod_direction_input(master->gpio_data); in fsi_master_acf_setup_external()
1045 struct fsi_master_acf *master = to_fsi_master_acf(_master); in fsi_master_acf_link_enable() local
1051 mutex_lock(&master->lock); in fsi_master_acf_link_enable()
1052 if (!master->external_mode) { in fsi_master_acf_link_enable()
1053 gpiod_set_value(master->gpio_enable, enable ? 1 : 0); in fsi_master_acf_link_enable()
1056 mutex_unlock(&master->lock); in fsi_master_acf_link_enable()
1064 struct fsi_master_acf *master = to_fsi_master_acf(_master); in fsi_master_acf_link_config() local
1069 mutex_lock(&master->lock); in fsi_master_acf_link_config()
1070 master->t_send_delay = t_send_delay; in fsi_master_acf_link_config()
1071 master->t_echo_delay = t_echo_delay; in fsi_master_acf_link_config()
1072 dev_dbg(master->dev, "Changing delays: send=%d echo=%d\n", in fsi_master_acf_link_config()
1074 iowrite8(master->t_send_delay, master->sram + SEND_DLY_REG); in fsi_master_acf_link_config()
1075 iowrite8(master->t_echo_delay, master->sram + ECHO_DLY_REG); in fsi_master_acf_link_config()
1076 mutex_unlock(&master->lock); in fsi_master_acf_link_config()
1084 struct fsi_master_acf *master = dev_get_drvdata(dev); in external_mode_show() local
1087 master->external_mode ? 1 : 0); in external_mode_show()
1093 struct fsi_master_acf *master = dev_get_drvdata(dev); in external_mode_store() local
1104 mutex_lock(&master->lock); in external_mode_store()
1106 if (external_mode == master->external_mode) { in external_mode_store()
1107 mutex_unlock(&master->lock); in external_mode_store()
1111 master->external_mode = external_mode; in external_mode_store()
1112 if (master->external_mode) { in external_mode_store()
1113 fsi_master_acf_terminate(master); in external_mode_store()
1114 fsi_master_acf_setup_external(master); in external_mode_store()
1116 fsi_master_acf_setup(master); in external_mode_store()
1118 mutex_unlock(&master->lock); in external_mode_store()
1120 fsi_master_rescan(&master->master); in external_mode_store()
1130 struct fsi_master_acf *master = data; in fsi_master_acf_gpio_request() local
1137 iowrite8(ARB_ARM_REQ, master->sram + ARB_REG); in fsi_master_acf_gpio_request()
1151 if (ioread32(master->sram + CF_STARTED) == 0) { in fsi_master_acf_gpio_request()
1154 regmap_read(master->scu, SCU_COPRO_CTRL, ®); in fsi_master_acf_gpio_request()
1160 if (master->cvic) in fsi_master_acf_gpio_request()
1161 iowrite32(0x2, master->cvic + CVIC_TRIG_REG); in fsi_master_acf_gpio_request()
1164 val = ioread8(master->sram + ARB_REG); in fsi_master_acf_gpio_request()
1172 dev_warn(master->dev, "GPIO request arbitration timeout\n"); in fsi_master_acf_gpio_request()
1179 struct fsi_master_acf *master = data; in fsi_master_acf_gpio_release() local
1182 iowrite8(0, master->sram + ARB_REG); in fsi_master_acf_gpio_release()
1185 if (master->cvic) in fsi_master_acf_gpio_release()
1186 iowrite32(0x2, master->cvic + CVIC_TRIG_REG); in fsi_master_acf_gpio_release()
1193 struct fsi_master_acf *master = to_fsi_master_acf(to_fsi_master(dev)); in fsi_master_acf_release() local
1196 mutex_lock(&master->lock); in fsi_master_acf_release()
1197 fsi_master_acf_terminate(master); in fsi_master_acf_release()
1199 mutex_unlock(&master->lock); in fsi_master_acf_release()
1202 gen_pool_free(master->sram_pool, (unsigned long)master->sram, SRAM_SIZE); in fsi_master_acf_release()
1203 of_node_put(dev_of_node(master->dev)); in fsi_master_acf_release()
1205 kfree(master); in fsi_master_acf_release()
1217 struct fsi_master_acf *master; in fsi_master_acf_probe() local
1223 master = kzalloc(sizeof(*master), GFP_KERNEL); in fsi_master_acf_probe()
1224 if (!master) in fsi_master_acf_probe()
1227 master->dev = &pdev->dev; in fsi_master_acf_probe()
1228 master->master.dev.parent = master->dev; in fsi_master_acf_probe()
1229 master->last_addr = LAST_ADDR_INVALID; in fsi_master_acf_probe()
1232 master->is_ast2500 = of_device_is_compatible(mnode, "aspeed,ast2500-cf-fsi-master"); in fsi_master_acf_probe()
1235 if (master->is_ast2500) in fsi_master_acf_probe()
1236 master->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2500-scu"); in fsi_master_acf_probe()
1238 master->scu = syscon_regmap_lookup_by_compatible("aspeed,ast2400-scu"); in fsi_master_acf_probe()
1239 if (IS_ERR(master->scu)) { in fsi_master_acf_probe()
1241 rc = PTR_ERR(master->scu); in fsi_master_acf_probe()
1252 master->gpio_clk = gpio; in fsi_master_acf_probe()
1260 master->gpio_data = gpio; in fsi_master_acf_probe()
1269 master->gpio_trans = gpio; in fsi_master_acf_probe()
1277 master->gpio_enable = gpio; in fsi_master_acf_probe()
1285 master->gpio_mux = gpio; in fsi_master_acf_probe()
1301 master->cf_mem_size = resource_size(&res); in fsi_master_acf_probe()
1302 master->cf_mem_addr = (uint32_t)res.start; in fsi_master_acf_probe()
1303 cf_mem_align = master->is_ast2500 ? 0x00100000 : 0x00200000; in fsi_master_acf_probe()
1304 if (master->cf_mem_addr & (cf_mem_align - 1)) { in fsi_master_acf_probe()
1309 master->cf_mem = devm_ioremap_resource(&pdev->dev, &res); in fsi_master_acf_probe()
1310 if (IS_ERR(master->cf_mem)) { in fsi_master_acf_probe()
1311 rc = PTR_ERR(master->cf_mem); in fsi_master_acf_probe()
1314 dev_dbg(&pdev->dev, "DRAM allocation @%x\n", master->cf_mem_addr); in fsi_master_acf_probe()
1317 if (master->is_ast2500) { in fsi_master_acf_probe()
1325 master->cvic = devm_of_iomap(&pdev->dev, np, 0, NULL); in fsi_master_acf_probe()
1326 if (IS_ERR(master->cvic)) { in fsi_master_acf_probe()
1328 rc = PTR_ERR(master->cvic); in fsi_master_acf_probe()
1333 &master->cvic_sw_irq); in fsi_master_acf_probe()
1342 master->sram_pool = of_gen_pool_get(dev_of_node(&pdev->dev), "aspeed,sram", 0); in fsi_master_acf_probe()
1343 if (!master->sram_pool) { in fsi_master_acf_probe()
1351 master->sram = (void __iomem *)gen_pool_alloc_algo(master->sram_pool, SRAM_SIZE, in fsi_master_acf_probe()
1353 if (!master->sram) { in fsi_master_acf_probe()
1359 (unsigned long)gen_pool_virt_to_phys(master->sram_pool, in fsi_master_acf_probe()
1360 (unsigned long)master->sram)); in fsi_master_acf_probe()
1366 aspeed_gpio_copro_set_ops(&fsi_master_acf_gpio_ops, master); in fsi_master_acf_probe()
1369 master->t_send_delay = FSI_SEND_DELAY_CLOCKS; in fsi_master_acf_probe()
1370 master->t_echo_delay = FSI_ECHO_DELAY_CLOCKS; in fsi_master_acf_probe()
1371 master->master.n_links = 1; in fsi_master_acf_probe()
1372 if (master->is_ast2500) in fsi_master_acf_probe()
1373 master->master.flags = FSI_MASTER_FLAG_SWCLOCK; in fsi_master_acf_probe()
1374 master->master.read = fsi_master_acf_read; in fsi_master_acf_probe()
1375 master->master.write = fsi_master_acf_write; in fsi_master_acf_probe()
1376 master->master.term = fsi_master_acf_term; in fsi_master_acf_probe()
1377 master->master.send_break = fsi_master_acf_break; in fsi_master_acf_probe()
1378 master->master.link_enable = fsi_master_acf_link_enable; in fsi_master_acf_probe()
1379 master->master.link_config = fsi_master_acf_link_config; in fsi_master_acf_probe()
1380 master->master.dev.of_node = of_node_get(dev_of_node(master->dev)); in fsi_master_acf_probe()
1381 master->master.dev.release = fsi_master_acf_release; in fsi_master_acf_probe()
1382 platform_set_drvdata(pdev, master); in fsi_master_acf_probe()
1383 mutex_init(&master->lock); in fsi_master_acf_probe()
1385 mutex_lock(&master->lock); in fsi_master_acf_probe()
1386 rc = fsi_master_acf_setup(master); in fsi_master_acf_probe()
1387 mutex_unlock(&master->lock); in fsi_master_acf_probe()
1395 rc = fsi_master_register(&master->master); in fsi_master_acf_probe()
1399 device_remove_file(master->dev, &dev_attr_external_mode); in fsi_master_acf_probe()
1400 put_device(&master->master.dev); in fsi_master_acf_probe()
1404 fsi_master_acf_terminate(master); in fsi_master_acf_probe()
1407 gen_pool_free(master->sram_pool, (unsigned long)master->sram, SRAM_SIZE); in fsi_master_acf_probe()
1408 of_node_put(dev_of_node(master->dev)); in fsi_master_acf_probe()
1410 kfree(master); in fsi_master_acf_probe()
1417 struct fsi_master_acf *master = platform_get_drvdata(pdev); in fsi_master_acf_remove() local
1419 device_remove_file(master->dev, &dev_attr_external_mode); in fsi_master_acf_remove()
1421 fsi_master_unregister(&master->master); in fsi_master_acf_remove()