Lines Matching +full:device +full:- +full:sram
1 // SPDX-License-Identifier: GPL-2.0+
9 #include <linux/device.h>
25 #include "fsi-master.h"
26 #include "cf-fsi-fw.h"
28 #define FW_FILE_NAME "cf-fsi-fw.bin"
82 /* Amount of SRAM required */
89 struct device *dev;
111 void __iomem *sram; member
132 msg->msg <<= bits; in msg_push_bits()
133 msg->msg |= data & ((1ull << bits) - 1); in msg_push_bits()
134 msg->bits += bits; in msg_push_bits()
142 top = msg->bits & 0x3; in msg_push_crc()
144 /* start bit, and any non-aligned top bits */ in msg_push_crc()
145 crc = crc4(0, 1 << top | msg->msg >> (msg->bits - top), top + 1); in msg_push_crc()
148 crc = crc4(crc, msg->msg, msg->bits - top); in msg_push_crc()
156 cmd->msg <<= (64 - cmd->bits); in msg_finish_cmd()
163 return master->last_addr == (((id & 0x3) << 21) | (addr & ~0x3)); in check_same_address()
169 uint32_t last_addr = master->last_addr; in check_relative_address()
175 /* We may be in 23-bit addressing mode, which uses the id as the in check_relative_address()
182 /* remove the top two bits from any 23-bit addressing */ in check_relative_address()
183 last_addr &= (1 << 21) - 1; in check_relative_address()
187 rel_addr = addr - last_addr; in check_relative_address()
188 if (rel_addr > 255 || rel_addr < -256) in check_relative_address()
200 master->last_addr = LAST_ADDR_INVALID; in last_address_update()
202 master->last_addr = ((id & 0x3) << 21) | (addr & ~0x3); in last_address_update()
218 cmd->bits = 0; in build_ar_command()
219 cmd->msg = 0; in build_ar_command()
222 addr &= ((1 << 21) - 1); in build_ar_command()
224 /* cmd opcodes are variable length - SAME_AR is only two bits */ in build_ar_command()
249 * (as it must be naturally-aligned), and the following ds bit. in build_ar_command()
258 addr &= ~(size - 1); in build_ar_command()
276 cmd->bits = 0; in build_dpoll_command()
277 cmd->msg = 0; in build_dpoll_command()
287 cmd->bits = 0; in build_epoll_command()
288 cmd->msg = 0; in build_epoll_command()
298 cmd->bits = 0; in build_term_command()
299 cmd->msg = 0; in build_term_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()
323 if (timeout-- == 0) { in do_copro_command()
324 dev_warn(master->dev, in do_copro_command()
326 return -ETIMEDOUT; in do_copro_command()
328 stat = ioread8(master->sram + CMD_STAT_REG); in do_copro_command()
335 return -EINVAL; in do_copro_command()
337 return -EIO; in do_copro_command()
339 return -ESHUTDOWN; in do_copro_command()
341 return -ENXIO; in do_copro_command()
353 count -= lcnt; in clock_zeros()
365 /* Store message into SRAM */ 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()
370 op |= cmd->bits << CMD_REG_CLEN_SHIFT; in send_request()
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()
407 return -ENODEV; in read_copro_response()
408 dev_dbg(master->dev, "Bad response CRC !\n"); in read_copro_response()
409 return -EAGAIN; in read_copro_response()
424 dev_warn(master->dev, "Error %d sending term\n", rc); in send_term()
430 dev_err(master->dev, in send_term()
432 return -EIO; in send_term()
434 dev_err(master->dev, "TERM failed; response %d\n", tag); in send_term()
435 return -EIO; in send_term()
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()
479 if (rc == -EAGAIN) { in handle_response()
483 * Pass it up as a -EIO otherwise upper level will retry in handle_response()
486 rc = -EIO; in handle_response()
490 if (master->trace_enabled) in handle_response()
494 dev_warn(master->dev, in handle_response()
501 dev_warn(master->dev, "Error %d sending E_POLL\n", rc); in handle_response()
502 return -EIO; in handle_response()
523 * d-poll, not indicated in the hardware protocol in handle_response()
526 dev_dbg(master->dev, "Busy, retrying...\n"); in handle_response()
527 if (master->trace_enabled) in handle_response()
531 dev_warn(master->dev, 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()
547 rc = -EIO; in handle_response()
551 dev_dbg(master->dev, "ERRA received\n"); in handle_response()
552 if (master->trace_enabled) in handle_response()
554 rc = -EIO; in handle_response()
557 dev_dbg(master->dev, "ERRC received\n"); in handle_response()
558 if (master->trace_enabled) in handle_response()
560 rc = -EAGAIN; in handle_response()
574 int rc = -EAGAIN, retries = 0; in fsi_master_acf_xfer()
580 if (rc != -ESHUTDOWN) in fsi_master_acf_xfer()
581 dev_warn(master->dev, "Error %d sending command\n", rc); in fsi_master_acf_xfer()
585 if (rc != -EAGAIN) in fsi_master_acf_xfer()
587 rc = -EIO; in fsi_master_acf_xfer()
588 dev_dbg(master->dev, "ECRC retry %d\n", retries); in fsi_master_acf_xfer()
606 return -ENODEV; in fsi_master_acf_read()
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()
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()
630 return -ENODEV; in fsi_master_acf_write()
632 mutex_lock(&master->lock); 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()
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()
654 return -ENODEV; in fsi_master_acf_term()
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()
661 mutex_unlock(&master->lock); in fsi_master_acf_term()
672 return -ENODEV; in fsi_master_acf_break()
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()
677 return -EBUSY; in fsi_master_acf_break()
679 dev_dbg(master->dev, "sending BREAK\n"); in fsi_master_acf_break()
682 mutex_unlock(&master->lock); in fsi_master_acf_break()
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()
700 regmap_write(master->scu, SCU_COPRO_CTRL, SCU_COPRO_CLK_EN); in start_cf()
716 * and 6 and 7 have a non-swapped mapping (LE) which allows in setup_ast2500_cf_maps()
722 regmap_write(master->scu, SCU_2500_COPRO_SEG0, master->cf_mem_addr | in setup_ast2500_cf_maps()
725 /* Segments 2 and 3 to sysregs with byteswap (for SRAM) */ 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()
735 /* Memory cachable, regs and SRAM not cachable */ in setup_ast2500_cf_maps()
736 regmap_write(master->scu, SCU_2500_COPRO_CACHE_CTL, in setup_ast2500_cf_maps()
743 regmap_write(master->scu, SCU_2400_COPRO_SEG0, master->cf_mem_addr | in setup_ast2400_cf_maps()
746 /* Segments 2 to sysregs with byteswap (for SRAM) */ 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()
753 /* Memory cachable, regs and SRAM not cachable */ in setup_ast2400_cf_maps()
754 regmap_write(master->scu, SCU_2400_COPRO_CACHE_CTL, in setup_ast2400_cf_maps()
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()
774 void __iomem *base = master->cf_mem + HDR_OFFSET; in setup_ast2500_fw_config()
782 void __iomem *base = master->cf_mem + HDR_OFFSET; in setup_ast2400_fw_config()
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()
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()
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()
854 for (data = fw->data; data < (fw->data + fw->size);) { in load_copro_firmware()
862 dev_err(master->dev, "Failed to locate image sig %04x in FW blob\n", in load_copro_firmware()
864 rc = -ENODEV; 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()
870 rc = -ENOMEM; in load_copro_firmware()
872 memcpy_toio(master->cf_mem, data, size); in load_copro_firmware()
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()
896 return -ENODEV; in check_firmware_image()
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()
920 return -ENODEV; in copro_enable_sw_irq()
934 * Clear SRAM. This needs to happen before we setup the GPIOs in fsi_master_acf_setup()
937 memset_io(master->sram, 0, SRAM_SIZE); in fsi_master_acf_setup()
955 if (master->is_ast2500) { 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()
977 rc = -ENODEV; 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()
1018 /* We mark the copro not-started */ 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()
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()
1046 int rc = -EBUSY; in fsi_master_acf_link_enable()
1049 return -ENODEV; in fsi_master_acf_link_enable()
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()
1067 return -ENODEV; in fsi_master_acf_link_config()
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()
1081 static ssize_t external_mode_show(struct device *dev, in external_mode_show()
1086 return snprintf(buf, PAGE_SIZE - 1, "%u\n", in external_mode_show()
1087 master->external_mode ? 1 : 0); in external_mode_show()
1090 static ssize_t external_mode_store(struct device *dev, in external_mode_store()
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()
1118 mutex_unlock(&master->lock); in external_mode_store()
1120 fsi_master_rescan(&master->master); in external_mode_store()
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()
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()
1191 static void fsi_master_acf_release(struct device *dev) in fsi_master_acf_release()
1196 mutex_lock(&master->lock); 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()
1215 struct device_node *np, *mnode = dev_of_node(&pdev->dev); in fsi_master_acf_probe()
1225 return -ENOMEM; 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()
1240 dev_err(&pdev->dev, "failed to find SCU regmap\n"); in fsi_master_acf_probe()
1241 rc = PTR_ERR(master->scu); in fsi_master_acf_probe()
1246 gpio = devm_gpiod_get(&pdev->dev, "clock", 0); in fsi_master_acf_probe()
1248 dev_err(&pdev->dev, "failed to get clock gpio\n"); in fsi_master_acf_probe()
1252 master->gpio_clk = gpio; in fsi_master_acf_probe()
1254 gpio = devm_gpiod_get(&pdev->dev, "data", 0); in fsi_master_acf_probe()
1256 dev_err(&pdev->dev, "failed to get data gpio\n"); in fsi_master_acf_probe()
1260 master->gpio_data = gpio; in fsi_master_acf_probe()
1263 gpio = devm_gpiod_get_optional(&pdev->dev, "trans", 0); in fsi_master_acf_probe()
1265 dev_err(&pdev->dev, "failed to get trans gpio\n"); in fsi_master_acf_probe()
1269 master->gpio_trans = gpio; in fsi_master_acf_probe()
1271 gpio = devm_gpiod_get_optional(&pdev->dev, "enable", 0); in fsi_master_acf_probe()
1273 dev_err(&pdev->dev, "failed to get enable gpio\n"); in fsi_master_acf_probe()
1277 master->gpio_enable = gpio; in fsi_master_acf_probe()
1279 gpio = devm_gpiod_get_optional(&pdev->dev, "mux", 0); in fsi_master_acf_probe()
1281 dev_err(&pdev->dev, "failed to get mux gpio\n"); in fsi_master_acf_probe()
1285 master->gpio_mux = gpio; in fsi_master_acf_probe()
1288 np = of_parse_phandle(mnode, "memory-region", 0); in fsi_master_acf_probe()
1290 dev_err(&pdev->dev, "Didn't find reserved memory\n"); in fsi_master_acf_probe()
1291 rc = -EINVAL; in fsi_master_acf_probe()
1297 dev_err(&pdev->dev, "Couldn't address to resource for reserved memory\n"); in fsi_master_acf_probe()
1298 rc = -ENOMEM; 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()
1305 dev_err(&pdev->dev, "Reserved memory has insufficient alignment\n"); in fsi_master_acf_probe()
1306 rc = -ENOMEM; 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()
1321 dev_err(&pdev->dev, "Didn't find CVIC\n"); in fsi_master_acf_probe()
1322 rc = -EINVAL; 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()
1329 dev_err(&pdev->dev, "Error %d mapping CVIC\n", rc); in fsi_master_acf_probe()
1332 rc = of_property_read_u32(np, "copro-sw-interrupts", in fsi_master_acf_probe()
1333 &master->cvic_sw_irq); in fsi_master_acf_probe()
1336 dev_err(&pdev->dev, "Can't find coprocessor SW interrupt\n"); in fsi_master_acf_probe()
1341 /* Grab the SRAM */ 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()
1344 rc = -ENODEV; in fsi_master_acf_probe()
1345 dev_err(&pdev->dev, "Can't find sram pool\n"); in fsi_master_acf_probe()
1349 /* Current microcode only deals with fixed location in SRAM */ 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()
1354 rc = -ENOMEM; in fsi_master_acf_probe()
1355 dev_err(&pdev->dev, "Failed to allocate sram from pool\n"); in fsi_master_acf_probe()
1358 dev_dbg(&pdev->dev, "SRAM allocation @%lx\n", 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()
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()
1383 mutex_init(&master->lock); in fsi_master_acf_probe()
1385 mutex_lock(&master->lock); in fsi_master_acf_probe()
1387 mutex_unlock(&master->lock); in fsi_master_acf_probe()
1391 rc = device_create_file(&pdev->dev, &dev_attr_external_mode); 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()
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()
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()
1425 { .compatible = "aspeed,ast2400-cf-fsi-master" },
1426 { .compatible = "aspeed,ast2500-cf-fsi-master" },
1433 .name = "fsi-master-acf",