at25.c (4f2c0a4acffbec01079c28f839422e64ddeff004) at25.c (0eb468b6e1c56b55c01bfc588f9a519ac15b4ff5)
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Driver for most of the SPI EEPROMs, such as Atmel AT25 models
4 * and Cypress FRAMs FM25 models.
5 *
6 * Copyright (C) 2006 David Brownell
7 */
8

--- 423 unchanged lines hidden (view full) ---

432static int at25_probe(struct spi_device *spi)
433{
434 struct at25_data *at25 = NULL;
435 int err;
436 int sr;
437 struct spi_eeprom *pdata;
438 bool is_fram;
439
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Driver for most of the SPI EEPROMs, such as Atmel AT25 models
4 * and Cypress FRAMs FM25 models.
5 *
6 * Copyright (C) 2006 David Brownell
7 */
8

--- 423 unchanged lines hidden (view full) ---

432static int at25_probe(struct spi_device *spi)
433{
434 struct at25_data *at25 = NULL;
435 int err;
436 int sr;
437 struct spi_eeprom *pdata;
438 bool is_fram;
439
440 err = device_property_match_string(&spi->dev, "compatible", "cypress,fm25");
441 if (err >= 0)
442 is_fram = true;
443 else
444 is_fram = false;
445
446 /*
447 * Ping the chip ... the status register is pretty portable,
448 * unlike probing manufacturer IDs. We do expect that system
449 * firmware didn't write it in the past few milliseconds!
450 */
451 sr = spi_w8r8(spi, AT25_RDSR);
452 if (sr < 0 || sr & AT25_SR_nRDY) {
453 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr);
454 return -ENXIO;
455 }
456
457 at25 = devm_kzalloc(&spi->dev, sizeof(*at25), GFP_KERNEL);
458 if (!at25)
459 return -ENOMEM;
460
461 mutex_init(&at25->lock);
462 at25->spi = spi;
463 spi_set_drvdata(spi, at25);
464
440 /*
441 * Ping the chip ... the status register is pretty portable,
442 * unlike probing manufacturer IDs. We do expect that system
443 * firmware didn't write it in the past few milliseconds!
444 */
445 sr = spi_w8r8(spi, AT25_RDSR);
446 if (sr < 0 || sr & AT25_SR_nRDY) {
447 dev_dbg(&spi->dev, "rdsr --> %d (%02x)\n", sr, sr);
448 return -ENXIO;
449 }
450
451 at25 = devm_kzalloc(&spi->dev, sizeof(*at25), GFP_KERNEL);
452 if (!at25)
453 return -ENOMEM;
454
455 mutex_init(&at25->lock);
456 at25->spi = spi;
457 spi_set_drvdata(spi, at25);
458
459 is_fram = fwnode_device_is_compatible(dev_fwnode(&spi->dev), "cypress,fm25");
460
465 /* Chip description */
466 pdata = dev_get_platdata(&spi->dev);
467 if (pdata) {
468 at25->chip = *pdata;
469 } else {
470 if (is_fram)
471 err = at25_fram_to_chip(&spi->dev, &at25->chip);
472 else

--- 64 unchanged lines hidden ---
461 /* Chip description */
462 pdata = dev_get_platdata(&spi->dev);
463 if (pdata) {
464 at25->chip = *pdata;
465 } else {
466 if (is_fram)
467 err = at25_fram_to_chip(&spi->dev, &at25->chip);
468 else

--- 64 unchanged lines hidden ---