#include "bman_priv.h"
u16 bman_ip_rev;
EXPORT_SYMBOL(…);
#define REG_FBPR_FPC …
#define REG_ECSR …
#define REG_ECIR …
#define REG_EADR …
#define REG_EDATA(n) …
#define REG_SBEC(n) …
#define REG_IP_REV_1 …
#define REG_IP_REV_2 …
#define REG_FBPR_BARE …
#define REG_FBPR_BAR …
#define REG_FBPR_AR …
#define REG_SRCIDR …
#define REG_LIODNR …
#define REG_ERR_ISR …
#define REG_ERR_IER …
#define REG_ERR_ISDR …
#define BM_EIRQ_IVCI …
#define BM_EIRQ_FLWI …
#define BM_EIRQ_MBEI …
#define BM_EIRQ_SBEI …
#define BM_EIRQ_BSCN …
struct bman_hwerr_txt { … };
static const struct bman_hwerr_txt bman_hwerr_txts[] = …;
#define BMAN_ERRS_TO_DISABLE …
static u32 __iomem *bm_ccsr_start;
static inline u32 bm_ccsr_in(u32 offset)
{ … }
static inline void bm_ccsr_out(u32 offset, u32 val)
{ … }
static void bm_get_version(u16 *id, u8 *major, u8 *minor)
{ … }
#define FBPR_AR_RPRIO_HI …
static int __bman_probed;
static int __bman_requires_cleanup;
static int bm_set_memory(u64 ba, u32 size)
{ … }
static dma_addr_t fbpr_a;
static size_t fbpr_sz;
static irqreturn_t bman_isr(int irq, void *ptr)
{ … }
int bman_is_probed(void)
{ … }
EXPORT_SYMBOL_GPL(…);
int bman_requires_cleanup(void)
{ … }
void bman_done_cleanup(void)
{ … }
static int fsl_bman_probe(struct platform_device *pdev)
{
int ret, err_irq;
struct device *dev = &pdev->dev;
struct device_node *node = dev->of_node;
struct resource *res;
u16 id, bm_pool_cnt;
u8 major, minor;
__bman_probed = -1;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(dev, "Can't get %pOF property 'IORESOURCE_MEM'\n",
node);
return -ENXIO;
}
bm_ccsr_start = devm_ioremap(dev, res->start, resource_size(res));
if (!bm_ccsr_start)
return -ENXIO;
bm_get_version(&id, &major, &minor);
if (major == 1 && minor == 0) {
bman_ip_rev = BMAN_REV10;
bm_pool_cnt = BM_POOL_MAX;
} else if (major == 2 && minor == 0) {
bman_ip_rev = BMAN_REV20;
bm_pool_cnt = 8;
} else if (major == 2 && minor == 1) {
bman_ip_rev = BMAN_REV21;
bm_pool_cnt = BM_POOL_MAX;
} else {
dev_err(dev, "Unknown Bman version:%04x,%02x,%02x\n",
id, major, minor);
return -ENODEV;
}
ret = qbman_init_private_mem(dev, 0, "fsl,bman-fbpr", &fbpr_a, &fbpr_sz);
if (ret) {
dev_err(dev, "qbman_init_private_mem() failed 0x%x\n",
ret);
return -ENODEV;
}
dev_dbg(dev, "Allocated FBPR 0x%llx 0x%zx\n", fbpr_a, fbpr_sz);
bm_set_memory(fbpr_a, fbpr_sz);
err_irq = platform_get_irq(pdev, 0);
if (err_irq <= 0) {
dev_info(dev, "Can't get %pOF IRQ\n", node);
return -ENODEV;
}
ret = devm_request_irq(dev, err_irq, bman_isr, IRQF_SHARED, "bman-err",
dev);
if (ret) {
dev_err(dev, "devm_request_irq() failed %d for '%pOF'\n",
ret, node);
return ret;
}
bm_ccsr_out(REG_ERR_ISDR, BM_EIRQ_BSCN);
bm_ccsr_out(REG_ERR_ISR, 0xffffffff);
bm_ccsr_out(REG_ERR_IER, 0xffffffff);
bm_bpalloc = devm_gen_pool_create(dev, 0, -1, "bman-bpalloc");
if (IS_ERR(bm_bpalloc)) {
ret = PTR_ERR(bm_bpalloc);
dev_err(dev, "bman-bpalloc pool init failed (%d)\n", ret);
return ret;
}
ret = gen_pool_add(bm_bpalloc, DPAA_GENALLOC_OFF, bm_pool_cnt, -1);
if (ret) {
dev_err(dev, "Failed to seed BPID range [%d..%d] (%d)\n",
0, bm_pool_cnt - 1, ret);
return ret;
}
__bman_probed = 1;
return 0;
};
static const struct of_device_id fsl_bman_ids[] = …;
static struct platform_driver fsl_bman_driver = …;
builtin_platform_driver(…) …;