layerscape: add ls1088ardb device support
[openwrt/staging/lynxis/omap.git] / target / linux / layerscape / patches-4.4 / 7173-staging-fsl-mc-get-version-of-root-dprc-from-MC-hard.patch
1 From 2df13a365ecda7e3321cf9d4e1a9ebd63e58c28b Mon Sep 17 00:00:00 2001
2 From: Itai Katz <itai.katz@nxp.com>
3 Date: Mon, 11 Apr 2016 11:55:55 -0500
4 Subject: [PATCH 173/226] staging: fsl-mc: get version of root dprc from MC
5 hardware
6
7 The root dprc is discovered as a platform device in the device tree. The
8 version of that dprc was previously set using hardcoded values from the API
9 header in the kernel). This patch removes the use of the hardcoded version
10 numbers and instead reads the actual dprc version from the hardware.
11
12 Signed-off-by: Itai Katz <itai.katz@nxp.com>
13 (Stuart: resolved merge conflict, updated commit subject/log)
14 Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
15 Acked-by: German Rivera <german.rivera@nxp.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 ---
18 drivers/staging/fsl-mc/bus/mc-bus.c | 45 ++++++++++++++++++++++++++++-------
19 1 file changed, 37 insertions(+), 8 deletions(-)
20
21 --- a/drivers/staging/fsl-mc/bus/mc-bus.c
22 +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
23 @@ -229,11 +229,10 @@ static bool fsl_mc_is_root_dprc(struct d
24 return dev == root_dprc_dev;
25 }
26
27 -static int get_dprc_icid(struct fsl_mc_io *mc_io,
28 - int container_id, u16 *icid)
29 +static int get_dprc_attr(struct fsl_mc_io *mc_io,
30 + int container_id, struct dprc_attributes *attr)
31 {
32 u16 dprc_handle;
33 - struct dprc_attributes attr;
34 int error;
35
36 error = dprc_open(mc_io, 0, container_id, &dprc_handle);
37 @@ -242,15 +241,14 @@ static int get_dprc_icid(struct fsl_mc_i
38 return error;
39 }
40
41 - memset(&attr, 0, sizeof(attr));
42 - error = dprc_get_attributes(mc_io, 0, dprc_handle, &attr);
43 + memset(attr, 0, sizeof(struct dprc_attributes));
44 + error = dprc_get_attributes(mc_io, 0, dprc_handle, attr);
45 if (error < 0) {
46 dev_err(mc_io->dev, "dprc_get_attributes() failed: %d\n",
47 error);
48 goto common_cleanup;
49 }
50
51 - *icid = attr.icid;
52 error = 0;
53
54 common_cleanup:
55 @@ -258,6 +256,34 @@ common_cleanup:
56 return error;
57 }
58
59 +static int get_dprc_icid(struct fsl_mc_io *mc_io,
60 + int container_id, u16 *icid)
61 +{
62 + struct dprc_attributes attr;
63 + int error;
64 +
65 + error = get_dprc_attr(mc_io, container_id, &attr);
66 + if (error == 0)
67 + *icid = attr.icid;
68 +
69 + return error;
70 +}
71 +
72 +static int get_dprc_version(struct fsl_mc_io *mc_io,
73 + int container_id, u16 *major, u16 *minor)
74 +{
75 + struct dprc_attributes attr;
76 + int error;
77 +
78 + error = get_dprc_attr(mc_io, container_id, &attr);
79 + if (error == 0) {
80 + *major = attr.version.major;
81 + *minor = attr.version.minor;
82 + }
83 +
84 + return error;
85 +}
86 +
87 static int translate_mc_addr(struct fsl_mc_device *mc_dev,
88 enum dprc_region_type mc_region_type,
89 u64 mc_offset, phys_addr_t *phys_addr)
90 @@ -719,11 +745,14 @@ static int fsl_mc_bus_probe(struct platf
91 goto error_cleanup_mc_io;
92 }
93
94 + error = get_dprc_version(mc_io, container_id,
95 + &obj_desc.ver_major, &obj_desc.ver_minor);
96 + if (error < 0)
97 + goto error_cleanup_mc_io;
98 +
99 obj_desc.vendor = FSL_MC_VENDOR_FREESCALE;
100 strcpy(obj_desc.type, "dprc");
101 obj_desc.id = container_id;
102 - obj_desc.ver_major = DPRC_VER_MAJOR;
103 - obj_desc.ver_minor = DPRC_VER_MINOR;
104 obj_desc.irq_count = 1;
105 obj_desc.region_count = 0;
106