Release 4.7 drivers/mtd/nand/orion_nand.c
/*
* drivers/mtd/nand/orion_nand.c
*
* NAND support for Marvell Orion SoC platforms
*
* Tzachi Perelstein <tzachi@marvell.com>
*
* This file is licensed under the terms of the GNU General Public
* License version 2. This program is licensed "as is" without any
* warranty of any kind, whether express or implied.
*/
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/of.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/nand.h>
#include <linux/mtd/partitions.h>
#include <linux/clk.h>
#include <linux/err.h>
#include <linux/io.h>
#include <asm/sizes.h>
#include <linux/platform_data/mtd-orion_nand.h>
static void orion_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, unsigned int ctrl)
{
struct nand_chip *nc = mtd_to_nand(mtd);
struct orion_nand_data *board = nand_get_controller_data(nc);
u32 offs;
if (cmd == NAND_CMD_NONE)
return;
if (ctrl & NAND_CLE)
offs = (1 << board->cle);
else if (ctrl & NAND_ALE)
offs = (1 << board->ale);
else
return;
if (nc->options & NAND_BUSWIDTH_16)
offs <<= 1;
writeb(cmd, nc->IO_ADDR_W + offs);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tzachi perelstein | tzachi perelstein | 100 | 94.34% | 1 | 33.33% |
boris brezillon | boris brezillon | 6 | 5.66% | 2 | 66.67% |
| Total | 106 | 100.00% | 3 | 100.00% |
static void orion_nand_read_buf(struct mtd_info *mtd, uint8_t *buf, int len)
{
struct nand_chip *chip = mtd_to_nand(mtd);
void __iomem *io_base = chip->IO_ADDR_R;
uint64_t *buf64;
int i = 0;
while (len && (unsigned long)buf & 7) {
*buf++ = readb(io_base);
len--;
}
buf64 = (uint64_t *)buf;
while (i < len/8) {
/*
* Since GCC has no proper constraint (PR 43518)
* force x variable to r2/r3 registers as ldrd instruction
* requires first register to be even.
*/
register uint64_t x asm ("r2");
asm volatile ("ldrd\t%0, [%1]" : "=&r" (x) : "r" (io_base));
buf64[i++] = x;
}
i *= 8;
while (i < len)
buf[i++] = readb(io_base);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nicolas pitre | nicolas pitre | 119 | 90.84% | 1 | 25.00% |
paulius zaleckas | paulius zaleckas | 6 | 4.58% | 1 | 25.00% |
simon kagstrom | simon kagstrom | 3 | 2.29% | 1 | 25.00% |
boris brezillon | boris brezillon | 3 | 2.29% | 1 | 25.00% |
| Total | 131 | 100.00% | 4 | 100.00% |
static int __init orion_nand_probe(struct platform_device *pdev)
{
struct mtd_info *mtd;
struct nand_chip *nc;
struct orion_nand_data *board;
struct resource *res;
struct clk *clk;
void __iomem *io_base;
int ret = 0;
u32 val = 0;
nc = devm_kzalloc(&pdev->dev,
sizeof(struct nand_chip),
GFP_KERNEL);
if (!nc)
return -ENOMEM;
mtd = nand_to_mtd(nc);
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
io_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(io_base))
return PTR_ERR(io_base);
if (pdev->dev.of_node) {
board = devm_kzalloc(&pdev->dev, sizeof(struct orion_nand_data),
GFP_KERNEL);
if (!board)
return -ENOMEM;
if (!of_property_read_u32(pdev->dev.of_node, "cle", &val))
board->cle = (u8)val;
else
board->cle = 0;
if (!of_property_read_u32(pdev->dev.of_node, "ale", &val))
board->ale = (u8)val;
else
board->ale = 1;
if (!of_property_read_u32(pdev->dev.of_node,
"bank-width", &val))
board->width = (u8)val * 8;
else
board->width = 8;
if (!of_property_read_u32(pdev->dev.of_node,
"chip-delay", &val))
board->chip_delay = (u8)val;
} else {
board = dev_get_platdata(&pdev->dev);
}
mtd->dev.parent = &pdev->dev;
nand_set_controller_data(nc, board);
nand_set_flash_node(nc, pdev->dev.of_node);
nc->IO_ADDR_R = nc->IO_ADDR_W = io_base;
nc->cmd_ctrl = orion_nand_cmd_ctrl;
nc->read_buf = orion_nand_read_buf;
nc->ecc.mode = NAND_ECC_SOFT;
nc->ecc.algo = NAND_ECC_HAMMING;
if (board->chip_delay)
nc->chip_delay = board->chip_delay;
WARN(board->width > 16,
"%d bit bus width out of range",
board->width);
if (board->width == 16)
nc->options |= NAND_BUSWIDTH_16;
if (board->dev_ready)
nc->dev_ready = board->dev_ready;
platform_set_drvdata(pdev, mtd);
/* Not all platforms can gate the clock, so it is not
an error if the clock does not exists. */
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_prepare_enable(clk);
clk_put(clk);
}
if (nand_scan(mtd, 1)) {
ret = -ENXIO;
goto no_dev;
}
mtd->name = "orion_nand";
ret = mtd_device_register(mtd, board->parts, board->nr_parts);
if (ret) {
nand_release(mtd);
goto no_dev;
}
return 0;
no_dev:
if (!IS_ERR(clk)) {
clk_disable_unprepare(clk);
clk_put(clk);
}
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tzachi perelstein | tzachi perelstein | 188 | 34.50% | 1 | 6.25% |
jamie lentin | jamie lentin | 183 | 33.58% | 1 | 6.25% |
andrew lunn | andrew lunn | 38 | 6.97% | 1 | 6.25% |
michael opdenacker | michael opdenacker | 21 | 3.85% | 1 | 6.25% |
simon baatz | simon baatz | 20 | 3.67% | 1 | 6.25% |
h hartley sweeten | h hartley sweeten | 17 | 3.12% | 1 | 6.25% |
ben dooks | ben dooks | 14 | 2.57% | 1 | 6.25% |
saeed bishara | saeed bishara | 14 | 2.57% | 1 | 6.25% |
brian norris | brian norris | 12 | 2.20% | 1 | 6.25% |
rafal milecki | rafal milecki | 8 | 1.47% | 1 | 6.25% |
frans klaver | frans klaver | 7 | 1.28% | 1 | 6.25% |
boris brezillon | boris brezillon | 7 | 1.28% | 2 | 12.50% |
jingoo han | jingoo han | 6 | 1.10% | 1 | 6.25% |
nicolas pitre | nicolas pitre | 6 | 1.10% | 1 | 6.25% |
dmitry eremin-baryshkov | dmitry eremin-baryshkov | 4 | 0.73% | 1 | 6.25% |
| Total | 545 | 100.00% | 16 | 100.00% |
static int orion_nand_remove(struct platform_device *pdev)
{
struct mtd_info *mtd = platform_get_drvdata(pdev);
struct clk *clk;
nand_release(mtd);
clk = clk_get(&pdev->dev, NULL);
if (!IS_ERR(clk)) {
clk_disable_unprepare(clk);
clk_put(clk);
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
andrew lunn | andrew lunn | 36 | 54.55% | 1 | 50.00% |
tzachi perelstein | tzachi perelstein | 30 | 45.45% | 1 | 50.00% |
| Total | 66 | 100.00% | 2 | 100.00% |
#ifdef CONFIG_OF
static const struct of_device_id orion_nand_of_match_table[] = {
{ .compatible = "marvell,orion-nand", },
{},
};
MODULE_DEVICE_TABLE(of, orion_nand_of_match_table);
#endif
static struct platform_driver orion_nand_driver = {
.remove = orion_nand_remove,
.driver = {
.name = "orion_nand",
.of_match_table = of_match_ptr(orion_nand_of_match_table),
},
};
module_platform_driver_probe(orion_nand_driver, orion_nand_probe);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Tzachi Perelstein");
MODULE_DESCRIPTION("NAND glue for Orion platforms");
MODULE_ALIAS("platform:orion_nand");
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
tzachi perelstein | tzachi perelstein | 387 | 39.81% | 1 | 3.85% |
jamie lentin | jamie lentin | 213 | 21.91% | 1 | 3.85% |
nicolas pitre | nicolas pitre | 125 | 12.86% | 1 | 3.85% |
andrew lunn | andrew lunn | 81 | 8.33% | 2 | 7.69% |
michael opdenacker | michael opdenacker | 22 | 2.26% | 1 | 3.85% |
simon baatz | simon baatz | 20 | 2.06% | 1 | 3.85% |
h hartley sweeten | h hartley sweeten | 17 | 1.75% | 1 | 3.85% |
boris brezillon | boris brezillon | 16 | 1.65% | 3 | 11.54% |
ben dooks | ben dooks | 14 | 1.44% | 1 | 3.85% |
saeed bishara | saeed bishara | 14 | 1.44% | 1 | 3.85% |
brian norris | brian norris | 12 | 1.23% | 1 | 3.85% |
jingoo han | jingoo han | 8 | 0.82% | 3 | 11.54% |
rafal milecki | rafal milecki | 8 | 0.82% | 1 | 3.85% |
luis de bethencourt | luis de bethencourt | 7 | 0.72% | 1 | 3.85% |
frans klaver | frans klaver | 7 | 0.72% | 1 | 3.85% |
paulius zaleckas | paulius zaleckas | 6 | 0.62% | 1 | 3.85% |
kay sievers | kay sievers | 5 | 0.51% | 1 | 3.85% |
dmitry eremin-baryshkov | dmitry eremin-baryshkov | 4 | 0.41% | 1 | 3.85% |
simon kagstrom | simon kagstrom | 3 | 0.31% | 1 | 3.85% |
uwe kleine-koenig | uwe kleine-koenig | 2 | 0.21% | 1 | 3.85% |
arnd bergmann | arnd bergmann | 1 | 0.10% | 1 | 3.85% |
| Total | 972 | 100.00% | 26 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.