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
802int mhi_register_controller(struct mhi_controller *mhi_cntrl,802int mhi_register_controller(struct mhi_controller *mhi_cntrl,
803 struct mhi_controller_config *config)803 struct mhi_controller_config *config)
804{804{
805 int ret;
806 int i;
807 struct mhi_event *mhi_event;805 struct mhi_event *mhi_event;
808 struct mhi_chan *mhi_chan;806 struct mhi_chan *mhi_chan;
809 struct mhi_cmd *mhi_cmd;807 struct mhi_cmd *mhi_cmd;
810 struct mhi_device *mhi_dev;808 struct mhi_device *mhi_dev;
809 u32 soc_info;
810 int ret, i;
811 811
812 if (!mhi_cntrl)812 if (!mhi_cntrl)
813 return -EINVAL;813 return -EINVAL;
@@ -874,6 +874,21 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl, · 60 unmodified lines
874 mhi_cntrl->unmap_single = mhi_unmap_single_no_bb;874 mhi_cntrl->unmap_single = mhi_unmap_single_no_bb;
875 }875 }
876 876
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
877 /* Register controller with MHI bus */892 /* Register controller with MHI bus */
878 mhi_dev = mhi_alloc_device(mhi_cntrl);893 mhi_dev = mhi_alloc_device(mhi_cntrl);
879 if (IS_ERR(mhi_dev)) {894 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
196#define BHIE_RXVECSTATUS_STATUS_XFER_COMPL (0x02)196#define BHIE_RXVECSTATUS_STATUS_XFER_COMPL (0x02)
197#define BHIE_RXVECSTATUS_STATUS_ERROR (0x03)197#define BHIE_RXVECSTATUS_STATUS_ERROR (0x03)
198 198
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
199#define EV_CTX_RESERVED_MASK GENMASK(7, 0)209#define EV_CTX_RESERVED_MASK GENMASK(7, 0)
200#define EV_CTX_INTMODC_MASK GENMASK(15, 8)210#define EV_CTX_INTMODC_MASK GENMASK(15, 8)
201#define EV_CTX_INTMODC_SHIFT 8211#define EV_CTX_INTMODC_SHIFT 8
include/linux/mhi.h+17−0
@@ -310,6 +310,10 @@ struct mhi_controller_config { · 309 unmodified lines
310 * @sw_ev_rings: Number of software event rings310 * @sw_ev_rings: Number of software event rings
311 * @nr_irqs_req: Number of IRQs required to operate (optional)311 * @nr_irqs_req: Number of IRQs required to operate (optional)
312 * @nr_irqs: Number of IRQ allocated by bus master (required)312 * @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
313 * @mhi_event: MHI event ring configurations table317 * @mhi_event: MHI event ring configurations table
314 * @mhi_cmd: MHI command ring configurations table318 * @mhi_cmd: MHI command ring configurations table
315 * @mhi_ctxt: MHI device context, shared memory between host and device319 * @mhi_ctxt: MHI device context, shared memory between host and device
@@ -348,6 +352,15 @@ struct mhi_controller_config { · 32 unmodified lines
348 * Fields marked as (required) need to be populated by the controller driver352 * Fields marked as (required) need to be populated by the controller driver
349 * before calling mhi_register_controller(). For the fields marked as (optional)353 * before calling mhi_register_controller(). For the fields marked as (optional)
350 * they can be populated depending on the usecase.354 * 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
351 */364 */
352struct mhi_controller {365struct mhi_controller {
353 struct device *cntrl_dev;366 struct device *cntrl_dev;
@@ -375,6 +388,10 @@ struct mhi_controller { · 21 unmodified lines
375 u32 sw_ev_rings;388 u32 sw_ev_rings;
376 u32 nr_irqs_req;389 u32 nr_irqs_req;
377 u32 nr_irqs;390 u32 nr_irqs;
391 u32 family_number;
392 u32 device_number;
393 u32 major_version;
394 u32 minor_version;
378 395
379 struct mhi_event *mhi_event;396 struct mhi_event *mhi_event;
380 struct mhi_cmd *mhi_cmd;397 struct mhi_cmd *mhi_cmd;