/* The base address of the CM GCR block */ externvoid __iomem *mips_gcr_base;
/* The base address of the CM L2-only sync region */ externvoid __iomem *mips_cm_l2sync_base;
/** * mips_cm_phys_base - retrieve the physical base address of the CM * * This function returns the physical base address of the Coherence Manager * global control block, or 0 if no Coherence Manager is present. It provides * a default implementation which reads the CMGCRBase register where available, * and may be overridden by platforms which determine this address in a * different way by defining a function with the same prototype.
*/ extern phys_addr_t mips_cm_phys_base(void);
/** * mips_cm_l2sync_phys_base - retrieve the physical base address of the CM * L2-sync region * * This function returns the physical base address of the Coherence Manager * L2-cache only region. It provides a default implementation which reads the * CMGCRL2OnlySyncBase register where available or returns a 4K region just * behind the CM GCR base address. It may be overridden by platforms which * determine this address in a different way by defining a function with the * same prototype.
*/ extern phys_addr_t mips_cm_l2sync_phys_base(void);
/* * mips_cm_is64 - determine CM register width * * The CM register width is determined by the version of the CM, with CM3 * introducing 64 bit GCRs and all prior CM versions having 32 bit GCRs. * However we may run a kernel built for MIPS32 on a system with 64 bit GCRs, * or vice-versa. This variable indicates the width of the memory accesses * that the kernel will perform to GCRs, which may differ from the actual * width of the GCRs. * * It's set to 0 for 32-bit accesses and 1 for 64-bit accesses.
*/ externint mips_cm_is64;
/* * mips_cm_is_l2_hci_broken - determine if HCI is broken * * Some CM reports show that Hardware Cache Initialization is * complete, but in reality it's not the case. They also incorrectly * indicate that Hardware Cache Initialization is supported. This * flags allows warning about this broken feature.
*/ externbool mips_cm_is_l2_hci_broken;
/** * mips_cm_probe - probe for a Coherence Manager * * Attempt to detect the presence of a Coherence Manager. Returns 0 if a CM * is successfully detected, else -errno.
*/ #ifdef CONFIG_MIPS_CM externint mips_cm_probe(void); #else staticinlineint mips_cm_probe(void)
{ return -ENODEV;
} #endif
/** * mips_cm_present - determine whether a Coherence Manager is present * * Returns true if a CM is present in the system, else false.
*/ staticinlinebool mips_cm_present(void)
{ #ifdef CONFIG_MIPS_CM return mips_gcr_base != NULL; #else returnfalse; #endif
}
/** * mips_cm_update_property - update property from the device tree * * Retrieve the properties from the device tree if a CM node exist and * update the internal variable based on this.
*/ #ifdef CONFIG_MIPS_CM externvoid mips_cm_update_property(void); #else staticinlinevoid mips_cm_update_property(void) {} #endif
/** * mips_cm_has_l2sync - determine whether an L2-only sync region is present * * Returns true if the system implements an L2-only sync region, else false.
*/ staticinlinebool mips_cm_has_l2sync(void)
{ #ifdef CONFIG_MIPS_CM return mips_cm_l2sync_base != NULL; #else returnfalse; #endif
}
/* Offsets to register blocks from the CM base address */ #define MIPS_CM_GCB_OFS 0x0000 /* Global Control Block */ #define MIPS_CM_CLCB_OFS 0x2000 /* Core Local Control Block */ #define MIPS_CM_COCB_OFS 0x4000 /* Core Other Control Block */ #define MIPS_CM_GDB_OFS 0x6000 /* Global Debug Block */
/* Total size of the CM memory mapped registers */ #define MIPS_CM_GCR_SIZE 0x8000
/* Size of the L2-only sync region */ #define MIPS_CM_L2SYNC_SIZE 0x1000
/* GCR_Cx_RESET_BASE - Configure where powered up cores will fetch from */
GCR_CX_ACCESSOR_RW(32, 0x020, reset_base)
GCR_CX_ACCESSOR_RW(64, 0x020, reset64_base) #define CM_GCR_Cx_RESET_BASE_BEVEXCBASE GENMASK(31, 12) #define CM_GCR_Cx_RESET64_BASE_BEVEXCBASE GENMASK_ULL(47, 12) #define CM_GCR_Cx_RESET_BASE_MODE BIT(1)
/* GCR_Cx_ID - Identify the current core */
GCR_CX_ACCESSOR_RO(32, 0x028, id) #define CM_GCR_Cx_ID_CLUSTER GENMASK(15, 8) #define CM_GCR_Cx_ID_CORE GENMASK(7, 0)
/* GCR_Cx_RESET_EXT_BASE - Configure behaviour when cores reset or power up */
GCR_CX_ACCESSOR_RW(32, 0x030, reset_ext_base) #define CM_GCR_Cx_RESET_EXT_BASE_EVARESET BIT(31) #define CM_GCR_Cx_RESET_EXT_BASE_UEB BIT(30) #define CM_GCR_Cx_RESET_EXT_BASE_BEVEXCMASK GENMASK(27, 20) #define CM_GCR_Cx_RESET_EXT_BASE_BEVEXCPA GENMASK(7, 1) #define CM_GCR_Cx_RESET_EXT_BASE_PRESENT BIT(0)
/** * mips_cm_l2sync - perform an L2-only sync operation * * If an L2-only sync region is present in the system then this function * performs and L2-only sync and returns zero. Otherwise it returns -ENODEV.
*/ staticinlineint mips_cm_l2sync(void)
{ if (!mips_cm_has_l2sync()) return -ENODEV;
writel(0, mips_cm_l2sync_base); return 0;
}
/** * mips_cm_revision() - return CM revision * * Return: The revision of the CM, from GCR_REV, or 0 if no CM is present. The * return value should be checked against the CM_REV_* macros.
*/ staticinlineint mips_cm_revision(void)
{ if (!mips_cm_present()) return 0;
return read_gcr_rev();
}
/** * mips_cm_max_vp_width() - return the width in bits of VP indices * * Return: the width, in bits, of VP indices in fields that combine core & VP * indices.
*/ staticinlineunsignedint mips_cm_max_vp_width(void)
{ externint smp_num_siblings;
if (mips_cm_revision() >= CM_REV_CM3) return FIELD_GET(CM_GCR_SYS_CONFIG2_MAXVPW,
read_gcr_sys_config2());
if (mips_cm_present()) { /* * We presume that all cores in the system will have the same * number of VP(E)s, and if that ever changes then this will * need revisiting.
*/ return FIELD_GET(CM_GCR_Cx_CONFIG_PVPE, read_gcr_cl_config()) + 1;
}
if (IS_ENABLED(CONFIG_SMP)) return smp_num_siblings;
return 1;
}
/** * mips_cm_vp_id() - calculate the hardware VP ID for a CPU * @cpu: the CPU whose VP ID to calculate * * Hardware such as the GIC uses identifiers for VPs which may not match the * CPU numbers used by Linux. This function calculates the hardware VP * identifier corresponding to a given CPU. * * Return: the VP ID for the CPU.
*/ staticinlineunsignedint mips_cm_vp_id(unsignedint cpu)
{ unsignedint core = cpu_core(&cpu_data[cpu]); unsignedint vp = cpu_vpe_id(&cpu_data[cpu]);
return (core * mips_cm_max_vp_width()) + vp;
}
#ifdef CONFIG_MIPS_CM
/** * mips_cm_lock_other - lock access to redirect/other region * @cluster: the other cluster to be accessed * @core: the other core to be accessed * @vp: the VP within the other core to be accessed * @block: the register block to be accessed * * Configure the redirect/other region for the local core/VP (depending upon * the CM revision) to target the specified @cluster, @core, @vp & register * @block. Must be called before using the redirect/other region, and followed * by a call to mips_cm_unlock_other() when access to the redirect/other region * is complete. * * This function acquires a spinlock such that code between it & * mips_cm_unlock_other() calls cannot be pre-empted by anything which may * reconfigure the redirect/other region, and cannot be interfered with by * another VP in the core. As such calls to this function should not be nested.
*/ externvoid mips_cm_lock_other(unsignedint cluster, unsignedint core, unsignedint vp, unsignedint block);
/** * mips_cm_unlock_other - unlock access to redirect/other region * * Must be called after mips_cm_lock_other() once all required access to the * redirect/other region has been completed.
*/ externvoid mips_cm_unlock_other(void);
/** * mips_cm_lock_other_cpu - lock access to redirect/other region * @cpu: the other CPU whose register we want to access * * Configure the redirect/other region for the local core/VP (depending upon * the CM revision) to target the specified @cpu & register @block. This is * equivalent to calling mips_cm_lock_other() but accepts a Linux CPU number * for convenience.
*/ staticinlinevoid mips_cm_lock_other_cpu(unsignedint cpu, unsignedint block)
{ struct cpuinfo_mips *d = &cpu_data[cpu];
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.