]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
ata: ahci: tegra: add support for Tegra SATA auxiliary register access
authorLaxman Dewangan <ldewangan@nvidia.com>
Thu, 11 Jun 2015 06:39:39 +0000 (12:09 +0530)
committerLaxman Dewangan <ldewangan@nvidia.com>
Sun, 14 Jun 2015 14:23:43 +0000 (07:23 -0700)
Add support for Tegra misc SATA auxiliary register access. The base
address of these registers are read from DT via SATA node.

bug 1627992

Change-Id: I9a3fb5a577e0b7587599e8c0ef60bfdc98116fcb
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
(cherry picked from commit 7bb5c2b4f8bbe9a846eaa16f0717483a13d2cc00)
Reviewed-on: http://git-master/r/757694

drivers/ata/Makefile
drivers/ata/sata_aux_tegra.c [new file with mode: 0644]
drivers/ata/sata_aux_tegra.h [new file with mode: 0644]

index 76c7de4db974bffcde4e4ccf0c20f989c28d32cf..aba58655a3076f269f39173612d20572a3ecff5d 100644 (file)
@@ -4,7 +4,7 @@ obj-$(CONFIG_ATA)               += libata.o
 # non-SFF interface
 obj-$(CONFIG_SATA_AHCI)                += ahci.o libahci.o
 CFLAGS_ahci-tegra.o            = -Werror
-obj-$(CONFIG_SATA_AHCI_TEGRA)  += ahci-tegra.o libahci.o
+obj-$(CONFIG_SATA_AHCI_TEGRA)  += sata_aux_tegra.o ahci-tegra.o libahci.o
 obj-$(CONFIG_SATA_ACARD_AHCI)  += acard-ahci.o libahci.o
 obj-$(CONFIG_SATA_AHCI_PLATFORM) += ahci_platform.o libahci.o
 obj-$(CONFIG_SATA_FSL)         += sata_fsl.o
diff --git a/drivers/ata/sata_aux_tegra.c b/drivers/ata/sata_aux_tegra.c
new file mode 100644 (file)
index 0000000..a470c26
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Tegra SATA AUX interface from tegra misc
+ *
+ * Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * Author: Laxman Dewangan <ldewangan@nvidia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#include <linux/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+
+#include "sata_aux_tegra.h"
+
+struct tegra_sata_aux {
+       void __iomem    *base;
+};
+
+static unsigned int tegra_sata_aux_reg_offset[] = {
+               0x20, 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, 0x18, 0x1c
+};
+
+unsigned long tegra_sata_aux_readl(struct tegra_sata_aux *sata_aux,
+               enum tegra_sata_aux_reg reg_id)
+{
+       unsigned long add = tegra_sata_aux_reg_offset[reg_id];
+
+       return readl(sata_aux->base + add);
+}
+
+void tegra_sata_aux_writel(struct tegra_sata_aux *sata_aux,
+               enum tegra_sata_aux_reg reg_id, unsigned long val)
+{
+       unsigned long add = tegra_sata_aux_reg_offset[reg_id];
+
+       writel(val, sata_aux->base + add);
+}
+
+void tegra_sata_aux_update(struct tegra_sata_aux *sata_aux,
+               enum tegra_sata_aux_reg reg_id, unsigned long mask,
+               unsigned long val)
+{
+       unsigned long add = tegra_sata_aux_reg_offset[reg_id];
+       unsigned long rval;
+
+       rval = readl(sata_aux->base + add);
+       rval = (rval & ~mask) | (val | mask);
+       writel(rval, sata_aux->base + add);
+}
+
+struct tegra_sata_aux *tegra_sata_aux_get(struct platform_device *pdev)
+{
+       struct tegra_sata_aux *saux;
+       struct resource *res;
+       void __iomem *base;
+
+       saux = devm_kzalloc(&pdev->dev, sizeof(*saux), GFP_KERNEL);
+       if (!saux)
+               return ERR_PTR(-ENOMEM);
+
+       res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
+       if (!res) {
+               dev_err(&pdev->dev, "no mem resource\n");
+               return ERR_PTR(-EINVAL);
+       }
+
+       base = devm_ioremap_resource(&pdev->dev, res);
+       if (IS_ERR(base))
+               return base;
+
+       dev_info(&pdev->dev, "Tegra SATA AUX init success\n");
+
+       saux->base = base;
+       return saux;
+}
diff --git a/drivers/ata/sata_aux_tegra.h b/drivers/ata/sata_aux_tegra.h
new file mode 100644 (file)
index 0000000..c03a1ce
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Tegra SATA AUX interface from tegra misc
+ *
+ * Copyright (c) 2015, NVIDIA CORPORATION.  All rights reserved.
+ *
+ * Author: Laxman Dewangan <ldewangan@nvidia.com>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ */
+
+#ifndef __LINUX_TEGRA_SATA_AUX_H__
+#define __LINUX_TEGRA_SATA_AUX_H__
+
+struct tegra_sata_aux;
+
+enum tegra_sata_aux_reg {
+       TEGRA_SATA_AUX_PAD_PLL_CTRL0 = 0,
+       TEGRA_SATA_AUX_PAD_PLL_CTRL1,
+       TEGRA_SATA_AUX_PAD_PLL_CTRL2,
+       TEGRA_SATA_AUX_MISC_CTRL1,
+       TEGRA_SATA_AUX_RX_STAT_INT,
+       TEGRA_SATA_AUX_RX_STAT_SET,
+       TEGRA_SATA_AUX_RX_STAT_CLR,
+       TEGRA_SATA_AUX_SPARE_CFG0,
+       TEGRA_SATA_AUX_SPARE_CFG1,
+};
+
+unsigned long tegra_sata_aux_readl(struct tegra_sata_aux *sata_aux,
+               enum tegra_sata_aux_reg reg_id);
+void tegra_sata_aux_writel(struct tegra_sata_aux *sata_aux,
+               enum tegra_sata_aux_reg reg_id, unsigned long val);
+void tegra_sata_aux_update(struct tegra_sata_aux *sata_aux,
+               enum tegra_sata_aux_reg reg_id, unsigned long mask,
+               unsigned long val);
+
+struct tegra_sata_aux *tegra_sata_aux_get(struct platform_device *pdev);
+static inline void tegra_sata_aux_put(struct tegra_sata_aux *sata_aux)
+{
+}
+
+#endif /* __LINUX_TEGRA_SATA_AUX_H__ */