diff options
Diffstat (limited to 'linux/drivers/soc/fsl/qbman/dpaa_sys.h')
-rw-r--r-- | linux/drivers/soc/fsl/qbman/dpaa_sys.h | 285 |
1 files changed, 67 insertions, 218 deletions
diff --git a/linux/drivers/soc/fsl/qbman/dpaa_sys.h b/linux/drivers/soc/fsl/qbman/dpaa_sys.h index 85f87800..0e897026 100644 --- a/linux/drivers/soc/fsl/qbman/dpaa_sys.h +++ b/linux/drivers/soc/fsl/qbman/dpaa_sys.h @@ -1,4 +1,4 @@ -/* Copyright 2008 - 2015 Freescale Semiconductor, Inc. +/* Copyright 2008 - 2016 Freescale Semiconductor, Inc. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -31,23 +31,19 @@ #ifndef __DPAA_SYS_H #define __DPAA_SYS_H +#include <linux/cpu.h> #include <linux/slab.h> #include <linux/module.h> #include <linux/interrupt.h> -#include <linux/of_address.h> -#include <linux/of_irq.h> -#include <linux/of_reserved_mem.h> #include <linux/kthread.h> -#include <linux/uaccess.h> -#include <linux/debugfs.h> +#include <linux/sched/signal.h> #include <linux/vmalloc.h> #include <linux/platform_device.h> -#include <linux/ctype.h> -#ifdef CONFIG_HOTPLUG_CPU -#include <linux/cpu.h> -#endif - -#include <asm/pgtable.h> +#include <linux/of.h> +#include <linux/of_reserved_mem.h> +#include <linux/prefetch.h> +#include <linux/genalloc.h> +#include <asm/cacheflush.h> #ifdef __rtems__ #include <asm/cache.h> #include <asm/mpc85xx.h> @@ -55,238 +51,91 @@ #include <linux/io.h> #include <linux/rbtree.h> #include <bsp/linker-symbols.h> + #define DPAA_NOCACHENOLOAD_ALIGNED_REGION(designator, size) \ BSP_NOCACHENOLOAD_SUBSECTION(designator) __aligned(size) \ uint8_t designator[size] -#endif /* __rtems__ */ - -struct dpaa_resource { - struct list_head free; - spinlock_t lock; - struct list_head used; -}; -#define DECLARE_DPAA_RESOURCE(name) \ -struct dpaa_resource name = { \ - .free = { \ - .prev = &name.free, \ - .next = &name.free \ - }, \ - .lock = __SPIN_LOCK_UNLOCKED(name.lock), \ - .used = { \ - .prev = &name.used, \ - .next = &name.used \ - } \ -} - -int dpaa_resource_new(struct dpaa_resource *alloc, u32 *result, - u32 count, u32 align, int partial); -u32 dpaa_resource_release(struct dpaa_resource *alloc, - u32 id, u32 count, int (*is_valid)(u32 id)); -void dpaa_resource_seed(struct dpaa_resource *alloc, u32 base_id, u32 count); -int dpaa_resource_reserve(struct dpaa_resource *alloc, u32 base, u32 num); +#ifdef __PPC_CPU_E6500__ +#define dma_wmb() ppc_light_weight_synchronize() +#else +#define dma_wmb() ppc_enforce_in_order_execution_of_io() +#endif -/* When copying aligned words or shorts, try to avoid memcpy() */ -#define CONFIG_TRY_BETTER_MEMCPY +#define prefetch(x) ppc_data_cache_block_touch(x) +#endif /* __rtems__ */ /* For 2-element tables related to cache-inhibited and cache-enabled mappings */ -#define DPA_PORTAL_CE 0 -#define DPA_PORTAL_CI 1 +#define DPAA_PORTAL_CE 0 +#define DPAA_PORTAL_CI 1 -/* Misc inline assists */ +#if (L1_CACHE_BYTES != 32) && (L1_CACHE_BYTES != 64) +#error "Unsupported Cacheline Size" +#endif -/* TODO: NB, we currently assume that hwsync() and lwsync() imply compiler - * barriers and that dcb*() won't fall victim to compiler or execution - * reordering with respect to other code/instructions that manipulate the same - * cacheline. */ -#define hwsync() __asm__ __volatile__ ("sync" : : : "memory") +static inline void dpaa_flush(void *p) +{ #ifndef __rtems__ -#define lwsync() __asm__ __volatile__ (stringify_in_c(LWSYNC) : : : "memory") +#ifdef CONFIG_PPC + flush_dcache_range((unsigned long)p, (unsigned long)p+64); +#elif defined(CONFIG_ARM32) + __cpuc_flush_dcache_area(p, 64); +#elif defined(CONFIG_ARM64) + __flush_dcache_area(p, 64); +#endif #else /* __rtems__ */ - #ifdef __PPC_CPU_E6500__ - #define lwsync() ppc_light_weight_synchronize() - #else - #define lwsync() ppc_synchronize_data() - #endif -#endif /* __rtems__ */ -#define dcbf(p) __asm__ __volatile__ ("dcbf 0,%0" : : "r" (p) : "memory") -#define dcbt_ro(p) __asm__ __volatile__ ("dcbt 0,%0" : : "r" (p)) -#define dcbt_rw(p) __asm__ __volatile__ ("dcbtst 0,%0" : : "r" (p)) -#define dcbi(p) dcbf(p) -#ifdef CONFIG_PPC_E500MC -#define dcbzl(p) __asm__ __volatile__ ("dcbzl 0,%0" : : "r" (p)) -#define dcbz_64(p) dcbzl(p) -#define dcbf_64(p) dcbf(p) -/* Commonly used combo */ -#define dcbit_ro(p) \ - do { \ - dcbi(p); \ - dcbt_ro(p); \ - } while (0) +#ifdef __PPC_CPU_E6500__ + ppc_data_cache_block_flush(p); #else -#define dcbz(p) __asm__ __volatile__ ("dcbz 0,%0" : : "r" (p)) -#define dcbz_64(p) \ - do { \ - dcbz((u32)p + 32); \ - dcbz(p); \ - } while (0) -#define dcbf_64(p) \ - do { \ - dcbf((u32)p + 32); \ - dcbf(p); \ - } while (0) -/* Commonly used combo */ -#define dcbit_ro(p) \ - do { \ - dcbi(p); \ - dcbi((u32)p + 32); \ - dcbt_ro(p); \ - dcbt_ro((u32)p + 32); \ - } while (0) -#endif /* CONFIG_PPC_E500MC */ - -static inline u64 mfatb(void) -{ - u32 hi, lo, chk; - - do { - hi = mfspr(SPRN_ATBU); - lo = mfspr(SPRN_ATBL); - chk = mfspr(SPRN_ATBU); - } while (unlikely(hi != chk)); - return ((u64)hi << 32) | (u64)lo; +#error "Unsupported platform" +#endif +#endif /* __rtems__ */ } -#ifdef CONFIG_FSL_DPA_CHECKING -#define DPA_ASSERT(x) WARN_ON(!(x)) +#define dpaa_invalidate(p) dpaa_flush(p) + +#ifndef __rtems__ +#define dpaa_zero(p) memset(p, 0, 64) +#else /* __rtems__ */ +#ifdef __PPC_CPU_E6500__ +#define dpaa_zero(p) ppc_data_cache_block_clear_to_zero(p) #else -#define DPA_ASSERT(x) +#define dpaa_zero(p) memset(p, 0, 64) #endif +#endif /* __rtems__ */ -#ifdef CONFIG_TRY_BETTER_MEMCPY -static inline void copy_words(void *dest, const void *src, size_t sz) +static inline void dpaa_touch_ro(void *p) { - u32 *__dest = dest; - const u32 *__src = src; - size_t __sz = sz >> 2; - - BUG_ON((unsigned long)dest & 0x3); - BUG_ON((unsigned long)src & 0x3); - BUG_ON(sz & 0x3); - while (__sz--) - *(__dest++) = *(__src++); -} -#else -#define copy_words memcpy +#if (L1_CACHE_BYTES == 32) + prefetch(p+32); #endif + prefetch(p); +} -/* RB-trees */ - -/* We encapsulate RB-trees so that its easier to use non-linux forms in - * non-linux systems. This also encapsulates the extra plumbing that linux code - * usually provides when using RB-trees. This encapsulation assumes that the - * data type held by the tree is u32. */ - -struct dpa_rbtree { - struct rb_root root; -}; -#define DPA_RBTREE { .root = RB_ROOT } - -static inline void dpa_rbtree_init(struct dpa_rbtree *tree) +/* Commonly used combo */ +static inline void dpaa_invalidate_touch_ro(void *p) { - tree->root = RB_ROOT; + dpaa_invalidate(p); + dpaa_touch_ro(p); } -#define IMPLEMENT_DPA_RBTREE(name, type, node_field, val_field) \ -static inline int name##_push(struct dpa_rbtree *tree, type *obj) \ -{ \ - struct rb_node *parent = NULL, **p = &tree->root.rb_node; \ - while (*p) { \ - u32 item; \ - parent = *p; \ - item = rb_entry(parent, type, node_field)->val_field; \ - if (obj->val_field < item) \ - p = &parent->rb_left; \ - else if (obj->val_field > item) \ - p = &parent->rb_right; \ - else \ - return -EBUSY; \ - } \ - rb_link_node(&obj->node_field, parent, p); \ - rb_insert_color(&obj->node_field, &tree->root); \ - return 0; \ -} \ -static inline void name##_del(struct dpa_rbtree *tree, type *obj) \ -{ \ - rb_erase(&obj->node_field, &tree->root); \ -} \ -static inline type *name##_find(struct dpa_rbtree *tree, u32 val) \ -{ \ - type *ret; \ - struct rb_node *p = tree->root.rb_node; \ - while (p) { \ - ret = rb_entry(p, type, node_field); \ - if (val < ret->val_field) \ - p = p->rb_left; \ - else if (val > ret->val_field) \ - p = p->rb_right; \ - else \ - return ret; \ - } \ - return NULL; \ -} -#ifndef __rtems__ -/* Bootargs */ +#ifdef CONFIG_FSL_DPAA_CHECKING +#define DPAA_ASSERT(x) WARN_ON(!(x)) +#else +#define DPAA_ASSERT(x) +#endif -/* QMan has "qportals=" and BMan has "bportals=", they use the same syntax - * though; a comma-separated list of items, each item being a cpu index and/or a - * range of cpu indices, and each item optionally be prefixed by "s" to indicate - * that the portal associated with that cpu should be shared. See bman_driver.c - * for more specifics. */ -static int __parse_portals_cpu(const char **s, unsigned int *cpu) +/* cyclic helper for rings */ +static inline u8 dpaa_cyc_diff(u8 ringsize, u8 first, u8 last) { - *cpu = 0; - if (!isdigit(**s)) - return -EINVAL; - while (isdigit(**s)) - *cpu = *cpu * 10 + (*((*s)++) - '0'); - return 0; + /* 'first' is included, 'last' is excluded */ + if (first <= last) + return last - first; + return ringsize + last - first; } -static inline int parse_portals_bootarg(char *str, struct cpumask *want_shared, - struct cpumask *want_unshared, - const char *argname) -{ - const char *s = str; - unsigned int shared, cpu1, cpu2, loop; -keep_going: - if (*s == 's') { - shared = 1; - s++; - } else - shared = 0; - if (__parse_portals_cpu(&s, &cpu1)) - goto err; - if (*s == '-') { - s++; - if (__parse_portals_cpu(&s, &cpu2)) - goto err; - if (cpu2 < cpu1) - goto err; - } else - cpu2 = cpu1; - for (loop = cpu1; loop <= cpu2; loop++) - cpumask_set_cpu(loop, shared ? want_shared : want_unshared); - if (*s == ',') { - s++; - goto keep_going; - } else if ((*s == '\0') || isspace(*s)) - return 0; -err: - pr_crit("Malformed %s argument: %s, offset: %lu\n", argname, str, - (unsigned long)s - (unsigned long)str); - return -EINVAL; -} -#endif /* __rtems__ */ +/* Offset applied to genalloc pools due to zero being an error return */ +#define DPAA_GENALLOC_OFF 0x80000000 + #endif /* __DPAA_SYS_H */ |