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
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.
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>
18 drivers/staging/fsl-mc/bus/mc-bus.c | 45 ++++++++++++++++++++++++++++-------
19 1 file changed, 37 insertions(+), 8 deletions(-)
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;
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)
33 - struct dprc_attributes attr;
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
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);
46 dev_err(mc_io->dev, "dprc_get_attributes() failed: %d\n",
55 @@ -258,6 +256,34 @@ common_cleanup:
59 +static int get_dprc_icid(struct fsl_mc_io *mc_io,
60 + int container_id, u16 *icid)
62 + struct dprc_attributes attr;
65 + error = get_dprc_attr(mc_io, container_id, &attr);
72 +static int get_dprc_version(struct fsl_mc_io *mc_io,
73 + int container_id, u16 *major, u16 *minor)
75 + struct dprc_attributes attr;
78 + error = get_dprc_attr(mc_io, container_id, &attr);
80 + *major = attr.version.major;
81 + *minor = attr.version.minor;
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;
94 + error = get_dprc_version(mc_io, container_id,
95 + &obj_desc.ver_major, &obj_desc.ver_minor);
97 + goto error_cleanup_mc_io;
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;