Commit d238db7f0b18fdd4ffd13f94c16e36932574ac24

Authored by balrog
1 parent 0941041e

Boot tags setup needed by N800 proprietary bootloader.

This code is needed to make NOLO bootloader happy.  It is mostly guesses.
The tags are normally written by some early boot code that runs before NOLO.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4492 c046a42c-6fe2-441c-8c8c-71466251a162
Showing 1 changed file with 195 additions and 0 deletions
hw/nseries.c
... ... @@ -730,6 +730,176 @@ static void n8x0_usb_setup(struct n800_s *s)
730 730 omap2_gpio_out_set(s->cpu->gpif, N8X0_TUSB_ENABLE_GPIO, tusb_pwr);
731 731 }
732 732  
  733 +/* Setup done before the main bootloader starts by some early setup code
  734 + * - used when we want to run the main bootloader in emulation. This
  735 + * isn't documented. */
  736 +static uint32_t n800_pinout[104] = {
  737 + 0x080f00d8, 0x00d40808, 0x03080808, 0x080800d0,
  738 + 0x00dc0808, 0x0b0f0f00, 0x080800b4, 0x00c00808,
  739 + 0x08080808, 0x180800c4, 0x00b80000, 0x08080808,
  740 + 0x080800bc, 0x00cc0808, 0x08081818, 0x18180128,
  741 + 0x01241800, 0x18181818, 0x000000f0, 0x01300000,
  742 + 0x00001b0b, 0x1b0f0138, 0x00e0181b, 0x1b031b0b,
  743 + 0x180f0078, 0x00740018, 0x0f0f0f1a, 0x00000080,
  744 + 0x007c0000, 0x00000000, 0x00000088, 0x00840000,
  745 + 0x00000000, 0x00000094, 0x00980300, 0x0f180003,
  746 + 0x0000008c, 0x00900f0f, 0x0f0f1b00, 0x0f00009c,
  747 + 0x01140000, 0x1b1b0f18, 0x0818013c, 0x01400008,
  748 + 0x00001818, 0x000b0110, 0x010c1800, 0x0b030b0f,
  749 + 0x181800f4, 0x00f81818, 0x00000018, 0x000000fc,
  750 + 0x00401808, 0x00000000, 0x0f1b0030, 0x003c0008,
  751 + 0x00000000, 0x00000038, 0x00340000, 0x00000000,
  752 + 0x1a080070, 0x00641a1a, 0x08080808, 0x08080060,
  753 + 0x005c0808, 0x08080808, 0x08080058, 0x00540808,
  754 + 0x08080808, 0x0808006c, 0x00680808, 0x08080808,
  755 + 0x000000a8, 0x00b00000, 0x08080808, 0x000000a0,
  756 + 0x00a40000, 0x00000000, 0x08ff0050, 0x004c0808,
  757 + 0xffffffff, 0xffff0048, 0x0044ffff, 0xffffffff,
  758 + 0x000000ac, 0x01040800, 0x08080b0f, 0x18180100,
  759 + 0x01081818, 0x0b0b1808, 0x1a0300e4, 0x012c0b1a,
  760 + 0x02020018, 0x0b000134, 0x011c0800, 0x0b1b1b00,
  761 + 0x0f0000c8, 0x00ec181b, 0x000f0f02, 0x00180118,
  762 + 0x01200000, 0x0f0b1b1b, 0x0f0200e8, 0x0000020b,
  763 +};
  764 +
  765 +static void n800_setup_nolo_tags(void *sram_base)
  766 +{
  767 + int i;
  768 + uint32_t *p = sram_base + 0x8000;
  769 + uint32_t *v = sram_base + 0xa000;
  770 +
  771 + memset(p, 0, 0x3000);
  772 +
  773 + strcpy((void *) (p + 0), "QEMU N800");
  774 +
  775 + strcpy((void *) (p + 8), "F5");
  776 +
  777 + stl_raw(p + 10, 0x04f70000);
  778 + strcpy((void *) (p + 9), "RX-34");
  779 +
  780 + /* RAM size in MB? */
  781 + stl_raw(p + 12, 0x80);
  782 +
  783 + /* Pointer to the list of tags */
  784 + stl_raw(p + 13, OMAP2_SRAM_BASE + 0x9000);
  785 +
  786 + /* The NOLO tags start here */
  787 + p = sram_base + 0x9000;
  788 +#define ADD_TAG(tag, len) \
  789 + stw_raw((uint16_t *) p + 0, tag); \
  790 + stw_raw((uint16_t *) p + 1, len); p ++; \
  791 + stl_raw(p ++, OMAP2_SRAM_BASE | (((void *) v - sram_base) & 0xffff));
  792 +
  793 + /* OMAP STI console? Pin out settings? */
  794 + ADD_TAG(0x6e01, 414);
  795 + for (i = 0; i < sizeof(n800_pinout) / 4; i ++)
  796 + stl_raw(v ++, n800_pinout[i]);
  797 +
  798 + /* Kernel memsize? */
  799 + ADD_TAG(0x6e05, 1);
  800 + stl_raw(v ++, 2);
  801 +
  802 + /* NOLO serial console */
  803 + ADD_TAG(0x6e02, 4);
  804 + stl_raw(v ++, XLDR_LL_UART); /* UART number (1 - 3) */
  805 +
  806 +#if 0
  807 + /* CBUS settings (Retu/AVilma) */
  808 + ADD_TAG(0x6e03, 6);
  809 + stw_raw((uint16_t *) v + 0, 65); /* CBUS GPIO0 */
  810 + stw_raw((uint16_t *) v + 1, 66); /* CBUS GPIO1 */
  811 + stw_raw((uint16_t *) v + 2, 64); /* CBUS GPIO2 */
  812 + v += 2;
  813 +#endif
  814 +
  815 + /* Nokia ASIC BB5 (Retu/Tahvo) */
  816 + ADD_TAG(0x6e0a, 4);
  817 + stw_raw((uint16_t *) v + 0, 111); /* "Retu" interrupt GPIO */
  818 + stw_raw((uint16_t *) v + 1, 108); /* "Tahvo" interrupt GPIO */
  819 + v ++;
  820 +
  821 + /* LCD console? */
  822 + ADD_TAG(0x6e04, 4);
  823 + stw_raw((uint16_t *) v + 0, 30); /* ??? */
  824 + stw_raw((uint16_t *) v + 1, 24); /* ??? */
  825 + v ++;
  826 +
  827 +#if 0
  828 + /* LCD settings */
  829 + ADD_TAG(0x6e06, 2);
  830 + stw_raw((uint16_t *) (v ++), 15); /* ??? */
  831 +#endif
  832 +
  833 + /* I^2C (Menelaus) */
  834 + ADD_TAG(0x6e07, 4);
  835 + stl_raw(v ++, 0x00720000); /* ??? */
  836 +
  837 + /* Unknown */
  838 + ADD_TAG(0x6e0b, 6);
  839 + stw_raw((uint16_t *) v + 0, 94); /* ??? */
  840 + stw_raw((uint16_t *) v + 1, 23); /* ??? */
  841 + stw_raw((uint16_t *) v + 2, 0); /* ??? */
  842 + v += 2;
  843 +
  844 + /* OMAP gpio switch info */
  845 + ADD_TAG(0x6e0c, 80);
  846 + strcpy((void *) v, "bat_cover"); v += 3;
  847 + stw_raw((uint16_t *) v + 0, 110); /* GPIO num ??? */
  848 + stw_raw((uint16_t *) v + 1, 1); /* GPIO num ??? */
  849 + v += 2;
  850 + strcpy((void *) v, "cam_act"); v += 3;
  851 + stw_raw((uint16_t *) v + 0, 95); /* GPIO num ??? */
  852 + stw_raw((uint16_t *) v + 1, 32); /* GPIO num ??? */
  853 + v += 2;
  854 + strcpy((void *) v, "cam_turn"); v += 3;
  855 + stw_raw((uint16_t *) v + 0, 12); /* GPIO num ??? */
  856 + stw_raw((uint16_t *) v + 1, 33); /* GPIO num ??? */
  857 + v += 2;
  858 + strcpy((void *) v, "headphone"); v += 3;
  859 + stw_raw((uint16_t *) v + 0, 107); /* GPIO num ??? */
  860 + stw_raw((uint16_t *) v + 1, 17); /* GPIO num ??? */
  861 + v += 2;
  862 +
  863 + /* Bluetooth */
  864 + ADD_TAG(0x6e0e, 12);
  865 + stl_raw(v ++, 0x5c623d01); /* ??? */
  866 + stl_raw(v ++, 0x00000201); /* ??? */
  867 + stl_raw(v ++, 0x00000000); /* ??? */
  868 +
  869 + /* CX3110x WLAN settings */
  870 + ADD_TAG(0x6e0f, 8);
  871 + stl_raw(v ++, 0x00610025); /* ??? */
  872 + stl_raw(v ++, 0xffff0057); /* ??? */
  873 +
  874 + /* MMC host settings */
  875 + ADD_TAG(0x6e10, 12);
  876 + stl_raw(v ++, 0xffff000f); /* ??? */
  877 + stl_raw(v ++, 0xffffffff); /* ??? */
  878 + stl_raw(v ++, 0x00000060); /* ??? */
  879 +
  880 + /* OneNAND chip select */
  881 + ADD_TAG(0x6e11, 10);
  882 + stl_raw(v ++, 0x00000401); /* ??? */
  883 + stl_raw(v ++, 0x0002003a); /* ??? */
  884 + stl_raw(v ++, 0x00000002); /* ??? */
  885 +
  886 + /* TEA5761 sensor settings */
  887 + ADD_TAG(0x6e12, 2);
  888 + stl_raw(v ++, 93); /* GPIO num ??? */
  889 +
  890 +#if 0
  891 + /* Unknown tag */
  892 + ADD_TAG(6e09, 0);
  893 +
  894 + /* Kernel UART / console */
  895 + ADD_TAG(6e12, 0);
  896 +#endif
  897 +
  898 + /* End of the list */
  899 + stl_raw(p ++, 0x00000000);
  900 + stl_raw(p ++, 0x00000000);
  901 +}
  902 +
733 903 /* This task is normally performed by the bootloader. If we're loading
734 904 * a kernel directly, we need to set up GPMC mappings ourselves. */
735 905 static void n800_gpmc_init(struct n800_s *s)
... ... @@ -1081,6 +1251,12 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device,
1081 1251 * (i2c bus 1)
1082 1252 * tmp105 (temperature sensor, hwmon)
1083 1253 * menelaus (pm)
  1254 + * (somewhere on i2c - maybe N800-only)
  1255 + * tea5761 (FM tuner)
  1256 + * (serial 0)
  1257 + * GPS
  1258 + * (some serial port)
  1259 + * csr41814 (Bluetooth)
1084 1260 */
1085 1261 n8x0_gpio_setup(s);
1086 1262 n8x0_nand_setup(s);
... ... @@ -1113,6 +1289,25 @@ static void n8x0_init(ram_addr_t ram_size, const char *boot_device,
1113 1289 n8x0_boot_init(s);
1114 1290 }
1115 1291  
  1292 + if (option_rom[0] && (boot_device[0] == 'n' || !kernel_filename)) {
  1293 + /* No, wait, better start at the ROM. */
  1294 + s->cpu->env->regs[15] = OMAP2_Q2_BASE + 0x400000;
  1295 +
  1296 + /* This is intended for loading the `secondary.bin' program from
  1297 + * Nokia images (the NOLO bootloader). The entry point seems
  1298 + * to be at OMAP2_Q2_BASE + 0x400000.
  1299 + *
  1300 + * The `2nd.bin' files contain some kind of earlier boot code and
  1301 + * for them the entry point needs to be set to OMAP2_SRAM_BASE.
  1302 + *
  1303 + * The code above is for loading the `zImage' file from Nokia
  1304 + * images. */
  1305 + printf("%i bytes of image loaded\n", load_image(option_rom[0],
  1306 + phys_ram_base + 0x400000));
  1307 +
  1308 + n800_setup_nolo_tags(phys_ram_base + sdram_size);
  1309 + }
  1310 +
1116 1311 dpy_resize(ds, 800, 480);
1117 1312 }
1118 1313  
... ...