From: Christophe Guerard Date: Mon, 12 Dec 2011 16:28:44 +0000 (+0100) Subject: [LOG] PTI not enabled on kernel 3.0 X-Git-Tag: 2.1b_release~1817 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2330773f8f8908a16a8edb7e90b8a7af40a54c60;p=kernel%2Fkernel-mfld-blackbay.git [LOG] PTI not enabled on kernel 3.0 BZ: 16865 Change-Id: Ie3e9f41cad62ab72c7051ea899f24668519748c1 Signed-off-by: Christophe Guerard Reviewed-on: http://android.intel.com:8080/27068 Reviewed-by: Chotard, Celine Reviewed-by: buildbot Tested-by: buildbot --- diff --git a/arch/x86/configs/i386_mfld_defconfig b/arch/x86/configs/i386_mfld_defconfig index 5832ce0..18c7545 100644 --- a/arch/x86/configs/i386_mfld_defconfig +++ b/arch/x86/configs/i386_mfld_defconfig @@ -743,7 +743,7 @@ CONFIG_MISC_DEVICES=y # CONFIG_ANDROID_PMEM is not set # CONFIG_IBM_ASM is not set # CONFIG_PHANTOM is not set -# CONFIG_INTEL_MID_PTI is not set +CONFIG_INTEL_MID_PTI=y # CONFIG_SGI_IOC4 is not set # CONFIG_TIFM_CORE is not set # CONFIG_ICS932S401 is not set @@ -2427,7 +2427,8 @@ CONFIG_HAVE_ARCH_KMEMCHECK=y # CONFIG_TEST_KSTRTOX is not set CONFIG_STRICT_DEVMEM=y CONFIG_X86_VERBOSE_BOOTUP=y -# CONFIG_EARLY_PRINTK is not set +CONFIG_EARLY_PRINTK=y +CONFIG_EARLY_PRINTK_INTEL_MID=y # CONFIG_DEBUG_STACKOVERFLOW is not set # CONFIG_X86_PTDUMP is not set CONFIG_DEBUG_RODATA=y diff --git a/arch/x86/include/asm/mrst.h b/arch/x86/include/asm/mrst.h index 60d2e43..087f6a9 100644 --- a/arch/x86/include/asm/mrst.h +++ b/arch/x86/include/asm/mrst.h @@ -109,6 +109,8 @@ extern void mrst_early_console_init(void); extern struct console early_hsu_console; extern void hsu_early_console_init(void); +extern struct console early_pti_console; + extern void intel_scu_devices_create(void); extern void intel_scu_devices_destroy(void); diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c index 7a53da0..0dea0dd 100644 --- a/arch/x86/kernel/early_printk.c +++ b/arch/x86/kernel/early_printk.c @@ -250,6 +250,9 @@ static int __init setup_early_printk(char *buf) hsu_early_console_init(); early_console_register(&early_hsu_console, keep); } + + if (!strncmp(buf, "pti", 3)) + early_console_register(&early_pti_console, keep); #endif buf++; } diff --git a/arch/x86/platform/mrst/early_printk_mrst.c b/arch/x86/platform/mrst/early_printk_mrst.c index b3b6494..a7361e2 100644 --- a/arch/x86/platform/mrst/early_printk_mrst.c +++ b/arch/x86/platform/mrst/early_printk_mrst.c @@ -10,10 +10,11 @@ */ /* - * This file implements two early consoles named mrst and hsu. + * This file implements three early consoles named mrst, hsu and pti. * mrst is based on Maxim3110 spi-uart device, it exists in both * Moorestown and Medfield platforms, while hsu is based on a High - * Speed UART device which only exists in the Medfield platform + * Speed UART device and pti is based on a Parallel Trace Interface + * The last two consoles only exist in the Medfield platform */ #include @@ -24,6 +25,9 @@ #include #include #include +#include +#include +#include #include #include @@ -67,6 +71,9 @@ #define SR_TX_ERR (1 << 5) #define SR_DCOL (1 << 6) +static unsigned int early_pti_console_channel; +static unsigned int early_pti_control_channel; + struct dw_spi_reg { u32 ctrl0; u32 ctrl1; @@ -320,3 +327,135 @@ struct console early_hsu_console = { .flags = CON_PRINTBUFFER, .index = -1, }; +void hsu_early_printk(const char *fmt, ...) +{ + char buf[512]; + int n; + va_list ap; + + va_start(ap, fmt); + n = vscnprintf(buf, 512, fmt, ap); + va_end(ap); + + early_hsu_console.write(&early_mrst_console, buf, n); +} + +#define PTI_ADDRESS 0xfd800000 +#define CONTROL_FRAME_LEN 32 /* PTI control frame maximum size */ + +static void early_pti_write_to_aperture(struct pti_masterchannel *mc, + u8 *buf, int len) +{ + int dwordcnt, final, i; + u32 ptiword; + u8 *p ; + u32 pti_phys_address ; + u32 __iomem *aperture; + + p = buf; + + /* + calculate the aperture offset from the base using the master and + channel id's. + */ + pti_phys_address = PTI_ADDRESS + + (mc->master << 15) + (mc->channel << 8); + + set_fixmap_nocache(FIX_EARLYCON_MEM_BASE, pti_phys_address); + aperture = (void *)(__fix_to_virt(FIX_EARLYCON_MEM_BASE) + + (pti_phys_address & (PAGE_SIZE - 1))); + + dwordcnt = len >> 2; + final = len - (dwordcnt << 2); /* final = trailing bytes */ + if (final == 0 && dwordcnt != 0) { /* always have a final dword */ + final += 4; + dwordcnt--; + } + + for (i = 0; i < dwordcnt; i++) { + ptiword = be32_to_cpu(*(u32 *)p); + p += 4; + iowrite32(ptiword, aperture); + } + + aperture += PTI_LASTDWORD_DTS; /* adding DTS signals that is EOM */ + ptiword = 0; + + for (i = 0; i < final; i++) + ptiword |= *p++ << (24-(8*i)); + + iowrite32(ptiword, aperture); + + return; +} + +static int pti_early_console_init(void) +{ + early_pti_console_channel = 0; + early_pti_control_channel = 0; + return 0; +} + +static void early_pti_write(struct console *con, + const char *str, unsigned n) +{ + static struct pti_masterchannel mccontrol = {.master = 72, + .channel = 0}; + static struct pti_masterchannel mcconsole = {.master = 73, + .channel = 0}; + const char *control_format = "%3d %3d %s"; + + /* + * Since we access the comm member in current's task_struct, + * we only need to be as large as what 'comm' in that + * structure is. + */ + char comm[TASK_COMM_LEN]; + u8 control_frame[CONTROL_FRAME_LEN]; + + /* task information */ + if (in_irq()) + strncpy(comm, "hardirq", sizeof(comm)); + else if (in_softirq()) + strncpy(comm, "softirq", sizeof(comm)); + else + strncpy(comm, current->comm, sizeof(comm)); + + /* Absolutely ensure our buffer is zero terminated */ + comm[TASK_COMM_LEN-1] = 0; + + mccontrol.channel = early_pti_control_channel; + early_pti_control_channel = (early_pti_control_channel + 1) & 0x7f; + + mcconsole.channel = early_pti_console_channel; + early_pti_console_channel = (early_pti_console_channel + 1) & 0x7f; + + snprintf(control_frame, CONTROL_FRAME_LEN, control_format, + mcconsole.master, mcconsole.channel, comm); + + early_pti_write_to_aperture(&mccontrol, control_frame, + strlen(control_frame)); + early_pti_write_to_aperture(&mcconsole, (u8 *)str, n); + +} + +struct console early_pti_console = { + .name = "earlypti", + .early_setup = pti_early_console_init, + .write = early_pti_write, + .flags = CON_PRINTBUFFER, + .index = -1, +}; + +void pti_early_printk(const char *fmt, ...) +{ + char buf[512]; + int n; + va_list ap; + + va_start(ap, fmt); + n = vscnprintf(buf, sizeof(buf), fmt, ap); + va_end(ap); + + early_pti_console.write(&early_mrst_console, buf, n); +} diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 3cd2ae3..7155fff 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -6,7 +6,7 @@ obj-$(CONFIG_IBM_ASM) += ibmasm/ obj-$(CONFIG_AD525X_DPOT) += ad525x_dpot.o obj-$(CONFIG_AD525X_DPOT_I2C) += ad525x_dpot-i2c.o obj-$(CONFIG_AD525X_DPOT_SPI) += ad525x_dpot-spi.o -0bj-$(CONFIG_INTEL_MID_PTI) += pti.o +obj-$(CONFIG_INTEL_MID_PTI) += pti.o obj-$(CONFIG_ATMEL_PWM) += atmel_pwm.o obj-$(CONFIG_ATMEL_SSC) += atmel-ssc.o obj-$(CONFIG_ATMEL_TCLIB) += atmel_tclib.o diff --git a/drivers/misc/pti.c b/drivers/misc/pti.c index 4f58ec1..fa58d1a 100644 --- a/drivers/misc/pti.c +++ b/drivers/misc/pti.c @@ -173,10 +173,13 @@ static void pti_control_frame_built_and_sent(struct pti_masterchannel *mc) */ char comm[TASK_COMM_LEN]; - if (!in_interrupt()) - get_task_comm(comm, current); + /* task information */ + if (in_irq()) + strncpy(comm, "hardirq", sizeof(comm)); + else if (in_softirq()) + strncpy(comm, "softirq", sizeof(comm)); else - strncpy(comm, "Interrupt", TASK_COMM_LEN); + strncpy(comm, current->comm, sizeof(comm)); /* Absolutely ensure our buffer is zero terminated. */ comm[TASK_COMM_LEN-1] = 0;