@@ -1927,6 +1927,31 @@ init_condition_time(struct nvbios *bios, uint16_t offset,
1927
1927
return 3 ;
1928
1928
}
1929
1929
1930
+ static int
1931
+ init_ltime (struct nvbios * bios , uint16_t offset , struct init_exec * iexec )
1932
+ {
1933
+ /*
1934
+ * INIT_LTIME opcode: 0x57 ('V')
1935
+ *
1936
+ * offset (8 bit): opcode
1937
+ * offset + 1 (16 bit): time
1938
+ *
1939
+ * Sleep for "time" miliseconds.
1940
+ */
1941
+
1942
+ unsigned time = ROM16 (bios -> data [offset + 1 ]);
1943
+
1944
+ if (!iexec -> execute )
1945
+ return 3 ;
1946
+
1947
+ BIOSLOG (bios , "0x%04X: Sleeping for 0x%04X miliseconds\n" ,
1948
+ offset , time );
1949
+
1950
+ msleep (time );
1951
+
1952
+ return 3 ;
1953
+ }
1954
+
1930
1955
static int
1931
1956
init_zm_reg_sequence (struct nvbios * bios , uint16_t offset ,
1932
1957
struct init_exec * iexec )
@@ -1994,6 +2019,64 @@ init_sub_direct(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
1994
2019
return 3 ;
1995
2020
}
1996
2021
2022
+ static int
2023
+ init_i2c_if (struct nvbios * bios , uint16_t offset , struct init_exec * iexec )
2024
+ {
2025
+ /*
2026
+ * INIT_I2C_IF opcode: 0x5E ('^')
2027
+ *
2028
+ * offset (8 bit): opcode
2029
+ * offset + 1 (8 bit): DCB I2C table entry index
2030
+ * offset + 2 (8 bit): I2C slave address
2031
+ * offset + 3 (8 bit): I2C register
2032
+ * offset + 4 (8 bit): mask
2033
+ * offset + 5 (8 bit): data
2034
+ *
2035
+ * Read the register given by "I2C register" on the device addressed
2036
+ * by "I2C slave address" on the I2C bus given by "DCB I2C table
2037
+ * entry index". Compare the result AND "mask" to "data".
2038
+ * If they're not equal, skip subsequent opcodes until condition is
2039
+ * inverted (INIT_NOT), or we hit INIT_RESUME
2040
+ */
2041
+
2042
+ uint8_t i2c_index = bios -> data [offset + 1 ];
2043
+ uint8_t i2c_address = bios -> data [offset + 2 ] >> 1 ;
2044
+ uint8_t reg = bios -> data [offset + 3 ];
2045
+ uint8_t mask = bios -> data [offset + 4 ];
2046
+ uint8_t data = bios -> data [offset + 5 ];
2047
+ struct nouveau_i2c_chan * chan ;
2048
+ union i2c_smbus_data val ;
2049
+ int ret ;
2050
+
2051
+ /* no execute check by design */
2052
+
2053
+ BIOSLOG (bios , "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X\n" ,
2054
+ offset , i2c_index , i2c_address );
2055
+
2056
+ chan = init_i2c_device_find (bios -> dev , i2c_index );
2057
+ if (!chan )
2058
+ return - ENODEV ;
2059
+
2060
+ ret = i2c_smbus_xfer (& chan -> adapter , i2c_address , 0 ,
2061
+ I2C_SMBUS_READ , reg ,
2062
+ I2C_SMBUS_BYTE_DATA , & val );
2063
+ if (ret < 0 ) {
2064
+ BIOSLOG (bios , "0x%04X: I2CReg: 0x%02X, Value: [no device], "
2065
+ "Mask: 0x%02X, Data: 0x%02X\n" ,
2066
+ offset , reg , mask , data );
2067
+ iexec -> execute = 0 ;
2068
+ return 6 ;
2069
+ }
2070
+
2071
+ BIOSLOG (bios , "0x%04X: I2CReg: 0x%02X, Value: 0x%02X, "
2072
+ "Mask: 0x%02X, Data: 0x%02X\n" ,
2073
+ offset , reg , val .byte , mask , data );
2074
+
2075
+ iexec -> execute = ((val .byte & mask ) == data );
2076
+
2077
+ return 6 ;
2078
+ }
2079
+
1997
2080
static int
1998
2081
init_copy_nv_reg (struct nvbios * bios , uint16_t offset , struct init_exec * iexec )
1999
2082
{
@@ -2083,9 +2166,10 @@ peek_fb(struct drm_device *dev, struct io_mapping *fb,
2083
2166
uint32_t val = 0 ;
2084
2167
2085
2168
if (off < pci_resource_len (dev -> pdev , 1 )) {
2086
- uint32_t __iomem * p = io_mapping_map_atomic_wc (fb , off , KM_USER0 );
2169
+ uint32_t __iomem * p =
2170
+ io_mapping_map_atomic_wc (fb , off & PAGE_MASK , KM_USER0 );
2087
2171
2088
- val = ioread32 (p );
2172
+ val = ioread32 (p + ( off & ~ PAGE_MASK ) );
2089
2173
2090
2174
io_mapping_unmap_atomic (p , KM_USER0 );
2091
2175
}
@@ -2098,9 +2182,10 @@ poke_fb(struct drm_device *dev, struct io_mapping *fb,
2098
2182
uint32_t off , uint32_t val )
2099
2183
{
2100
2184
if (off < pci_resource_len (dev -> pdev , 1 )) {
2101
- uint32_t __iomem * p = io_mapping_map_atomic_wc (fb , off , KM_USER0 );
2185
+ uint32_t __iomem * p =
2186
+ io_mapping_map_atomic_wc (fb , off & PAGE_MASK , KM_USER0 );
2102
2187
2103
- iowrite32 (val , p );
2188
+ iowrite32 (val , p + ( off & ~ PAGE_MASK ) );
2104
2189
wmb ();
2105
2190
2106
2191
io_mapping_unmap_atomic (p , KM_USER0 );
@@ -2165,7 +2250,7 @@ nv04_init_compute_mem(struct nvbios *bios)
2165
2250
NV04_PFB_BOOT_0_RAM_AMOUNT ,
2166
2251
NV04_PFB_BOOT_0_RAM_AMOUNT_4MB );
2167
2252
2168
- } else if (peek_fb (dev , fb , 0 ) = = patt ) {
2253
+ } else if (peek_fb (dev , fb , 0 ) ! = patt ) {
2169
2254
if (read_back_fb (dev , fb , 0x800000 , patt ))
2170
2255
bios_md32 (bios , NV04_PFB_BOOT_0 ,
2171
2256
NV04_PFB_BOOT_0_RAM_AMOUNT ,
@@ -2593,7 +2678,7 @@ init_configure_preinit(struct nvbios *bios, uint16_t offset,
2593
2678
/* no iexec->execute check by design */
2594
2679
2595
2680
uint32_t straps = bios_rd32 (bios , NV_PEXTDEV_BOOT_0 );
2596
- uint8_t cr3c = ((straps << 2 ) & 0xf0 ) | (straps & ( 1 << 6 )) ;
2681
+ uint8_t cr3c = ((straps << 2 ) & 0xf0 ) | (straps & 0x40 ) >> 6 ;
2597
2682
2598
2683
if (bios -> major_version > 2 )
2599
2684
return 0 ;
@@ -3140,7 +3225,7 @@ init_gpio(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
3140
3225
const uint32_t nv50_gpio_ctl [2 ] = { 0xe100 , 0xe28c };
3141
3226
int i ;
3142
3227
3143
- if (dev_priv -> card_type != NV_50 ) {
3228
+ if (dev_priv -> card_type < NV_50 ) {
3144
3229
NV_ERROR (bios -> dev , "INIT_GPIO on unsupported chipset\n" );
3145
3230
return 1 ;
3146
3231
}
@@ -3490,6 +3575,69 @@ init_zm_auxch(struct nvbios *bios, uint16_t offset, struct init_exec *iexec)
3490
3575
return len ;
3491
3576
}
3492
3577
3578
+ static int
3579
+ init_i2c_long_if (struct nvbios * bios , uint16_t offset , struct init_exec * iexec )
3580
+ {
3581
+ /*
3582
+ * INIT_I2C_LONG_IF opcode: 0x9A ('')
3583
+ *
3584
+ * offset (8 bit): opcode
3585
+ * offset + 1 (8 bit): DCB I2C table entry index
3586
+ * offset + 2 (8 bit): I2C slave address
3587
+ * offset + 3 (16 bit): I2C register
3588
+ * offset + 5 (8 bit): mask
3589
+ * offset + 6 (8 bit): data
3590
+ *
3591
+ * Read the register given by "I2C register" on the device addressed
3592
+ * by "I2C slave address" on the I2C bus given by "DCB I2C table
3593
+ * entry index". Compare the result AND "mask" to "data".
3594
+ * If they're not equal, skip subsequent opcodes until condition is
3595
+ * inverted (INIT_NOT), or we hit INIT_RESUME
3596
+ */
3597
+
3598
+ uint8_t i2c_index = bios -> data [offset + 1 ];
3599
+ uint8_t i2c_address = bios -> data [offset + 2 ] >> 1 ;
3600
+ uint8_t reglo = bios -> data [offset + 3 ];
3601
+ uint8_t reghi = bios -> data [offset + 4 ];
3602
+ uint8_t mask = bios -> data [offset + 5 ];
3603
+ uint8_t data = bios -> data [offset + 6 ];
3604
+ struct nouveau_i2c_chan * chan ;
3605
+ uint8_t buf0 [2 ] = { reghi , reglo };
3606
+ uint8_t buf1 [1 ];
3607
+ struct i2c_msg msg [2 ] = {
3608
+ { i2c_address , 0 , 1 , buf0 },
3609
+ { i2c_address , I2C_M_RD , 1 , buf1 },
3610
+ };
3611
+ int ret ;
3612
+
3613
+ /* no execute check by design */
3614
+
3615
+ BIOSLOG (bios , "0x%04X: DCBI2CIndex: 0x%02X, I2CAddress: 0x%02X\n" ,
3616
+ offset , i2c_index , i2c_address );
3617
+
3618
+ chan = init_i2c_device_find (bios -> dev , i2c_index );
3619
+ if (!chan )
3620
+ return - ENODEV ;
3621
+
3622
+
3623
+ ret = i2c_transfer (& chan -> adapter , msg , 2 );
3624
+ if (ret < 0 ) {
3625
+ BIOSLOG (bios , "0x%04X: I2CReg: 0x%02X:0x%02X, Value: [no device], "
3626
+ "Mask: 0x%02X, Data: 0x%02X\n" ,
3627
+ offset , reghi , reglo , mask , data );
3628
+ iexec -> execute = 0 ;
3629
+ return 7 ;
3630
+ }
3631
+
3632
+ BIOSLOG (bios , "0x%04X: I2CReg: 0x%02X:0x%02X, Value: 0x%02X, "
3633
+ "Mask: 0x%02X, Data: 0x%02X\n" ,
3634
+ offset , reghi , reglo , buf1 [0 ], mask , data );
3635
+
3636
+ iexec -> execute = ((buf1 [0 ] & mask ) == data );
3637
+
3638
+ return 7 ;
3639
+ }
3640
+
3493
3641
static struct init_tbl_entry itbl_entry [] = {
3494
3642
/* command name , id , length , offset , mult , command handler */
3495
3643
/* INIT_PROG (0x31, 15, 10, 4) removed due to no example of use */
@@ -3516,9 +3664,11 @@ static struct init_tbl_entry itbl_entry[] = {
3516
3664
{ "INIT_ZM_CR" , 0x53 , init_zm_cr },
3517
3665
{ "INIT_ZM_CR_GROUP" , 0x54 , init_zm_cr_group },
3518
3666
{ "INIT_CONDITION_TIME" , 0x56 , init_condition_time },
3667
+ { "INIT_LTIME" , 0x57 , init_ltime },
3519
3668
{ "INIT_ZM_REG_SEQUENCE" , 0x58 , init_zm_reg_sequence },
3520
3669
/* INIT_INDIRECT_REG (0x5A, 7, 0, 0) removed due to no example of use */
3521
3670
{ "INIT_SUB_DIRECT" , 0x5B , init_sub_direct },
3671
+ { "INIT_I2C_IF" , 0x5E , init_i2c_if },
3522
3672
{ "INIT_COPY_NV_REG" , 0x5F , init_copy_nv_reg },
3523
3673
{ "INIT_ZM_INDEX_IO" , 0x62 , init_zm_index_io },
3524
3674
{ "INIT_COMPUTE_MEM" , 0x63 , init_compute_mem },
@@ -3552,6 +3702,7 @@ static struct init_tbl_entry itbl_entry[] = {
3552
3702
{ "INIT_97" , 0x97 , init_97 },
3553
3703
{ "INIT_AUXCH" , 0x98 , init_auxch },
3554
3704
{ "INIT_ZM_AUXCH" , 0x99 , init_zm_auxch },
3705
+ { "INIT_I2C_LONG_IF" , 0x9A , init_i2c_long_if },
3555
3706
{ NULL , 0 , NULL }
3556
3707
};
3557
3708
@@ -4410,7 +4561,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent,
4410
4561
bios -> display .script_table_ptr ,
4411
4562
table [2 ], table [3 ], table [0 ] >= 0x21 );
4412
4563
if (!otable ) {
4413
- NV_ERROR (dev , "Couldn't find matching output script table\n" );
4564
+ NV_DEBUG_KMS (dev , "failed to match any output table\n" );
4414
4565
return 1 ;
4415
4566
}
4416
4567
@@ -4467,7 +4618,7 @@ nouveau_bios_run_display_table(struct drm_device *dev, struct dcb_entry *dcbent,
4467
4618
if (script )
4468
4619
script = clkcmptable (bios , script , pxclk );
4469
4620
if (!script ) {
4470
- NV_ERROR (dev , "clock script 0 not found\n" );
4621
+ NV_DEBUG_KMS (dev , "clock script 0 not found\n" );
4471
4622
return 1 ;
4472
4623
}
4473
4624
@@ -4826,7 +4977,7 @@ int get_pll_limits(struct drm_device *dev, uint32_t limit_match, struct pll_lims
4826
4977
pll_lim -> min_p = record [12 ];
4827
4978
pll_lim -> max_p = record [13 ];
4828
4979
/* where did this go to?? */
4829
- if (limit_match == 0x00614100 || limit_match == 0x00614900 )
4980
+ if (( entry [ 0 ] & 0xf0 ) == 0x80 )
4830
4981
pll_lim -> refclk = 27000 ;
4831
4982
else
4832
4983
pll_lim -> refclk = 100000 ;
@@ -5852,7 +6003,7 @@ static void fabricate_vga_output(struct dcb_table *dcb, int i2c, int heads)
5852
6003
entry -> i2c_index = i2c ;
5853
6004
entry -> heads = heads ;
5854
6005
entry -> location = DCB_LOC_ON_CHIP ;
5855
- /* "or" mostly unused in early gen crt modesetting, 0 is fine */
6006
+ entry -> or = 1 ;
5856
6007
}
5857
6008
5858
6009
static void fabricate_dvi_i_output (struct dcb_table * dcb , bool twoHeads )
@@ -5980,7 +6131,13 @@ parse_dcb20_entry(struct drm_device *dev, struct dcb_table *dcb,
5980
6131
}
5981
6132
break ;
5982
6133
case OUTPUT_TMDS :
5983
- entry -> tmdsconf .sor .link = (conf & 0x00000030 ) >> 4 ;
6134
+ if (dcb -> version >= 0x40 )
6135
+ entry -> tmdsconf .sor .link = (conf & 0x00000030 ) >> 4 ;
6136
+ else if (dcb -> version >= 0x30 )
6137
+ entry -> tmdsconf .slave_addr = (conf & 0x00000700 ) >> 8 ;
6138
+ else if (dcb -> version >= 0x22 )
6139
+ entry -> tmdsconf .slave_addr = (conf & 0x00000070 ) >> 4 ;
6140
+
5984
6141
break ;
5985
6142
case 0xe :
5986
6143
/* weird g80 mobile type that "nv" treats as a terminator */
@@ -6270,6 +6427,19 @@ parse_dcb_table(struct drm_device *dev, struct nvbios *bios, bool twoHeads)
6270
6427
dcb -> i2c_table = & bios -> data [i2ctabptr ];
6271
6428
if (dcb -> version >= 0x30 )
6272
6429
dcb -> i2c_default_indices = dcb -> i2c_table [4 ];
6430
+
6431
+ /*
6432
+ * Parse the "management" I2C bus, used for hardware
6433
+ * monitoring and some external TMDS transmitters.
6434
+ */
6435
+ if (dcb -> version >= 0x22 ) {
6436
+ int idx = (dcb -> version >= 0x40 ?
6437
+ dcb -> i2c_default_indices & 0xf :
6438
+ 2 );
6439
+
6440
+ read_dcb_i2c_entry (dev , dcb -> version , dcb -> i2c_table ,
6441
+ idx , & dcb -> i2c [idx ]);
6442
+ }
6273
6443
}
6274
6444
6275
6445
if (entries > DCB_MAX_NUM_ENTRIES )
0 commit comments