Эх сурвалжийг харах

Support the Ultra730 with High-Speed USB

Keir Fraser 4 жил өмнө
parent
commit
6b399c6ed0

+ 2 - 1
scripts/greaseweazle/tools/info.py

@@ -17,7 +17,8 @@ from greaseweazle import version
 
 submodel_id = { 1: { 0: 'Basic' },
                 7: { 0: 'Basic',
-                     1: 'AmberTronic F7 Plus' } }
+                     1: 'AmberTronic F7 Plus',
+                     2: 'Ultra730' } }
 
 speed_id = { 0: 'Full Speed (12 Mbit/s)',
              1: 'High Speed (480 Mbit/s)' }

+ 5 - 3
src/stm32f7.c

@@ -68,12 +68,14 @@ static void board_id_init(void)
 
     /* Panic if the ID is unrecognised. */
     gw_info.hw_submodel = id;
-    if (id > 1)
+    if (id > 2)
         early_fatal(2);
 }
 
 static void clock_init(void)
 {
+    unsigned int hse = (gw_info.hw_submodel == F7SM_ultra730) ? 16 : 8;
+
     /* Disable all peripheral clocks except the essentials before enabling 
      * Over-drive mode (see note in RM0431, p102). We still need access to RAM
      * and to the power interface itself. */
@@ -87,8 +89,8 @@ static void clock_init(void)
         cpu_relax();
 
     /* Main PLL. */
-    rcc->pllcfgr = (RCC_PLLCFGR_PLLSRC_HSE | /* PLLSrc = HSE = 8MHz */
-                    RCC_PLLCFGR_PLLM(4) |    /* PLL In = HSE/4 = 2MHz */
+    rcc->pllcfgr = (RCC_PLLCFGR_PLLSRC_HSE | /* PLLSrc = HSE */
+                    RCC_PLLCFGR_PLLM(hse/2) |/* PLL In = HSE/(HSE/2) = 2MHz */
                     RCC_PLLCFGR_PLLN(216) |  /* PLLVCO = 2MHz*216 = 432MHz */
                     RCC_PLLCFGR_PLLP(0) |    /* SYSCLK = 432MHz/2 = 216MHz */
                     RCC_PLLCFGR_PLLQ(9));    /* USB    = 432MHz/9 = 48MHz */

+ 13 - 2
src/usb/hw_dwc_otg.c

@@ -11,6 +11,7 @@
 
 #include "hw_dwc_otg.h"
 
+static int conf_iface;
 static bool_t is_hs;
 
 static struct rx_buf {
@@ -49,8 +50,8 @@ static void hsphyc_init(void)
     hsphyc->ldo |= HSPHYC_LDO_ENABLE;
     do { delay_us(1); } while (!(hsphyc->ldo & HSPHYC_LDO_STATUS));
 
-    /* HSE must be 25MHz! SEL(3) for 16MHz. */
-    hsphyc->pll1 |= HSPHYC_PLL1_SEL(5);
+    /* This is correct only for HSE = 16Mhz. */
+    hsphyc->pll1 |= HSPHYC_PLL1_SEL(3);
 
     /* Magic values from the LL driver. We can probably discard them. */
     hsphyc->tune |= (HSPHYC_TUNE_HSDRVCHKITRIM(7) |
@@ -153,6 +154,16 @@ void hw_usb_init(void)
 {
     int i;
 
+    /* Determine which PHY we use based on hardware submodel ID. */
+    switch (gw_info.hw_submodel) {
+    case F7SM_ultra730:
+        conf_iface = IFACE_HS_EMBEDDED;
+        break;
+    default:
+        conf_iface = IFACE_FS;
+        break;
+    }
+
     /*
      * HAL_PCD_MspInit
      */

+ 0 - 1
src/usb/hw_dwc_otg.h

@@ -17,7 +17,6 @@
 #define IFACE_HS_ULPI     2
 
 #define conf_port PORT_HS
-#define conf_iface IFACE_FS
 #define conf_nr_ep 4
 
 /* USB On-The-Go Full Speed interface */