History

bus: mhi: core: Add support for reading MHI info from device

The MHI register base has several registers used for getting the MHI specific information such as version, family, major, and minor numbers from the device. This information can be used by the controller drivers for usecases such as applying quirks for a specific revision etc... While at it, let's also rearrange the local variables in mhi_register_controller().

Manivannan Sadhasivam committed 6 years ago

Commit 3316ab21 parent 10cea233 files · +44 −2Browse files

Unified · Split

3 files
  1. drivers/bus/mhi/core/init.c +17 −2
  2. drivers/bus/mhi/core/internal.h +10 −0
  3. include/linux/mhi.h +17 −0
drivers/bus/mhi/core/init.c+17−2
@@ -802,12 +802,12 @@ error_ev_cfg: · 801 unmodified lines
802802 int mhi_register_controller(struct mhi_controller *mhi_cntrl,
803803 struct mhi_controller_config *config)
804804 {
805− int ret;
806− int i;
807805 struct mhi_event *mhi_event;
808806 struct mhi_chan *mhi_chan;
809807 struct mhi_cmd *mhi_cmd;
810808 struct mhi_device *mhi_dev;
809+ u32 soc_info;
810+ int ret, i;
811811
812812 if (!mhi_cntrl)
813813 return -EINVAL;
@@ -874,6 +874,21 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, · 60 unmodified lines
874874 mhi_cntrl->unmap_single = mhi_unmap_single_no_bb;
875875 }
876876
877+ /* Read the MHI device info */
878+ ret = mhi_read_reg(mhi_cntrl, mhi_cntrl->regs,
879+ SOC_HW_VERSION_OFFS, &soc_info);
880+ if (ret)
881+ goto error_alloc_dev;
882+
883+ mhi_cntrl->family_number = (soc_info & SOC_HW_VERSION_FAM_NUM_BMSK) >>
884+ SOC_HW_VERSION_FAM_NUM_SHFT;
885+ mhi_cntrl->device_number = (soc_info & SOC_HW_VERSION_DEV_NUM_BMSK) >>
886+ SOC_HW_VERSION_DEV_NUM_SHFT;
887+ mhi_cntrl->major_version = (soc_info & SOC_HW_VERSION_MAJOR_VER_BMSK) >>
888+ SOC_HW_VERSION_MAJOR_VER_SHFT;
889+ mhi_cntrl->minor_version = (soc_info & SOC_HW_VERSION_MINOR_VER_BMSK) >>
890+ SOC_HW_VERSION_MINOR_VER_SHFT;
891+
877892 /* Register controller with MHI bus */
878893 mhi_dev = mhi_alloc_device(mhi_cntrl);
879894 if (IS_ERR(mhi_dev)) {
drivers/bus/mhi/core/internal.h+10−0
@@ -196,6 +196,16 @@ extern struct bus_type mhi_bus_type; · 195 unmodified lines
196196 #define BHIE_RXVECSTATUS_STATUS_XFER_COMPL (0x02)
197197 #define BHIE_RXVECSTATUS_STATUS_ERROR (0x03)
198198
199+#define SOC_HW_VERSION_OFFS (0x224)
200+#define SOC_HW_VERSION_FAM_NUM_BMSK (0xF0000000)
201+#define SOC_HW_VERSION_FAM_NUM_SHFT (28)
202+#define SOC_HW_VERSION_DEV_NUM_BMSK (0x0FFF0000)
203+#define SOC_HW_VERSION_DEV_NUM_SHFT (16)
204+#define SOC_HW_VERSION_MAJOR_VER_BMSK (0x0000FF00)
205+#define SOC_HW_VERSION_MAJOR_VER_SHFT (8)
206+#define SOC_HW_VERSION_MINOR_VER_BMSK (0x000000FF)
207+#define SOC_HW_VERSION_MINOR_VER_SHFT (0)
208+
199209 #define EV_CTX_RESERVED_MASK GENMASK(7, 0)
200210 #define EV_CTX_INTMODC_MASK GENMASK(15, 8)
201211 #define EV_CTX_INTMODC_SHIFT 8
include/linux/mhi.h+17−0
@@ -310,6 +310,10 @@ struct mhi_controller_config { · 309 unmodified lines
310310 * @sw_ev_rings: Number of software event rings
311311 * @nr_irqs_req: Number of IRQs required to operate (optional)
312312 * @nr_irqs: Number of IRQ allocated by bus master (required)
313+ * @family_number: MHI controller family number
314+ * @device_number: MHI controller device number
315+ * @major_version: MHI controller major revision number
316+ * @minor_version: MHI controller minor revision number
313317 * @mhi_event: MHI event ring configurations table
314318 * @mhi_cmd: MHI command ring configurations table
315319 * @mhi_ctxt: MHI device context, shared memory between host and device
@@ -348,6 +352,15 @@ struct mhi_controller_config { · 32 unmodified lines
348352 * Fields marked as (required) need to be populated by the controller driver
349353 * before calling mhi_register_controller(). For the fields marked as (optional)
350354 * they can be populated depending on the usecase.
355+ *
356+ * The following fields are present for the purpose of implementing any device
357+ * specific quirks or customizations for specific MHI revisions used in device
358+ * by the controller drivers. The MHI stack will just populate these fields
359+ * during mhi_register_controller():
360+ * family_number
361+ * device_number
362+ * major_version
363+ * minor_version
351364 */
352365 struct mhi_controller {
353366 struct device *cntrl_dev;
@@ -375,6 +388,10 @@ struct mhi_controller { · 21 unmodified lines
375388 u32 sw_ev_rings;
376389 u32 nr_irqs_req;
377390 u32 nr_irqs;
391+ u32 family_number;
392+ u32 device_number;
393+ u32 major_version;
394+ u32 minor_version;
378395
379396 struct mhi_event *mhi_event;
380397 struct mhi_cmd *mhi_cmd;