mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
wifi: rt2x00: add nvmem eeprom support
Some embedded platforms have eeproms located in flash. Add nvmem support to handle this. Support is added for PCI and SOC backends. Signed-off-by: Rosen Penev <rosenp@gmail.com> Link: https://patch.msgid.link/20251027180639.3797-1-rosenp@gmail.com Signed-off-by: Johannes Berg <johannes.berg@intel.com>
This commit is contained in:
committed by
Johannes Berg
parent
db82ddeaf4
commit
ec81b33b23
@@ -24,6 +24,7 @@
|
|||||||
#include <linux/crc-ccitt.h>
|
#include <linux/crc-ccitt.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
|
#include <linux/nvmem-consumer.h>
|
||||||
#include <linux/slab.h>
|
#include <linux/slab.h>
|
||||||
|
|
||||||
#include "rt2x00.h"
|
#include "rt2x00.h"
|
||||||
@@ -10962,6 +10963,36 @@ int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse);
|
EXPORT_SYMBOL_GPL(rt2800_read_eeprom_efuse);
|
||||||
|
|
||||||
|
int rt2800_read_eeprom_nvmem(struct rt2x00_dev *rt2x00dev)
|
||||||
|
{
|
||||||
|
struct device_node *np = rt2x00dev->dev->of_node;
|
||||||
|
unsigned int len = rt2x00dev->ops->eeprom_size;
|
||||||
|
struct nvmem_cell *cell;
|
||||||
|
const void *data;
|
||||||
|
size_t retlen;
|
||||||
|
|
||||||
|
cell = of_nvmem_cell_get(np, "eeprom");
|
||||||
|
if (IS_ERR(cell))
|
||||||
|
return PTR_ERR(cell);
|
||||||
|
|
||||||
|
data = nvmem_cell_read(cell, &retlen);
|
||||||
|
nvmem_cell_put(cell);
|
||||||
|
|
||||||
|
if (IS_ERR(data))
|
||||||
|
return PTR_ERR(data);
|
||||||
|
|
||||||
|
if (retlen != len) {
|
||||||
|
dev_err(rt2x00dev->dev, "invalid eeprom size, required: 0x%04x\n", len);
|
||||||
|
kfree(data);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(rt2x00dev->eeprom, data, len);
|
||||||
|
kfree(data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
EXPORT_SYMBOL_GPL(rt2800_read_eeprom_nvmem);
|
||||||
|
|
||||||
static u8 rt2800_get_txmixer_gain_24g(struct rt2x00_dev *rt2x00dev)
|
static u8 rt2800_get_txmixer_gain_24g(struct rt2x00_dev *rt2x00dev)
|
||||||
{
|
{
|
||||||
u16 word;
|
u16 word;
|
||||||
|
|||||||
@@ -248,6 +248,8 @@ void rt2800_disable_radio(struct rt2x00_dev *rt2x00dev);
|
|||||||
int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
|
int rt2800_efuse_detect(struct rt2x00_dev *rt2x00dev);
|
||||||
int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
|
int rt2800_read_eeprom_efuse(struct rt2x00_dev *rt2x00dev);
|
||||||
|
|
||||||
|
int rt2800_read_eeprom_nvmem(struct rt2x00_dev *rt2x00dev);
|
||||||
|
|
||||||
int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
|
int rt2800_probe_hw(struct rt2x00_dev *rt2x00dev);
|
||||||
|
|
||||||
void rt2800_get_key_seq(struct ieee80211_hw *hw,
|
void rt2800_get_key_seq(struct ieee80211_hw *hw,
|
||||||
|
|||||||
@@ -278,6 +278,9 @@ static int rt2800pci_read_eeprom(struct rt2x00_dev *rt2x00dev)
|
|||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
|
if (!rt2800_read_eeprom_nvmem(rt2x00dev))
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (rt2800pci_efuse_detect(rt2x00dev))
|
if (rt2800pci_efuse_detect(rt2x00dev))
|
||||||
retval = rt2800pci_read_eeprom_efuse(rt2x00dev);
|
retval = rt2800pci_read_eeprom_efuse(rt2x00dev);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -92,8 +92,12 @@ static int rt2800soc_set_device_state(struct rt2x00_dev *rt2x00dev,
|
|||||||
|
|
||||||
static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev)
|
static int rt2800soc_read_eeprom(struct rt2x00_dev *rt2x00dev)
|
||||||
{
|
{
|
||||||
void __iomem *base_addr = ioremap(0x1F040000, EEPROM_SIZE);
|
void __iomem *base_addr;
|
||||||
|
|
||||||
|
if (!rt2800_read_eeprom_nvmem(rt2x00dev))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
base_addr = ioremap(0x1F040000, EEPROM_SIZE);
|
||||||
if (!base_addr)
|
if (!base_addr)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user