Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ufs: add TC G210 platform driver

This patch adds a glue platform driver for the Synopsys G210 Test Chip.

Signed-off-by: Joao Pinto <jpinto@synopsys.com>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>

authored by

Joao Pinto and committed by
Martin K. Petersen
fc040a3f 947e7013

+148
+26
Documentation/devicetree/bindings/ufs/tc-dwc-g210-pltfrm.txt
··· 1 + * Universal Flash Storage (UFS) DesignWare Host Controller 2 + 3 + DWC_UFS nodes are defined to describe on-chip UFS host controllers and MPHY. 4 + Each UFS controller instance should have its own node. 5 + 6 + Required properties: 7 + - compatible : compatible list must contain the PHY type & version: 8 + "snps,g210-tc-6.00-20bit" 9 + "snps,g210-tc-6.00-40bit" 10 + complemented with the Controller IP version: 11 + "snps,dwc-ufshcd-1.40a" 12 + complemented with the JEDEC version: 13 + "jedec,ufs-1.1" 14 + "jedec,ufs-2.0" 15 + 16 + - reg : <registers mapping> 17 + - interrupts : <interrupt mapping for UFS host controller IRQ> 18 + 19 + Example for a setup using a 1.40a DWC Controller with a 6.00 G210 40-bit TC: 20 + dwc-ufs@d0000000 { 21 + compatible = "snps,g210-tc-6.00-40bit", 22 + "snps,dwc-ufshcd-1.40a", 23 + "jedec,ufs-2.0"; 24 + reg = < 0xd0000000 0x10000 >; 25 + interrupts = < 24 >; 26 + };
+8
drivers/scsi/ufs/Kconfig
··· 72 72 73 73 If unsure, say N. 74 74 75 + config SCSI_UFS_DWC_TC_PLATFORM 76 + tristate "DesignWare platform support using a G210 Test Chip" 77 + depends on SCSI_UFSHCD_PLATFORM 78 + ---help--- 79 + Synopsys Test Chip is a PHY for prototyping purposes. 80 + 81 + If unsure, say N. 82 + 75 83 config SCSI_UFS_QCOM 76 84 tristate "QCOM specific hooks to UFS controller platform driver" 77 85 depends on SCSI_UFSHCD_PLATFORM && ARCH_QCOM
+1
drivers/scsi/ufs/Makefile
··· 1 1 # UFSHCD makefile 2 + obj-$(CONFIG_SCSI_UFS_DWC_TC_PLATFORM) += tc-dwc-g210-pltfrm.o ufshcd-dwc.o tc-dwc-g210.o 2 3 obj-$(CONFIG_SCSI_UFS_QCOM) += ufs-qcom.o 3 4 obj-$(CONFIG_SCSI_UFSHCD) += ufshcd.o 4 5 obj-$(CONFIG_SCSI_UFSHCD_PCI) += ufshcd-pci.o
+113
drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
··· 1 + /* 2 + * Synopsys G210 Test Chip driver 3 + * 4 + * Copyright (C) 2015-2016 Synopsys, Inc. (www.synopsys.com) 5 + * 6 + * Authors: Joao Pinto <jpinto@synopsys.com> 7 + * 8 + * This program is free software; you can redistribute it and/or modify 9 + * it under the terms of the GNU General Public License version 2 as 10 + * published by the Free Software Foundation. 11 + */ 12 + 13 + #include <linux/kernel.h> 14 + #include <linux/module.h> 15 + #include <linux/platform_device.h> 16 + #include <linux/of.h> 17 + #include <linux/delay.h> 18 + 19 + #include "ufshcd-pltfrm.h" 20 + #include "ufshcd-dwc.h" 21 + #include "tc-dwc-g210.h" 22 + 23 + /** 24 + * UFS DWC specific variant operations 25 + */ 26 + static struct ufs_hba_variant_ops tc_dwc_g210_20bit_pltfm_hba_vops = { 27 + .name = "tc-dwc-g210-pltfm", 28 + .link_startup_notify = ufshcd_dwc_link_startup_notify, 29 + .phy_initialization = tc_dwc_g210_config_20_bit, 30 + }; 31 + 32 + static struct ufs_hba_variant_ops tc_dwc_g210_40bit_pltfm_hba_vops = { 33 + .name = "tc-dwc-g210-pltfm", 34 + .link_startup_notify = ufshcd_dwc_link_startup_notify, 35 + .phy_initialization = tc_dwc_g210_config_40_bit, 36 + }; 37 + 38 + static const struct of_device_id tc_dwc_g210_pltfm_match[] = { 39 + { 40 + .compatible = "snps,g210-tc-6.00-20bit", 41 + .data = &tc_dwc_g210_20bit_pltfm_hba_vops, 42 + }, 43 + { 44 + .compatible = "snps,g210-tc-6.00-40bit", 45 + .data = &tc_dwc_g210_40bit_pltfm_hba_vops, 46 + }, 47 + { }, 48 + }; 49 + MODULE_DEVICE_TABLE(of, tc_dwc_g210_pltfm_match); 50 + 51 + /** 52 + * tc_dwc_g210_pltfm_probe() 53 + * @pdev: pointer to platform device structure 54 + * 55 + */ 56 + static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev) 57 + { 58 + int err; 59 + const struct of_device_id *of_id; 60 + struct ufs_hba_variant_ops *vops; 61 + struct device *dev = &pdev->dev; 62 + 63 + of_id = of_match_node(tc_dwc_g210_pltfm_match, dev->of_node); 64 + vops = (struct ufs_hba_variant_ops *)of_id->data; 65 + 66 + /* Perform generic probe */ 67 + err = ufshcd_pltfrm_init(pdev, vops); 68 + if (err) 69 + dev_err(dev, "ufshcd_pltfrm_init() failed %d\n", err); 70 + 71 + return err; 72 + } 73 + 74 + /** 75 + * tc_dwc_g210_pltfm_remove() 76 + * @pdev: pointer to platform device structure 77 + * 78 + */ 79 + static int tc_dwc_g210_pltfm_remove(struct platform_device *pdev) 80 + { 81 + struct ufs_hba *hba = platform_get_drvdata(pdev); 82 + 83 + pm_runtime_get_sync(&(pdev)->dev); 84 + ufshcd_remove(hba); 85 + 86 + return 0; 87 + } 88 + 89 + static const struct dev_pm_ops tc_dwc_g210_pltfm_pm_ops = { 90 + .suspend = ufshcd_pltfrm_suspend, 91 + .resume = ufshcd_pltfrm_resume, 92 + .runtime_suspend = ufshcd_pltfrm_runtime_suspend, 93 + .runtime_resume = ufshcd_pltfrm_runtime_resume, 94 + .runtime_idle = ufshcd_pltfrm_runtime_idle, 95 + }; 96 + 97 + static struct platform_driver tc_dwc_g210_pltfm_driver = { 98 + .probe = tc_dwc_g210_pltfm_probe, 99 + .remove = tc_dwc_g210_pltfm_remove, 100 + .shutdown = ufshcd_pltfrm_shutdown, 101 + .driver = { 102 + .name = "tc-dwc-g210-pltfm", 103 + .pm = &tc_dwc_g210_pltfm_pm_ops, 104 + .of_match_table = of_match_ptr(tc_dwc_g210_pltfm_match), 105 + }, 106 + }; 107 + 108 + module_platform_driver(tc_dwc_g210_pltfm_driver); 109 + 110 + MODULE_ALIAS("platform:tc-dwc-g210-pltfm"); 111 + MODULE_DESCRIPTION("Synopsys Test Chip G210 platform glue driver"); 112 + MODULE_AUTHOR("Joao Pinto <Joao.Pinto@synopsys.com>"); 113 + MODULE_LICENSE("Dual BSD/GPL");