Lines Matching refs:base_address

16 static inline int32_t cdns_nand_wait_idle(uintptr_t base_address)  in cdns_nand_wait_idle()  argument
19 if (!WAIT_FOR(CNF_GET_CTRL_BUSY(sys_read32(CNF_CMDREG(base_address, CTRL_STATUS))) == 0U, in cdns_nand_wait_idle()
58 uintptr_t base_address; in cdns_nand_device_info() local
62 base_address = params->nand_base; in cdns_nand_device_info()
65 reg_value = sys_read32(CNF_CTRLPARAM(base_address, VERSION)); in cdns_nand_device_info()
74 reg_value = sys_read32(CNF_CTRLPARAM(base_address, DEV_PARAMS0)); in cdns_nand_device_info()
85 reg_value = sys_read32(CNF_CTRLCFG(base_address, DEV_LAYOUT)); in cdns_nand_device_info()
89 reg_value = sys_read32(CNF_CTRLPARAM(base_address, DEV_AREA)); in cdns_nand_device_info()
94 params->nblocks_per_lun = sys_read32(CNF_CTRLPARAM(base_address, DEV_BLOCKS_PLUN)); in cdns_nand_device_info()
116 static uint32_t cdns_nand_get_thrd_status(uintptr_t base_address, uint8_t thread) in cdns_nand_get_thrd_status() argument
120 sys_write32(THREAD_VAL(thread), (base_address + CMD_STATUS_PTR_ADDR)); in cdns_nand_get_thrd_status()
121 status = sys_read32((base_address + CMD_STAT_CMD_STATUS)); in cdns_nand_get_thrd_status()
132 static int cdns_wait_for_thread(uintptr_t base_address, uint8_t thread) in cdns_wait_for_thread() argument
135 if (!WAIT_FOR((sys_read32((base_address) + THR_STATUS) & BIT(thread)) == 0U, in cdns_wait_for_thread()
155 static int cdns_nand_pio_set_features(uintptr_t base_address, uint8_t feat_addr, uint8_t feat_val, in cdns_nand_pio_set_features() argument
161 ret = cdns_wait_for_thread(base_address, thread); in cdns_nand_pio_set_features()
167 sys_write32(SET_FEAT_ADDR(feat_addr), (base_address + CDNS_CMD_REG1)); in cdns_nand_pio_set_features()
168 sys_write32(feat_val, (base_address + CDNS_CMD_REG2)); in cdns_nand_pio_set_features()
173 sys_write32(status, (base_address + CDNS_CMD_REG0)); in cdns_nand_pio_set_features()
184 static int cdns_pio_transfer_complete(uintptr_t base_address, uint8_t thread) in cdns_pio_transfer_complete() argument
188 status = WAIT_FOR(((cdns_nand_get_thrd_status(base_address, thread)) != 0), IDLE_TIME_OUT, in cdns_pio_transfer_complete()
215 static int cdns_nand_set_opr_mode(uintptr_t base_address, uint8_t opr_mode) in cdns_nand_set_opr_mode() argument
225 sys_read32(CNF_CTRLPARAM(base_address, ONFI_TIMING_0))); in cdns_nand_set_opr_mode()
229 sys_write32(PHY_CTRL_REG_SDR, (base_address + PHY_CTRL_REG_OFFSET)); in cdns_nand_set_opr_mode()
230 sys_write32(PHY_TSEL_REG_SDR, (base_address + PHY_TSEL_REG_OFFSET)); in cdns_nand_set_opr_mode()
231 sys_write32(PHY_DQ_TIMING_REG_SDR, (base_address + PHY_DQ_TIMING_REG_OFFSET)); in cdns_nand_set_opr_mode()
232 sys_write32(PHY_DQS_TIMING_REG_SDR, (base_address + PHY_DQS_TIMING_REG_OFFSET)); in cdns_nand_set_opr_mode()
233 sys_write32(PHY_GATE_LPBK_CTRL_REG_SDR, (base_address + PHY_GATE_LPBK_OFFSET)); in cdns_nand_set_opr_mode()
234 sys_write32(PHY_DLL_MASTER_CTRL_REG_SDR, (base_address + PHY_DLL_MASTER_OFFSET)); in cdns_nand_set_opr_mode()
239 CNF_MINICTRL(base_address, ASYNC_TOGGLE_TIMINGS)); in cdns_nand_set_opr_mode()
242 sys_clear_bits(CNF_MINICTRL(base_address, CMN_SETTINGS), in cdns_nand_set_opr_mode()
248 sys_read32(CNF_CTRLPARAM(base_address, ONFI_TIMING_0))); in cdns_nand_set_opr_mode()
251 sys_write32(PHY_CTRL_REG_DDR, (base_address + PHY_CTRL_REG_OFFSET)); in cdns_nand_set_opr_mode()
252 sys_write32(PHY_TSEL_REG_DDR, (base_address + PHY_TSEL_REG_OFFSET)); in cdns_nand_set_opr_mode()
253 sys_write32(PHY_DQ_TIMING_REG_DDR, (base_address + PHY_DQ_TIMING_REG_OFFSET)); in cdns_nand_set_opr_mode()
254 sys_write32(PHY_DQS_TIMING_REG_DDR, (base_address + PHY_DQS_TIMING_REG_OFFSET)); in cdns_nand_set_opr_mode()
255 sys_write32(PHY_GATE_LPBK_CTRL_REG_DDR, (base_address + PHY_GATE_LPBK_OFFSET)); in cdns_nand_set_opr_mode()
256 sys_write32(PHY_DLL_MASTER_CTRL_REG_DDR, (base_address + PHY_DLL_MASTER_OFFSET)); in cdns_nand_set_opr_mode()
258 sys_set_bits(CNF_MINICTRL(base_address, CMN_SETTINGS), in cdns_nand_set_opr_mode()
263 ret = cdns_nand_wait_idle(base_address); in cdns_nand_set_opr_mode()
270 device_type = CNF_GET_DEV_TYPE(sys_read32(CNF_CTRLPARAM(base_address, DEV_PARAMS0))); in cdns_nand_set_opr_mode()
277 sys_clear_bit(CNF_MINICTRL(base_address, DLL_PHY_CTRL), CNF_DLL_PHY_RST_N); in cdns_nand_set_opr_mode()
280 ret = cdns_nand_wait_idle(base_address); in cdns_nand_set_opr_mode()
286 ret = cdns_nand_pio_set_features(base_address, SET_FEAT_TIMING_MODE_ADDRESS, timing_mode, in cdns_nand_set_opr_mode()
292 ret = cdns_pio_transfer_complete(base_address, NF_TDEF_TRD_NUM); in cdns_nand_set_opr_mode()
298 ret = cdns_nand_wait_idle(base_address); in cdns_nand_set_opr_mode()
305 sys_set_bit(CNF_MINICTRL(base_address, DLL_PHY_CTRL), CNF_DLL_PHY_RST_N); in cdns_nand_set_opr_mode()
307 ret = cdns_nand_wait_idle(base_address); in cdns_nand_set_opr_mode()
322 static int cdns_nand_transfer_config(uintptr_t base_address) in cdns_nand_transfer_config() argument
326 ret = cdns_nand_wait_idle(base_address); in cdns_nand_transfer_config()
334 sys_write32(ENABLE, CNF_CTRLCFG(base_address, TRANS_CFG0)); in cdns_nand_transfer_config()
337 sys_write32(DISABLE, CNF_CTRLCFG(base_address, MULTIPLANE_CFG)); in cdns_nand_transfer_config()
338 sys_write32(DISABLE, CNF_CTRLCFG(base_address, CACHE_CFG)); in cdns_nand_transfer_config()
341 sys_write32(CLEAR_ALL_INTERRUPT, (base_address + INTR_STATUS)); in cdns_nand_transfer_config()
354 uintptr_t base_address = params->nand_base; in cdns_nand_init() local
358 if (!WAIT_FOR(CNF_GET_INIT_COMP(sys_read32(CNF_CMDREG(base_address, CTRL_STATUS))) != 0U, in cdns_nand_init()
364 if (CNF_GET_INIT_FAIL(sys_read32(CNF_CMDREG(base_address, CTRL_STATUS))) != 0) { in cdns_nand_init()
375 reg_value_read = sys_read32(CNF_CTRLPARAM(base_address, FEATURE)); in cdns_nand_init()
379 sys_set_bit(CNF_DI(base_address, CONTROL), CNF_DI_PAR_EN); in cdns_nand_init()
385 sys_set_bit(CNF_DI(base_address, CONTROL), CNF_DI_CRC_EN); in cdns_nand_init()
388 ret = cdns_nand_wait_idle(base_address); in cdns_nand_init()
394 sys_write32(DEV_STAT_DEF_VALUE, CNF_CTRLCFG(base_address, DEV_STAT)); in cdns_nand_init()
397 ret = cdns_nand_set_opr_mode(base_address, datarate_mode); in cdns_nand_init()
403 ret = cdns_nand_transfer_config(base_address); in cdns_nand_init()
409 ret = cdns_nand_wait_idle(base_address); in cdns_nand_init()
417 (base_address + NF_DMA_SETTING)); in cdns_nand_init()
422 (base_address + NF_PRE_FETCH)); in cdns_nand_init()
433 sys_set_bit((base_address + INTERRUPT_STATUS_REG), GINTR_ENABLE); in cdns_nand_init()
530 static int cdns_nand_send(uintptr_t base_address, char *desc_ptr, uint8_t thread) in cdns_nand_send() argument
538 ret = cdns_wait_for_thread(base_address, thread); in cdns_nand_send()
544 sys_write32(desc_address & U32_MASK_VAL, (base_address + CDNS_CMD_REG2)); in cdns_nand_send()
545 sys_write32((desc_address >> 32) & U32_MASK_VAL, (base_address + CDNS_CMD_REG3)); in cdns_nand_send()
551 sys_write32(status, (base_address + CDNS_CMD_REG0)); in cdns_nand_send()
561 uint32_t base_address; in cdns_cdma_desc_transfer_finish() local
575 base_address = params->nand_base; in cdns_cdma_desc_transfer_finish()
593 ret = cdns_nand_send(base_address, (char *)cdma_desc, NF_TDEF_TRD_NUM); in cdns_cdma_desc_transfer_finish()
694 uintptr_t base_address; in cdns_nand_pio_erase() local
699 base_address = params->nand_base; in cdns_nand_pio_erase()
702 ret = cdns_wait_for_thread(base_address, thread); in cdns_nand_pio_erase()
708 sys_write32(row_address, (base_address + CDNS_CMD_REG1)); in cdns_nand_pio_erase()
710 sys_write32((NF_CMD4_BANK_SET(bank)), (base_address + CDNS_CMD_REG4)); in cdns_nand_pio_erase()
717 sys_write32(status, (base_address + CDNS_CMD_REG0)); in cdns_nand_pio_erase()
719 ret = cdns_pio_transfer_complete(base_address, thread); in cdns_nand_pio_erase()
741 static int cdns_nand_pio_prepare(uintptr_t base_address, uint8_t thread, uint8_t bank, in cdns_nand_pio_prepare() argument
749 ret = cdns_wait_for_thread(base_address, thread); in cdns_nand_pio_prepare()
755 sys_write32(row_address, (base_address + CDNS_CMD_REG1)); in cdns_nand_pio_prepare()
756 sys_write32(NF_CMD4_BANK_SET(bank), (base_address + CDNS_CMD_REG4)); in cdns_nand_pio_prepare()
757 sys_write32(buf_addr & U32_MASK_VAL, (base_address + CDNS_CMD_REG2)); in cdns_nand_pio_prepare()
758 sys_write32((buf_addr >> 32) & U32_MASK_VAL, (base_address + CDNS_CMD_REG3)); in cdns_nand_pio_prepare()
767 sys_write32(status, (base_address + CDNS_CMD_REG0)); in cdns_nand_pio_prepare()
782 uintptr_t base_address; in cdns_nand_pio_write() local
785 base_address = params->nand_base; in cdns_nand_pio_write()
787 ret = cdns_nand_pio_prepare(base_address, NF_TDEF_TRD_NUM, NF_TDEF_DEV_NUM, row_address, in cdns_nand_pio_write()
794 ret = cdns_pio_transfer_complete(base_address, NF_TDEF_TRD_NUM); in cdns_nand_pio_write()
813 uintptr_t base_address; in cdns_nand_pio_read() local
816 base_address = params->nand_base; in cdns_nand_pio_read()
818 ret = cdns_nand_pio_prepare(base_address, NF_TDEF_TRD_NUM, NF_TDEF_DEV_NUM, row_address, in cdns_nand_pio_read()
826 ret = cdns_pio_transfer_complete(base_address, NF_TDEF_TRD_NUM); in cdns_nand_pio_read()
877 uintptr_t base_address; in cdns_generic_send_cmd() local
880 base_address = params->nand_base; in cdns_generic_send_cmd()
883 ret = cdns_nand_wait_idle(base_address); in cdns_generic_send_cmd()
889 sys_write32(mini_ctrl_cmd_l, (base_address + CDNS_CMD_REG2)); in cdns_generic_send_cmd()
890 sys_write32(mini_ctrl_cmd_h, (base_address + CDNS_CMD_REG3)); in cdns_generic_send_cmd()
897 sys_write32(status, (base_address + CDNS_CMD_REG0)); in cdns_generic_send_cmd()
931 static int cdns_wait_sdma(uintptr_t base_address) in cdns_wait_sdma() argument
934 if (!WAIT_FOR(((sys_read32(base_address + INTR_STATUS) & BIT(SDMA_TRIGG)) != 0), in cdns_wait_sdma()
939 sys_set_bit((base_address + INTR_STATUS), SDMA_TRIGG); in cdns_wait_sdma()
987 uintptr_t base_address = params->nand_base; in cdns_generic_page_read() local
1008 ret = cdns_wait_sdma(base_address); in cdns_generic_page_read()
1030 uintptr_t base_address = params->nand_base; in cdns_generic_page_write() local
1060 ret = cdns_wait_sdma(base_address); in cdns_generic_page_write()
1116 uintptr_t base_address = 0; in cdns_nand_gen_erase() local
1124 base_address = params->nand_base; in cdns_nand_gen_erase()