1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright 2014 Freescale Semiconductor
5 * Freescale T2080RDB board-specific CPLD controlling supports.
12 u8 cpld_read(unsigned int reg)
14 void *p = (void *)CONFIG_SYS_CPLD_BASE;
19 void cpld_write(unsigned int reg, u8 value)
21 void *p = (void *)CONFIG_SYS_CPLD_BASE;
23 out_8(p + reg, value);
26 /* Set the boot bank to the alternate bank */
27 void cpld_set_altbank(void)
29 u8 reg = CPLD_READ(flash_csr);
31 reg = (reg & ~CPLD_BANK_SEL_MASK) | CPLD_LBMAP_ALTBANK;
32 CPLD_WRITE(flash_csr, reg);
33 CPLD_WRITE(reset_ctl, CPLD_LBMAP_RESET);
36 /* Set the boot bank to the default bank */
37 void cpld_set_defbank(void)
39 u8 reg = CPLD_READ(flash_csr);
41 reg = (reg & ~CPLD_BANK_SEL_MASK) | CPLD_LBMAP_DFLTBANK;
42 CPLD_WRITE(flash_csr, reg);
43 CPLD_WRITE(reset_ctl, CPLD_LBMAP_RESET);
46 int do_cpld(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
51 return cmd_usage(cmdtp);
53 if (strcmp(argv[1], "reset") == 0) {
54 if (strcmp(argv[2], "altbank") == 0)
59 rc = cmd_usage(cmdtp);
66 cpld, CONFIG_SYS_MAXARGS, 1, do_cpld,
67 "Reset the board or alternate bank",
68 "reset: reset to default bank\n"
69 "cpld reset altbank: reset to alternate bank\n"