Lines Matching +full:ast2600 +full:- +full:fmc
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ASPEED FMC/SPI Memory Controller Driver
5 * Copyright (c) 2015-2022, IBM Corporation.
15 #include <linux/spi/spi-mem.h>
17 #define DEVICE_NAME "spi-aspeed-smc"
108 switch (op->data.buswidth) { in aspeed_spi_get_io_mode()
125 ctl = readl(chip->ctl) & ~CTRL_IO_MODE_MASK; in aspeed_spi_set_io_mode()
127 writel(ctl, chip->ctl); in aspeed_spi_set_io_mode()
133 u32 ctl = chip->ctl_val[ASPEED_SPI_BASE]; in aspeed_spi_start_user()
136 writel(ctl, chip->ctl); in aspeed_spi_start_user()
139 writel(ctl, chip->ctl); in aspeed_spi_start_user()
144 u32 ctl = chip->ctl_val[ASPEED_SPI_READ] | in aspeed_spi_stop_user()
147 writel(ctl, chip->ctl); in aspeed_spi_stop_user()
150 writel(chip->ctl_val[ASPEED_SPI_READ], chip->ctl); in aspeed_spi_stop_user()
161 len -= offset; in aspeed_spi_read_from_ahb()
175 len -= offset; in aspeed_spi_write_to_ahb()
193 aspeed_spi_write_to_ahb(chip->ahb_base, &temp, 4); in aspeed_spi_send_cmd_addr()
197 aspeed_spi_write_to_ahb(chip->ahb_base, &opcode, 1); in aspeed_spi_send_cmd_addr()
198 aspeed_spi_write_to_ahb(chip->ahb_base, &temp, 4); in aspeed_spi_send_cmd_addr()
202 return -EOPNOTSUPP; in aspeed_spi_send_cmd_addr()
211 aspeed_spi_write_to_ahb(chip->ahb_base, &op->cmd.opcode, 1); in aspeed_spi_read_reg()
212 aspeed_spi_read_from_ahb(op->data.buf.in, in aspeed_spi_read_reg()
213 chip->ahb_base, op->data.nbytes); in aspeed_spi_read_reg()
222 aspeed_spi_write_to_ahb(chip->ahb_base, &op->cmd.opcode, 1); in aspeed_spi_write_reg()
223 aspeed_spi_write_to_ahb(chip->ahb_base, op->data.buf.out, in aspeed_spi_write_reg()
224 op->data.nbytes); in aspeed_spi_write_reg()
240 ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, offset, op->cmd.opcode); in aspeed_spi_read_user()
244 if (op->dummy.buswidth && op->dummy.nbytes) { in aspeed_spi_read_user()
245 for (i = 0; i < op->dummy.nbytes / op->dummy.buswidth; i++) in aspeed_spi_read_user()
246 aspeed_spi_write_to_ahb(chip->ahb_base, &dummy, sizeof(dummy)); in aspeed_spi_read_user()
251 aspeed_spi_read_from_ahb(buf, chip->ahb_base, len); in aspeed_spi_read_user()
262 ret = aspeed_spi_send_cmd_addr(chip, op->addr.nbytes, op->addr.val, op->cmd.opcode); in aspeed_spi_write_user()
265 aspeed_spi_write_to_ahb(chip->ahb_base, op->data.buf.out, op->data.nbytes); in aspeed_spi_write_user()
270 /* support for 1-1-1, 1-1-2 or 1-1-4 */
273 if (op->cmd.buswidth > 1) in aspeed_spi_supports_op()
276 if (op->addr.nbytes != 0) { in aspeed_spi_supports_op()
277 if (op->addr.buswidth > 1) in aspeed_spi_supports_op()
279 if (op->addr.nbytes < 3 || op->addr.nbytes > 4) in aspeed_spi_supports_op()
283 if (op->dummy.nbytes != 0) { in aspeed_spi_supports_op()
284 if (op->dummy.buswidth > 1 || op->dummy.nbytes > 7) in aspeed_spi_supports_op()
288 if (op->data.nbytes != 0 && op->data.buswidth > 4) in aspeed_spi_supports_op()
298 struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->controller); in do_aspeed_spi_exec_op()
299 struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(mem->spi, 0)]; in do_aspeed_spi_exec_op()
304 dev_dbg(aspi->dev, in do_aspeed_spi_exec_op()
306 chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write", in do_aspeed_spi_exec_op()
307 op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, in do_aspeed_spi_exec_op()
308 op->dummy.buswidth, op->data.buswidth, in do_aspeed_spi_exec_op()
309 op->addr.nbytes, op->dummy.nbytes, op->data.nbytes); in do_aspeed_spi_exec_op()
311 addr_mode = readl(aspi->regs + CE_CTRL_REG); in do_aspeed_spi_exec_op()
314 ctl_val = chip->ctl_val[ASPEED_SPI_BASE]; in do_aspeed_spi_exec_op()
317 ctl_val |= op->cmd.opcode << CTRL_COMMAND_SHIFT; in do_aspeed_spi_exec_op()
320 if (op->addr.nbytes) { in do_aspeed_spi_exec_op()
321 if (op->addr.nbytes == 4) in do_aspeed_spi_exec_op()
322 addr_mode |= (0x11 << chip->cs); in do_aspeed_spi_exec_op()
324 addr_mode &= ~(0x11 << chip->cs); in do_aspeed_spi_exec_op()
326 if (op->addr.nbytes == 4 && chip->aspi->data == &ast2400_spi_data) in do_aspeed_spi_exec_op()
330 if (op->dummy.nbytes) in do_aspeed_spi_exec_op()
331 ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth); in do_aspeed_spi_exec_op()
333 if (op->data.nbytes) in do_aspeed_spi_exec_op()
336 if (op->data.dir == SPI_MEM_DATA_OUT) in do_aspeed_spi_exec_op()
342 writel(addr_mode, aspi->regs + CE_CTRL_REG); in do_aspeed_spi_exec_op()
343 writel(ctl_val, chip->ctl); in do_aspeed_spi_exec_op()
345 if (op->data.dir == SPI_MEM_DATA_IN) { in do_aspeed_spi_exec_op()
346 if (!op->addr.nbytes) in do_aspeed_spi_exec_op()
349 ret = aspeed_spi_read_user(chip, op, op->addr.val, in do_aspeed_spi_exec_op()
350 op->data.nbytes, op->data.buf.in); in do_aspeed_spi_exec_op()
352 if (!op->addr.nbytes) in do_aspeed_spi_exec_op()
360 writel(addr_mode_backup, aspi->regs + CE_CTRL_REG); in do_aspeed_spi_exec_op()
361 writel(chip->ctl_val[ASPEED_SPI_READ], chip->ctl); in do_aspeed_spi_exec_op()
371 dev_err(&mem->spi->dev, "operation failed: %d\n", ret); in aspeed_spi_exec_op()
377 struct aspeed_spi *aspi = spi_controller_get_devdata(mem->spi->controller); in aspeed_spi_get_name()
378 struct device *dev = aspi->dev; in aspeed_spi_get_name()
381 spi_get_chipselect(mem->spi, 0)); in aspeed_spi_get_name()
393 const struct aspeed_spi_data *data = aspi->data; in aspeed_spi_get_windows()
397 for (cs = 0; cs < aspi->data->max_cs; cs++) { in aspeed_spi_get_windows()
398 reg_val = readl(aspi->regs + CE0_SEGMENT_ADDR_REG + cs * 4); in aspeed_spi_get_windows()
400 windows[cs].size = data->segment_end(aspi, reg_val) - in aspeed_spi_get_windows()
401 data->segment_start(aspi, reg_val); in aspeed_spi_get_windows()
402 windows[cs].offset = data->segment_start(aspi, reg_val) - aspi->ahb_base_phy; in aspeed_spi_get_windows()
403 dev_vdbg(aspi->dev, "CE%d offset=0x%.8x size=0x%x\n", cs, in aspeed_spi_get_windows()
409 * On the AST2600, some CE windows are closed by default at reset but
410 * U-Boot should open all.
414 struct aspeed_spi *aspi = chip->aspi; in aspeed_spi_chip_set_default_window()
416 struct aspeed_spi_window *win = &windows[chip->cs]; in aspeed_spi_chip_set_default_window()
419 if (aspi->data == &ast2400_spi_data) { in aspeed_spi_chip_set_default_window()
420 win->offset = 0; in aspeed_spi_chip_set_default_window()
421 win->size = aspi->ahb_window_size; in aspeed_spi_chip_set_default_window()
426 chip->ahb_base = aspi->ahb_base + win->offset; in aspeed_spi_chip_set_default_window()
427 chip->ahb_window_size = win->size; in aspeed_spi_chip_set_default_window()
429 dev_dbg(aspi->dev, "CE%d default window [ 0x%.8x - 0x%.8x ] %dMB", in aspeed_spi_chip_set_default_window()
430 chip->cs, aspi->ahb_base_phy + win->offset, in aspeed_spi_chip_set_default_window()
431 aspi->ahb_base_phy + win->offset + win->size - 1, in aspeed_spi_chip_set_default_window()
432 win->size >> 20); in aspeed_spi_chip_set_default_window()
434 return chip->ahb_window_size ? 0 : -1; in aspeed_spi_chip_set_default_window()
440 u32 start = aspi->ahb_base_phy + win->offset; in aspeed_spi_set_window()
441 u32 end = start + win->size; in aspeed_spi_set_window()
442 void __iomem *seg_reg = aspi->regs + CE0_SEGMENT_ADDR_REG + win->cs * 4; in aspeed_spi_set_window()
444 u32 seg_val = aspi->data->segment_reg(aspi, start, end); in aspeed_spi_set_window()
456 dev_err(aspi->dev, "CE%d invalid window [ 0x%.8x - 0x%.8x ] %dMB", in aspeed_spi_set_window()
457 win->cs, start, end - 1, win->size >> 20); in aspeed_spi_set_window()
459 return -EIO; in aspeed_spi_set_window()
462 if (win->size) in aspeed_spi_set_window()
463 dev_dbg(aspi->dev, "CE%d new window [ 0x%.8x - 0x%.8x ] %dMB", in aspeed_spi_set_window()
464 win->cs, start, end - 1, win->size >> 20); in aspeed_spi_set_window()
466 dev_dbg(aspi->dev, "CE%d window closed", win->cs); in aspeed_spi_set_window()
473 * - Align mappings on flash size (we don't have the info)
474 * - ioremap each window, not strictly necessary since the overall window
484 struct aspeed_spi *aspi = chip->aspi; in aspeed_spi_chip_adjust_window()
486 struct aspeed_spi_window *win = &windows[chip->cs]; in aspeed_spi_chip_adjust_window()
490 if (aspi->data == &ast2400_spi_data) in aspeed_spi_chip_adjust_window()
497 if (aspi->data == &ast2500_spi_data && chip->cs == 0 && size == SZ_128M) { in aspeed_spi_chip_adjust_window()
499 dev_info(aspi->dev, "CE%d window resized to %dMB (AST2500 HW quirk)", in aspeed_spi_chip_adjust_window()
500 chip->cs, size >> 20); in aspeed_spi_chip_adjust_window()
504 * The decoding size of AST2600 SPI controller should set at in aspeed_spi_chip_adjust_window()
507 if ((aspi->data == &ast2600_spi_data || aspi->data == &ast2600_fmc_data) && in aspeed_spi_chip_adjust_window()
510 dev_info(aspi->dev, "CE%d window resized to %dMB (AST2600 Decoding)", in aspeed_spi_chip_adjust_window()
511 chip->cs, size >> 20); in aspeed_spi_chip_adjust_window()
517 win->offset += local_offset; in aspeed_spi_chip_adjust_window()
518 win->size = size; in aspeed_spi_chip_adjust_window()
520 if (win->offset + win->size > aspi->ahb_window_size) { in aspeed_spi_chip_adjust_window()
521 win->size = aspi->ahb_window_size - win->offset; in aspeed_spi_chip_adjust_window()
522 dev_warn(aspi->dev, "CE%d window resized to %dMB", chip->cs, win->size >> 20); in aspeed_spi_chip_adjust_window()
530 chip->ahb_base = aspi->ahb_base + win->offset; in aspeed_spi_chip_adjust_window()
531 chip->ahb_window_size = win->size; in aspeed_spi_chip_adjust_window()
537 if (chip->cs < aspi->data->max_cs - 1) { in aspeed_spi_chip_adjust_window()
538 struct aspeed_spi_window *next = &windows[chip->cs + 1]; in aspeed_spi_chip_adjust_window()
541 if ((next->offset + next->size) > (win->offset + win->size)) in aspeed_spi_chip_adjust_window()
542 next->size = (next->offset + next->size) - (win->offset + win->size); in aspeed_spi_chip_adjust_window()
544 next->size = 0; in aspeed_spi_chip_adjust_window()
545 next->offset = win->offset + win->size; in aspeed_spi_chip_adjust_window()
556 struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->controller); in aspeed_spi_dirmap_create()
557 struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)]; in aspeed_spi_dirmap_create()
558 struct spi_mem_op *op = &desc->info.op_tmpl; in aspeed_spi_dirmap_create()
562 dev_dbg(aspi->dev, in aspeed_spi_dirmap_create()
563 "CE%d %s dirmap [ 0x%.8llx - 0x%.8llx ] OP %#x mode:%d.%d.%d.%d naddr:%#x ndummies:%#x\n", in aspeed_spi_dirmap_create()
564 chip->cs, op->data.dir == SPI_MEM_DATA_IN ? "read" : "write", in aspeed_spi_dirmap_create()
565 desc->info.offset, desc->info.offset + desc->info.length, in aspeed_spi_dirmap_create()
566 op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, in aspeed_spi_dirmap_create()
567 op->dummy.buswidth, op->data.buswidth, in aspeed_spi_dirmap_create()
568 op->addr.nbytes, op->dummy.nbytes); in aspeed_spi_dirmap_create()
570 chip->clk_freq = desc->mem->spi->max_speed_hz; in aspeed_spi_dirmap_create()
573 if (op->data.dir != SPI_MEM_DATA_IN) in aspeed_spi_dirmap_create()
574 return -EOPNOTSUPP; in aspeed_spi_dirmap_create()
576 aspeed_spi_chip_adjust_window(chip, desc->info.offset, desc->info.length); in aspeed_spi_dirmap_create()
578 if (desc->info.length > chip->ahb_window_size) in aspeed_spi_dirmap_create()
579 dev_warn(aspi->dev, "CE%d window (%dMB) too small for mapping", in aspeed_spi_dirmap_create()
580 chip->cs, chip->ahb_window_size >> 20); in aspeed_spi_dirmap_create()
583 ctl_val = readl(chip->ctl) & ~CTRL_IO_CMD_MASK; in aspeed_spi_dirmap_create()
585 op->cmd.opcode << CTRL_COMMAND_SHIFT | in aspeed_spi_dirmap_create()
588 if (op->dummy.nbytes) in aspeed_spi_dirmap_create()
589 ctl_val |= CTRL_IO_DUMMY_SET(op->dummy.nbytes / op->dummy.buswidth); in aspeed_spi_dirmap_create()
592 if (op->addr.nbytes) { in aspeed_spi_dirmap_create()
593 u32 addr_mode = readl(aspi->regs + CE_CTRL_REG); in aspeed_spi_dirmap_create()
595 if (op->addr.nbytes == 4) in aspeed_spi_dirmap_create()
596 addr_mode |= (0x11 << chip->cs); in aspeed_spi_dirmap_create()
598 addr_mode &= ~(0x11 << chip->cs); in aspeed_spi_dirmap_create()
599 writel(addr_mode, aspi->regs + CE_CTRL_REG); in aspeed_spi_dirmap_create()
604 if (op->addr.nbytes == 4 && chip->aspi->data == &ast2400_spi_data) in aspeed_spi_dirmap_create()
609 chip->ctl_val[ASPEED_SPI_READ] = ctl_val; in aspeed_spi_dirmap_create()
610 writel(chip->ctl_val[ASPEED_SPI_READ], chip->ctl); in aspeed_spi_dirmap_create()
614 dev_info(aspi->dev, "CE%d read buswidth:%d [0x%08x]\n", in aspeed_spi_dirmap_create()
615 chip->cs, op->data.buswidth, chip->ctl_val[ASPEED_SPI_READ]); in aspeed_spi_dirmap_create()
623 struct aspeed_spi *aspi = spi_controller_get_devdata(desc->mem->spi->controller); in aspeed_spi_dirmap_read()
624 struct aspeed_spi_chip *chip = &aspi->chips[spi_get_chipselect(desc->mem->spi, 0)]; in aspeed_spi_dirmap_read()
627 if (chip->ahb_window_size < offset + len) { in aspeed_spi_dirmap_read()
630 ret = aspeed_spi_read_user(chip, &desc->info.op_tmpl, offset, len, buf); in aspeed_spi_dirmap_read()
634 memcpy_fromio(buf, chip->ahb_base + offset, len); in aspeed_spi_dirmap_read()
652 reg = readl(aspi->regs + CONFIG_REG); in aspeed_spi_chip_set_type()
655 writel(reg, aspi->regs + CONFIG_REG); in aspeed_spi_chip_set_type()
660 u32 we_bit = BIT(aspi->data->we0 + cs); in aspeed_spi_chip_enable()
661 u32 reg = readl(aspi->regs + CONFIG_REG); in aspeed_spi_chip_enable()
667 writel(reg, aspi->regs + CONFIG_REG); in aspeed_spi_chip_enable()
672 struct aspeed_spi *aspi = spi_controller_get_devdata(spi->controller); in aspeed_spi_setup()
673 const struct aspeed_spi_data *data = aspi->data; in aspeed_spi_setup()
675 struct aspeed_spi_chip *chip = &aspi->chips[cs]; in aspeed_spi_setup()
677 chip->aspi = aspi; in aspeed_spi_setup()
678 chip->cs = cs; in aspeed_spi_setup()
679 chip->ctl = aspi->regs + data->ctl0 + cs * 4; in aspeed_spi_setup()
682 if (data->hastype) in aspeed_spi_setup()
686 dev_warn(aspi->dev, "CE%d window invalid", cs); in aspeed_spi_setup()
687 return -EINVAL; in aspeed_spi_setup()
692 chip->ctl_val[ASPEED_SPI_BASE] = CTRL_CE_STOP_ACTIVE | CTRL_IO_MODE_USER; in aspeed_spi_setup()
694 dev_dbg(aspi->dev, "CE%d setup done\n", cs); in aspeed_spi_setup()
700 struct aspeed_spi *aspi = spi_controller_get_devdata(spi->controller); in aspeed_spi_cleanup()
705 dev_dbg(aspi->dev, "CE%d cleanup done\n", cs); in aspeed_spi_cleanup()
712 for (cs = 0; cs < aspi->data->max_cs; cs++) in aspeed_spi_enable()
718 struct device *dev = &pdev->dev; in aspeed_spi_probe()
725 data = of_device_get_match_data(&pdev->dev); in aspeed_spi_probe()
727 return -ENODEV; in aspeed_spi_probe()
731 return -ENOMEM; in aspeed_spi_probe()
735 aspi->data = data; in aspeed_spi_probe()
736 aspi->dev = dev; in aspeed_spi_probe()
738 aspi->regs = devm_platform_ioremap_resource(pdev, 0); in aspeed_spi_probe()
739 if (IS_ERR(aspi->regs)) in aspeed_spi_probe()
740 return PTR_ERR(aspi->regs); in aspeed_spi_probe()
742 aspi->ahb_base = devm_platform_get_and_ioremap_resource(pdev, 1, &res); in aspeed_spi_probe()
743 if (IS_ERR(aspi->ahb_base)) { in aspeed_spi_probe()
745 return PTR_ERR(aspi->ahb_base); in aspeed_spi_probe()
748 aspi->ahb_window_size = resource_size(res); in aspeed_spi_probe()
749 aspi->ahb_base_phy = res->start; in aspeed_spi_probe()
751 aspi->clk = devm_clk_get_enabled(&pdev->dev, NULL); in aspeed_spi_probe()
752 if (IS_ERR(aspi->clk)) { in aspeed_spi_probe()
754 return PTR_ERR(aspi->clk); in aspeed_spi_probe()
757 aspi->clk_freq = clk_get_rate(aspi->clk); in aspeed_spi_probe()
758 if (!aspi->clk_freq) { in aspeed_spi_probe()
760 return -EINVAL; in aspeed_spi_probe()
765 ctlr->mode_bits = SPI_RX_DUAL | SPI_TX_DUAL | data->mode_bits; in aspeed_spi_probe()
766 ctlr->bus_num = pdev->id; in aspeed_spi_probe()
767 ctlr->mem_ops = &aspeed_spi_mem_ops; in aspeed_spi_probe()
768 ctlr->setup = aspeed_spi_setup; in aspeed_spi_probe()
769 ctlr->cleanup = aspeed_spi_cleanup; in aspeed_spi_probe()
770 ctlr->num_chipselect = data->max_cs; in aspeed_spi_probe()
771 ctlr->dev.of_node = dev->of_node; in aspeed_spi_probe()
775 dev_err(&pdev->dev, "spi_register_controller failed\n"); in aspeed_spi_probe()
812 * The Segment Registers of the AST2600 use a 1MB unit. The address
823 return aspi->ahb_base_phy + start_offset; in aspeed_spi_segment_ast2600_start()
833 return aspi->ahb_base_phy; in aspeed_spi_segment_ast2600_end()
835 return aspi->ahb_base_phy + end_offset + 0x100000; in aspeed_spi_segment_ast2600_end()
846 ((end - 1) & AST2600_SEG_ADDR_MASK); in aspeed_spi_segment_ast2600_reg()
861 memcpy_fromio(test_buf, chip->ahb_base, CALIBRATE_BUF_SIZE); in aspeed_spi_check_reads()
881 struct aspeed_spi *aspi = chip->aspi; in aspeed_spi_calibrate()
882 const struct aspeed_spi_data *data = aspi->data; in aspeed_spi_calibrate()
884 int good_pass = -1, pass_count = 0; in aspeed_spi_calibrate()
885 u32 shift = (hdiv - 1) << 2; in aspeed_spi_calibrate()
895 if (chip->cs == 0) { in aspeed_spi_calibrate()
898 writel(fread_timing_val, aspi->regs + data->timing); in aspeed_spi_calibrate()
901 dev_dbg(aspi->dev, in aspeed_spi_calibrate()
908 good_pass = i - 1; in aspeed_spi_calibrate()
918 return -1; in aspeed_spi_calibrate()
921 if (chip->cs == 0) { in aspeed_spi_calibrate()
924 writel(fread_timing_val, aspi->regs + data->timing); in aspeed_spi_calibrate()
926 dev_dbg(aspi->dev, " * -> good is pass %d [0x%08x]", in aspeed_spi_calibrate()
958 (aspeed_spi_hclk_divs[(i) - 1] << CTRL_FREQ_SEL_SHIFT)
962 struct aspeed_spi *aspi = chip->aspi; in aspeed_spi_do_calibration()
963 const struct aspeed_spi_data *data = aspi->data; in aspeed_spi_do_calibration()
964 u32 ahb_freq = aspi->clk_freq; in aspeed_spi_do_calibration()
965 u32 max_freq = chip->clk_freq; in aspeed_spi_do_calibration()
969 int i, rc, best_div = -1; in aspeed_spi_do_calibration()
971 dev_dbg(aspi->dev, "calculate timing compensation - AHB freq: %d MHz", in aspeed_spi_do_calibration()
978 ctl_val = chip->ctl_val[ASPEED_SPI_READ] & data->hclk_mask; in aspeed_spi_do_calibration()
979 writel(ctl_val, chip->ctl); in aspeed_spi_do_calibration()
983 return -ENOMEM; in aspeed_spi_do_calibration()
987 memcpy_fromio(golden_buf, chip->ahb_base, CALIBRATE_BUF_SIZE); in aspeed_spi_do_calibration()
989 dev_info(aspi->dev, "Calibration area too uniform, using low speed"); in aspeed_spi_do_calibration()
999 for (i = ARRAY_SIZE(aspeed_spi_hclk_divs); i > data->hdiv_max - 1; i--) { in aspeed_spi_do_calibration()
1007 tv = chip->ctl_val[ASPEED_SPI_READ] | ASPEED_SPI_HCLK_DIV(i); in aspeed_spi_do_calibration()
1008 writel(tv, chip->ctl); in aspeed_spi_do_calibration()
1009 dev_dbg(aspi->dev, "Trying HCLK/%d [%08x] ...", i, tv); in aspeed_spi_do_calibration()
1010 rc = data->calibrate(chip, i, golden_buf, test_buf); in aspeed_spi_do_calibration()
1017 dev_warn(aspi->dev, "No good frequency, using dumb slow"); in aspeed_spi_do_calibration()
1019 dev_dbg(aspi->dev, "Found good read timings at HCLK/%d", best_div); in aspeed_spi_do_calibration()
1023 chip->ctl_val[i] = (chip->ctl_val[i] & data->hclk_mask) | in aspeed_spi_do_calibration()
1028 writel(chip->ctl_val[ASPEED_SPI_READ], chip->ctl); in aspeed_spi_do_calibration()
1036 ((chip)->aspi->regs + (chip)->aspi->data->timing + \
1037 (chip)->cs * 4)
1042 struct aspeed_spi *aspi = chip->aspi; in aspeed_spi_ast2600_calibrate()
1044 u32 shift = (hdiv - 2) << 3; in aspeed_spi_ast2600_calibrate()
1058 dev_dbg(aspi->dev, in aspeed_spi_ast2600_calibrate()
1074 dev_dbg(aspi->dev, in aspeed_spi_ast2600_calibrate()
1089 return -1; in aspeed_spi_ast2600_calibrate()
1180 { .compatible = "aspeed,ast2400-fmc", .data = &ast2400_fmc_data },
1181 { .compatible = "aspeed,ast2400-spi", .data = &ast2400_spi_data },
1182 { .compatible = "aspeed,ast2500-fmc", .data = &ast2500_fmc_data },
1183 { .compatible = "aspeed,ast2500-spi", .data = &ast2500_spi_data },
1184 { .compatible = "aspeed,ast2600-fmc", .data = &ast2600_fmc_data },
1185 { .compatible = "aspeed,ast2600-spi", .data = &ast2600_spi_data },
1202 MODULE_AUTHOR("Chin-Ting Kuo <chin-ting_kuo@aspeedtech.com>");