1 // SPDX-License-Identifier: GPL-2.0-only
3 * External Memory Interface
5 * Copyright (C) 2011 Texas Instruments Incorporated
6 * Author: Mark Salter <msalter@redhat.com>
9 #include <linux/of_address.h>
14 #define NUM_EMIFA_CHIP_ENABLES 4
22 u32 cecfg
[NUM_EMIFA_CHIP_ENABLES
];
32 static struct of_device_id emifa_match
[] __initdata
= {
33 { .compatible
= "ti,c64x+emifa" },
38 * Parse device tree for existence of an EMIF (External Memory Interface)
39 * and initialize it if found.
41 static int __init
c6x_emifa_init(void)
43 struct emifa_regs __iomem
*regs
;
44 struct device_node
*node
;
49 node
= of_find_matching_node(NULL
, emifa_match
);
53 regs
= of_iomap(node
, 0);
57 /* look for a dscr-based enable for emifa pin buffers */
58 err
= of_property_read_u32_array(node
, "ti,dscr-dev-enable", &val
, 1);
60 dscr_set_devstate(val
, DSCR_DEVSTATE_ENABLED
);
62 /* set up the chip enables */
63 p
= of_get_property(node
, "ti,emifa-ce-config", &len
);
66 if (len
> NUM_EMIFA_CHIP_ENABLES
)
67 len
= NUM_EMIFA_CHIP_ENABLES
;
68 for (i
= 0; i
<= len
; i
++)
69 soc_writel(be32_to_cpup(&p
[i
]), ®s
->cecfg
[i
]);
72 err
= of_property_read_u32_array(node
, "ti,emifa-burst-priority", &val
, 1);
74 soc_writel(val
, ®s
->bprio
);
76 err
= of_property_read_u32_array(node
, "ti,emifa-async-wait-control", &val
, 1);
78 soc_writel(val
, ®s
->awcc
);
84 pure_initcall(c6x_emifa_init
);