diff options
895 files changed, 21809 insertions, 6537 deletions
| @@ -62,6 +62,11 @@ Jeff Garzik <jgarzik@pretzel.yyz.us> | |||
| 62 | Jens Axboe <axboe@suse.de> | 62 | Jens Axboe <axboe@suse.de> |
| 63 | Jens Osterkamp <Jens.Osterkamp@de.ibm.com> | 63 | Jens Osterkamp <Jens.Osterkamp@de.ibm.com> |
| 64 | John Stultz <johnstul@us.ibm.com> | 64 | John Stultz <johnstul@us.ibm.com> |
| 65 | <josh@joshtriplett.org> <josh@freedesktop.org> | ||
| 66 | <josh@joshtriplett.org> <josh@kernel.org> | ||
| 67 | <josh@joshtriplett.org> <josht@linux.vnet.ibm.com> | ||
| 68 | <josh@joshtriplett.org> <josht@us.ibm.com> | ||
| 69 | <josh@joshtriplett.org> <josht@vnet.ibm.com> | ||
| 65 | Juha Yrjola <at solidboot.com> | 70 | Juha Yrjola <at solidboot.com> |
| 66 | Juha Yrjola <juha.yrjola@nokia.com> | 71 | Juha Yrjola <juha.yrjola@nokia.com> |
| 67 | Juha Yrjola <juha.yrjola@solidboot.com> | 72 | Juha Yrjola <juha.yrjola@solidboot.com> |
| @@ -3511,10 +3511,11 @@ S: MacGregor A.C.T 2615 | |||
| 3511 | S: Australia | 3511 | S: Australia |
| 3512 | 3512 | ||
| 3513 | N: Josh Triplett | 3513 | N: Josh Triplett |
| 3514 | E: josh@freedesktop.org | 3514 | E: josh@joshtriplett.org |
| 3515 | P: 1024D/D0FE7AFB B24A 65C9 1D71 2AC2 DE87 CA26 189B 9946 D0FE 7AFB | 3515 | P: 4096R/8AFF873D 758E 5042 E397 4BA3 3A9C 1E67 0ED9 A3DF 8AFF 873D |
| 3516 | D: rcutorture maintainer | 3516 | D: RCU and rcutorture |
| 3517 | D: lock annotations, finding and fixing lock bugs | 3517 | D: lock annotations, finding and fixing lock bugs |
| 3518 | D: kernel tinification | ||
| 3518 | 3519 | ||
| 3519 | N: Winfried Trümper | 3520 | N: Winfried Trümper |
| 3520 | E: winni@xpilot.org | 3521 | E: winni@xpilot.org |
diff --git a/Documentation/Changes b/Documentation/Changes index 2254db0f00a5..227bec88021e 100644 --- a/Documentation/Changes +++ b/Documentation/Changes | |||
| @@ -280,12 +280,9 @@ that is possible. | |||
| 280 | mcelog | 280 | mcelog |
| 281 | ------ | 281 | ------ |
| 282 | 282 | ||
| 283 | In Linux 2.6.31+ the i386 kernel needs to run the mcelog utility | 283 | On x86 kernels the mcelog utility is needed to process and log machine check |
| 284 | as a regular cronjob similar to the x86-64 kernel to process and log | 284 | events when CONFIG_X86_MCE is enabled. Machine check events are errors reported |
| 285 | machine check events when CONFIG_X86_NEW_MCE is enabled. Machine check | 285 | by the CPU. Processing them is strongly encouraged. |
| 286 | events are errors reported by the CPU. Processing them is strongly encouraged. | ||
| 287 | All x86-64 kernels since 2.6.4 require the mcelog utility to | ||
| 288 | process machine checks. | ||
| 289 | 286 | ||
| 290 | Getting updated software | 287 | Getting updated software |
| 291 | ======================== | 288 | ======================== |
diff --git a/Documentation/DocBook/gadget.tmpl b/Documentation/DocBook/gadget.tmpl index 4017f147ba2f..2c425d70f7e2 100644 --- a/Documentation/DocBook/gadget.tmpl +++ b/Documentation/DocBook/gadget.tmpl | |||
| @@ -708,7 +708,7 @@ hardware level details could be very different. | |||
| 708 | 708 | ||
| 709 | <para>Systems need specialized hardware support to implement OTG, | 709 | <para>Systems need specialized hardware support to implement OTG, |
| 710 | notably including a special <emphasis>Mini-AB</emphasis> jack | 710 | notably including a special <emphasis>Mini-AB</emphasis> jack |
| 711 | and associated transciever to support <emphasis>Dual-Role</emphasis> | 711 | and associated transceiver to support <emphasis>Dual-Role</emphasis> |
| 712 | operation: | 712 | operation: |
| 713 | they can act either as a host, using the standard | 713 | they can act either as a host, using the standard |
| 714 | Linux-USB host side driver stack, | 714 | Linux-USB host side driver stack, |
diff --git a/Documentation/DocBook/genericirq.tmpl b/Documentation/DocBook/genericirq.tmpl index 46347f603353..59fb5c077541 100644 --- a/Documentation/DocBook/genericirq.tmpl +++ b/Documentation/DocBook/genericirq.tmpl | |||
| @@ -182,7 +182,7 @@ | |||
| 182 | <para> | 182 | <para> |
| 183 | Each interrupt is described by an interrupt descriptor structure | 183 | Each interrupt is described by an interrupt descriptor structure |
| 184 | irq_desc. The interrupt is referenced by an 'unsigned int' numeric | 184 | irq_desc. The interrupt is referenced by an 'unsigned int' numeric |
| 185 | value which selects the corresponding interrupt decription structure | 185 | value which selects the corresponding interrupt description structure |
| 186 | in the descriptor structures array. | 186 | in the descriptor structures array. |
| 187 | The descriptor structure contains status information and pointers | 187 | The descriptor structure contains status information and pointers |
| 188 | to the interrupt flow method and the interrupt chip structure | 188 | to the interrupt flow method and the interrupt chip structure |
| @@ -470,7 +470,7 @@ if (desc->irq_data.chip->irq_eoi) | |||
| 470 | <para> | 470 | <para> |
| 471 | To avoid copies of identical implementations of IRQ chips the | 471 | To avoid copies of identical implementations of IRQ chips the |
| 472 | core provides a configurable generic interrupt chip | 472 | core provides a configurable generic interrupt chip |
| 473 | implementation. Developers should check carefuly whether the | 473 | implementation. Developers should check carefully whether the |
| 474 | generic chip fits their needs before implementing the same | 474 | generic chip fits their needs before implementing the same |
| 475 | functionality slightly differently themselves. | 475 | functionality slightly differently themselves. |
| 476 | </para> | 476 | </para> |
diff --git a/Documentation/DocBook/kernel-locking.tmpl b/Documentation/DocBook/kernel-locking.tmpl index 19f2a5a5a5b4..e584ee12a1e7 100644 --- a/Documentation/DocBook/kernel-locking.tmpl +++ b/Documentation/DocBook/kernel-locking.tmpl | |||
| @@ -1760,7 +1760,7 @@ as it would be on UP. | |||
| 1760 | </para> | 1760 | </para> |
| 1761 | 1761 | ||
| 1762 | <para> | 1762 | <para> |
| 1763 | There is a furthur optimization possible here: remember our original | 1763 | There is a further optimization possible here: remember our original |
| 1764 | cache code, where there were no reference counts and the caller simply | 1764 | cache code, where there were no reference counts and the caller simply |
| 1765 | held the lock whenever using the object? This is still possible: if | 1765 | held the lock whenever using the object? This is still possible: if |
| 1766 | you hold the lock, no one can delete the object, so you don't need to | 1766 | you hold the lock, no one can delete the object, so you don't need to |
diff --git a/Documentation/DocBook/libata.tmpl b/Documentation/DocBook/libata.tmpl index deb71baed328..d7fcdc5a4379 100644 --- a/Documentation/DocBook/libata.tmpl +++ b/Documentation/DocBook/libata.tmpl | |||
| @@ -677,7 +677,7 @@ and other resources, etc. | |||
| 677 | 677 | ||
| 678 | <listitem> | 678 | <listitem> |
| 679 | <para> | 679 | <para> |
| 680 | ATA_QCFLAG_ACTIVE is clared from qc->flags. | 680 | ATA_QCFLAG_ACTIVE is cleared from qc->flags. |
| 681 | </para> | 681 | </para> |
| 682 | </listitem> | 682 | </listitem> |
| 683 | 683 | ||
| @@ -708,7 +708,7 @@ and other resources, etc. | |||
| 708 | 708 | ||
| 709 | <listitem> | 709 | <listitem> |
| 710 | <para> | 710 | <para> |
| 711 | qc->waiting is claread & completed (in that order). | 711 | qc->waiting is cleared & completed (in that order). |
| 712 | </para> | 712 | </para> |
| 713 | </listitem> | 713 | </listitem> |
| 714 | 714 | ||
| @@ -1163,7 +1163,7 @@ and other resources, etc. | |||
| 1163 | 1163 | ||
| 1164 | <para> | 1164 | <para> |
| 1165 | Once sense data is acquired, this type of errors can be | 1165 | Once sense data is acquired, this type of errors can be |
| 1166 | handled similary to other SCSI errors. Note that sense data | 1166 | handled similarly to other SCSI errors. Note that sense data |
| 1167 | may indicate ATA bus error (e.g. Sense Key 04h HARDWARE ERROR | 1167 | may indicate ATA bus error (e.g. Sense Key 04h HARDWARE ERROR |
| 1168 | && ASC/ASCQ 47h/00h SCSI PARITY ERROR). In such | 1168 | && ASC/ASCQ 47h/00h SCSI PARITY ERROR). In such |
| 1169 | cases, the error should be considered as an ATA bus error and | 1169 | cases, the error should be considered as an ATA bus error and |
diff --git a/Documentation/DocBook/media_api.tmpl b/Documentation/DocBook/media_api.tmpl index 4decb46bfa76..03f9a1f8d413 100644 --- a/Documentation/DocBook/media_api.tmpl +++ b/Documentation/DocBook/media_api.tmpl | |||
| @@ -68,7 +68,7 @@ | |||
| 68 | several digital tv standards. While it is called as DVB API, | 68 | several digital tv standards. While it is called as DVB API, |
| 69 | in fact it covers several different video standards including | 69 | in fact it covers several different video standards including |
| 70 | DVB-T, DVB-S, DVB-C and ATSC. The API is currently being updated | 70 | DVB-T, DVB-S, DVB-C and ATSC. The API is currently being updated |
| 71 | to documment support also for DVB-S2, ISDB-T and ISDB-S.</para> | 71 | to document support also for DVB-S2, ISDB-T and ISDB-S.</para> |
| 72 | <para>The third part covers the Remote Controller API.</para> | 72 | <para>The third part covers the Remote Controller API.</para> |
| 73 | <para>The fourth part covers the Media Controller API.</para> | 73 | <para>The fourth part covers the Media Controller API.</para> |
| 74 | <para>For additional information and for the latest development code, | 74 | <para>For additional information and for the latest development code, |
diff --git a/Documentation/DocBook/mtdnand.tmpl b/Documentation/DocBook/mtdnand.tmpl index cd11926e07c7..7da8f0402af5 100644 --- a/Documentation/DocBook/mtdnand.tmpl +++ b/Documentation/DocBook/mtdnand.tmpl | |||
| @@ -91,7 +91,7 @@ | |||
| 91 | <listitem><para> | 91 | <listitem><para> |
| 92 | [MTD Interface]</para><para> | 92 | [MTD Interface]</para><para> |
| 93 | These functions provide the interface to the MTD kernel API. | 93 | These functions provide the interface to the MTD kernel API. |
| 94 | They are not replacable and provide functionality | 94 | They are not replaceable and provide functionality |
| 95 | which is complete hardware independent. | 95 | which is complete hardware independent. |
| 96 | </para></listitem> | 96 | </para></listitem> |
| 97 | <listitem><para> | 97 | <listitem><para> |
| @@ -100,14 +100,14 @@ | |||
| 100 | </para></listitem> | 100 | </para></listitem> |
| 101 | <listitem><para> | 101 | <listitem><para> |
| 102 | [GENERIC]</para><para> | 102 | [GENERIC]</para><para> |
| 103 | Generic functions are not replacable and provide functionality | 103 | Generic functions are not replaceable and provide functionality |
| 104 | which is complete hardware independent. | 104 | which is complete hardware independent. |
| 105 | </para></listitem> | 105 | </para></listitem> |
| 106 | <listitem><para> | 106 | <listitem><para> |
| 107 | [DEFAULT]</para><para> | 107 | [DEFAULT]</para><para> |
| 108 | Default functions provide hardware related functionality which is suitable | 108 | Default functions provide hardware related functionality which is suitable |
| 109 | for most of the implementations. These functions can be replaced by the | 109 | for most of the implementations. These functions can be replaced by the |
| 110 | board driver if neccecary. Those functions are called via pointers in the | 110 | board driver if necessary. Those functions are called via pointers in the |
| 111 | NAND chip description structure. The board driver can set the functions which | 111 | NAND chip description structure. The board driver can set the functions which |
| 112 | should be replaced by board dependent functions before calling nand_scan(). | 112 | should be replaced by board dependent functions before calling nand_scan(). |
| 113 | If the function pointer is NULL on entry to nand_scan() then the pointer | 113 | If the function pointer is NULL on entry to nand_scan() then the pointer |
| @@ -264,7 +264,7 @@ static void board_hwcontrol(struct mtd_info *mtd, int cmd) | |||
| 264 | is set up nand_scan() is called. This function tries to | 264 | is set up nand_scan() is called. This function tries to |
| 265 | detect and identify then chip. If a chip is found all the | 265 | detect and identify then chip. If a chip is found all the |
| 266 | internal data fields are initialized accordingly. | 266 | internal data fields are initialized accordingly. |
| 267 | The structure(s) have to be zeroed out first and then filled with the neccecary | 267 | The structure(s) have to be zeroed out first and then filled with the necessary |
| 268 | information about the device. | 268 | information about the device. |
| 269 | </para> | 269 | </para> |
| 270 | <programlisting> | 270 | <programlisting> |
| @@ -327,7 +327,7 @@ module_init(board_init); | |||
| 327 | <sect1 id="Exit_function"> | 327 | <sect1 id="Exit_function"> |
| 328 | <title>Exit function</title> | 328 | <title>Exit function</title> |
| 329 | <para> | 329 | <para> |
| 330 | The exit function is only neccecary if the driver is | 330 | The exit function is only necessary if the driver is |
| 331 | compiled as a module. It releases all resources which | 331 | compiled as a module. It releases all resources which |
| 332 | are held by the chip driver and unregisters the partitions | 332 | are held by the chip driver and unregisters the partitions |
| 333 | in the MTD layer. | 333 | in the MTD layer. |
| @@ -494,7 +494,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip) | |||
| 494 | in this case. See rts_from4.c and diskonchip.c for | 494 | in this case. See rts_from4.c and diskonchip.c for |
| 495 | implementation reference. In those cases we must also | 495 | implementation reference. In those cases we must also |
| 496 | use bad block tables on FLASH, because the ECC layout is | 496 | use bad block tables on FLASH, because the ECC layout is |
| 497 | interferring with the bad block marker positions. | 497 | interfering with the bad block marker positions. |
| 498 | See bad block table support for details. | 498 | See bad block table support for details. |
| 499 | </para> | 499 | </para> |
| 500 | </sect2> | 500 | </sect2> |
| @@ -542,7 +542,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip) | |||
| 542 | <para> | 542 | <para> |
| 543 | nand_scan() calls the function nand_default_bbt(). | 543 | nand_scan() calls the function nand_default_bbt(). |
| 544 | nand_default_bbt() selects appropriate default | 544 | nand_default_bbt() selects appropriate default |
| 545 | bad block table desriptors depending on the chip information | 545 | bad block table descriptors depending on the chip information |
| 546 | which was retrieved by nand_scan(). | 546 | which was retrieved by nand_scan(). |
| 547 | </para> | 547 | </para> |
| 548 | <para> | 548 | <para> |
| @@ -554,7 +554,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip) | |||
| 554 | <sect2 id="Flash_based_tables"> | 554 | <sect2 id="Flash_based_tables"> |
| 555 | <title>Flash based tables</title> | 555 | <title>Flash based tables</title> |
| 556 | <para> | 556 | <para> |
| 557 | It may be desired or neccecary to keep a bad block table in FLASH. | 557 | It may be desired or necessary to keep a bad block table in FLASH. |
| 558 | For AG-AND chips this is mandatory, as they have no factory marked | 558 | For AG-AND chips this is mandatory, as they have no factory marked |
| 559 | bad blocks. They have factory marked good blocks. The marker pattern | 559 | bad blocks. They have factory marked good blocks. The marker pattern |
| 560 | is erased when the block is erased to be reused. So in case of | 560 | is erased when the block is erased to be reused. So in case of |
| @@ -565,10 +565,10 @@ static void board_select_chip (struct mtd_info *mtd, int chip) | |||
| 565 | of the blocks. | 565 | of the blocks. |
| 566 | </para> | 566 | </para> |
| 567 | <para> | 567 | <para> |
| 568 | The blocks in which the tables are stored are procteted against | 568 | The blocks in which the tables are stored are protected against |
| 569 | accidental access by marking them bad in the memory bad block | 569 | accidental access by marking them bad in the memory bad block |
| 570 | table. The bad block table management functions are allowed | 570 | table. The bad block table management functions are allowed |
| 571 | to circumvernt this protection. | 571 | to circumvent this protection. |
| 572 | </para> | 572 | </para> |
| 573 | <para> | 573 | <para> |
| 574 | The simplest way to activate the FLASH based bad block table support | 574 | The simplest way to activate the FLASH based bad block table support |
| @@ -592,7 +592,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip) | |||
| 592 | User defined tables are created by filling out a | 592 | User defined tables are created by filling out a |
| 593 | nand_bbt_descr structure and storing the pointer in the | 593 | nand_bbt_descr structure and storing the pointer in the |
| 594 | nand_chip structure member bbt_td before calling nand_scan(). | 594 | nand_chip structure member bbt_td before calling nand_scan(). |
| 595 | If a mirror table is neccecary a second structure must be | 595 | If a mirror table is necessary a second structure must be |
| 596 | created and a pointer to this structure must be stored | 596 | created and a pointer to this structure must be stored |
| 597 | in bbt_md inside the nand_chip structure. If the bbt_md | 597 | in bbt_md inside the nand_chip structure. If the bbt_md |
| 598 | member is set to NULL then only the main table is used | 598 | member is set to NULL then only the main table is used |
| @@ -666,7 +666,7 @@ static void board_select_chip (struct mtd_info *mtd, int chip) | |||
| 666 | <para> | 666 | <para> |
| 667 | For automatic placement some blocks must be reserved for | 667 | For automatic placement some blocks must be reserved for |
| 668 | bad block table storage. The number of reserved blocks is defined | 668 | bad block table storage. The number of reserved blocks is defined |
| 669 | in the maxblocks member of the babd block table description structure. | 669 | in the maxblocks member of the bad block table description structure. |
| 670 | Reserving 4 blocks for mirrored tables should be a reasonable number. | 670 | Reserving 4 blocks for mirrored tables should be a reasonable number. |
| 671 | This also limits the number of blocks which are scanned for the bad | 671 | This also limits the number of blocks which are scanned for the bad |
| 672 | block table ident pattern. | 672 | block table ident pattern. |
| @@ -1068,11 +1068,11 @@ in this page</entry> | |||
| 1068 | <chapter id="filesystems"> | 1068 | <chapter id="filesystems"> |
| 1069 | <title>Filesystem support</title> | 1069 | <title>Filesystem support</title> |
| 1070 | <para> | 1070 | <para> |
| 1071 | The NAND driver provides all neccecary functions for a | 1071 | The NAND driver provides all necessary functions for a |
| 1072 | filesystem via the MTD interface. | 1072 | filesystem via the MTD interface. |
| 1073 | </para> | 1073 | </para> |
| 1074 | <para> | 1074 | <para> |
| 1075 | Filesystems must be aware of the NAND pecularities and | 1075 | Filesystems must be aware of the NAND peculiarities and |
| 1076 | restrictions. One major restrictions of NAND Flash is, that you cannot | 1076 | restrictions. One major restrictions of NAND Flash is, that you cannot |
| 1077 | write as often as you want to a page. The consecutive writes to a page, | 1077 | write as often as you want to a page. The consecutive writes to a page, |
| 1078 | before erasing it again, are restricted to 1-3 writes, depending on the | 1078 | before erasing it again, are restricted to 1-3 writes, depending on the |
| @@ -1222,7 +1222,7 @@ in this page</entry> | |||
| 1222 | #define NAND_BBT_VERSION 0x00000100 | 1222 | #define NAND_BBT_VERSION 0x00000100 |
| 1223 | /* Create a bbt if none axists */ | 1223 | /* Create a bbt if none axists */ |
| 1224 | #define NAND_BBT_CREATE 0x00000200 | 1224 | #define NAND_BBT_CREATE 0x00000200 |
| 1225 | /* Write bbt if neccecary */ | 1225 | /* Write bbt if necessary */ |
| 1226 | #define NAND_BBT_WRITE 0x00001000 | 1226 | #define NAND_BBT_WRITE 0x00001000 |
| 1227 | /* Read and write back block contents when writing bbt */ | 1227 | /* Read and write back block contents when writing bbt */ |
| 1228 | #define NAND_BBT_SAVECONTENT 0x00002000 | 1228 | #define NAND_BBT_SAVECONTENT 0x00002000 |
diff --git a/Documentation/DocBook/regulator.tmpl b/Documentation/DocBook/regulator.tmpl index 346e552fa2cc..3b08a085d2c7 100644 --- a/Documentation/DocBook/regulator.tmpl +++ b/Documentation/DocBook/regulator.tmpl | |||
| @@ -155,7 +155,7 @@ | |||
| 155 | release regulators. Functions are | 155 | release regulators. Functions are |
| 156 | provided to <link linkend='API-regulator-enable'>enable</link> | 156 | provided to <link linkend='API-regulator-enable'>enable</link> |
| 157 | and <link linkend='API-regulator-disable'>disable</link> the | 157 | and <link linkend='API-regulator-disable'>disable</link> the |
| 158 | reguator and to get and set the runtime parameters of the | 158 | regulator and to get and set the runtime parameters of the |
| 159 | regulator. | 159 | regulator. |
| 160 | </para> | 160 | </para> |
| 161 | <para> | 161 | <para> |
diff --git a/Documentation/DocBook/uio-howto.tmpl b/Documentation/DocBook/uio-howto.tmpl index 95618159e29b..bbe9c1fd5cef 100644 --- a/Documentation/DocBook/uio-howto.tmpl +++ b/Documentation/DocBook/uio-howto.tmpl | |||
| @@ -766,10 +766,10 @@ framework to set up sysfs files for this region. Simply leave it alone. | |||
| 766 | <para> | 766 | <para> |
| 767 | The dynamic memory regions will be allocated when the UIO device file, | 767 | The dynamic memory regions will be allocated when the UIO device file, |
| 768 | <varname>/dev/uioX</varname> is opened. | 768 | <varname>/dev/uioX</varname> is opened. |
| 769 | Simiar to static memory resources, the memory region information for | 769 | Similar to static memory resources, the memory region information for |
| 770 | dynamic regions is then visible via sysfs at | 770 | dynamic regions is then visible via sysfs at |
| 771 | <varname>/sys/class/uio/uioX/maps/mapY/*</varname>. | 771 | <varname>/sys/class/uio/uioX/maps/mapY/*</varname>. |
| 772 | The dynmaic memory regions will be freed when the UIO device file is | 772 | The dynamic memory regions will be freed when the UIO device file is |
| 773 | closed. When no processes are holding the device file open, the address | 773 | closed. When no processes are holding the device file open, the address |
| 774 | returned to userspace is ~0. | 774 | returned to userspace is ~0. |
| 775 | </para> | 775 | </para> |
diff --git a/Documentation/DocBook/usb.tmpl b/Documentation/DocBook/usb.tmpl index 8d57c1888dca..85fc0e28576f 100644 --- a/Documentation/DocBook/usb.tmpl +++ b/Documentation/DocBook/usb.tmpl | |||
| @@ -153,7 +153,7 @@ | |||
| 153 | 153 | ||
| 154 | <listitem><para>The Linux USB API supports synchronous calls for | 154 | <listitem><para>The Linux USB API supports synchronous calls for |
| 155 | control and bulk messages. | 155 | control and bulk messages. |
| 156 | It also supports asynchnous calls for all kinds of data transfer, | 156 | It also supports asynchronous calls for all kinds of data transfer, |
| 157 | using request structures called "URBs" (USB Request Blocks). | 157 | using request structures called "URBs" (USB Request Blocks). |
| 158 | </para></listitem> | 158 | </para></listitem> |
| 159 | 159 | ||
diff --git a/Documentation/DocBook/writing-an-alsa-driver.tmpl b/Documentation/DocBook/writing-an-alsa-driver.tmpl index d0056a4e9c53..6f639d9530b5 100644 --- a/Documentation/DocBook/writing-an-alsa-driver.tmpl +++ b/Documentation/DocBook/writing-an-alsa-driver.tmpl | |||
| @@ -5696,7 +5696,7 @@ struct _snd_pcm_runtime { | |||
| 5696 | suspending the PCM operations via | 5696 | suspending the PCM operations via |
| 5697 | <function>snd_pcm_suspend_all()</function> or | 5697 | <function>snd_pcm_suspend_all()</function> or |
| 5698 | <function>snd_pcm_suspend()</function>. It means that the PCM | 5698 | <function>snd_pcm_suspend()</function>. It means that the PCM |
| 5699 | streams are already stoppped when the register snapshot is | 5699 | streams are already stopped when the register snapshot is |
| 5700 | taken. But, remember that you don't have to restart the PCM | 5700 | taken. But, remember that you don't have to restart the PCM |
| 5701 | stream in the resume callback. It'll be restarted via | 5701 | stream in the resume callback. It'll be restarted via |
| 5702 | trigger call with <constant>SNDRV_PCM_TRIGGER_RESUME</constant> | 5702 | trigger call with <constant>SNDRV_PCM_TRIGGER_RESUME</constant> |
diff --git a/Documentation/acpi/enumeration.txt b/Documentation/acpi/enumeration.txt index fd786ea13a1f..e182be5e3c83 100644 --- a/Documentation/acpi/enumeration.txt +++ b/Documentation/acpi/enumeration.txt | |||
| @@ -60,12 +60,6 @@ If the driver needs to perform more complex initialization like getting and | |||
| 60 | configuring GPIOs it can get its ACPI handle and extract this information | 60 | configuring GPIOs it can get its ACPI handle and extract this information |
| 61 | from ACPI tables. | 61 | from ACPI tables. |
| 62 | 62 | ||
| 63 | Currently the kernel is not able to automatically determine from which ACPI | ||
| 64 | device it should make the corresponding platform device so we need to add | ||
| 65 | the ACPI device explicitly to acpi_platform_device_ids list defined in | ||
| 66 | drivers/acpi/acpi_platform.c. This limitation is only for the platform | ||
| 67 | devices, SPI and I2C devices are created automatically as described below. | ||
| 68 | |||
| 69 | DMA support | 63 | DMA support |
| 70 | ~~~~~~~~~~~ | 64 | ~~~~~~~~~~~ |
| 71 | DMA controllers enumerated via ACPI should be registered in the system to | 65 | DMA controllers enumerated via ACPI should be registered in the system to |
diff --git a/Documentation/cpu-freq/intel-pstate.txt b/Documentation/cpu-freq/intel-pstate.txt index e742d21dbd96..a69ffe1d54d5 100644 --- a/Documentation/cpu-freq/intel-pstate.txt +++ b/Documentation/cpu-freq/intel-pstate.txt | |||
| @@ -15,10 +15,13 @@ New sysfs files for controlling P state selection have been added to | |||
| 15 | /sys/devices/system/cpu/intel_pstate/ | 15 | /sys/devices/system/cpu/intel_pstate/ |
| 16 | 16 | ||
| 17 | max_perf_pct: limits the maximum P state that will be requested by | 17 | max_perf_pct: limits the maximum P state that will be requested by |
| 18 | the driver stated as a percentage of the available performance. | 18 | the driver stated as a percentage of the available performance. The |
| 19 | available (P states) performance may be reduced by the no_turbo | ||
| 20 | setting described below. | ||
| 19 | 21 | ||
| 20 | min_perf_pct: limits the minimum P state that will be requested by | 22 | min_perf_pct: limits the minimum P state that will be requested by |
| 21 | the driver stated as a percentage of the available performance. | 23 | the driver stated as a percentage of the max (non-turbo) |
| 24 | performance level. | ||
| 22 | 25 | ||
| 23 | no_turbo: limits the driver to selecting P states below the turbo | 26 | no_turbo: limits the driver to selecting P states below the turbo |
| 24 | frequency range. | 27 | frequency range. |
diff --git a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt index 5216b419016a..8b4f7b7fe88b 100644 --- a/Documentation/devicetree/bindings/arm/exynos/power_domain.txt +++ b/Documentation/devicetree/bindings/arm/exynos/power_domain.txt | |||
| @@ -9,6 +9,18 @@ Required Properties: | |||
| 9 | - reg: physical base address of the controller and length of memory mapped | 9 | - reg: physical base address of the controller and length of memory mapped |
| 10 | region. | 10 | region. |
| 11 | 11 | ||
| 12 | Optional Properties: | ||
| 13 | - clocks: List of clock handles. The parent clocks of the input clocks to the | ||
| 14 | devices in this power domain are set to oscclk before power gating | ||
| 15 | and restored back after powering on a domain. This is required for | ||
| 16 | all domains which are powered on and off and not required for unused | ||
| 17 | domains. | ||
| 18 | - clock-names: The following clocks can be specified: | ||
| 19 | - oscclk: Oscillator clock. | ||
| 20 | - pclkN, clkN: Pairs of parent of input clock and input clock to the | ||
| 21 | devices in this power domain. Maximum of 4 pairs (N = 0 to 3) | ||
| 22 | are supported currently. | ||
| 23 | |||
| 12 | Node of a device using power domains must have a samsung,power-domain property | 24 | Node of a device using power domains must have a samsung,power-domain property |
| 13 | defined with a phandle to respective power domain. | 25 | defined with a phandle to respective power domain. |
| 14 | 26 | ||
| @@ -19,6 +31,14 @@ Example: | |||
| 19 | reg = <0x10023C00 0x10>; | 31 | reg = <0x10023C00 0x10>; |
| 20 | }; | 32 | }; |
| 21 | 33 | ||
| 34 | mfc_pd: power-domain@10044060 { | ||
| 35 | compatible = "samsung,exynos4210-pd"; | ||
| 36 | reg = <0x10044060 0x20>; | ||
| 37 | clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>, | ||
| 38 | <&clock CLK_MOUT_USER_ACLK333>; | ||
| 39 | clock-names = "oscclk", "pclk0", "clk0"; | ||
| 40 | }; | ||
| 41 | |||
| 22 | Example of the node using power domain: | 42 | Example of the node using power domain: |
| 23 | 43 | ||
| 24 | node { | 44 | node { |
diff --git a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt index f055515d2b62..366690cb86a3 100644 --- a/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt +++ b/Documentation/devicetree/bindings/cpufreq/cpufreq-cpu0.txt | |||
| @@ -8,10 +8,12 @@ Both required and optional properties listed below must be defined | |||
| 8 | under node /cpus/cpu@0. | 8 | under node /cpus/cpu@0. |
| 9 | 9 | ||
| 10 | Required properties: | 10 | Required properties: |
| 11 | - operating-points: Refer to Documentation/devicetree/bindings/power/opp.txt | 11 | - None |
| 12 | for details | ||
| 13 | 12 | ||
| 14 | Optional properties: | 13 | Optional properties: |
| 14 | - operating-points: Refer to Documentation/devicetree/bindings/power/opp.txt for | ||
| 15 | details. OPPs *must* be supplied either via DT, i.e. this property, or | ||
| 16 | populated at runtime. | ||
| 15 | - clock-latency: Specify the possible maximum transition latency for clock, | 17 | - clock-latency: Specify the possible maximum transition latency for clock, |
| 16 | in unit of nanoseconds. | 18 | in unit of nanoseconds. |
| 17 | - voltage-tolerance: Specify the CPU voltage tolerance in percentage. | 19 | - voltage-tolerance: Specify the CPU voltage tolerance in percentage. |
diff --git a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt index 64fd7dec1bbc..b3556609a06f 100644 --- a/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt +++ b/Documentation/devicetree/bindings/serial/renesas,sci-serial.txt | |||
| @@ -4,6 +4,13 @@ Required properties: | |||
| 4 | 4 | ||
| 5 | - compatible: Must contain one of the following: | 5 | - compatible: Must contain one of the following: |
| 6 | 6 | ||
| 7 | - "renesas,scifa-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFA compatible UART. | ||
| 8 | - "renesas,scifb-sh73a0" for SH73A0 (SH-Mobile AG5) SCIFB compatible UART. | ||
| 9 | - "renesas,scifa-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFA compatible UART. | ||
| 10 | - "renesas,scifb-r8a73a4" for R8A73A4 (R-Mobile APE6) SCIFB compatible UART. | ||
| 11 | - "renesas,scifa-r8a7740" for R8A7740 (R-Mobile A1) SCIFA compatible UART. | ||
| 12 | - "renesas,scifb-r8a7740" for R8A7740 (R-Mobile A1) SCIFB compatible UART. | ||
| 13 | - "renesas,scif-r8a7778" for R8A7778 (R-Car M1) SCIF compatible UART. | ||
| 7 | - "renesas,scif-r8a7779" for R8A7779 (R-Car H1) SCIF compatible UART. | 14 | - "renesas,scif-r8a7779" for R8A7779 (R-Car H1) SCIF compatible UART. |
| 8 | - "renesas,scif-r8a7790" for R8A7790 (R-Car H2) SCIF compatible UART. | 15 | - "renesas,scif-r8a7790" for R8A7790 (R-Car H2) SCIF compatible UART. |
| 9 | - "renesas,scifa-r8a7790" for R8A7790 (R-Car H2) SCIFA compatible UART. | 16 | - "renesas,scifa-r8a7790" for R8A7790 (R-Car H2) SCIFA compatible UART. |
diff --git a/Documentation/devicetree/bindings/sound/ak5386.txt b/Documentation/devicetree/bindings/sound/ak5386.txt index dc3914fe6ce8..ec3df3abba0c 100644 --- a/Documentation/devicetree/bindings/sound/ak5386.txt +++ b/Documentation/devicetree/bindings/sound/ak5386.txt | |||
| @@ -10,10 +10,14 @@ Optional properties: | |||
| 10 | 10 | ||
| 11 | - reset-gpio : a GPIO spec for the reset/power down pin. | 11 | - reset-gpio : a GPIO spec for the reset/power down pin. |
| 12 | If specified, it will be deasserted at probe time. | 12 | If specified, it will be deasserted at probe time. |
| 13 | - va-supply : a regulator spec, providing 5.0V | ||
| 14 | - vd-supply : a regulator spec, providing 3.3V | ||
| 13 | 15 | ||
| 14 | Example: | 16 | Example: |
| 15 | 17 | ||
| 16 | spdif: ak5386@0 { | 18 | spdif: ak5386@0 { |
| 17 | compatible = "asahi-kasei,ak5386"; | 19 | compatible = "asahi-kasei,ak5386"; |
| 18 | reset-gpio = <&gpio0 23>; | 20 | reset-gpio = <&gpio0 23>; |
| 21 | va-supply = <&vdd_5v0_reg>; | ||
| 22 | vd-supply = <&vdd_3v3_reg>; | ||
| 19 | }; | 23 | }; |
diff --git a/Documentation/devicetree/bindings/sound/cs4265.txt b/Documentation/devicetree/bindings/sound/cs4265.txt new file mode 100644 index 000000000000..380fff8e4e83 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/cs4265.txt | |||
| @@ -0,0 +1,29 @@ | |||
| 1 | CS4265 audio CODEC | ||
| 2 | |||
| 3 | This device supports I2C only. | ||
| 4 | |||
| 5 | Required properties: | ||
| 6 | |||
| 7 | - compatible : "cirrus,cs4265" | ||
| 8 | |||
| 9 | - reg : the I2C address of the device for I2C. The I2C address depends on | ||
| 10 | the state of the AD0 pin. If AD0 is high, the i2c address is 0x4f. | ||
| 11 | If it is low, the i2c address is 0x4e. | ||
| 12 | |||
| 13 | Optional properties: | ||
| 14 | |||
| 15 | - reset-gpios : a GPIO spec for the reset pin. If specified, it will be | ||
| 16 | deasserted before communication to the codec starts. | ||
| 17 | |||
| 18 | Examples: | ||
| 19 | |||
| 20 | codec_ad0_high: cs4265@4f { /* AD0 Pin is high */ | ||
| 21 | compatible = "cirrus,cs4265"; | ||
| 22 | reg = <0x4f>; | ||
| 23 | }; | ||
| 24 | |||
| 25 | |||
| 26 | codec_ad0_low: cs4265@4e { /* AD0 Pin is low */ | ||
| 27 | compatible = "cirrus,cs4265"; | ||
| 28 | reg = <0x4e>; | ||
| 29 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/fsl,asrc.txt b/Documentation/devicetree/bindings/sound/fsl,asrc.txt new file mode 100644 index 000000000000..b93362a570be --- /dev/null +++ b/Documentation/devicetree/bindings/sound/fsl,asrc.txt | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | Freescale Asynchronous Sample Rate Converter (ASRC) Controller | ||
| 2 | |||
| 3 | The Asynchronous Sample Rate Converter (ASRC) converts the sampling rate of a | ||
| 4 | signal associated with an input clock into a signal associated with a different | ||
| 5 | output clock. The driver currently works as a Front End of DPCM with other Back | ||
| 6 | Ends Audio controller such as ESAI, SSI and SAI. It has three pairs to support | ||
| 7 | three substreams within totally 10 channels. | ||
| 8 | |||
| 9 | Required properties: | ||
| 10 | |||
| 11 | - compatible : Contains "fsl,imx35-asrc" or "fsl,imx53-asrc". | ||
| 12 | |||
| 13 | - reg : Offset and length of the register set for the device. | ||
| 14 | |||
| 15 | - interrupts : Contains the spdif interrupt. | ||
| 16 | |||
| 17 | - dmas : Generic dma devicetree binding as described in | ||
| 18 | Documentation/devicetree/bindings/dma/dma.txt. | ||
| 19 | |||
| 20 | - dma-names : Contains "rxa", "rxb", "rxc", "txa", "txb" and "txc". | ||
| 21 | |||
| 22 | - clocks : Contains an entry for each entry in clock-names. | ||
| 23 | |||
| 24 | - clock-names : Contains the following entries | ||
| 25 | "mem" Peripheral access clock to access registers. | ||
| 26 | "ipg" Peripheral clock to driver module. | ||
| 27 | "asrck_<0-f>" Clock sources for input and output clock. | ||
| 28 | |||
| 29 | - big-endian : If this property is absent, the little endian mode | ||
| 30 | will be in use as default. Otherwise, the big endian | ||
| 31 | mode will be in use for all the device registers. | ||
| 32 | |||
| 33 | - fsl,asrc-rate : Defines a mutual sample rate used by DPCM Back Ends. | ||
| 34 | |||
| 35 | - fsl,asrc-width : Defines a mutual sample width used by DPCM Back Ends. | ||
| 36 | |||
| 37 | Example: | ||
| 38 | |||
| 39 | asrc: asrc@02034000 { | ||
| 40 | compatible = "fsl,imx53-asrc"; | ||
| 41 | reg = <0x02034000 0x4000>; | ||
| 42 | interrupts = <0 50 IRQ_TYPE_LEVEL_HIGH>; | ||
| 43 | clocks = <&clks 107>, <&clks 107>, <&clks 0>, | ||
| 44 | <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, | ||
| 45 | <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, | ||
| 46 | <&clks 0>, <&clks 0>, <&clks 0>, <&clks 0>, | ||
| 47 | <&clks 107>, <&clks 0>, <&clks 0>; | ||
| 48 | clock-names = "mem", "ipg", "asrck0", | ||
| 49 | "asrck_1", "asrck_2", "asrck_3", "asrck_4", | ||
| 50 | "asrck_5", "asrck_6", "asrck_7", "asrck_8", | ||
| 51 | "asrck_9", "asrck_a", "asrck_b", "asrck_c", | ||
| 52 | "asrck_d", "asrck_e", "asrck_f"; | ||
| 53 | dmas = <&sdma 17 23 1>, <&sdma 18 23 1>, <&sdma 19 23 1>, | ||
| 54 | <&sdma 20 23 1>, <&sdma 21 23 1>, <&sdma 22 23 1>; | ||
| 55 | dma-names = "rxa", "rxb", "rxc", | ||
| 56 | "txa", "txb", "txc"; | ||
| 57 | fsl,asrc-rate = <48000>; | ||
| 58 | fsl,asrc-width = <16>; | ||
| 59 | status = "okay"; | ||
| 60 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/max98090.txt b/Documentation/devicetree/bindings/sound/max98090.txt index a5e63fa47dc5..c454e67f54bb 100644 --- a/Documentation/devicetree/bindings/sound/max98090.txt +++ b/Documentation/devicetree/bindings/sound/max98090.txt | |||
| @@ -4,7 +4,7 @@ This device supports I2C only. | |||
| 4 | 4 | ||
| 5 | Required properties: | 5 | Required properties: |
| 6 | 6 | ||
| 7 | - compatible : "maxim,max98090". | 7 | - compatible : "maxim,max98090" or "maxim,max98091". |
| 8 | 8 | ||
| 9 | - reg : The I2C address of the device. | 9 | - reg : The I2C address of the device. |
| 10 | 10 | ||
diff --git a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt index 8346cab046cd..aa697abf337e 100644 --- a/Documentation/devicetree/bindings/sound/renesas,rsnd.txt +++ b/Documentation/devicetree/bindings/sound/renesas,rsnd.txt | |||
| @@ -13,6 +13,9 @@ Required properties: | |||
| 13 | - rcar_sound,src : Should contain SRC feature. | 13 | - rcar_sound,src : Should contain SRC feature. |
| 14 | The number of SRC subnode should be same as HW. | 14 | The number of SRC subnode should be same as HW. |
| 15 | see below for detail. | 15 | see below for detail. |
| 16 | - rcar_sound,dvc : Should contain DVC feature. | ||
| 17 | The number of DVC subnode should be same as HW. | ||
| 18 | see below for detail. | ||
| 16 | - rcar_sound,dai : DAI contents. | 19 | - rcar_sound,dai : DAI contents. |
| 17 | The number of DAI subnode should be same as HW. | 20 | The number of DAI subnode should be same as HW. |
| 18 | see below for detail. | 21 | see below for detail. |
| @@ -21,6 +24,7 @@ SSI subnode properties: | |||
| 21 | - interrupts : Should contain SSI interrupt for PIO transfer | 24 | - interrupts : Should contain SSI interrupt for PIO transfer |
| 22 | - shared-pin : if shared clock pin | 25 | - shared-pin : if shared clock pin |
| 23 | - pio-transfer : use PIO transfer mode | 26 | - pio-transfer : use PIO transfer mode |
| 27 | - no-busif : BUSIF is not ussed when [mem -> SSI] via DMA case | ||
| 24 | 28 | ||
| 25 | SRC subnode properties: | 29 | SRC subnode properties: |
| 26 | no properties at this point | 30 | no properties at this point |
| @@ -39,6 +43,11 @@ rcar_sound: rcar_sound@0xffd90000 { | |||
| 39 | <0 0xec540000 0 0x1000>, /* SSIU */ | 43 | <0 0xec540000 0 0x1000>, /* SSIU */ |
| 40 | <0 0xec541000 0 0x1280>; /* SSI */ | 44 | <0 0xec541000 0 0x1280>; /* SSI */ |
| 41 | 45 | ||
| 46 | rcar_sound,dvc { | ||
| 47 | dvc0: dvc@0 { }; | ||
| 48 | dvc1: dvc@1 { }; | ||
| 49 | }; | ||
| 50 | |||
| 42 | rcar_sound,src { | 51 | rcar_sound,src { |
| 43 | src0: src@0 { }; | 52 | src0: src@0 { }; |
| 44 | src1: src@1 { }; | 53 | src1: src@1 { }; |
diff --git a/Documentation/devicetree/bindings/sound/rockchip-i2s.txt b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt new file mode 100644 index 000000000000..6c55fcfe5e1d --- /dev/null +++ b/Documentation/devicetree/bindings/sound/rockchip-i2s.txt | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | * Rockchip I2S controller | ||
| 2 | |||
| 3 | The I2S bus (Inter-IC sound bus) is a serial link for digital | ||
| 4 | audio data transfer between devices in the system. | ||
| 5 | |||
| 6 | Required properties: | ||
| 7 | |||
| 8 | - compatible: should be one of the followings | ||
| 9 | - "rockchip,rk3066-i2s": for rk3066 | ||
| 10 | - "rockchip,rk3188-i2s", "rockchip,rk3066-i2s": for rk3188 | ||
| 11 | - "rockchip,rk3288-i2s", "rockchip,rk3066-i2s": for rk3288 | ||
| 12 | - reg: physical base address of the controller and length of memory mapped | ||
| 13 | region. | ||
| 14 | - interrupts: should contain the I2S interrupt. | ||
| 15 | - #address-cells: should be 1. | ||
| 16 | - #size-cells: should be 0. | ||
| 17 | - dmas: DMA specifiers for tx and rx dma. See the DMA client binding, | ||
| 18 | Documentation/devicetree/bindings/dma/dma.txt | ||
| 19 | - dma-names: should include "tx" and "rx". | ||
| 20 | - clocks: a list of phandle + clock-specifer pairs, one for each entry in clock-names. | ||
| 21 | - clock-names: should contain followings: | ||
| 22 | - "i2s_hclk": clock for I2S BUS | ||
| 23 | - "i2s_clk" : clock for I2S controller | ||
| 24 | |||
| 25 | Example for rk3288 I2S controller: | ||
| 26 | |||
| 27 | i2s@ff890000 { | ||
| 28 | compatible = "rockchip,rk3288-i2s", "rockchip,rk3066-i2s"; | ||
| 29 | reg = <0xff890000 0x10000>; | ||
| 30 | interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>; | ||
| 31 | #address-cells = <1>; | ||
| 32 | #size-cells = <0>; | ||
| 33 | dmas = <&pdma1 0>, <&pdma1 1>; | ||
| 34 | dma-names = "rx", "tx"; | ||
| 35 | clock-names = "i2s_hclk", "i2s_clk"; | ||
| 36 | clocks = <&cru HCLK_I2S0>, <&cru SCLK_I2S0>; | ||
| 37 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/samsung,odroidx2-max98090.txt b/Documentation/devicetree/bindings/sound/samsung,odroidx2-max98090.txt new file mode 100644 index 000000000000..9148f72319e1 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/samsung,odroidx2-max98090.txt | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | Samsung Exynos Odroid X2/U3 audio complex with MAX98090 codec | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible : "samsung,odroidx2-audio" - for Odroid X2 board, | ||
| 5 | "samsung,odroidu3-audio" - for Odroid U3 board | ||
| 6 | - samsung,model : the user-visible name of this sound complex | ||
| 7 | - samsung,i2s-controller : the phandle of the I2S controller | ||
| 8 | - samsung,audio-codec : the phandle of the MAX98090 audio codec | ||
| 9 | - samsung,audio-routing : a list of the connections between audio | ||
| 10 | components; each entry is a pair of strings, the first being the | ||
| 11 | connection's sink, the second being the connection's source; | ||
| 12 | valid names for sources and sinks are the MAX98090's pins (as | ||
| 13 | documented in its binding), and the jacks on the board | ||
| 14 | For Odroid X2: | ||
| 15 | * Headphone Jack | ||
| 16 | * Mic Jack | ||
| 17 | * DMIC | ||
| 18 | |||
| 19 | For Odroid U3: | ||
| 20 | * Headphone Jack | ||
| 21 | * Speakers | ||
| 22 | |||
| 23 | Example: | ||
| 24 | |||
| 25 | sound { | ||
| 26 | compatible = "samsung,odroidu3-audio"; | ||
| 27 | samsung,i2s-controller = <&i2s0>; | ||
| 28 | samsung,audio-codec = <&max98090>; | ||
| 29 | samsung,model = "Odroid-X2"; | ||
| 30 | samsung,audio-routing = | ||
| 31 | "Headphone Jack", "HPL", | ||
| 32 | "Headphone Jack", "HPR", | ||
| 33 | "IN1", "Mic Jack", | ||
| 34 | "Mic Jack", "MICBIAS"; | ||
| 35 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/sirf-usp.txt b/Documentation/devicetree/bindings/sound/sirf-usp.txt new file mode 100644 index 000000000000..02f85b32d359 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/sirf-usp.txt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | * SiRF SoC USP module | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible: "sirf,prima2-usp-pcm" | ||
| 5 | - reg: Base address and size entries: | ||
| 6 | - dmas: List of DMA controller phandle and DMA request line ordered pairs. | ||
| 7 | - dma-names: Identifier string for each DMA request line in the dmas property. | ||
| 8 | These strings correspond 1:1 with the ordered pairs in dmas. | ||
| 9 | |||
| 10 | One of the DMA channels will be responsible for transmission (should be | ||
| 11 | named "tx") and one for reception (should be named "rx"). | ||
| 12 | |||
| 13 | - clocks: USP controller clock source | ||
| 14 | - pinctrl-names: Must contain a "default" entry. | ||
| 15 | - pinctrl-NNN: One property must exist for each entry in pinctrl-names. | ||
| 16 | |||
| 17 | Example: | ||
| 18 | usp0: usp@b0080000 { | ||
| 19 | compatible = "sirf,prima2-usp-pcm"; | ||
| 20 | reg = <0xb0080000 0x10000>; | ||
| 21 | clocks = <&clks 28>; | ||
| 22 | dmas = <&dmac1 1>, <&dmac1 2>; | ||
| 23 | dma-names = "rx", "tx"; | ||
| 24 | pinctrl-names = "default"; | ||
| 25 | pinctrl-0 = <&usp0_only_utfs_pins_a>; | ||
| 26 | }; | ||
| 27 | |||
diff --git a/Documentation/devicetree/bindings/sound/snow.txt b/Documentation/devicetree/bindings/sound/snow.txt index 678b191c37b8..6df74f15687f 100644 --- a/Documentation/devicetree/bindings/sound/snow.txt +++ b/Documentation/devicetree/bindings/sound/snow.txt | |||
| @@ -3,15 +3,20 @@ Audio Binding for Snow boards | |||
| 3 | Required properties: | 3 | Required properties: |
| 4 | - compatible : Can be one of the following, | 4 | - compatible : Can be one of the following, |
| 5 | "google,snow-audio-max98090" or | 5 | "google,snow-audio-max98090" or |
| 6 | "google,snow-audio-max98091" or | ||
| 6 | "google,snow-audio-max98095" | 7 | "google,snow-audio-max98095" |
| 7 | - samsung,i2s-controller: The phandle of the Samsung I2S controller | 8 | - samsung,i2s-controller: The phandle of the Samsung I2S controller |
| 8 | - samsung,audio-codec: The phandle of the audio codec | 9 | - samsung,audio-codec: The phandle of the audio codec |
| 9 | 10 | ||
| 11 | Optional: | ||
| 12 | - samsung,model: The name of the sound-card | ||
| 13 | |||
| 10 | Example: | 14 | Example: |
| 11 | 15 | ||
| 12 | sound { | 16 | sound { |
| 13 | compatible = "google,snow-audio-max98095"; | 17 | compatible = "google,snow-audio-max98095"; |
| 14 | 18 | ||
| 19 | samsung,model = "Snow-I2S-MAX98095"; | ||
| 15 | samsung,i2s-controller = <&i2s0>; | 20 | samsung,i2s-controller = <&i2s0>; |
| 16 | samsung,audio-codec = <&max98095>; | 21 | samsung,audio-codec = <&max98095>; |
| 17 | }; | 22 | }; |
diff --git a/Documentation/devicetree/bindings/sound/tas2552.txt b/Documentation/devicetree/bindings/sound/tas2552.txt new file mode 100644 index 000000000000..55e2a0af5645 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/tas2552.txt | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | Texas Instruments - tas2552 Codec module | ||
| 2 | |||
| 3 | The tas2552 serial control bus communicates through I2C protocols | ||
| 4 | |||
| 5 | Required properties: | ||
| 6 | - compatible - One of: | ||
| 7 | "ti,tas2552" - TAS2552 | ||
| 8 | - reg - I2C slave address | ||
| 9 | - supply-*: Required supply regulators are: | ||
| 10 | "vbat" battery voltage | ||
| 11 | "iovdd" I/O Voltage | ||
| 12 | "avdd" Analog DAC Voltage | ||
| 13 | |||
| 14 | Optional properties: | ||
| 15 | - enable-gpio - gpio pin to enable/disable the device | ||
| 16 | |||
| 17 | Example: | ||
| 18 | |||
| 19 | tas2552: tas2552@41 { | ||
| 20 | compatible = "ti,tas2552"; | ||
| 21 | reg = <0x41>; | ||
| 22 | enable-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>; | ||
| 23 | }; | ||
| 24 | |||
| 25 | For more product information please see the link below: | ||
| 26 | http://www.ti.com/product/TAS2552 | ||
diff --git a/Documentation/devicetree/bindings/sound/ti,tas5086.txt b/Documentation/devicetree/bindings/sound/ti,tas5086.txt index d2866a0d6a26..234dad296da7 100644 --- a/Documentation/devicetree/bindings/sound/ti,tas5086.txt +++ b/Documentation/devicetree/bindings/sound/ti,tas5086.txt | |||
| @@ -31,6 +31,9 @@ Optional properties: | |||
| 31 | 31 | ||
| 32 | Most systems should not set any of these properties. | 32 | Most systems should not set any of these properties. |
| 33 | 33 | ||
| 34 | - avdd-supply: Power supply for AVDD, providing 3.3V | ||
| 35 | - dvdd-supply: Power supply for DVDD, providing 3.3V | ||
| 36 | |||
| 34 | Examples: | 37 | Examples: |
| 35 | 38 | ||
| 36 | i2c_bus { | 39 | i2c_bus { |
| @@ -39,5 +42,7 @@ Examples: | |||
| 39 | reg = <0x1b>; | 42 | reg = <0x1b>; |
| 40 | reset-gpio = <&gpio 23 0>; | 43 | reset-gpio = <&gpio 23 0>; |
| 41 | ti,charge-period = <156000>; | 44 | ti,charge-period = <156000>; |
| 45 | avdd-supply = <&vdd_3v3_reg>; | ||
| 46 | dvdd-supply = <&vdd_3v3_reg>; | ||
| 42 | }; | 47 | }; |
| 43 | }; | 48 | }; |
diff --git a/Documentation/devicetree/bindings/sound/wm8904.txt b/Documentation/devicetree/bindings/sound/wm8904.txt new file mode 100644 index 000000000000..e99f4097c83c --- /dev/null +++ b/Documentation/devicetree/bindings/sound/wm8904.txt | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | WM8904 audio CODEC | ||
| 2 | |||
| 3 | This device supports I2C only. | ||
| 4 | |||
| 5 | Required properties: | ||
| 6 | - compatible: "wlf,wm8904" | ||
| 7 | - reg: the I2C address of the device. | ||
| 8 | - clock-names: "mclk" | ||
| 9 | - clocks: reference to | ||
| 10 | <Documentation/devicetree/bindings/clock/clock-bindings.txt> | ||
| 11 | |||
| 12 | Pins on the device (for linking into audio routes): | ||
| 13 | |||
| 14 | * IN1L | ||
| 15 | * IN1R | ||
| 16 | * IN2L | ||
| 17 | * IN2R | ||
| 18 | * IN3L | ||
| 19 | * IN3R | ||
| 20 | * HPOUTL | ||
| 21 | * HPOUTR | ||
| 22 | * LINEOUTL | ||
| 23 | * LINEOUTR | ||
| 24 | * MICBIAS | ||
| 25 | |||
| 26 | Examples: | ||
| 27 | |||
| 28 | codec: wm8904@1a { | ||
| 29 | compatible = "wlf,wm8904"; | ||
| 30 | reg = <0x1a>; | ||
| 31 | clocks = <&pck0>; | ||
| 32 | clock-names = "mclk"; | ||
| 33 | }; | ||
diff --git a/Documentation/input/event-codes.txt b/Documentation/input/event-codes.txt index f1ea2c69648d..c587a966413e 100644 --- a/Documentation/input/event-codes.txt +++ b/Documentation/input/event-codes.txt | |||
| @@ -281,6 +281,19 @@ gestures can normally be extracted from it. | |||
| 281 | If INPUT_PROP_SEMI_MT is not set, the device is assumed to be a true MT | 281 | If INPUT_PROP_SEMI_MT is not set, the device is assumed to be a true MT |
| 282 | device. | 282 | device. |
| 283 | 283 | ||
| 284 | INPUT_PROP_TOPBUTTONPAD: | ||
| 285 | ----------------------- | ||
| 286 | Some laptops, most notably the Lenovo *40 series provide a trackstick | ||
| 287 | device but do not have physical buttons associated with the trackstick | ||
| 288 | device. Instead, the top area of the touchpad is marked to show | ||
| 289 | visual/haptic areas for left, middle, right buttons intended to be used | ||
| 290 | with the trackstick. | ||
| 291 | |||
| 292 | If INPUT_PROP_TOPBUTTONPAD is set, userspace should emulate buttons | ||
| 293 | accordingly. This property does not affect kernel behavior. | ||
| 294 | The kernel does not provide button emulation for such devices but treats | ||
| 295 | them as any other INPUT_PROP_BUTTONPAD device. | ||
| 296 | |||
| 284 | Guidelines: | 297 | Guidelines: |
| 285 | ========== | 298 | ========== |
| 286 | The guidelines below ensure proper single-touch and multi-finger functionality. | 299 | The guidelines below ensure proper single-touch and multi-finger functionality. |
diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt index c1b9aa8c5a52..b7fa2f599459 100644 --- a/Documentation/kernel-parameters.txt +++ b/Documentation/kernel-parameters.txt | |||
| @@ -2790,6 +2790,12 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
| 2790 | leaf rcu_node structure. Useful for very large | 2790 | leaf rcu_node structure. Useful for very large |
| 2791 | systems. | 2791 | systems. |
| 2792 | 2792 | ||
| 2793 | rcutree.jiffies_till_sched_qs= [KNL] | ||
| 2794 | Set required age in jiffies for a | ||
| 2795 | given grace period before RCU starts | ||
| 2796 | soliciting quiescent-state help from | ||
| 2797 | rcu_note_context_switch(). | ||
| 2798 | |||
| 2793 | rcutree.jiffies_till_first_fqs= [KNL] | 2799 | rcutree.jiffies_till_first_fqs= [KNL] |
| 2794 | Set delay from grace-period initialization to | 2800 | Set delay from grace-period initialization to |
| 2795 | first attempt to force quiescent states. | 2801 | first attempt to force quiescent states. |
| @@ -3526,7 +3532,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted. | |||
| 3526 | the allocated input device; If set to 0, video driver | 3532 | the allocated input device; If set to 0, video driver |
| 3527 | will only send out the event without touching backlight | 3533 | will only send out the event without touching backlight |
| 3528 | brightness level. | 3534 | brightness level. |
| 3529 | default: 0 | 3535 | default: 1 |
| 3530 | 3536 | ||
| 3531 | virtio_mmio.device= | 3537 | virtio_mmio.device= |
| 3532 | [VMMIO] Memory mapped virtio (platform) device. | 3538 | [VMMIO] Memory mapped virtio (platform) device. |
diff --git a/Documentation/laptops/00-INDEX b/Documentation/laptops/00-INDEX index d13b9a9a9e00..d399ae1fc724 100644 --- a/Documentation/laptops/00-INDEX +++ b/Documentation/laptops/00-INDEX | |||
| @@ -8,8 +8,8 @@ disk-shock-protection.txt | |||
| 8 | - information on hard disk shock protection. | 8 | - information on hard disk shock protection. |
| 9 | dslm.c | 9 | dslm.c |
| 10 | - Simple Disk Sleep Monitor program | 10 | - Simple Disk Sleep Monitor program |
| 11 | hpfall.c | 11 | freefall.c |
| 12 | - (HP) laptop accelerometer program for disk protection. | 12 | - (HP/DELL) laptop accelerometer program for disk protection. |
| 13 | laptop-mode.txt | 13 | laptop-mode.txt |
| 14 | - how to conserve battery power using laptop-mode. | 14 | - how to conserve battery power using laptop-mode. |
| 15 | sony-laptop.txt | 15 | sony-laptop.txt |
diff --git a/Documentation/laptops/hpfall.c b/Documentation/laptops/freefall.c index b85dbbac0499..aab2ff09e868 100644 --- a/Documentation/laptops/hpfall.c +++ b/Documentation/laptops/freefall.c | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | /* Disk protection for HP machines. | 1 | /* Disk protection for HP/DELL machines. |
| 2 | * | 2 | * |
| 3 | * Copyright 2008 Eric Piel | 3 | * Copyright 2008 Eric Piel |
| 4 | * Copyright 2009 Pavel Machek <pavel@ucw.cz> | 4 | * Copyright 2009 Pavel Machek <pavel@ucw.cz> |
| 5 | * Copyright 2012 Sonal Santan | ||
| 6 | * Copyright 2014 Pali Rohár <pali.rohar@gmail.com> | ||
| 5 | * | 7 | * |
| 6 | * GPLv2. | 8 | * GPLv2. |
| 7 | */ | 9 | */ |
| @@ -18,24 +20,31 @@ | |||
| 18 | #include <signal.h> | 20 | #include <signal.h> |
| 19 | #include <sys/mman.h> | 21 | #include <sys/mman.h> |
| 20 | #include <sched.h> | 22 | #include <sched.h> |
| 23 | #include <syslog.h> | ||
| 21 | 24 | ||
| 22 | char unload_heads_path[64]; | 25 | static int noled; |
| 26 | static char unload_heads_path[64]; | ||
| 27 | static char device_path[32]; | ||
| 28 | static const char app_name[] = "FREE FALL"; | ||
| 23 | 29 | ||
| 24 | int set_unload_heads_path(char *device) | 30 | static int set_unload_heads_path(char *device) |
| 25 | { | 31 | { |
| 26 | char devname[64]; | 32 | char devname[64]; |
| 27 | 33 | ||
| 28 | if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0) | 34 | if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0) |
| 29 | return -EINVAL; | 35 | return -EINVAL; |
| 30 | strncpy(devname, device + 5, sizeof(devname)); | 36 | strncpy(devname, device + 5, sizeof(devname) - 1); |
| 37 | strncpy(device_path, device, sizeof(device_path) - 1); | ||
| 31 | 38 | ||
| 32 | snprintf(unload_heads_path, sizeof(unload_heads_path) - 1, | 39 | snprintf(unload_heads_path, sizeof(unload_heads_path) - 1, |
| 33 | "/sys/block/%s/device/unload_heads", devname); | 40 | "/sys/block/%s/device/unload_heads", devname); |
| 34 | return 0; | 41 | return 0; |
| 35 | } | 42 | } |
| 36 | int valid_disk(void) | 43 | |
| 44 | static int valid_disk(void) | ||
| 37 | { | 45 | { |
| 38 | int fd = open(unload_heads_path, O_RDONLY); | 46 | int fd = open(unload_heads_path, O_RDONLY); |
| 47 | |||
| 39 | if (fd < 0) { | 48 | if (fd < 0) { |
| 40 | perror(unload_heads_path); | 49 | perror(unload_heads_path); |
| 41 | return 0; | 50 | return 0; |
| @@ -45,43 +54,54 @@ int valid_disk(void) | |||
| 45 | return 1; | 54 | return 1; |
| 46 | } | 55 | } |
| 47 | 56 | ||
| 48 | void write_int(char *path, int i) | 57 | static void write_int(char *path, int i) |
| 49 | { | 58 | { |
| 50 | char buf[1024]; | 59 | char buf[1024]; |
| 51 | int fd = open(path, O_RDWR); | 60 | int fd = open(path, O_RDWR); |
| 61 | |||
| 52 | if (fd < 0) { | 62 | if (fd < 0) { |
| 53 | perror("open"); | 63 | perror("open"); |
| 54 | exit(1); | 64 | exit(1); |
| 55 | } | 65 | } |
| 66 | |||
| 56 | sprintf(buf, "%d", i); | 67 | sprintf(buf, "%d", i); |
| 68 | |||
| 57 | if (write(fd, buf, strlen(buf)) != strlen(buf)) { | 69 | if (write(fd, buf, strlen(buf)) != strlen(buf)) { |
| 58 | perror("write"); | 70 | perror("write"); |
| 59 | exit(1); | 71 | exit(1); |
| 60 | } | 72 | } |
| 73 | |||
| 61 | close(fd); | 74 | close(fd); |
| 62 | } | 75 | } |
| 63 | 76 | ||
| 64 | void set_led(int on) | 77 | static void set_led(int on) |
| 65 | { | 78 | { |
| 79 | if (noled) | ||
| 80 | return; | ||
| 66 | write_int("/sys/class/leds/hp::hddprotect/brightness", on); | 81 | write_int("/sys/class/leds/hp::hddprotect/brightness", on); |
| 67 | } | 82 | } |
| 68 | 83 | ||
| 69 | void protect(int seconds) | 84 | static void protect(int seconds) |
| 70 | { | 85 | { |
| 86 | const char *str = (seconds == 0) ? "Unparked" : "Parked"; | ||
| 87 | |||
| 71 | write_int(unload_heads_path, seconds*1000); | 88 | write_int(unload_heads_path, seconds*1000); |
| 89 | syslog(LOG_INFO, "%s %s disk head\n", str, device_path); | ||
| 72 | } | 90 | } |
| 73 | 91 | ||
| 74 | int on_ac(void) | 92 | static int on_ac(void) |
| 75 | { | 93 | { |
| 76 | // /sys/class/power_supply/AC0/online | 94 | /* /sys/class/power_supply/AC0/online */ |
| 95 | return 1; | ||
| 77 | } | 96 | } |
| 78 | 97 | ||
| 79 | int lid_open(void) | 98 | static int lid_open(void) |
| 80 | { | 99 | { |
| 81 | // /proc/acpi/button/lid/LID/state | 100 | /* /proc/acpi/button/lid/LID/state */ |
| 101 | return 1; | ||
| 82 | } | 102 | } |
| 83 | 103 | ||
| 84 | void ignore_me(void) | 104 | static void ignore_me(int signum) |
| 85 | { | 105 | { |
| 86 | protect(0); | 106 | protect(0); |
| 87 | set_led(0); | 107 | set_led(0); |
| @@ -90,6 +110,7 @@ void ignore_me(void) | |||
| 90 | int main(int argc, char **argv) | 110 | int main(int argc, char **argv) |
| 91 | { | 111 | { |
| 92 | int fd, ret; | 112 | int fd, ret; |
| 113 | struct stat st; | ||
| 93 | struct sched_param param; | 114 | struct sched_param param; |
| 94 | 115 | ||
| 95 | if (argc == 1) | 116 | if (argc == 1) |
| @@ -111,7 +132,16 @@ int main(int argc, char **argv) | |||
| 111 | return EXIT_FAILURE; | 132 | return EXIT_FAILURE; |
| 112 | } | 133 | } |
| 113 | 134 | ||
| 114 | daemon(0, 0); | 135 | if (stat("/sys/class/leds/hp::hddprotect/brightness", &st)) |
| 136 | noled = 1; | ||
| 137 | |||
| 138 | if (daemon(0, 0) != 0) { | ||
| 139 | perror("daemon"); | ||
| 140 | return EXIT_FAILURE; | ||
| 141 | } | ||
| 142 | |||
| 143 | openlog(app_name, LOG_CONS | LOG_PID | LOG_NDELAY, LOG_LOCAL1); | ||
| 144 | |||
| 115 | param.sched_priority = sched_get_priority_max(SCHED_FIFO); | 145 | param.sched_priority = sched_get_priority_max(SCHED_FIFO); |
| 116 | sched_setscheduler(0, SCHED_FIFO, ¶m); | 146 | sched_setscheduler(0, SCHED_FIFO, ¶m); |
| 117 | mlockall(MCL_CURRENT|MCL_FUTURE); | 147 | mlockall(MCL_CURRENT|MCL_FUTURE); |
| @@ -141,6 +171,7 @@ int main(int argc, char **argv) | |||
| 141 | alarm(20); | 171 | alarm(20); |
| 142 | } | 172 | } |
| 143 | 173 | ||
| 174 | closelog(); | ||
| 144 | close(fd); | 175 | close(fd); |
| 145 | return EXIT_SUCCESS; | 176 | return EXIT_SUCCESS; |
| 146 | } | 177 | } |
diff --git a/MAINTAINERS b/MAINTAINERS index 6813d0aa5ecf..6d383ec8325a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -156,7 +156,6 @@ F: drivers/net/hamradio/6pack.c | |||
| 156 | 156 | ||
| 157 | 8169 10/100/1000 GIGABIT ETHERNET DRIVER | 157 | 8169 10/100/1000 GIGABIT ETHERNET DRIVER |
| 158 | M: Realtek linux nic maintainers <nic_swsd@realtek.com> | 158 | M: Realtek linux nic maintainers <nic_swsd@realtek.com> |
| 159 | M: Francois Romieu <romieu@fr.zoreil.com> | ||
| 160 | L: netdev@vger.kernel.org | 159 | L: netdev@vger.kernel.org |
| 161 | S: Maintained | 160 | S: Maintained |
| 162 | F: drivers/net/ethernet/realtek/r8169.c | 161 | F: drivers/net/ethernet/realtek/r8169.c |
| @@ -1314,6 +1313,20 @@ W: http://oss.renesas.com | |||
| 1314 | Q: http://patchwork.kernel.org/project/linux-sh/list/ | 1313 | Q: http://patchwork.kernel.org/project/linux-sh/list/ |
| 1315 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git next | 1314 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/horms/renesas.git next |
| 1316 | S: Supported | 1315 | S: Supported |
| 1316 | F: arch/arm/boot/dts/emev2* | ||
| 1317 | F: arch/arm/boot/dts/r7s* | ||
| 1318 | F: arch/arm/boot/dts/r8a* | ||
| 1319 | F: arch/arm/boot/dts/sh* | ||
| 1320 | F: arch/arm/configs/ape6evm_defconfig | ||
| 1321 | F: arch/arm/configs/armadillo800eva_defconfig | ||
| 1322 | F: arch/arm/configs/bockw_defconfig | ||
| 1323 | F: arch/arm/configs/genmai_defconfig | ||
| 1324 | F: arch/arm/configs/koelsch_defconfig | ||
| 1325 | F: arch/arm/configs/kzm9g_defconfig | ||
| 1326 | F: arch/arm/configs/lager_defconfig | ||
| 1327 | F: arch/arm/configs/mackerel_defconfig | ||
| 1328 | F: arch/arm/configs/marzen_defconfig | ||
| 1329 | F: arch/arm/configs/shmobile_defconfig | ||
| 1317 | F: arch/arm/mach-shmobile/ | 1330 | F: arch/arm/mach-shmobile/ |
| 1318 | F: drivers/sh/ | 1331 | F: drivers/sh/ |
| 1319 | 1332 | ||
| @@ -4497,8 +4510,7 @@ S: Supported | |||
| 4497 | F: drivers/idle/i7300_idle.c | 4510 | F: drivers/idle/i7300_idle.c |
| 4498 | 4511 | ||
| 4499 | IEEE 802.15.4 SUBSYSTEM | 4512 | IEEE 802.15.4 SUBSYSTEM |
| 4500 | M: Alexander Smirnov <alex.bluesman.smirnov@gmail.com> | 4513 | M: Alexander Aring <alex.aring@gmail.com> |
| 4501 | M: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | ||
| 4502 | L: linux-zigbee-devel@lists.sourceforge.net (moderated for non-subscribers) | 4514 | L: linux-zigbee-devel@lists.sourceforge.net (moderated for non-subscribers) |
| 4503 | W: http://apps.sourceforge.net/trac/linux-zigbee | 4515 | W: http://apps.sourceforge.net/trac/linux-zigbee |
| 4504 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.git | 4516 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/lowpan/lowpan.git |
| @@ -6787,7 +6799,7 @@ F: arch/x86/kernel/quirks.c | |||
| 6787 | 6799 | ||
| 6788 | PCI DRIVER FOR IMX6 | 6800 | PCI DRIVER FOR IMX6 |
| 6789 | M: Richard Zhu <r65037@freescale.com> | 6801 | M: Richard Zhu <r65037@freescale.com> |
| 6790 | M: Shawn Guo <shawn.guo@linaro.org> | 6802 | M: Shawn Guo <shawn.guo@freescale.com> |
| 6791 | L: linux-pci@vger.kernel.org | 6803 | L: linux-pci@vger.kernel.org |
| 6792 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | 6804 | L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) |
| 6793 | S: Maintained | 6805 | S: Maintained |
| @@ -6944,6 +6956,12 @@ L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) | |||
| 6944 | S: Maintained | 6956 | S: Maintained |
| 6945 | F: drivers/pinctrl/pinctrl-at91.c | 6957 | F: drivers/pinctrl/pinctrl-at91.c |
| 6946 | 6958 | ||
| 6959 | PIN CONTROLLER - RENESAS | ||
| 6960 | M: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
| 6961 | L: linux-sh@vger.kernel.org | ||
| 6962 | S: Maintained | ||
| 6963 | F: drivers/pinctrl/sh-pfc/ | ||
| 6964 | |||
| 6947 | PIN CONTROLLER - SAMSUNG | 6965 | PIN CONTROLLER - SAMSUNG |
| 6948 | M: Tomasz Figa <t.figa@samsung.com> | 6966 | M: Tomasz Figa <t.figa@samsung.com> |
| 6949 | M: Thomas Abraham <thomas.abraham@linaro.org> | 6967 | M: Thomas Abraham <thomas.abraham@linaro.org> |
| @@ -7406,7 +7424,7 @@ S: Orphan | |||
| 7406 | F: drivers/net/wireless/ray* | 7424 | F: drivers/net/wireless/ray* |
| 7407 | 7425 | ||
| 7408 | RCUTORTURE MODULE | 7426 | RCUTORTURE MODULE |
| 7409 | M: Josh Triplett <josh@freedesktop.org> | 7427 | M: Josh Triplett <josh@joshtriplett.org> |
| 7410 | M: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> | 7428 | M: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com> |
| 7411 | L: linux-kernel@vger.kernel.org | 7429 | L: linux-kernel@vger.kernel.org |
| 7412 | S: Supported | 7430 | S: Supported |
| @@ -7461,6 +7479,13 @@ F: drivers/rtc/ | |||
| 7461 | F: include/linux/rtc.h | 7479 | F: include/linux/rtc.h |
| 7462 | F: include/uapi/linux/rtc.h | 7480 | F: include/uapi/linux/rtc.h |
| 7463 | 7481 | ||
| 7482 | REALTEK AUDIO CODECS | ||
| 7483 | M: Bard Liao <bardliao@realtek.com> | ||
| 7484 | M: Oder Chiou <oder_chiou@realtek.com> | ||
| 7485 | S: Maintained | ||
| 7486 | F: sound/soc/codecs/rt* | ||
| 7487 | F: include/sound/rt*.h | ||
| 7488 | |||
| 7464 | REISERFS FILE SYSTEM | 7489 | REISERFS FILE SYSTEM |
| 7465 | L: reiserfs-devel@vger.kernel.org | 7490 | L: reiserfs-devel@vger.kernel.org |
| 7466 | S: Supported | 7491 | S: Supported |
| @@ -8007,6 +8032,16 @@ F: drivers/ata/ | |||
| 8007 | F: include/linux/ata.h | 8032 | F: include/linux/ata.h |
| 8008 | F: include/linux/libata.h | 8033 | F: include/linux/libata.h |
| 8009 | 8034 | ||
| 8035 | SERIAL ATA AHCI PLATFORM devices support | ||
| 8036 | M: Hans de Goede <hdegoede@redhat.com> | ||
| 8037 | M: Tejun Heo <tj@kernel.org> | ||
| 8038 | L: linux-ide@vger.kernel.org | ||
| 8039 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata.git | ||
| 8040 | S: Supported | ||
| 8041 | F: drivers/ata/ahci_platform.c | ||
| 8042 | F: drivers/ata/libahci_platform.c | ||
| 8043 | F: include/linux/ahci_platform.h | ||
| 8044 | |||
| 8010 | SERVER ENGINES 10Gbps iSCSI - BladeEngine 2 DRIVER | 8045 | SERVER ENGINES 10Gbps iSCSI - BladeEngine 2 DRIVER |
| 8011 | M: Jayamohan Kallickal <jayamohan.kallickal@emulex.com> | 8046 | M: Jayamohan Kallickal <jayamohan.kallickal@emulex.com> |
| 8012 | L: linux-scsi@vger.kernel.org | 8047 | L: linux-scsi@vger.kernel.org |
| @@ -8894,7 +8929,7 @@ M: Stephen Warren <swarren@wwwdotorg.org> | |||
| 8894 | M: Thierry Reding <thierry.reding@gmail.com> | 8929 | M: Thierry Reding <thierry.reding@gmail.com> |
| 8895 | L: linux-tegra@vger.kernel.org | 8930 | L: linux-tegra@vger.kernel.org |
| 8896 | Q: http://patchwork.ozlabs.org/project/linux-tegra/list/ | 8931 | Q: http://patchwork.ozlabs.org/project/linux-tegra/list/ |
| 8897 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/swarren/linux-tegra.git | 8932 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git |
| 8898 | S: Supported | 8933 | S: Supported |
| 8899 | N: [^a-z]tegra | 8934 | N: [^a-z]tegra |
| 8900 | 8935 | ||
| @@ -8984,7 +9019,7 @@ F: drivers/media/radio/radio-raremono.c | |||
| 8984 | 9019 | ||
| 8985 | THERMAL | 9020 | THERMAL |
| 8986 | M: Zhang Rui <rui.zhang@intel.com> | 9021 | M: Zhang Rui <rui.zhang@intel.com> |
| 8987 | M: Eduardo Valentin <eduardo.valentin@ti.com> | 9022 | M: Eduardo Valentin <edubezval@gmail.com> |
| 8988 | L: linux-pm@vger.kernel.org | 9023 | L: linux-pm@vger.kernel.org |
| 8989 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git | 9024 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux.git |
| 8990 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git | 9025 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux-soc-thermal.git |
| @@ -9011,7 +9046,7 @@ S: Maintained | |||
| 9011 | F: drivers/platform/x86/thinkpad_acpi.c | 9046 | F: drivers/platform/x86/thinkpad_acpi.c |
| 9012 | 9047 | ||
| 9013 | TI BANDGAP AND THERMAL DRIVER | 9048 | TI BANDGAP AND THERMAL DRIVER |
| 9014 | M: Eduardo Valentin <eduardo.valentin@ti.com> | 9049 | M: Eduardo Valentin <edubezval@gmail.com> |
| 9015 | L: linux-pm@vger.kernel.org | 9050 | L: linux-pm@vger.kernel.org |
| 9016 | S: Supported | 9051 | S: Supported |
| 9017 | F: drivers/thermal/ti-soc-thermal/ | 9052 | F: drivers/thermal/ti-soc-thermal/ |
| @@ -1,7 +1,7 @@ | |||
| 1 | VERSION = 3 | 1 | VERSION = 3 |
| 2 | PATCHLEVEL = 16 | 2 | PATCHLEVEL = 16 |
| 3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
| 4 | EXTRAVERSION = -rc4 | 4 | EXTRAVERSION = |
| 5 | NAME = Shuffling Zombie Juror | 5 | NAME = Shuffling Zombie Juror |
| 6 | 6 | ||
| 7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
| @@ -41,6 +41,29 @@ unexport GREP_OPTIONS | |||
| 41 | # descending is started. They are now explicitly listed as the | 41 | # descending is started. They are now explicitly listed as the |
| 42 | # prepare rule. | 42 | # prepare rule. |
| 43 | 43 | ||
| 44 | # Beautify output | ||
| 45 | # --------------------------------------------------------------------------- | ||
| 46 | # | ||
| 47 | # Normally, we echo the whole command before executing it. By making | ||
| 48 | # that echo $($(quiet)$(cmd)), we now have the possibility to set | ||
| 49 | # $(quiet) to choose other forms of output instead, e.g. | ||
| 50 | # | ||
| 51 | # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ | ||
| 52 | # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | ||
| 53 | # | ||
| 54 | # If $(quiet) is empty, the whole command will be printed. | ||
| 55 | # If it is set to "quiet_", only the short version will be printed. | ||
| 56 | # If it is set to "silent_", nothing will be printed at all, since | ||
| 57 | # the variable $(silent_cmd_cc_o_c) doesn't exist. | ||
| 58 | # | ||
| 59 | # A simple variant is to prefix commands with $(Q) - that's useful | ||
| 60 | # for commands that shall be hidden in non-verbose mode. | ||
| 61 | # | ||
| 62 | # $(Q)ln $@ :< | ||
| 63 | # | ||
| 64 | # If KBUILD_VERBOSE equals 0 then the above command will be hidden. | ||
| 65 | # If KBUILD_VERBOSE equals 1 then the above command is displayed. | ||
| 66 | # | ||
| 44 | # To put more focus on warnings, be less verbose as default | 67 | # To put more focus on warnings, be less verbose as default |
| 45 | # Use 'make V=1' to see the full commands | 68 | # Use 'make V=1' to see the full commands |
| 46 | 69 | ||
| @@ -51,6 +74,29 @@ ifndef KBUILD_VERBOSE | |||
| 51 | KBUILD_VERBOSE = 0 | 74 | KBUILD_VERBOSE = 0 |
| 52 | endif | 75 | endif |
| 53 | 76 | ||
| 77 | ifeq ($(KBUILD_VERBOSE),1) | ||
| 78 | quiet = | ||
| 79 | Q = | ||
| 80 | else | ||
| 81 | quiet=quiet_ | ||
| 82 | Q = @ | ||
| 83 | endif | ||
| 84 | |||
| 85 | # If the user is running make -s (silent mode), suppress echoing of | ||
| 86 | # commands | ||
| 87 | |||
| 88 | ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 | ||
| 89 | ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) | ||
| 90 | quiet=silent_ | ||
| 91 | endif | ||
| 92 | else # make-3.8x | ||
| 93 | ifneq ($(filter s% -s%,$(MAKEFLAGS)),) | ||
| 94 | quiet=silent_ | ||
| 95 | endif | ||
| 96 | endif | ||
| 97 | |||
| 98 | export quiet Q KBUILD_VERBOSE | ||
| 99 | |||
| 54 | # Call a source code checker (by default, "sparse") as part of the | 100 | # Call a source code checker (by default, "sparse") as part of the |
| 55 | # C compilation. | 101 | # C compilation. |
| 56 | # | 102 | # |
| @@ -128,8 +174,11 @@ $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make | |||
| 128 | 174 | ||
| 129 | # Fake the "Entering directory" message once, so that IDEs/editors are | 175 | # Fake the "Entering directory" message once, so that IDEs/editors are |
| 130 | # able to understand relative filenames. | 176 | # able to understand relative filenames. |
| 177 | echodir := @echo | ||
| 178 | quiet_echodir := @echo | ||
| 179 | silent_echodir := @: | ||
| 131 | sub-make: FORCE | 180 | sub-make: FORCE |
| 132 | @echo "make[1]: Entering directory \`$(KBUILD_OUTPUT)'" | 181 | $($(quiet)echodir) "make[1]: Entering directory \`$(KBUILD_OUTPUT)'" |
| 133 | $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ | 182 | $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ |
| 134 | KBUILD_SRC=$(CURDIR) \ | 183 | KBUILD_SRC=$(CURDIR) \ |
| 135 | KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ | 184 | KBUILD_EXTMOD="$(KBUILD_EXTMOD)" -f $(CURDIR)/Makefile \ |
| @@ -292,52 +341,6 @@ endif | |||
| 292 | export KBUILD_MODULES KBUILD_BUILTIN | 341 | export KBUILD_MODULES KBUILD_BUILTIN |
| 293 | export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD | 342 | export KBUILD_CHECKSRC KBUILD_SRC KBUILD_EXTMOD |
| 294 | 343 | ||
| 295 | # Beautify output | ||
| 296 | # --------------------------------------------------------------------------- | ||
| 297 | # | ||
| 298 | # Normally, we echo the whole command before executing it. By making | ||
| 299 | # that echo $($(quiet)$(cmd)), we now have the possibility to set | ||
| 300 | # $(quiet) to choose other forms of output instead, e.g. | ||
| 301 | # | ||
| 302 | # quiet_cmd_cc_o_c = Compiling $(RELDIR)/$@ | ||
| 303 | # cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | ||
| 304 | # | ||
| 305 | # If $(quiet) is empty, the whole command will be printed. | ||
| 306 | # If it is set to "quiet_", only the short version will be printed. | ||
| 307 | # If it is set to "silent_", nothing will be printed at all, since | ||
| 308 | # the variable $(silent_cmd_cc_o_c) doesn't exist. | ||
| 309 | # | ||
| 310 | # A simple variant is to prefix commands with $(Q) - that's useful | ||
| 311 | # for commands that shall be hidden in non-verbose mode. | ||
| 312 | # | ||
| 313 | # $(Q)ln $@ :< | ||
| 314 | # | ||
| 315 | # If KBUILD_VERBOSE equals 0 then the above command will be hidden. | ||
| 316 | # If KBUILD_VERBOSE equals 1 then the above command is displayed. | ||
| 317 | |||
| 318 | ifeq ($(KBUILD_VERBOSE),1) | ||
| 319 | quiet = | ||
| 320 | Q = | ||
| 321 | else | ||
| 322 | quiet=quiet_ | ||
| 323 | Q = @ | ||
| 324 | endif | ||
| 325 | |||
| 326 | # If the user is running make -s (silent mode), suppress echoing of | ||
| 327 | # commands | ||
| 328 | |||
| 329 | ifneq ($(filter 4.%,$(MAKE_VERSION)),) # make-4 | ||
| 330 | ifneq ($(filter %s ,$(firstword x$(MAKEFLAGS))),) | ||
| 331 | quiet=silent_ | ||
| 332 | endif | ||
| 333 | else # make-3.8x | ||
| 334 | ifneq ($(filter s% -s%,$(MAKEFLAGS)),) | ||
| 335 | quiet=silent_ | ||
| 336 | endif | ||
| 337 | endif | ||
| 338 | |||
| 339 | export quiet Q KBUILD_VERBOSE | ||
| 340 | |||
| 341 | ifneq ($(CC),) | 344 | ifneq ($(CC),) |
| 342 | ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) | 345 | ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang version"), 1) |
| 343 | COMPILER := clang | 346 | COMPILER := clang |
| @@ -685,6 +688,8 @@ KBUILD_CFLAGS += -fomit-frame-pointer | |||
| 685 | endif | 688 | endif |
| 686 | endif | 689 | endif |
| 687 | 690 | ||
| 691 | KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) | ||
| 692 | |||
| 688 | ifdef CONFIG_DEBUG_INFO | 693 | ifdef CONFIG_DEBUG_INFO |
| 689 | KBUILD_CFLAGS += -g | 694 | KBUILD_CFLAGS += -g |
| 690 | KBUILD_AFLAGS += -Wa,-gdwarf-2 | 695 | KBUILD_AFLAGS += -Wa,-gdwarf-2 |
| @@ -1173,7 +1178,7 @@ distclean: mrproper | |||
| 1173 | # Packaging of the kernel to various formats | 1178 | # Packaging of the kernel to various formats |
| 1174 | # --------------------------------------------------------------------------- | 1179 | # --------------------------------------------------------------------------- |
| 1175 | # rpm target kept for backward compatibility | 1180 | # rpm target kept for backward compatibility |
| 1176 | package-dir := $(srctree)/scripts/package | 1181 | package-dir := scripts/package |
| 1177 | 1182 | ||
| 1178 | %src-pkg: FORCE | 1183 | %src-pkg: FORCE |
| 1179 | $(Q)$(MAKE) $(build)=$(package-dir) $@ | 1184 | $(Q)$(MAKE) $(build)=$(package-dir) $@ |
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 245058b3b0ef..290f02ee0157 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig | |||
| @@ -6,6 +6,7 @@ config ARM | |||
| 6 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST | 6 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST |
| 7 | select ARCH_HAVE_CUSTOM_GPIO_H | 7 | select ARCH_HAVE_CUSTOM_GPIO_H |
| 8 | select ARCH_MIGHT_HAVE_PC_PARPORT | 8 | select ARCH_MIGHT_HAVE_PC_PARPORT |
| 9 | select ARCH_SUPPORTS_ATOMIC_RMW | ||
| 9 | select ARCH_USE_BUILTIN_BSWAP | 10 | select ARCH_USE_BUILTIN_BSWAP |
| 10 | select ARCH_USE_CMPXCHG_LOCKREF | 11 | select ARCH_USE_CMPXCHG_LOCKREF |
| 11 | select ARCH_WANT_IPC_PARSE_VERSION | 12 | select ARCH_WANT_IPC_PARSE_VERSION |
| @@ -312,7 +313,7 @@ config ARCH_MULTIPLATFORM | |||
| 312 | config ARCH_INTEGRATOR | 313 | config ARCH_INTEGRATOR |
| 313 | bool "ARM Ltd. Integrator family" | 314 | bool "ARM Ltd. Integrator family" |
| 314 | select ARM_AMBA | 315 | select ARM_AMBA |
| 315 | select ARM_PATCH_PHYS_VIRT | 316 | select ARM_PATCH_PHYS_VIRT if MMU |
| 316 | select AUTO_ZRELADDR | 317 | select AUTO_ZRELADDR |
| 317 | select COMMON_CLK | 318 | select COMMON_CLK |
| 318 | select COMMON_CLK_VERSATILE | 319 | select COMMON_CLK_VERSATILE |
| @@ -658,7 +659,7 @@ config ARCH_MSM | |||
| 658 | config ARCH_SHMOBILE_LEGACY | 659 | config ARCH_SHMOBILE_LEGACY |
| 659 | bool "Renesas ARM SoCs (non-multiplatform)" | 660 | bool "Renesas ARM SoCs (non-multiplatform)" |
| 660 | select ARCH_SHMOBILE | 661 | select ARCH_SHMOBILE |
| 661 | select ARM_PATCH_PHYS_VIRT | 662 | select ARM_PATCH_PHYS_VIRT if MMU |
| 662 | select CLKDEV_LOOKUP | 663 | select CLKDEV_LOOKUP |
| 663 | select GENERIC_CLOCKEVENTS | 664 | select GENERIC_CLOCKEVENTS |
| 664 | select HAVE_ARM_SCU if SMP | 665 | select HAVE_ARM_SCU if SMP |
diff --git a/arch/arm/boot/dts/am335x-evm.dts b/arch/arm/boot/dts/am335x-evm.dts index ecb267767cf5..e2156a583de7 100644 --- a/arch/arm/boot/dts/am335x-evm.dts +++ b/arch/arm/boot/dts/am335x-evm.dts | |||
| @@ -529,8 +529,8 @@ | |||
| 529 | serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */ | 529 | serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */ |
| 530 | 0 0 1 2 | 530 | 0 0 1 2 |
| 531 | >; | 531 | >; |
| 532 | tx-num-evt = <1>; | 532 | tx-num-evt = <32>; |
| 533 | rx-num-evt = <1>; | 533 | rx-num-evt = <32>; |
| 534 | }; | 534 | }; |
| 535 | 535 | ||
| 536 | &tps { | 536 | &tps { |
diff --git a/arch/arm/boot/dts/am335x-evmsk.dts b/arch/arm/boot/dts/am335x-evmsk.dts index ab9a34ce524c..80a3b215e7d6 100644 --- a/arch/arm/boot/dts/am335x-evmsk.dts +++ b/arch/arm/boot/dts/am335x-evmsk.dts | |||
| @@ -560,8 +560,8 @@ | |||
| 560 | serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */ | 560 | serial-dir = < /* 0: INACTIVE, 1: TX, 2: RX */ |
| 561 | 0 0 1 2 | 561 | 0 0 1 2 |
| 562 | >; | 562 | >; |
| 563 | tx-num-evt = <1>; | 563 | tx-num-evt = <32>; |
| 564 | rx-num-evt = <1>; | 564 | rx-num-evt = <32>; |
| 565 | }; | 565 | }; |
| 566 | 566 | ||
| 567 | &tscadc { | 567 | &tscadc { |
diff --git a/arch/arm/boot/dts/am335x-igep0033.dtsi b/arch/arm/boot/dts/am335x-igep0033.dtsi index 8a0a72dc7dd7..a1a0cc5eb35c 100644 --- a/arch/arm/boot/dts/am335x-igep0033.dtsi +++ b/arch/arm/boot/dts/am335x-igep0033.dtsi | |||
| @@ -105,10 +105,16 @@ | |||
| 105 | 105 | ||
| 106 | &cpsw_emac0 { | 106 | &cpsw_emac0 { |
| 107 | phy_id = <&davinci_mdio>, <0>; | 107 | phy_id = <&davinci_mdio>, <0>; |
| 108 | phy-mode = "rmii"; | ||
| 108 | }; | 109 | }; |
| 109 | 110 | ||
| 110 | &cpsw_emac1 { | 111 | &cpsw_emac1 { |
| 111 | phy_id = <&davinci_mdio>, <1>; | 112 | phy_id = <&davinci_mdio>, <1>; |
| 113 | phy-mode = "rmii"; | ||
| 114 | }; | ||
| 115 | |||
| 116 | &phy_sel { | ||
| 117 | rmii-clock-ext; | ||
| 112 | }; | 118 | }; |
| 113 | 119 | ||
| 114 | &elm { | 120 | &elm { |
diff --git a/arch/arm/boot/dts/at91sam9n12.dtsi b/arch/arm/boot/dts/at91sam9n12.dtsi index 287795985e32..b84bac5bada4 100644 --- a/arch/arm/boot/dts/at91sam9n12.dtsi +++ b/arch/arm/boot/dts/at91sam9n12.dtsi | |||
| @@ -925,7 +925,7 @@ | |||
| 925 | compatible = "atmel,at91rm9200-ohci", "usb-ohci"; | 925 | compatible = "atmel,at91rm9200-ohci", "usb-ohci"; |
| 926 | reg = <0x00500000 0x00100000>; | 926 | reg = <0x00500000 0x00100000>; |
| 927 | interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>; | 927 | interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>; |
| 928 | clocks = <&usb>, <&uhphs_clk>, <&udphs_clk>, | 928 | clocks = <&usb>, <&uhphs_clk>, <&uhphs_clk>, |
| 929 | <&uhpck>; | 929 | <&uhpck>; |
| 930 | clock-names = "usb_clk", "ohci_clk", "hclk", "uhpck"; | 930 | clock-names = "usb_clk", "ohci_clk", "hclk", "uhpck"; |
| 931 | status = "disabled"; | 931 | status = "disabled"; |
diff --git a/arch/arm/boot/dts/at91sam9x5.dtsi b/arch/arm/boot/dts/at91sam9x5.dtsi index d6133f497207..2c0d6ea3ab41 100644 --- a/arch/arm/boot/dts/at91sam9x5.dtsi +++ b/arch/arm/boot/dts/at91sam9x5.dtsi | |||
| @@ -1045,6 +1045,8 @@ | |||
| 1045 | reg = <0x00500000 0x80000 | 1045 | reg = <0x00500000 0x80000 |
| 1046 | 0xf803c000 0x400>; | 1046 | 0xf803c000 0x400>; |
| 1047 | interrupts = <23 IRQ_TYPE_LEVEL_HIGH 0>; | 1047 | interrupts = <23 IRQ_TYPE_LEVEL_HIGH 0>; |
| 1048 | clocks = <&usb>, <&udphs_clk>; | ||
| 1049 | clock-names = "hclk", "pclk"; | ||
| 1048 | status = "disabled"; | 1050 | status = "disabled"; |
| 1049 | 1051 | ||
| 1050 | ep0 { | 1052 | ep0 { |
| @@ -1122,6 +1124,7 @@ | |||
| 1122 | compatible = "atmel,at91sam9rl-pwm"; | 1124 | compatible = "atmel,at91sam9rl-pwm"; |
| 1123 | reg = <0xf8034000 0x300>; | 1125 | reg = <0xf8034000 0x300>; |
| 1124 | interrupts = <18 IRQ_TYPE_LEVEL_HIGH 4>; | 1126 | interrupts = <18 IRQ_TYPE_LEVEL_HIGH 4>; |
| 1127 | clocks = <&pwm_clk>; | ||
| 1125 | #pwm-cells = <3>; | 1128 | #pwm-cells = <3>; |
| 1126 | status = "disabled"; | 1129 | status = "disabled"; |
| 1127 | }; | 1130 | }; |
| @@ -1153,8 +1156,7 @@ | |||
| 1153 | compatible = "atmel,at91rm9200-ohci", "usb-ohci"; | 1156 | compatible = "atmel,at91rm9200-ohci", "usb-ohci"; |
| 1154 | reg = <0x00600000 0x100000>; | 1157 | reg = <0x00600000 0x100000>; |
| 1155 | interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>; | 1158 | interrupts = <22 IRQ_TYPE_LEVEL_HIGH 2>; |
| 1156 | clocks = <&usb>, <&uhphs_clk>, <&udphs_clk>, | 1159 | clocks = <&usb>, <&uhphs_clk>, <&uhphs_clk>, <&uhpck>; |
| 1157 | <&uhpck>; | ||
| 1158 | clock-names = "usb_clk", "ohci_clk", "hclk", "uhpck"; | 1160 | clock-names = "usb_clk", "ohci_clk", "hclk", "uhpck"; |
| 1159 | status = "disabled"; | 1161 | status = "disabled"; |
| 1160 | }; | 1162 | }; |
diff --git a/arch/arm/boot/dts/dra7-evm.dts b/arch/arm/boot/dts/dra7-evm.dts index 4adc28039c30..83089540e324 100644 --- a/arch/arm/boot/dts/dra7-evm.dts +++ b/arch/arm/boot/dts/dra7-evm.dts | |||
| @@ -240,6 +240,7 @@ | |||
| 240 | regulator-name = "ldo3"; | 240 | regulator-name = "ldo3"; |
| 241 | regulator-min-microvolt = <1800000>; | 241 | regulator-min-microvolt = <1800000>; |
| 242 | regulator-max-microvolt = <1800000>; | 242 | regulator-max-microvolt = <1800000>; |
| 243 | regulator-always-on; | ||
| 243 | regulator-boot-on; | 244 | regulator-boot-on; |
| 244 | }; | 245 | }; |
| 245 | 246 | ||
diff --git a/arch/arm/boot/dts/dra7xx-clocks.dtsi b/arch/arm/boot/dts/dra7xx-clocks.dtsi index c90c76de84d6..dc7a292fe939 100644 --- a/arch/arm/boot/dts/dra7xx-clocks.dtsi +++ b/arch/arm/boot/dts/dra7xx-clocks.dtsi | |||
| @@ -673,10 +673,12 @@ | |||
| 673 | 673 | ||
| 674 | l3_iclk_div: l3_iclk_div { | 674 | l3_iclk_div: l3_iclk_div { |
| 675 | #clock-cells = <0>; | 675 | #clock-cells = <0>; |
| 676 | compatible = "fixed-factor-clock"; | 676 | compatible = "ti,divider-clock"; |
| 677 | ti,max-div = <2>; | ||
| 678 | ti,bit-shift = <4>; | ||
| 679 | reg = <0x0100>; | ||
| 677 | clocks = <&dpll_core_h12x2_ck>; | 680 | clocks = <&dpll_core_h12x2_ck>; |
| 678 | clock-mult = <1>; | 681 | ti,index-power-of-two; |
| 679 | clock-div = <1>; | ||
| 680 | }; | 682 | }; |
| 681 | 683 | ||
| 682 | l4_root_clk_div: l4_root_clk_div { | 684 | l4_root_clk_div: l4_root_clk_div { |
| @@ -684,7 +686,7 @@ | |||
| 684 | compatible = "fixed-factor-clock"; | 686 | compatible = "fixed-factor-clock"; |
| 685 | clocks = <&l3_iclk_div>; | 687 | clocks = <&l3_iclk_div>; |
| 686 | clock-mult = <1>; | 688 | clock-mult = <1>; |
| 687 | clock-div = <1>; | 689 | clock-div = <2>; |
| 688 | }; | 690 | }; |
| 689 | 691 | ||
| 690 | video1_clk2_div: video1_clk2_div { | 692 | video1_clk2_div: video1_clk2_div { |
diff --git a/arch/arm/boot/dts/exynos4.dtsi b/arch/arm/boot/dts/exynos4.dtsi index fbaf426d2daa..17b22e9cc2aa 100644 --- a/arch/arm/boot/dts/exynos4.dtsi +++ b/arch/arm/boot/dts/exynos4.dtsi | |||
| @@ -554,7 +554,7 @@ | |||
| 554 | interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>; | 554 | interrupts = <0 37 0>, <0 38 0>, <0 39 0>, <0 40 0>, <0 41 0>; |
| 555 | clocks = <&clock CLK_PWM>; | 555 | clocks = <&clock CLK_PWM>; |
| 556 | clock-names = "timers"; | 556 | clock-names = "timers"; |
| 557 | #pwm-cells = <2>; | 557 | #pwm-cells = <3>; |
| 558 | status = "disabled"; | 558 | status = "disabled"; |
| 559 | }; | 559 | }; |
| 560 | 560 | ||
diff --git a/arch/arm/boot/dts/exynos5420.dtsi b/arch/arm/boot/dts/exynos5420.dtsi index e38532271ef9..15957227ffda 100644 --- a/arch/arm/boot/dts/exynos5420.dtsi +++ b/arch/arm/boot/dts/exynos5420.dtsi | |||
| @@ -167,7 +167,7 @@ | |||
| 167 | compatible = "samsung,exynos5420-audss-clock"; | 167 | compatible = "samsung,exynos5420-audss-clock"; |
| 168 | reg = <0x03810000 0x0C>; | 168 | reg = <0x03810000 0x0C>; |
| 169 | #clock-cells = <1>; | 169 | #clock-cells = <1>; |
| 170 | clocks = <&clock CLK_FIN_PLL>, <&clock CLK_FOUT_EPLL>, | 170 | clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MAU_EPLL>, |
| 171 | <&clock CLK_SCLK_MAUDIO0>, <&clock CLK_SCLK_MAUPCM0>; | 171 | <&clock CLK_SCLK_MAUDIO0>, <&clock CLK_SCLK_MAUPCM0>; |
| 172 | clock-names = "pll_ref", "pll_in", "sclk_audio", "sclk_pcm_in"; | 172 | clock-names = "pll_ref", "pll_in", "sclk_audio", "sclk_pcm_in"; |
| 173 | }; | 173 | }; |
| @@ -260,6 +260,9 @@ | |||
| 260 | mfc_pd: power-domain@10044060 { | 260 | mfc_pd: power-domain@10044060 { |
| 261 | compatible = "samsung,exynos4210-pd"; | 261 | compatible = "samsung,exynos4210-pd"; |
| 262 | reg = <0x10044060 0x20>; | 262 | reg = <0x10044060 0x20>; |
| 263 | clocks = <&clock CLK_FIN_PLL>, <&clock CLK_MOUT_SW_ACLK333>, | ||
| 264 | <&clock CLK_MOUT_USER_ACLK333>; | ||
| 265 | clock-names = "oscclk", "pclk0", "clk0"; | ||
| 263 | }; | 266 | }; |
| 264 | 267 | ||
| 265 | disp_pd: power-domain@100440C0 { | 268 | disp_pd: power-domain@100440C0 { |
diff --git a/arch/arm/boot/dts/hi3620.dtsi b/arch/arm/boot/dts/hi3620.dtsi index ab1116d086be..83a5b8685bd9 100644 --- a/arch/arm/boot/dts/hi3620.dtsi +++ b/arch/arm/boot/dts/hi3620.dtsi | |||
| @@ -73,7 +73,7 @@ | |||
| 73 | 73 | ||
| 74 | L2: l2-cache { | 74 | L2: l2-cache { |
| 75 | compatible = "arm,pl310-cache"; | 75 | compatible = "arm,pl310-cache"; |
| 76 | reg = <0xfc10000 0x100000>; | 76 | reg = <0x100000 0x100000>; |
| 77 | interrupts = <0 15 4>; | 77 | interrupts = <0 15 4>; |
| 78 | cache-unified; | 78 | cache-unified; |
| 79 | cache-level = <2>; | 79 | cache-level = <2>; |
diff --git a/arch/arm/boot/dts/omap3-n900.dts b/arch/arm/boot/dts/omap3-n900.dts index 1fe45d1f75ec..b15f1a77d684 100644 --- a/arch/arm/boot/dts/omap3-n900.dts +++ b/arch/arm/boot/dts/omap3-n900.dts | |||
| @@ -353,7 +353,7 @@ | |||
| 353 | }; | 353 | }; |
| 354 | 354 | ||
| 355 | twl_power: power { | 355 | twl_power: power { |
| 356 | compatible = "ti,twl4030-power-n900", "ti,twl4030-power-idle-osc-off"; | 356 | compatible = "ti,twl4030-power-n900"; |
| 357 | ti,use_poweroff; | 357 | ti,use_poweroff; |
| 358 | }; | 358 | }; |
| 359 | }; | 359 | }; |
diff --git a/arch/arm/boot/dts/r8a7791.dtsi b/arch/arm/boot/dts/r8a7791.dtsi index 8d7ffaeff6e0..79f68acfd5d4 100644 --- a/arch/arm/boot/dts/r8a7791.dtsi +++ b/arch/arm/boot/dts/r8a7791.dtsi | |||
| @@ -540,9 +540,9 @@ | |||
| 540 | #clock-cells = <0>; | 540 | #clock-cells = <0>; |
| 541 | clock-output-names = "sd1"; | 541 | clock-output-names = "sd1"; |
| 542 | }; | 542 | }; |
| 543 | sd2_clk: sd3_clk@e615007c { | 543 | sd2_clk: sd3_clk@e615026c { |
| 544 | compatible = "renesas,r8a7791-div6-clock", "renesas,cpg-div6-clock"; | 544 | compatible = "renesas,r8a7791-div6-clock", "renesas,cpg-div6-clock"; |
| 545 | reg = <0 0xe615007c 0 4>; | 545 | reg = <0 0xe615026c 0 4>; |
| 546 | clocks = <&pll1_div2_clk>; | 546 | clocks = <&pll1_div2_clk>; |
| 547 | #clock-cells = <0>; | 547 | #clock-cells = <0>; |
| 548 | clock-output-names = "sd2"; | 548 | clock-output-names = "sd2"; |
diff --git a/arch/arm/boot/dts/ste-nomadik-s8815.dts b/arch/arm/boot/dts/ste-nomadik-s8815.dts index f557feb997f4..90d8b6c7a205 100644 --- a/arch/arm/boot/dts/ste-nomadik-s8815.dts +++ b/arch/arm/boot/dts/ste-nomadik-s8815.dts | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | /dts-v1/; | 6 | /dts-v1/; |
| 7 | /include/ "ste-nomadik-stn8815.dtsi" | 7 | #include "ste-nomadik-stn8815.dtsi" |
| 8 | 8 | ||
| 9 | / { | 9 | / { |
| 10 | model = "Calao Systems USB-S8815"; | 10 | model = "Calao Systems USB-S8815"; |
diff --git a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi index d316c955bd5f..dbcf521b017f 100644 --- a/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi +++ b/arch/arm/boot/dts/ste-nomadik-stn8815.dtsi | |||
| @@ -1,7 +1,9 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Device Tree for the ST-Ericsson Nomadik 8815 STn8815 SoC | 2 | * Device Tree for the ST-Ericsson Nomadik 8815 STn8815 SoC |
| 3 | */ | 3 | */ |
| 4 | /include/ "skeleton.dtsi" | 4 | |
| 5 | #include <dt-bindings/gpio/gpio.h> | ||
| 6 | #include "skeleton.dtsi" | ||
| 5 | 7 | ||
| 6 | / { | 8 | / { |
| 7 | #address-cells = <1>; | 9 | #address-cells = <1>; |
| @@ -842,8 +844,7 @@ | |||
| 842 | bus-width = <4>; | 844 | bus-width = <4>; |
| 843 | cap-mmc-highspeed; | 845 | cap-mmc-highspeed; |
| 844 | cap-sd-highspeed; | 846 | cap-sd-highspeed; |
| 845 | cd-gpios = <&gpio3 15 0x1>; | 847 | cd-gpios = <&gpio3 15 GPIO_ACTIVE_LOW>; |
| 846 | cd-inverted; | ||
| 847 | pinctrl-names = "default"; | 848 | pinctrl-names = "default"; |
| 848 | pinctrl-0 = <&mmcsd_default_mux>, <&mmcsd_default_mode>; | 849 | pinctrl-0 = <&mmcsd_default_mux>, <&mmcsd_default_mode>; |
| 849 | vmmc-supply = <&vmmc_regulator>; | 850 | vmmc-supply = <&vmmc_regulator>; |
diff --git a/arch/arm/crypto/aesbs-glue.c b/arch/arm/crypto/aesbs-glue.c index 4522366da759..15468fbbdea3 100644 --- a/arch/arm/crypto/aesbs-glue.c +++ b/arch/arm/crypto/aesbs-glue.c | |||
| @@ -137,7 +137,7 @@ static int aesbs_cbc_encrypt(struct blkcipher_desc *desc, | |||
| 137 | dst += AES_BLOCK_SIZE; | 137 | dst += AES_BLOCK_SIZE; |
| 138 | } while (--blocks); | 138 | } while (--blocks); |
| 139 | } | 139 | } |
| 140 | err = blkcipher_walk_done(desc, &walk, 0); | 140 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 141 | } | 141 | } |
| 142 | return err; | 142 | return err; |
| 143 | } | 143 | } |
| @@ -158,7 +158,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc, | |||
| 158 | bsaes_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr, | 158 | bsaes_cbc_encrypt(walk.src.virt.addr, walk.dst.virt.addr, |
| 159 | walk.nbytes, &ctx->dec, walk.iv); | 159 | walk.nbytes, &ctx->dec, walk.iv); |
| 160 | kernel_neon_end(); | 160 | kernel_neon_end(); |
| 161 | err = blkcipher_walk_done(desc, &walk, 0); | 161 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 162 | } | 162 | } |
| 163 | while (walk.nbytes) { | 163 | while (walk.nbytes) { |
| 164 | u32 blocks = walk.nbytes / AES_BLOCK_SIZE; | 164 | u32 blocks = walk.nbytes / AES_BLOCK_SIZE; |
| @@ -182,7 +182,7 @@ static int aesbs_cbc_decrypt(struct blkcipher_desc *desc, | |||
| 182 | dst += AES_BLOCK_SIZE; | 182 | dst += AES_BLOCK_SIZE; |
| 183 | src += AES_BLOCK_SIZE; | 183 | src += AES_BLOCK_SIZE; |
| 184 | } while (--blocks); | 184 | } while (--blocks); |
| 185 | err = blkcipher_walk_done(desc, &walk, 0); | 185 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 186 | } | 186 | } |
| 187 | return err; | 187 | return err; |
| 188 | } | 188 | } |
| @@ -268,7 +268,7 @@ static int aesbs_xts_encrypt(struct blkcipher_desc *desc, | |||
| 268 | bsaes_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr, | 268 | bsaes_xts_encrypt(walk.src.virt.addr, walk.dst.virt.addr, |
| 269 | walk.nbytes, &ctx->enc, walk.iv); | 269 | walk.nbytes, &ctx->enc, walk.iv); |
| 270 | kernel_neon_end(); | 270 | kernel_neon_end(); |
| 271 | err = blkcipher_walk_done(desc, &walk, 0); | 271 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 272 | } | 272 | } |
| 273 | return err; | 273 | return err; |
| 274 | } | 274 | } |
| @@ -292,7 +292,7 @@ static int aesbs_xts_decrypt(struct blkcipher_desc *desc, | |||
| 292 | bsaes_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr, | 292 | bsaes_xts_decrypt(walk.src.virt.addr, walk.dst.virt.addr, |
| 293 | walk.nbytes, &ctx->dec, walk.iv); | 293 | walk.nbytes, &ctx->dec, walk.iv); |
| 294 | kernel_neon_end(); | 294 | kernel_neon_end(); |
| 295 | err = blkcipher_walk_done(desc, &walk, 0); | 295 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 296 | } | 296 | } |
| 297 | return err; | 297 | return err; |
| 298 | } | 298 | } |
diff --git a/arch/arm/include/asm/mach/arch.h b/arch/arm/include/asm/mach/arch.h index 060a75e99263..0406cb3f1af7 100644 --- a/arch/arm/include/asm/mach/arch.h +++ b/arch/arm/include/asm/mach/arch.h | |||
| @@ -50,6 +50,7 @@ struct machine_desc { | |||
| 50 | struct smp_operations *smp; /* SMP operations */ | 50 | struct smp_operations *smp; /* SMP operations */ |
| 51 | bool (*smp_init)(void); | 51 | bool (*smp_init)(void); |
| 52 | void (*fixup)(struct tag *, char **); | 52 | void (*fixup)(struct tag *, char **); |
| 53 | void (*dt_fixup)(void); | ||
| 53 | void (*init_meminfo)(void); | 54 | void (*init_meminfo)(void); |
| 54 | void (*reserve)(void);/* reserve mem blocks */ | 55 | void (*reserve)(void);/* reserve mem blocks */ |
| 55 | void (*map_io)(void);/* IO mapping function */ | 56 | void (*map_io)(void);/* IO mapping function */ |
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c index e94a157ddff1..11c54de9f8cf 100644 --- a/arch/arm/kernel/devtree.c +++ b/arch/arm/kernel/devtree.c | |||
| @@ -212,7 +212,7 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) | |||
| 212 | mdesc_best = &__mach_desc_GENERIC_DT; | 212 | mdesc_best = &__mach_desc_GENERIC_DT; |
| 213 | #endif | 213 | #endif |
| 214 | 214 | ||
| 215 | if (!dt_phys || !early_init_dt_scan(phys_to_virt(dt_phys))) | 215 | if (!dt_phys || !early_init_dt_verify(phys_to_virt(dt_phys))) |
| 216 | return NULL; | 216 | return NULL; |
| 217 | 217 | ||
| 218 | mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); | 218 | mdesc = of_flat_dt_match_machine(mdesc_best, arch_get_next_mach); |
| @@ -237,6 +237,12 @@ const struct machine_desc * __init setup_machine_fdt(unsigned int dt_phys) | |||
| 237 | dump_machine_table(); /* does not return */ | 237 | dump_machine_table(); /* does not return */ |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | /* We really don't want to do this, but sometimes firmware provides buggy data */ | ||
| 241 | if (mdesc->dt_fixup) | ||
| 242 | mdesc->dt_fixup(); | ||
| 243 | |||
| 244 | early_init_dt_scan_nodes(); | ||
| 245 | |||
| 240 | /* Change machine number to match the mdesc we're using */ | 246 | /* Change machine number to match the mdesc we're using */ |
| 241 | __machine_arch_type = mdesc->nr; | 247 | __machine_arch_type = mdesc->nr; |
| 242 | 248 | ||
diff --git a/arch/arm/kernel/iwmmxt.S b/arch/arm/kernel/iwmmxt.S index a5599cfc43cb..2b32978ae905 100644 --- a/arch/arm/kernel/iwmmxt.S +++ b/arch/arm/kernel/iwmmxt.S | |||
| @@ -94,13 +94,19 @@ ENTRY(iwmmxt_task_enable) | |||
| 94 | 94 | ||
| 95 | mrc p15, 0, r2, c2, c0, 0 | 95 | mrc p15, 0, r2, c2, c0, 0 |
| 96 | mov r2, r2 @ cpwait | 96 | mov r2, r2 @ cpwait |
| 97 | bl concan_save | ||
| 97 | 98 | ||
| 98 | teq r1, #0 @ test for last ownership | 99 | #ifdef CONFIG_PREEMPT_COUNT |
| 99 | mov lr, r9 @ normal exit from exception | 100 | get_thread_info r10 |
| 100 | beq concan_load @ no owner, skip save | 101 | #endif |
| 102 | 4: dec_preempt_count r10, r3 | ||
| 103 | mov pc, r9 @ normal exit from exception | ||
| 101 | 104 | ||
| 102 | concan_save: | 105 | concan_save: |
| 103 | 106 | ||
| 107 | teq r1, #0 @ test for last ownership | ||
| 108 | beq concan_load @ no owner, skip save | ||
| 109 | |||
| 104 | tmrc r2, wCon | 110 | tmrc r2, wCon |
| 105 | 111 | ||
| 106 | @ CUP? wCx | 112 | @ CUP? wCx |
| @@ -138,7 +144,7 @@ concan_dump: | |||
| 138 | wstrd wR15, [r1, #MMX_WR15] | 144 | wstrd wR15, [r1, #MMX_WR15] |
| 139 | 145 | ||
| 140 | 2: teq r0, #0 @ anything to load? | 146 | 2: teq r0, #0 @ anything to load? |
| 141 | beq 3f | 147 | moveq pc, lr @ if not, return |
| 142 | 148 | ||
| 143 | concan_load: | 149 | concan_load: |
| 144 | 150 | ||
| @@ -171,14 +177,9 @@ concan_load: | |||
| 171 | @ clear CUP/MUP (only if r1 != 0) | 177 | @ clear CUP/MUP (only if r1 != 0) |
| 172 | teq r1, #0 | 178 | teq r1, #0 |
| 173 | mov r2, #0 | 179 | mov r2, #0 |
| 174 | beq 3f | 180 | moveq pc, lr |
| 175 | tmcr wCon, r2 | ||
| 176 | 181 | ||
| 177 | 3: | 182 | tmcr wCon, r2 |
| 178 | #ifdef CONFIG_PREEMPT_COUNT | ||
| 179 | get_thread_info r10 | ||
| 180 | #endif | ||
| 181 | 4: dec_preempt_count r10, r3 | ||
| 182 | mov pc, lr | 183 | mov pc, lr |
| 183 | 184 | ||
| 184 | /* | 185 | /* |
diff --git a/arch/arm/kernel/kgdb.c b/arch/arm/kernel/kgdb.c index 778c2f7024ff..a74b53c1b7df 100644 --- a/arch/arm/kernel/kgdb.c +++ b/arch/arm/kernel/kgdb.c | |||
| @@ -160,12 +160,16 @@ static int kgdb_compiled_brk_fn(struct pt_regs *regs, unsigned int instr) | |||
| 160 | static struct undef_hook kgdb_brkpt_hook = { | 160 | static struct undef_hook kgdb_brkpt_hook = { |
| 161 | .instr_mask = 0xffffffff, | 161 | .instr_mask = 0xffffffff, |
| 162 | .instr_val = KGDB_BREAKINST, | 162 | .instr_val = KGDB_BREAKINST, |
| 163 | .cpsr_mask = MODE_MASK, | ||
| 164 | .cpsr_val = SVC_MODE, | ||
| 163 | .fn = kgdb_brk_fn | 165 | .fn = kgdb_brk_fn |
| 164 | }; | 166 | }; |
| 165 | 167 | ||
| 166 | static struct undef_hook kgdb_compiled_brkpt_hook = { | 168 | static struct undef_hook kgdb_compiled_brkpt_hook = { |
| 167 | .instr_mask = 0xffffffff, | 169 | .instr_mask = 0xffffffff, |
| 168 | .instr_val = KGDB_COMPILED_BREAK, | 170 | .instr_val = KGDB_COMPILED_BREAK, |
| 171 | .cpsr_mask = MODE_MASK, | ||
| 172 | .cpsr_val = SVC_MODE, | ||
| 169 | .fn = kgdb_compiled_brk_fn | 173 | .fn = kgdb_compiled_brk_fn |
| 170 | }; | 174 | }; |
| 171 | 175 | ||
diff --git a/arch/arm/kernel/kprobes-test-arm.c b/arch/arm/kernel/kprobes-test-arm.c index 9db4b659d03e..cb1424240ff6 100644 --- a/arch/arm/kernel/kprobes-test-arm.c +++ b/arch/arm/kernel/kprobes-test-arm.c | |||
| @@ -74,8 +74,6 @@ void kprobe_arm_test_cases(void) | |||
| 74 | TEST_RRR( op "lt" s " r11, r",11,VAL1,", r",14,N(val),", asr r",7, 6,"")\ | 74 | TEST_RRR( op "lt" s " r11, r",11,VAL1,", r",14,N(val),", asr r",7, 6,"")\ |
| 75 | TEST_RR( op "gt" s " r12, r13" ", r",14,val, ", ror r",14,7,"")\ | 75 | TEST_RR( op "gt" s " r12, r13" ", r",14,val, ", ror r",14,7,"")\ |
| 76 | TEST_RR( op "le" s " r14, r",0, val, ", r13" ", lsl r",14,8,"")\ | 76 | TEST_RR( op "le" s " r14, r",0, val, ", r13" ", lsl r",14,8,"")\ |
| 77 | TEST_RR( op s " r12, pc" ", r",14,val, ", ror r",14,7,"")\ | ||
| 78 | TEST_RR( op s " r14, r",0, val, ", pc" ", lsl r",14,8,"")\ | ||
| 79 | TEST_R( op "eq" s " r0, r",11,VAL1,", #0xf5") \ | 77 | TEST_R( op "eq" s " r0, r",11,VAL1,", #0xf5") \ |
| 80 | TEST_R( op "ne" s " r11, r",0, VAL1,", #0xf5000000") \ | 78 | TEST_R( op "ne" s " r11, r",0, VAL1,", #0xf5000000") \ |
| 81 | TEST_R( op s " r7, r",8, VAL2,", #0x000af000") \ | 79 | TEST_R( op s " r7, r",8, VAL2,", #0x000af000") \ |
| @@ -103,8 +101,6 @@ void kprobe_arm_test_cases(void) | |||
| 103 | TEST_RRR( op "ge r",11,VAL1,", r",14,N(val),", asr r",7, 6,"") \ | 101 | TEST_RRR( op "ge r",11,VAL1,", r",14,N(val),", asr r",7, 6,"") \ |
| 104 | TEST_RR( op "le r13" ", r",14,val, ", ror r",14,7,"") \ | 102 | TEST_RR( op "le r13" ", r",14,val, ", ror r",14,7,"") \ |
| 105 | TEST_RR( op "gt r",0, val, ", r13" ", lsl r",14,8,"") \ | 103 | TEST_RR( op "gt r",0, val, ", r13" ", lsl r",14,8,"") \ |
| 106 | TEST_RR( op " pc" ", r",14,val, ", ror r",14,7,"") \ | ||
| 107 | TEST_RR( op " r",0, val, ", pc" ", lsl r",14,8,"") \ | ||
| 108 | TEST_R( op "eq r",11,VAL1,", #0xf5") \ | 104 | TEST_R( op "eq r",11,VAL1,", #0xf5") \ |
| 109 | TEST_R( op "ne r",0, VAL1,", #0xf5000000") \ | 105 | TEST_R( op "ne r",0, VAL1,", #0xf5000000") \ |
| 110 | TEST_R( op " r",8, VAL2,", #0x000af000") | 106 | TEST_R( op " r",8, VAL2,", #0x000af000") |
| @@ -125,7 +121,6 @@ void kprobe_arm_test_cases(void) | |||
| 125 | TEST_RR( op "ge" s " r11, r",11,N(val),", asr r",7, 6,"") \ | 121 | TEST_RR( op "ge" s " r11, r",11,N(val),", asr r",7, 6,"") \ |
| 126 | TEST_RR( op "lt" s " r12, r",11,val, ", ror r",14,7,"") \ | 122 | TEST_RR( op "lt" s " r12, r",11,val, ", ror r",14,7,"") \ |
| 127 | TEST_R( op "gt" s " r14, r13" ", lsl r",14,8,"") \ | 123 | TEST_R( op "gt" s " r14, r13" ", lsl r",14,8,"") \ |
| 128 | TEST_R( op "le" s " r14, pc" ", lsl r",14,8,"") \ | ||
| 129 | TEST( op "eq" s " r0, #0xf5") \ | 124 | TEST( op "eq" s " r0, #0xf5") \ |
| 130 | TEST( op "ne" s " r11, #0xf5000000") \ | 125 | TEST( op "ne" s " r11, #0xf5000000") \ |
| 131 | TEST( op s " r7, #0x000af000") \ | 126 | TEST( op s " r7, #0x000af000") \ |
| @@ -159,12 +154,19 @@ void kprobe_arm_test_cases(void) | |||
| 159 | TEST_SUPPORTED("cmp pc, #0x1000"); | 154 | TEST_SUPPORTED("cmp pc, #0x1000"); |
| 160 | TEST_SUPPORTED("cmp sp, #0x1000"); | 155 | TEST_SUPPORTED("cmp sp, #0x1000"); |
| 161 | 156 | ||
| 162 | /* Data-processing with PC as shift*/ | 157 | /* Data-processing with PC and a shift count in a register */ |
| 163 | TEST_UNSUPPORTED(__inst_arm(0xe15c0f1e) " @ cmp r12, r14, asl pc") | 158 | TEST_UNSUPPORTED(__inst_arm(0xe15c0f1e) " @ cmp r12, r14, asl pc") |
| 164 | TEST_UNSUPPORTED(__inst_arm(0xe1a0cf1e) " @ mov r12, r14, asl pc") | 159 | TEST_UNSUPPORTED(__inst_arm(0xe1a0cf1e) " @ mov r12, r14, asl pc") |
| 165 | TEST_UNSUPPORTED(__inst_arm(0xe08caf1e) " @ add r10, r12, r14, asl pc") | 160 | TEST_UNSUPPORTED(__inst_arm(0xe08caf1e) " @ add r10, r12, r14, asl pc") |
| 166 | 161 | TEST_UNSUPPORTED(__inst_arm(0xe151021f) " @ cmp r1, pc, lsl r2") | |
| 167 | /* Data-processing with PC as shift*/ | 162 | TEST_UNSUPPORTED(__inst_arm(0xe17f0211) " @ cmn pc, r1, lsl r2") |
| 163 | TEST_UNSUPPORTED(__inst_arm(0xe1a0121f) " @ mov r1, pc, lsl r2") | ||
| 164 | TEST_UNSUPPORTED(__inst_arm(0xe1a0f211) " @ mov pc, r1, lsl r2") | ||
| 165 | TEST_UNSUPPORTED(__inst_arm(0xe042131f) " @ sub r1, r2, pc, lsl r3") | ||
| 166 | TEST_UNSUPPORTED(__inst_arm(0xe1cf1312) " @ bic r1, pc, r2, lsl r3") | ||
| 167 | TEST_UNSUPPORTED(__inst_arm(0xe081f312) " @ add pc, r1, r2, lsl r3") | ||
| 168 | |||
| 169 | /* Data-processing with PC as a target and status registers updated */ | ||
| 168 | TEST_UNSUPPORTED("movs pc, r1") | 170 | TEST_UNSUPPORTED("movs pc, r1") |
| 169 | TEST_UNSUPPORTED("movs pc, r1, lsl r2") | 171 | TEST_UNSUPPORTED("movs pc, r1, lsl r2") |
| 170 | TEST_UNSUPPORTED("movs pc, #0x10000") | 172 | TEST_UNSUPPORTED("movs pc, #0x10000") |
| @@ -187,14 +189,14 @@ void kprobe_arm_test_cases(void) | |||
| 187 | TEST_BF_R ("add pc, pc, r",14,2f-1f-8,"") | 189 | TEST_BF_R ("add pc, pc, r",14,2f-1f-8,"") |
| 188 | TEST_BF_R ("add pc, r",14,2f-1f-8,", pc") | 190 | TEST_BF_R ("add pc, r",14,2f-1f-8,", pc") |
| 189 | TEST_BF_R ("mov pc, r",0,2f,"") | 191 | TEST_BF_R ("mov pc, r",0,2f,"") |
| 190 | TEST_BF_RR("mov pc, r",0,2f,", asl r",1,0,"") | 192 | TEST_BF_R ("add pc, pc, r",14,(2f-1f-8)*2,", asr #1") |
| 191 | TEST_BB( "sub pc, pc, #1b-2b+8") | 193 | TEST_BB( "sub pc, pc, #1b-2b+8") |
| 192 | #if __LINUX_ARM_ARCH__ == 6 && !defined(CONFIG_CPU_V7) | 194 | #if __LINUX_ARM_ARCH__ == 6 && !defined(CONFIG_CPU_V7) |
| 193 | TEST_BB( "sub pc, pc, #1b-2b+8-2") /* UNPREDICTABLE before and after ARMv6 */ | 195 | TEST_BB( "sub pc, pc, #1b-2b+8-2") /* UNPREDICTABLE before and after ARMv6 */ |
| 194 | #endif | 196 | #endif |
| 195 | TEST_BB_R( "sub pc, pc, r",14, 1f-2f+8,"") | 197 | TEST_BB_R( "sub pc, pc, r",14, 1f-2f+8,"") |
| 196 | TEST_BB_R( "rsb pc, r",14,1f-2f+8,", pc") | 198 | TEST_BB_R( "rsb pc, r",14,1f-2f+8,", pc") |
| 197 | TEST_RR( "add pc, pc, r",10,-2,", asl r",11,1,"") | 199 | TEST_R( "add pc, pc, r",10,-2,", asl #1") |
| 198 | #ifdef CONFIG_THUMB2_KERNEL | 200 | #ifdef CONFIG_THUMB2_KERNEL |
| 199 | TEST_ARM_TO_THUMB_INTERWORK_R("add pc, pc, r",0,3f-1f-8+1,"") | 201 | TEST_ARM_TO_THUMB_INTERWORK_R("add pc, pc, r",0,3f-1f-8+1,"") |
| 200 | TEST_ARM_TO_THUMB_INTERWORK_R("sub pc, r",0,3f+8+1,", #8") | 202 | TEST_ARM_TO_THUMB_INTERWORK_R("sub pc, r",0,3f+8+1,", #8") |
| @@ -216,6 +218,7 @@ void kprobe_arm_test_cases(void) | |||
| 216 | TEST_BB_R("bx r",7,2f,"") | 218 | TEST_BB_R("bx r",7,2f,"") |
| 217 | TEST_BF_R("bxeq r",14,2f,"") | 219 | TEST_BF_R("bxeq r",14,2f,"") |
| 218 | 220 | ||
| 221 | #if __LINUX_ARM_ARCH__ >= 5 | ||
| 219 | TEST_R("clz r0, r",0, 0x0,"") | 222 | TEST_R("clz r0, r",0, 0x0,"") |
| 220 | TEST_R("clzeq r7, r",14,0x1,"") | 223 | TEST_R("clzeq r7, r",14,0x1,"") |
| 221 | TEST_R("clz lr, r",7, 0xffffffff,"") | 224 | TEST_R("clz lr, r",7, 0xffffffff,"") |
| @@ -337,6 +340,7 @@ void kprobe_arm_test_cases(void) | |||
| 337 | TEST_UNSUPPORTED(__inst_arm(0xe16f02e1) " @ smultt pc, r1, r2") | 340 | TEST_UNSUPPORTED(__inst_arm(0xe16f02e1) " @ smultt pc, r1, r2") |
| 338 | TEST_UNSUPPORTED(__inst_arm(0xe16002ef) " @ smultt r0, pc, r2") | 341 | TEST_UNSUPPORTED(__inst_arm(0xe16002ef) " @ smultt r0, pc, r2") |
| 339 | TEST_UNSUPPORTED(__inst_arm(0xe1600fe1) " @ smultt r0, r1, pc") | 342 | TEST_UNSUPPORTED(__inst_arm(0xe1600fe1) " @ smultt r0, r1, pc") |
| 343 | #endif | ||
| 340 | 344 | ||
| 341 | TEST_GROUP("Multiply and multiply-accumulate") | 345 | TEST_GROUP("Multiply and multiply-accumulate") |
| 342 | 346 | ||
| @@ -559,6 +563,7 @@ void kprobe_arm_test_cases(void) | |||
| 559 | TEST_UNSUPPORTED("ldrsht r1, [r2], #48") | 563 | TEST_UNSUPPORTED("ldrsht r1, [r2], #48") |
| 560 | #endif | 564 | #endif |
| 561 | 565 | ||
| 566 | #if __LINUX_ARM_ARCH__ >= 5 | ||
| 562 | TEST_RPR( "strd r",0, VAL1,", [r",1, 48,", -r",2,24,"]") | 567 | TEST_RPR( "strd r",0, VAL1,", [r",1, 48,", -r",2,24,"]") |
| 563 | TEST_RPR( "strccd r",8, VAL2,", [r",13,0, ", r",12,48,"]") | 568 | TEST_RPR( "strccd r",8, VAL2,", [r",13,0, ", r",12,48,"]") |
| 564 | TEST_RPR( "strd r",4, VAL1,", [r",2, 24,", r",3, 48,"]!") | 569 | TEST_RPR( "strd r",4, VAL1,", [r",2, 24,", r",3, 48,"]!") |
| @@ -595,6 +600,7 @@ void kprobe_arm_test_cases(void) | |||
| 595 | TEST_UNSUPPORTED(__inst_arm(0xe1efc3d0) " @ ldrd r12, [pc, #48]!") | 600 | TEST_UNSUPPORTED(__inst_arm(0xe1efc3d0) " @ ldrd r12, [pc, #48]!") |
| 596 | TEST_UNSUPPORTED(__inst_arm(0xe0c9f3d0) " @ ldrd pc, [r9], #48") | 601 | TEST_UNSUPPORTED(__inst_arm(0xe0c9f3d0) " @ ldrd pc, [r9], #48") |
| 597 | TEST_UNSUPPORTED(__inst_arm(0xe0c9e3d0) " @ ldrd lr, [r9], #48") | 602 | TEST_UNSUPPORTED(__inst_arm(0xe0c9e3d0) " @ ldrd lr, [r9], #48") |
| 603 | #endif | ||
| 598 | 604 | ||
| 599 | TEST_GROUP("Miscellaneous") | 605 | TEST_GROUP("Miscellaneous") |
| 600 | 606 | ||
| @@ -1227,7 +1233,9 @@ void kprobe_arm_test_cases(void) | |||
| 1227 | TEST_COPROCESSOR( "mrc"two" 0, 0, r0, cr0, cr0, 0") | 1233 | TEST_COPROCESSOR( "mrc"two" 0, 0, r0, cr0, cr0, 0") |
| 1228 | 1234 | ||
| 1229 | COPROCESSOR_INSTRUCTIONS_ST_LD("",e) | 1235 | COPROCESSOR_INSTRUCTIONS_ST_LD("",e) |
| 1236 | #if __LINUX_ARM_ARCH__ >= 5 | ||
| 1230 | COPROCESSOR_INSTRUCTIONS_MC_MR("",e) | 1237 | COPROCESSOR_INSTRUCTIONS_MC_MR("",e) |
| 1238 | #endif | ||
| 1231 | TEST_UNSUPPORTED("svc 0") | 1239 | TEST_UNSUPPORTED("svc 0") |
| 1232 | TEST_UNSUPPORTED("svc 0xffffff") | 1240 | TEST_UNSUPPORTED("svc 0xffffff") |
| 1233 | 1241 | ||
| @@ -1287,7 +1295,9 @@ void kprobe_arm_test_cases(void) | |||
| 1287 | TEST( "blx __dummy_thumb_subroutine_odd") | 1295 | TEST( "blx __dummy_thumb_subroutine_odd") |
| 1288 | #endif /* __LINUX_ARM_ARCH__ >= 6 */ | 1296 | #endif /* __LINUX_ARM_ARCH__ >= 6 */ |
| 1289 | 1297 | ||
| 1298 | #if __LINUX_ARM_ARCH__ >= 5 | ||
| 1290 | COPROCESSOR_INSTRUCTIONS_ST_LD("2",f) | 1299 | COPROCESSOR_INSTRUCTIONS_ST_LD("2",f) |
| 1300 | #endif | ||
| 1291 | #if __LINUX_ARM_ARCH__ >= 6 | 1301 | #if __LINUX_ARM_ARCH__ >= 6 |
| 1292 | COPROCESSOR_INSTRUCTIONS_MC_MR("2",f) | 1302 | COPROCESSOR_INSTRUCTIONS_MC_MR("2",f) |
| 1293 | #endif | 1303 | #endif |
diff --git a/arch/arm/kernel/kprobes-test.c b/arch/arm/kernel/kprobes-test.c index 379639998d5a..08d731294bcd 100644 --- a/arch/arm/kernel/kprobes-test.c +++ b/arch/arm/kernel/kprobes-test.c | |||
| @@ -225,6 +225,7 @@ static int pre_handler_called; | |||
| 225 | static int post_handler_called; | 225 | static int post_handler_called; |
| 226 | static int jprobe_func_called; | 226 | static int jprobe_func_called; |
| 227 | static int kretprobe_handler_called; | 227 | static int kretprobe_handler_called; |
| 228 | static int tests_failed; | ||
| 228 | 229 | ||
| 229 | #define FUNC_ARG1 0x12345678 | 230 | #define FUNC_ARG1 0x12345678 |
| 230 | #define FUNC_ARG2 0xabcdef | 231 | #define FUNC_ARG2 0xabcdef |
| @@ -461,6 +462,13 @@ static int run_api_tests(long (*func)(long, long)) | |||
| 461 | 462 | ||
| 462 | pr_info(" jprobe\n"); | 463 | pr_info(" jprobe\n"); |
| 463 | ret = test_jprobe(func); | 464 | ret = test_jprobe(func); |
| 465 | #if defined(CONFIG_THUMB2_KERNEL) && !defined(MODULE) | ||
| 466 | if (ret == -EINVAL) { | ||
| 467 | pr_err("FAIL: Known longtime bug with jprobe on Thumb kernels\n"); | ||
| 468 | tests_failed = ret; | ||
| 469 | ret = 0; | ||
| 470 | } | ||
| 471 | #endif | ||
| 464 | if (ret < 0) | 472 | if (ret < 0) |
| 465 | return ret; | 473 | return ret; |
| 466 | 474 | ||
| @@ -1672,6 +1680,8 @@ static int __init run_all_tests(void) | |||
| 1672 | 1680 | ||
| 1673 | out: | 1681 | out: |
| 1674 | if (ret == 0) | 1682 | if (ret == 0) |
| 1683 | ret = tests_failed; | ||
| 1684 | if (ret == 0) | ||
| 1675 | pr_info("Finished kprobe tests OK\n"); | 1685 | pr_info("Finished kprobe tests OK\n"); |
| 1676 | else | 1686 | else |
| 1677 | pr_err("kprobe tests failed\n"); | 1687 | pr_err("kprobe tests failed\n"); |
diff --git a/arch/arm/kernel/probes-arm.c b/arch/arm/kernel/probes-arm.c index 51a13a027989..8eaef81d8344 100644 --- a/arch/arm/kernel/probes-arm.c +++ b/arch/arm/kernel/probes-arm.c | |||
| @@ -341,12 +341,12 @@ static const union decode_item arm_cccc_000x_table[] = { | |||
| 341 | /* CMP (reg-shift reg) cccc 0001 0101 xxxx xxxx xxxx 0xx1 xxxx */ | 341 | /* CMP (reg-shift reg) cccc 0001 0101 xxxx xxxx xxxx 0xx1 xxxx */ |
| 342 | /* CMN (reg-shift reg) cccc 0001 0111 xxxx xxxx xxxx 0xx1 xxxx */ | 342 | /* CMN (reg-shift reg) cccc 0001 0111 xxxx xxxx xxxx 0xx1 xxxx */ |
| 343 | DECODE_EMULATEX (0x0f900090, 0x01100010, PROBES_DATA_PROCESSING_REG, | 343 | DECODE_EMULATEX (0x0f900090, 0x01100010, PROBES_DATA_PROCESSING_REG, |
| 344 | REGS(ANY, 0, NOPC, 0, ANY)), | 344 | REGS(NOPC, 0, NOPC, 0, NOPC)), |
| 345 | 345 | ||
| 346 | /* MOV (reg-shift reg) cccc 0001 101x xxxx xxxx xxxx 0xx1 xxxx */ | 346 | /* MOV (reg-shift reg) cccc 0001 101x xxxx xxxx xxxx 0xx1 xxxx */ |
| 347 | /* MVN (reg-shift reg) cccc 0001 111x xxxx xxxx xxxx 0xx1 xxxx */ | 347 | /* MVN (reg-shift reg) cccc 0001 111x xxxx xxxx xxxx 0xx1 xxxx */ |
| 348 | DECODE_EMULATEX (0x0fa00090, 0x01a00010, PROBES_DATA_PROCESSING_REG, | 348 | DECODE_EMULATEX (0x0fa00090, 0x01a00010, PROBES_DATA_PROCESSING_REG, |
| 349 | REGS(0, ANY, NOPC, 0, ANY)), | 349 | REGS(0, NOPC, NOPC, 0, NOPC)), |
| 350 | 350 | ||
| 351 | /* AND (reg-shift reg) cccc 0000 000x xxxx xxxx xxxx 0xx1 xxxx */ | 351 | /* AND (reg-shift reg) cccc 0000 000x xxxx xxxx xxxx 0xx1 xxxx */ |
| 352 | /* EOR (reg-shift reg) cccc 0000 001x xxxx xxxx xxxx 0xx1 xxxx */ | 352 | /* EOR (reg-shift reg) cccc 0000 001x xxxx xxxx xxxx 0xx1 xxxx */ |
| @@ -359,7 +359,7 @@ static const union decode_item arm_cccc_000x_table[] = { | |||
| 359 | /* ORR (reg-shift reg) cccc 0001 100x xxxx xxxx xxxx 0xx1 xxxx */ | 359 | /* ORR (reg-shift reg) cccc 0001 100x xxxx xxxx xxxx 0xx1 xxxx */ |
| 360 | /* BIC (reg-shift reg) cccc 0001 110x xxxx xxxx xxxx 0xx1 xxxx */ | 360 | /* BIC (reg-shift reg) cccc 0001 110x xxxx xxxx xxxx 0xx1 xxxx */ |
| 361 | DECODE_EMULATEX (0x0e000090, 0x00000010, PROBES_DATA_PROCESSING_REG, | 361 | DECODE_EMULATEX (0x0e000090, 0x00000010, PROBES_DATA_PROCESSING_REG, |
| 362 | REGS(ANY, ANY, NOPC, 0, ANY)), | 362 | REGS(NOPC, NOPC, NOPC, 0, NOPC)), |
| 363 | 363 | ||
| 364 | DECODE_END | 364 | DECODE_END |
| 365 | }; | 365 | }; |
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c index 9d853189028b..e35d880f9773 100644 --- a/arch/arm/kernel/topology.c +++ b/arch/arm/kernel/topology.c | |||
| @@ -275,7 +275,7 @@ void store_cpu_topology(unsigned int cpuid) | |||
| 275 | cpu_topology[cpuid].socket_id, mpidr); | 275 | cpu_topology[cpuid].socket_id, mpidr); |
| 276 | } | 276 | } |
| 277 | 277 | ||
| 278 | static inline const int cpu_corepower_flags(void) | 278 | static inline int cpu_corepower_flags(void) |
| 279 | { | 279 | { |
| 280 | return SD_SHARE_PKG_RESOURCES | SD_SHARE_POWERDOMAIN; | 280 | return SD_SHARE_PKG_RESOURCES | SD_SHARE_POWERDOMAIN; |
| 281 | } | 281 | } |
diff --git a/arch/arm/mach-exynos/exynos.c b/arch/arm/mach-exynos/exynos.c index f38cf7c110cc..66c9b9614f3c 100644 --- a/arch/arm/mach-exynos/exynos.c +++ b/arch/arm/mach-exynos/exynos.c | |||
| @@ -173,10 +173,8 @@ static struct platform_device exynos_cpuidle = { | |||
| 173 | 173 | ||
| 174 | void __init exynos_cpuidle_init(void) | 174 | void __init exynos_cpuidle_init(void) |
| 175 | { | 175 | { |
| 176 | if (soc_is_exynos5440()) | 176 | if (soc_is_exynos4210() || soc_is_exynos5250()) |
| 177 | return; | 177 | platform_device_register(&exynos_cpuidle); |
| 178 | |||
| 179 | platform_device_register(&exynos_cpuidle); | ||
| 180 | } | 178 | } |
| 181 | 179 | ||
| 182 | void __init exynos_cpufreq_init(void) | 180 | void __init exynos_cpufreq_init(void) |
| @@ -297,7 +295,7 @@ static void __init exynos_dt_machine_init(void) | |||
| 297 | * This is called from smp_prepare_cpus if we've built for SMP, but | 295 | * This is called from smp_prepare_cpus if we've built for SMP, but |
| 298 | * we still need to set it up for PM and firmware ops if not. | 296 | * we still need to set it up for PM and firmware ops if not. |
| 299 | */ | 297 | */ |
| 300 | if (!IS_ENABLED(SMP)) | 298 | if (!IS_ENABLED(CONFIG_SMP)) |
| 301 | exynos_sysram_init(); | 299 | exynos_sysram_init(); |
| 302 | 300 | ||
| 303 | exynos_cpuidle_init(); | 301 | exynos_cpuidle_init(); |
| @@ -337,6 +335,15 @@ static void __init exynos_reserve(void) | |||
| 337 | #endif | 335 | #endif |
| 338 | } | 336 | } |
| 339 | 337 | ||
| 338 | static void __init exynos_dt_fixup(void) | ||
| 339 | { | ||
| 340 | /* | ||
| 341 | * Some versions of uboot pass garbage entries in the memory node, | ||
| 342 | * use the old CONFIG_ARM_NR_BANKS | ||
| 343 | */ | ||
| 344 | of_fdt_limit_memory(8); | ||
| 345 | } | ||
| 346 | |||
| 340 | DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") | 347 | DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") |
| 341 | /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */ | 348 | /* Maintainer: Thomas Abraham <thomas.abraham@linaro.org> */ |
| 342 | /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ | 349 | /* Maintainer: Kukjin Kim <kgene.kim@samsung.com> */ |
| @@ -350,4 +357,5 @@ DT_MACHINE_START(EXYNOS_DT, "SAMSUNG EXYNOS (Flattened Device Tree)") | |||
| 350 | .dt_compat = exynos_dt_compat, | 357 | .dt_compat = exynos_dt_compat, |
| 351 | .restart = exynos_restart, | 358 | .restart = exynos_restart, |
| 352 | .reserve = exynos_reserve, | 359 | .reserve = exynos_reserve, |
| 360 | .dt_fixup = exynos_dt_fixup, | ||
| 353 | MACHINE_END | 361 | MACHINE_END |
diff --git a/arch/arm/mach-exynos/firmware.c b/arch/arm/mach-exynos/firmware.c index eb91d2350f8c..e8797bb78871 100644 --- a/arch/arm/mach-exynos/firmware.c +++ b/arch/arm/mach-exynos/firmware.c | |||
| @@ -57,8 +57,13 @@ static int exynos_set_cpu_boot_addr(int cpu, unsigned long boot_addr) | |||
| 57 | 57 | ||
| 58 | boot_reg = sysram_ns_base_addr + 0x1c; | 58 | boot_reg = sysram_ns_base_addr + 0x1c; |
| 59 | 59 | ||
| 60 | if (!soc_is_exynos4212() && !soc_is_exynos3250()) | 60 | /* |
| 61 | boot_reg += 4*cpu; | 61 | * Almost all Exynos-series of SoCs that run in secure mode don't need |
| 62 | * additional offset for every CPU, with Exynos4412 being the only | ||
| 63 | * exception. | ||
| 64 | */ | ||
| 65 | if (soc_is_exynos4412()) | ||
| 66 | boot_reg += 4 * cpu; | ||
| 62 | 67 | ||
| 63 | __raw_writel(boot_addr, boot_reg); | 68 | __raw_writel(boot_addr, boot_reg); |
| 64 | return 0; | 69 | return 0; |
diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c index 8a134d019cb3..920a4baa53cd 100644 --- a/arch/arm/mach-exynos/hotplug.c +++ b/arch/arm/mach-exynos/hotplug.c | |||
| @@ -40,15 +40,17 @@ static inline void cpu_leave_lowpower(void) | |||
| 40 | 40 | ||
| 41 | static inline void platform_do_lowpower(unsigned int cpu, int *spurious) | 41 | static inline void platform_do_lowpower(unsigned int cpu, int *spurious) |
| 42 | { | 42 | { |
| 43 | u32 mpidr = cpu_logical_map(cpu); | ||
| 44 | u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); | ||
| 45 | |||
| 43 | for (;;) { | 46 | for (;;) { |
| 44 | 47 | ||
| 45 | /* make cpu1 to be turned off at next WFI command */ | 48 | /* Turn the CPU off on next WFI instruction. */ |
| 46 | if (cpu == 1) | 49 | exynos_cpu_power_down(core_id); |
| 47 | exynos_cpu_power_down(cpu); | ||
| 48 | 50 | ||
| 49 | wfi(); | 51 | wfi(); |
| 50 | 52 | ||
| 51 | if (pen_release == cpu_logical_map(cpu)) { | 53 | if (pen_release == core_id) { |
| 52 | /* | 54 | /* |
| 53 | * OK, proper wakeup, we're done | 55 | * OK, proper wakeup, we're done |
| 54 | */ | 56 | */ |
diff --git a/arch/arm/mach-exynos/platsmp.c b/arch/arm/mach-exynos/platsmp.c index 1c8d31e39520..50b9aad5e27b 100644 --- a/arch/arm/mach-exynos/platsmp.c +++ b/arch/arm/mach-exynos/platsmp.c | |||
| @@ -90,7 +90,8 @@ static void exynos_secondary_init(unsigned int cpu) | |||
| 90 | static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle) | 90 | static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle) |
| 91 | { | 91 | { |
| 92 | unsigned long timeout; | 92 | unsigned long timeout; |
| 93 | unsigned long phys_cpu = cpu_logical_map(cpu); | 93 | u32 mpidr = cpu_logical_map(cpu); |
| 94 | u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); | ||
| 94 | int ret = -ENOSYS; | 95 | int ret = -ENOSYS; |
| 95 | 96 | ||
| 96 | /* | 97 | /* |
| @@ -104,17 +105,18 @@ static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle) | |||
| 104 | * the holding pen - release it, then wait for it to flag | 105 | * the holding pen - release it, then wait for it to flag |
| 105 | * that it has been released by resetting pen_release. | 106 | * that it has been released by resetting pen_release. |
| 106 | * | 107 | * |
| 107 | * Note that "pen_release" is the hardware CPU ID, whereas | 108 | * Note that "pen_release" is the hardware CPU core ID, whereas |
| 108 | * "cpu" is Linux's internal ID. | 109 | * "cpu" is Linux's internal ID. |
| 109 | */ | 110 | */ |
| 110 | write_pen_release(phys_cpu); | 111 | write_pen_release(core_id); |
| 111 | 112 | ||
| 112 | if (!exynos_cpu_power_state(cpu)) { | 113 | if (!exynos_cpu_power_state(core_id)) { |
| 113 | exynos_cpu_power_up(cpu); | 114 | exynos_cpu_power_up(core_id); |
| 114 | timeout = 10; | 115 | timeout = 10; |
| 115 | 116 | ||
| 116 | /* wait max 10 ms until cpu1 is on */ | 117 | /* wait max 10 ms until cpu1 is on */ |
| 117 | while (exynos_cpu_power_state(cpu) != S5P_CORE_LOCAL_PWR_EN) { | 118 | while (exynos_cpu_power_state(core_id) |
| 119 | != S5P_CORE_LOCAL_PWR_EN) { | ||
| 118 | if (timeout-- == 0) | 120 | if (timeout-- == 0) |
| 119 | break; | 121 | break; |
| 120 | 122 | ||
| @@ -145,20 +147,20 @@ static int exynos_boot_secondary(unsigned int cpu, struct task_struct *idle) | |||
| 145 | * Try to set boot address using firmware first | 147 | * Try to set boot address using firmware first |
| 146 | * and fall back to boot register if it fails. | 148 | * and fall back to boot register if it fails. |
| 147 | */ | 149 | */ |
| 148 | ret = call_firmware_op(set_cpu_boot_addr, phys_cpu, boot_addr); | 150 | ret = call_firmware_op(set_cpu_boot_addr, core_id, boot_addr); |
| 149 | if (ret && ret != -ENOSYS) | 151 | if (ret && ret != -ENOSYS) |
| 150 | goto fail; | 152 | goto fail; |
| 151 | if (ret == -ENOSYS) { | 153 | if (ret == -ENOSYS) { |
| 152 | void __iomem *boot_reg = cpu_boot_reg(phys_cpu); | 154 | void __iomem *boot_reg = cpu_boot_reg(core_id); |
| 153 | 155 | ||
| 154 | if (IS_ERR(boot_reg)) { | 156 | if (IS_ERR(boot_reg)) { |
| 155 | ret = PTR_ERR(boot_reg); | 157 | ret = PTR_ERR(boot_reg); |
| 156 | goto fail; | 158 | goto fail; |
| 157 | } | 159 | } |
| 158 | __raw_writel(boot_addr, cpu_boot_reg(phys_cpu)); | 160 | __raw_writel(boot_addr, cpu_boot_reg(core_id)); |
| 159 | } | 161 | } |
| 160 | 162 | ||
| 161 | call_firmware_op(cpu_boot, phys_cpu); | 163 | call_firmware_op(cpu_boot, core_id); |
| 162 | 164 | ||
| 163 | arch_send_wakeup_ipi_mask(cpumask_of(cpu)); | 165 | arch_send_wakeup_ipi_mask(cpumask_of(cpu)); |
| 164 | 166 | ||
| @@ -227,22 +229,24 @@ static void __init exynos_smp_prepare_cpus(unsigned int max_cpus) | |||
| 227 | * boot register if it fails. | 229 | * boot register if it fails. |
| 228 | */ | 230 | */ |
| 229 | for (i = 1; i < max_cpus; ++i) { | 231 | for (i = 1; i < max_cpus; ++i) { |
| 230 | unsigned long phys_cpu; | ||
| 231 | unsigned long boot_addr; | 232 | unsigned long boot_addr; |
| 233 | u32 mpidr; | ||
| 234 | u32 core_id; | ||
| 232 | int ret; | 235 | int ret; |
| 233 | 236 | ||
| 234 | phys_cpu = cpu_logical_map(i); | 237 | mpidr = cpu_logical_map(i); |
| 238 | core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); | ||
| 235 | boot_addr = virt_to_phys(exynos4_secondary_startup); | 239 | boot_addr = virt_to_phys(exynos4_secondary_startup); |
| 236 | 240 | ||
| 237 | ret = call_firmware_op(set_cpu_boot_addr, phys_cpu, boot_addr); | 241 | ret = call_firmware_op(set_cpu_boot_addr, core_id, boot_addr); |
| 238 | if (ret && ret != -ENOSYS) | 242 | if (ret && ret != -ENOSYS) |
| 239 | break; | 243 | break; |
| 240 | if (ret == -ENOSYS) { | 244 | if (ret == -ENOSYS) { |
| 241 | void __iomem *boot_reg = cpu_boot_reg(phys_cpu); | 245 | void __iomem *boot_reg = cpu_boot_reg(core_id); |
| 242 | 246 | ||
| 243 | if (IS_ERR(boot_reg)) | 247 | if (IS_ERR(boot_reg)) |
| 244 | break; | 248 | break; |
| 245 | __raw_writel(boot_addr, cpu_boot_reg(phys_cpu)); | 249 | __raw_writel(boot_addr, cpu_boot_reg(core_id)); |
| 246 | } | 250 | } |
| 247 | } | 251 | } |
| 248 | } | 252 | } |
diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c index fe6570ebbdde..797cb134bfff 100644 --- a/arch/arm/mach-exynos/pm_domains.c +++ b/arch/arm/mach-exynos/pm_domains.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/err.h> | 17 | #include <linux/err.h> |
| 18 | #include <linux/slab.h> | 18 | #include <linux/slab.h> |
| 19 | #include <linux/pm_domain.h> | 19 | #include <linux/pm_domain.h> |
| 20 | #include <linux/clk.h> | ||
| 20 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
| 21 | #include <linux/of_address.h> | 22 | #include <linux/of_address.h> |
| 22 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
| @@ -24,6 +25,8 @@ | |||
| 24 | 25 | ||
| 25 | #include "regs-pmu.h" | 26 | #include "regs-pmu.h" |
| 26 | 27 | ||
| 28 | #define MAX_CLK_PER_DOMAIN 4 | ||
| 29 | |||
| 27 | /* | 30 | /* |
| 28 | * Exynos specific wrapper around the generic power domain | 31 | * Exynos specific wrapper around the generic power domain |
| 29 | */ | 32 | */ |
| @@ -32,6 +35,9 @@ struct exynos_pm_domain { | |||
| 32 | char const *name; | 35 | char const *name; |
| 33 | bool is_off; | 36 | bool is_off; |
| 34 | struct generic_pm_domain pd; | 37 | struct generic_pm_domain pd; |
| 38 | struct clk *oscclk; | ||
| 39 | struct clk *clk[MAX_CLK_PER_DOMAIN]; | ||
| 40 | struct clk *pclk[MAX_CLK_PER_DOMAIN]; | ||
| 35 | }; | 41 | }; |
| 36 | 42 | ||
| 37 | static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) | 43 | static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) |
| @@ -44,6 +50,19 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) | |||
| 44 | pd = container_of(domain, struct exynos_pm_domain, pd); | 50 | pd = container_of(domain, struct exynos_pm_domain, pd); |
| 45 | base = pd->base; | 51 | base = pd->base; |
| 46 | 52 | ||
| 53 | /* Set oscclk before powering off a domain*/ | ||
| 54 | if (!power_on) { | ||
| 55 | int i; | ||
| 56 | |||
| 57 | for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) { | ||
| 58 | if (IS_ERR(pd->clk[i])) | ||
| 59 | break; | ||
| 60 | if (clk_set_parent(pd->clk[i], pd->oscclk)) | ||
| 61 | pr_err("%s: error setting oscclk as parent to clock %d\n", | ||
| 62 | pd->name, i); | ||
| 63 | } | ||
| 64 | } | ||
| 65 | |||
| 47 | pwr = power_on ? S5P_INT_LOCAL_PWR_EN : 0; | 66 | pwr = power_on ? S5P_INT_LOCAL_PWR_EN : 0; |
| 48 | __raw_writel(pwr, base); | 67 | __raw_writel(pwr, base); |
| 49 | 68 | ||
| @@ -60,6 +79,20 @@ static int exynos_pd_power(struct generic_pm_domain *domain, bool power_on) | |||
| 60 | cpu_relax(); | 79 | cpu_relax(); |
| 61 | usleep_range(80, 100); | 80 | usleep_range(80, 100); |
| 62 | } | 81 | } |
| 82 | |||
| 83 | /* Restore clocks after powering on a domain*/ | ||
| 84 | if (power_on) { | ||
| 85 | int i; | ||
| 86 | |||
| 87 | for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) { | ||
| 88 | if (IS_ERR(pd->clk[i])) | ||
| 89 | break; | ||
| 90 | if (clk_set_parent(pd->clk[i], pd->pclk[i])) | ||
| 91 | pr_err("%s: error setting parent to clock%d\n", | ||
| 92 | pd->name, i); | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 63 | return 0; | 96 | return 0; |
| 64 | } | 97 | } |
| 65 | 98 | ||
| @@ -152,9 +185,11 @@ static __init int exynos4_pm_init_power_domain(void) | |||
| 152 | 185 | ||
| 153 | for_each_compatible_node(np, NULL, "samsung,exynos4210-pd") { | 186 | for_each_compatible_node(np, NULL, "samsung,exynos4210-pd") { |
| 154 | struct exynos_pm_domain *pd; | 187 | struct exynos_pm_domain *pd; |
| 155 | int on; | 188 | int on, i; |
| 189 | struct device *dev; | ||
| 156 | 190 | ||
| 157 | pdev = of_find_device_by_node(np); | 191 | pdev = of_find_device_by_node(np); |
| 192 | dev = &pdev->dev; | ||
| 158 | 193 | ||
| 159 | pd = kzalloc(sizeof(*pd), GFP_KERNEL); | 194 | pd = kzalloc(sizeof(*pd), GFP_KERNEL); |
| 160 | if (!pd) { | 195 | if (!pd) { |
| @@ -170,6 +205,30 @@ static __init int exynos4_pm_init_power_domain(void) | |||
| 170 | pd->pd.power_on = exynos_pd_power_on; | 205 | pd->pd.power_on = exynos_pd_power_on; |
| 171 | pd->pd.of_node = np; | 206 | pd->pd.of_node = np; |
| 172 | 207 | ||
| 208 | pd->oscclk = clk_get(dev, "oscclk"); | ||
| 209 | if (IS_ERR(pd->oscclk)) | ||
| 210 | goto no_clk; | ||
| 211 | |||
| 212 | for (i = 0; i < MAX_CLK_PER_DOMAIN; i++) { | ||
| 213 | char clk_name[8]; | ||
| 214 | |||
| 215 | snprintf(clk_name, sizeof(clk_name), "clk%d", i); | ||
| 216 | pd->clk[i] = clk_get(dev, clk_name); | ||
| 217 | if (IS_ERR(pd->clk[i])) | ||
| 218 | break; | ||
| 219 | snprintf(clk_name, sizeof(clk_name), "pclk%d", i); | ||
| 220 | pd->pclk[i] = clk_get(dev, clk_name); | ||
| 221 | if (IS_ERR(pd->pclk[i])) { | ||
| 222 | clk_put(pd->clk[i]); | ||
| 223 | pd->clk[i] = ERR_PTR(-EINVAL); | ||
| 224 | break; | ||
| 225 | } | ||
| 226 | } | ||
| 227 | |||
| 228 | if (IS_ERR(pd->clk[0])) | ||
| 229 | clk_put(pd->oscclk); | ||
| 230 | |||
| 231 | no_clk: | ||
| 173 | platform_set_drvdata(pdev, pd); | 232 | platform_set_drvdata(pdev, pd); |
| 174 | 233 | ||
| 175 | on = __raw_readl(pd->base + 0x4) & S5P_INT_LOCAL_PWR_EN; | 234 | on = __raw_readl(pd->base + 0x4) & S5P_INT_LOCAL_PWR_EN; |
diff --git a/arch/arm/mach-imx/clk-gate2.c b/arch/arm/mach-imx/clk-gate2.c index 4ba587da89d2..84acdfd1d715 100644 --- a/arch/arm/mach-imx/clk-gate2.c +++ b/arch/arm/mach-imx/clk-gate2.c | |||
| @@ -67,8 +67,12 @@ static void clk_gate2_disable(struct clk_hw *hw) | |||
| 67 | 67 | ||
| 68 | spin_lock_irqsave(gate->lock, flags); | 68 | spin_lock_irqsave(gate->lock, flags); |
| 69 | 69 | ||
| 70 | if (gate->share_count && --(*gate->share_count) > 0) | 70 | if (gate->share_count) { |
| 71 | goto out; | 71 | if (WARN_ON(*gate->share_count == 0)) |
| 72 | goto out; | ||
| 73 | else if (--(*gate->share_count) > 0) | ||
| 74 | goto out; | ||
| 75 | } | ||
| 72 | 76 | ||
| 73 | reg = readl(gate->reg); | 77 | reg = readl(gate->reg); |
| 74 | reg &= ~(3 << gate->bit_idx); | 78 | reg &= ~(3 << gate->bit_idx); |
| @@ -78,19 +82,26 @@ out: | |||
| 78 | spin_unlock_irqrestore(gate->lock, flags); | 82 | spin_unlock_irqrestore(gate->lock, flags); |
| 79 | } | 83 | } |
| 80 | 84 | ||
| 81 | static int clk_gate2_is_enabled(struct clk_hw *hw) | 85 | static int clk_gate2_reg_is_enabled(void __iomem *reg, u8 bit_idx) |
| 82 | { | 86 | { |
| 83 | u32 reg; | 87 | u32 val = readl(reg); |
| 84 | struct clk_gate2 *gate = to_clk_gate2(hw); | ||
| 85 | 88 | ||
| 86 | reg = readl(gate->reg); | 89 | if (((val >> bit_idx) & 1) == 1) |
| 87 | |||
| 88 | if (((reg >> gate->bit_idx) & 1) == 1) | ||
| 89 | return 1; | 90 | return 1; |
| 90 | 91 | ||
| 91 | return 0; | 92 | return 0; |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 95 | static int clk_gate2_is_enabled(struct clk_hw *hw) | ||
| 96 | { | ||
| 97 | struct clk_gate2 *gate = to_clk_gate2(hw); | ||
| 98 | |||
| 99 | if (gate->share_count) | ||
| 100 | return !!(*gate->share_count); | ||
| 101 | else | ||
| 102 | return clk_gate2_reg_is_enabled(gate->reg, gate->bit_idx); | ||
| 103 | } | ||
| 104 | |||
| 94 | static struct clk_ops clk_gate2_ops = { | 105 | static struct clk_ops clk_gate2_ops = { |
| 95 | .enable = clk_gate2_enable, | 106 | .enable = clk_gate2_enable, |
| 96 | .disable = clk_gate2_disable, | 107 | .disable = clk_gate2_disable, |
| @@ -116,6 +127,10 @@ struct clk *clk_register_gate2(struct device *dev, const char *name, | |||
| 116 | gate->bit_idx = bit_idx; | 127 | gate->bit_idx = bit_idx; |
| 117 | gate->flags = clk_gate2_flags; | 128 | gate->flags = clk_gate2_flags; |
| 118 | gate->lock = lock; | 129 | gate->lock = lock; |
| 130 | |||
| 131 | /* Initialize share_count per hardware state */ | ||
| 132 | if (share_count) | ||
| 133 | *share_count = clk_gate2_reg_is_enabled(reg, bit_idx) ? 1 : 0; | ||
| 119 | gate->share_count = share_count; | 134 | gate->share_count = share_count; |
| 120 | 135 | ||
| 121 | init.name = name; | 136 | init.name = name; |
diff --git a/arch/arm/mach-imx/clk-imx6q.c b/arch/arm/mach-imx/clk-imx6q.c index 8e795dea02ec..8556c787e59c 100644 --- a/arch/arm/mach-imx/clk-imx6q.c +++ b/arch/arm/mach-imx/clk-imx6q.c | |||
| @@ -70,7 +70,7 @@ static const char *cko_sels[] = { "cko1", "cko2", }; | |||
| 70 | static const char *lvds_sels[] = { | 70 | static const char *lvds_sels[] = { |
| 71 | "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", | 71 | "dummy", "dummy", "dummy", "dummy", "dummy", "dummy", |
| 72 | "pll4_audio", "pll5_video", "pll8_mlb", "enet_ref", | 72 | "pll4_audio", "pll5_video", "pll8_mlb", "enet_ref", |
| 73 | "pcie_ref", "sata_ref", | 73 | "pcie_ref_125m", "sata_ref_100m", |
| 74 | }; | 74 | }; |
| 75 | 75 | ||
| 76 | enum mx6q_clks { | 76 | enum mx6q_clks { |
| @@ -491,7 +491,7 @@ static void __init imx6q_clocks_init(struct device_node *ccm_node) | |||
| 491 | 491 | ||
| 492 | /* All existing boards with PCIe use LVDS1 */ | 492 | /* All existing boards with PCIe use LVDS1 */ |
| 493 | if (IS_ENABLED(CONFIG_PCI_IMX6)) | 493 | if (IS_ENABLED(CONFIG_PCI_IMX6)) |
| 494 | clk_set_parent(clk[lvds1_sel], clk[sata_ref]); | 494 | clk_set_parent(clk[lvds1_sel], clk[sata_ref_100m]); |
| 495 | 495 | ||
| 496 | /* Set initial power mode */ | 496 | /* Set initial power mode */ |
| 497 | imx6q_set_lpm(WAIT_CLOCKED); | 497 | imx6q_set_lpm(WAIT_CLOCKED); |
diff --git a/arch/arm/mach-mvebu/coherency.c b/arch/arm/mach-mvebu/coherency.c index 477202fd39cc..2bdc3233abe2 100644 --- a/arch/arm/mach-mvebu/coherency.c +++ b/arch/arm/mach-mvebu/coherency.c | |||
| @@ -292,6 +292,10 @@ static struct notifier_block mvebu_hwcc_nb = { | |||
| 292 | .notifier_call = mvebu_hwcc_notifier, | 292 | .notifier_call = mvebu_hwcc_notifier, |
| 293 | }; | 293 | }; |
| 294 | 294 | ||
| 295 | static struct notifier_block mvebu_hwcc_pci_nb = { | ||
| 296 | .notifier_call = mvebu_hwcc_notifier, | ||
| 297 | }; | ||
| 298 | |||
| 295 | static void __init armada_370_coherency_init(struct device_node *np) | 299 | static void __init armada_370_coherency_init(struct device_node *np) |
| 296 | { | 300 | { |
| 297 | struct resource res; | 301 | struct resource res; |
| @@ -427,7 +431,7 @@ static int __init coherency_pci_init(void) | |||
| 427 | { | 431 | { |
| 428 | if (coherency_available()) | 432 | if (coherency_available()) |
| 429 | bus_register_notifier(&pci_bus_type, | 433 | bus_register_notifier(&pci_bus_type, |
| 430 | &mvebu_hwcc_nb); | 434 | &mvebu_hwcc_pci_nb); |
| 431 | return 0; | 435 | return 0; |
| 432 | } | 436 | } |
| 433 | 437 | ||
diff --git a/arch/arm/mach-mvebu/headsmp-a9.S b/arch/arm/mach-mvebu/headsmp-a9.S index 5925366bc03c..da5bb292b91c 100644 --- a/arch/arm/mach-mvebu/headsmp-a9.S +++ b/arch/arm/mach-mvebu/headsmp-a9.S | |||
| @@ -15,6 +15,8 @@ | |||
| 15 | #include <linux/linkage.h> | 15 | #include <linux/linkage.h> |
| 16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
| 17 | 17 | ||
| 18 | #include <asm/assembler.h> | ||
| 19 | |||
| 18 | __CPUINIT | 20 | __CPUINIT |
| 19 | #define CPU_RESUME_ADDR_REG 0xf10182d4 | 21 | #define CPU_RESUME_ADDR_REG 0xf10182d4 |
| 20 | 22 | ||
| @@ -22,13 +24,18 @@ | |||
| 22 | .global armada_375_smp_cpu1_enable_code_end | 24 | .global armada_375_smp_cpu1_enable_code_end |
| 23 | 25 | ||
| 24 | armada_375_smp_cpu1_enable_code_start: | 26 | armada_375_smp_cpu1_enable_code_start: |
| 25 | ldr r0, [pc, #4] | 27 | ARM_BE8(setend be) |
| 28 | adr r0, 1f | ||
| 29 | ldr r0, [r0] | ||
| 26 | ldr r1, [r0] | 30 | ldr r1, [r0] |
| 31 | ARM_BE8(rev r1, r1) | ||
| 27 | mov pc, r1 | 32 | mov pc, r1 |
| 33 | 1: | ||
| 28 | .word CPU_RESUME_ADDR_REG | 34 | .word CPU_RESUME_ADDR_REG |
| 29 | armada_375_smp_cpu1_enable_code_end: | 35 | armada_375_smp_cpu1_enable_code_end: |
| 30 | 36 | ||
| 31 | ENTRY(mvebu_cortex_a9_secondary_startup) | 37 | ENTRY(mvebu_cortex_a9_secondary_startup) |
| 38 | ARM_BE8(setend be) | ||
| 32 | bl v7_invalidate_l1 | 39 | bl v7_invalidate_l1 |
| 33 | b secondary_startup | 40 | b secondary_startup |
| 34 | ENDPROC(mvebu_cortex_a9_secondary_startup) | 41 | ENDPROC(mvebu_cortex_a9_secondary_startup) |
diff --git a/arch/arm/mach-mvebu/pmsu.c b/arch/arm/mach-mvebu/pmsu.c index a1d407c0febe..25aa8237d668 100644 --- a/arch/arm/mach-mvebu/pmsu.c +++ b/arch/arm/mach-mvebu/pmsu.c | |||
| @@ -201,12 +201,12 @@ static noinline int do_armada_370_xp_cpu_suspend(unsigned long deepidle) | |||
| 201 | 201 | ||
| 202 | /* Test the CR_C bit and set it if it was cleared */ | 202 | /* Test the CR_C bit and set it if it was cleared */ |
| 203 | asm volatile( | 203 | asm volatile( |
| 204 | "mrc p15, 0, %0, c1, c0, 0 \n\t" | 204 | "mrc p15, 0, r0, c1, c0, 0 \n\t" |
| 205 | "tst %0, #(1 << 2) \n\t" | 205 | "tst r0, #(1 << 2) \n\t" |
| 206 | "orreq %0, %0, #(1 << 2) \n\t" | 206 | "orreq r0, r0, #(1 << 2) \n\t" |
| 207 | "mcreq p15, 0, %0, c1, c0, 0 \n\t" | 207 | "mcreq p15, 0, r0, c1, c0, 0 \n\t" |
| 208 | "isb " | 208 | "isb " |
| 209 | : : "r" (0)); | 209 | : : : "r0"); |
| 210 | 210 | ||
| 211 | pr_warn("Failed to suspend the system\n"); | 211 | pr_warn("Failed to suspend the system\n"); |
| 212 | 212 | ||
diff --git a/arch/arm/mach-omap2/clkt_dpll.c b/arch/arm/mach-omap2/clkt_dpll.c index 332af927f4d3..67fd26a18441 100644 --- a/arch/arm/mach-omap2/clkt_dpll.c +++ b/arch/arm/mach-omap2/clkt_dpll.c | |||
| @@ -76,7 +76,7 @@ | |||
| 76 | * (assuming that it is counting N upwards), or -2 if the enclosing loop | 76 | * (assuming that it is counting N upwards), or -2 if the enclosing loop |
| 77 | * should skip to the next iteration (again assuming N is increasing). | 77 | * should skip to the next iteration (again assuming N is increasing). |
| 78 | */ | 78 | */ |
| 79 | static int _dpll_test_fint(struct clk_hw_omap *clk, u8 n) | 79 | static int _dpll_test_fint(struct clk_hw_omap *clk, unsigned int n) |
| 80 | { | 80 | { |
| 81 | struct dpll_data *dd; | 81 | struct dpll_data *dd; |
| 82 | long fint, fint_min, fint_max; | 82 | long fint, fint_min, fint_max; |
diff --git a/arch/arm/mach-omap2/cm-regbits-34xx.h b/arch/arm/mach-omap2/cm-regbits-34xx.h index 04dab2fcf862..ee6c784cd6b7 100644 --- a/arch/arm/mach-omap2/cm-regbits-34xx.h +++ b/arch/arm/mach-omap2/cm-regbits-34xx.h | |||
| @@ -26,11 +26,14 @@ | |||
| 26 | #define OMAP3430_EN_WDT3_SHIFT 12 | 26 | #define OMAP3430_EN_WDT3_SHIFT 12 |
| 27 | #define OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_MASK (1 << 0) | 27 | #define OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_MASK (1 << 0) |
| 28 | #define OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_SHIFT 0 | 28 | #define OMAP3430_CM_FCLKEN_IVA2_EN_IVA2_SHIFT 0 |
| 29 | #define OMAP3430_IVA2_DPLL_FREQSEL_SHIFT 4 | ||
| 29 | #define OMAP3430_IVA2_DPLL_FREQSEL_MASK (0xf << 4) | 30 | #define OMAP3430_IVA2_DPLL_FREQSEL_MASK (0xf << 4) |
| 30 | #define OMAP3430_EN_IVA2_DPLL_DRIFTGUARD_SHIFT 3 | 31 | #define OMAP3430_EN_IVA2_DPLL_DRIFTGUARD_SHIFT 3 |
| 32 | #define OMAP3430_EN_IVA2_DPLL_SHIFT 0 | ||
| 31 | #define OMAP3430_EN_IVA2_DPLL_MASK (0x7 << 0) | 33 | #define OMAP3430_EN_IVA2_DPLL_MASK (0x7 << 0) |
| 32 | #define OMAP3430_ST_IVA2_SHIFT 0 | 34 | #define OMAP3430_ST_IVA2_SHIFT 0 |
| 33 | #define OMAP3430_ST_IVA2_CLK_MASK (1 << 0) | 35 | #define OMAP3430_ST_IVA2_CLK_MASK (1 << 0) |
| 36 | #define OMAP3430_AUTO_IVA2_DPLL_SHIFT 0 | ||
| 34 | #define OMAP3430_AUTO_IVA2_DPLL_MASK (0x7 << 0) | 37 | #define OMAP3430_AUTO_IVA2_DPLL_MASK (0x7 << 0) |
| 35 | #define OMAP3430_IVA2_CLK_SRC_SHIFT 19 | 38 | #define OMAP3430_IVA2_CLK_SRC_SHIFT 19 |
| 36 | #define OMAP3430_IVA2_CLK_SRC_WIDTH 3 | 39 | #define OMAP3430_IVA2_CLK_SRC_WIDTH 3 |
diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index b2d252bf4a53..dc571f1d3b8a 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h | |||
| @@ -162,7 +162,8 @@ static inline void omap3xxx_restart(enum reboot_mode mode, const char *cmd) | |||
| 162 | } | 162 | } |
| 163 | #endif | 163 | #endif |
| 164 | 164 | ||
| 165 | #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) | 165 | #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \ |
| 166 | defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM43XX) | ||
| 166 | void omap44xx_restart(enum reboot_mode mode, const char *cmd); | 167 | void omap44xx_restart(enum reboot_mode mode, const char *cmd); |
| 167 | #else | 168 | #else |
| 168 | static inline void omap44xx_restart(enum reboot_mode mode, const char *cmd) | 169 | static inline void omap44xx_restart(enum reboot_mode mode, const char *cmd) |
diff --git a/arch/arm/mach-omap2/devices.c b/arch/arm/mach-omap2/devices.c index 592ba0a0ecf3..b6f8f348296e 100644 --- a/arch/arm/mach-omap2/devices.c +++ b/arch/arm/mach-omap2/devices.c | |||
| @@ -297,33 +297,6 @@ static void omap_init_audio(void) | |||
| 297 | static inline void omap_init_audio(void) {} | 297 | static inline void omap_init_audio(void) {} |
| 298 | #endif | 298 | #endif |
| 299 | 299 | ||
| 300 | #if defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI) || \ | ||
| 301 | defined(CONFIG_SND_OMAP_SOC_OMAP_HDMI_MODULE) | ||
| 302 | |||
| 303 | static struct platform_device omap_hdmi_audio = { | ||
| 304 | .name = "omap-hdmi-audio", | ||
| 305 | .id = -1, | ||
| 306 | }; | ||
| 307 | |||
| 308 | static void __init omap_init_hdmi_audio(void) | ||
| 309 | { | ||
| 310 | struct omap_hwmod *oh; | ||
| 311 | struct platform_device *pdev; | ||
| 312 | |||
| 313 | oh = omap_hwmod_lookup("dss_hdmi"); | ||
| 314 | if (!oh) | ||
| 315 | return; | ||
| 316 | |||
| 317 | pdev = omap_device_build("omap-hdmi-audio-dai", -1, oh, NULL, 0); | ||
| 318 | WARN(IS_ERR(pdev), | ||
| 319 | "Can't build omap_device for omap-hdmi-audio-dai.\n"); | ||
| 320 | |||
| 321 | platform_device_register(&omap_hdmi_audio); | ||
| 322 | } | ||
| 323 | #else | ||
| 324 | static inline void omap_init_hdmi_audio(void) {} | ||
| 325 | #endif | ||
| 326 | |||
| 327 | #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE) | 300 | #if defined(CONFIG_SPI_OMAP24XX) || defined(CONFIG_SPI_OMAP24XX_MODULE) |
| 328 | 301 | ||
| 329 | #include <linux/platform_data/spi-omap2-mcspi.h> | 302 | #include <linux/platform_data/spi-omap2-mcspi.h> |
| @@ -459,7 +432,6 @@ static int __init omap2_init_devices(void) | |||
| 459 | */ | 432 | */ |
| 460 | omap_init_audio(); | 433 | omap_init_audio(); |
| 461 | omap_init_camera(); | 434 | omap_init_camera(); |
| 462 | omap_init_hdmi_audio(); | ||
| 463 | omap_init_mbox(); | 435 | omap_init_mbox(); |
| 464 | /* If dtb is there, the devices will be created dynamically */ | 436 | /* If dtb is there, the devices will be created dynamically */ |
| 465 | if (!of_have_populated_dt()) { | 437 | if (!of_have_populated_dt()) { |
diff --git a/arch/arm/mach-omap2/dsp.c b/arch/arm/mach-omap2/dsp.c index b8208b4b1bd9..f7492df1cbba 100644 --- a/arch/arm/mach-omap2/dsp.c +++ b/arch/arm/mach-omap2/dsp.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #ifdef CONFIG_TIDSPBRIDGE_DVFS | 29 | #ifdef CONFIG_TIDSPBRIDGE_DVFS |
| 30 | #include "omap-pm.h" | 30 | #include "omap-pm.h" |
| 31 | #endif | 31 | #endif |
| 32 | #include "soc.h" | ||
| 32 | 33 | ||
| 33 | #include <linux/platform_data/dsp-omap.h> | 34 | #include <linux/platform_data/dsp-omap.h> |
| 34 | 35 | ||
| @@ -59,6 +60,9 @@ void __init omap_dsp_reserve_sdram_memblock(void) | |||
| 59 | phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE; | 60 | phys_addr_t size = CONFIG_TIDSPBRIDGE_MEMPOOL_SIZE; |
| 60 | phys_addr_t paddr; | 61 | phys_addr_t paddr; |
| 61 | 62 | ||
| 63 | if (!cpu_is_omap34xx()) | ||
| 64 | return; | ||
| 65 | |||
| 62 | if (!size) | 66 | if (!size) |
| 63 | return; | 67 | return; |
| 64 | 68 | ||
| @@ -83,6 +87,9 @@ static int __init omap_dsp_init(void) | |||
| 83 | int err = -ENOMEM; | 87 | int err = -ENOMEM; |
| 84 | struct omap_dsp_platform_data *pdata = &omap_dsp_pdata; | 88 | struct omap_dsp_platform_data *pdata = &omap_dsp_pdata; |
| 85 | 89 | ||
| 90 | if (!cpu_is_omap34xx()) | ||
| 91 | return 0; | ||
| 92 | |||
| 86 | pdata->phys_mempool_base = omap_dsp_get_mempool_base(); | 93 | pdata->phys_mempool_base = omap_dsp_get_mempool_base(); |
| 87 | 94 | ||
| 88 | if (pdata->phys_mempool_base) { | 95 | if (pdata->phys_mempool_base) { |
| @@ -115,6 +122,9 @@ module_init(omap_dsp_init); | |||
| 115 | 122 | ||
| 116 | static void __exit omap_dsp_exit(void) | 123 | static void __exit omap_dsp_exit(void) |
| 117 | { | 124 | { |
| 125 | if (!cpu_is_omap34xx()) | ||
| 126 | return; | ||
| 127 | |||
| 118 | platform_device_unregister(omap_dsp_pdev); | 128 | platform_device_unregister(omap_dsp_pdev); |
| 119 | } | 129 | } |
| 120 | module_exit(omap_dsp_exit); | 130 | module_exit(omap_dsp_exit); |
diff --git a/arch/arm/mach-omap2/gpmc-nand.c b/arch/arm/mach-omap2/gpmc-nand.c index 17cd39360afe..93914d220069 100644 --- a/arch/arm/mach-omap2/gpmc-nand.c +++ b/arch/arm/mach-omap2/gpmc-nand.c | |||
| @@ -50,6 +50,16 @@ static bool gpmc_hwecc_bch_capable(enum omap_ecc ecc_opt) | |||
| 50 | soc_is_omap54xx() || soc_is_dra7xx()) | 50 | soc_is_omap54xx() || soc_is_dra7xx()) |
| 51 | return 1; | 51 | return 1; |
| 52 | 52 | ||
| 53 | if (ecc_opt == OMAP_ECC_BCH4_CODE_HW_DETECTION_SW || | ||
| 54 | ecc_opt == OMAP_ECC_BCH8_CODE_HW_DETECTION_SW) { | ||
| 55 | if (cpu_is_omap24xx()) | ||
| 56 | return 0; | ||
| 57 | else if (cpu_is_omap3630() && (GET_OMAP_REVISION() == 0)) | ||
| 58 | return 0; | ||
| 59 | else | ||
| 60 | return 1; | ||
| 61 | } | ||
| 62 | |||
| 53 | /* OMAP3xxx do not have ELM engine, so cannot support ECC schemes | 63 | /* OMAP3xxx do not have ELM engine, so cannot support ECC schemes |
| 54 | * which require H/W based ECC error detection */ | 64 | * which require H/W based ECC error detection */ |
| 55 | if ((cpu_is_omap34xx() || cpu_is_omap3630()) && | 65 | if ((cpu_is_omap34xx() || cpu_is_omap3630()) && |
| @@ -57,14 +67,6 @@ static bool gpmc_hwecc_bch_capable(enum omap_ecc ecc_opt) | |||
| 57 | (ecc_opt == OMAP_ECC_BCH8_CODE_HW))) | 67 | (ecc_opt == OMAP_ECC_BCH8_CODE_HW))) |
| 58 | return 0; | 68 | return 0; |
| 59 | 69 | ||
| 60 | /* | ||
| 61 | * For now, assume 4-bit mode is only supported on OMAP3630 ES1.x, x>=1 | ||
| 62 | * and AM33xx derivates. Other chips may be added if confirmed to work. | ||
| 63 | */ | ||
| 64 | if ((ecc_opt == OMAP_ECC_BCH4_CODE_HW_DETECTION_SW) && | ||
| 65 | (!cpu_is_omap3630() || (GET_OMAP_REVISION() == 0))) | ||
| 66 | return 0; | ||
| 67 | |||
| 68 | /* legacy platforms support only HAM1 (1-bit Hamming) ECC scheme */ | 70 | /* legacy platforms support only HAM1 (1-bit Hamming) ECC scheme */ |
| 69 | if (ecc_opt == OMAP_ECC_HAM1_CODE_HW) | 71 | if (ecc_opt == OMAP_ECC_HAM1_CODE_HW) |
| 70 | return 1; | 72 | return 1; |
diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 2c0c2816900f..8bc13380f0a0 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c | |||
| @@ -1615,7 +1615,7 @@ static int gpmc_probe_dt(struct platform_device *pdev) | |||
| 1615 | return ret; | 1615 | return ret; |
| 1616 | } | 1616 | } |
| 1617 | 1617 | ||
| 1618 | for_each_child_of_node(pdev->dev.of_node, child) { | 1618 | for_each_available_child_of_node(pdev->dev.of_node, child) { |
| 1619 | 1619 | ||
| 1620 | if (!child->name) | 1620 | if (!child->name) |
| 1621 | continue; | 1621 | continue; |
diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c index 539e8106eb96..a0fe747634c1 100644 --- a/arch/arm/mach-omap2/omap4-common.c +++ b/arch/arm/mach-omap2/omap4-common.c | |||
| @@ -168,6 +168,10 @@ static void omap4_l2c310_write_sec(unsigned long val, unsigned reg) | |||
| 168 | smc_op = OMAP4_MON_L2X0_PREFETCH_INDEX; | 168 | smc_op = OMAP4_MON_L2X0_PREFETCH_INDEX; |
| 169 | break; | 169 | break; |
| 170 | 170 | ||
| 171 | case L310_POWER_CTRL: | ||
| 172 | pr_info_once("OMAP L2C310: ROM does not support power control setting\n"); | ||
| 173 | return; | ||
| 174 | |||
| 171 | default: | 175 | default: |
| 172 | WARN_ONCE(1, "OMAP L2C310: ignoring write to reg 0x%x\n", reg); | 176 | WARN_ONCE(1, "OMAP L2C310: ignoring write to reg 0x%x\n", reg); |
| 173 | return; | 177 | return; |
diff --git a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c index 20b4398cec05..284324f2b98a 100644 --- a/arch/arm/mach-omap2/omap_hwmod_7xx_data.c +++ b/arch/arm/mach-omap2/omap_hwmod_7xx_data.c | |||
| @@ -1268,9 +1268,6 @@ static struct omap_hwmod_class dra7xx_sata_hwmod_class = { | |||
| 1268 | }; | 1268 | }; |
| 1269 | 1269 | ||
| 1270 | /* sata */ | 1270 | /* sata */ |
| 1271 | static struct omap_hwmod_opt_clk sata_opt_clks[] = { | ||
| 1272 | { .role = "ref_clk", .clk = "sata_ref_clk" }, | ||
| 1273 | }; | ||
| 1274 | 1271 | ||
| 1275 | static struct omap_hwmod dra7xx_sata_hwmod = { | 1272 | static struct omap_hwmod dra7xx_sata_hwmod = { |
| 1276 | .name = "sata", | 1273 | .name = "sata", |
| @@ -1278,6 +1275,7 @@ static struct omap_hwmod dra7xx_sata_hwmod = { | |||
| 1278 | .clkdm_name = "l3init_clkdm", | 1275 | .clkdm_name = "l3init_clkdm", |
| 1279 | .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY, | 1276 | .flags = HWMOD_SWSUP_SIDLE | HWMOD_SWSUP_MSTANDBY, |
| 1280 | .main_clk = "func_48m_fclk", | 1277 | .main_clk = "func_48m_fclk", |
| 1278 | .mpu_rt_idx = 1, | ||
| 1281 | .prcm = { | 1279 | .prcm = { |
| 1282 | .omap4 = { | 1280 | .omap4 = { |
| 1283 | .clkctrl_offs = DRA7XX_CM_L3INIT_SATA_CLKCTRL_OFFSET, | 1281 | .clkctrl_offs = DRA7XX_CM_L3INIT_SATA_CLKCTRL_OFFSET, |
| @@ -1285,8 +1283,6 @@ static struct omap_hwmod dra7xx_sata_hwmod = { | |||
| 1285 | .modulemode = MODULEMODE_SWCTRL, | 1283 | .modulemode = MODULEMODE_SWCTRL, |
| 1286 | }, | 1284 | }, |
| 1287 | }, | 1285 | }, |
| 1288 | .opt_clks = sata_opt_clks, | ||
| 1289 | .opt_clks_cnt = ARRAY_SIZE(sata_opt_clks), | ||
| 1290 | }; | 1286 | }; |
| 1291 | 1287 | ||
| 1292 | /* | 1288 | /* |
| @@ -1731,8 +1727,20 @@ static struct omap_hwmod dra7xx_uart6_hwmod = { | |||
| 1731 | * | 1727 | * |
| 1732 | */ | 1728 | */ |
| 1733 | 1729 | ||
| 1730 | static struct omap_hwmod_class_sysconfig dra7xx_usb_otg_ss_sysc = { | ||
| 1731 | .rev_offs = 0x0000, | ||
| 1732 | .sysc_offs = 0x0010, | ||
| 1733 | .sysc_flags = (SYSC_HAS_DMADISABLE | SYSC_HAS_MIDLEMODE | | ||
| 1734 | SYSC_HAS_SIDLEMODE), | ||
| 1735 | .idlemodes = (SIDLE_FORCE | SIDLE_NO | SIDLE_SMART | | ||
| 1736 | SIDLE_SMART_WKUP | MSTANDBY_FORCE | MSTANDBY_NO | | ||
| 1737 | MSTANDBY_SMART | MSTANDBY_SMART_WKUP), | ||
| 1738 | .sysc_fields = &omap_hwmod_sysc_type2, | ||
| 1739 | }; | ||
| 1740 | |||
| 1734 | static struct omap_hwmod_class dra7xx_usb_otg_ss_hwmod_class = { | 1741 | static struct omap_hwmod_class dra7xx_usb_otg_ss_hwmod_class = { |
| 1735 | .name = "usb_otg_ss", | 1742 | .name = "usb_otg_ss", |
| 1743 | .sysc = &dra7xx_usb_otg_ss_sysc, | ||
| 1736 | }; | 1744 | }; |
| 1737 | 1745 | ||
| 1738 | /* usb_otg_ss1 */ | 1746 | /* usb_otg_ss1 */ |
diff --git a/arch/arm/mach-omap2/prm-regbits-34xx.h b/arch/arm/mach-omap2/prm-regbits-34xx.h index 106132db532b..cbefbd7cfdb5 100644 --- a/arch/arm/mach-omap2/prm-regbits-34xx.h +++ b/arch/arm/mach-omap2/prm-regbits-34xx.h | |||
| @@ -35,6 +35,8 @@ | |||
| 35 | #define OMAP3430_LOGICSTATEST_MASK (1 << 2) | 35 | #define OMAP3430_LOGICSTATEST_MASK (1 << 2) |
| 36 | #define OMAP3430_LASTLOGICSTATEENTERED_MASK (1 << 2) | 36 | #define OMAP3430_LASTLOGICSTATEENTERED_MASK (1 << 2) |
| 37 | #define OMAP3430_LASTPOWERSTATEENTERED_MASK (0x3 << 0) | 37 | #define OMAP3430_LASTPOWERSTATEENTERED_MASK (0x3 << 0) |
| 38 | #define OMAP3430_GRPSEL_MCBSP5_MASK (1 << 10) | ||
| 39 | #define OMAP3430_GRPSEL_MCBSP1_MASK (1 << 9) | ||
| 38 | #define OMAP3630_GRPSEL_UART4_MASK (1 << 18) | 40 | #define OMAP3630_GRPSEL_UART4_MASK (1 << 18) |
| 39 | #define OMAP3430_GRPSEL_GPIO6_MASK (1 << 17) | 41 | #define OMAP3430_GRPSEL_GPIO6_MASK (1 << 17) |
| 40 | #define OMAP3430_GRPSEL_GPIO5_MASK (1 << 16) | 42 | #define OMAP3430_GRPSEL_GPIO5_MASK (1 << 16) |
| @@ -42,6 +44,10 @@ | |||
| 42 | #define OMAP3430_GRPSEL_GPIO3_MASK (1 << 14) | 44 | #define OMAP3430_GRPSEL_GPIO3_MASK (1 << 14) |
| 43 | #define OMAP3430_GRPSEL_GPIO2_MASK (1 << 13) | 45 | #define OMAP3430_GRPSEL_GPIO2_MASK (1 << 13) |
| 44 | #define OMAP3430_GRPSEL_UART3_MASK (1 << 11) | 46 | #define OMAP3430_GRPSEL_UART3_MASK (1 << 11) |
| 47 | #define OMAP3430_GRPSEL_GPT8_MASK (1 << 9) | ||
| 48 | #define OMAP3430_GRPSEL_GPT7_MASK (1 << 8) | ||
| 49 | #define OMAP3430_GRPSEL_GPT6_MASK (1 << 7) | ||
| 50 | #define OMAP3430_GRPSEL_GPT5_MASK (1 << 6) | ||
| 45 | #define OMAP3430_GRPSEL_MCBSP4_MASK (1 << 2) | 51 | #define OMAP3430_GRPSEL_MCBSP4_MASK (1 << 2) |
| 46 | #define OMAP3430_GRPSEL_MCBSP3_MASK (1 << 1) | 52 | #define OMAP3430_GRPSEL_MCBSP3_MASK (1 << 1) |
| 47 | #define OMAP3430_GRPSEL_MCBSP2_MASK (1 << 0) | 53 | #define OMAP3430_GRPSEL_MCBSP2_MASK (1 << 0) |
diff --git a/arch/arm/mach-shmobile/board-armadillo800eva.c b/arch/arm/mach-shmobile/board-armadillo800eva.c index 30fcac73a540..689c121157ec 100644 --- a/arch/arm/mach-shmobile/board-armadillo800eva.c +++ b/arch/arm/mach-shmobile/board-armadillo800eva.c | |||
| @@ -998,6 +998,8 @@ static struct platform_device fsi_wm8978_device = { | |||
| 998 | .id = 0, | 998 | .id = 0, |
| 999 | .dev = { | 999 | .dev = { |
| 1000 | .platform_data = &fsi_wm8978_info, | 1000 | .platform_data = &fsi_wm8978_info, |
| 1001 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 1002 | .dma_mask = &fsi_wm8978_device.dev.coherent_dma_mask, | ||
| 1001 | }, | 1003 | }, |
| 1002 | }; | 1004 | }; |
| 1003 | 1005 | ||
| @@ -1021,6 +1023,8 @@ static struct platform_device fsi_hdmi_device = { | |||
| 1021 | .id = 1, | 1023 | .id = 1, |
| 1022 | .dev = { | 1024 | .dev = { |
| 1023 | .platform_data = &fsi2_hdmi_info, | 1025 | .platform_data = &fsi2_hdmi_info, |
| 1026 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 1027 | .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask, | ||
| 1024 | }, | 1028 | }, |
| 1025 | }; | 1029 | }; |
| 1026 | 1030 | ||
diff --git a/arch/arm/mach-shmobile/board-kzm9g.c b/arch/arm/mach-shmobile/board-kzm9g.c index f94ec8ca42c1..01e0d1386db7 100644 --- a/arch/arm/mach-shmobile/board-kzm9g.c +++ b/arch/arm/mach-shmobile/board-kzm9g.c | |||
| @@ -603,6 +603,8 @@ static struct platform_device fsi_ak4648_device = { | |||
| 603 | .name = "asoc-simple-card", | 603 | .name = "asoc-simple-card", |
| 604 | .dev = { | 604 | .dev = { |
| 605 | .platform_data = &fsi2_ak4648_info, | 605 | .platform_data = &fsi2_ak4648_info, |
| 606 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 607 | .dma_mask = &fsi_ak4648_device.dev.coherent_dma_mask, | ||
| 606 | }, | 608 | }, |
| 607 | }; | 609 | }; |
| 608 | 610 | ||
diff --git a/arch/arm/mach-shmobile/board-mackerel.c b/arch/arm/mach-shmobile/board-mackerel.c index 0ff4d8e45cf7..112553f0f9bf 100644 --- a/arch/arm/mach-shmobile/board-mackerel.c +++ b/arch/arm/mach-shmobile/board-mackerel.c | |||
| @@ -523,6 +523,8 @@ static struct platform_device fsi_hdmi_device = { | |||
| 523 | .id = 1, | 523 | .id = 1, |
| 524 | .dev = { | 524 | .dev = { |
| 525 | .platform_data = &fsi2_hdmi_info, | 525 | .platform_data = &fsi2_hdmi_info, |
| 526 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 527 | .dma_mask = &fsi_hdmi_device.dev.coherent_dma_mask, | ||
| 526 | }, | 528 | }, |
| 527 | }; | 529 | }; |
| 528 | 530 | ||
| @@ -919,6 +921,8 @@ static struct platform_device fsi_ak4643_device = { | |||
| 919 | .name = "asoc-simple-card", | 921 | .name = "asoc-simple-card", |
| 920 | .dev = { | 922 | .dev = { |
| 921 | .platform_data = &fsi2_ak4643_info, | 923 | .platform_data = &fsi2_ak4643_info, |
| 924 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 925 | .dma_mask = &fsi_ak4643_device.dev.coherent_dma_mask, | ||
| 922 | }, | 926 | }, |
| 923 | }; | 927 | }; |
| 924 | 928 | ||
diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c index 076172b69422..7c3fb41a462e 100644 --- a/arch/arm/mm/cache-l2x0.c +++ b/arch/arm/mm/cache-l2x0.c | |||
| @@ -664,7 +664,7 @@ static int l2c310_cpu_enable_flz(struct notifier_block *nb, unsigned long act, v | |||
| 664 | 664 | ||
| 665 | static void __init l2c310_enable(void __iomem *base, u32 aux, unsigned num_lock) | 665 | static void __init l2c310_enable(void __iomem *base, u32 aux, unsigned num_lock) |
| 666 | { | 666 | { |
| 667 | unsigned rev = readl_relaxed(base + L2X0_CACHE_ID) & L2X0_CACHE_ID_PART_MASK; | 667 | unsigned rev = readl_relaxed(base + L2X0_CACHE_ID) & L2X0_CACHE_ID_RTL_MASK; |
| 668 | bool cortex_a9 = read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9; | 668 | bool cortex_a9 = read_cpuid_part_number() == ARM_CPU_PART_CORTEX_A9; |
| 669 | 669 | ||
| 670 | if (rev >= L310_CACHE_ID_RTL_R2P0) { | 670 | if (rev >= L310_CACHE_ID_RTL_R2P0) { |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 4c88935654ca..1f88db06b133 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
| @@ -461,12 +461,21 @@ void __init dma_contiguous_remap(void) | |||
| 461 | map.type = MT_MEMORY_DMA_READY; | 461 | map.type = MT_MEMORY_DMA_READY; |
| 462 | 462 | ||
| 463 | /* | 463 | /* |
| 464 | * Clear previous low-memory mapping | 464 | * Clear previous low-memory mapping to ensure that the |
| 465 | * TLB does not see any conflicting entries, then flush | ||
| 466 | * the TLB of the old entries before creating new mappings. | ||
| 467 | * | ||
| 468 | * This ensures that any speculatively loaded TLB entries | ||
| 469 | * (even though they may be rare) can not cause any problems, | ||
| 470 | * and ensures that this code is architecturally compliant. | ||
| 465 | */ | 471 | */ |
| 466 | for (addr = __phys_to_virt(start); addr < __phys_to_virt(end); | 472 | for (addr = __phys_to_virt(start); addr < __phys_to_virt(end); |
| 467 | addr += PMD_SIZE) | 473 | addr += PMD_SIZE) |
| 468 | pmd_clear(pmd_off_k(addr)); | 474 | pmd_clear(pmd_off_k(addr)); |
| 469 | 475 | ||
| 476 | flush_tlb_kernel_range(__phys_to_virt(start), | ||
| 477 | __phys_to_virt(end)); | ||
| 478 | |||
| 470 | iotable_init(&map, 1); | 479 | iotable_init(&map, 1); |
| 471 | } | 480 | } |
| 472 | } | 481 | } |
diff --git a/arch/arm/mm/idmap.c b/arch/arm/mm/idmap.c index 8e0e52eb76b5..c447ec70e868 100644 --- a/arch/arm/mm/idmap.c +++ b/arch/arm/mm/idmap.c | |||
| @@ -9,6 +9,11 @@ | |||
| 9 | #include <asm/sections.h> | 9 | #include <asm/sections.h> |
| 10 | #include <asm/system_info.h> | 10 | #include <asm/system_info.h> |
| 11 | 11 | ||
| 12 | /* | ||
| 13 | * Note: accesses outside of the kernel image and the identity map area | ||
| 14 | * are not supported on any CPU using the idmap tables as its current | ||
| 15 | * page tables. | ||
| 16 | */ | ||
| 12 | pgd_t *idmap_pgd; | 17 | pgd_t *idmap_pgd; |
| 13 | phys_addr_t (*arch_virt_to_idmap) (unsigned long x); | 18 | phys_addr_t (*arch_virt_to_idmap) (unsigned long x); |
| 14 | 19 | ||
| @@ -25,6 +30,13 @@ static void idmap_add_pmd(pud_t *pud, unsigned long addr, unsigned long end, | |||
| 25 | pr_warning("Failed to allocate identity pmd.\n"); | 30 | pr_warning("Failed to allocate identity pmd.\n"); |
| 26 | return; | 31 | return; |
| 27 | } | 32 | } |
| 33 | /* | ||
| 34 | * Copy the original PMD to ensure that the PMD entries for | ||
| 35 | * the kernel image are preserved. | ||
| 36 | */ | ||
| 37 | if (!pud_none(*pud)) | ||
| 38 | memcpy(pmd, pmd_offset(pud, 0), | ||
| 39 | PTRS_PER_PMD * sizeof(pmd_t)); | ||
| 28 | pud_populate(&init_mm, pud, pmd); | 40 | pud_populate(&init_mm, pud, pmd); |
| 29 | pmd += pmd_index(addr); | 41 | pmd += pmd_index(addr); |
| 30 | } else | 42 | } else |
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index ab14b79b03f0..6e3ba8d112a2 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c | |||
| @@ -1406,8 +1406,8 @@ void __init early_paging_init(const struct machine_desc *mdesc, | |||
| 1406 | return; | 1406 | return; |
| 1407 | 1407 | ||
| 1408 | /* remap kernel code and data */ | 1408 | /* remap kernel code and data */ |
| 1409 | map_start = init_mm.start_code; | 1409 | map_start = init_mm.start_code & PMD_MASK; |
| 1410 | map_end = init_mm.brk; | 1410 | map_end = ALIGN(init_mm.brk, PMD_SIZE); |
| 1411 | 1411 | ||
| 1412 | /* get a handle on things... */ | 1412 | /* get a handle on things... */ |
| 1413 | pgd0 = pgd_offset_k(0); | 1413 | pgd0 = pgd_offset_k(0); |
| @@ -1442,7 +1442,7 @@ void __init early_paging_init(const struct machine_desc *mdesc, | |||
| 1442 | } | 1442 | } |
| 1443 | 1443 | ||
| 1444 | /* remap pmds for kernel mapping */ | 1444 | /* remap pmds for kernel mapping */ |
| 1445 | phys = __pa(map_start) & PMD_MASK; | 1445 | phys = __pa(map_start); |
| 1446 | do { | 1446 | do { |
| 1447 | *pmdk++ = __pmd(phys | pmdprot); | 1447 | *pmdk++ = __pmd(phys | pmdprot); |
| 1448 | phys += PMD_SIZE; | 1448 | phys += PMD_SIZE; |
diff --git a/arch/arm/xen/grant-table.c b/arch/arm/xen/grant-table.c index 859a9bb002d5..91cf08ba1e95 100644 --- a/arch/arm/xen/grant-table.c +++ b/arch/arm/xen/grant-table.c | |||
| @@ -51,3 +51,8 @@ int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, | |||
| 51 | { | 51 | { |
| 52 | return -ENOSYS; | 52 | return -ENOSYS; |
| 53 | } | 53 | } |
| 54 | |||
| 55 | int arch_gnttab_init(unsigned long nr_shared, unsigned long nr_status) | ||
| 56 | { | ||
| 57 | return 0; | ||
| 58 | } | ||
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index a474de346be6..839f48c26ef0 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig | |||
| @@ -4,6 +4,7 @@ config ARM64 | |||
| 4 | select ARCH_HAS_OPP | 4 | select ARCH_HAS_OPP |
| 5 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST | 5 | select ARCH_HAS_TICK_BROADCAST if GENERIC_CLOCKEVENTS_BROADCAST |
| 6 | select ARCH_USE_CMPXCHG_LOCKREF | 6 | select ARCH_USE_CMPXCHG_LOCKREF |
| 7 | select ARCH_SUPPORTS_ATOMIC_RMW | ||
| 7 | select ARCH_WANT_OPTIONAL_GPIOLIB | 8 | select ARCH_WANT_OPTIONAL_GPIOLIB |
| 8 | select ARCH_WANT_COMPAT_IPC_PARSE_VERSION | 9 | select ARCH_WANT_COMPAT_IPC_PARSE_VERSION |
| 9 | select ARCH_WANT_FRAME_POINTERS | 10 | select ARCH_WANT_FRAME_POINTERS |
diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c index 60f2f4c12256..79cd911ef88c 100644 --- a/arch/arm64/crypto/aes-glue.c +++ b/arch/arm64/crypto/aes-glue.c | |||
| @@ -106,7 +106,7 @@ static int ecb_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | |||
| 106 | for (first = 1; (blocks = (walk.nbytes / AES_BLOCK_SIZE)); first = 0) { | 106 | for (first = 1; (blocks = (walk.nbytes / AES_BLOCK_SIZE)); first = 0) { |
| 107 | aes_ecb_encrypt(walk.dst.virt.addr, walk.src.virt.addr, | 107 | aes_ecb_encrypt(walk.dst.virt.addr, walk.src.virt.addr, |
| 108 | (u8 *)ctx->key_enc, rounds, blocks, first); | 108 | (u8 *)ctx->key_enc, rounds, blocks, first); |
| 109 | err = blkcipher_walk_done(desc, &walk, 0); | 109 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 110 | } | 110 | } |
| 111 | kernel_neon_end(); | 111 | kernel_neon_end(); |
| 112 | return err; | 112 | return err; |
| @@ -128,7 +128,7 @@ static int ecb_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | |||
| 128 | for (first = 1; (blocks = (walk.nbytes / AES_BLOCK_SIZE)); first = 0) { | 128 | for (first = 1; (blocks = (walk.nbytes / AES_BLOCK_SIZE)); first = 0) { |
| 129 | aes_ecb_decrypt(walk.dst.virt.addr, walk.src.virt.addr, | 129 | aes_ecb_decrypt(walk.dst.virt.addr, walk.src.virt.addr, |
| 130 | (u8 *)ctx->key_dec, rounds, blocks, first); | 130 | (u8 *)ctx->key_dec, rounds, blocks, first); |
| 131 | err = blkcipher_walk_done(desc, &walk, 0); | 131 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 132 | } | 132 | } |
| 133 | kernel_neon_end(); | 133 | kernel_neon_end(); |
| 134 | return err; | 134 | return err; |
| @@ -151,7 +151,7 @@ static int cbc_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | |||
| 151 | aes_cbc_encrypt(walk.dst.virt.addr, walk.src.virt.addr, | 151 | aes_cbc_encrypt(walk.dst.virt.addr, walk.src.virt.addr, |
| 152 | (u8 *)ctx->key_enc, rounds, blocks, walk.iv, | 152 | (u8 *)ctx->key_enc, rounds, blocks, walk.iv, |
| 153 | first); | 153 | first); |
| 154 | err = blkcipher_walk_done(desc, &walk, 0); | 154 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 155 | } | 155 | } |
| 156 | kernel_neon_end(); | 156 | kernel_neon_end(); |
| 157 | return err; | 157 | return err; |
| @@ -174,7 +174,7 @@ static int cbc_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | |||
| 174 | aes_cbc_decrypt(walk.dst.virt.addr, walk.src.virt.addr, | 174 | aes_cbc_decrypt(walk.dst.virt.addr, walk.src.virt.addr, |
| 175 | (u8 *)ctx->key_dec, rounds, blocks, walk.iv, | 175 | (u8 *)ctx->key_dec, rounds, blocks, walk.iv, |
| 176 | first); | 176 | first); |
| 177 | err = blkcipher_walk_done(desc, &walk, 0); | 177 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 178 | } | 178 | } |
| 179 | kernel_neon_end(); | 179 | kernel_neon_end(); |
| 180 | return err; | 180 | return err; |
| @@ -243,7 +243,7 @@ static int xts_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | |||
| 243 | aes_xts_encrypt(walk.dst.virt.addr, walk.src.virt.addr, | 243 | aes_xts_encrypt(walk.dst.virt.addr, walk.src.virt.addr, |
| 244 | (u8 *)ctx->key1.key_enc, rounds, blocks, | 244 | (u8 *)ctx->key1.key_enc, rounds, blocks, |
| 245 | (u8 *)ctx->key2.key_enc, walk.iv, first); | 245 | (u8 *)ctx->key2.key_enc, walk.iv, first); |
| 246 | err = blkcipher_walk_done(desc, &walk, 0); | 246 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 247 | } | 247 | } |
| 248 | kernel_neon_end(); | 248 | kernel_neon_end(); |
| 249 | 249 | ||
| @@ -267,7 +267,7 @@ static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, | |||
| 267 | aes_xts_decrypt(walk.dst.virt.addr, walk.src.virt.addr, | 267 | aes_xts_decrypt(walk.dst.virt.addr, walk.src.virt.addr, |
| 268 | (u8 *)ctx->key1.key_dec, rounds, blocks, | 268 | (u8 *)ctx->key1.key_dec, rounds, blocks, |
| 269 | (u8 *)ctx->key2.key_enc, walk.iv, first); | 269 | (u8 *)ctx->key2.key_enc, walk.iv, first); |
| 270 | err = blkcipher_walk_done(desc, &walk, 0); | 270 | err = blkcipher_walk_done(desc, &walk, walk.nbytes % AES_BLOCK_SIZE); |
| 271 | } | 271 | } |
| 272 | kernel_neon_end(); | 272 | kernel_neon_end(); |
| 273 | 273 | ||
diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 993bce527b85..902eb708804a 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h | |||
| @@ -56,6 +56,8 @@ | |||
| 56 | #define TASK_SIZE_32 UL(0x100000000) | 56 | #define TASK_SIZE_32 UL(0x100000000) |
| 57 | #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ | 57 | #define TASK_SIZE (test_thread_flag(TIF_32BIT) ? \ |
| 58 | TASK_SIZE_32 : TASK_SIZE_64) | 58 | TASK_SIZE_32 : TASK_SIZE_64) |
| 59 | #define TASK_SIZE_OF(tsk) (test_tsk_thread_flag(tsk, TIF_32BIT) ? \ | ||
| 60 | TASK_SIZE_32 : TASK_SIZE_64) | ||
| 59 | #else | 61 | #else |
| 60 | #define TASK_SIZE TASK_SIZE_64 | 62 | #define TASK_SIZE TASK_SIZE_64 |
| 61 | #endif /* CONFIG_COMPAT */ | 63 | #endif /* CONFIG_COMPAT */ |
diff --git a/arch/arm64/kernel/efi-stub.c b/arch/arm64/kernel/efi-stub.c index 60e98a639ac5..e786e6cdc400 100644 --- a/arch/arm64/kernel/efi-stub.c +++ b/arch/arm64/kernel/efi-stub.c | |||
| @@ -12,8 +12,6 @@ | |||
| 12 | #include <linux/efi.h> | 12 | #include <linux/efi.h> |
| 13 | #include <linux/libfdt.h> | 13 | #include <linux/libfdt.h> |
| 14 | #include <asm/sections.h> | 14 | #include <asm/sections.h> |
| 15 | #include <generated/compile.h> | ||
| 16 | #include <generated/utsrelease.h> | ||
| 17 | 15 | ||
| 18 | /* | 16 | /* |
| 19 | * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from | 17 | * AArch64 requires the DTB to be 8-byte aligned in the first 512MiB from |
diff --git a/arch/arm64/mm/copypage.c b/arch/arm64/mm/copypage.c index 9aecbace4128..13bbc3be6f5a 100644 --- a/arch/arm64/mm/copypage.c +++ b/arch/arm64/mm/copypage.c | |||
| @@ -27,8 +27,10 @@ void __cpu_copy_user_page(void *kto, const void *kfrom, unsigned long vaddr) | |||
| 27 | copy_page(kto, kfrom); | 27 | copy_page(kto, kfrom); |
| 28 | __flush_dcache_area(kto, PAGE_SIZE); | 28 | __flush_dcache_area(kto, PAGE_SIZE); |
| 29 | } | 29 | } |
| 30 | EXPORT_SYMBOL_GPL(__cpu_copy_user_page); | ||
| 30 | 31 | ||
| 31 | void __cpu_clear_user_page(void *kaddr, unsigned long vaddr) | 32 | void __cpu_clear_user_page(void *kaddr, unsigned long vaddr) |
| 32 | { | 33 | { |
| 33 | clear_page(kaddr); | 34 | clear_page(kaddr); |
| 34 | } | 35 | } |
| 36 | EXPORT_SYMBOL_GPL(__cpu_clear_user_page); | ||
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c index f43db8a69262..e90c5426fe14 100644 --- a/arch/arm64/mm/init.c +++ b/arch/arm64/mm/init.c | |||
| @@ -60,6 +60,17 @@ static int __init early_initrd(char *p) | |||
| 60 | early_param("initrd", early_initrd); | 60 | early_param("initrd", early_initrd); |
| 61 | #endif | 61 | #endif |
| 62 | 62 | ||
| 63 | /* | ||
| 64 | * Return the maximum physical address for ZONE_DMA (DMA_BIT_MASK(32)). It | ||
| 65 | * currently assumes that for memory starting above 4G, 32-bit devices will | ||
| 66 | * use a DMA offset. | ||
| 67 | */ | ||
| 68 | static phys_addr_t max_zone_dma_phys(void) | ||
| 69 | { | ||
| 70 | phys_addr_t offset = memblock_start_of_DRAM() & GENMASK_ULL(63, 32); | ||
| 71 | return min(offset + (1ULL << 32), memblock_end_of_DRAM()); | ||
| 72 | } | ||
| 73 | |||
| 63 | static void __init zone_sizes_init(unsigned long min, unsigned long max) | 74 | static void __init zone_sizes_init(unsigned long min, unsigned long max) |
| 64 | { | 75 | { |
| 65 | struct memblock_region *reg; | 76 | struct memblock_region *reg; |
| @@ -70,9 +81,7 @@ static void __init zone_sizes_init(unsigned long min, unsigned long max) | |||
| 70 | 81 | ||
| 71 | /* 4GB maximum for 32-bit only capable devices */ | 82 | /* 4GB maximum for 32-bit only capable devices */ |
| 72 | if (IS_ENABLED(CONFIG_ZONE_DMA)) { | 83 | if (IS_ENABLED(CONFIG_ZONE_DMA)) { |
| 73 | unsigned long max_dma_phys = | 84 | max_dma = PFN_DOWN(max_zone_dma_phys()); |
| 74 | (unsigned long)(dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1); | ||
| 75 | max_dma = max(min, min(max, max_dma_phys >> PAGE_SHIFT)); | ||
| 76 | zone_size[ZONE_DMA] = max_dma - min; | 85 | zone_size[ZONE_DMA] = max_dma - min; |
| 77 | } | 86 | } |
| 78 | zone_size[ZONE_NORMAL] = max - max_dma; | 87 | zone_size[ZONE_NORMAL] = max - max_dma; |
| @@ -146,7 +155,7 @@ void __init arm64_memblock_init(void) | |||
| 146 | 155 | ||
| 147 | /* 4GB maximum for 32-bit only capable devices */ | 156 | /* 4GB maximum for 32-bit only capable devices */ |
| 148 | if (IS_ENABLED(CONFIG_ZONE_DMA)) | 157 | if (IS_ENABLED(CONFIG_ZONE_DMA)) |
| 149 | dma_phys_limit = dma_to_phys(NULL, DMA_BIT_MASK(32)) + 1; | 158 | dma_phys_limit = max_zone_dma_phys(); |
| 150 | dma_contiguous_reserve(dma_phys_limit); | 159 | dma_contiguous_reserve(dma_phys_limit); |
| 151 | 160 | ||
| 152 | memblock_allow_resize(); | 161 | memblock_allow_resize(); |
diff --git a/arch/blackfin/configs/BF609-EZKIT_defconfig b/arch/blackfin/configs/BF609-EZKIT_defconfig index a7e9bfd84183..fcec5ce71392 100644 --- a/arch/blackfin/configs/BF609-EZKIT_defconfig +++ b/arch/blackfin/configs/BF609-EZKIT_defconfig | |||
| @@ -102,7 +102,7 @@ CONFIG_I2C_CHARDEV=y | |||
| 102 | CONFIG_I2C_BLACKFIN_TWI=y | 102 | CONFIG_I2C_BLACKFIN_TWI=y |
| 103 | CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100 | 103 | CONFIG_I2C_BLACKFIN_TWI_CLK_KHZ=100 |
| 104 | CONFIG_SPI=y | 104 | CONFIG_SPI=y |
| 105 | CONFIG_SPI_BFIN_V3=y | 105 | CONFIG_SPI_ADI_V3=y |
| 106 | CONFIG_GPIOLIB=y | 106 | CONFIG_GPIOLIB=y |
| 107 | CONFIG_GPIO_SYSFS=y | 107 | CONFIG_GPIO_SYSFS=y |
| 108 | # CONFIG_HWMON is not set | 108 | # CONFIG_HWMON is not set |
diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S index ba35864b2b74..c9eec84aa258 100644 --- a/arch/blackfin/kernel/vmlinux.lds.S +++ b/arch/blackfin/kernel/vmlinux.lds.S | |||
| @@ -145,7 +145,7 @@ SECTIONS | |||
| 145 | 145 | ||
| 146 | .text_l1 L1_CODE_START : AT(LOADADDR(.exit.data) + SIZEOF(.exit.data)) | 146 | .text_l1 L1_CODE_START : AT(LOADADDR(.exit.data) + SIZEOF(.exit.data)) |
| 147 | #else | 147 | #else |
| 148 | .init.data : AT(__data_lma + __data_len) | 148 | .init.data : AT(__data_lma + __data_len + 32) |
| 149 | { | 149 | { |
| 150 | __sinitdata = .; | 150 | __sinitdata = .; |
| 151 | INIT_DATA | 151 | INIT_DATA |
diff --git a/arch/blackfin/mach-bf533/boards/blackstamp.c b/arch/blackfin/mach-bf533/boards/blackstamp.c index 63b0e4fe760c..0ccf0cf4daaf 100644 --- a/arch/blackfin/mach-bf533/boards/blackstamp.c +++ b/arch/blackfin/mach-bf533/boards/blackstamp.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/spi/spi.h> | 20 | #include <linux/spi/spi.h> |
| 21 | #include <linux/spi/flash.h> | 21 | #include <linux/spi/flash.h> |
| 22 | #include <linux/irq.h> | 22 | #include <linux/irq.h> |
| 23 | #include <linux/gpio.h> | ||
| 23 | #include <linux/i2c.h> | 24 | #include <linux/i2c.h> |
| 24 | #include <asm/dma.h> | 25 | #include <asm/dma.h> |
| 25 | #include <asm/bfin5xx_spi.h> | 26 | #include <asm/bfin5xx_spi.h> |
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537e.c b/arch/blackfin/mach-bf537/boards/cm_bf537e.c index c65c6dbda3da..1e7290ef3525 100644 --- a/arch/blackfin/mach-bf537/boards/cm_bf537e.c +++ b/arch/blackfin/mach-bf537/boards/cm_bf537e.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #endif | 21 | #endif |
| 22 | #include <linux/ata_platform.h> | 22 | #include <linux/ata_platform.h> |
| 23 | #include <linux/irq.h> | 23 | #include <linux/irq.h> |
| 24 | #include <linux/gpio.h> | ||
| 24 | #include <asm/dma.h> | 25 | #include <asm/dma.h> |
| 25 | #include <asm/bfin5xx_spi.h> | 26 | #include <asm/bfin5xx_spi.h> |
| 26 | #include <asm/portmux.h> | 27 | #include <asm/portmux.h> |
diff --git a/arch/blackfin/mach-bf537/boards/cm_bf537u.c b/arch/blackfin/mach-bf537/boards/cm_bf537u.c index af58454b4bff..c7495dc74690 100644 --- a/arch/blackfin/mach-bf537/boards/cm_bf537u.c +++ b/arch/blackfin/mach-bf537/boards/cm_bf537u.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #endif | 21 | #endif |
| 22 | #include <linux/ata_platform.h> | 22 | #include <linux/ata_platform.h> |
| 23 | #include <linux/irq.h> | 23 | #include <linux/irq.h> |
| 24 | #include <linux/gpio.h> | ||
| 24 | #include <asm/dma.h> | 25 | #include <asm/dma.h> |
| 25 | #include <asm/bfin5xx_spi.h> | 26 | #include <asm/bfin5xx_spi.h> |
| 26 | #include <asm/portmux.h> | 27 | #include <asm/portmux.h> |
diff --git a/arch/blackfin/mach-bf537/boards/tcm_bf537.c b/arch/blackfin/mach-bf537/boards/tcm_bf537.c index a0211225748d..6b988ad653d8 100644 --- a/arch/blackfin/mach-bf537/boards/tcm_bf537.c +++ b/arch/blackfin/mach-bf537/boards/tcm_bf537.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #endif | 21 | #endif |
| 22 | #include <linux/ata_platform.h> | 22 | #include <linux/ata_platform.h> |
| 23 | #include <linux/irq.h> | 23 | #include <linux/irq.h> |
| 24 | #include <linux/gpio.h> | ||
| 24 | #include <asm/dma.h> | 25 | #include <asm/dma.h> |
| 25 | #include <asm/bfin5xx_spi.h> | 26 | #include <asm/bfin5xx_spi.h> |
| 26 | #include <asm/portmux.h> | 27 | #include <asm/portmux.h> |
diff --git a/arch/blackfin/mach-bf548/boards/ezkit.c b/arch/blackfin/mach-bf548/boards/ezkit.c index 90138e6112c1..1fe7ff286619 100644 --- a/arch/blackfin/mach-bf548/boards/ezkit.c +++ b/arch/blackfin/mach-bf548/boards/ezkit.c | |||
| @@ -2118,7 +2118,7 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = { | |||
| 2118 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), | 2118 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), |
| 2119 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_can.0", "pinctrl-adi2.0", NULL, "can0"), | 2119 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_can.0", "pinctrl-adi2.0", NULL, "can0"), |
| 2120 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_can.1", "pinctrl-adi2.0", NULL, "can1"), | 2120 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_can.1", "pinctrl-adi2.0", NULL, "can1"), |
| 2121 | PIN_MAP_MUX_GROUP_DEFAULT("bf54x-lq043", "pinctrl-adi2.0", NULL, "ppi0_24b"), | 2121 | PIN_MAP_MUX_GROUP_DEFAULT("bf54x-lq043", "pinctrl-adi2.0", "ppi0_24bgrp", "ppi0"), |
| 2122 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-i2s.0", "pinctrl-adi2.0", NULL, "sport0"), | 2122 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-i2s.0", "pinctrl-adi2.0", NULL, "sport0"), |
| 2123 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-tdm.0", "pinctrl-adi2.0", NULL, "sport0"), | 2123 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-tdm.0", "pinctrl-adi2.0", NULL, "sport0"), |
| 2124 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-ac97.0", "pinctrl-adi2.0", NULL, "sport0"), | 2124 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-ac97.0", "pinctrl-adi2.0", NULL, "sport0"), |
| @@ -2140,7 +2140,9 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = { | |||
| 2140 | PIN_MAP_MUX_GROUP_DEFAULT("pata-bf54x", "pinctrl-adi2.0", NULL, "atapi_alter"), | 2140 | PIN_MAP_MUX_GROUP_DEFAULT("pata-bf54x", "pinctrl-adi2.0", NULL, "atapi_alter"), |
| 2141 | #endif | 2141 | #endif |
| 2142 | PIN_MAP_MUX_GROUP_DEFAULT("bf5xx-nand.0", "pinctrl-adi2.0", NULL, "nfc0"), | 2142 | PIN_MAP_MUX_GROUP_DEFAULT("bf5xx-nand.0", "pinctrl-adi2.0", NULL, "nfc0"), |
| 2143 | PIN_MAP_MUX_GROUP_DEFAULT("bf54x-keys", "pinctrl-adi2.0", NULL, "keys_4x4"), | 2143 | PIN_MAP_MUX_GROUP_DEFAULT("bf54x-keys", "pinctrl-adi2.0", "keys_4x4grp", "keys"), |
| 2144 | PIN_MAP_MUX_GROUP("bf54x-keys", "4bit", "pinctrl-adi2.0", "keys_4x4grp", "keys"), | ||
| 2145 | PIN_MAP_MUX_GROUP("bf54x-keys", "8bit", "pinctrl-adi2.0", "keys_8x8grp", "keys"), | ||
| 2144 | }; | 2146 | }; |
| 2145 | 2147 | ||
| 2146 | static int __init ezkit_init(void) | 2148 | static int __init ezkit_init(void) |
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c b/arch/blackfin/mach-bf561/boards/acvilon.c index 430b16d5ccb1..6ab951534d79 100644 --- a/arch/blackfin/mach-bf561/boards/acvilon.c +++ b/arch/blackfin/mach-bf561/boards/acvilon.c | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #include <linux/spi/flash.h> | 44 | #include <linux/spi/flash.h> |
| 45 | #include <linux/irq.h> | 45 | #include <linux/irq.h> |
| 46 | #include <linux/interrupt.h> | 46 | #include <linux/interrupt.h> |
| 47 | #include <linux/gpio.h> | ||
| 47 | #include <linux/jiffies.h> | 48 | #include <linux/jiffies.h> |
| 48 | #include <linux/i2c-pca-platform.h> | 49 | #include <linux/i2c-pca-platform.h> |
| 49 | #include <linux/delay.h> | 50 | #include <linux/delay.h> |
diff --git a/arch/blackfin/mach-bf561/boards/cm_bf561.c b/arch/blackfin/mach-bf561/boards/cm_bf561.c index 9f777df4cacc..e862f7823e68 100644 --- a/arch/blackfin/mach-bf561/boards/cm_bf561.c +++ b/arch/blackfin/mach-bf561/boards/cm_bf561.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #endif | 18 | #endif |
| 19 | #include <linux/ata_platform.h> | 19 | #include <linux/ata_platform.h> |
| 20 | #include <linux/irq.h> | 20 | #include <linux/irq.h> |
| 21 | #include <linux/gpio.h> | ||
| 21 | #include <asm/dma.h> | 22 | #include <asm/dma.h> |
| 22 | #include <asm/bfin5xx_spi.h> | 23 | #include <asm/bfin5xx_spi.h> |
| 23 | #include <asm/portmux.h> | 24 | #include <asm/portmux.h> |
diff --git a/arch/blackfin/mach-bf561/boards/ezkit.c b/arch/blackfin/mach-bf561/boards/ezkit.c index 88dee43e7abe..2de71e8c104b 100644 --- a/arch/blackfin/mach-bf561/boards/ezkit.c +++ b/arch/blackfin/mach-bf561/boards/ezkit.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/spi/spi.h> | 14 | #include <linux/spi/spi.h> |
| 15 | #include <linux/irq.h> | 15 | #include <linux/irq.h> |
| 16 | #include <linux/interrupt.h> | 16 | #include <linux/interrupt.h> |
| 17 | #include <linux/gpio.h> | ||
| 17 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
| 18 | #include <asm/dma.h> | 19 | #include <asm/dma.h> |
| 19 | #include <asm/bfin5xx_spi.h> | 20 | #include <asm/bfin5xx_spi.h> |
diff --git a/arch/blackfin/mach-bf609/boards/ezkit.c b/arch/blackfin/mach-bf609/boards/ezkit.c index 1ba4600de69f..e2c0b024ce88 100644 --- a/arch/blackfin/mach-bf609/boards/ezkit.c +++ b/arch/blackfin/mach-bf609/boards/ezkit.c | |||
| @@ -698,8 +698,6 @@ int bf609_nor_flash_init(struct platform_device *pdev) | |||
| 698 | { | 698 | { |
| 699 | #define CONFIG_SMC_GCTL_VAL 0x00000010 | 699 | #define CONFIG_SMC_GCTL_VAL 0x00000010 |
| 700 | 700 | ||
| 701 | if (!devm_pinctrl_get_select_default(&pdev->dev)) | ||
| 702 | return -EBUSY; | ||
| 703 | bfin_write32(SMC_GCTL, CONFIG_SMC_GCTL_VAL); | 701 | bfin_write32(SMC_GCTL, CONFIG_SMC_GCTL_VAL); |
| 704 | bfin_write32(SMC_B0CTL, 0x01002011); | 702 | bfin_write32(SMC_B0CTL, 0x01002011); |
| 705 | bfin_write32(SMC_B0TIM, 0x08170977); | 703 | bfin_write32(SMC_B0TIM, 0x08170977); |
| @@ -709,7 +707,6 @@ int bf609_nor_flash_init(struct platform_device *pdev) | |||
| 709 | 707 | ||
| 710 | void bf609_nor_flash_exit(struct platform_device *pdev) | 708 | void bf609_nor_flash_exit(struct platform_device *pdev) |
| 711 | { | 709 | { |
| 712 | devm_pinctrl_put(pdev->dev.pins->p); | ||
| 713 | bfin_write32(SMC_GCTL, 0); | 710 | bfin_write32(SMC_GCTL, 0); |
| 714 | } | 711 | } |
| 715 | 712 | ||
| @@ -2058,15 +2055,14 @@ static struct pinctrl_map __initdata bfin_pinmux_map[] = { | |||
| 2058 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), | 2055 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-rotary", "pinctrl-adi2.0", NULL, "rotary"), |
| 2059 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_can.0", "pinctrl-adi2.0", NULL, "can0"), | 2056 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_can.0", "pinctrl-adi2.0", NULL, "can0"), |
| 2060 | PIN_MAP_MUX_GROUP_DEFAULT("physmap-flash.0", "pinctrl-adi2.0", NULL, "smc0"), | 2057 | PIN_MAP_MUX_GROUP_DEFAULT("physmap-flash.0", "pinctrl-adi2.0", NULL, "smc0"), |
| 2061 | PIN_MAP_MUX_GROUP_DEFAULT("bf609_nl8048.2", "pinctrl-adi2.0", NULL, "ppi2_16b"), | 2058 | PIN_MAP_MUX_GROUP_DEFAULT("bf609_nl8048.2", "pinctrl-adi2.0", "ppi2_16bgrp", "ppi2"), |
| 2062 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_display.0", "pinctrl-adi2.0", NULL, "ppi0_16b"), | 2059 | PIN_MAP_MUX_GROUP("bfin_display.0", "8bit", "pinctrl-adi2.0", "ppi2_8bgrp", "ppi2"), |
| 2063 | #if IS_ENABLED(CONFIG_VIDEO_MT9M114) | 2060 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_display.0", "pinctrl-adi2.0", "ppi2_16bgrp", "ppi2"), |
| 2064 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_8b"), | 2061 | PIN_MAP_MUX_GROUP("bfin_display.0", "16bit", "pinctrl-adi2.0", "ppi2_16bgrp", "ppi2"), |
| 2065 | #elif IS_ENABLED(CONFIG_VIDEO_VS6624) | 2062 | PIN_MAP_MUX_GROUP("bfin_capture.0", "8bit", "pinctrl-adi2.0", "ppi0_8bgrp", "ppi0"), |
| 2066 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_16b"), | 2063 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", "ppi0_16bgrp", "ppi0"), |
| 2067 | #else | 2064 | PIN_MAP_MUX_GROUP("bfin_capture.0", "16bit", "pinctrl-adi2.0", "ppi0_16bgrp", "ppi0"), |
| 2068 | PIN_MAP_MUX_GROUP_DEFAULT("bfin_capture.0", "pinctrl-adi2.0", NULL, "ppi0_24b"), | 2065 | PIN_MAP_MUX_GROUP("bfin_capture.0", "24bit", "pinctrl-adi2.0", "ppi0_24bgrp", "ppi0"), |
| 2069 | #endif | ||
| 2070 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-i2s.0", "pinctrl-adi2.0", NULL, "sport0"), | 2066 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-i2s.0", "pinctrl-adi2.0", NULL, "sport0"), |
| 2071 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-tdm.0", "pinctrl-adi2.0", NULL, "sport0"), | 2067 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-tdm.0", "pinctrl-adi2.0", NULL, "sport0"), |
| 2072 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-i2s.1", "pinctrl-adi2.0", NULL, "sport1"), | 2068 | PIN_MAP_MUX_GROUP_DEFAULT("bfin-i2s.1", "pinctrl-adi2.0", NULL, "sport1"), |
diff --git a/arch/blackfin/mach-bf609/include/mach/pm.h b/arch/blackfin/mach-bf609/include/mach/pm.h index 3ca0fb965636..a1efd936dd30 100644 --- a/arch/blackfin/mach-bf609/include/mach/pm.h +++ b/arch/blackfin/mach-bf609/include/mach/pm.h | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #define __MACH_BF609_PM_H__ | 10 | #define __MACH_BF609_PM_H__ |
| 11 | 11 | ||
| 12 | #include <linux/suspend.h> | 12 | #include <linux/suspend.h> |
| 13 | #include <linux/platform_device.h> | ||
| 13 | 14 | ||
| 14 | extern int bfin609_pm_enter(suspend_state_t state); | 15 | extern int bfin609_pm_enter(suspend_state_t state); |
| 15 | extern int bf609_pm_prepare(void); | 16 | extern int bf609_pm_prepare(void); |
| @@ -19,6 +20,6 @@ void bf609_hibernate(void); | |||
| 19 | void bfin_sec_raise_irq(unsigned int sid); | 20 | void bfin_sec_raise_irq(unsigned int sid); |
| 20 | void coreb_enable(void); | 21 | void coreb_enable(void); |
| 21 | 22 | ||
| 22 | int bf609_nor_flash_init(void); | 23 | int bf609_nor_flash_init(struct platform_device *pdev); |
| 23 | void bf609_nor_flash_exit(void); | 24 | void bf609_nor_flash_exit(struct platform_device *pdev); |
| 24 | #endif | 25 | #endif |
diff --git a/arch/blackfin/mach-bf609/pm.c b/arch/blackfin/mach-bf609/pm.c index 0cdd6955c7be..b1bfcf434d16 100644 --- a/arch/blackfin/mach-bf609/pm.c +++ b/arch/blackfin/mach-bf609/pm.c | |||
| @@ -291,13 +291,13 @@ static struct bfin_cpu_pm_fns bf609_cpu_pm = { | |||
| 291 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) | 291 | #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE) |
| 292 | static int smc_pm_syscore_suspend(void) | 292 | static int smc_pm_syscore_suspend(void) |
| 293 | { | 293 | { |
| 294 | bf609_nor_flash_exit(); | 294 | bf609_nor_flash_exit(NULL); |
| 295 | return 0; | 295 | return 0; |
| 296 | } | 296 | } |
| 297 | 297 | ||
| 298 | static void smc_pm_syscore_resume(void) | 298 | static void smc_pm_syscore_resume(void) |
| 299 | { | 299 | { |
| 300 | bf609_nor_flash_init(); | 300 | bf609_nor_flash_init(NULL); |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | static struct syscore_ops smc_pm_syscore_ops = { | 303 | static struct syscore_ops smc_pm_syscore_ops = { |
diff --git a/arch/blackfin/mach-common/ints-priority.c b/arch/blackfin/mach-common/ints-priority.c index 867b7cef204c..1f94784eab6d 100644 --- a/arch/blackfin/mach-common/ints-priority.c +++ b/arch/blackfin/mach-common/ints-priority.c | |||
| @@ -1208,8 +1208,6 @@ int __init init_arch_irq(void) | |||
| 1208 | 1208 | ||
| 1209 | bfin_sec_set_priority(CONFIG_SEC_IRQ_PRIORITY_LEVELS, sec_int_priority); | 1209 | bfin_sec_set_priority(CONFIG_SEC_IRQ_PRIORITY_LEVELS, sec_int_priority); |
| 1210 | 1210 | ||
| 1211 | bfin_sec_set_priority(CONFIG_SEC_IRQ_PRIORITY_LEVELS, sec_int_priority); | ||
| 1212 | |||
| 1213 | /* Enable interrupts IVG7-15 */ | 1211 | /* Enable interrupts IVG7-15 */ |
| 1214 | bfin_irq_flags |= IMASK_IVG15 | | 1212 | bfin_irq_flags |= IMASK_IVG15 | |
| 1215 | IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 | | 1213 | IMASK_IVG14 | IMASK_IVG13 | IMASK_IVG12 | IMASK_IVG11 | |
diff --git a/arch/m68k/kernel/head.S b/arch/m68k/kernel/head.S index dbb118e1a4e0..a54788458ca3 100644 --- a/arch/m68k/kernel/head.S +++ b/arch/m68k/kernel/head.S | |||
| @@ -921,7 +921,8 @@ L(nocon): | |||
| 921 | jls 1f | 921 | jls 1f |
| 922 | lsrl #1,%d1 | 922 | lsrl #1,%d1 |
| 923 | 1: | 923 | 1: |
| 924 | movel %d1,m68k_init_mapped_size | 924 | lea %pc@(m68k_init_mapped_size),%a0 |
| 925 | movel %d1,%a0@ | ||
| 925 | mmu_map #PAGE_OFFSET,%pc@(L(phys_kernel_start)),%d1,\ | 926 | mmu_map #PAGE_OFFSET,%pc@(L(phys_kernel_start)),%d1,\ |
| 926 | %pc@(m68k_supervisor_cachemode) | 927 | %pc@(m68k_supervisor_cachemode) |
| 927 | 928 | ||
diff --git a/arch/m68k/kernel/time.c b/arch/m68k/kernel/time.c index 958f1adb9d0c..3857737e3958 100644 --- a/arch/m68k/kernel/time.c +++ b/arch/m68k/kernel/time.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
| 14 | #include <linux/export.h> | ||
| 14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 15 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
| 16 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| @@ -30,6 +31,7 @@ | |||
| 30 | 31 | ||
| 31 | 32 | ||
| 32 | unsigned long (*mach_random_get_entropy)(void); | 33 | unsigned long (*mach_random_get_entropy)(void); |
| 34 | EXPORT_SYMBOL_GPL(mach_random_get_entropy); | ||
| 33 | 35 | ||
| 34 | 36 | ||
| 35 | /* | 37 | /* |
diff --git a/arch/parisc/include/uapi/asm/signal.h b/arch/parisc/include/uapi/asm/signal.h index a2fa297196bc..f5645d6a89f2 100644 --- a/arch/parisc/include/uapi/asm/signal.h +++ b/arch/parisc/include/uapi/asm/signal.h | |||
| @@ -69,8 +69,6 @@ | |||
| 69 | #define SA_NOMASK SA_NODEFER | 69 | #define SA_NOMASK SA_NODEFER |
| 70 | #define SA_ONESHOT SA_RESETHAND | 70 | #define SA_ONESHOT SA_RESETHAND |
| 71 | 71 | ||
| 72 | #define SA_RESTORER 0x04000000 /* obsolete -- ignored */ | ||
| 73 | |||
| 74 | #define MINSIGSTKSZ 2048 | 72 | #define MINSIGSTKSZ 2048 |
| 75 | #define SIGSTKSZ 8192 | 73 | #define SIGSTKSZ 8192 |
| 76 | 74 | ||
diff --git a/arch/parisc/kernel/hardware.c b/arch/parisc/kernel/hardware.c index 608716f8496b..af3bc359dc70 100644 --- a/arch/parisc/kernel/hardware.c +++ b/arch/parisc/kernel/hardware.c | |||
| @@ -1210,7 +1210,8 @@ static struct hp_hardware hp_hardware_list[] = { | |||
| 1210 | {HPHW_FIO, 0x004, 0x00320, 0x0, "Metheus Frame Buffer"}, | 1210 | {HPHW_FIO, 0x004, 0x00320, 0x0, "Metheus Frame Buffer"}, |
| 1211 | {HPHW_FIO, 0x004, 0x00340, 0x0, "BARCO CX4500 VME Grphx Cnsl"}, | 1211 | {HPHW_FIO, 0x004, 0x00340, 0x0, "BARCO CX4500 VME Grphx Cnsl"}, |
| 1212 | {HPHW_FIO, 0x004, 0x00360, 0x0, "Hughes TOG VME FDDI"}, | 1212 | {HPHW_FIO, 0x004, 0x00360, 0x0, "Hughes TOG VME FDDI"}, |
| 1213 | {HPHW_FIO, 0x076, 0x000AD, 0x00, "Crestone Peak RS-232"}, | 1213 | {HPHW_FIO, 0x076, 0x000AD, 0x0, "Crestone Peak Core RS-232"}, |
| 1214 | {HPHW_FIO, 0x077, 0x000AD, 0x0, "Crestone Peak Fast? Core RS-232"}, | ||
| 1214 | {HPHW_IOA, 0x185, 0x0000B, 0x00, "Java BC Summit Port"}, | 1215 | {HPHW_IOA, 0x185, 0x0000B, 0x00, "Java BC Summit Port"}, |
| 1215 | {HPHW_IOA, 0x1FF, 0x0000B, 0x00, "Hitachi Ghostview Summit Port"}, | 1216 | {HPHW_IOA, 0x1FF, 0x0000B, 0x00, "Hitachi Ghostview Summit Port"}, |
| 1216 | {HPHW_IOA, 0x580, 0x0000B, 0x10, "U2-IOA BC Runway Port"}, | 1217 | {HPHW_IOA, 0x580, 0x0000B, 0x10, "U2-IOA BC Runway Port"}, |
diff --git a/arch/parisc/kernel/sys_parisc32.c b/arch/parisc/kernel/sys_parisc32.c index bb9f3b64de55..93c1963d76fe 100644 --- a/arch/parisc/kernel/sys_parisc32.c +++ b/arch/parisc/kernel/sys_parisc32.c | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | * Copyright (C) 2000-2001 Hewlett Packard Company | 4 | * Copyright (C) 2000-2001 Hewlett Packard Company |
| 5 | * Copyright (C) 2000 John Marvin | 5 | * Copyright (C) 2000 John Marvin |
| 6 | * Copyright (C) 2001 Matthew Wilcox | 6 | * Copyright (C) 2001 Matthew Wilcox |
| 7 | * Copyright (C) 2014 Helge Deller <deller@gmx.de> | ||
| 7 | * | 8 | * |
| 8 | * These routines maintain argument size conversion between 32bit and 64bit | 9 | * These routines maintain argument size conversion between 32bit and 64bit |
| 9 | * environment. Based heavily on sys_ia32.c and sys_sparc32.c. | 10 | * environment. Based heavily on sys_ia32.c and sys_sparc32.c. |
| @@ -11,44 +12,8 @@ | |||
| 11 | 12 | ||
| 12 | #include <linux/compat.h> | 13 | #include <linux/compat.h> |
| 13 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
| 14 | #include <linux/sched.h> | ||
| 15 | #include <linux/fs.h> | ||
| 16 | #include <linux/mm.h> | ||
| 17 | #include <linux/file.h> | ||
| 18 | #include <linux/signal.h> | ||
| 19 | #include <linux/resource.h> | ||
| 20 | #include <linux/times.h> | ||
| 21 | #include <linux/time.h> | ||
| 22 | #include <linux/smp.h> | ||
| 23 | #include <linux/sem.h> | ||
| 24 | #include <linux/shm.h> | ||
| 25 | #include <linux/slab.h> | ||
| 26 | #include <linux/uio.h> | ||
| 27 | #include <linux/ncp_fs.h> | ||
| 28 | #include <linux/poll.h> | ||
| 29 | #include <linux/personality.h> | ||
| 30 | #include <linux/stat.h> | ||
| 31 | #include <linux/highmem.h> | ||
| 32 | #include <linux/highuid.h> | ||
| 33 | #include <linux/mman.h> | ||
| 34 | #include <linux/binfmts.h> | ||
| 35 | #include <linux/namei.h> | ||
| 36 | #include <linux/vfs.h> | ||
| 37 | #include <linux/ptrace.h> | ||
| 38 | #include <linux/swap.h> | ||
| 39 | #include <linux/syscalls.h> | 15 | #include <linux/syscalls.h> |
| 40 | 16 | ||
| 41 | #include <asm/types.h> | ||
| 42 | #include <asm/uaccess.h> | ||
| 43 | #include <asm/mmu_context.h> | ||
| 44 | |||
| 45 | #undef DEBUG | ||
| 46 | |||
| 47 | #ifdef DEBUG | ||
| 48 | #define DBG(x) printk x | ||
| 49 | #else | ||
| 50 | #define DBG(x) | ||
| 51 | #endif | ||
| 52 | 17 | ||
| 53 | asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, | 18 | asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, |
| 54 | int r22, int r21, int r20) | 19 | int r22, int r21, int r20) |
| @@ -57,3 +22,12 @@ asmlinkage long sys32_unimplemented(int r26, int r25, int r24, int r23, | |||
| 57 | current->comm, current->pid, r20); | 22 | current->comm, current->pid, r20); |
| 58 | return -ENOSYS; | 23 | return -ENOSYS; |
| 59 | } | 24 | } |
| 25 | |||
| 26 | asmlinkage long sys32_fanotify_mark(compat_int_t fanotify_fd, compat_uint_t flags, | ||
| 27 | compat_uint_t mask0, compat_uint_t mask1, compat_int_t dfd, | ||
| 28 | const char __user * pathname) | ||
| 29 | { | ||
| 30 | return sys_fanotify_mark(fanotify_fd, flags, | ||
| 31 | ((__u64)mask1 << 32) | mask0, | ||
| 32 | dfd, pathname); | ||
| 33 | } | ||
diff --git a/arch/parisc/kernel/syscall_table.S b/arch/parisc/kernel/syscall_table.S index c5fa7a697fba..84c5d3a58fa1 100644 --- a/arch/parisc/kernel/syscall_table.S +++ b/arch/parisc/kernel/syscall_table.S | |||
| @@ -418,7 +418,7 @@ | |||
| 418 | ENTRY_SAME(accept4) /* 320 */ | 418 | ENTRY_SAME(accept4) /* 320 */ |
| 419 | ENTRY_SAME(prlimit64) | 419 | ENTRY_SAME(prlimit64) |
| 420 | ENTRY_SAME(fanotify_init) | 420 | ENTRY_SAME(fanotify_init) |
| 421 | ENTRY_COMP(fanotify_mark) | 421 | ENTRY_DIFF(fanotify_mark) |
| 422 | ENTRY_COMP(clock_adjtime) | 422 | ENTRY_COMP(clock_adjtime) |
| 423 | ENTRY_SAME(name_to_handle_at) /* 325 */ | 423 | ENTRY_SAME(name_to_handle_at) /* 325 */ |
| 424 | ENTRY_COMP(open_by_handle_at) | 424 | ENTRY_COMP(open_by_handle_at) |
diff --git a/arch/parisc/mm/init.c b/arch/parisc/mm/init.c index ae085ad0fba0..0bef864264c0 100644 --- a/arch/parisc/mm/init.c +++ b/arch/parisc/mm/init.c | |||
| @@ -728,7 +728,6 @@ static void __init pagetable_init(void) | |||
| 728 | #endif | 728 | #endif |
| 729 | 729 | ||
| 730 | empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); | 730 | empty_zero_page = alloc_bootmem_pages(PAGE_SIZE); |
| 731 | memset(empty_zero_page, 0, PAGE_SIZE); | ||
| 732 | } | 731 | } |
| 733 | 732 | ||
| 734 | static void __init gateway_init(void) | 733 | static void __init gateway_init(void) |
diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig index bd6dd6ed3a9f..80b94b0add1f 100644 --- a/arch/powerpc/Kconfig +++ b/arch/powerpc/Kconfig | |||
| @@ -145,6 +145,7 @@ config PPC | |||
| 145 | select HAVE_IRQ_EXIT_ON_IRQ_STACK | 145 | select HAVE_IRQ_EXIT_ON_IRQ_STACK |
| 146 | select ARCH_USE_CMPXCHG_LOCKREF if PPC64 | 146 | select ARCH_USE_CMPXCHG_LOCKREF if PPC64 |
| 147 | select HAVE_ARCH_AUDITSYSCALL | 147 | select HAVE_ARCH_AUDITSYSCALL |
| 148 | select ARCH_SUPPORTS_ATOMIC_RMW | ||
| 148 | 149 | ||
| 149 | config GENERIC_CSUM | 150 | config GENERIC_CSUM |
| 150 | def_bool CPU_LITTLE_ENDIAN | 151 | def_bool CPU_LITTLE_ENDIAN |
| @@ -414,7 +415,7 @@ config KEXEC | |||
| 414 | config CRASH_DUMP | 415 | config CRASH_DUMP |
| 415 | bool "Build a kdump crash kernel" | 416 | bool "Build a kdump crash kernel" |
| 416 | depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP) | 417 | depends on PPC64 || 6xx || FSL_BOOKE || (44x && !SMP) |
| 417 | select RELOCATABLE if PPC64 || 44x || FSL_BOOKE | 418 | select RELOCATABLE if (PPC64 && !COMPILE_TEST) || 44x || FSL_BOOKE |
| 418 | help | 419 | help |
| 419 | Build a kernel suitable for use as a kdump capture kernel. | 420 | Build a kernel suitable for use as a kdump capture kernel. |
| 420 | The same kernel binary can be used as production kernel and dump | 421 | The same kernel binary can be used as production kernel and dump |
| @@ -1017,6 +1018,7 @@ endmenu | |||
| 1017 | if PPC64 | 1018 | if PPC64 |
| 1018 | config RELOCATABLE | 1019 | config RELOCATABLE |
| 1019 | bool "Build a relocatable kernel" | 1020 | bool "Build a relocatable kernel" |
| 1021 | depends on !COMPILE_TEST | ||
| 1020 | select NONSTATIC_KERNEL | 1022 | select NONSTATIC_KERNEL |
| 1021 | help | 1023 | help |
| 1022 | This builds a kernel image that is capable of running anywhere | 1024 | This builds a kernel image that is capable of running anywhere |
diff --git a/arch/powerpc/include/asm/cputable.h b/arch/powerpc/include/asm/cputable.h index bc2347774f0a..0fdd7eece6d9 100644 --- a/arch/powerpc/include/asm/cputable.h +++ b/arch/powerpc/include/asm/cputable.h | |||
| @@ -447,6 +447,7 @@ extern const char *powerpc_base_platform; | |||
| 447 | CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \ | 447 | CPU_FTR_DBELL | CPU_FTR_HAS_PPR | CPU_FTR_DAWR | \ |
| 448 | CPU_FTR_ARCH_207S | CPU_FTR_TM_COMP) | 448 | CPU_FTR_ARCH_207S | CPU_FTR_TM_COMP) |
| 449 | #define CPU_FTRS_POWER8E (CPU_FTRS_POWER8 | CPU_FTR_PMAO_BUG) | 449 | #define CPU_FTRS_POWER8E (CPU_FTRS_POWER8 | CPU_FTR_PMAO_BUG) |
| 450 | #define CPU_FTRS_POWER8_DD1 (CPU_FTRS_POWER8 & ~CPU_FTR_DBELL) | ||
| 450 | #define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ | 451 | #define CPU_FTRS_CELL (CPU_FTR_USE_TB | CPU_FTR_LWSYNC | \ |
| 451 | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ | 452 | CPU_FTR_PPCAS_ARCH_V2 | CPU_FTR_CTRL | \ |
| 452 | CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ | 453 | CPU_FTR_ALTIVEC_COMP | CPU_FTR_MMCRA | CPU_FTR_SMT | \ |
diff --git a/arch/powerpc/include/asm/kvm_book3s_64.h b/arch/powerpc/include/asm/kvm_book3s_64.h index fddb72b48ce9..d645428a65a4 100644 --- a/arch/powerpc/include/asm/kvm_book3s_64.h +++ b/arch/powerpc/include/asm/kvm_book3s_64.h | |||
| @@ -198,8 +198,10 @@ static inline unsigned long compute_tlbie_rb(unsigned long v, unsigned long r, | |||
| 198 | return rb; | 198 | return rb; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | static inline unsigned long hpte_page_size(unsigned long h, unsigned long l) | 201 | static inline unsigned long __hpte_page_size(unsigned long h, unsigned long l, |
| 202 | bool is_base_size) | ||
| 202 | { | 203 | { |
| 204 | |||
| 203 | int size, a_psize; | 205 | int size, a_psize; |
| 204 | /* Look at the 8 bit LP value */ | 206 | /* Look at the 8 bit LP value */ |
| 205 | unsigned int lp = (l >> LP_SHIFT) & ((1 << LP_BITS) - 1); | 207 | unsigned int lp = (l >> LP_SHIFT) & ((1 << LP_BITS) - 1); |
| @@ -214,14 +216,27 @@ static inline unsigned long hpte_page_size(unsigned long h, unsigned long l) | |||
| 214 | continue; | 216 | continue; |
| 215 | 217 | ||
| 216 | a_psize = __hpte_actual_psize(lp, size); | 218 | a_psize = __hpte_actual_psize(lp, size); |
| 217 | if (a_psize != -1) | 219 | if (a_psize != -1) { |
| 220 | if (is_base_size) | ||
| 221 | return 1ul << mmu_psize_defs[size].shift; | ||
| 218 | return 1ul << mmu_psize_defs[a_psize].shift; | 222 | return 1ul << mmu_psize_defs[a_psize].shift; |
| 223 | } | ||
| 219 | } | 224 | } |
| 220 | 225 | ||
| 221 | } | 226 | } |
| 222 | return 0; | 227 | return 0; |
| 223 | } | 228 | } |
| 224 | 229 | ||
| 230 | static inline unsigned long hpte_page_size(unsigned long h, unsigned long l) | ||
| 231 | { | ||
| 232 | return __hpte_page_size(h, l, 0); | ||
| 233 | } | ||
| 234 | |||
| 235 | static inline unsigned long hpte_base_page_size(unsigned long h, unsigned long l) | ||
| 236 | { | ||
| 237 | return __hpte_page_size(h, l, 1); | ||
| 238 | } | ||
| 239 | |||
| 225 | static inline unsigned long hpte_rpn(unsigned long ptel, unsigned long psize) | 240 | static inline unsigned long hpte_rpn(unsigned long ptel, unsigned long psize) |
| 226 | { | 241 | { |
| 227 | return ((ptel & HPTE_R_RPN) & ~(psize - 1)) >> PAGE_SHIFT; | 242 | return ((ptel & HPTE_R_RPN) & ~(psize - 1)) >> PAGE_SHIFT; |
diff --git a/arch/powerpc/include/asm/mmu-hash64.h b/arch/powerpc/include/asm/mmu-hash64.h index 807014dde821..c2b4dcf23d03 100644 --- a/arch/powerpc/include/asm/mmu-hash64.h +++ b/arch/powerpc/include/asm/mmu-hash64.h | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | */ | 22 | */ |
| 23 | #include <asm/pgtable-ppc64.h> | 23 | #include <asm/pgtable-ppc64.h> |
| 24 | #include <asm/bug.h> | 24 | #include <asm/bug.h> |
| 25 | #include <asm/processor.h> | ||
| 25 | 26 | ||
| 26 | /* | 27 | /* |
| 27 | * Segment table | 28 | * Segment table |
| @@ -496,7 +497,7 @@ extern void slb_set_size(u16 size); | |||
| 496 | */ | 497 | */ |
| 497 | struct subpage_prot_table { | 498 | struct subpage_prot_table { |
| 498 | unsigned long maxaddr; /* only addresses < this are protected */ | 499 | unsigned long maxaddr; /* only addresses < this are protected */ |
| 499 | unsigned int **protptrs[2]; | 500 | unsigned int **protptrs[(TASK_SIZE_USER64 >> 43)]; |
| 500 | unsigned int *low_prot[4]; | 501 | unsigned int *low_prot[4]; |
| 501 | }; | 502 | }; |
| 502 | 503 | ||
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index f8d1d6dcf7db..e61f24ed4e65 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h | |||
| @@ -19,8 +19,7 @@ | |||
| 19 | #define MMU_FTR_TYPE_40x ASM_CONST(0x00000004) | 19 | #define MMU_FTR_TYPE_40x ASM_CONST(0x00000004) |
| 20 | #define MMU_FTR_TYPE_44x ASM_CONST(0x00000008) | 20 | #define MMU_FTR_TYPE_44x ASM_CONST(0x00000008) |
| 21 | #define MMU_FTR_TYPE_FSL_E ASM_CONST(0x00000010) | 21 | #define MMU_FTR_TYPE_FSL_E ASM_CONST(0x00000010) |
| 22 | #define MMU_FTR_TYPE_3E ASM_CONST(0x00000020) | 22 | #define MMU_FTR_TYPE_47x ASM_CONST(0x00000020) |
| 23 | #define MMU_FTR_TYPE_47x ASM_CONST(0x00000040) | ||
| 24 | 23 | ||
| 25 | /* | 24 | /* |
| 26 | * This is individual features | 25 | * This is individual features |
| @@ -106,13 +105,6 @@ | |||
| 106 | MMU_FTR_CI_LARGE_PAGE | 105 | MMU_FTR_CI_LARGE_PAGE |
| 107 | #define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ | 106 | #define MMU_FTRS_PA6T MMU_FTRS_DEFAULT_HPTE_ARCH_V2 | \ |
| 108 | MMU_FTR_CI_LARGE_PAGE | MMU_FTR_NO_SLBIE_B | 107 | MMU_FTR_CI_LARGE_PAGE | MMU_FTR_NO_SLBIE_B |
| 109 | #define MMU_FTRS_A2 MMU_FTR_TYPE_3E | MMU_FTR_USE_TLBILX | \ | ||
| 110 | MMU_FTR_USE_TLBIVAX_BCAST | \ | ||
| 111 | MMU_FTR_LOCK_BCAST_INVAL | \ | ||
| 112 | MMU_FTR_USE_TLBRSRV | \ | ||
| 113 | MMU_FTR_USE_PAIRED_MAS | \ | ||
| 114 | MMU_FTR_TLBIEL | \ | ||
| 115 | MMU_FTR_16M_PAGE | ||
| 116 | #ifndef __ASSEMBLY__ | 108 | #ifndef __ASSEMBLY__ |
| 117 | #include <asm/cputable.h> | 109 | #include <asm/cputable.h> |
| 118 | 110 | ||
diff --git a/arch/powerpc/include/asm/perf_event_server.h b/arch/powerpc/include/asm/perf_event_server.h index 9ed737146dbb..b3e936027b26 100644 --- a/arch/powerpc/include/asm/perf_event_server.h +++ b/arch/powerpc/include/asm/perf_event_server.h | |||
| @@ -61,8 +61,7 @@ struct power_pmu { | |||
| 61 | #define PPMU_SIAR_VALID 0x00000010 /* Processor has SIAR Valid bit */ | 61 | #define PPMU_SIAR_VALID 0x00000010 /* Processor has SIAR Valid bit */ |
| 62 | #define PPMU_HAS_SSLOT 0x00000020 /* Has sampled slot in MMCRA */ | 62 | #define PPMU_HAS_SSLOT 0x00000020 /* Has sampled slot in MMCRA */ |
| 63 | #define PPMU_HAS_SIER 0x00000040 /* Has SIER */ | 63 | #define PPMU_HAS_SIER 0x00000040 /* Has SIER */ |
| 64 | #define PPMU_BHRB 0x00000080 /* has BHRB feature enabled */ | 64 | #define PPMU_ARCH_207S 0x00000080 /* PMC is architecture v2.07S */ |
| 65 | #define PPMU_EBB 0x00000100 /* supports event based branch */ | ||
| 66 | 65 | ||
| 67 | /* | 66 | /* |
| 68 | * Values for flags to get_alternatives() | 67 | * Values for flags to get_alternatives() |
diff --git a/arch/powerpc/include/asm/ppc_asm.h b/arch/powerpc/include/asm/ppc_asm.h index 9ea266eae33e..7e4612528546 100644 --- a/arch/powerpc/include/asm/ppc_asm.h +++ b/arch/powerpc/include/asm/ppc_asm.h | |||
| @@ -277,6 +277,8 @@ n: | |||
| 277 | .globl n; \ | 277 | .globl n; \ |
| 278 | n: | 278 | n: |
| 279 | 279 | ||
| 280 | #define _GLOBAL_TOC(name) _GLOBAL(name) | ||
| 281 | |||
| 280 | #define _KPROBE(n) \ | 282 | #define _KPROBE(n) \ |
| 281 | .section ".kprobes.text","a"; \ | 283 | .section ".kprobes.text","a"; \ |
| 282 | .globl n; \ | 284 | .globl n; \ |
diff --git a/arch/powerpc/kernel/cputable.c b/arch/powerpc/kernel/cputable.c index 965291b4c2fa..0c157642c2a1 100644 --- a/arch/powerpc/kernel/cputable.c +++ b/arch/powerpc/kernel/cputable.c | |||
| @@ -527,6 +527,26 @@ static struct cpu_spec __initdata cpu_specs[] = { | |||
| 527 | .machine_check_early = __machine_check_early_realmode_p8, | 527 | .machine_check_early = __machine_check_early_realmode_p8, |
| 528 | .platform = "power8", | 528 | .platform = "power8", |
| 529 | }, | 529 | }, |
| 530 | { /* Power8 DD1: Does not support doorbell IPIs */ | ||
| 531 | .pvr_mask = 0xffffff00, | ||
| 532 | .pvr_value = 0x004d0100, | ||
| 533 | .cpu_name = "POWER8 (raw)", | ||
| 534 | .cpu_features = CPU_FTRS_POWER8_DD1, | ||
| 535 | .cpu_user_features = COMMON_USER_POWER8, | ||
| 536 | .cpu_user_features2 = COMMON_USER2_POWER8, | ||
| 537 | .mmu_features = MMU_FTRS_POWER8, | ||
| 538 | .icache_bsize = 128, | ||
| 539 | .dcache_bsize = 128, | ||
| 540 | .num_pmcs = 6, | ||
| 541 | .pmc_type = PPC_PMC_IBM, | ||
| 542 | .oprofile_cpu_type = "ppc64/power8", | ||
| 543 | .oprofile_type = PPC_OPROFILE_INVALID, | ||
| 544 | .cpu_setup = __setup_cpu_power8, | ||
| 545 | .cpu_restore = __restore_cpu_power8, | ||
| 546 | .flush_tlb = __flush_tlb_power8, | ||
| 547 | .machine_check_early = __machine_check_early_realmode_p8, | ||
| 548 | .platform = "power8", | ||
| 549 | }, | ||
| 530 | { /* Power8 */ | 550 | { /* Power8 */ |
| 531 | .pvr_mask = 0xffff0000, | 551 | .pvr_mask = 0xffff0000, |
| 532 | .pvr_value = 0x004d0000, | 552 | .pvr_value = 0x004d0000, |
diff --git a/arch/powerpc/kernel/idle_power7.S b/arch/powerpc/kernel/idle_power7.S index 2480256272d4..5cf3d367190d 100644 --- a/arch/powerpc/kernel/idle_power7.S +++ b/arch/powerpc/kernel/idle_power7.S | |||
| @@ -131,7 +131,7 @@ _GLOBAL(power7_nap) | |||
| 131 | 131 | ||
| 132 | _GLOBAL(power7_sleep) | 132 | _GLOBAL(power7_sleep) |
| 133 | li r3,1 | 133 | li r3,1 |
| 134 | li r4,0 | 134 | li r4,1 |
| 135 | b power7_powersave_common | 135 | b power7_powersave_common |
| 136 | /* No return */ | 136 | /* No return */ |
| 137 | 137 | ||
diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c index 658e89d2025b..db2b482af658 100644 --- a/arch/powerpc/kernel/rtas_flash.c +++ b/arch/powerpc/kernel/rtas_flash.c | |||
| @@ -611,17 +611,19 @@ static void rtas_flash_firmware(int reboot_type) | |||
| 611 | for (f = flist; f; f = next) { | 611 | for (f = flist; f; f = next) { |
| 612 | /* Translate data addrs to absolute */ | 612 | /* Translate data addrs to absolute */ |
| 613 | for (i = 0; i < f->num_blocks; i++) { | 613 | for (i = 0; i < f->num_blocks; i++) { |
| 614 | f->blocks[i].data = (char *)__pa(f->blocks[i].data); | 614 | f->blocks[i].data = (char *)cpu_to_be64(__pa(f->blocks[i].data)); |
| 615 | image_size += f->blocks[i].length; | 615 | image_size += f->blocks[i].length; |
| 616 | f->blocks[i].length = cpu_to_be64(f->blocks[i].length); | ||
| 616 | } | 617 | } |
| 617 | next = f->next; | 618 | next = f->next; |
| 618 | /* Don't translate NULL pointer for last entry */ | 619 | /* Don't translate NULL pointer for last entry */ |
| 619 | if (f->next) | 620 | if (f->next) |
| 620 | f->next = (struct flash_block_list *)__pa(f->next); | 621 | f->next = (struct flash_block_list *)cpu_to_be64(__pa(f->next)); |
| 621 | else | 622 | else |
| 622 | f->next = NULL; | 623 | f->next = NULL; |
| 623 | /* make num_blocks into the version/length field */ | 624 | /* make num_blocks into the version/length field */ |
| 624 | f->num_blocks = (FLASH_BLOCK_LIST_VERSION << 56) | ((f->num_blocks+1)*16); | 625 | f->num_blocks = (FLASH_BLOCK_LIST_VERSION << 56) | ((f->num_blocks+1)*16); |
| 626 | f->num_blocks = cpu_to_be64(f->num_blocks); | ||
| 625 | } | 627 | } |
| 626 | 628 | ||
| 627 | printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size); | 629 | printk(KERN_ALERT "FLASH: flash image is %ld bytes\n", image_size); |
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 51a3ff78838a..1007fb802e6b 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
| @@ -747,7 +747,7 @@ int setup_profiling_timer(unsigned int multiplier) | |||
| 747 | 747 | ||
| 748 | #ifdef CONFIG_SCHED_SMT | 748 | #ifdef CONFIG_SCHED_SMT |
| 749 | /* cpumask of CPUs with asymetric SMT dependancy */ | 749 | /* cpumask of CPUs with asymetric SMT dependancy */ |
| 750 | static const int powerpc_smt_flags(void) | 750 | static int powerpc_smt_flags(void) |
| 751 | { | 751 | { |
| 752 | int flags = SD_SHARE_CPUCAPACITY | SD_SHARE_PKG_RESOURCES; | 752 | int flags = SD_SHARE_CPUCAPACITY | SD_SHARE_PKG_RESOURCES; |
| 753 | 753 | ||
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index 80561074078d..68468d695f12 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c | |||
| @@ -1562,7 +1562,7 @@ static ssize_t kvm_htab_write(struct file *file, const char __user *buf, | |||
| 1562 | goto out; | 1562 | goto out; |
| 1563 | } | 1563 | } |
| 1564 | if (!rma_setup && is_vrma_hpte(v)) { | 1564 | if (!rma_setup && is_vrma_hpte(v)) { |
| 1565 | unsigned long psize = hpte_page_size(v, r); | 1565 | unsigned long psize = hpte_base_page_size(v, r); |
| 1566 | unsigned long senc = slb_pgsize_encoding(psize); | 1566 | unsigned long senc = slb_pgsize_encoding(psize); |
| 1567 | unsigned long lpcr; | 1567 | unsigned long lpcr; |
| 1568 | 1568 | ||
diff --git a/arch/powerpc/kvm/book3s_hv_interrupts.S b/arch/powerpc/kvm/book3s_hv_interrupts.S index 8c86422a1e37..731be7478b27 100644 --- a/arch/powerpc/kvm/book3s_hv_interrupts.S +++ b/arch/powerpc/kvm/book3s_hv_interrupts.S | |||
| @@ -127,11 +127,6 @@ BEGIN_FTR_SECTION | |||
| 127 | stw r10, HSTATE_PMC + 24(r13) | 127 | stw r10, HSTATE_PMC + 24(r13) |
| 128 | stw r11, HSTATE_PMC + 28(r13) | 128 | stw r11, HSTATE_PMC + 28(r13) |
| 129 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) | 129 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_201) |
| 130 | BEGIN_FTR_SECTION | ||
| 131 | mfspr r9, SPRN_SIER | ||
| 132 | std r8, HSTATE_MMCR + 40(r13) | ||
| 133 | std r9, HSTATE_MMCR + 48(r13) | ||
| 134 | END_FTR_SECTION_IFSET(CPU_FTR_ARCH_207S) | ||
| 135 | 31: | 130 | 31: |
| 136 | 131 | ||
| 137 | /* | 132 | /* |
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c index 6e6224318c36..5a24d3c2b6b8 100644 --- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c +++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c | |||
| @@ -814,13 +814,10 @@ long kvmppc_hv_find_lock_hpte(struct kvm *kvm, gva_t eaddr, unsigned long slb_v, | |||
| 814 | r = hpte[i+1]; | 814 | r = hpte[i+1]; |
| 815 | 815 | ||
| 816 | /* | 816 | /* |
| 817 | * Check the HPTE again, including large page size | 817 | * Check the HPTE again, including base page size |
| 818 | * Since we don't currently allow any MPSS (mixed | ||
| 819 | * page-size segment) page sizes, it is sufficient | ||
| 820 | * to check against the actual page size. | ||
| 821 | */ | 818 | */ |
| 822 | if ((v & valid) && (v & mask) == val && | 819 | if ((v & valid) && (v & mask) == val && |
| 823 | hpte_page_size(v, r) == (1ul << pshift)) | 820 | hpte_base_page_size(v, r) == (1ul << pshift)) |
| 824 | /* Return with the HPTE still locked */ | 821 | /* Return with the HPTE still locked */ |
| 825 | return (hash << 3) + (i >> 1); | 822 | return (hash << 3) + (i >> 1); |
| 826 | 823 | ||
diff --git a/arch/powerpc/kvm/book3s_hv_rmhandlers.S b/arch/powerpc/kvm/book3s_hv_rmhandlers.S index 868347ef09fd..558a67df8126 100644 --- a/arch/powerpc/kvm/book3s_hv_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_hv_rmhandlers.S | |||
| @@ -48,7 +48,7 @@ | |||
| 48 | * | 48 | * |
| 49 | * LR = return address to continue at after eventually re-enabling MMU | 49 | * LR = return address to continue at after eventually re-enabling MMU |
| 50 | */ | 50 | */ |
| 51 | _GLOBAL(kvmppc_hv_entry_trampoline) | 51 | _GLOBAL_TOC(kvmppc_hv_entry_trampoline) |
| 52 | mflr r0 | 52 | mflr r0 |
| 53 | std r0, PPC_LR_STKOFF(r1) | 53 | std r0, PPC_LR_STKOFF(r1) |
| 54 | stdu r1, -112(r1) | 54 | stdu r1, -112(r1) |
diff --git a/arch/powerpc/kvm/book3s_interrupts.S b/arch/powerpc/kvm/book3s_interrupts.S index e2c29e381dc7..d044b8b7c69d 100644 --- a/arch/powerpc/kvm/book3s_interrupts.S +++ b/arch/powerpc/kvm/book3s_interrupts.S | |||
| @@ -25,7 +25,11 @@ | |||
| 25 | #include <asm/exception-64s.h> | 25 | #include <asm/exception-64s.h> |
| 26 | 26 | ||
| 27 | #if defined(CONFIG_PPC_BOOK3S_64) | 27 | #if defined(CONFIG_PPC_BOOK3S_64) |
| 28 | #if defined(_CALL_ELF) && _CALL_ELF == 2 | ||
| 29 | #define FUNC(name) name | ||
| 30 | #else | ||
| 28 | #define FUNC(name) GLUE(.,name) | 31 | #define FUNC(name) GLUE(.,name) |
| 32 | #endif | ||
| 29 | #define GET_SHADOW_VCPU(reg) addi reg, r13, PACA_SVCPU | 33 | #define GET_SHADOW_VCPU(reg) addi reg, r13, PACA_SVCPU |
| 30 | 34 | ||
| 31 | #elif defined(CONFIG_PPC_BOOK3S_32) | 35 | #elif defined(CONFIG_PPC_BOOK3S_32) |
diff --git a/arch/powerpc/kvm/book3s_rmhandlers.S b/arch/powerpc/kvm/book3s_rmhandlers.S index 9eec675220e6..16c4d88ba27d 100644 --- a/arch/powerpc/kvm/book3s_rmhandlers.S +++ b/arch/powerpc/kvm/book3s_rmhandlers.S | |||
| @@ -36,7 +36,11 @@ | |||
| 36 | 36 | ||
| 37 | #if defined(CONFIG_PPC_BOOK3S_64) | 37 | #if defined(CONFIG_PPC_BOOK3S_64) |
| 38 | 38 | ||
| 39 | #if defined(_CALL_ELF) && _CALL_ELF == 2 | ||
| 40 | #define FUNC(name) name | ||
| 41 | #else | ||
| 39 | #define FUNC(name) GLUE(.,name) | 42 | #define FUNC(name) GLUE(.,name) |
| 43 | #endif | ||
| 40 | 44 | ||
| 41 | #elif defined(CONFIG_PPC_BOOK3S_32) | 45 | #elif defined(CONFIG_PPC_BOOK3S_32) |
| 42 | 46 | ||
| @@ -146,7 +150,7 @@ kvmppc_handler_skip_ins: | |||
| 146 | * On entry, r4 contains the guest shadow MSR | 150 | * On entry, r4 contains the guest shadow MSR |
| 147 | * MSR.EE has to be 0 when calling this function | 151 | * MSR.EE has to be 0 when calling this function |
| 148 | */ | 152 | */ |
| 149 | _GLOBAL(kvmppc_entry_trampoline) | 153 | _GLOBAL_TOC(kvmppc_entry_trampoline) |
| 150 | mfmsr r5 | 154 | mfmsr r5 |
| 151 | LOAD_REG_ADDR(r7, kvmppc_handler_trampoline_enter) | 155 | LOAD_REG_ADDR(r7, kvmppc_handler_trampoline_enter) |
| 152 | toreal(r7) | 156 | toreal(r7) |
diff --git a/arch/powerpc/kvm/book3s_rtas.c b/arch/powerpc/kvm/book3s_rtas.c index edb14ba992b3..ef27fbd5d9c5 100644 --- a/arch/powerpc/kvm/book3s_rtas.c +++ b/arch/powerpc/kvm/book3s_rtas.c | |||
| @@ -23,20 +23,20 @@ static void kvm_rtas_set_xive(struct kvm_vcpu *vcpu, struct rtas_args *args) | |||
| 23 | u32 irq, server, priority; | 23 | u32 irq, server, priority; |
| 24 | int rc; | 24 | int rc; |
| 25 | 25 | ||
| 26 | if (args->nargs != 3 || args->nret != 1) { | 26 | if (be32_to_cpu(args->nargs) != 3 || be32_to_cpu(args->nret) != 1) { |
| 27 | rc = -3; | 27 | rc = -3; |
| 28 | goto out; | 28 | goto out; |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | irq = args->args[0]; | 31 | irq = be32_to_cpu(args->args[0]); |
| 32 | server = args->args[1]; | 32 | server = be32_to_cpu(args->args[1]); |
| 33 | priority = args->args[2]; | 33 | priority = be32_to_cpu(args->args[2]); |
| 34 | 34 | ||
| 35 | rc = kvmppc_xics_set_xive(vcpu->kvm, irq, server, priority); | 35 | rc = kvmppc_xics_set_xive(vcpu->kvm, irq, server, priority); |
| 36 | if (rc) | 36 | if (rc) |
| 37 | rc = -3; | 37 | rc = -3; |
| 38 | out: | 38 | out: |
| 39 | args->rets[0] = rc; | 39 | args->rets[0] = cpu_to_be32(rc); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | static void kvm_rtas_get_xive(struct kvm_vcpu *vcpu, struct rtas_args *args) | 42 | static void kvm_rtas_get_xive(struct kvm_vcpu *vcpu, struct rtas_args *args) |
| @@ -44,12 +44,12 @@ static void kvm_rtas_get_xive(struct kvm_vcpu *vcpu, struct rtas_args *args) | |||
| 44 | u32 irq, server, priority; | 44 | u32 irq, server, priority; |
| 45 | int rc; | 45 | int rc; |
| 46 | 46 | ||
| 47 | if (args->nargs != 1 || args->nret != 3) { | 47 | if (be32_to_cpu(args->nargs) != 1 || be32_to_cpu(args->nret) != 3) { |
| 48 | rc = -3; | 48 | rc = -3; |
| 49 | goto out; | 49 | goto out; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | irq = args->args[0]; | 52 | irq = be32_to_cpu(args->args[0]); |
| 53 | 53 | ||
| 54 | server = priority = 0; | 54 | server = priority = 0; |
| 55 | rc = kvmppc_xics_get_xive(vcpu->kvm, irq, &server, &priority); | 55 | rc = kvmppc_xics_get_xive(vcpu->kvm, irq, &server, &priority); |
| @@ -58,10 +58,10 @@ static void kvm_rtas_get_xive(struct kvm_vcpu *vcpu, struct rtas_args *args) | |||
| 58 | goto out; | 58 | goto out; |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | args->rets[1] = server; | 61 | args->rets[1] = cpu_to_be32(server); |
| 62 | args->rets[2] = priority; | 62 | args->rets[2] = cpu_to_be32(priority); |
| 63 | out: | 63 | out: |
| 64 | args->rets[0] = rc; | 64 | args->rets[0] = cpu_to_be32(rc); |
| 65 | } | 65 | } |
| 66 | 66 | ||
| 67 | static void kvm_rtas_int_off(struct kvm_vcpu *vcpu, struct rtas_args *args) | 67 | static void kvm_rtas_int_off(struct kvm_vcpu *vcpu, struct rtas_args *args) |
| @@ -69,18 +69,18 @@ static void kvm_rtas_int_off(struct kvm_vcpu *vcpu, struct rtas_args *args) | |||
| 69 | u32 irq; | 69 | u32 irq; |
| 70 | int rc; | 70 | int rc; |
| 71 | 71 | ||
| 72 | if (args->nargs != 1 || args->nret != 1) { | 72 | if (be32_to_cpu(args->nargs) != 1 || be32_to_cpu(args->nret) != 1) { |
| 73 | rc = -3; | 73 | rc = -3; |
| 74 | goto out; | 74 | goto out; |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | irq = args->args[0]; | 77 | irq = be32_to_cpu(args->args[0]); |
| 78 | 78 | ||
| 79 | rc = kvmppc_xics_int_off(vcpu->kvm, irq); | 79 | rc = kvmppc_xics_int_off(vcpu->kvm, irq); |
| 80 | if (rc) | 80 | if (rc) |
| 81 | rc = -3; | 81 | rc = -3; |
| 82 | out: | 82 | out: |
| 83 | args->rets[0] = rc; | 83 | args->rets[0] = cpu_to_be32(rc); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | static void kvm_rtas_int_on(struct kvm_vcpu *vcpu, struct rtas_args *args) | 86 | static void kvm_rtas_int_on(struct kvm_vcpu *vcpu, struct rtas_args *args) |
| @@ -88,18 +88,18 @@ static void kvm_rtas_int_on(struct kvm_vcpu *vcpu, struct rtas_args *args) | |||
| 88 | u32 irq; | 88 | u32 irq; |
| 89 | int rc; | 89 | int rc; |
| 90 | 90 | ||
| 91 | if (args->nargs != 1 || args->nret != 1) { | 91 | if (be32_to_cpu(args->nargs) != 1 || be32_to_cpu(args->nret) != 1) { |
| 92 | rc = -3; | 92 | rc = -3; |
| 93 | goto out; | 93 | goto out; |
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | irq = args->args[0]; | 96 | irq = be32_to_cpu(args->args[0]); |
| 97 | 97 | ||
| 98 | rc = kvmppc_xics_int_on(vcpu->kvm, irq); | 98 | rc = kvmppc_xics_int_on(vcpu->kvm, irq); |
| 99 | if (rc) | 99 | if (rc) |
| 100 | rc = -3; | 100 | rc = -3; |
| 101 | out: | 101 | out: |
| 102 | args->rets[0] = rc; | 102 | args->rets[0] = cpu_to_be32(rc); |
| 103 | } | 103 | } |
| 104 | #endif /* CONFIG_KVM_XICS */ | 104 | #endif /* CONFIG_KVM_XICS */ |
| 105 | 105 | ||
| @@ -205,32 +205,6 @@ int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp) | |||
| 205 | return rc; | 205 | return rc; |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | static void kvmppc_rtas_swap_endian_in(struct rtas_args *args) | ||
| 209 | { | ||
| 210 | #ifdef __LITTLE_ENDIAN__ | ||
| 211 | int i; | ||
| 212 | |||
| 213 | args->token = be32_to_cpu(args->token); | ||
| 214 | args->nargs = be32_to_cpu(args->nargs); | ||
| 215 | args->nret = be32_to_cpu(args->nret); | ||
| 216 | for (i = 0; i < args->nargs; i++) | ||
| 217 | args->args[i] = be32_to_cpu(args->args[i]); | ||
| 218 | #endif | ||
| 219 | } | ||
| 220 | |||
| 221 | static void kvmppc_rtas_swap_endian_out(struct rtas_args *args) | ||
| 222 | { | ||
| 223 | #ifdef __LITTLE_ENDIAN__ | ||
| 224 | int i; | ||
| 225 | |||
| 226 | for (i = 0; i < args->nret; i++) | ||
| 227 | args->args[i] = cpu_to_be32(args->args[i]); | ||
| 228 | args->token = cpu_to_be32(args->token); | ||
| 229 | args->nargs = cpu_to_be32(args->nargs); | ||
| 230 | args->nret = cpu_to_be32(args->nret); | ||
| 231 | #endif | ||
| 232 | } | ||
| 233 | |||
| 234 | int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) | 208 | int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) |
| 235 | { | 209 | { |
| 236 | struct rtas_token_definition *d; | 210 | struct rtas_token_definition *d; |
| @@ -249,8 +223,6 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) | |||
| 249 | if (rc) | 223 | if (rc) |
| 250 | goto fail; | 224 | goto fail; |
| 251 | 225 | ||
| 252 | kvmppc_rtas_swap_endian_in(&args); | ||
| 253 | |||
| 254 | /* | 226 | /* |
| 255 | * args->rets is a pointer into args->args. Now that we've | 227 | * args->rets is a pointer into args->args. Now that we've |
| 256 | * copied args we need to fix it up to point into our copy, | 228 | * copied args we need to fix it up to point into our copy, |
| @@ -258,13 +230,13 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) | |||
| 258 | * value so we can restore it on the way out. | 230 | * value so we can restore it on the way out. |
| 259 | */ | 231 | */ |
| 260 | orig_rets = args.rets; | 232 | orig_rets = args.rets; |
| 261 | args.rets = &args.args[args.nargs]; | 233 | args.rets = &args.args[be32_to_cpu(args.nargs)]; |
| 262 | 234 | ||
| 263 | mutex_lock(&vcpu->kvm->lock); | 235 | mutex_lock(&vcpu->kvm->lock); |
| 264 | 236 | ||
| 265 | rc = -ENOENT; | 237 | rc = -ENOENT; |
| 266 | list_for_each_entry(d, &vcpu->kvm->arch.rtas_tokens, list) { | 238 | list_for_each_entry(d, &vcpu->kvm->arch.rtas_tokens, list) { |
| 267 | if (d->token == args.token) { | 239 | if (d->token == be32_to_cpu(args.token)) { |
| 268 | d->handler->handler(vcpu, &args); | 240 | d->handler->handler(vcpu, &args); |
| 269 | rc = 0; | 241 | rc = 0; |
| 270 | break; | 242 | break; |
| @@ -275,7 +247,6 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) | |||
| 275 | 247 | ||
| 276 | if (rc == 0) { | 248 | if (rc == 0) { |
| 277 | args.rets = orig_rets; | 249 | args.rets = orig_rets; |
| 278 | kvmppc_rtas_swap_endian_out(&args); | ||
| 279 | rc = kvm_write_guest(vcpu->kvm, args_phys, &args, sizeof(args)); | 250 | rc = kvm_write_guest(vcpu->kvm, args_phys, &args, sizeof(args)); |
| 280 | if (rc) | 251 | if (rc) |
| 281 | goto fail; | 252 | goto fail; |
diff --git a/arch/powerpc/kvm/e500_mmu_host.c b/arch/powerpc/kvm/e500_mmu_host.c index dd2cc03f406f..86903d3f5a03 100644 --- a/arch/powerpc/kvm/e500_mmu_host.c +++ b/arch/powerpc/kvm/e500_mmu_host.c | |||
| @@ -473,7 +473,8 @@ static inline int kvmppc_e500_shadow_map(struct kvmppc_vcpu_e500 *vcpu_e500, | |||
| 473 | if (printk_ratelimit()) | 473 | if (printk_ratelimit()) |
| 474 | pr_err("%s: pte not present: gfn %lx, pfn %lx\n", | 474 | pr_err("%s: pte not present: gfn %lx, pfn %lx\n", |
| 475 | __func__, (long)gfn, pfn); | 475 | __func__, (long)gfn, pfn); |
| 476 | return -EINVAL; | 476 | ret = -EINVAL; |
| 477 | goto out; | ||
| 477 | } | 478 | } |
| 478 | kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); | 479 | kvmppc_e500_ref_setup(ref, gtlbe, pfn, wimg); |
| 479 | 480 | ||
diff --git a/arch/powerpc/lib/mem_64.S b/arch/powerpc/lib/mem_64.S index 0738f96befbf..43435c6892fb 100644 --- a/arch/powerpc/lib/mem_64.S +++ b/arch/powerpc/lib/mem_64.S | |||
| @@ -77,7 +77,7 @@ _GLOBAL(memset) | |||
| 77 | stb r4,0(r6) | 77 | stb r4,0(r6) |
| 78 | blr | 78 | blr |
| 79 | 79 | ||
| 80 | _GLOBAL(memmove) | 80 | _GLOBAL_TOC(memmove) |
| 81 | cmplw 0,r3,r4 | 81 | cmplw 0,r3,r4 |
| 82 | bgt backwards_memcpy | 82 | bgt backwards_memcpy |
| 83 | b memcpy | 83 | b memcpy |
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c index 412dd46dd0b7..5c09f365c842 100644 --- a/arch/powerpc/lib/sstep.c +++ b/arch/powerpc/lib/sstep.c | |||
| @@ -1198,7 +1198,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
| 1198 | sh = regs->gpr[rb] & 0x3f; | 1198 | sh = regs->gpr[rb] & 0x3f; |
| 1199 | ival = (signed int) regs->gpr[rd]; | 1199 | ival = (signed int) regs->gpr[rd]; |
| 1200 | regs->gpr[ra] = ival >> (sh < 32 ? sh : 31); | 1200 | regs->gpr[ra] = ival >> (sh < 32 ? sh : 31); |
| 1201 | if (ival < 0 && (sh >= 32 || (ival & ((1 << sh) - 1)) != 0)) | 1201 | if (ival < 0 && (sh >= 32 || (ival & ((1ul << sh) - 1)) != 0)) |
| 1202 | regs->xer |= XER_CA; | 1202 | regs->xer |= XER_CA; |
| 1203 | else | 1203 | else |
| 1204 | regs->xer &= ~XER_CA; | 1204 | regs->xer &= ~XER_CA; |
| @@ -1208,7 +1208,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
| 1208 | sh = rb; | 1208 | sh = rb; |
| 1209 | ival = (signed int) regs->gpr[rd]; | 1209 | ival = (signed int) regs->gpr[rd]; |
| 1210 | regs->gpr[ra] = ival >> sh; | 1210 | regs->gpr[ra] = ival >> sh; |
| 1211 | if (ival < 0 && (ival & ((1 << sh) - 1)) != 0) | 1211 | if (ival < 0 && (ival & ((1ul << sh) - 1)) != 0) |
| 1212 | regs->xer |= XER_CA; | 1212 | regs->xer |= XER_CA; |
| 1213 | else | 1213 | else |
| 1214 | regs->xer &= ~XER_CA; | 1214 | regs->xer &= ~XER_CA; |
| @@ -1216,7 +1216,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
| 1216 | 1216 | ||
| 1217 | #ifdef __powerpc64__ | 1217 | #ifdef __powerpc64__ |
| 1218 | case 27: /* sld */ | 1218 | case 27: /* sld */ |
| 1219 | sh = regs->gpr[rd] & 0x7f; | 1219 | sh = regs->gpr[rb] & 0x7f; |
| 1220 | if (sh < 64) | 1220 | if (sh < 64) |
| 1221 | regs->gpr[ra] = regs->gpr[rd] << sh; | 1221 | regs->gpr[ra] = regs->gpr[rd] << sh; |
| 1222 | else | 1222 | else |
| @@ -1235,7 +1235,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
| 1235 | sh = regs->gpr[rb] & 0x7f; | 1235 | sh = regs->gpr[rb] & 0x7f; |
| 1236 | ival = (signed long int) regs->gpr[rd]; | 1236 | ival = (signed long int) regs->gpr[rd]; |
| 1237 | regs->gpr[ra] = ival >> (sh < 64 ? sh : 63); | 1237 | regs->gpr[ra] = ival >> (sh < 64 ? sh : 63); |
| 1238 | if (ival < 0 && (sh >= 64 || (ival & ((1 << sh) - 1)) != 0)) | 1238 | if (ival < 0 && (sh >= 64 || (ival & ((1ul << sh) - 1)) != 0)) |
| 1239 | regs->xer |= XER_CA; | 1239 | regs->xer |= XER_CA; |
| 1240 | else | 1240 | else |
| 1241 | regs->xer &= ~XER_CA; | 1241 | regs->xer &= ~XER_CA; |
| @@ -1246,7 +1246,7 @@ int __kprobes emulate_step(struct pt_regs *regs, unsigned int instr) | |||
| 1246 | sh = rb | ((instr & 2) << 4); | 1246 | sh = rb | ((instr & 2) << 4); |
| 1247 | ival = (signed long int) regs->gpr[rd]; | 1247 | ival = (signed long int) regs->gpr[rd]; |
| 1248 | regs->gpr[ra] = ival >> sh; | 1248 | regs->gpr[ra] = ival >> sh; |
| 1249 | if (ival < 0 && (ival & ((1 << sh) - 1)) != 0) | 1249 | if (ival < 0 && (ival & ((1ul << sh) - 1)) != 0) |
| 1250 | regs->xer |= XER_CA; | 1250 | regs->xer |= XER_CA; |
| 1251 | else | 1251 | else |
| 1252 | regs->xer &= ~XER_CA; | 1252 | regs->xer &= ~XER_CA; |
diff --git a/arch/powerpc/mm/mmu_context_nohash.c b/arch/powerpc/mm/mmu_context_nohash.c index af3d78e19302..928ebe79668b 100644 --- a/arch/powerpc/mm/mmu_context_nohash.c +++ b/arch/powerpc/mm/mmu_context_nohash.c | |||
| @@ -410,17 +410,7 @@ void __init mmu_context_init(void) | |||
| 410 | } else if (mmu_has_feature(MMU_FTR_TYPE_47x)) { | 410 | } else if (mmu_has_feature(MMU_FTR_TYPE_47x)) { |
| 411 | first_context = 1; | 411 | first_context = 1; |
| 412 | last_context = 65535; | 412 | last_context = 65535; |
| 413 | } else | 413 | } else { |
| 414 | #ifdef CONFIG_PPC_BOOK3E_MMU | ||
| 415 | if (mmu_has_feature(MMU_FTR_TYPE_3E)) { | ||
| 416 | u32 mmucfg = mfspr(SPRN_MMUCFG); | ||
| 417 | u32 pid_bits = (mmucfg & MMUCFG_PIDSIZE_MASK) | ||
| 418 | >> MMUCFG_PIDSIZE_SHIFT; | ||
| 419 | first_context = 1; | ||
| 420 | last_context = (1UL << (pid_bits + 1)) - 1; | ||
| 421 | } else | ||
| 422 | #endif | ||
| 423 | { | ||
| 424 | first_context = 1; | 414 | first_context = 1; |
| 425 | last_context = 255; | 415 | last_context = 255; |
| 426 | } | 416 | } |
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c index 6dcdadefd8d0..82e82cadcde5 100644 --- a/arch/powerpc/net/bpf_jit_comp.c +++ b/arch/powerpc/net/bpf_jit_comp.c | |||
| @@ -390,12 +390,16 @@ static int bpf_jit_build_body(struct sk_filter *fp, u32 *image, | |||
| 390 | case BPF_ANC | SKF_AD_VLAN_TAG: | 390 | case BPF_ANC | SKF_AD_VLAN_TAG: |
| 391 | case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT: | 391 | case BPF_ANC | SKF_AD_VLAN_TAG_PRESENT: |
| 392 | BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2); | 392 | BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, vlan_tci) != 2); |
| 393 | BUILD_BUG_ON(VLAN_TAG_PRESENT != 0x1000); | ||
| 394 | |||
| 393 | PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff, | 395 | PPC_LHZ_OFFS(r_A, r_skb, offsetof(struct sk_buff, |
| 394 | vlan_tci)); | 396 | vlan_tci)); |
| 395 | if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) | 397 | if (code == (BPF_ANC | SKF_AD_VLAN_TAG)) { |
| 396 | PPC_ANDI(r_A, r_A, VLAN_VID_MASK); | 398 | PPC_ANDI(r_A, r_A, ~VLAN_TAG_PRESENT); |
| 397 | else | 399 | } else { |
| 398 | PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT); | 400 | PPC_ANDI(r_A, r_A, VLAN_TAG_PRESENT); |
| 401 | PPC_SRWI(r_A, r_A, 12); | ||
| 402 | } | ||
| 399 | break; | 403 | break; |
| 400 | case BPF_ANC | SKF_AD_QUEUE: | 404 | case BPF_ANC | SKF_AD_QUEUE: |
| 401 | BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, | 405 | BUILD_BUG_ON(FIELD_SIZEOF(struct sk_buff, |
diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c index 4520c9356b54..fe52db2eea6a 100644 --- a/arch/powerpc/perf/core-book3s.c +++ b/arch/powerpc/perf/core-book3s.c | |||
| @@ -485,7 +485,7 @@ static bool is_ebb_event(struct perf_event *event) | |||
| 485 | * check that the PMU supports EBB, meaning those that don't can still | 485 | * check that the PMU supports EBB, meaning those that don't can still |
| 486 | * use bit 63 of the event code for something else if they wish. | 486 | * use bit 63 of the event code for something else if they wish. |
| 487 | */ | 487 | */ |
| 488 | return (ppmu->flags & PPMU_EBB) && | 488 | return (ppmu->flags & PPMU_ARCH_207S) && |
| 489 | ((event->attr.config >> PERF_EVENT_CONFIG_EBB_SHIFT) & 1); | 489 | ((event->attr.config >> PERF_EVENT_CONFIG_EBB_SHIFT) & 1); |
| 490 | } | 490 | } |
| 491 | 491 | ||
| @@ -777,7 +777,7 @@ void perf_event_print_debug(void) | |||
| 777 | if (ppmu->flags & PPMU_HAS_SIER) | 777 | if (ppmu->flags & PPMU_HAS_SIER) |
| 778 | sier = mfspr(SPRN_SIER); | 778 | sier = mfspr(SPRN_SIER); |
| 779 | 779 | ||
| 780 | if (ppmu->flags & PPMU_EBB) { | 780 | if (ppmu->flags & PPMU_ARCH_207S) { |
| 781 | pr_info("MMCR2: %016lx EBBHR: %016lx\n", | 781 | pr_info("MMCR2: %016lx EBBHR: %016lx\n", |
| 782 | mfspr(SPRN_MMCR2), mfspr(SPRN_EBBHR)); | 782 | mfspr(SPRN_MMCR2), mfspr(SPRN_EBBHR)); |
| 783 | pr_info("EBBRR: %016lx BESCR: %016lx\n", | 783 | pr_info("EBBRR: %016lx BESCR: %016lx\n", |
| @@ -996,7 +996,22 @@ static void power_pmu_read(struct perf_event *event) | |||
| 996 | } while (local64_cmpxchg(&event->hw.prev_count, prev, val) != prev); | 996 | } while (local64_cmpxchg(&event->hw.prev_count, prev, val) != prev); |
| 997 | 997 | ||
| 998 | local64_add(delta, &event->count); | 998 | local64_add(delta, &event->count); |
| 999 | local64_sub(delta, &event->hw.period_left); | 999 | |
| 1000 | /* | ||
| 1001 | * A number of places program the PMC with (0x80000000 - period_left). | ||
| 1002 | * We never want period_left to be less than 1 because we will program | ||
| 1003 | * the PMC with a value >= 0x800000000 and an edge detected PMC will | ||
| 1004 | * roll around to 0 before taking an exception. We have seen this | ||
| 1005 | * on POWER8. | ||
| 1006 | * | ||
| 1007 | * To fix this, clamp the minimum value of period_left to 1. | ||
| 1008 | */ | ||
| 1009 | do { | ||
| 1010 | prev = local64_read(&event->hw.period_left); | ||
| 1011 | val = prev - delta; | ||
| 1012 | if (val < 1) | ||
| 1013 | val = 1; | ||
| 1014 | } while (local64_cmpxchg(&event->hw.period_left, prev, val) != prev); | ||
| 1000 | } | 1015 | } |
| 1001 | 1016 | ||
| 1002 | /* | 1017 | /* |
| @@ -1292,6 +1307,9 @@ static void power_pmu_enable(struct pmu *pmu) | |||
| 1292 | out_enable: | 1307 | out_enable: |
| 1293 | pmao_restore_workaround(ebb); | 1308 | pmao_restore_workaround(ebb); |
| 1294 | 1309 | ||
| 1310 | if (ppmu->flags & PPMU_ARCH_207S) | ||
| 1311 | mtspr(SPRN_MMCR2, 0); | ||
| 1312 | |||
| 1295 | mmcr0 = ebb_switch_in(ebb, cpuhw->mmcr[0]); | 1313 | mmcr0 = ebb_switch_in(ebb, cpuhw->mmcr[0]); |
| 1296 | 1314 | ||
| 1297 | mb(); | 1315 | mb(); |
| @@ -1696,7 +1714,7 @@ static int power_pmu_event_init(struct perf_event *event) | |||
| 1696 | 1714 | ||
| 1697 | if (has_branch_stack(event)) { | 1715 | if (has_branch_stack(event)) { |
| 1698 | /* PMU has BHRB enabled */ | 1716 | /* PMU has BHRB enabled */ |
| 1699 | if (!(ppmu->flags & PPMU_BHRB)) | 1717 | if (!(ppmu->flags & PPMU_ARCH_207S)) |
| 1700 | return -EOPNOTSUPP; | 1718 | return -EOPNOTSUPP; |
| 1701 | } | 1719 | } |
| 1702 | 1720 | ||
diff --git a/arch/powerpc/perf/power8-pmu.c b/arch/powerpc/perf/power8-pmu.c index fe2763b6e039..639cd9156585 100644 --- a/arch/powerpc/perf/power8-pmu.c +++ b/arch/powerpc/perf/power8-pmu.c | |||
| @@ -792,7 +792,7 @@ static struct power_pmu power8_pmu = { | |||
| 792 | .get_constraint = power8_get_constraint, | 792 | .get_constraint = power8_get_constraint, |
| 793 | .get_alternatives = power8_get_alternatives, | 793 | .get_alternatives = power8_get_alternatives, |
| 794 | .disable_pmc = power8_disable_pmc, | 794 | .disable_pmc = power8_disable_pmc, |
| 795 | .flags = PPMU_HAS_SSLOT | PPMU_HAS_SIER | PPMU_BHRB | PPMU_EBB, | 795 | .flags = PPMU_HAS_SSLOT | PPMU_HAS_SIER | PPMU_ARCH_207S, |
| 796 | .n_generic = ARRAY_SIZE(power8_generic_events), | 796 | .n_generic = ARRAY_SIZE(power8_generic_events), |
| 797 | .generic_events = power8_generic_events, | 797 | .generic_events = power8_generic_events, |
| 798 | .cache_events = &power8_cache_events, | 798 | .cache_events = &power8_cache_events, |
diff --git a/arch/powerpc/platforms/cell/spu_syscalls.c b/arch/powerpc/platforms/cell/spu_syscalls.c index 38e0a1a5cec3..5e6e0bad6db6 100644 --- a/arch/powerpc/platforms/cell/spu_syscalls.c +++ b/arch/powerpc/platforms/cell/spu_syscalls.c | |||
| @@ -111,6 +111,7 @@ asmlinkage long sys_spu_run(int fd, __u32 __user *unpc, __u32 __user *ustatus) | |||
| 111 | return ret; | 111 | return ret; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | #ifdef CONFIG_COREDUMP | ||
| 114 | int elf_coredump_extra_notes_size(void) | 115 | int elf_coredump_extra_notes_size(void) |
| 115 | { | 116 | { |
| 116 | struct spufs_calls *calls; | 117 | struct spufs_calls *calls; |
| @@ -142,6 +143,7 @@ int elf_coredump_extra_notes_write(struct coredump_params *cprm) | |||
| 142 | 143 | ||
| 143 | return ret; | 144 | return ret; |
| 144 | } | 145 | } |
| 146 | #endif | ||
| 145 | 147 | ||
| 146 | void notify_spus_active(void) | 148 | void notify_spus_active(void) |
| 147 | { | 149 | { |
diff --git a/arch/powerpc/platforms/cell/spufs/Makefile b/arch/powerpc/platforms/cell/spufs/Makefile index b9d5d678aa44..52a7d2596d30 100644 --- a/arch/powerpc/platforms/cell/spufs/Makefile +++ b/arch/powerpc/platforms/cell/spufs/Makefile | |||
| @@ -1,8 +1,9 @@ | |||
| 1 | 1 | ||
| 2 | obj-$(CONFIG_SPU_FS) += spufs.o | 2 | obj-$(CONFIG_SPU_FS) += spufs.o |
| 3 | spufs-y += inode.o file.o context.o syscalls.o coredump.o | 3 | spufs-y += inode.o file.o context.o syscalls.o |
| 4 | spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o | 4 | spufs-y += sched.o backing_ops.o hw_ops.o run.o gang.o |
| 5 | spufs-y += switch.o fault.o lscsa_alloc.o | 5 | spufs-y += switch.o fault.o lscsa_alloc.o |
| 6 | spufs-$(CONFIG_COREDUMP) += coredump.o | ||
| 6 | 7 | ||
| 7 | # magic for the trace events | 8 | # magic for the trace events |
| 8 | CFLAGS_sched.o := -I$(src) | 9 | CFLAGS_sched.o := -I$(src) |
diff --git a/arch/powerpc/platforms/cell/spufs/syscalls.c b/arch/powerpc/platforms/cell/spufs/syscalls.c index b045fdda4845..a87200a535fa 100644 --- a/arch/powerpc/platforms/cell/spufs/syscalls.c +++ b/arch/powerpc/platforms/cell/spufs/syscalls.c | |||
| @@ -79,8 +79,10 @@ static long do_spu_create(const char __user *pathname, unsigned int flags, | |||
| 79 | struct spufs_calls spufs_calls = { | 79 | struct spufs_calls spufs_calls = { |
| 80 | .create_thread = do_spu_create, | 80 | .create_thread = do_spu_create, |
| 81 | .spu_run = do_spu_run, | 81 | .spu_run = do_spu_run, |
| 82 | .coredump_extra_notes_size = spufs_coredump_extra_notes_size, | ||
| 83 | .coredump_extra_notes_write = spufs_coredump_extra_notes_write, | ||
| 84 | .notify_spus_active = do_notify_spus_active, | 82 | .notify_spus_active = do_notify_spus_active, |
| 85 | .owner = THIS_MODULE, | 83 | .owner = THIS_MODULE, |
| 84 | #ifdef CONFIG_COREDUMP | ||
| 85 | .coredump_extra_notes_size = spufs_coredump_extra_notes_size, | ||
| 86 | .coredump_extra_notes_write = spufs_coredump_extra_notes_write, | ||
| 87 | #endif | ||
| 86 | }; | 88 | }; |
diff --git a/arch/powerpc/platforms/powernv/opal-elog.c b/arch/powerpc/platforms/powernv/opal-elog.c index 10268c41d830..0ad533b617f7 100644 --- a/arch/powerpc/platforms/powernv/opal-elog.c +++ b/arch/powerpc/platforms/powernv/opal-elog.c | |||
| @@ -249,7 +249,7 @@ static void elog_work_fn(struct work_struct *work) | |||
| 249 | 249 | ||
| 250 | rc = opal_get_elog_size(&id, &size, &type); | 250 | rc = opal_get_elog_size(&id, &size, &type); |
| 251 | if (rc != OPAL_SUCCESS) { | 251 | if (rc != OPAL_SUCCESS) { |
| 252 | pr_err("ELOG: Opal log read failed\n"); | 252 | pr_err("ELOG: OPAL log info read failed\n"); |
| 253 | return; | 253 | return; |
| 254 | } | 254 | } |
| 255 | 255 | ||
| @@ -257,7 +257,7 @@ static void elog_work_fn(struct work_struct *work) | |||
| 257 | log_id = be64_to_cpu(id); | 257 | log_id = be64_to_cpu(id); |
| 258 | elog_type = be64_to_cpu(type); | 258 | elog_type = be64_to_cpu(type); |
| 259 | 259 | ||
| 260 | BUG_ON(elog_size > OPAL_MAX_ERRLOG_SIZE); | 260 | WARN_ON(elog_size > OPAL_MAX_ERRLOG_SIZE); |
| 261 | 261 | ||
| 262 | if (elog_size >= OPAL_MAX_ERRLOG_SIZE) | 262 | if (elog_size >= OPAL_MAX_ERRLOG_SIZE) |
| 263 | elog_size = OPAL_MAX_ERRLOG_SIZE; | 263 | elog_size = OPAL_MAX_ERRLOG_SIZE; |
diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c index 022b38e6a80b..2d0b4d68a40a 100644 --- a/arch/powerpc/platforms/pseries/dlpar.c +++ b/arch/powerpc/platforms/pseries/dlpar.c | |||
| @@ -86,6 +86,7 @@ static struct device_node *dlpar_parse_cc_node(struct cc_workarea *ccwa, | |||
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | of_node_set_flag(dn, OF_DYNAMIC); | 88 | of_node_set_flag(dn, OF_DYNAMIC); |
| 89 | of_node_init(dn); | ||
| 89 | 90 | ||
| 90 | return dn; | 91 | return dn; |
| 91 | } | 92 | } |
diff --git a/arch/powerpc/platforms/pseries/reconfig.c b/arch/powerpc/platforms/pseries/reconfig.c index 0435bb65d0aa..1c0a60d98867 100644 --- a/arch/powerpc/platforms/pseries/reconfig.c +++ b/arch/powerpc/platforms/pseries/reconfig.c | |||
| @@ -69,6 +69,7 @@ static int pSeries_reconfig_add_node(const char *path, struct property *proplist | |||
| 69 | 69 | ||
| 70 | np->properties = proplist; | 70 | np->properties = proplist; |
| 71 | of_node_set_flag(np, OF_DYNAMIC); | 71 | of_node_set_flag(np, OF_DYNAMIC); |
| 72 | of_node_init(np); | ||
| 72 | 73 | ||
| 73 | np->parent = derive_parent(path); | 74 | np->parent = derive_parent(path); |
| 74 | if (IS_ERR(np->parent)) { | 75 | if (IS_ERR(np->parent)) { |
diff --git a/arch/s390/include/asm/switch_to.h b/arch/s390/include/asm/switch_to.h index df38c70cd59e..18ea9e3f8142 100644 --- a/arch/s390/include/asm/switch_to.h +++ b/arch/s390/include/asm/switch_to.h | |||
| @@ -51,8 +51,8 @@ static inline int restore_fp_ctl(u32 *fpc) | |||
| 51 | return 0; | 51 | return 0; |
| 52 | 52 | ||
| 53 | asm volatile( | 53 | asm volatile( |
| 54 | "0: lfpc %1\n" | 54 | " lfpc %1\n" |
| 55 | " la %0,0\n" | 55 | "0: la %0,0\n" |
| 56 | "1:\n" | 56 | "1:\n" |
| 57 | EX_TABLE(0b,1b) | 57 | EX_TABLE(0b,1b) |
| 58 | : "=d" (rc) : "Q" (*fpc), "0" (-EINVAL)); | 58 | : "=d" (rc) : "Q" (*fpc), "0" (-EINVAL)); |
diff --git a/arch/s390/kernel/head.S b/arch/s390/kernel/head.S index 7ba7d6784510..e88d35d74950 100644 --- a/arch/s390/kernel/head.S +++ b/arch/s390/kernel/head.S | |||
| @@ -437,11 +437,11 @@ ENTRY(startup_kdump) | |||
| 437 | 437 | ||
| 438 | #if defined(CONFIG_64BIT) | 438 | #if defined(CONFIG_64BIT) |
| 439 | #if defined(CONFIG_MARCH_ZEC12) | 439 | #if defined(CONFIG_MARCH_ZEC12) |
| 440 | .long 3, 0xc100efea, 0xf46ce800, 0x00400000 | 440 | .long 3, 0xc100eff2, 0xf46ce800, 0x00400000 |
| 441 | #elif defined(CONFIG_MARCH_Z196) | 441 | #elif defined(CONFIG_MARCH_Z196) |
| 442 | .long 2, 0xc100efea, 0xf46c0000 | 442 | .long 2, 0xc100eff2, 0xf46c0000 |
| 443 | #elif defined(CONFIG_MARCH_Z10) | 443 | #elif defined(CONFIG_MARCH_Z10) |
| 444 | .long 2, 0xc100efea, 0xf0680000 | 444 | .long 2, 0xc100eff2, 0xf0680000 |
| 445 | #elif defined(CONFIG_MARCH_Z9_109) | 445 | #elif defined(CONFIG_MARCH_Z9_109) |
| 446 | .long 1, 0xc100efc2 | 446 | .long 1, 0xc100efc2 |
| 447 | #elif defined(CONFIG_MARCH_Z990) | 447 | #elif defined(CONFIG_MARCH_Z990) |
diff --git a/arch/s390/kernel/ptrace.c b/arch/s390/kernel/ptrace.c index 2d716734b5b1..5dc7ad9e2fbf 100644 --- a/arch/s390/kernel/ptrace.c +++ b/arch/s390/kernel/ptrace.c | |||
| @@ -334,9 +334,14 @@ static int __poke_user(struct task_struct *child, addr_t addr, addr_t data) | |||
| 334 | unsigned long mask = PSW_MASK_USER; | 334 | unsigned long mask = PSW_MASK_USER; |
| 335 | 335 | ||
| 336 | mask |= is_ri_task(child) ? PSW_MASK_RI : 0; | 336 | mask |= is_ri_task(child) ? PSW_MASK_RI : 0; |
| 337 | if ((data & ~mask) != PSW_USER_BITS) | 337 | if ((data ^ PSW_USER_BITS) & ~mask) |
| 338 | /* Invalid psw mask. */ | ||
| 339 | return -EINVAL; | ||
| 340 | if ((data & PSW_MASK_ASC) == PSW_ASC_HOME) | ||
| 341 | /* Invalid address-space-control bits */ | ||
| 338 | return -EINVAL; | 342 | return -EINVAL; |
| 339 | if ((data & PSW_MASK_EA) && !(data & PSW_MASK_BA)) | 343 | if ((data & PSW_MASK_EA) && !(data & PSW_MASK_BA)) |
| 344 | /* Invalid addressing mode bits */ | ||
| 340 | return -EINVAL; | 345 | return -EINVAL; |
| 341 | } | 346 | } |
| 342 | *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data; | 347 | *(addr_t *)((addr_t) &task_pt_regs(child)->psw + addr) = data; |
| @@ -672,9 +677,12 @@ static int __poke_user_compat(struct task_struct *child, | |||
| 672 | 677 | ||
| 673 | mask |= is_ri_task(child) ? PSW32_MASK_RI : 0; | 678 | mask |= is_ri_task(child) ? PSW32_MASK_RI : 0; |
| 674 | /* Build a 64 bit psw mask from 31 bit mask. */ | 679 | /* Build a 64 bit psw mask from 31 bit mask. */ |
| 675 | if ((tmp & ~mask) != PSW32_USER_BITS) | 680 | if ((tmp ^ PSW32_USER_BITS) & ~mask) |
| 676 | /* Invalid psw mask. */ | 681 | /* Invalid psw mask. */ |
| 677 | return -EINVAL; | 682 | return -EINVAL; |
| 683 | if ((data & PSW32_MASK_ASC) == PSW32_ASC_HOME) | ||
| 684 | /* Invalid address-space-control bits */ | ||
| 685 | return -EINVAL; | ||
| 678 | regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) | | 686 | regs->psw.mask = (regs->psw.mask & ~PSW_MASK_USER) | |
| 679 | (regs->psw.mask & PSW_MASK_BA) | | 687 | (regs->psw.mask & PSW_MASK_BA) | |
| 680 | (__u64)(tmp & mask) << 32; | 688 | (__u64)(tmp & mask) << 32; |
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 9ddc51eeb8d6..30de42730b2f 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c | |||
| @@ -48,13 +48,10 @@ | |||
| 48 | static LIST_HEAD(zpci_list); | 48 | static LIST_HEAD(zpci_list); |
| 49 | static DEFINE_SPINLOCK(zpci_list_lock); | 49 | static DEFINE_SPINLOCK(zpci_list_lock); |
| 50 | 50 | ||
| 51 | static void zpci_enable_irq(struct irq_data *data); | ||
| 52 | static void zpci_disable_irq(struct irq_data *data); | ||
| 53 | |||
| 54 | static struct irq_chip zpci_irq_chip = { | 51 | static struct irq_chip zpci_irq_chip = { |
| 55 | .name = "zPCI", | 52 | .name = "zPCI", |
| 56 | .irq_unmask = zpci_enable_irq, | 53 | .irq_unmask = unmask_msi_irq, |
| 57 | .irq_mask = zpci_disable_irq, | 54 | .irq_mask = mask_msi_irq, |
| 58 | }; | 55 | }; |
| 59 | 56 | ||
| 60 | static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES); | 57 | static DECLARE_BITMAP(zpci_domain, ZPCI_NR_DEVICES); |
| @@ -244,43 +241,6 @@ static int zpci_cfg_store(struct zpci_dev *zdev, int offset, u32 val, u8 len) | |||
| 244 | return rc; | 241 | return rc; |
| 245 | } | 242 | } |
| 246 | 243 | ||
| 247 | static int zpci_msi_set_mask_bits(struct msi_desc *msi, u32 mask, u32 flag) | ||
| 248 | { | ||
| 249 | int offset, pos; | ||
| 250 | u32 mask_bits; | ||
| 251 | |||
| 252 | if (msi->msi_attrib.is_msix) { | ||
| 253 | offset = msi->msi_attrib.entry_nr * PCI_MSIX_ENTRY_SIZE + | ||
| 254 | PCI_MSIX_ENTRY_VECTOR_CTRL; | ||
| 255 | msi->masked = readl(msi->mask_base + offset); | ||
| 256 | writel(flag, msi->mask_base + offset); | ||
| 257 | } else if (msi->msi_attrib.maskbit) { | ||
| 258 | pos = (long) msi->mask_base; | ||
| 259 | pci_read_config_dword(msi->dev, pos, &mask_bits); | ||
| 260 | mask_bits &= ~(mask); | ||
| 261 | mask_bits |= flag & mask; | ||
| 262 | pci_write_config_dword(msi->dev, pos, mask_bits); | ||
| 263 | } else | ||
| 264 | return 0; | ||
| 265 | |||
| 266 | msi->msi_attrib.maskbit = !!flag; | ||
| 267 | return 1; | ||
| 268 | } | ||
| 269 | |||
| 270 | static void zpci_enable_irq(struct irq_data *data) | ||
| 271 | { | ||
| 272 | struct msi_desc *msi = irq_get_msi_desc(data->irq); | ||
| 273 | |||
| 274 | zpci_msi_set_mask_bits(msi, 1, 0); | ||
| 275 | } | ||
| 276 | |||
| 277 | static void zpci_disable_irq(struct irq_data *data) | ||
| 278 | { | ||
| 279 | struct msi_desc *msi = irq_get_msi_desc(data->irq); | ||
| 280 | |||
| 281 | zpci_msi_set_mask_bits(msi, 1, 1); | ||
| 282 | } | ||
| 283 | |||
| 284 | void pcibios_fixup_bus(struct pci_bus *bus) | 244 | void pcibios_fixup_bus(struct pci_bus *bus) |
| 285 | { | 245 | { |
| 286 | } | 246 | } |
| @@ -487,7 +447,10 @@ void arch_teardown_msi_irqs(struct pci_dev *pdev) | |||
| 487 | 447 | ||
| 488 | /* Release MSI interrupts */ | 448 | /* Release MSI interrupts */ |
| 489 | list_for_each_entry(msi, &pdev->msi_list, list) { | 449 | list_for_each_entry(msi, &pdev->msi_list, list) { |
| 490 | zpci_msi_set_mask_bits(msi, 1, 1); | 450 | if (msi->msi_attrib.is_msix) |
| 451 | default_msix_mask_irq(msi, 1); | ||
| 452 | else | ||
| 453 | default_msi_mask_irq(msi, 1, 1); | ||
| 491 | irq_set_msi_desc(msi->irq, NULL); | 454 | irq_set_msi_desc(msi->irq, NULL); |
| 492 | irq_free_desc(msi->irq); | 455 | irq_free_desc(msi->irq); |
| 493 | msi->msg.address_lo = 0; | 456 | msi->msg.address_lo = 0; |
diff --git a/arch/sh/Makefile b/arch/sh/Makefile index d4d16e4be07c..bf5b3f5f4962 100644 --- a/arch/sh/Makefile +++ b/arch/sh/Makefile | |||
| @@ -32,7 +32,8 @@ endif | |||
| 32 | 32 | ||
| 33 | cflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,) | 33 | cflags-$(CONFIG_CPU_SH2) := $(call cc-option,-m2,) |
| 34 | cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \ | 34 | cflags-$(CONFIG_CPU_SH2A) += $(call cc-option,-m2a,) \ |
| 35 | $(call cc-option,-m2a-nofpu,) | 35 | $(call cc-option,-m2a-nofpu,) \ |
| 36 | $(call cc-option,-m4-nofpu,) | ||
| 36 | cflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,) | 37 | cflags-$(CONFIG_CPU_SH3) := $(call cc-option,-m3,) |
| 37 | cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \ | 38 | cflags-$(CONFIG_CPU_SH4) := $(call cc-option,-m4,) \ |
| 38 | $(call cc-option,-mno-implicit-fp,-m4-nofpu) | 39 | $(call cc-option,-mno-implicit-fp,-m4-nofpu) |
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index 85d5255d259f..0d3049244cd3 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c | |||
| @@ -874,6 +874,8 @@ static struct platform_device fsi_da7210_device = { | |||
| 874 | .name = "asoc-simple-card", | 874 | .name = "asoc-simple-card", |
| 875 | .dev = { | 875 | .dev = { |
| 876 | .platform_data = &fsi_da7210_info, | 876 | .platform_data = &fsi_da7210_info, |
| 877 | .coherent_dma_mask = DMA_BIT_MASK(32), | ||
| 878 | .dma_mask = &fsi_da7210_device.dev.coherent_dma_mask, | ||
| 877 | }, | 879 | }, |
| 878 | }; | 880 | }; |
| 879 | 881 | ||
diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig index 29f2e988c56a..407c87d9879a 100644 --- a/arch/sparc/Kconfig +++ b/arch/sparc/Kconfig | |||
| @@ -78,6 +78,7 @@ config SPARC64 | |||
| 78 | select HAVE_C_RECORDMCOUNT | 78 | select HAVE_C_RECORDMCOUNT |
| 79 | select NO_BOOTMEM | 79 | select NO_BOOTMEM |
| 80 | select HAVE_ARCH_AUDITSYSCALL | 80 | select HAVE_ARCH_AUDITSYSCALL |
| 81 | select ARCH_SUPPORTS_ATOMIC_RMW | ||
| 81 | 82 | ||
| 82 | config ARCH_DEFCONFIG | 83 | config ARCH_DEFCONFIG |
| 83 | string | 84 | string |
diff --git a/arch/sparc/include/uapi/asm/unistd.h b/arch/sparc/include/uapi/asm/unistd.h index b73274fb961a..42f2bca1d338 100644 --- a/arch/sparc/include/uapi/asm/unistd.h +++ b/arch/sparc/include/uapi/asm/unistd.h | |||
| @@ -410,8 +410,9 @@ | |||
| 410 | #define __NR_finit_module 342 | 410 | #define __NR_finit_module 342 |
| 411 | #define __NR_sched_setattr 343 | 411 | #define __NR_sched_setattr 343 |
| 412 | #define __NR_sched_getattr 344 | 412 | #define __NR_sched_getattr 344 |
| 413 | #define __NR_renameat2 345 | ||
| 413 | 414 | ||
| 414 | #define NR_syscalls 345 | 415 | #define NR_syscalls 346 |
| 415 | 416 | ||
| 416 | /* Bitmask values returned from kern_features system call. */ | 417 | /* Bitmask values returned from kern_features system call. */ |
| 417 | #define KERN_FEATURE_MIXED_MODE_STACK 0x00000001 | 418 | #define KERN_FEATURE_MIXED_MODE_STACK 0x00000001 |
diff --git a/arch/sparc/kernel/sys32.S b/arch/sparc/kernel/sys32.S index d066eb18650c..f834224208ed 100644 --- a/arch/sparc/kernel/sys32.S +++ b/arch/sparc/kernel/sys32.S | |||
| @@ -48,6 +48,7 @@ SIGN1(sys32_futex, compat_sys_futex, %o1) | |||
| 48 | SIGN1(sys32_recvfrom, compat_sys_recvfrom, %o0) | 48 | SIGN1(sys32_recvfrom, compat_sys_recvfrom, %o0) |
| 49 | SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0) | 49 | SIGN1(sys32_recvmsg, compat_sys_recvmsg, %o0) |
| 50 | SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0) | 50 | SIGN1(sys32_sendmsg, compat_sys_sendmsg, %o0) |
| 51 | SIGN2(sys32_renameat2, sys_renameat2, %o0, %o2) | ||
| 51 | 52 | ||
| 52 | .globl sys32_mmap2 | 53 | .globl sys32_mmap2 |
| 53 | sys32_mmap2: | 54 | sys32_mmap2: |
diff --git a/arch/sparc/kernel/systbls_32.S b/arch/sparc/kernel/systbls_32.S index 151ace8766cc..85fe9b1087cd 100644 --- a/arch/sparc/kernel/systbls_32.S +++ b/arch/sparc/kernel/systbls_32.S | |||
| @@ -86,3 +86,4 @@ sys_call_table: | |||
| 86 | /*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime | 86 | /*330*/ .long sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime |
| 87 | /*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev | 87 | /*335*/ .long sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev |
| 88 | /*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr | 88 | /*340*/ .long sys_ni_syscall, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr |
| 89 | /*345*/ .long sys_renameat2 | ||
diff --git a/arch/sparc/kernel/systbls_64.S b/arch/sparc/kernel/systbls_64.S index 4bd4e2bb26cf..33ecba2826ea 100644 --- a/arch/sparc/kernel/systbls_64.S +++ b/arch/sparc/kernel/systbls_64.S | |||
| @@ -87,6 +87,7 @@ sys_call_table32: | |||
| 87 | /*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime | 87 | /*330*/ .word compat_sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, compat_sys_open_by_handle_at, compat_sys_clock_adjtime |
| 88 | .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev | 88 | .word sys_syncfs, compat_sys_sendmmsg, sys_setns, compat_sys_process_vm_readv, compat_sys_process_vm_writev |
| 89 | /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr | 89 | /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr |
| 90 | .word sys32_renameat2 | ||
| 90 | 91 | ||
| 91 | #endif /* CONFIG_COMPAT */ | 92 | #endif /* CONFIG_COMPAT */ |
| 92 | 93 | ||
| @@ -165,3 +166,4 @@ sys_call_table: | |||
| 165 | /*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime | 166 | /*330*/ .word sys_fanotify_mark, sys_prlimit64, sys_name_to_handle_at, sys_open_by_handle_at, sys_clock_adjtime |
| 166 | .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev | 167 | .word sys_syncfs, sys_sendmmsg, sys_setns, sys_process_vm_readv, sys_process_vm_writev |
| 167 | /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr | 168 | /*340*/ .word sys_kern_features, sys_kcmp, sys_finit_module, sys_sched_setattr, sys_sched_getattr |
| 169 | .word sys_renameat2 | ||
diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c index 9472079471bb..f1b3eb14b855 100644 --- a/arch/um/kernel/tlb.c +++ b/arch/um/kernel/tlb.c | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include <mem_user.h> | 12 | #include <mem_user.h> |
| 13 | #include <os.h> | 13 | #include <os.h> |
| 14 | #include <skas.h> | 14 | #include <skas.h> |
| 15 | #include <kern_util.h> | ||
| 15 | 16 | ||
| 16 | struct host_vm_change { | 17 | struct host_vm_change { |
| 17 | struct host_vm_op { | 18 | struct host_vm_op { |
| @@ -124,6 +125,9 @@ static int add_munmap(unsigned long addr, unsigned long len, | |||
| 124 | struct host_vm_op *last; | 125 | struct host_vm_op *last; |
| 125 | int ret = 0; | 126 | int ret = 0; |
| 126 | 127 | ||
| 128 | if ((addr >= STUB_START) && (addr < STUB_END)) | ||
| 129 | return -EINVAL; | ||
| 130 | |||
| 127 | if (hvc->index != 0) { | 131 | if (hvc->index != 0) { |
| 128 | last = &hvc->ops[hvc->index - 1]; | 132 | last = &hvc->ops[hvc->index - 1]; |
| 129 | if ((last->type == MUNMAP) && | 133 | if ((last->type == MUNMAP) && |
| @@ -283,8 +287,11 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr, | |||
| 283 | /* This is not an else because ret is modified above */ | 287 | /* This is not an else because ret is modified above */ |
| 284 | if (ret) { | 288 | if (ret) { |
| 285 | printk(KERN_ERR "fix_range_common: failed, killing current " | 289 | printk(KERN_ERR "fix_range_common: failed, killing current " |
| 286 | "process\n"); | 290 | "process: %d\n", task_tgid_vnr(current)); |
| 291 | /* We are under mmap_sem, release it such that current can terminate */ | ||
| 292 | up_write(¤t->mm->mmap_sem); | ||
| 287 | force_sig(SIGKILL, current); | 293 | force_sig(SIGKILL, current); |
| 294 | do_signal(); | ||
| 288 | } | 295 | } |
| 289 | } | 296 | } |
| 290 | 297 | ||
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c index 974b87474a99..5678c3571e7c 100644 --- a/arch/um/kernel/trap.c +++ b/arch/um/kernel/trap.c | |||
| @@ -206,7 +206,7 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user, | |||
| 206 | int is_write = FAULT_WRITE(fi); | 206 | int is_write = FAULT_WRITE(fi); |
| 207 | unsigned long address = FAULT_ADDRESS(fi); | 207 | unsigned long address = FAULT_ADDRESS(fi); |
| 208 | 208 | ||
| 209 | if (regs) | 209 | if (!is_user && regs) |
| 210 | current->thread.segv_regs = container_of(regs, struct pt_regs, regs); | 210 | current->thread.segv_regs = container_of(regs, struct pt_regs, regs); |
| 211 | 211 | ||
| 212 | if (!is_user && (address >= start_vm) && (address < end_vm)) { | 212 | if (!is_user && (address >= start_vm) && (address < end_vm)) { |
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c index d531879a4617..908579f2b0ab 100644 --- a/arch/um/os-Linux/skas/process.c +++ b/arch/um/os-Linux/skas/process.c | |||
| @@ -54,7 +54,7 @@ static int ptrace_dump_regs(int pid) | |||
| 54 | 54 | ||
| 55 | void wait_stub_done(int pid) | 55 | void wait_stub_done(int pid) |
| 56 | { | 56 | { |
| 57 | int n, status, err, bad_stop = 0; | 57 | int n, status, err; |
| 58 | 58 | ||
| 59 | while (1) { | 59 | while (1) { |
| 60 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL)); | 60 | CATCH_EINTR(n = waitpid(pid, &status, WUNTRACED | __WALL)); |
| @@ -74,8 +74,6 @@ void wait_stub_done(int pid) | |||
| 74 | 74 | ||
| 75 | if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0) | 75 | if (((1 << WSTOPSIG(status)) & STUB_DONE_MASK) != 0) |
| 76 | return; | 76 | return; |
| 77 | else | ||
| 78 | bad_stop = 1; | ||
| 79 | 77 | ||
| 80 | bad_wait: | 78 | bad_wait: |
| 81 | err = ptrace_dump_regs(pid); | 79 | err = ptrace_dump_regs(pid); |
| @@ -85,10 +83,7 @@ bad_wait: | |||
| 85 | printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, " | 83 | printk(UM_KERN_ERR "wait_stub_done : failed to wait for SIGTRAP, " |
| 86 | "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno, | 84 | "pid = %d, n = %d, errno = %d, status = 0x%x\n", pid, n, errno, |
| 87 | status); | 85 | status); |
| 88 | if (bad_stop) | 86 | fatal_sigsegv(); |
| 89 | kill(pid, SIGKILL); | ||
| 90 | else | ||
| 91 | fatal_sigsegv(); | ||
| 92 | } | 87 | } |
| 93 | 88 | ||
| 94 | extern unsigned long current_stub_stack(void); | 89 | extern unsigned long current_stub_stack(void); |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index a8f749ef0fdc..d24887b645dc 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -131,6 +131,7 @@ config X86 | |||
| 131 | select HAVE_CC_STACKPROTECTOR | 131 | select HAVE_CC_STACKPROTECTOR |
| 132 | select GENERIC_CPU_AUTOPROBE | 132 | select GENERIC_CPU_AUTOPROBE |
| 133 | select HAVE_ARCH_AUDITSYSCALL | 133 | select HAVE_ARCH_AUDITSYSCALL |
| 134 | select ARCH_SUPPORTS_ATOMIC_RMW | ||
| 134 | 135 | ||
| 135 | config INSTRUCTION_DECODER | 136 | config INSTRUCTION_DECODER |
| 136 | def_bool y | 137 | def_bool y |
diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S index 84c223479e3c..7a6d43a554d7 100644 --- a/arch/x86/boot/header.S +++ b/arch/x86/boot/header.S | |||
| @@ -91,10 +91,9 @@ bs_die: | |||
| 91 | 91 | ||
| 92 | .section ".bsdata", "a" | 92 | .section ".bsdata", "a" |
| 93 | bugger_off_msg: | 93 | bugger_off_msg: |
| 94 | .ascii "Direct floppy boot is not supported. " | 94 | .ascii "Use a boot loader.\r\n" |
| 95 | .ascii "Use a boot loader program instead.\r\n" | ||
| 96 | .ascii "\n" | 95 | .ascii "\n" |
| 97 | .ascii "Remove disk and press any key to reboot ...\r\n" | 96 | .ascii "Remove disk and press any key to reboot...\r\n" |
| 98 | .byte 0 | 97 | .byte 0 |
| 99 | 98 | ||
| 100 | #ifdef CONFIG_EFI_STUB | 99 | #ifdef CONFIG_EFI_STUB |
| @@ -108,7 +107,7 @@ coff_header: | |||
| 108 | #else | 107 | #else |
| 109 | .word 0x8664 # x86-64 | 108 | .word 0x8664 # x86-64 |
| 110 | #endif | 109 | #endif |
| 111 | .word 3 # nr_sections | 110 | .word 4 # nr_sections |
| 112 | .long 0 # TimeDateStamp | 111 | .long 0 # TimeDateStamp |
| 113 | .long 0 # PointerToSymbolTable | 112 | .long 0 # PointerToSymbolTable |
| 114 | .long 1 # NumberOfSymbols | 113 | .long 1 # NumberOfSymbols |
| @@ -250,6 +249,25 @@ section_table: | |||
| 250 | .word 0 # NumberOfLineNumbers | 249 | .word 0 # NumberOfLineNumbers |
| 251 | .long 0x60500020 # Characteristics (section flags) | 250 | .long 0x60500020 # Characteristics (section flags) |
| 252 | 251 | ||
| 252 | # | ||
| 253 | # The offset & size fields are filled in by build.c. | ||
| 254 | # | ||
| 255 | .ascii ".bss" | ||
| 256 | .byte 0 | ||
| 257 | .byte 0 | ||
| 258 | .byte 0 | ||
| 259 | .byte 0 | ||
| 260 | .long 0 | ||
| 261 | .long 0x0 | ||
| 262 | .long 0 # Size of initialized data | ||
| 263 | # on disk | ||
| 264 | .long 0x0 | ||
| 265 | .long 0 # PointerToRelocations | ||
| 266 | .long 0 # PointerToLineNumbers | ||
| 267 | .word 0 # NumberOfRelocations | ||
| 268 | .word 0 # NumberOfLineNumbers | ||
| 269 | .long 0xc8000080 # Characteristics (section flags) | ||
| 270 | |||
| 253 | #endif /* CONFIG_EFI_STUB */ | 271 | #endif /* CONFIG_EFI_STUB */ |
| 254 | 272 | ||
| 255 | # Kernel attributes; used by setup. This is part 1 of the | 273 | # Kernel attributes; used by setup. This is part 1 of the |
diff --git a/arch/x86/boot/tools/build.c b/arch/x86/boot/tools/build.c index 1a2f2121cada..a7661c430cd9 100644 --- a/arch/x86/boot/tools/build.c +++ b/arch/x86/boot/tools/build.c | |||
| @@ -143,7 +143,7 @@ static void usage(void) | |||
| 143 | 143 | ||
| 144 | #ifdef CONFIG_EFI_STUB | 144 | #ifdef CONFIG_EFI_STUB |
| 145 | 145 | ||
| 146 | static void update_pecoff_section_header(char *section_name, u32 offset, u32 size) | 146 | static void update_pecoff_section_header_fields(char *section_name, u32 vma, u32 size, u32 datasz, u32 offset) |
| 147 | { | 147 | { |
| 148 | unsigned int pe_header; | 148 | unsigned int pe_header; |
| 149 | unsigned short num_sections; | 149 | unsigned short num_sections; |
| @@ -164,10 +164,10 @@ static void update_pecoff_section_header(char *section_name, u32 offset, u32 siz | |||
| 164 | put_unaligned_le32(size, section + 0x8); | 164 | put_unaligned_le32(size, section + 0x8); |
| 165 | 165 | ||
| 166 | /* section header vma field */ | 166 | /* section header vma field */ |
| 167 | put_unaligned_le32(offset, section + 0xc); | 167 | put_unaligned_le32(vma, section + 0xc); |
| 168 | 168 | ||
| 169 | /* section header 'size of initialised data' field */ | 169 | /* section header 'size of initialised data' field */ |
| 170 | put_unaligned_le32(size, section + 0x10); | 170 | put_unaligned_le32(datasz, section + 0x10); |
| 171 | 171 | ||
| 172 | /* section header 'file offset' field */ | 172 | /* section header 'file offset' field */ |
| 173 | put_unaligned_le32(offset, section + 0x14); | 173 | put_unaligned_le32(offset, section + 0x14); |
| @@ -179,6 +179,11 @@ static void update_pecoff_section_header(char *section_name, u32 offset, u32 siz | |||
| 179 | } | 179 | } |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | static void update_pecoff_section_header(char *section_name, u32 offset, u32 size) | ||
| 183 | { | ||
| 184 | update_pecoff_section_header_fields(section_name, offset, size, size, offset); | ||
| 185 | } | ||
| 186 | |||
| 182 | static void update_pecoff_setup_and_reloc(unsigned int size) | 187 | static void update_pecoff_setup_and_reloc(unsigned int size) |
| 183 | { | 188 | { |
| 184 | u32 setup_offset = 0x200; | 189 | u32 setup_offset = 0x200; |
| @@ -203,9 +208,6 @@ static void update_pecoff_text(unsigned int text_start, unsigned int file_sz) | |||
| 203 | 208 | ||
| 204 | pe_header = get_unaligned_le32(&buf[0x3c]); | 209 | pe_header = get_unaligned_le32(&buf[0x3c]); |
| 205 | 210 | ||
| 206 | /* Size of image */ | ||
| 207 | put_unaligned_le32(file_sz, &buf[pe_header + 0x50]); | ||
| 208 | |||
| 209 | /* | 211 | /* |
| 210 | * Size of code: Subtract the size of the first sector (512 bytes) | 212 | * Size of code: Subtract the size of the first sector (512 bytes) |
| 211 | * which includes the header. | 213 | * which includes the header. |
| @@ -220,6 +222,22 @@ static void update_pecoff_text(unsigned int text_start, unsigned int file_sz) | |||
| 220 | update_pecoff_section_header(".text", text_start, text_sz); | 222 | update_pecoff_section_header(".text", text_start, text_sz); |
| 221 | } | 223 | } |
| 222 | 224 | ||
| 225 | static void update_pecoff_bss(unsigned int file_sz, unsigned int init_sz) | ||
| 226 | { | ||
| 227 | unsigned int pe_header; | ||
| 228 | unsigned int bss_sz = init_sz - file_sz; | ||
| 229 | |||
| 230 | pe_header = get_unaligned_le32(&buf[0x3c]); | ||
| 231 | |||
| 232 | /* Size of uninitialized data */ | ||
| 233 | put_unaligned_le32(bss_sz, &buf[pe_header + 0x24]); | ||
| 234 | |||
| 235 | /* Size of image */ | ||
| 236 | put_unaligned_le32(init_sz, &buf[pe_header + 0x50]); | ||
| 237 | |||
| 238 | update_pecoff_section_header_fields(".bss", file_sz, bss_sz, 0, 0); | ||
| 239 | } | ||
| 240 | |||
| 223 | static int reserve_pecoff_reloc_section(int c) | 241 | static int reserve_pecoff_reloc_section(int c) |
| 224 | { | 242 | { |
| 225 | /* Reserve 0x20 bytes for .reloc section */ | 243 | /* Reserve 0x20 bytes for .reloc section */ |
| @@ -259,6 +277,8 @@ static void efi_stub_entry_update(void) | |||
| 259 | static inline void update_pecoff_setup_and_reloc(unsigned int size) {} | 277 | static inline void update_pecoff_setup_and_reloc(unsigned int size) {} |
| 260 | static inline void update_pecoff_text(unsigned int text_start, | 278 | static inline void update_pecoff_text(unsigned int text_start, |
| 261 | unsigned int file_sz) {} | 279 | unsigned int file_sz) {} |
| 280 | static inline void update_pecoff_bss(unsigned int file_sz, | ||
| 281 | unsigned int init_sz) {} | ||
| 262 | static inline void efi_stub_defaults(void) {} | 282 | static inline void efi_stub_defaults(void) {} |
| 263 | static inline void efi_stub_entry_update(void) {} | 283 | static inline void efi_stub_entry_update(void) {} |
| 264 | 284 | ||
| @@ -310,7 +330,7 @@ static void parse_zoffset(char *fname) | |||
| 310 | 330 | ||
| 311 | int main(int argc, char ** argv) | 331 | int main(int argc, char ** argv) |
| 312 | { | 332 | { |
| 313 | unsigned int i, sz, setup_sectors; | 333 | unsigned int i, sz, setup_sectors, init_sz; |
| 314 | int c; | 334 | int c; |
| 315 | u32 sys_size; | 335 | u32 sys_size; |
| 316 | struct stat sb; | 336 | struct stat sb; |
| @@ -376,7 +396,9 @@ int main(int argc, char ** argv) | |||
| 376 | buf[0x1f1] = setup_sectors-1; | 396 | buf[0x1f1] = setup_sectors-1; |
| 377 | put_unaligned_le32(sys_size, &buf[0x1f4]); | 397 | put_unaligned_le32(sys_size, &buf[0x1f4]); |
| 378 | 398 | ||
| 379 | update_pecoff_text(setup_sectors * 512, sz + i + ((sys_size * 16) - sz)); | 399 | update_pecoff_text(setup_sectors * 512, i + (sys_size * 16)); |
| 400 | init_sz = get_unaligned_le32(&buf[0x260]); | ||
| 401 | update_pecoff_bss(i + (sys_size * 16), init_sz); | ||
| 380 | 402 | ||
| 381 | efi_stub_entry_update(); | 403 | efi_stub_entry_update(); |
| 382 | 404 | ||
diff --git a/arch/x86/crypto/sha512_ssse3_glue.c b/arch/x86/crypto/sha512_ssse3_glue.c index f30cd10293f0..8626b03e83b7 100644 --- a/arch/x86/crypto/sha512_ssse3_glue.c +++ b/arch/x86/crypto/sha512_ssse3_glue.c | |||
| @@ -141,7 +141,7 @@ static int sha512_ssse3_final(struct shash_desc *desc, u8 *out) | |||
| 141 | 141 | ||
| 142 | /* save number of bits */ | 142 | /* save number of bits */ |
| 143 | bits[1] = cpu_to_be64(sctx->count[0] << 3); | 143 | bits[1] = cpu_to_be64(sctx->count[0] << 3); |
| 144 | bits[0] = cpu_to_be64(sctx->count[1] << 3) | sctx->count[0] >> 61; | 144 | bits[0] = cpu_to_be64(sctx->count[1] << 3 | sctx->count[0] >> 61); |
| 145 | 145 | ||
| 146 | /* Pad out to 112 mod 128 and append length */ | 146 | /* Pad out to 112 mod 128 and append length */ |
| 147 | index = sctx->count[0] & 0x7f; | 147 | index = sctx->count[0] & 0x7f; |
diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h index bba3cf88e624..0a8b519226b8 100644 --- a/arch/x86/include/asm/irqflags.h +++ b/arch/x86/include/asm/irqflags.h | |||
| @@ -129,7 +129,7 @@ static inline notrace unsigned long arch_local_irq_save(void) | |||
| 129 | 129 | ||
| 130 | #define PARAVIRT_ADJUST_EXCEPTION_FRAME /* */ | 130 | #define PARAVIRT_ADJUST_EXCEPTION_FRAME /* */ |
| 131 | 131 | ||
| 132 | #define INTERRUPT_RETURN iretq | 132 | #define INTERRUPT_RETURN jmp native_iret |
| 133 | #define USERGS_SYSRET64 \ | 133 | #define USERGS_SYSRET64 \ |
| 134 | swapgs; \ | 134 | swapgs; \ |
| 135 | sysretq; | 135 | sysretq; |
diff --git a/arch/x86/include/asm/platform_sst_audio.h b/arch/x86/include/asm/platform_sst_audio.h new file mode 100644 index 000000000000..0a4e140315b6 --- /dev/null +++ b/arch/x86/include/asm/platform_sst_audio.h | |||
| @@ -0,0 +1,78 @@ | |||
| 1 | /* | ||
| 2 | * platform_sst_audio.h: sst audio platform data header file | ||
| 3 | * | ||
| 4 | * Copyright (C) 2012-14 Intel Corporation | ||
| 5 | * Author: Jeeja KP <jeeja.kp@intel.com> | ||
| 6 | * Omair Mohammed Abdullah <omair.m.abdullah@intel.com> | ||
| 7 | * Vinod Koul ,vinod.koul@intel.com> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or | ||
| 10 | * modify it under the terms of the GNU General Public License | ||
| 11 | * as published by the Free Software Foundation; version 2 | ||
| 12 | * of the License. | ||
| 13 | */ | ||
| 14 | #ifndef _PLATFORM_SST_AUDIO_H_ | ||
| 15 | #define _PLATFORM_SST_AUDIO_H_ | ||
| 16 | |||
| 17 | #include <linux/sfi.h> | ||
| 18 | |||
| 19 | enum sst_audio_task_id_mrfld { | ||
| 20 | SST_TASK_ID_NONE = 0, | ||
| 21 | SST_TASK_ID_SBA = 1, | ||
| 22 | SST_TASK_ID_MEDIA = 3, | ||
| 23 | SST_TASK_ID_MAX = SST_TASK_ID_MEDIA, | ||
| 24 | }; | ||
| 25 | |||
| 26 | /* Device IDs for Merrifield are Pipe IDs, | ||
| 27 | * ref: DSP spec v0.75 */ | ||
| 28 | enum sst_audio_device_id_mrfld { | ||
| 29 | /* Output pipeline IDs */ | ||
| 30 | PIPE_ID_OUT_START = 0x0, | ||
| 31 | PIPE_CODEC_OUT0 = 0x2, | ||
| 32 | PIPE_CODEC_OUT1 = 0x3, | ||
| 33 | PIPE_SPROT_LOOP_OUT = 0x4, | ||
| 34 | PIPE_MEDIA_LOOP1_OUT = 0x5, | ||
| 35 | PIPE_MEDIA_LOOP2_OUT = 0x6, | ||
| 36 | PIPE_VOIP_OUT = 0xC, | ||
| 37 | PIPE_PCM0_OUT = 0xD, | ||
| 38 | PIPE_PCM1_OUT = 0xE, | ||
| 39 | PIPE_PCM2_OUT = 0xF, | ||
| 40 | PIPE_MEDIA0_OUT = 0x12, | ||
| 41 | PIPE_MEDIA1_OUT = 0x13, | ||
| 42 | /* Input Pipeline IDs */ | ||
| 43 | PIPE_ID_IN_START = 0x80, | ||
| 44 | PIPE_CODEC_IN0 = 0x82, | ||
| 45 | PIPE_CODEC_IN1 = 0x83, | ||
| 46 | PIPE_SPROT_LOOP_IN = 0x84, | ||
| 47 | PIPE_MEDIA_LOOP1_IN = 0x85, | ||
| 48 | PIPE_MEDIA_LOOP2_IN = 0x86, | ||
| 49 | PIPE_VOIP_IN = 0x8C, | ||
| 50 | PIPE_PCM0_IN = 0x8D, | ||
| 51 | PIPE_PCM1_IN = 0x8E, | ||
| 52 | PIPE_MEDIA0_IN = 0x8F, | ||
| 53 | PIPE_MEDIA1_IN = 0x90, | ||
| 54 | PIPE_MEDIA2_IN = 0x91, | ||
| 55 | PIPE_RSVD = 0xFF, | ||
| 56 | }; | ||
| 57 | |||
| 58 | /* The stream map for each platform consists of an array of the below | ||
| 59 | * stream map structure. | ||
| 60 | */ | ||
| 61 | struct sst_dev_stream_map { | ||
| 62 | u8 dev_num; /* device id */ | ||
| 63 | u8 subdev_num; /* substream */ | ||
| 64 | u8 direction; | ||
| 65 | u8 device_id; /* fw id */ | ||
| 66 | u8 task_id; /* fw task */ | ||
| 67 | u8 status; | ||
| 68 | }; | ||
| 69 | |||
| 70 | struct sst_platform_data { | ||
| 71 | /* Intel software platform id*/ | ||
| 72 | struct sst_dev_stream_map *pdev_strm_map; | ||
| 73 | unsigned int strm_map_size; | ||
| 74 | }; | ||
| 75 | |||
| 76 | int add_sst_platform_device(void); | ||
| 77 | #endif | ||
| 78 | |||
diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c index f3a1f04ed4cb..584874451414 100644 --- a/arch/x86/kernel/apm_32.c +++ b/arch/x86/kernel/apm_32.c | |||
| @@ -841,7 +841,6 @@ static int apm_do_idle(void) | |||
| 841 | u32 eax; | 841 | u32 eax; |
| 842 | u8 ret = 0; | 842 | u8 ret = 0; |
| 843 | int idled = 0; | 843 | int idled = 0; |
| 844 | int polling; | ||
| 845 | int err = 0; | 844 | int err = 0; |
| 846 | 845 | ||
| 847 | if (!need_resched()) { | 846 | if (!need_resched()) { |
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c index a80029035bf2..f9e4fdd3b877 100644 --- a/arch/x86/kernel/cpu/intel.c +++ b/arch/x86/kernel/cpu/intel.c | |||
| @@ -370,6 +370,17 @@ static void init_intel(struct cpuinfo_x86 *c) | |||
| 370 | */ | 370 | */ |
| 371 | detect_extended_topology(c); | 371 | detect_extended_topology(c); |
| 372 | 372 | ||
| 373 | if (!cpu_has(c, X86_FEATURE_XTOPOLOGY)) { | ||
| 374 | /* | ||
| 375 | * let's use the legacy cpuid vector 0x1 and 0x4 for topology | ||
| 376 | * detection. | ||
| 377 | */ | ||
| 378 | c->x86_max_cores = intel_num_cpu_cores(c); | ||
| 379 | #ifdef CONFIG_X86_32 | ||
| 380 | detect_ht(c); | ||
| 381 | #endif | ||
| 382 | } | ||
| 383 | |||
| 373 | l2 = init_intel_cacheinfo(c); | 384 | l2 = init_intel_cacheinfo(c); |
| 374 | if (c->cpuid_level > 9) { | 385 | if (c->cpuid_level > 9) { |
| 375 | unsigned eax = cpuid_eax(10); | 386 | unsigned eax = cpuid_eax(10); |
| @@ -438,17 +449,6 @@ static void init_intel(struct cpuinfo_x86 *c) | |||
| 438 | set_cpu_cap(c, X86_FEATURE_P3); | 449 | set_cpu_cap(c, X86_FEATURE_P3); |
| 439 | #endif | 450 | #endif |
| 440 | 451 | ||
| 441 | if (!cpu_has(c, X86_FEATURE_XTOPOLOGY)) { | ||
| 442 | /* | ||
| 443 | * let's use the legacy cpuid vector 0x1 and 0x4 for topology | ||
| 444 | * detection. | ||
| 445 | */ | ||
| 446 | c->x86_max_cores = intel_num_cpu_cores(c); | ||
| 447 | #ifdef CONFIG_X86_32 | ||
| 448 | detect_ht(c); | ||
| 449 | #endif | ||
| 450 | } | ||
| 451 | |||
| 452 | /* Work around errata */ | 452 | /* Work around errata */ |
| 453 | srat_detect_node(c); | 453 | srat_detect_node(c); |
| 454 | 454 | ||
diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c index a952e9c85b6f..9c8f7394c612 100644 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c | |||
| @@ -730,6 +730,18 @@ unsigned int init_intel_cacheinfo(struct cpuinfo_x86 *c) | |||
| 730 | #endif | 730 | #endif |
| 731 | } | 731 | } |
| 732 | 732 | ||
| 733 | #ifdef CONFIG_X86_HT | ||
| 734 | /* | ||
| 735 | * If cpu_llc_id is not yet set, this means cpuid_level < 4 which in | ||
| 736 | * turns means that the only possibility is SMT (as indicated in | ||
| 737 | * cpuid1). Since cpuid2 doesn't specify shared caches, and we know | ||
| 738 | * that SMT shares all caches, we can unconditionally set cpu_llc_id to | ||
| 739 | * c->phys_proc_id. | ||
| 740 | */ | ||
| 741 | if (per_cpu(cpu_llc_id, cpu) == BAD_APICID) | ||
| 742 | per_cpu(cpu_llc_id, cpu) = c->phys_proc_id; | ||
| 743 | #endif | ||
| 744 | |||
| 733 | c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d)); | 745 | c->x86_cache_size = l3 ? l3 : (l2 ? l2 : (l1i+l1d)); |
| 734 | 746 | ||
| 735 | return l2; | 747 | return l2; |
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index bb92f38153b2..9a79c8dbd8e8 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
| @@ -2451,6 +2451,12 @@ static __init int mcheck_init_device(void) | |||
| 2451 | for_each_online_cpu(i) { | 2451 | for_each_online_cpu(i) { |
| 2452 | err = mce_device_create(i); | 2452 | err = mce_device_create(i); |
| 2453 | if (err) { | 2453 | if (err) { |
| 2454 | /* | ||
| 2455 | * Register notifier anyway (and do not unreg it) so | ||
| 2456 | * that we don't leave undeleted timers, see notifier | ||
| 2457 | * callback above. | ||
| 2458 | */ | ||
| 2459 | __register_hotcpu_notifier(&mce_cpu_notifier); | ||
| 2454 | cpu_notifier_register_done(); | 2460 | cpu_notifier_register_done(); |
| 2455 | goto err_device_create; | 2461 | goto err_device_create; |
| 2456 | } | 2462 | } |
| @@ -2471,10 +2477,6 @@ static __init int mcheck_init_device(void) | |||
| 2471 | err_register: | 2477 | err_register: |
| 2472 | unregister_syscore_ops(&mce_syscore_ops); | 2478 | unregister_syscore_ops(&mce_syscore_ops); |
| 2473 | 2479 | ||
| 2474 | cpu_notifier_register_begin(); | ||
| 2475 | __unregister_hotcpu_notifier(&mce_cpu_notifier); | ||
| 2476 | cpu_notifier_register_done(); | ||
| 2477 | |||
| 2478 | err_device_create: | 2480 | err_device_create: |
| 2479 | /* | 2481 | /* |
| 2480 | * We didn't keep track of which devices were created above, but | 2482 | * We didn't keep track of which devices were created above, but |
diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c index 2bdfbff8a4f6..2879ecdaac43 100644 --- a/arch/x86/kernel/cpu/perf_event.c +++ b/arch/x86/kernel/cpu/perf_event.c | |||
| @@ -118,6 +118,9 @@ static int x86_pmu_extra_regs(u64 config, struct perf_event *event) | |||
| 118 | continue; | 118 | continue; |
| 119 | if (event->attr.config1 & ~er->valid_mask) | 119 | if (event->attr.config1 & ~er->valid_mask) |
| 120 | return -EINVAL; | 120 | return -EINVAL; |
| 121 | /* Check if the extra msrs can be safely accessed*/ | ||
| 122 | if (!er->extra_msr_access) | ||
| 123 | return -ENXIO; | ||
| 121 | 124 | ||
| 122 | reg->idx = er->idx; | 125 | reg->idx = er->idx; |
| 123 | reg->config = event->attr.config1; | 126 | reg->config = event->attr.config1; |
diff --git a/arch/x86/kernel/cpu/perf_event.h b/arch/x86/kernel/cpu/perf_event.h index 3b2f9bdd974b..8ade93111e03 100644 --- a/arch/x86/kernel/cpu/perf_event.h +++ b/arch/x86/kernel/cpu/perf_event.h | |||
| @@ -295,14 +295,16 @@ struct extra_reg { | |||
| 295 | u64 config_mask; | 295 | u64 config_mask; |
| 296 | u64 valid_mask; | 296 | u64 valid_mask; |
| 297 | int idx; /* per_xxx->regs[] reg index */ | 297 | int idx; /* per_xxx->regs[] reg index */ |
| 298 | bool extra_msr_access; | ||
| 298 | }; | 299 | }; |
| 299 | 300 | ||
| 300 | #define EVENT_EXTRA_REG(e, ms, m, vm, i) { \ | 301 | #define EVENT_EXTRA_REG(e, ms, m, vm, i) { \ |
| 301 | .event = (e), \ | 302 | .event = (e), \ |
| 302 | .msr = (ms), \ | 303 | .msr = (ms), \ |
| 303 | .config_mask = (m), \ | 304 | .config_mask = (m), \ |
| 304 | .valid_mask = (vm), \ | 305 | .valid_mask = (vm), \ |
| 305 | .idx = EXTRA_REG_##i, \ | 306 | .idx = EXTRA_REG_##i, \ |
| 307 | .extra_msr_access = true, \ | ||
| 306 | } | 308 | } |
| 307 | 309 | ||
| 308 | #define INTEL_EVENT_EXTRA_REG(event, msr, vm, idx) \ | 310 | #define INTEL_EVENT_EXTRA_REG(event, msr, vm, idx) \ |
diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c index adb02aa62af5..2502d0d9d246 100644 --- a/arch/x86/kernel/cpu/perf_event_intel.c +++ b/arch/x86/kernel/cpu/perf_event_intel.c | |||
| @@ -1382,6 +1382,15 @@ again: | |||
| 1382 | intel_pmu_lbr_read(); | 1382 | intel_pmu_lbr_read(); |
| 1383 | 1383 | ||
| 1384 | /* | 1384 | /* |
| 1385 | * CondChgd bit 63 doesn't mean any overflow status. Ignore | ||
| 1386 | * and clear the bit. | ||
| 1387 | */ | ||
| 1388 | if (__test_and_clear_bit(63, (unsigned long *)&status)) { | ||
| 1389 | if (!status) | ||
| 1390 | goto done; | ||
| 1391 | } | ||
| 1392 | |||
| 1393 | /* | ||
| 1385 | * PEBS overflow sets bit 62 in the global status register | 1394 | * PEBS overflow sets bit 62 in the global status register |
| 1386 | */ | 1395 | */ |
| 1387 | if (__test_and_clear_bit(62, (unsigned long *)&status)) { | 1396 | if (__test_and_clear_bit(62, (unsigned long *)&status)) { |
| @@ -2173,6 +2182,41 @@ static void intel_snb_check_microcode(void) | |||
| 2173 | } | 2182 | } |
| 2174 | } | 2183 | } |
| 2175 | 2184 | ||
| 2185 | /* | ||
| 2186 | * Under certain circumstances, access certain MSR may cause #GP. | ||
| 2187 | * The function tests if the input MSR can be safely accessed. | ||
| 2188 | */ | ||
| 2189 | static bool check_msr(unsigned long msr, u64 mask) | ||
| 2190 | { | ||
| 2191 | u64 val_old, val_new, val_tmp; | ||
| 2192 | |||
| 2193 | /* | ||
| 2194 | * Read the current value, change it and read it back to see if it | ||
| 2195 | * matches, this is needed to detect certain hardware emulators | ||
| 2196 | * (qemu/kvm) that don't trap on the MSR access and always return 0s. | ||
| 2197 | */ | ||
| 2198 | if (rdmsrl_safe(msr, &val_old)) | ||
| 2199 | return false; | ||
| 2200 | |||
| 2201 | /* | ||
| 2202 | * Only change the bits which can be updated by wrmsrl. | ||
| 2203 | */ | ||
| 2204 | val_tmp = val_old ^ mask; | ||
| 2205 | if (wrmsrl_safe(msr, val_tmp) || | ||
| 2206 | rdmsrl_safe(msr, &val_new)) | ||
| 2207 | return false; | ||
| 2208 | |||
| 2209 | if (val_new != val_tmp) | ||
| 2210 | return false; | ||
| 2211 | |||
| 2212 | /* Here it's sure that the MSR can be safely accessed. | ||
| 2213 | * Restore the old value and return. | ||
| 2214 | */ | ||
| 2215 | wrmsrl(msr, val_old); | ||
| 2216 | |||
| 2217 | return true; | ||
| 2218 | } | ||
| 2219 | |||
| 2176 | static __init void intel_sandybridge_quirk(void) | 2220 | static __init void intel_sandybridge_quirk(void) |
| 2177 | { | 2221 | { |
| 2178 | x86_pmu.check_microcode = intel_snb_check_microcode; | 2222 | x86_pmu.check_microcode = intel_snb_check_microcode; |
| @@ -2262,7 +2306,8 @@ __init int intel_pmu_init(void) | |||
| 2262 | union cpuid10_ebx ebx; | 2306 | union cpuid10_ebx ebx; |
| 2263 | struct event_constraint *c; | 2307 | struct event_constraint *c; |
| 2264 | unsigned int unused; | 2308 | unsigned int unused; |
| 2265 | int version; | 2309 | struct extra_reg *er; |
| 2310 | int version, i; | ||
| 2266 | 2311 | ||
| 2267 | if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { | 2312 | if (!cpu_has(&boot_cpu_data, X86_FEATURE_ARCH_PERFMON)) { |
| 2268 | switch (boot_cpu_data.x86) { | 2313 | switch (boot_cpu_data.x86) { |
| @@ -2465,6 +2510,9 @@ __init int intel_pmu_init(void) | |||
| 2465 | case 62: /* IvyBridge EP */ | 2510 | case 62: /* IvyBridge EP */ |
| 2466 | memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, | 2511 | memcpy(hw_cache_event_ids, snb_hw_cache_event_ids, |
| 2467 | sizeof(hw_cache_event_ids)); | 2512 | sizeof(hw_cache_event_ids)); |
| 2513 | /* dTLB-load-misses on IVB is different than SNB */ | ||
| 2514 | hw_cache_event_ids[C(DTLB)][C(OP_READ)][C(RESULT_MISS)] = 0x8108; /* DTLB_LOAD_MISSES.DEMAND_LD_MISS_CAUSES_A_WALK */ | ||
| 2515 | |||
| 2468 | memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, | 2516 | memcpy(hw_cache_extra_regs, snb_hw_cache_extra_regs, |
| 2469 | sizeof(hw_cache_extra_regs)); | 2517 | sizeof(hw_cache_extra_regs)); |
| 2470 | 2518 | ||
| @@ -2565,6 +2613,34 @@ __init int intel_pmu_init(void) | |||
| 2565 | } | 2613 | } |
| 2566 | } | 2614 | } |
| 2567 | 2615 | ||
| 2616 | /* | ||
| 2617 | * Access LBR MSR may cause #GP under certain circumstances. | ||
| 2618 | * E.g. KVM doesn't support LBR MSR | ||
| 2619 | * Check all LBT MSR here. | ||
| 2620 | * Disable LBR access if any LBR MSRs can not be accessed. | ||
| 2621 | */ | ||
| 2622 | if (x86_pmu.lbr_nr && !check_msr(x86_pmu.lbr_tos, 0x3UL)) | ||
| 2623 | x86_pmu.lbr_nr = 0; | ||
| 2624 | for (i = 0; i < x86_pmu.lbr_nr; i++) { | ||
| 2625 | if (!(check_msr(x86_pmu.lbr_from + i, 0xffffUL) && | ||
| 2626 | check_msr(x86_pmu.lbr_to + i, 0xffffUL))) | ||
| 2627 | x86_pmu.lbr_nr = 0; | ||
| 2628 | } | ||
| 2629 | |||
| 2630 | /* | ||
| 2631 | * Access extra MSR may cause #GP under certain circumstances. | ||
| 2632 | * E.g. KVM doesn't support offcore event | ||
| 2633 | * Check all extra_regs here. | ||
| 2634 | */ | ||
| 2635 | if (x86_pmu.extra_regs) { | ||
| 2636 | for (er = x86_pmu.extra_regs; er->msr; er++) { | ||
| 2637 | er->extra_msr_access = check_msr(er->msr, 0x1ffUL); | ||
| 2638 | /* Disable LBR select mapping */ | ||
| 2639 | if ((er->idx == EXTRA_REG_LBR) && !er->extra_msr_access) | ||
| 2640 | x86_pmu.lbr_sel_map = NULL; | ||
| 2641 | } | ||
| 2642 | } | ||
| 2643 | |||
| 2568 | /* Support full width counters using alternative MSR range */ | 2644 | /* Support full width counters using alternative MSR range */ |
| 2569 | if (x86_pmu.intel_cap.full_width_write) { | 2645 | if (x86_pmu.intel_cap.full_width_write) { |
| 2570 | x86_pmu.max_period = x86_pmu.cntval_mask; | 2646 | x86_pmu.max_period = x86_pmu.cntval_mask; |
diff --git a/arch/x86/kernel/cpu/perf_event_intel_ds.c b/arch/x86/kernel/cpu/perf_event_intel_ds.c index 980970cb744d..696ade311ded 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_ds.c +++ b/arch/x86/kernel/cpu/perf_event_intel_ds.c | |||
| @@ -311,9 +311,11 @@ static int alloc_bts_buffer(int cpu) | |||
| 311 | if (!x86_pmu.bts) | 311 | if (!x86_pmu.bts) |
| 312 | return 0; | 312 | return 0; |
| 313 | 313 | ||
| 314 | buffer = kzalloc_node(BTS_BUFFER_SIZE, GFP_KERNEL, node); | 314 | buffer = kzalloc_node(BTS_BUFFER_SIZE, GFP_KERNEL | __GFP_NOWARN, node); |
| 315 | if (unlikely(!buffer)) | 315 | if (unlikely(!buffer)) { |
| 316 | WARN_ONCE(1, "%s: BTS buffer allocation failure\n", __func__); | ||
| 316 | return -ENOMEM; | 317 | return -ENOMEM; |
| 318 | } | ||
| 317 | 319 | ||
| 318 | max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE; | 320 | max = BTS_BUFFER_SIZE / BTS_RECORD_SIZE; |
| 319 | thresh = max / 16; | 321 | thresh = max / 16; |
diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c index 65bbbea38b9c..ae6552a0701f 100644 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c | |||
| @@ -550,16 +550,16 @@ static struct extra_reg snbep_uncore_cbox_extra_regs[] = { | |||
| 550 | SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0x6), | 550 | SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0x6), |
| 551 | SNBEP_CBO_EVENT_EXTRA_REG(0x0135, 0xffff, 0x8), | 551 | SNBEP_CBO_EVENT_EXTRA_REG(0x0135, 0xffff, 0x8), |
| 552 | SNBEP_CBO_EVENT_EXTRA_REG(0x0335, 0xffff, 0x8), | 552 | SNBEP_CBO_EVENT_EXTRA_REG(0x0335, 0xffff, 0x8), |
| 553 | SNBEP_CBO_EVENT_EXTRA_REG(0x4135, 0xffff, 0xc), | 553 | SNBEP_CBO_EVENT_EXTRA_REG(0x4135, 0xffff, 0xa), |
| 554 | SNBEP_CBO_EVENT_EXTRA_REG(0x4335, 0xffff, 0xc), | 554 | SNBEP_CBO_EVENT_EXTRA_REG(0x4335, 0xffff, 0xa), |
| 555 | SNBEP_CBO_EVENT_EXTRA_REG(0x4435, 0xffff, 0x2), | 555 | SNBEP_CBO_EVENT_EXTRA_REG(0x4435, 0xffff, 0x2), |
| 556 | SNBEP_CBO_EVENT_EXTRA_REG(0x4835, 0xffff, 0x2), | 556 | SNBEP_CBO_EVENT_EXTRA_REG(0x4835, 0xffff, 0x2), |
| 557 | SNBEP_CBO_EVENT_EXTRA_REG(0x4a35, 0xffff, 0x2), | 557 | SNBEP_CBO_EVENT_EXTRA_REG(0x4a35, 0xffff, 0x2), |
| 558 | SNBEP_CBO_EVENT_EXTRA_REG(0x5035, 0xffff, 0x2), | 558 | SNBEP_CBO_EVENT_EXTRA_REG(0x5035, 0xffff, 0x2), |
| 559 | SNBEP_CBO_EVENT_EXTRA_REG(0x0136, 0xffff, 0x8), | 559 | SNBEP_CBO_EVENT_EXTRA_REG(0x0136, 0xffff, 0x8), |
| 560 | SNBEP_CBO_EVENT_EXTRA_REG(0x0336, 0xffff, 0x8), | 560 | SNBEP_CBO_EVENT_EXTRA_REG(0x0336, 0xffff, 0x8), |
| 561 | SNBEP_CBO_EVENT_EXTRA_REG(0x4136, 0xffff, 0xc), | 561 | SNBEP_CBO_EVENT_EXTRA_REG(0x4136, 0xffff, 0xa), |
| 562 | SNBEP_CBO_EVENT_EXTRA_REG(0x4336, 0xffff, 0xc), | 562 | SNBEP_CBO_EVENT_EXTRA_REG(0x4336, 0xffff, 0xa), |
| 563 | SNBEP_CBO_EVENT_EXTRA_REG(0x4436, 0xffff, 0x2), | 563 | SNBEP_CBO_EVENT_EXTRA_REG(0x4436, 0xffff, 0x2), |
| 564 | SNBEP_CBO_EVENT_EXTRA_REG(0x4836, 0xffff, 0x2), | 564 | SNBEP_CBO_EVENT_EXTRA_REG(0x4836, 0xffff, 0x2), |
| 565 | SNBEP_CBO_EVENT_EXTRA_REG(0x4a36, 0xffff, 0x2), | 565 | SNBEP_CBO_EVENT_EXTRA_REG(0x4a36, 0xffff, 0x2), |
| @@ -1222,6 +1222,7 @@ static struct extra_reg ivt_uncore_cbox_extra_regs[] = { | |||
| 1222 | SNBEP_CBO_EVENT_EXTRA_REG(SNBEP_CBO_PMON_CTL_TID_EN, | 1222 | SNBEP_CBO_EVENT_EXTRA_REG(SNBEP_CBO_PMON_CTL_TID_EN, |
| 1223 | SNBEP_CBO_PMON_CTL_TID_EN, 0x1), | 1223 | SNBEP_CBO_PMON_CTL_TID_EN, 0x1), |
| 1224 | SNBEP_CBO_EVENT_EXTRA_REG(0x1031, 0x10ff, 0x2), | 1224 | SNBEP_CBO_EVENT_EXTRA_REG(0x1031, 0x10ff, 0x2), |
| 1225 | |||
| 1225 | SNBEP_CBO_EVENT_EXTRA_REG(0x1134, 0xffff, 0x4), | 1226 | SNBEP_CBO_EVENT_EXTRA_REG(0x1134, 0xffff, 0x4), |
| 1226 | SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0xc), | 1227 | SNBEP_CBO_EVENT_EXTRA_REG(0x4134, 0xffff, 0xc), |
| 1227 | SNBEP_CBO_EVENT_EXTRA_REG(0x5134, 0xffff, 0xc), | 1228 | SNBEP_CBO_EVENT_EXTRA_REG(0x5134, 0xffff, 0xc), |
| @@ -1245,7 +1246,7 @@ static struct extra_reg ivt_uncore_cbox_extra_regs[] = { | |||
| 1245 | SNBEP_CBO_EVENT_EXTRA_REG(0x8335, 0xffff, 0x10), | 1246 | SNBEP_CBO_EVENT_EXTRA_REG(0x8335, 0xffff, 0x10), |
| 1246 | SNBEP_CBO_EVENT_EXTRA_REG(0x0136, 0xffff, 0x10), | 1247 | SNBEP_CBO_EVENT_EXTRA_REG(0x0136, 0xffff, 0x10), |
| 1247 | SNBEP_CBO_EVENT_EXTRA_REG(0x0336, 0xffff, 0x10), | 1248 | SNBEP_CBO_EVENT_EXTRA_REG(0x0336, 0xffff, 0x10), |
| 1248 | SNBEP_CBO_EVENT_EXTRA_REG(0x2336, 0xffff, 0x10), | 1249 | SNBEP_CBO_EVENT_EXTRA_REG(0x2136, 0xffff, 0x10), |
| 1249 | SNBEP_CBO_EVENT_EXTRA_REG(0x2336, 0xffff, 0x10), | 1250 | SNBEP_CBO_EVENT_EXTRA_REG(0x2336, 0xffff, 0x10), |
| 1250 | SNBEP_CBO_EVENT_EXTRA_REG(0x4136, 0xffff, 0x18), | 1251 | SNBEP_CBO_EVENT_EXTRA_REG(0x4136, 0xffff, 0x18), |
| 1251 | SNBEP_CBO_EVENT_EXTRA_REG(0x4336, 0xffff, 0x18), | 1252 | SNBEP_CBO_EVENT_EXTRA_REG(0x4336, 0xffff, 0x18), |
diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S index dbaa23e78b36..0d0c9d4ab6d5 100644 --- a/arch/x86/kernel/entry_32.S +++ b/arch/x86/kernel/entry_32.S | |||
| @@ -425,8 +425,8 @@ sysenter_do_call: | |||
| 425 | cmpl $(NR_syscalls), %eax | 425 | cmpl $(NR_syscalls), %eax |
| 426 | jae sysenter_badsys | 426 | jae sysenter_badsys |
| 427 | call *sys_call_table(,%eax,4) | 427 | call *sys_call_table(,%eax,4) |
| 428 | movl %eax,PT_EAX(%esp) | ||
| 429 | sysenter_after_call: | 428 | sysenter_after_call: |
| 429 | movl %eax,PT_EAX(%esp) | ||
| 430 | LOCKDEP_SYS_EXIT | 430 | LOCKDEP_SYS_EXIT |
| 431 | DISABLE_INTERRUPTS(CLBR_ANY) | 431 | DISABLE_INTERRUPTS(CLBR_ANY) |
| 432 | TRACE_IRQS_OFF | 432 | TRACE_IRQS_OFF |
| @@ -502,6 +502,7 @@ ENTRY(system_call) | |||
| 502 | jae syscall_badsys | 502 | jae syscall_badsys |
| 503 | syscall_call: | 503 | syscall_call: |
| 504 | call *sys_call_table(,%eax,4) | 504 | call *sys_call_table(,%eax,4) |
| 505 | syscall_after_call: | ||
| 505 | movl %eax,PT_EAX(%esp) # store the return value | 506 | movl %eax,PT_EAX(%esp) # store the return value |
| 506 | syscall_exit: | 507 | syscall_exit: |
| 507 | LOCKDEP_SYS_EXIT | 508 | LOCKDEP_SYS_EXIT |
| @@ -675,12 +676,12 @@ syscall_fault: | |||
| 675 | END(syscall_fault) | 676 | END(syscall_fault) |
| 676 | 677 | ||
| 677 | syscall_badsys: | 678 | syscall_badsys: |
| 678 | movl $-ENOSYS,PT_EAX(%esp) | 679 | movl $-ENOSYS,%eax |
| 679 | jmp syscall_exit | 680 | jmp syscall_after_call |
| 680 | END(syscall_badsys) | 681 | END(syscall_badsys) |
| 681 | 682 | ||
| 682 | sysenter_badsys: | 683 | sysenter_badsys: |
| 683 | movl $-ENOSYS,PT_EAX(%esp) | 684 | movl $-ENOSYS,%eax |
| 684 | jmp sysenter_after_call | 685 | jmp sysenter_after_call |
| 685 | END(syscall_badsys) | 686 | END(syscall_badsys) |
| 686 | CFI_ENDPROC | 687 | CFI_ENDPROC |
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index b25ca969edd2..c844f0816ab8 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
| @@ -830,27 +830,24 @@ restore_args: | |||
| 830 | RESTORE_ARGS 1,8,1 | 830 | RESTORE_ARGS 1,8,1 |
| 831 | 831 | ||
| 832 | irq_return: | 832 | irq_return: |
| 833 | INTERRUPT_RETURN | ||
| 834 | |||
| 835 | ENTRY(native_iret) | ||
| 833 | /* | 836 | /* |
| 834 | * Are we returning to a stack segment from the LDT? Note: in | 837 | * Are we returning to a stack segment from the LDT? Note: in |
| 835 | * 64-bit mode SS:RSP on the exception stack is always valid. | 838 | * 64-bit mode SS:RSP on the exception stack is always valid. |
| 836 | */ | 839 | */ |
| 837 | #ifdef CONFIG_X86_ESPFIX64 | 840 | #ifdef CONFIG_X86_ESPFIX64 |
| 838 | testb $4,(SS-RIP)(%rsp) | 841 | testb $4,(SS-RIP)(%rsp) |
| 839 | jnz irq_return_ldt | 842 | jnz native_irq_return_ldt |
| 840 | #endif | 843 | #endif |
| 841 | 844 | ||
| 842 | irq_return_iret: | 845 | native_irq_return_iret: |
| 843 | INTERRUPT_RETURN | ||
| 844 | _ASM_EXTABLE(irq_return_iret, bad_iret) | ||
| 845 | |||
| 846 | #ifdef CONFIG_PARAVIRT | ||
| 847 | ENTRY(native_iret) | ||
| 848 | iretq | 846 | iretq |
| 849 | _ASM_EXTABLE(native_iret, bad_iret) | 847 | _ASM_EXTABLE(native_irq_return_iret, bad_iret) |
| 850 | #endif | ||
| 851 | 848 | ||
| 852 | #ifdef CONFIG_X86_ESPFIX64 | 849 | #ifdef CONFIG_X86_ESPFIX64 |
| 853 | irq_return_ldt: | 850 | native_irq_return_ldt: |
| 854 | pushq_cfi %rax | 851 | pushq_cfi %rax |
| 855 | pushq_cfi %rdi | 852 | pushq_cfi %rdi |
| 856 | SWAPGS | 853 | SWAPGS |
| @@ -872,7 +869,7 @@ irq_return_ldt: | |||
| 872 | SWAPGS | 869 | SWAPGS |
| 873 | movq %rax,%rsp | 870 | movq %rax,%rsp |
| 874 | popq_cfi %rax | 871 | popq_cfi %rax |
| 875 | jmp irq_return_iret | 872 | jmp native_irq_return_iret |
| 876 | #endif | 873 | #endif |
| 877 | 874 | ||
| 878 | .section .fixup,"ax" | 875 | .section .fixup,"ax" |
| @@ -956,13 +953,8 @@ __do_double_fault: | |||
| 956 | cmpl $__KERNEL_CS,CS(%rdi) | 953 | cmpl $__KERNEL_CS,CS(%rdi) |
| 957 | jne do_double_fault | 954 | jne do_double_fault |
| 958 | movq RIP(%rdi),%rax | 955 | movq RIP(%rdi),%rax |
| 959 | cmpq $irq_return_iret,%rax | 956 | cmpq $native_irq_return_iret,%rax |
| 960 | #ifdef CONFIG_PARAVIRT | ||
| 961 | je 1f | ||
| 962 | cmpq $native_iret,%rax | ||
| 963 | #endif | ||
| 964 | jne do_double_fault /* This shouldn't happen... */ | 957 | jne do_double_fault /* This shouldn't happen... */ |
| 965 | 1: | ||
| 966 | movq PER_CPU_VAR(kernel_stack),%rax | 958 | movq PER_CPU_VAR(kernel_stack),%rax |
| 967 | subq $(6*8-KERNEL_STACK_OFFSET),%rax /* Reset to original stack */ | 959 | subq $(6*8-KERNEL_STACK_OFFSET),%rax /* Reset to original stack */ |
| 968 | movq %rax,RSP(%rdi) | 960 | movq %rax,RSP(%rdi) |
| @@ -1428,7 +1420,7 @@ error_sti: | |||
| 1428 | */ | 1420 | */ |
| 1429 | error_kernelspace: | 1421 | error_kernelspace: |
| 1430 | incl %ebx | 1422 | incl %ebx |
| 1431 | leaq irq_return_iret(%rip),%rcx | 1423 | leaq native_irq_return_iret(%rip),%rcx |
| 1432 | cmpq %rcx,RIP+8(%rsp) | 1424 | cmpq %rcx,RIP+8(%rsp) |
| 1433 | je error_swapgs | 1425 | je error_swapgs |
| 1434 | movl %ecx,%eax /* zero extend */ | 1426 | movl %ecx,%eax /* zero extend */ |
diff --git a/arch/x86/kernel/espfix_64.c b/arch/x86/kernel/espfix_64.c index 6afbb16e9b79..94d857fb1033 100644 --- a/arch/x86/kernel/espfix_64.c +++ b/arch/x86/kernel/espfix_64.c | |||
| @@ -175,7 +175,7 @@ void init_espfix_ap(void) | |||
| 175 | if (!pud_present(pud)) { | 175 | if (!pud_present(pud)) { |
| 176 | pmd_p = (pmd_t *)__get_free_page(PGALLOC_GFP); | 176 | pmd_p = (pmd_t *)__get_free_page(PGALLOC_GFP); |
| 177 | pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask)); | 177 | pud = __pud(__pa(pmd_p) | (PGTABLE_PROT & ptemask)); |
| 178 | paravirt_alloc_pud(&init_mm, __pa(pmd_p) >> PAGE_SHIFT); | 178 | paravirt_alloc_pmd(&init_mm, __pa(pmd_p) >> PAGE_SHIFT); |
| 179 | for (n = 0; n < ESPFIX_PUD_CLONES; n++) | 179 | for (n = 0; n < ESPFIX_PUD_CLONES; n++) |
| 180 | set_pud(&pud_p[n], pud); | 180 | set_pud(&pud_p[n], pud); |
| 181 | } | 181 | } |
| @@ -185,7 +185,7 @@ void init_espfix_ap(void) | |||
| 185 | if (!pmd_present(pmd)) { | 185 | if (!pmd_present(pmd)) { |
| 186 | pte_p = (pte_t *)__get_free_page(PGALLOC_GFP); | 186 | pte_p = (pte_t *)__get_free_page(PGALLOC_GFP); |
| 187 | pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask)); | 187 | pmd = __pmd(__pa(pte_p) | (PGTABLE_PROT & ptemask)); |
| 188 | paravirt_alloc_pmd(&init_mm, __pa(pte_p) >> PAGE_SHIFT); | 188 | paravirt_alloc_pte(&init_mm, __pa(pte_p) >> PAGE_SHIFT); |
| 189 | for (n = 0; n < ESPFIX_PMD_CLONES; n++) | 189 | for (n = 0; n < ESPFIX_PMD_CLONES; n++) |
| 190 | set_pmd(&pmd_p[n], pmd); | 190 | set_pmd(&pmd_p[n], pmd); |
| 191 | } | 191 | } |
| @@ -193,7 +193,6 @@ void init_espfix_ap(void) | |||
| 193 | pte_p = pte_offset_kernel(&pmd, addr); | 193 | pte_p = pte_offset_kernel(&pmd, addr); |
| 194 | stack_page = (void *)__get_free_page(GFP_KERNEL); | 194 | stack_page = (void *)__get_free_page(GFP_KERNEL); |
| 195 | pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); | 195 | pte = __pte(__pa(stack_page) | (__PAGE_KERNEL_RO & ptemask)); |
| 196 | paravirt_alloc_pte(&init_mm, __pa(stack_page) >> PAGE_SHIFT); | ||
| 197 | for (n = 0; n < ESPFIX_PTE_CLONES; n++) | 196 | for (n = 0; n < ESPFIX_PTE_CLONES; n++) |
| 198 | set_pte(&pte_p[n*PTE_STRIDE], pte); | 197 | set_pte(&pte_p[n*PTE_STRIDE], pte); |
| 199 | 198 | ||
diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c index 7596df664901..67e6d19ef1be 100644 --- a/arch/x86/kernel/kprobes/core.c +++ b/arch/x86/kernel/kprobes/core.c | |||
| @@ -574,6 +574,9 @@ int kprobe_int3_handler(struct pt_regs *regs) | |||
| 574 | struct kprobe *p; | 574 | struct kprobe *p; |
| 575 | struct kprobe_ctlblk *kcb; | 575 | struct kprobe_ctlblk *kcb; |
| 576 | 576 | ||
| 577 | if (user_mode_vm(regs)) | ||
| 578 | return 0; | ||
| 579 | |||
| 577 | addr = (kprobe_opcode_t *)(regs->ip - sizeof(kprobe_opcode_t)); | 580 | addr = (kprobe_opcode_t *)(regs->ip - sizeof(kprobe_opcode_t)); |
| 578 | /* | 581 | /* |
| 579 | * We don't want to be preempted for the entire | 582 | * We don't want to be preempted for the entire |
diff --git a/arch/x86/kernel/paravirt_patch_64.c b/arch/x86/kernel/paravirt_patch_64.c index 3f08f34f93eb..a1da6737ba5b 100644 --- a/arch/x86/kernel/paravirt_patch_64.c +++ b/arch/x86/kernel/paravirt_patch_64.c | |||
| @@ -6,7 +6,6 @@ DEF_NATIVE(pv_irq_ops, irq_disable, "cli"); | |||
| 6 | DEF_NATIVE(pv_irq_ops, irq_enable, "sti"); | 6 | DEF_NATIVE(pv_irq_ops, irq_enable, "sti"); |
| 7 | DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq"); | 7 | DEF_NATIVE(pv_irq_ops, restore_fl, "pushq %rdi; popfq"); |
| 8 | DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax"); | 8 | DEF_NATIVE(pv_irq_ops, save_fl, "pushfq; popq %rax"); |
| 9 | DEF_NATIVE(pv_cpu_ops, iret, "iretq"); | ||
| 10 | DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax"); | 9 | DEF_NATIVE(pv_mmu_ops, read_cr2, "movq %cr2, %rax"); |
| 11 | DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax"); | 10 | DEF_NATIVE(pv_mmu_ops, read_cr3, "movq %cr3, %rax"); |
| 12 | DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3"); | 11 | DEF_NATIVE(pv_mmu_ops, write_cr3, "movq %rdi, %cr3"); |
| @@ -50,7 +49,6 @@ unsigned native_patch(u8 type, u16 clobbers, void *ibuf, | |||
| 50 | PATCH_SITE(pv_irq_ops, save_fl); | 49 | PATCH_SITE(pv_irq_ops, save_fl); |
| 51 | PATCH_SITE(pv_irq_ops, irq_enable); | 50 | PATCH_SITE(pv_irq_ops, irq_enable); |
| 52 | PATCH_SITE(pv_irq_ops, irq_disable); | 51 | PATCH_SITE(pv_irq_ops, irq_disable); |
| 53 | PATCH_SITE(pv_cpu_ops, iret); | ||
| 54 | PATCH_SITE(pv_cpu_ops, irq_enable_sysexit); | 52 | PATCH_SITE(pv_cpu_ops, irq_enable_sysexit); |
| 55 | PATCH_SITE(pv_cpu_ops, usergs_sysret32); | 53 | PATCH_SITE(pv_cpu_ops, usergs_sysret32); |
| 56 | PATCH_SITE(pv_cpu_ops, usergs_sysret64); | 54 | PATCH_SITE(pv_cpu_ops, usergs_sysret64); |
diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c index 57e5ce126d5a..ea030319b321 100644 --- a/arch/x86/kernel/tsc.c +++ b/arch/x86/kernel/tsc.c | |||
| @@ -920,9 +920,9 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val, | |||
| 920 | tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new); | 920 | tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new); |
| 921 | if (!(freq->flags & CPUFREQ_CONST_LOOPS)) | 921 | if (!(freq->flags & CPUFREQ_CONST_LOOPS)) |
| 922 | mark_tsc_unstable("cpufreq changes"); | 922 | mark_tsc_unstable("cpufreq changes"); |
| 923 | } | ||
| 924 | 923 | ||
| 925 | set_cyc2ns_scale(tsc_khz, freq->cpu); | 924 | set_cyc2ns_scale(tsc_khz, freq->cpu); |
| 925 | } | ||
| 926 | 926 | ||
| 927 | return 0; | 927 | return 0; |
| 928 | } | 928 | } |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index f6449334ec45..ef432f891d30 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -5887,6 +5887,18 @@ static int inject_pending_event(struct kvm_vcpu *vcpu, bool req_int_win) | |||
| 5887 | kvm_x86_ops->set_nmi(vcpu); | 5887 | kvm_x86_ops->set_nmi(vcpu); |
| 5888 | } | 5888 | } |
| 5889 | } else if (kvm_cpu_has_injectable_intr(vcpu)) { | 5889 | } else if (kvm_cpu_has_injectable_intr(vcpu)) { |
| 5890 | /* | ||
| 5891 | * Because interrupts can be injected asynchronously, we are | ||
| 5892 | * calling check_nested_events again here to avoid a race condition. | ||
| 5893 | * See https://lkml.org/lkml/2014/7/2/60 for discussion about this | ||
| 5894 | * proposal and current concerns. Perhaps we should be setting | ||
| 5895 | * KVM_REQ_EVENT only on certain events and not unconditionally? | ||
| 5896 | */ | ||
| 5897 | if (is_guest_mode(vcpu) && kvm_x86_ops->check_nested_events) { | ||
| 5898 | r = kvm_x86_ops->check_nested_events(vcpu, req_int_win); | ||
| 5899 | if (r != 0) | ||
| 5900 | return r; | ||
| 5901 | } | ||
| 5890 | if (kvm_x86_ops->interrupt_allowed(vcpu)) { | 5902 | if (kvm_x86_ops->interrupt_allowed(vcpu)) { |
| 5891 | kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu), | 5903 | kvm_queue_interrupt(vcpu, kvm_cpu_get_interrupt(vcpu), |
| 5892 | false); | 5904 | false); |
diff --git a/arch/x86/vdso/vdso2c.h b/arch/x86/vdso/vdso2c.h index df95a2fdff73..11b65d4f9414 100644 --- a/arch/x86/vdso/vdso2c.h +++ b/arch/x86/vdso/vdso2c.h | |||
| @@ -93,6 +93,9 @@ static void BITSFUNC(copy_section)(struct BITSFUNC(fake_sections) *out, | |||
| 93 | uint64_t flags = GET_LE(&in->sh_flags); | 93 | uint64_t flags = GET_LE(&in->sh_flags); |
| 94 | 94 | ||
| 95 | bool copy = flags & SHF_ALLOC && | 95 | bool copy = flags & SHF_ALLOC && |
| 96 | (GET_LE(&in->sh_size) || | ||
| 97 | (GET_LE(&in->sh_type) != SHT_RELA && | ||
| 98 | GET_LE(&in->sh_type) != SHT_REL)) && | ||
| 96 | strcmp(name, ".altinstructions") && | 99 | strcmp(name, ".altinstructions") && |
| 97 | strcmp(name, ".altinstr_replacement"); | 100 | strcmp(name, ".altinstr_replacement"); |
| 98 | 101 | ||
diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c index e1513c47872a..5a5176de8d0a 100644 --- a/arch/x86/vdso/vma.c +++ b/arch/x86/vdso/vma.c | |||
| @@ -62,6 +62,9 @@ struct linux_binprm; | |||
| 62 | Only used for the 64-bit and x32 vdsos. */ | 62 | Only used for the 64-bit and x32 vdsos. */ |
| 63 | static unsigned long vdso_addr(unsigned long start, unsigned len) | 63 | static unsigned long vdso_addr(unsigned long start, unsigned len) |
| 64 | { | 64 | { |
| 65 | #ifdef CONFIG_X86_32 | ||
| 66 | return 0; | ||
| 67 | #else | ||
| 65 | unsigned long addr, end; | 68 | unsigned long addr, end; |
| 66 | unsigned offset; | 69 | unsigned offset; |
| 67 | end = (start + PMD_SIZE - 1) & PMD_MASK; | 70 | end = (start + PMD_SIZE - 1) & PMD_MASK; |
| @@ -83,6 +86,7 @@ static unsigned long vdso_addr(unsigned long start, unsigned len) | |||
| 83 | addr = align_vdso_addr(addr); | 86 | addr = align_vdso_addr(addr); |
| 84 | 87 | ||
| 85 | return addr; | 88 | return addr; |
| 89 | #endif | ||
| 86 | } | 90 | } |
| 87 | 91 | ||
| 88 | static int map_vdso(const struct vdso_image *image, bool calculate_addr) | 92 | static int map_vdso(const struct vdso_image *image, bool calculate_addr) |
diff --git a/arch/x86/xen/grant-table.c b/arch/x86/xen/grant-table.c index c98583588580..ebfa9b2c871d 100644 --- a/arch/x86/xen/grant-table.c +++ b/arch/x86/xen/grant-table.c | |||
| @@ -36,99 +36,133 @@ | |||
| 36 | 36 | ||
| 37 | #include <linux/sched.h> | 37 | #include <linux/sched.h> |
| 38 | #include <linux/mm.h> | 38 | #include <linux/mm.h> |
| 39 | #include <linux/slab.h> | ||
| 39 | #include <linux/vmalloc.h> | 40 | #include <linux/vmalloc.h> |
| 40 | 41 | ||
| 41 | #include <xen/interface/xen.h> | 42 | #include <xen/interface/xen.h> |
| 42 | #include <xen/page.h> | 43 | #include <xen/page.h> |
| 43 | #include <xen/grant_table.h> | 44 | #include <xen/grant_table.h> |
| 45 | #include <xen/xen.h> | ||
| 44 | 46 | ||
| 45 | #include <asm/pgtable.h> | 47 | #include <asm/pgtable.h> |
| 46 | 48 | ||
| 47 | static int map_pte_fn(pte_t *pte, struct page *pmd_page, | 49 | static struct gnttab_vm_area { |
| 48 | unsigned long addr, void *data) | 50 | struct vm_struct *area; |
| 51 | pte_t **ptes; | ||
| 52 | } gnttab_shared_vm_area, gnttab_status_vm_area; | ||
| 53 | |||
| 54 | int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, | ||
| 55 | unsigned long max_nr_gframes, | ||
| 56 | void **__shared) | ||
| 49 | { | 57 | { |
| 50 | unsigned long **frames = (unsigned long **)data; | 58 | void *shared = *__shared; |
| 59 | unsigned long addr; | ||
| 60 | unsigned long i; | ||
| 51 | 61 | ||
| 52 | set_pte_at(&init_mm, addr, pte, mfn_pte((*frames)[0], PAGE_KERNEL)); | 62 | if (shared == NULL) |
| 53 | (*frames)++; | 63 | *__shared = shared = gnttab_shared_vm_area.area->addr; |
| 54 | return 0; | ||
| 55 | } | ||
| 56 | 64 | ||
| 57 | /* | 65 | addr = (unsigned long)shared; |
| 58 | * This function is used to map shared frames to store grant status. It is | 66 | |
| 59 | * different from map_pte_fn above, the frames type here is uint64_t. | 67 | for (i = 0; i < nr_gframes; i++) { |
| 60 | */ | 68 | set_pte_at(&init_mm, addr, gnttab_shared_vm_area.ptes[i], |
| 61 | static int map_pte_fn_status(pte_t *pte, struct page *pmd_page, | 69 | mfn_pte(frames[i], PAGE_KERNEL)); |
| 62 | unsigned long addr, void *data) | 70 | addr += PAGE_SIZE; |
| 63 | { | 71 | } |
| 64 | uint64_t **frames = (uint64_t **)data; | ||
| 65 | 72 | ||
| 66 | set_pte_at(&init_mm, addr, pte, mfn_pte((*frames)[0], PAGE_KERNEL)); | ||
| 67 | (*frames)++; | ||
| 68 | return 0; | 73 | return 0; |
| 69 | } | 74 | } |
| 70 | 75 | ||
| 71 | static int unmap_pte_fn(pte_t *pte, struct page *pmd_page, | 76 | int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, |
| 72 | unsigned long addr, void *data) | 77 | unsigned long max_nr_gframes, |
| 78 | grant_status_t **__shared) | ||
| 73 | { | 79 | { |
| 80 | grant_status_t *shared = *__shared; | ||
| 81 | unsigned long addr; | ||
| 82 | unsigned long i; | ||
| 83 | |||
| 84 | if (shared == NULL) | ||
| 85 | *__shared = shared = gnttab_status_vm_area.area->addr; | ||
| 86 | |||
| 87 | addr = (unsigned long)shared; | ||
| 88 | |||
| 89 | for (i = 0; i < nr_gframes; i++) { | ||
| 90 | set_pte_at(&init_mm, addr, gnttab_status_vm_area.ptes[i], | ||
| 91 | mfn_pte(frames[i], PAGE_KERNEL)); | ||
| 92 | addr += PAGE_SIZE; | ||
| 93 | } | ||
| 74 | 94 | ||
| 75 | set_pte_at(&init_mm, addr, pte, __pte(0)); | ||
| 76 | return 0; | 95 | return 0; |
| 77 | } | 96 | } |
| 78 | 97 | ||
| 79 | int arch_gnttab_map_shared(unsigned long *frames, unsigned long nr_gframes, | 98 | void arch_gnttab_unmap(void *shared, unsigned long nr_gframes) |
| 80 | unsigned long max_nr_gframes, | ||
| 81 | void **__shared) | ||
| 82 | { | 99 | { |
| 83 | int rc; | 100 | pte_t **ptes; |
| 84 | void *shared = *__shared; | 101 | unsigned long addr; |
| 102 | unsigned long i; | ||
| 85 | 103 | ||
| 86 | if (shared == NULL) { | 104 | if (shared == gnttab_status_vm_area.area->addr) |
| 87 | struct vm_struct *area = | 105 | ptes = gnttab_status_vm_area.ptes; |
| 88 | alloc_vm_area(PAGE_SIZE * max_nr_gframes, NULL); | 106 | else |
| 89 | BUG_ON(area == NULL); | 107 | ptes = gnttab_shared_vm_area.ptes; |
| 90 | shared = area->addr; | ||
| 91 | *__shared = shared; | ||
| 92 | } | ||
| 93 | 108 | ||
| 94 | rc = apply_to_page_range(&init_mm, (unsigned long)shared, | 109 | addr = (unsigned long)shared; |
| 95 | PAGE_SIZE * nr_gframes, | 110 | |
| 96 | map_pte_fn, &frames); | 111 | for (i = 0; i < nr_gframes; i++) { |
| 97 | return rc; | 112 | set_pte_at(&init_mm, addr, ptes[i], __pte(0)); |
| 113 | addr += PAGE_SIZE; | ||
| 114 | } | ||
| 98 | } | 115 | } |
| 99 | 116 | ||
| 100 | int arch_gnttab_map_status(uint64_t *frames, unsigned long nr_gframes, | 117 | static int arch_gnttab_valloc(struct gnttab_vm_area *area, unsigned nr_frames) |
| 101 | unsigned long max_nr_gframes, | ||
| 102 | grant_status_t **__shared) | ||
| 103 | { | 118 | { |
| 104 | int rc; | 119 | area->ptes = kmalloc(sizeof(pte_t *) * nr_frames, GFP_KERNEL); |
| 105 | grant_status_t *shared = *__shared; | 120 | if (area->ptes == NULL) |
| 121 | return -ENOMEM; | ||
| 106 | 122 | ||
| 107 | if (shared == NULL) { | 123 | area->area = alloc_vm_area(PAGE_SIZE * nr_frames, area->ptes); |
| 108 | /* No need to pass in PTE as we are going to do it | 124 | if (area->area == NULL) { |
| 109 | * in apply_to_page_range anyhow. */ | 125 | kfree(area->ptes); |
| 110 | struct vm_struct *area = | 126 | return -ENOMEM; |
| 111 | alloc_vm_area(PAGE_SIZE * max_nr_gframes, NULL); | ||
| 112 | BUG_ON(area == NULL); | ||
| 113 | shared = area->addr; | ||
| 114 | *__shared = shared; | ||
| 115 | } | 127 | } |
| 116 | 128 | ||
| 117 | rc = apply_to_page_range(&init_mm, (unsigned long)shared, | 129 | return 0; |
| 118 | PAGE_SIZE * nr_gframes, | ||
| 119 | map_pte_fn_status, &frames); | ||
| 120 | return rc; | ||
| 121 | } | 130 | } |
| 122 | 131 | ||
| 123 | void arch_gnttab_unmap(void *shared, unsigned long nr_gframes) | 132 | static void arch_gnttab_vfree(struct gnttab_vm_area *area) |
| 133 | { | ||
| 134 | free_vm_area(area->area); | ||
| 135 | kfree(area->ptes); | ||
| 136 | } | ||
| 137 | |||
| 138 | int arch_gnttab_init(unsigned long nr_shared, unsigned long nr_status) | ||
| 124 | { | 139 | { |
| 125 | apply_to_page_range(&init_mm, (unsigned long)shared, | 140 | int ret; |
| 126 | PAGE_SIZE * nr_gframes, unmap_pte_fn, NULL); | 141 | |
| 142 | if (!xen_pv_domain()) | ||
| 143 | return 0; | ||
| 144 | |||
| 145 | ret = arch_gnttab_valloc(&gnttab_shared_vm_area, nr_shared); | ||
| 146 | if (ret < 0) | ||
| 147 | return ret; | ||
| 148 | |||
| 149 | /* | ||
| 150 | * Always allocate the space for the status frames in case | ||
| 151 | * we're migrated to a host with V2 support. | ||
| 152 | */ | ||
| 153 | ret = arch_gnttab_valloc(&gnttab_status_vm_area, nr_status); | ||
| 154 | if (ret < 0) | ||
| 155 | goto err; | ||
| 156 | |||
| 157 | return 0; | ||
| 158 | err: | ||
| 159 | arch_gnttab_vfree(&gnttab_shared_vm_area); | ||
| 160 | return -ENOMEM; | ||
| 127 | } | 161 | } |
| 162 | |||
| 128 | #ifdef CONFIG_XEN_PVH | 163 | #ifdef CONFIG_XEN_PVH |
| 129 | #include <xen/balloon.h> | 164 | #include <xen/balloon.h> |
| 130 | #include <xen/events.h> | 165 | #include <xen/events.h> |
| 131 | #include <xen/xen.h> | ||
| 132 | #include <linux/slab.h> | 166 | #include <linux/slab.h> |
| 133 | static int __init xlated_setup_gnttab_pages(void) | 167 | static int __init xlated_setup_gnttab_pages(void) |
| 134 | { | 168 | { |
diff --git a/arch/xtensa/kernel/vectors.S b/arch/xtensa/kernel/vectors.S index f9e1ec346e35..8453e6e39895 100644 --- a/arch/xtensa/kernel/vectors.S +++ b/arch/xtensa/kernel/vectors.S | |||
| @@ -376,38 +376,42 @@ _DoubleExceptionVector_WindowOverflow: | |||
| 376 | beqz a2, 1f # if at start of vector, don't restore | 376 | beqz a2, 1f # if at start of vector, don't restore |
| 377 | 377 | ||
| 378 | addi a0, a0, -128 | 378 | addi a0, a0, -128 |
| 379 | bbsi a0, 8, 1f # don't restore except for overflow 8 and 12 | 379 | bbsi.l a0, 8, 1f # don't restore except for overflow 8 and 12 |
| 380 | bbsi a0, 7, 2f | 380 | |
| 381 | /* | ||
| 382 | * This fixup handler is for the extremely unlikely case where the | ||
| 383 | * overflow handler's reference thru a0 gets a hardware TLB refill | ||
| 384 | * that bumps out the (distinct, aliasing) TLB entry that mapped its | ||
| 385 | * prior references thru a9/a13, and where our reference now thru | ||
| 386 | * a9/a13 gets a 2nd-level miss exception (not hardware TLB refill). | ||
| 387 | */ | ||
| 388 | movi a2, window_overflow_restore_a0_fixup | ||
| 389 | s32i a2, a3, EXC_TABLE_FIXUP | ||
| 390 | l32i a2, a3, EXC_TABLE_DOUBLE_SAVE | ||
| 391 | xsr a3, excsave1 | ||
| 392 | |||
| 393 | bbsi.l a0, 7, 2f | ||
| 381 | 394 | ||
| 382 | /* | 395 | /* |
| 383 | * Restore a0 as saved by _WindowOverflow8(). | 396 | * Restore a0 as saved by _WindowOverflow8(). |
| 384 | * | ||
| 385 | * FIXME: we really need a fixup handler for this L32E, | ||
| 386 | * for the extremely unlikely case where the overflow handler's | ||
| 387 | * reference thru a0 gets a hardware TLB refill that bumps out | ||
| 388 | * the (distinct, aliasing) TLB entry that mapped its prior | ||
| 389 | * references thru a9, and where our reference now thru a9 | ||
| 390 | * gets a 2nd-level miss exception (not hardware TLB refill). | ||
| 391 | */ | 397 | */ |
| 392 | 398 | ||
| 393 | l32e a2, a9, -16 | 399 | l32e a0, a9, -16 |
| 394 | wsr a2, depc # replace the saved a0 | 400 | wsr a0, depc # replace the saved a0 |
| 395 | j 1f | 401 | j 3f |
| 396 | 402 | ||
| 397 | 2: | 403 | 2: |
| 398 | /* | 404 | /* |
| 399 | * Restore a0 as saved by _WindowOverflow12(). | 405 | * Restore a0 as saved by _WindowOverflow12(). |
| 400 | * | ||
| 401 | * FIXME: we really need a fixup handler for this L32E, | ||
| 402 | * for the extremely unlikely case where the overflow handler's | ||
| 403 | * reference thru a0 gets a hardware TLB refill that bumps out | ||
| 404 | * the (distinct, aliasing) TLB entry that mapped its prior | ||
| 405 | * references thru a13, and where our reference now thru a13 | ||
| 406 | * gets a 2nd-level miss exception (not hardware TLB refill). | ||
| 407 | */ | 406 | */ |
| 408 | 407 | ||
| 409 | l32e a2, a13, -16 | 408 | l32e a0, a13, -16 |
| 410 | wsr a2, depc # replace the saved a0 | 409 | wsr a0, depc # replace the saved a0 |
| 410 | 3: | ||
| 411 | xsr a3, excsave1 | ||
| 412 | movi a0, 0 | ||
| 413 | s32i a0, a3, EXC_TABLE_FIXUP | ||
| 414 | s32i a2, a3, EXC_TABLE_DOUBLE_SAVE | ||
| 411 | 1: | 415 | 1: |
| 412 | /* | 416 | /* |
| 413 | * Restore WindowBase while leaving all address registers restored. | 417 | * Restore WindowBase while leaving all address registers restored. |
| @@ -449,6 +453,7 @@ _DoubleExceptionVector_WindowOverflow: | |||
| 449 | 453 | ||
| 450 | s32i a0, a2, PT_DEPC | 454 | s32i a0, a2, PT_DEPC |
| 451 | 455 | ||
| 456 | _DoubleExceptionVector_handle_exception: | ||
| 452 | addx4 a0, a0, a3 | 457 | addx4 a0, a0, a3 |
| 453 | l32i a0, a0, EXC_TABLE_FAST_USER | 458 | l32i a0, a0, EXC_TABLE_FAST_USER |
| 454 | xsr a3, excsave1 | 459 | xsr a3, excsave1 |
| @@ -464,11 +469,120 @@ _DoubleExceptionVector_WindowOverflow: | |||
| 464 | rotw -3 | 469 | rotw -3 |
| 465 | j 1b | 470 | j 1b |
| 466 | 471 | ||
| 467 | .end literal_prefix | ||
| 468 | 472 | ||
| 469 | ENDPROC(_DoubleExceptionVector) | 473 | ENDPROC(_DoubleExceptionVector) |
| 470 | 474 | ||
| 471 | /* | 475 | /* |
| 476 | * Fixup handler for TLB miss in double exception handler for window owerflow. | ||
| 477 | * We get here with windowbase set to the window that was being spilled and | ||
| 478 | * a0 trashed. a0 bit 7 determines if this is a call8 (bit clear) or call12 | ||
| 479 | * (bit set) window. | ||
| 480 | * | ||
| 481 | * We do the following here: | ||
| 482 | * - go to the original window retaining a0 value; | ||
| 483 | * - set up exception stack to return back to appropriate a0 restore code | ||
| 484 | * (we'll need to rotate window back and there's no place to save this | ||
| 485 | * information, use different return address for that); | ||
| 486 | * - handle the exception; | ||
| 487 | * - go to the window that was being spilled; | ||
| 488 | * - set up window_overflow_restore_a0_fixup as a fixup routine; | ||
| 489 | * - reload a0; | ||
| 490 | * - restore the original window; | ||
| 491 | * - reset the default fixup routine; | ||
| 492 | * - return to user. By the time we get to this fixup handler all information | ||
| 493 | * about the conditions of the original double exception that happened in | ||
| 494 | * the window overflow handler is lost, so we just return to userspace to | ||
| 495 | * retry overflow from start. | ||
| 496 | * | ||
| 497 | * a0: value of depc, original value in depc | ||
| 498 | * a2: trashed, original value in EXC_TABLE_DOUBLE_SAVE | ||
| 499 | * a3: exctable, original value in excsave1 | ||
| 500 | */ | ||
| 501 | |||
| 502 | ENTRY(window_overflow_restore_a0_fixup) | ||
| 503 | |||
| 504 | rsr a0, ps | ||
| 505 | extui a0, a0, PS_OWB_SHIFT, PS_OWB_WIDTH | ||
| 506 | rsr a2, windowbase | ||
| 507 | sub a0, a2, a0 | ||
| 508 | extui a0, a0, 0, 3 | ||
| 509 | l32i a2, a3, EXC_TABLE_DOUBLE_SAVE | ||
| 510 | xsr a3, excsave1 | ||
| 511 | |||
| 512 | _beqi a0, 1, .Lhandle_1 | ||
| 513 | _beqi a0, 3, .Lhandle_3 | ||
| 514 | |||
| 515 | .macro overflow_fixup_handle_exception_pane n | ||
| 516 | |||
| 517 | rsr a0, depc | ||
| 518 | rotw -\n | ||
| 519 | |||
| 520 | xsr a3, excsave1 | ||
| 521 | wsr a2, depc | ||
| 522 | l32i a2, a3, EXC_TABLE_KSTK | ||
| 523 | s32i a0, a2, PT_AREG0 | ||
| 524 | |||
| 525 | movi a0, .Lrestore_\n | ||
| 526 | s32i a0, a2, PT_DEPC | ||
| 527 | rsr a0, exccause | ||
| 528 | j _DoubleExceptionVector_handle_exception | ||
| 529 | |||
| 530 | .endm | ||
| 531 | |||
| 532 | overflow_fixup_handle_exception_pane 2 | ||
| 533 | .Lhandle_1: | ||
| 534 | overflow_fixup_handle_exception_pane 1 | ||
| 535 | .Lhandle_3: | ||
| 536 | overflow_fixup_handle_exception_pane 3 | ||
| 537 | |||
| 538 | .macro overflow_fixup_restore_a0_pane n | ||
| 539 | |||
| 540 | rotw \n | ||
| 541 | /* Need to preserve a0 value here to be able to handle exception | ||
| 542 | * that may occur on a0 reload from stack. It may occur because | ||
| 543 | * TLB miss handler may not be atomic and pointer to page table | ||
| 544 | * may be lost before we get here. There are no free registers, | ||
| 545 | * so we need to use EXC_TABLE_DOUBLE_SAVE area. | ||
| 546 | */ | ||
| 547 | xsr a3, excsave1 | ||
| 548 | s32i a2, a3, EXC_TABLE_DOUBLE_SAVE | ||
| 549 | movi a2, window_overflow_restore_a0_fixup | ||
| 550 | s32i a2, a3, EXC_TABLE_FIXUP | ||
| 551 | l32i a2, a3, EXC_TABLE_DOUBLE_SAVE | ||
| 552 | xsr a3, excsave1 | ||
| 553 | bbsi.l a0, 7, 1f | ||
| 554 | l32e a0, a9, -16 | ||
| 555 | j 2f | ||
| 556 | 1: | ||
| 557 | l32e a0, a13, -16 | ||
| 558 | 2: | ||
| 559 | rotw -\n | ||
| 560 | |||
| 561 | .endm | ||
| 562 | |||
| 563 | .Lrestore_2: | ||
| 564 | overflow_fixup_restore_a0_pane 2 | ||
| 565 | |||
| 566 | .Lset_default_fixup: | ||
| 567 | xsr a3, excsave1 | ||
| 568 | s32i a2, a3, EXC_TABLE_DOUBLE_SAVE | ||
| 569 | movi a2, 0 | ||
| 570 | s32i a2, a3, EXC_TABLE_FIXUP | ||
| 571 | l32i a2, a3, EXC_TABLE_DOUBLE_SAVE | ||
| 572 | xsr a3, excsave1 | ||
| 573 | rfe | ||
| 574 | |||
| 575 | .Lrestore_1: | ||
| 576 | overflow_fixup_restore_a0_pane 1 | ||
| 577 | j .Lset_default_fixup | ||
| 578 | .Lrestore_3: | ||
| 579 | overflow_fixup_restore_a0_pane 3 | ||
| 580 | j .Lset_default_fixup | ||
| 581 | |||
| 582 | ENDPROC(window_overflow_restore_a0_fixup) | ||
| 583 | |||
| 584 | .end literal_prefix | ||
| 585 | /* | ||
| 472 | * Debug interrupt vector | 586 | * Debug interrupt vector |
| 473 | * | 587 | * |
| 474 | * There is not much space here, so simply jump to another handler. | 588 | * There is not much space here, so simply jump to another handler. |
diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S index ee32c0085dff..d16db6df86f8 100644 --- a/arch/xtensa/kernel/vmlinux.lds.S +++ b/arch/xtensa/kernel/vmlinux.lds.S | |||
| @@ -269,13 +269,13 @@ SECTIONS | |||
| 269 | .UserExceptionVector.literal) | 269 | .UserExceptionVector.literal) |
| 270 | SECTION_VECTOR (_DoubleExceptionVector_literal, | 270 | SECTION_VECTOR (_DoubleExceptionVector_literal, |
| 271 | .DoubleExceptionVector.literal, | 271 | .DoubleExceptionVector.literal, |
| 272 | DOUBLEEXC_VECTOR_VADDR - 16, | 272 | DOUBLEEXC_VECTOR_VADDR - 40, |
| 273 | SIZEOF(.UserExceptionVector.text), | 273 | SIZEOF(.UserExceptionVector.text), |
| 274 | .UserExceptionVector.text) | 274 | .UserExceptionVector.text) |
| 275 | SECTION_VECTOR (_DoubleExceptionVector_text, | 275 | SECTION_VECTOR (_DoubleExceptionVector_text, |
| 276 | .DoubleExceptionVector.text, | 276 | .DoubleExceptionVector.text, |
| 277 | DOUBLEEXC_VECTOR_VADDR, | 277 | DOUBLEEXC_VECTOR_VADDR, |
| 278 | 32, | 278 | 40, |
| 279 | .DoubleExceptionVector.literal) | 279 | .DoubleExceptionVector.literal) |
| 280 | 280 | ||
| 281 | . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; | 281 | . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3; |
diff --git a/arch/xtensa/mm/init.c b/arch/xtensa/mm/init.c index 4224256bb215..77ed20209ca5 100644 --- a/arch/xtensa/mm/init.c +++ b/arch/xtensa/mm/init.c | |||
| @@ -191,7 +191,7 @@ int __init mem_reserve(unsigned long start, unsigned long end, int must_exist) | |||
| 191 | return -EINVAL; | 191 | return -EINVAL; |
| 192 | } | 192 | } |
| 193 | 193 | ||
| 194 | if (it && start - it->start < bank_sz) { | 194 | if (it && start - it->start <= bank_sz) { |
| 195 | if (start == it->start) { | 195 | if (start == it->start) { |
| 196 | if (end - it->start < bank_sz) { | 196 | if (end - it->start < bank_sz) { |
| 197 | it->start = end; | 197 | it->start = end; |
diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c index b9f4cc494ece..28d227c5ca77 100644 --- a/block/blk-cgroup.c +++ b/block/blk-cgroup.c | |||
| @@ -872,6 +872,13 @@ void blkcg_drain_queue(struct request_queue *q) | |||
| 872 | { | 872 | { |
| 873 | lockdep_assert_held(q->queue_lock); | 873 | lockdep_assert_held(q->queue_lock); |
| 874 | 874 | ||
| 875 | /* | ||
| 876 | * @q could be exiting and already have destroyed all blkgs as | ||
| 877 | * indicated by NULL root_blkg. If so, don't confuse policies. | ||
| 878 | */ | ||
| 879 | if (!q->root_blkg) | ||
| 880 | return; | ||
| 881 | |||
| 875 | blk_throtl_drain(q); | 882 | blk_throtl_drain(q); |
| 876 | } | 883 | } |
| 877 | 884 | ||
diff --git a/block/blk-tag.c b/block/blk-tag.c index 3f33d8672268..a185b86741e5 100644 --- a/block/blk-tag.c +++ b/block/blk-tag.c | |||
| @@ -27,18 +27,15 @@ struct request *blk_queue_find_tag(struct request_queue *q, int tag) | |||
| 27 | EXPORT_SYMBOL(blk_queue_find_tag); | 27 | EXPORT_SYMBOL(blk_queue_find_tag); |
| 28 | 28 | ||
| 29 | /** | 29 | /** |
| 30 | * __blk_free_tags - release a given set of tag maintenance info | 30 | * blk_free_tags - release a given set of tag maintenance info |
| 31 | * @bqt: the tag map to free | 31 | * @bqt: the tag map to free |
| 32 | * | 32 | * |
| 33 | * Tries to free the specified @bqt. Returns true if it was | 33 | * Drop the reference count on @bqt and frees it when the last reference |
| 34 | * actually freed and false if there are still references using it | 34 | * is dropped. |
| 35 | */ | 35 | */ |
| 36 | static int __blk_free_tags(struct blk_queue_tag *bqt) | 36 | void blk_free_tags(struct blk_queue_tag *bqt) |
| 37 | { | 37 | { |
| 38 | int retval; | 38 | if (atomic_dec_and_test(&bqt->refcnt)) { |
| 39 | |||
| 40 | retval = atomic_dec_and_test(&bqt->refcnt); | ||
| 41 | if (retval) { | ||
| 42 | BUG_ON(find_first_bit(bqt->tag_map, bqt->max_depth) < | 39 | BUG_ON(find_first_bit(bqt->tag_map, bqt->max_depth) < |
| 43 | bqt->max_depth); | 40 | bqt->max_depth); |
| 44 | 41 | ||
| @@ -50,9 +47,8 @@ static int __blk_free_tags(struct blk_queue_tag *bqt) | |||
| 50 | 47 | ||
| 51 | kfree(bqt); | 48 | kfree(bqt); |
| 52 | } | 49 | } |
| 53 | |||
| 54 | return retval; | ||
| 55 | } | 50 | } |
| 51 | EXPORT_SYMBOL(blk_free_tags); | ||
| 56 | 52 | ||
| 57 | /** | 53 | /** |
| 58 | * __blk_queue_free_tags - release tag maintenance info | 54 | * __blk_queue_free_tags - release tag maintenance info |
| @@ -69,28 +65,13 @@ void __blk_queue_free_tags(struct request_queue *q) | |||
| 69 | if (!bqt) | 65 | if (!bqt) |
| 70 | return; | 66 | return; |
| 71 | 67 | ||
| 72 | __blk_free_tags(bqt); | 68 | blk_free_tags(bqt); |
| 73 | 69 | ||
| 74 | q->queue_tags = NULL; | 70 | q->queue_tags = NULL; |
| 75 | queue_flag_clear_unlocked(QUEUE_FLAG_QUEUED, q); | 71 | queue_flag_clear_unlocked(QUEUE_FLAG_QUEUED, q); |
| 76 | } | 72 | } |
| 77 | 73 | ||
| 78 | /** | 74 | /** |
| 79 | * blk_free_tags - release a given set of tag maintenance info | ||
| 80 | * @bqt: the tag map to free | ||
| 81 | * | ||
| 82 | * For externally managed @bqt frees the map. Callers of this | ||
| 83 | * function must guarantee to have released all the queues that | ||
| 84 | * might have been using this tag map. | ||
| 85 | */ | ||
| 86 | void blk_free_tags(struct blk_queue_tag *bqt) | ||
| 87 | { | ||
| 88 | if (unlikely(!__blk_free_tags(bqt))) | ||
| 89 | BUG(); | ||
| 90 | } | ||
| 91 | EXPORT_SYMBOL(blk_free_tags); | ||
| 92 | |||
| 93 | /** | ||
| 94 | * blk_queue_free_tags - release tag maintenance info | 75 | * blk_queue_free_tags - release tag maintenance info |
| 95 | * @q: the request queue for the device | 76 | * @q: the request queue for the device |
| 96 | * | 77 | * |
diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c index fbd5a67cb773..a0926a6094b2 100644 --- a/block/compat_ioctl.c +++ b/block/compat_ioctl.c | |||
| @@ -690,6 +690,7 @@ long compat_blkdev_ioctl(struct file *file, unsigned cmd, unsigned long arg) | |||
| 690 | case BLKROSET: | 690 | case BLKROSET: |
| 691 | case BLKDISCARD: | 691 | case BLKDISCARD: |
| 692 | case BLKSECDISCARD: | 692 | case BLKSECDISCARD: |
| 693 | case BLKZEROOUT: | ||
| 693 | /* | 694 | /* |
| 694 | * the ones below are implemented in blkdev_locked_ioctl, | 695 | * the ones below are implemented in blkdev_locked_ioctl, |
| 695 | * but we call blkdev_ioctl, which gets the lock for us | 696 | * but we call blkdev_ioctl, which gets the lock for us |
diff --git a/crypto/af_alg.c b/crypto/af_alg.c index 966f893711b3..6a3ad8011585 100644 --- a/crypto/af_alg.c +++ b/crypto/af_alg.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/module.h> | 21 | #include <linux/module.h> |
| 22 | #include <linux/net.h> | 22 | #include <linux/net.h> |
| 23 | #include <linux/rwsem.h> | 23 | #include <linux/rwsem.h> |
| 24 | #include <linux/security.h> | ||
| 24 | 25 | ||
| 25 | struct alg_type_list { | 26 | struct alg_type_list { |
| 26 | const struct af_alg_type *type; | 27 | const struct af_alg_type *type; |
| @@ -243,6 +244,7 @@ int af_alg_accept(struct sock *sk, struct socket *newsock) | |||
| 243 | 244 | ||
| 244 | sock_init_data(newsock, sk2); | 245 | sock_init_data(newsock, sk2); |
| 245 | sock_graft(sk2, newsock); | 246 | sock_graft(sk2, newsock); |
| 247 | security_sk_clone(sk, sk2); | ||
| 246 | 248 | ||
| 247 | err = type->accept(ask->private, sk2); | 249 | err = type->accept(ask->private, sk2); |
| 248 | if (err) { | 250 | if (err) { |
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c index c67f6f5ad611..36b0e61f9c09 100644 --- a/drivers/acpi/ac.c +++ b/drivers/acpi/ac.c | |||
| @@ -30,6 +30,10 @@ | |||
| 30 | #include <linux/types.h> | 30 | #include <linux/types.h> |
| 31 | #include <linux/dmi.h> | 31 | #include <linux/dmi.h> |
| 32 | #include <linux/delay.h> | 32 | #include <linux/delay.h> |
| 33 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 34 | #include <linux/proc_fs.h> | ||
| 35 | #include <linux/seq_file.h> | ||
| 36 | #endif | ||
| 33 | #include <linux/platform_device.h> | 37 | #include <linux/platform_device.h> |
| 34 | #include <linux/power_supply.h> | 38 | #include <linux/power_supply.h> |
| 35 | #include <linux/acpi.h> | 39 | #include <linux/acpi.h> |
| @@ -52,6 +56,7 @@ MODULE_AUTHOR("Paul Diefenbaugh"); | |||
| 52 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); | 56 | MODULE_DESCRIPTION("ACPI AC Adapter Driver"); |
| 53 | MODULE_LICENSE("GPL"); | 57 | MODULE_LICENSE("GPL"); |
| 54 | 58 | ||
| 59 | |||
| 55 | static int acpi_ac_add(struct acpi_device *device); | 60 | static int acpi_ac_add(struct acpi_device *device); |
| 56 | static int acpi_ac_remove(struct acpi_device *device); | 61 | static int acpi_ac_remove(struct acpi_device *device); |
| 57 | static void acpi_ac_notify(struct acpi_device *device, u32 event); | 62 | static void acpi_ac_notify(struct acpi_device *device, u32 event); |
| @@ -67,6 +72,13 @@ static int acpi_ac_resume(struct device *dev); | |||
| 67 | #endif | 72 | #endif |
| 68 | static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume); | 73 | static SIMPLE_DEV_PM_OPS(acpi_ac_pm, NULL, acpi_ac_resume); |
| 69 | 74 | ||
| 75 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 76 | extern struct proc_dir_entry *acpi_lock_ac_dir(void); | ||
| 77 | extern void *acpi_unlock_ac_dir(struct proc_dir_entry *acpi_ac_dir); | ||
| 78 | static int acpi_ac_open_fs(struct inode *inode, struct file *file); | ||
| 79 | #endif | ||
| 80 | |||
| 81 | |||
| 70 | static int ac_sleep_before_get_state_ms; | 82 | static int ac_sleep_before_get_state_ms; |
| 71 | 83 | ||
| 72 | static struct acpi_driver acpi_ac_driver = { | 84 | static struct acpi_driver acpi_ac_driver = { |
| @@ -91,6 +103,16 @@ struct acpi_ac { | |||
| 91 | 103 | ||
| 92 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger) | 104 | #define to_acpi_ac(x) container_of(x, struct acpi_ac, charger) |
| 93 | 105 | ||
| 106 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 107 | static const struct file_operations acpi_ac_fops = { | ||
| 108 | .owner = THIS_MODULE, | ||
| 109 | .open = acpi_ac_open_fs, | ||
| 110 | .read = seq_read, | ||
| 111 | .llseek = seq_lseek, | ||
| 112 | .release = single_release, | ||
| 113 | }; | ||
| 114 | #endif | ||
| 115 | |||
| 94 | /* -------------------------------------------------------------------------- | 116 | /* -------------------------------------------------------------------------- |
| 95 | AC Adapter Management | 117 | AC Adapter Management |
| 96 | -------------------------------------------------------------------------- */ | 118 | -------------------------------------------------------------------------- */ |
| @@ -143,6 +165,83 @@ static enum power_supply_property ac_props[] = { | |||
| 143 | POWER_SUPPLY_PROP_ONLINE, | 165 | POWER_SUPPLY_PROP_ONLINE, |
| 144 | }; | 166 | }; |
| 145 | 167 | ||
| 168 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 169 | /* -------------------------------------------------------------------------- | ||
| 170 | FS Interface (/proc) | ||
| 171 | -------------------------------------------------------------------------- */ | ||
| 172 | |||
| 173 | static struct proc_dir_entry *acpi_ac_dir; | ||
| 174 | |||
| 175 | static int acpi_ac_seq_show(struct seq_file *seq, void *offset) | ||
| 176 | { | ||
| 177 | struct acpi_ac *ac = seq->private; | ||
| 178 | |||
| 179 | |||
| 180 | if (!ac) | ||
| 181 | return 0; | ||
| 182 | |||
| 183 | if (acpi_ac_get_state(ac)) { | ||
| 184 | seq_puts(seq, "ERROR: Unable to read AC Adapter state\n"); | ||
| 185 | return 0; | ||
| 186 | } | ||
| 187 | |||
| 188 | seq_puts(seq, "state: "); | ||
| 189 | switch (ac->state) { | ||
| 190 | case ACPI_AC_STATUS_OFFLINE: | ||
| 191 | seq_puts(seq, "off-line\n"); | ||
| 192 | break; | ||
| 193 | case ACPI_AC_STATUS_ONLINE: | ||
| 194 | seq_puts(seq, "on-line\n"); | ||
| 195 | break; | ||
| 196 | default: | ||
| 197 | seq_puts(seq, "unknown\n"); | ||
| 198 | break; | ||
| 199 | } | ||
| 200 | |||
| 201 | return 0; | ||
| 202 | } | ||
| 203 | |||
| 204 | static int acpi_ac_open_fs(struct inode *inode, struct file *file) | ||
| 205 | { | ||
| 206 | return single_open(file, acpi_ac_seq_show, PDE_DATA(inode)); | ||
| 207 | } | ||
| 208 | |||
| 209 | static int acpi_ac_add_fs(struct acpi_ac *ac) | ||
| 210 | { | ||
| 211 | struct proc_dir_entry *entry = NULL; | ||
| 212 | |||
| 213 | printk(KERN_WARNING PREFIX "Deprecated procfs I/F for AC is loaded," | ||
| 214 | " please retry with CONFIG_ACPI_PROCFS_POWER cleared\n"); | ||
| 215 | if (!acpi_device_dir(ac->device)) { | ||
| 216 | acpi_device_dir(ac->device) = | ||
| 217 | proc_mkdir(acpi_device_bid(ac->device), acpi_ac_dir); | ||
| 218 | if (!acpi_device_dir(ac->device)) | ||
| 219 | return -ENODEV; | ||
| 220 | } | ||
| 221 | |||
| 222 | /* 'state' [R] */ | ||
| 223 | entry = proc_create_data(ACPI_AC_FILE_STATE, | ||
| 224 | S_IRUGO, acpi_device_dir(ac->device), | ||
| 225 | &acpi_ac_fops, ac); | ||
| 226 | if (!entry) | ||
| 227 | return -ENODEV; | ||
| 228 | return 0; | ||
| 229 | } | ||
| 230 | |||
| 231 | static int acpi_ac_remove_fs(struct acpi_ac *ac) | ||
| 232 | { | ||
| 233 | |||
| 234 | if (acpi_device_dir(ac->device)) { | ||
| 235 | remove_proc_entry(ACPI_AC_FILE_STATE, | ||
| 236 | acpi_device_dir(ac->device)); | ||
| 237 | remove_proc_entry(acpi_device_bid(ac->device), acpi_ac_dir); | ||
| 238 | acpi_device_dir(ac->device) = NULL; | ||
| 239 | } | ||
| 240 | |||
| 241 | return 0; | ||
| 242 | } | ||
| 243 | #endif | ||
| 244 | |||
| 146 | /* -------------------------------------------------------------------------- | 245 | /* -------------------------------------------------------------------------- |
| 147 | Driver Model | 246 | Driver Model |
| 148 | -------------------------------------------------------------------------- */ | 247 | -------------------------------------------------------------------------- */ |
| @@ -243,6 +342,11 @@ static int acpi_ac_add(struct acpi_device *device) | |||
| 243 | goto end; | 342 | goto end; |
| 244 | 343 | ||
| 245 | ac->charger.name = acpi_device_bid(device); | 344 | ac->charger.name = acpi_device_bid(device); |
| 345 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 346 | result = acpi_ac_add_fs(ac); | ||
| 347 | if (result) | ||
| 348 | goto end; | ||
| 349 | #endif | ||
| 246 | ac->charger.type = POWER_SUPPLY_TYPE_MAINS; | 350 | ac->charger.type = POWER_SUPPLY_TYPE_MAINS; |
| 247 | ac->charger.properties = ac_props; | 351 | ac->charger.properties = ac_props; |
| 248 | ac->charger.num_properties = ARRAY_SIZE(ac_props); | 352 | ac->charger.num_properties = ARRAY_SIZE(ac_props); |
| @@ -258,8 +362,12 @@ static int acpi_ac_add(struct acpi_device *device) | |||
| 258 | ac->battery_nb.notifier_call = acpi_ac_battery_notify; | 362 | ac->battery_nb.notifier_call = acpi_ac_battery_notify; |
| 259 | register_acpi_notifier(&ac->battery_nb); | 363 | register_acpi_notifier(&ac->battery_nb); |
| 260 | end: | 364 | end: |
| 261 | if (result) | 365 | if (result) { |
| 366 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 367 | acpi_ac_remove_fs(ac); | ||
| 368 | #endif | ||
| 262 | kfree(ac); | 369 | kfree(ac); |
| 370 | } | ||
| 263 | 371 | ||
| 264 | dmi_check_system(ac_dmi_table); | 372 | dmi_check_system(ac_dmi_table); |
| 265 | return result; | 373 | return result; |
| @@ -303,6 +411,10 @@ static int acpi_ac_remove(struct acpi_device *device) | |||
| 303 | power_supply_unregister(&ac->charger); | 411 | power_supply_unregister(&ac->charger); |
| 304 | unregister_acpi_notifier(&ac->battery_nb); | 412 | unregister_acpi_notifier(&ac->battery_nb); |
| 305 | 413 | ||
| 414 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 415 | acpi_ac_remove_fs(ac); | ||
| 416 | #endif | ||
| 417 | |||
| 306 | kfree(ac); | 418 | kfree(ac); |
| 307 | 419 | ||
| 308 | return 0; | 420 | return 0; |
| @@ -315,9 +427,20 @@ static int __init acpi_ac_init(void) | |||
| 315 | if (acpi_disabled) | 427 | if (acpi_disabled) |
| 316 | return -ENODEV; | 428 | return -ENODEV; |
| 317 | 429 | ||
| 430 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 431 | acpi_ac_dir = acpi_lock_ac_dir(); | ||
| 432 | if (!acpi_ac_dir) | ||
| 433 | return -ENODEV; | ||
| 434 | #endif | ||
| 435 | |||
| 436 | |||
| 318 | result = acpi_bus_register_driver(&acpi_ac_driver); | 437 | result = acpi_bus_register_driver(&acpi_ac_driver); |
| 319 | if (result < 0) | 438 | if (result < 0) { |
| 439 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 440 | acpi_unlock_ac_dir(acpi_ac_dir); | ||
| 441 | #endif | ||
| 320 | return -ENODEV; | 442 | return -ENODEV; |
| 443 | } | ||
| 321 | 444 | ||
| 322 | return 0; | 445 | return 0; |
| 323 | } | 446 | } |
| @@ -325,6 +448,9 @@ static int __init acpi_ac_init(void) | |||
| 325 | static void __exit acpi_ac_exit(void) | 448 | static void __exit acpi_ac_exit(void) |
| 326 | { | 449 | { |
| 327 | acpi_bus_unregister_driver(&acpi_ac_driver); | 450 | acpi_bus_unregister_driver(&acpi_ac_driver); |
| 451 | #ifdef CONFIG_ACPI_PROCFS_POWER | ||
| 452 | acpi_unlock_ac_dir(acpi_ac_dir); | ||
| 453 | #endif | ||
| 328 | } | 454 | } |
| 329 | module_init(acpi_ac_init); | 455 | module_init(acpi_ac_init); |
| 330 | module_exit(acpi_ac_exit); | 456 | module_exit(acpi_ac_exit); |
diff --git a/drivers/acpi/acpi_pnp.c b/drivers/acpi/acpi_pnp.c index 6703c1fd993a..4ddb0dca56f6 100644 --- a/drivers/acpi/acpi_pnp.c +++ b/drivers/acpi/acpi_pnp.c | |||
| @@ -14,6 +14,8 @@ | |||
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | 15 | ||
| 16 | static const struct acpi_device_id acpi_pnp_device_ids[] = { | 16 | static const struct acpi_device_id acpi_pnp_device_ids[] = { |
| 17 | /* soc_button_array */ | ||
| 18 | {"PNP0C40"}, | ||
| 17 | /* pata_isapnp */ | 19 | /* pata_isapnp */ |
| 18 | {"PNP0600"}, /* Generic ESDI/IDE/ATA compatible hard disk controller */ | 20 | {"PNP0600"}, /* Generic ESDI/IDE/ATA compatible hard disk controller */ |
| 19 | /* floppy */ | 21 | /* floppy */ |
diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 0d7116f34b95..130f513e08c9 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c | |||
| @@ -35,6 +35,7 @@ | |||
| 35 | #include <linux/delay.h> | 35 | #include <linux/delay.h> |
| 36 | #include <linux/slab.h> | 36 | #include <linux/slab.h> |
| 37 | #include <linux/suspend.h> | 37 | #include <linux/suspend.h> |
| 38 | #include <linux/delay.h> | ||
| 38 | #include <asm/unaligned.h> | 39 | #include <asm/unaligned.h> |
| 39 | 40 | ||
| 40 | #ifdef CONFIG_ACPI_PROCFS_POWER | 41 | #ifdef CONFIG_ACPI_PROCFS_POWER |
| @@ -534,6 +535,20 @@ static int acpi_battery_get_state(struct acpi_battery *battery) | |||
| 534 | " invalid.\n"); | 535 | " invalid.\n"); |
| 535 | } | 536 | } |
| 536 | 537 | ||
| 538 | /* | ||
| 539 | * When fully charged, some batteries wrongly report | ||
| 540 | * capacity_now = design_capacity instead of = full_charge_capacity | ||
| 541 | */ | ||
| 542 | if (battery->capacity_now > battery->full_charge_capacity | ||
| 543 | && battery->full_charge_capacity != ACPI_BATTERY_VALUE_UNKNOWN) { | ||
| 544 | battery->capacity_now = battery->full_charge_capacity; | ||
| 545 | if (battery->capacity_now != battery->design_capacity) | ||
| 546 | printk_once(KERN_WARNING FW_BUG | ||
| 547 | "battery: reported current charge level (%d) " | ||
| 548 | "is higher than reported maximum charge level (%d).\n", | ||
| 549 | battery->capacity_now, battery->full_charge_capacity); | ||
| 550 | } | ||
| 551 | |||
| 537 | if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) | 552 | if (test_bit(ACPI_BATTERY_QUIRK_PERCENTAGE_CAPACITY, &battery->flags) |
| 538 | && battery->capacity_now >= 0 && battery->capacity_now <= 100) | 553 | && battery->capacity_now >= 0 && battery->capacity_now <= 100) |
| 539 | battery->capacity_now = (battery->capacity_now * | 554 | battery->capacity_now = (battery->capacity_now * |
| @@ -1151,6 +1166,28 @@ static struct dmi_system_id bat_dmi_table[] = { | |||
| 1151 | {}, | 1166 | {}, |
| 1152 | }; | 1167 | }; |
| 1153 | 1168 | ||
| 1169 | /* | ||
| 1170 | * Some machines'(E,G Lenovo Z480) ECs are not stable | ||
| 1171 | * during boot up and this causes battery driver fails to be | ||
| 1172 | * probed due to failure of getting battery information | ||
| 1173 | * from EC sometimes. After several retries, the operation | ||
| 1174 | * may work. So add retry code here and 20ms sleep between | ||
| 1175 | * every retries. | ||
| 1176 | */ | ||
| 1177 | static int acpi_battery_update_retry(struct acpi_battery *battery) | ||
| 1178 | { | ||
| 1179 | int retry, ret; | ||
| 1180 | |||
| 1181 | for (retry = 5; retry; retry--) { | ||
| 1182 | ret = acpi_battery_update(battery, false); | ||
| 1183 | if (!ret) | ||
| 1184 | break; | ||
| 1185 | |||
| 1186 | msleep(20); | ||
| 1187 | } | ||
| 1188 | return ret; | ||
| 1189 | } | ||
| 1190 | |||
| 1154 | static int acpi_battery_add(struct acpi_device *device) | 1191 | static int acpi_battery_add(struct acpi_device *device) |
| 1155 | { | 1192 | { |
| 1156 | int result = 0; | 1193 | int result = 0; |
| @@ -1169,9 +1206,11 @@ static int acpi_battery_add(struct acpi_device *device) | |||
| 1169 | mutex_init(&battery->sysfs_lock); | 1206 | mutex_init(&battery->sysfs_lock); |
| 1170 | if (acpi_has_method(battery->device->handle, "_BIX")) | 1207 | if (acpi_has_method(battery->device->handle, "_BIX")) |
| 1171 | set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); | 1208 | set_bit(ACPI_BATTERY_XINFO_PRESENT, &battery->flags); |
| 1172 | result = acpi_battery_update(battery, false); | 1209 | |
| 1210 | result = acpi_battery_update_retry(battery); | ||
| 1173 | if (result) | 1211 | if (result) |
| 1174 | goto fail; | 1212 | goto fail; |
| 1213 | |||
| 1175 | #ifdef CONFIG_ACPI_PROCFS_POWER | 1214 | #ifdef CONFIG_ACPI_PROCFS_POWER |
| 1176 | result = acpi_battery_add_fs(device); | 1215 | result = acpi_battery_add_fs(device); |
| 1177 | #endif | 1216 | #endif |
diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index ad11ba4a412d..a66ab658abbc 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c | |||
| @@ -1,11 +1,14 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * ec.c - ACPI Embedded Controller Driver (v2.1) | 2 | * ec.c - ACPI Embedded Controller Driver (v2.2) |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2006-2008 Alexey Starikovskiy <astarikovskiy@suse.de> | 4 | * Copyright (C) 2001-2014 Intel Corporation |
| 5 | * Copyright (C) 2006 Denis Sadykov <denis.m.sadykov@intel.com> | 5 | * Author: 2014 Lv Zheng <lv.zheng@intel.com> |
| 6 | * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> | 6 | * 2006, 2007 Alexey Starikovskiy <alexey.y.starikovskiy@intel.com> |
| 7 | * Copyright (C) 2001, 2002 Andy Grover <andrew.grover@intel.com> | 7 | * 2006 Denis Sadykov <denis.m.sadykov@intel.com> |
| 8 | * Copyright (C) 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | 8 | * 2004 Luming Yu <luming.yu@intel.com> |
| 9 | * 2001, 2002 Andy Grover <andrew.grover@intel.com> | ||
| 10 | * 2001, 2002 Paul Diefenbaugh <paul.s.diefenbaugh@intel.com> | ||
| 11 | * Copyright (C) 2008 Alexey Starikovskiy <astarikovskiy@suse.de> | ||
| 9 | * | 12 | * |
| 10 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 13 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 11 | * | 14 | * |
| @@ -52,6 +55,7 @@ | |||
| 52 | /* EC status register */ | 55 | /* EC status register */ |
| 53 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ | 56 | #define ACPI_EC_FLAG_OBF 0x01 /* Output buffer full */ |
| 54 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ | 57 | #define ACPI_EC_FLAG_IBF 0x02 /* Input buffer full */ |
| 58 | #define ACPI_EC_FLAG_CMD 0x08 /* Input buffer contains a command */ | ||
| 55 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ | 59 | #define ACPI_EC_FLAG_BURST 0x10 /* burst mode */ |
| 56 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ | 60 | #define ACPI_EC_FLAG_SCI 0x20 /* EC-SCI occurred */ |
| 57 | 61 | ||
| @@ -78,6 +82,9 @@ enum { | |||
| 78 | EC_FLAGS_BLOCKED, /* Transactions are blocked */ | 82 | EC_FLAGS_BLOCKED, /* Transactions are blocked */ |
| 79 | }; | 83 | }; |
| 80 | 84 | ||
| 85 | #define ACPI_EC_COMMAND_POLL 0x01 /* Available for command byte */ | ||
| 86 | #define ACPI_EC_COMMAND_COMPLETE 0x02 /* Completed last byte */ | ||
| 87 | |||
| 81 | /* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */ | 88 | /* ec.c is compiled in acpi namespace so this shows up as acpi.ec_delay param */ |
| 82 | static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; | 89 | static unsigned int ec_delay __read_mostly = ACPI_EC_DELAY; |
| 83 | module_param(ec_delay, uint, 0644); | 90 | module_param(ec_delay, uint, 0644); |
| @@ -109,7 +116,7 @@ struct transaction { | |||
| 109 | u8 ri; | 116 | u8 ri; |
| 110 | u8 wlen; | 117 | u8 wlen; |
| 111 | u8 rlen; | 118 | u8 rlen; |
| 112 | bool done; | 119 | u8 flags; |
| 113 | }; | 120 | }; |
| 114 | 121 | ||
| 115 | struct acpi_ec *boot_ec, *first_ec; | 122 | struct acpi_ec *boot_ec, *first_ec; |
| @@ -127,83 +134,104 @@ static int EC_FLAGS_CLEAR_ON_RESUME; /* Needs acpi_ec_clear() on boot/resume */ | |||
| 127 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) | 134 | static inline u8 acpi_ec_read_status(struct acpi_ec *ec) |
| 128 | { | 135 | { |
| 129 | u8 x = inb(ec->command_addr); | 136 | u8 x = inb(ec->command_addr); |
| 130 | pr_debug("---> status = 0x%2.2x\n", x); | 137 | pr_debug("EC_SC(R) = 0x%2.2x " |
| 138 | "SCI_EVT=%d BURST=%d CMD=%d IBF=%d OBF=%d\n", | ||
| 139 | x, | ||
| 140 | !!(x & ACPI_EC_FLAG_SCI), | ||
| 141 | !!(x & ACPI_EC_FLAG_BURST), | ||
| 142 | !!(x & ACPI_EC_FLAG_CMD), | ||
| 143 | !!(x & ACPI_EC_FLAG_IBF), | ||
| 144 | !!(x & ACPI_EC_FLAG_OBF)); | ||
| 131 | return x; | 145 | return x; |
| 132 | } | 146 | } |
| 133 | 147 | ||
| 134 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) | 148 | static inline u8 acpi_ec_read_data(struct acpi_ec *ec) |
| 135 | { | 149 | { |
| 136 | u8 x = inb(ec->data_addr); | 150 | u8 x = inb(ec->data_addr); |
| 137 | pr_debug("---> data = 0x%2.2x\n", x); | 151 | pr_debug("EC_DATA(R) = 0x%2.2x\n", x); |
| 138 | return x; | 152 | return x; |
| 139 | } | 153 | } |
| 140 | 154 | ||
| 141 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) | 155 | static inline void acpi_ec_write_cmd(struct acpi_ec *ec, u8 command) |
| 142 | { | 156 | { |
| 143 | pr_debug("<--- command = 0x%2.2x\n", command); | 157 | pr_debug("EC_SC(W) = 0x%2.2x\n", command); |
| 144 | outb(command, ec->command_addr); | 158 | outb(command, ec->command_addr); |
| 145 | } | 159 | } |
| 146 | 160 | ||
| 147 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) | 161 | static inline void acpi_ec_write_data(struct acpi_ec *ec, u8 data) |
| 148 | { | 162 | { |
| 149 | pr_debug("<--- data = 0x%2.2x\n", data); | 163 | pr_debug("EC_DATA(W) = 0x%2.2x\n", data); |
| 150 | outb(data, ec->data_addr); | 164 | outb(data, ec->data_addr); |
| 151 | } | 165 | } |
| 152 | 166 | ||
| 153 | static int ec_transaction_done(struct acpi_ec *ec) | 167 | static int ec_transaction_completed(struct acpi_ec *ec) |
| 154 | { | 168 | { |
| 155 | unsigned long flags; | 169 | unsigned long flags; |
| 156 | int ret = 0; | 170 | int ret = 0; |
| 157 | spin_lock_irqsave(&ec->lock, flags); | 171 | spin_lock_irqsave(&ec->lock, flags); |
| 158 | if (!ec->curr || ec->curr->done) | 172 | if (ec->curr && (ec->curr->flags & ACPI_EC_COMMAND_COMPLETE)) |
| 159 | ret = 1; | 173 | ret = 1; |
| 160 | spin_unlock_irqrestore(&ec->lock, flags); | 174 | spin_unlock_irqrestore(&ec->lock, flags); |
| 161 | return ret; | 175 | return ret; |
| 162 | } | 176 | } |
| 163 | 177 | ||
| 164 | static void start_transaction(struct acpi_ec *ec) | 178 | static bool advance_transaction(struct acpi_ec *ec) |
| 165 | { | 179 | { |
| 166 | ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0; | ||
| 167 | ec->curr->done = false; | ||
| 168 | acpi_ec_write_cmd(ec, ec->curr->command); | ||
| 169 | } | ||
| 170 | |||
| 171 | static void advance_transaction(struct acpi_ec *ec, u8 status) | ||
| 172 | { | ||
| 173 | unsigned long flags; | ||
| 174 | struct transaction *t; | 180 | struct transaction *t; |
| 181 | u8 status; | ||
| 182 | bool wakeup = false; | ||
| 175 | 183 | ||
| 176 | spin_lock_irqsave(&ec->lock, flags); | 184 | pr_debug("===== %s =====\n", in_interrupt() ? "IRQ" : "TASK"); |
| 185 | status = acpi_ec_read_status(ec); | ||
| 177 | t = ec->curr; | 186 | t = ec->curr; |
| 178 | if (!t) | 187 | if (!t) |
| 179 | goto unlock; | 188 | goto err; |
| 180 | if (t->wlen > t->wi) { | 189 | if (t->flags & ACPI_EC_COMMAND_POLL) { |
| 181 | if ((status & ACPI_EC_FLAG_IBF) == 0) | 190 | if (t->wlen > t->wi) { |
| 182 | acpi_ec_write_data(ec, | 191 | if ((status & ACPI_EC_FLAG_IBF) == 0) |
| 183 | t->wdata[t->wi++]); | 192 | acpi_ec_write_data(ec, t->wdata[t->wi++]); |
| 184 | else | 193 | else |
| 185 | goto err; | 194 | goto err; |
| 186 | } else if (t->rlen > t->ri) { | 195 | } else if (t->rlen > t->ri) { |
| 187 | if ((status & ACPI_EC_FLAG_OBF) == 1) { | 196 | if ((status & ACPI_EC_FLAG_OBF) == 1) { |
| 188 | t->rdata[t->ri++] = acpi_ec_read_data(ec); | 197 | t->rdata[t->ri++] = acpi_ec_read_data(ec); |
| 189 | if (t->rlen == t->ri) | 198 | if (t->rlen == t->ri) { |
| 190 | t->done = true; | 199 | t->flags |= ACPI_EC_COMMAND_COMPLETE; |
| 200 | wakeup = true; | ||
| 201 | } | ||
| 202 | } else | ||
| 203 | goto err; | ||
| 204 | } else if (t->wlen == t->wi && | ||
| 205 | (status & ACPI_EC_FLAG_IBF) == 0) { | ||
| 206 | t->flags |= ACPI_EC_COMMAND_COMPLETE; | ||
| 207 | wakeup = true; | ||
| 208 | } | ||
| 209 | return wakeup; | ||
| 210 | } else { | ||
| 211 | if ((status & ACPI_EC_FLAG_IBF) == 0) { | ||
| 212 | acpi_ec_write_cmd(ec, t->command); | ||
| 213 | t->flags |= ACPI_EC_COMMAND_POLL; | ||
| 191 | } else | 214 | } else |
| 192 | goto err; | 215 | goto err; |
| 193 | } else if (t->wlen == t->wi && | 216 | return wakeup; |
| 194 | (status & ACPI_EC_FLAG_IBF) == 0) | 217 | } |
| 195 | t->done = true; | ||
| 196 | goto unlock; | ||
| 197 | err: | 218 | err: |
| 198 | /* | 219 | /* |
| 199 | * If SCI bit is set, then don't think it's a false IRQ | 220 | * If SCI bit is set, then don't think it's a false IRQ |
| 200 | * otherwise will take a not handled IRQ as a false one. | 221 | * otherwise will take a not handled IRQ as a false one. |
| 201 | */ | 222 | */ |
| 202 | if (in_interrupt() && !(status & ACPI_EC_FLAG_SCI)) | 223 | if (!(status & ACPI_EC_FLAG_SCI)) { |
| 203 | ++t->irq_count; | 224 | if (in_interrupt() && t) |
| 225 | ++t->irq_count; | ||
| 226 | } | ||
| 227 | return wakeup; | ||
| 228 | } | ||
| 204 | 229 | ||
| 205 | unlock: | 230 | static void start_transaction(struct acpi_ec *ec) |
| 206 | spin_unlock_irqrestore(&ec->lock, flags); | 231 | { |
| 232 | ec->curr->irq_count = ec->curr->wi = ec->curr->ri = 0; | ||
| 233 | ec->curr->flags = 0; | ||
| 234 | (void)advance_transaction(ec); | ||
| 207 | } | 235 | } |
| 208 | 236 | ||
| 209 | static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data); | 237 | static int acpi_ec_sync_query(struct acpi_ec *ec, u8 *data); |
| @@ -228,15 +256,17 @@ static int ec_poll(struct acpi_ec *ec) | |||
| 228 | /* don't sleep with disabled interrupts */ | 256 | /* don't sleep with disabled interrupts */ |
| 229 | if (EC_FLAGS_MSI || irqs_disabled()) { | 257 | if (EC_FLAGS_MSI || irqs_disabled()) { |
| 230 | udelay(ACPI_EC_MSI_UDELAY); | 258 | udelay(ACPI_EC_MSI_UDELAY); |
| 231 | if (ec_transaction_done(ec)) | 259 | if (ec_transaction_completed(ec)) |
| 232 | return 0; | 260 | return 0; |
| 233 | } else { | 261 | } else { |
| 234 | if (wait_event_timeout(ec->wait, | 262 | if (wait_event_timeout(ec->wait, |
| 235 | ec_transaction_done(ec), | 263 | ec_transaction_completed(ec), |
| 236 | msecs_to_jiffies(1))) | 264 | msecs_to_jiffies(1))) |
| 237 | return 0; | 265 | return 0; |
| 238 | } | 266 | } |
| 239 | advance_transaction(ec, acpi_ec_read_status(ec)); | 267 | spin_lock_irqsave(&ec->lock, flags); |
| 268 | (void)advance_transaction(ec); | ||
| 269 | spin_unlock_irqrestore(&ec->lock, flags); | ||
| 240 | } while (time_before(jiffies, delay)); | 270 | } while (time_before(jiffies, delay)); |
| 241 | pr_debug("controller reset, restart transaction\n"); | 271 | pr_debug("controller reset, restart transaction\n"); |
| 242 | spin_lock_irqsave(&ec->lock, flags); | 272 | spin_lock_irqsave(&ec->lock, flags); |
| @@ -268,23 +298,6 @@ static int acpi_ec_transaction_unlocked(struct acpi_ec *ec, | |||
| 268 | return ret; | 298 | return ret; |
| 269 | } | 299 | } |
| 270 | 300 | ||
| 271 | static int ec_check_ibf0(struct acpi_ec *ec) | ||
| 272 | { | ||
| 273 | u8 status = acpi_ec_read_status(ec); | ||
| 274 | return (status & ACPI_EC_FLAG_IBF) == 0; | ||
| 275 | } | ||
| 276 | |||
| 277 | static int ec_wait_ibf0(struct acpi_ec *ec) | ||
| 278 | { | ||
| 279 | unsigned long delay = jiffies + msecs_to_jiffies(ec_delay); | ||
| 280 | /* interrupt wait manually if GPE mode is not active */ | ||
| 281 | while (time_before(jiffies, delay)) | ||
| 282 | if (wait_event_timeout(ec->wait, ec_check_ibf0(ec), | ||
| 283 | msecs_to_jiffies(1))) | ||
| 284 | return 0; | ||
| 285 | return -ETIME; | ||
| 286 | } | ||
| 287 | |||
| 288 | static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | 301 | static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) |
| 289 | { | 302 | { |
| 290 | int status; | 303 | int status; |
| @@ -305,12 +318,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
| 305 | goto unlock; | 318 | goto unlock; |
| 306 | } | 319 | } |
| 307 | } | 320 | } |
| 308 | if (ec_wait_ibf0(ec)) { | ||
| 309 | pr_err("input buffer is not empty, " | ||
| 310 | "aborting transaction\n"); | ||
| 311 | status = -ETIME; | ||
| 312 | goto end; | ||
| 313 | } | ||
| 314 | pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n", | 321 | pr_debug("transaction start (cmd=0x%02x, addr=0x%02x)\n", |
| 315 | t->command, t->wdata ? t->wdata[0] : 0); | 322 | t->command, t->wdata ? t->wdata[0] : 0); |
| 316 | /* disable GPE during transaction if storm is detected */ | 323 | /* disable GPE during transaction if storm is detected */ |
| @@ -334,7 +341,6 @@ static int acpi_ec_transaction(struct acpi_ec *ec, struct transaction *t) | |||
| 334 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); | 341 | set_bit(EC_FLAGS_GPE_STORM, &ec->flags); |
| 335 | } | 342 | } |
| 336 | pr_debug("transaction end\n"); | 343 | pr_debug("transaction end\n"); |
| 337 | end: | ||
| 338 | if (ec->global_lock) | 344 | if (ec->global_lock) |
| 339 | acpi_release_global_lock(glk); | 345 | acpi_release_global_lock(glk); |
| 340 | unlock: | 346 | unlock: |
| @@ -634,17 +640,14 @@ static int ec_check_sci(struct acpi_ec *ec, u8 state) | |||
| 634 | static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, | 640 | static u32 acpi_ec_gpe_handler(acpi_handle gpe_device, |
| 635 | u32 gpe_number, void *data) | 641 | u32 gpe_number, void *data) |
| 636 | { | 642 | { |
| 643 | unsigned long flags; | ||
| 637 | struct acpi_ec *ec = data; | 644 | struct acpi_ec *ec = data; |
| 638 | u8 status = acpi_ec_read_status(ec); | ||
| 639 | 645 | ||
| 640 | pr_debug("~~~> interrupt, status:0x%02x\n", status); | 646 | spin_lock_irqsave(&ec->lock, flags); |
| 641 | 647 | if (advance_transaction(ec)) | |
| 642 | advance_transaction(ec, status); | ||
| 643 | if (ec_transaction_done(ec) && | ||
| 644 | (acpi_ec_read_status(ec) & ACPI_EC_FLAG_IBF) == 0) { | ||
| 645 | wake_up(&ec->wait); | 648 | wake_up(&ec->wait); |
| 646 | ec_check_sci(ec, acpi_ec_read_status(ec)); | 649 | spin_unlock_irqrestore(&ec->lock, flags); |
| 647 | } | 650 | ec_check_sci(ec, acpi_ec_read_status(ec)); |
| 648 | return ACPI_INTERRUPT_HANDLED | ACPI_REENABLE_GPE; | 651 | return ACPI_INTERRUPT_HANDLED | ACPI_REENABLE_GPE; |
| 649 | } | 652 | } |
| 650 | 653 | ||
| @@ -1066,8 +1069,10 @@ int __init acpi_ec_ecdt_probe(void) | |||
| 1066 | /* fall through */ | 1069 | /* fall through */ |
| 1067 | } | 1070 | } |
| 1068 | 1071 | ||
| 1069 | if (EC_FLAGS_SKIP_DSDT_SCAN) | 1072 | if (EC_FLAGS_SKIP_DSDT_SCAN) { |
| 1073 | kfree(saved_ec); | ||
| 1070 | return -ENODEV; | 1074 | return -ENODEV; |
| 1075 | } | ||
| 1071 | 1076 | ||
| 1072 | /* This workaround is needed only on some broken machines, | 1077 | /* This workaround is needed only on some broken machines, |
| 1073 | * which require early EC, but fail to provide ECDT */ | 1078 | * which require early EC, but fail to provide ECDT */ |
| @@ -1105,6 +1110,7 @@ install: | |||
| 1105 | } | 1110 | } |
| 1106 | error: | 1111 | error: |
| 1107 | kfree(boot_ec); | 1112 | kfree(boot_ec); |
| 1113 | kfree(saved_ec); | ||
| 1108 | boot_ec = NULL; | 1114 | boot_ec = NULL; |
| 1109 | return -ENODEV; | 1115 | return -ENODEV; |
| 1110 | } | 1116 | } |
diff --git a/drivers/acpi/resource.c b/drivers/acpi/resource.c index 0bdacc5e26a3..2ba8f02ced36 100644 --- a/drivers/acpi/resource.c +++ b/drivers/acpi/resource.c | |||
| @@ -77,7 +77,7 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) | |||
| 77 | switch (ares->type) { | 77 | switch (ares->type) { |
| 78 | case ACPI_RESOURCE_TYPE_MEMORY24: | 78 | case ACPI_RESOURCE_TYPE_MEMORY24: |
| 79 | memory24 = &ares->data.memory24; | 79 | memory24 = &ares->data.memory24; |
| 80 | if (!memory24->address_length) | 80 | if (!memory24->minimum && !memory24->address_length) |
| 81 | return false; | 81 | return false; |
| 82 | acpi_dev_get_memresource(res, memory24->minimum, | 82 | acpi_dev_get_memresource(res, memory24->minimum, |
| 83 | memory24->address_length, | 83 | memory24->address_length, |
| @@ -85,7 +85,7 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) | |||
| 85 | break; | 85 | break; |
| 86 | case ACPI_RESOURCE_TYPE_MEMORY32: | 86 | case ACPI_RESOURCE_TYPE_MEMORY32: |
| 87 | memory32 = &ares->data.memory32; | 87 | memory32 = &ares->data.memory32; |
| 88 | if (!memory32->address_length) | 88 | if (!memory32->minimum && !memory32->address_length) |
| 89 | return false; | 89 | return false; |
| 90 | acpi_dev_get_memresource(res, memory32->minimum, | 90 | acpi_dev_get_memresource(res, memory32->minimum, |
| 91 | memory32->address_length, | 91 | memory32->address_length, |
| @@ -93,7 +93,7 @@ bool acpi_dev_resource_memory(struct acpi_resource *ares, struct resource *res) | |||
| 93 | break; | 93 | break; |
| 94 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: | 94 | case ACPI_RESOURCE_TYPE_FIXED_MEMORY32: |
| 95 | fixed_memory32 = &ares->data.fixed_memory32; | 95 | fixed_memory32 = &ares->data.fixed_memory32; |
| 96 | if (!fixed_memory32->address_length) | 96 | if (!fixed_memory32->address && !fixed_memory32->address_length) |
| 97 | return false; | 97 | return false; |
| 98 | acpi_dev_get_memresource(res, fixed_memory32->address, | 98 | acpi_dev_get_memresource(res, fixed_memory32->address, |
| 99 | fixed_memory32->address_length, | 99 | fixed_memory32->address_length, |
| @@ -150,7 +150,7 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) | |||
| 150 | switch (ares->type) { | 150 | switch (ares->type) { |
| 151 | case ACPI_RESOURCE_TYPE_IO: | 151 | case ACPI_RESOURCE_TYPE_IO: |
| 152 | io = &ares->data.io; | 152 | io = &ares->data.io; |
| 153 | if (!io->address_length) | 153 | if (!io->minimum && !io->address_length) |
| 154 | return false; | 154 | return false; |
| 155 | acpi_dev_get_ioresource(res, io->minimum, | 155 | acpi_dev_get_ioresource(res, io->minimum, |
| 156 | io->address_length, | 156 | io->address_length, |
| @@ -158,7 +158,7 @@ bool acpi_dev_resource_io(struct acpi_resource *ares, struct resource *res) | |||
| 158 | break; | 158 | break; |
| 159 | case ACPI_RESOURCE_TYPE_FIXED_IO: | 159 | case ACPI_RESOURCE_TYPE_FIXED_IO: |
| 160 | fixed_io = &ares->data.fixed_io; | 160 | fixed_io = &ares->data.fixed_io; |
| 161 | if (!fixed_io->address_length) | 161 | if (!fixed_io->address && !fixed_io->address_length) |
| 162 | return false; | 162 | return false; |
| 163 | acpi_dev_get_ioresource(res, fixed_io->address, | 163 | acpi_dev_get_ioresource(res, fixed_io->address, |
| 164 | fixed_io->address_length, | 164 | fixed_io->address_length, |
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index fb9ffe9adc64..350d52a8f781 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
| @@ -68,7 +68,7 @@ MODULE_AUTHOR("Bruno Ducrot"); | |||
| 68 | MODULE_DESCRIPTION("ACPI Video Driver"); | 68 | MODULE_DESCRIPTION("ACPI Video Driver"); |
| 69 | MODULE_LICENSE("GPL"); | 69 | MODULE_LICENSE("GPL"); |
| 70 | 70 | ||
| 71 | static bool brightness_switch_enabled; | 71 | static bool brightness_switch_enabled = 1; |
| 72 | module_param(brightness_switch_enabled, bool, 0644); | 72 | module_param(brightness_switch_enabled, bool, 0644); |
| 73 | 73 | ||
| 74 | /* | 74 | /* |
| @@ -241,13 +241,14 @@ static bool acpi_video_use_native_backlight(void) | |||
| 241 | return use_native_backlight_dmi; | 241 | return use_native_backlight_dmi; |
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | static bool acpi_video_verify_backlight_support(void) | 244 | bool acpi_video_verify_backlight_support(void) |
| 245 | { | 245 | { |
| 246 | if (acpi_osi_is_win8() && acpi_video_use_native_backlight() && | 246 | if (acpi_osi_is_win8() && acpi_video_use_native_backlight() && |
| 247 | backlight_device_registered(BACKLIGHT_RAW)) | 247 | backlight_device_registered(BACKLIGHT_RAW)) |
| 248 | return false; | 248 | return false; |
| 249 | return acpi_video_backlight_support(); | 249 | return acpi_video_backlight_support(); |
| 250 | } | 250 | } |
| 251 | EXPORT_SYMBOL_GPL(acpi_video_verify_backlight_support); | ||
| 251 | 252 | ||
| 252 | /* backlight device sysfs support */ | 253 | /* backlight device sysfs support */ |
| 253 | static int acpi_video_get_brightness(struct backlight_device *bd) | 254 | static int acpi_video_get_brightness(struct backlight_device *bd) |
| @@ -563,6 +564,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
| 563 | }, | 564 | }, |
| 564 | }, | 565 | }, |
| 565 | { | 566 | { |
| 567 | .callback = video_set_use_native_backlight, | ||
| 568 | .ident = "Acer TravelMate B113", | ||
| 569 | .matches = { | ||
| 570 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
| 571 | DMI_MATCH(DMI_PRODUCT_NAME, "TravelMate B113"), | ||
| 572 | }, | ||
| 573 | }, | ||
| 574 | { | ||
| 566 | .callback = video_set_use_native_backlight, | 575 | .callback = video_set_use_native_backlight, |
| 567 | .ident = "HP ProBook 4340s", | 576 | .ident = "HP ProBook 4340s", |
| 568 | .matches = { | 577 | .matches = { |
| @@ -572,6 +581,14 @@ static struct dmi_system_id video_dmi_table[] __initdata = { | |||
| 572 | }, | 581 | }, |
| 573 | { | 582 | { |
| 574 | .callback = video_set_use_native_backlight, | 583 | .callback = video_set_use_native_backlight, |
| 584 | .ident = "HP ProBook 4540s", | ||
| 585 | .matches = { | ||
| 586 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | ||
| 587 | DMI_MATCH(DMI_PRODUCT_VERSION, "HP ProBook 4540s"), | ||
| 588 | }, | ||
| 589 | }, | ||
| 590 | { | ||
| 591 | .callback = video_set_use_native_backlight, | ||
| 575 | .ident = "HP ProBook 2013 models", | 592 | .ident = "HP ProBook 2013 models", |
| 576 | .matches = { | 593 | .matches = { |
| 577 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), | 594 | DMI_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), |
diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c index 33e3db548a29..c42feb2bacd0 100644 --- a/drivers/acpi/video_detect.c +++ b/drivers/acpi/video_detect.c | |||
| @@ -166,6 +166,14 @@ static struct dmi_system_id video_detect_dmi_table[] = { | |||
| 166 | DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), | 166 | DMI_MATCH(DMI_PRODUCT_NAME, "UL30A"), |
| 167 | }, | 167 | }, |
| 168 | }, | 168 | }, |
| 169 | { | ||
| 170 | .callback = video_detect_force_vendor, | ||
| 171 | .ident = "Dell Inspiron 5737", | ||
| 172 | .matches = { | ||
| 173 | DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), | ||
| 174 | DMI_MATCH(DMI_PRODUCT_NAME, "Inspiron 5737"), | ||
| 175 | }, | ||
| 176 | }, | ||
| 169 | { }, | 177 | { }, |
| 170 | }; | 178 | }; |
| 171 | 179 | ||
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c index dae5607e1115..4cd52a4541a9 100644 --- a/drivers/ata/ahci.c +++ b/drivers/ata/ahci.c | |||
| @@ -456,6 +456,7 @@ static const struct pci_device_id ahci_pci_tbl[] = { | |||
| 456 | 456 | ||
| 457 | /* Promise */ | 457 | /* Promise */ |
| 458 | { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */ | 458 | { PCI_VDEVICE(PROMISE, 0x3f20), board_ahci }, /* PDC42819 */ |
| 459 | { PCI_VDEVICE(PROMISE, 0x3781), board_ahci }, /* FastTrak TX8660 ahci-mode */ | ||
| 459 | 460 | ||
| 460 | /* Asmedia */ | 461 | /* Asmedia */ |
| 461 | { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */ | 462 | { PCI_VDEVICE(ASMEDIA, 0x0601), board_ahci }, /* ASM1060 */ |
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h index 05882e4445a6..5513296e5e2e 100644 --- a/drivers/ata/ahci.h +++ b/drivers/ata/ahci.h | |||
| @@ -371,7 +371,9 @@ int ahci_do_softreset(struct ata_link *link, unsigned int *class, | |||
| 371 | int pmp, unsigned long deadline, | 371 | int pmp, unsigned long deadline, |
| 372 | int (*check_ready)(struct ata_link *link)); | 372 | int (*check_ready)(struct ata_link *link)); |
| 373 | 373 | ||
| 374 | unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); | ||
| 374 | int ahci_stop_engine(struct ata_port *ap); | 375 | int ahci_stop_engine(struct ata_port *ap); |
| 376 | void ahci_start_fis_rx(struct ata_port *ap); | ||
| 375 | void ahci_start_engine(struct ata_port *ap); | 377 | void ahci_start_engine(struct ata_port *ap); |
| 376 | int ahci_check_ready(struct ata_link *link); | 378 | int ahci_check_ready(struct ata_link *link); |
| 377 | int ahci_kick_engine(struct ata_port *ap); | 379 | int ahci_kick_engine(struct ata_port *ap); |
diff --git a/drivers/ata/ahci_imx.c b/drivers/ata/ahci_imx.c index 3a901520c62b..cac4360f272a 100644 --- a/drivers/ata/ahci_imx.c +++ b/drivers/ata/ahci_imx.c | |||
| @@ -58,6 +58,8 @@ enum ahci_imx_type { | |||
| 58 | struct imx_ahci_priv { | 58 | struct imx_ahci_priv { |
| 59 | struct platform_device *ahci_pdev; | 59 | struct platform_device *ahci_pdev; |
| 60 | enum ahci_imx_type type; | 60 | enum ahci_imx_type type; |
| 61 | struct clk *sata_clk; | ||
| 62 | struct clk *sata_ref_clk; | ||
| 61 | struct clk *ahb_clk; | 63 | struct clk *ahb_clk; |
| 62 | struct regmap *gpr; | 64 | struct regmap *gpr; |
| 63 | bool no_device; | 65 | bool no_device; |
| @@ -224,7 +226,7 @@ static int imx_sata_enable(struct ahci_host_priv *hpriv) | |||
| 224 | return ret; | 226 | return ret; |
| 225 | } | 227 | } |
| 226 | 228 | ||
| 227 | ret = ahci_platform_enable_clks(hpriv); | 229 | ret = clk_prepare_enable(imxpriv->sata_ref_clk); |
| 228 | if (ret < 0) | 230 | if (ret < 0) |
| 229 | goto disable_regulator; | 231 | goto disable_regulator; |
| 230 | 232 | ||
| @@ -291,7 +293,7 @@ static void imx_sata_disable(struct ahci_host_priv *hpriv) | |||
| 291 | !IMX6Q_GPR13_SATA_MPLL_CLK_EN); | 293 | !IMX6Q_GPR13_SATA_MPLL_CLK_EN); |
| 292 | } | 294 | } |
| 293 | 295 | ||
| 294 | ahci_platform_disable_clks(hpriv); | 296 | clk_disable_unprepare(imxpriv->sata_ref_clk); |
| 295 | 297 | ||
| 296 | if (hpriv->target_pwr) | 298 | if (hpriv->target_pwr) |
| 297 | regulator_disable(hpriv->target_pwr); | 299 | regulator_disable(hpriv->target_pwr); |
| @@ -324,6 +326,9 @@ static void ahci_imx_error_handler(struct ata_port *ap) | |||
| 324 | writel(reg_val | IMX_P0PHYCR_TEST_PDDQ, mmio + IMX_P0PHYCR); | 326 | writel(reg_val | IMX_P0PHYCR_TEST_PDDQ, mmio + IMX_P0PHYCR); |
| 325 | imx_sata_disable(hpriv); | 327 | imx_sata_disable(hpriv); |
| 326 | imxpriv->no_device = true; | 328 | imxpriv->no_device = true; |
| 329 | |||
| 330 | dev_info(ap->dev, "no device found, disabling link.\n"); | ||
| 331 | dev_info(ap->dev, "pass " MODULE_PARAM_PREFIX ".hotplug=1 to enable hotplug\n"); | ||
| 327 | } | 332 | } |
| 328 | 333 | ||
| 329 | static int ahci_imx_softreset(struct ata_link *link, unsigned int *class, | 334 | static int ahci_imx_softreset(struct ata_link *link, unsigned int *class, |
| @@ -385,6 +390,19 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
| 385 | imxpriv->no_device = false; | 390 | imxpriv->no_device = false; |
| 386 | imxpriv->first_time = true; | 391 | imxpriv->first_time = true; |
| 387 | imxpriv->type = (enum ahci_imx_type)of_id->data; | 392 | imxpriv->type = (enum ahci_imx_type)of_id->data; |
| 393 | |||
| 394 | imxpriv->sata_clk = devm_clk_get(dev, "sata"); | ||
| 395 | if (IS_ERR(imxpriv->sata_clk)) { | ||
| 396 | dev_err(dev, "can't get sata clock.\n"); | ||
| 397 | return PTR_ERR(imxpriv->sata_clk); | ||
| 398 | } | ||
| 399 | |||
| 400 | imxpriv->sata_ref_clk = devm_clk_get(dev, "sata_ref"); | ||
| 401 | if (IS_ERR(imxpriv->sata_ref_clk)) { | ||
| 402 | dev_err(dev, "can't get sata_ref clock.\n"); | ||
| 403 | return PTR_ERR(imxpriv->sata_ref_clk); | ||
| 404 | } | ||
| 405 | |||
| 388 | imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); | 406 | imxpriv->ahb_clk = devm_clk_get(dev, "ahb"); |
| 389 | if (IS_ERR(imxpriv->ahb_clk)) { | 407 | if (IS_ERR(imxpriv->ahb_clk)) { |
| 390 | dev_err(dev, "can't get ahb clock.\n"); | 408 | dev_err(dev, "can't get ahb clock.\n"); |
| @@ -407,10 +425,14 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
| 407 | 425 | ||
| 408 | hpriv->plat_data = imxpriv; | 426 | hpriv->plat_data = imxpriv; |
| 409 | 427 | ||
| 410 | ret = imx_sata_enable(hpriv); | 428 | ret = clk_prepare_enable(imxpriv->sata_clk); |
| 411 | if (ret) | 429 | if (ret) |
| 412 | return ret; | 430 | return ret; |
| 413 | 431 | ||
| 432 | ret = imx_sata_enable(hpriv); | ||
| 433 | if (ret) | ||
| 434 | goto disable_clk; | ||
| 435 | |||
| 414 | /* | 436 | /* |
| 415 | * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, | 437 | * Configure the HWINIT bits of the HOST_CAP and HOST_PORTS_IMPL, |
| 416 | * and IP vendor specific register IMX_TIMER1MS. | 438 | * and IP vendor specific register IMX_TIMER1MS. |
| @@ -435,16 +457,24 @@ static int imx_ahci_probe(struct platform_device *pdev) | |||
| 435 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, | 457 | ret = ahci_platform_init_host(pdev, hpriv, &ahci_imx_port_info, |
| 436 | 0, 0, 0); | 458 | 0, 0, 0); |
| 437 | if (ret) | 459 | if (ret) |
| 438 | imx_sata_disable(hpriv); | 460 | goto disable_sata; |
| 439 | 461 | ||
| 462 | return 0; | ||
| 463 | |||
| 464 | disable_sata: | ||
| 465 | imx_sata_disable(hpriv); | ||
| 466 | disable_clk: | ||
| 467 | clk_disable_unprepare(imxpriv->sata_clk); | ||
| 440 | return ret; | 468 | return ret; |
| 441 | } | 469 | } |
| 442 | 470 | ||
| 443 | static void ahci_imx_host_stop(struct ata_host *host) | 471 | static void ahci_imx_host_stop(struct ata_host *host) |
| 444 | { | 472 | { |
| 445 | struct ahci_host_priv *hpriv = host->private_data; | 473 | struct ahci_host_priv *hpriv = host->private_data; |
| 474 | struct imx_ahci_priv *imxpriv = hpriv->plat_data; | ||
| 446 | 475 | ||
| 447 | imx_sata_disable(hpriv); | 476 | imx_sata_disable(hpriv); |
| 477 | clk_disable_unprepare(imxpriv->sata_clk); | ||
| 448 | } | 478 | } |
| 449 | 479 | ||
| 450 | #ifdef CONFIG_PM_SLEEP | 480 | #ifdef CONFIG_PM_SLEEP |
diff --git a/drivers/ata/ahci_platform.c b/drivers/ata/ahci_platform.c index ebe505c17763..b10d81ddb528 100644 --- a/drivers/ata/ahci_platform.c +++ b/drivers/ata/ahci_platform.c | |||
| @@ -58,7 +58,7 @@ static int ahci_probe(struct platform_device *pdev) | |||
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) | 60 | if (of_device_is_compatible(dev->of_node, "hisilicon,hisi-ahci")) |
| 61 | hflags |= AHCI_HFLAG_NO_FBS; | 61 | hflags |= AHCI_HFLAG_NO_FBS | AHCI_HFLAG_NO_NCQ; |
| 62 | 62 | ||
| 63 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info, | 63 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_port_info, |
| 64 | hflags, 0, 0); | 64 | hflags, 0, 0); |
diff --git a/drivers/ata/ahci_xgene.c b/drivers/ata/ahci_xgene.c index 042a9bb45c86..ee3a3659bd9e 100644 --- a/drivers/ata/ahci_xgene.c +++ b/drivers/ata/ahci_xgene.c | |||
| @@ -78,6 +78,7 @@ | |||
| 78 | struct xgene_ahci_context { | 78 | struct xgene_ahci_context { |
| 79 | struct ahci_host_priv *hpriv; | 79 | struct ahci_host_priv *hpriv; |
| 80 | struct device *dev; | 80 | struct device *dev; |
| 81 | u8 last_cmd[MAX_AHCI_CHN_PERCTR]; /* tracking the last command issued*/ | ||
| 81 | void __iomem *csr_core; /* Core CSR address of IP */ | 82 | void __iomem *csr_core; /* Core CSR address of IP */ |
| 82 | void __iomem *csr_diag; /* Diag CSR address of IP */ | 83 | void __iomem *csr_diag; /* Diag CSR address of IP */ |
| 83 | void __iomem *csr_axi; /* AXI CSR address of IP */ | 84 | void __iomem *csr_axi; /* AXI CSR address of IP */ |
| @@ -98,20 +99,62 @@ static int xgene_ahci_init_memram(struct xgene_ahci_context *ctx) | |||
| 98 | } | 99 | } |
| 99 | 100 | ||
| 100 | /** | 101 | /** |
| 102 | * xgene_ahci_restart_engine - Restart the dma engine. | ||
| 103 | * @ap : ATA port of interest | ||
| 104 | * | ||
| 105 | * Restarts the dma engine inside the controller. | ||
| 106 | */ | ||
| 107 | static int xgene_ahci_restart_engine(struct ata_port *ap) | ||
| 108 | { | ||
| 109 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
| 110 | |||
| 111 | ahci_stop_engine(ap); | ||
| 112 | ahci_start_fis_rx(ap); | ||
| 113 | hpriv->start_engine(ap); | ||
| 114 | |||
| 115 | return 0; | ||
| 116 | } | ||
| 117 | |||
| 118 | /** | ||
| 119 | * xgene_ahci_qc_issue - Issue commands to the device | ||
| 120 | * @qc: Command to issue | ||
| 121 | * | ||
| 122 | * Due to Hardware errata for IDENTIFY DEVICE command, the controller cannot | ||
| 123 | * clear the BSY bit after receiving the PIO setup FIS. This results in the dma | ||
| 124 | * state machine goes into the CMFatalErrorUpdate state and locks up. By | ||
| 125 | * restarting the dma engine, it removes the controller out of lock up state. | ||
| 126 | */ | ||
| 127 | static unsigned int xgene_ahci_qc_issue(struct ata_queued_cmd *qc) | ||
| 128 | { | ||
| 129 | struct ata_port *ap = qc->ap; | ||
| 130 | struct ahci_host_priv *hpriv = ap->host->private_data; | ||
| 131 | struct xgene_ahci_context *ctx = hpriv->plat_data; | ||
| 132 | int rc = 0; | ||
| 133 | |||
| 134 | if (unlikely(ctx->last_cmd[ap->port_no] == ATA_CMD_ID_ATA)) | ||
| 135 | xgene_ahci_restart_engine(ap); | ||
| 136 | |||
| 137 | rc = ahci_qc_issue(qc); | ||
| 138 | |||
| 139 | /* Save the last command issued */ | ||
| 140 | ctx->last_cmd[ap->port_no] = qc->tf.command; | ||
| 141 | |||
| 142 | return rc; | ||
| 143 | } | ||
| 144 | |||
| 145 | /** | ||
| 101 | * xgene_ahci_read_id - Read ID data from the specified device | 146 | * xgene_ahci_read_id - Read ID data from the specified device |
| 102 | * @dev: device | 147 | * @dev: device |
| 103 | * @tf: proposed taskfile | 148 | * @tf: proposed taskfile |
| 104 | * @id: data buffer | 149 | * @id: data buffer |
| 105 | * | 150 | * |
| 106 | * This custom read ID function is required due to the fact that the HW | 151 | * This custom read ID function is required due to the fact that the HW |
| 107 | * does not support DEVSLP and the controller state machine may get stuck | 152 | * does not support DEVSLP. |
| 108 | * after processing the ID query command. | ||
| 109 | */ | 153 | */ |
| 110 | static unsigned int xgene_ahci_read_id(struct ata_device *dev, | 154 | static unsigned int xgene_ahci_read_id(struct ata_device *dev, |
| 111 | struct ata_taskfile *tf, u16 *id) | 155 | struct ata_taskfile *tf, u16 *id) |
| 112 | { | 156 | { |
| 113 | u32 err_mask; | 157 | u32 err_mask; |
| 114 | void __iomem *port_mmio = ahci_port_base(dev->link->ap); | ||
| 115 | 158 | ||
| 116 | err_mask = ata_do_dev_read_id(dev, tf, id); | 159 | err_mask = ata_do_dev_read_id(dev, tf, id); |
| 117 | if (err_mask) | 160 | if (err_mask) |
| @@ -133,16 +176,6 @@ static unsigned int xgene_ahci_read_id(struct ata_device *dev, | |||
| 133 | */ | 176 | */ |
| 134 | id[ATA_ID_FEATURE_SUPP] &= ~(1 << 8); | 177 | id[ATA_ID_FEATURE_SUPP] &= ~(1 << 8); |
| 135 | 178 | ||
| 136 | /* | ||
| 137 | * Due to HW errata, restart the port if no other command active. | ||
| 138 | * Otherwise the controller may get stuck. | ||
| 139 | */ | ||
| 140 | if (!readl(port_mmio + PORT_CMD_ISSUE)) { | ||
| 141 | writel(PORT_CMD_FIS_RX, port_mmio + PORT_CMD); | ||
| 142 | readl(port_mmio + PORT_CMD); /* Force a barrier */ | ||
| 143 | writel(PORT_CMD_FIS_RX | PORT_CMD_START, port_mmio + PORT_CMD); | ||
| 144 | readl(port_mmio + PORT_CMD); /* Force a barrier */ | ||
| 145 | } | ||
| 146 | return 0; | 179 | return 0; |
| 147 | } | 180 | } |
| 148 | 181 | ||
| @@ -300,6 +333,7 @@ static struct ata_port_operations xgene_ahci_ops = { | |||
| 300 | .host_stop = xgene_ahci_host_stop, | 333 | .host_stop = xgene_ahci_host_stop, |
| 301 | .hardreset = xgene_ahci_hardreset, | 334 | .hardreset = xgene_ahci_hardreset, |
| 302 | .read_id = xgene_ahci_read_id, | 335 | .read_id = xgene_ahci_read_id, |
| 336 | .qc_issue = xgene_ahci_qc_issue, | ||
| 303 | }; | 337 | }; |
| 304 | 338 | ||
| 305 | static const struct ata_port_info xgene_ahci_port_info = { | 339 | static const struct ata_port_info xgene_ahci_port_info = { |
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index 40ea583d3610..d72ce0470309 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c | |||
| @@ -68,7 +68,6 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state, | |||
| 68 | 68 | ||
| 69 | static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); | 69 | static int ahci_scr_read(struct ata_link *link, unsigned int sc_reg, u32 *val); |
| 70 | static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); | 70 | static int ahci_scr_write(struct ata_link *link, unsigned int sc_reg, u32 val); |
| 71 | static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc); | ||
| 72 | static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc); | 71 | static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc); |
| 73 | static int ahci_port_start(struct ata_port *ap); | 72 | static int ahci_port_start(struct ata_port *ap); |
| 74 | static void ahci_port_stop(struct ata_port *ap); | 73 | static void ahci_port_stop(struct ata_port *ap); |
| @@ -620,7 +619,7 @@ int ahci_stop_engine(struct ata_port *ap) | |||
| 620 | } | 619 | } |
| 621 | EXPORT_SYMBOL_GPL(ahci_stop_engine); | 620 | EXPORT_SYMBOL_GPL(ahci_stop_engine); |
| 622 | 621 | ||
| 623 | static void ahci_start_fis_rx(struct ata_port *ap) | 622 | void ahci_start_fis_rx(struct ata_port *ap) |
| 624 | { | 623 | { |
| 625 | void __iomem *port_mmio = ahci_port_base(ap); | 624 | void __iomem *port_mmio = ahci_port_base(ap); |
| 626 | struct ahci_host_priv *hpriv = ap->host->private_data; | 625 | struct ahci_host_priv *hpriv = ap->host->private_data; |
| @@ -646,6 +645,7 @@ static void ahci_start_fis_rx(struct ata_port *ap) | |||
| 646 | /* flush */ | 645 | /* flush */ |
| 647 | readl(port_mmio + PORT_CMD); | 646 | readl(port_mmio + PORT_CMD); |
| 648 | } | 647 | } |
| 648 | EXPORT_SYMBOL_GPL(ahci_start_fis_rx); | ||
| 649 | 649 | ||
| 650 | static int ahci_stop_fis_rx(struct ata_port *ap) | 650 | static int ahci_stop_fis_rx(struct ata_port *ap) |
| 651 | { | 651 | { |
| @@ -1945,7 +1945,7 @@ irqreturn_t ahci_interrupt(int irq, void *dev_instance) | |||
| 1945 | } | 1945 | } |
| 1946 | EXPORT_SYMBOL_GPL(ahci_interrupt); | 1946 | EXPORT_SYMBOL_GPL(ahci_interrupt); |
| 1947 | 1947 | ||
| 1948 | static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc) | 1948 | unsigned int ahci_qc_issue(struct ata_queued_cmd *qc) |
| 1949 | { | 1949 | { |
| 1950 | struct ata_port *ap = qc->ap; | 1950 | struct ata_port *ap = qc->ap; |
| 1951 | void __iomem *port_mmio = ahci_port_base(ap); | 1951 | void __iomem *port_mmio = ahci_port_base(ap); |
| @@ -1974,6 +1974,7 @@ static unsigned int ahci_qc_issue(struct ata_queued_cmd *qc) | |||
| 1974 | 1974 | ||
| 1975 | return 0; | 1975 | return 0; |
| 1976 | } | 1976 | } |
| 1977 | EXPORT_SYMBOL_GPL(ahci_qc_issue); | ||
| 1977 | 1978 | ||
| 1978 | static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc) | 1979 | static bool ahci_qc_fill_rtf(struct ata_queued_cmd *qc) |
| 1979 | { | 1980 | { |
diff --git a/drivers/ata/libahci_platform.c b/drivers/ata/libahci_platform.c index 3a5b4ed25a4f..b0077589f065 100644 --- a/drivers/ata/libahci_platform.c +++ b/drivers/ata/libahci_platform.c | |||
| @@ -250,8 +250,13 @@ struct ahci_host_priv *ahci_platform_get_resources(struct platform_device *pdev) | |||
| 250 | if (IS_ERR(hpriv->phy)) { | 250 | if (IS_ERR(hpriv->phy)) { |
| 251 | rc = PTR_ERR(hpriv->phy); | 251 | rc = PTR_ERR(hpriv->phy); |
| 252 | switch (rc) { | 252 | switch (rc) { |
| 253 | case -ENODEV: | ||
| 254 | case -ENOSYS: | 253 | case -ENOSYS: |
| 254 | /* No PHY support. Check if PHY is required. */ | ||
| 255 | if (of_find_property(dev->of_node, "phys", NULL)) { | ||
| 256 | dev_err(dev, "couldn't get sata-phy: ENOSYS\n"); | ||
| 257 | goto err_out; | ||
| 258 | } | ||
| 259 | case -ENODEV: | ||
| 255 | /* continue normally */ | 260 | /* continue normally */ |
| 256 | hpriv->phy = NULL; | 261 | hpriv->phy = NULL; |
| 257 | break; | 262 | break; |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 18d97d5c7d90..677c0c1b03bd 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
| @@ -4787,6 +4787,10 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) | |||
| 4787 | * ata_qc_new - Request an available ATA command, for queueing | 4787 | * ata_qc_new - Request an available ATA command, for queueing |
| 4788 | * @ap: target port | 4788 | * @ap: target port |
| 4789 | * | 4789 | * |
| 4790 | * Some ATA host controllers may implement a queue depth which is less | ||
| 4791 | * than ATA_MAX_QUEUE. So we shouldn't allocate a tag which is beyond | ||
| 4792 | * the hardware limitation. | ||
| 4793 | * | ||
| 4790 | * LOCKING: | 4794 | * LOCKING: |
| 4791 | * None. | 4795 | * None. |
| 4792 | */ | 4796 | */ |
| @@ -4794,14 +4798,15 @@ void swap_buf_le16(u16 *buf, unsigned int buf_words) | |||
| 4794 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) | 4798 | static struct ata_queued_cmd *ata_qc_new(struct ata_port *ap) |
| 4795 | { | 4799 | { |
| 4796 | struct ata_queued_cmd *qc = NULL; | 4800 | struct ata_queued_cmd *qc = NULL; |
| 4801 | unsigned int max_queue = ap->host->n_tags; | ||
| 4797 | unsigned int i, tag; | 4802 | unsigned int i, tag; |
| 4798 | 4803 | ||
| 4799 | /* no command while frozen */ | 4804 | /* no command while frozen */ |
| 4800 | if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) | 4805 | if (unlikely(ap->pflags & ATA_PFLAG_FROZEN)) |
| 4801 | return NULL; | 4806 | return NULL; |
| 4802 | 4807 | ||
| 4803 | for (i = 0; i < ATA_MAX_QUEUE; i++) { | 4808 | for (i = 0, tag = ap->last_tag + 1; i < max_queue; i++, tag++) { |
| 4804 | tag = (i + ap->last_tag + 1) % ATA_MAX_QUEUE; | 4809 | tag = tag < max_queue ? tag : 0; |
| 4805 | 4810 | ||
| 4806 | /* the last tag is reserved for internal command. */ | 4811 | /* the last tag is reserved for internal command. */ |
| 4807 | if (tag == ATA_TAG_INTERNAL) | 4812 | if (tag == ATA_TAG_INTERNAL) |
| @@ -6088,6 +6093,7 @@ void ata_host_init(struct ata_host *host, struct device *dev, | |||
| 6088 | { | 6093 | { |
| 6089 | spin_lock_init(&host->lock); | 6094 | spin_lock_init(&host->lock); |
| 6090 | mutex_init(&host->eh_mutex); | 6095 | mutex_init(&host->eh_mutex); |
| 6096 | host->n_tags = ATA_MAX_QUEUE - 1; | ||
| 6091 | host->dev = dev; | 6097 | host->dev = dev; |
| 6092 | host->ops = ops; | 6098 | host->ops = ops; |
| 6093 | } | 6099 | } |
| @@ -6169,6 +6175,8 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht) | |||
| 6169 | { | 6175 | { |
| 6170 | int i, rc; | 6176 | int i, rc; |
| 6171 | 6177 | ||
| 6178 | host->n_tags = clamp(sht->can_queue, 1, ATA_MAX_QUEUE - 1); | ||
| 6179 | |||
| 6172 | /* host must have been started */ | 6180 | /* host must have been started */ |
| 6173 | if (!(host->flags & ATA_HOST_STARTED)) { | 6181 | if (!(host->flags & ATA_HOST_STARTED)) { |
| 6174 | dev_err(host->dev, "BUG: trying to register unstarted host\n"); | 6182 | dev_err(host->dev, "BUG: trying to register unstarted host\n"); |
diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c index 6760fc4e85b8..dad83df555c4 100644 --- a/drivers/ata/libata-eh.c +++ b/drivers/ata/libata-eh.c | |||
| @@ -1811,7 +1811,7 @@ static unsigned int ata_eh_analyze_tf(struct ata_queued_cmd *qc, | |||
| 1811 | case ATA_DEV_ATA: | 1811 | case ATA_DEV_ATA: |
| 1812 | if (err & ATA_ICRC) | 1812 | if (err & ATA_ICRC) |
| 1813 | qc->err_mask |= AC_ERR_ATA_BUS; | 1813 | qc->err_mask |= AC_ERR_ATA_BUS; |
| 1814 | if (err & ATA_UNC) | 1814 | if (err & (ATA_UNC | ATA_AMNF)) |
| 1815 | qc->err_mask |= AC_ERR_MEDIA; | 1815 | qc->err_mask |= AC_ERR_MEDIA; |
| 1816 | if (err & ATA_IDNF) | 1816 | if (err & ATA_IDNF) |
| 1817 | qc->err_mask |= AC_ERR_INVALID; | 1817 | qc->err_mask |= AC_ERR_INVALID; |
| @@ -2556,11 +2556,12 @@ static void ata_eh_link_report(struct ata_link *link) | |||
| 2556 | } | 2556 | } |
| 2557 | 2557 | ||
| 2558 | if (cmd->command != ATA_CMD_PACKET && | 2558 | if (cmd->command != ATA_CMD_PACKET && |
| 2559 | (res->feature & (ATA_ICRC | ATA_UNC | ATA_IDNF | | 2559 | (res->feature & (ATA_ICRC | ATA_UNC | ATA_AMNF | |
| 2560 | ATA_ABORTED))) | 2560 | ATA_IDNF | ATA_ABORTED))) |
| 2561 | ata_dev_err(qc->dev, "error: { %s%s%s%s}\n", | 2561 | ata_dev_err(qc->dev, "error: { %s%s%s%s%s}\n", |
| 2562 | res->feature & ATA_ICRC ? "ICRC " : "", | 2562 | res->feature & ATA_ICRC ? "ICRC " : "", |
| 2563 | res->feature & ATA_UNC ? "UNC " : "", | 2563 | res->feature & ATA_UNC ? "UNC " : "", |
| 2564 | res->feature & ATA_AMNF ? "AMNF " : "", | ||
| 2564 | res->feature & ATA_IDNF ? "IDNF " : "", | 2565 | res->feature & ATA_IDNF ? "IDNF " : "", |
| 2565 | res->feature & ATA_ABORTED ? "ABRT " : ""); | 2566 | res->feature & ATA_ABORTED ? "ABRT " : ""); |
| 2566 | #endif | 2567 | #endif |
diff --git a/drivers/ata/pata_ep93xx.c b/drivers/ata/pata_ep93xx.c index 6ad5c072ce34..4d37c5415fc7 100644 --- a/drivers/ata/pata_ep93xx.c +++ b/drivers/ata/pata_ep93xx.c | |||
| @@ -915,7 +915,7 @@ static int ep93xx_pata_probe(struct platform_device *pdev) | |||
| 915 | struct ep93xx_pata_data *drv_data; | 915 | struct ep93xx_pata_data *drv_data; |
| 916 | struct ata_host *host; | 916 | struct ata_host *host; |
| 917 | struct ata_port *ap; | 917 | struct ata_port *ap; |
| 918 | unsigned int irq; | 918 | int irq; |
| 919 | struct resource *mem_res; | 919 | struct resource *mem_res; |
| 920 | void __iomem *ide_base; | 920 | void __iomem *ide_base; |
| 921 | int err; | 921 | int err; |
diff --git a/drivers/base/platform.c b/drivers/base/platform.c index 9e9227e1762d..eee48c49f5de 100644 --- a/drivers/base/platform.c +++ b/drivers/base/platform.c | |||
| @@ -89,8 +89,13 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) | |||
| 89 | return dev->archdata.irqs[num]; | 89 | return dev->archdata.irqs[num]; |
| 90 | #else | 90 | #else |
| 91 | struct resource *r; | 91 | struct resource *r; |
| 92 | if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) | 92 | if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) { |
| 93 | return of_irq_get(dev->dev.of_node, num); | 93 | int ret; |
| 94 | |||
| 95 | ret = of_irq_get(dev->dev.of_node, num); | ||
| 96 | if (ret >= 0 || ret == -EPROBE_DEFER) | ||
| 97 | return ret; | ||
| 98 | } | ||
| 94 | 99 | ||
| 95 | r = platform_get_resource(dev, IORESOURCE_IRQ, num); | 100 | r = platform_get_resource(dev, IORESOURCE_IRQ, num); |
| 96 | 101 | ||
| @@ -133,8 +138,13 @@ int platform_get_irq_byname(struct platform_device *dev, const char *name) | |||
| 133 | { | 138 | { |
| 134 | struct resource *r; | 139 | struct resource *r; |
| 135 | 140 | ||
| 136 | if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) | 141 | if (IS_ENABLED(CONFIG_OF_IRQ) && dev->dev.of_node) { |
| 137 | return of_irq_get_byname(dev->dev.of_node, name); | 142 | int ret; |
| 143 | |||
| 144 | ret = of_irq_get_byname(dev->dev.of_node, name); | ||
| 145 | if (ret >= 0 || ret == -EPROBE_DEFER) | ||
| 146 | return ret; | ||
| 147 | } | ||
| 138 | 148 | ||
| 139 | r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); | 149 | r = platform_get_resource_byname(dev, IORESOURCE_IRQ, name); |
| 140 | return r ? r->start : -ENXIO; | 150 | return r ? r->start : -ENXIO; |
diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c index 1b35c45c92b7..3f2e16738080 100644 --- a/drivers/block/drbd/drbd_nl.c +++ b/drivers/block/drbd/drbd_nl.c | |||
| @@ -544,6 +544,12 @@ void conn_try_outdate_peer_async(struct drbd_connection *connection) | |||
| 544 | struct task_struct *opa; | 544 | struct task_struct *opa; |
| 545 | 545 | ||
| 546 | kref_get(&connection->kref); | 546 | kref_get(&connection->kref); |
| 547 | /* We may just have force_sig()'ed this thread | ||
| 548 | * to get it out of some blocking network function. | ||
| 549 | * Clear signals; otherwise kthread_run(), which internally uses | ||
| 550 | * wait_on_completion_killable(), will mistake our pending signal | ||
| 551 | * for a new fatal signal and fail. */ | ||
| 552 | flush_signals(current); | ||
| 547 | opa = kthread_run(_try_outdate_peer_async, connection, "drbd_async_h"); | 553 | opa = kthread_run(_try_outdate_peer_async, connection, "drbd_async_h"); |
| 548 | if (IS_ERR(opa)) { | 554 | if (IS_ERR(opa)) { |
| 549 | drbd_err(connection, "out of mem, failed to invoke fence-peer helper\n"); | 555 | drbd_err(connection, "out of mem, failed to invoke fence-peer helper\n"); |
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index 089e72cd37be..36e54be402df 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
| @@ -622,11 +622,18 @@ static void zram_reset_device(struct zram *zram, bool reset_capacity) | |||
| 622 | memset(&zram->stats, 0, sizeof(zram->stats)); | 622 | memset(&zram->stats, 0, sizeof(zram->stats)); |
| 623 | 623 | ||
| 624 | zram->disksize = 0; | 624 | zram->disksize = 0; |
| 625 | if (reset_capacity) { | 625 | if (reset_capacity) |
| 626 | set_capacity(zram->disk, 0); | 626 | set_capacity(zram->disk, 0); |
| 627 | revalidate_disk(zram->disk); | 627 | |
| 628 | } | ||
| 629 | up_write(&zram->init_lock); | 628 | up_write(&zram->init_lock); |
| 629 | |||
| 630 | /* | ||
| 631 | * Revalidate disk out of the init_lock to avoid lockdep splat. | ||
| 632 | * It's okay because disk's capacity is protected by init_lock | ||
| 633 | * so that revalidate_disk always sees up-to-date capacity. | ||
| 634 | */ | ||
| 635 | if (reset_capacity) | ||
| 636 | revalidate_disk(zram->disk); | ||
| 630 | } | 637 | } |
| 631 | 638 | ||
| 632 | static ssize_t disksize_store(struct device *dev, | 639 | static ssize_t disksize_store(struct device *dev, |
| @@ -666,8 +673,15 @@ static ssize_t disksize_store(struct device *dev, | |||
| 666 | zram->comp = comp; | 673 | zram->comp = comp; |
| 667 | zram->disksize = disksize; | 674 | zram->disksize = disksize; |
| 668 | set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); | 675 | set_capacity(zram->disk, zram->disksize >> SECTOR_SHIFT); |
| 669 | revalidate_disk(zram->disk); | ||
| 670 | up_write(&zram->init_lock); | 676 | up_write(&zram->init_lock); |
| 677 | |||
| 678 | /* | ||
| 679 | * Revalidate disk out of the init_lock to avoid lockdep splat. | ||
| 680 | * It's okay because disk's capacity is protected by init_lock | ||
| 681 | * so that revalidate_disk always sees up-to-date capacity. | ||
| 682 | */ | ||
| 683 | revalidate_disk(zram->disk); | ||
| 684 | |||
| 671 | return len; | 685 | return len; |
| 672 | 686 | ||
| 673 | out_destroy_comp: | 687 | out_destroy_comp: |
diff --git a/drivers/bluetooth/ath3k.c b/drivers/bluetooth/ath3k.c index f98380648cb3..f50dffc0374f 100644 --- a/drivers/bluetooth/ath3k.c +++ b/drivers/bluetooth/ath3k.c | |||
| @@ -90,7 +90,6 @@ static const struct usb_device_id ath3k_table[] = { | |||
| 90 | { USB_DEVICE(0x0b05, 0x17d0) }, | 90 | { USB_DEVICE(0x0b05, 0x17d0) }, |
| 91 | { USB_DEVICE(0x0CF3, 0x0036) }, | 91 | { USB_DEVICE(0x0CF3, 0x0036) }, |
| 92 | { USB_DEVICE(0x0CF3, 0x3004) }, | 92 | { USB_DEVICE(0x0CF3, 0x3004) }, |
| 93 | { USB_DEVICE(0x0CF3, 0x3005) }, | ||
| 94 | { USB_DEVICE(0x0CF3, 0x3008) }, | 93 | { USB_DEVICE(0x0CF3, 0x3008) }, |
| 95 | { USB_DEVICE(0x0CF3, 0x311D) }, | 94 | { USB_DEVICE(0x0CF3, 0x311D) }, |
| 96 | { USB_DEVICE(0x0CF3, 0x311E) }, | 95 | { USB_DEVICE(0x0CF3, 0x311E) }, |
| @@ -140,7 +139,6 @@ static const struct usb_device_id ath3k_blist_tbl[] = { | |||
| 140 | { USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 }, | 139 | { USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 }, |
| 141 | { USB_DEVICE(0x0CF3, 0x0036), .driver_info = BTUSB_ATH3012 }, | 140 | { USB_DEVICE(0x0CF3, 0x0036), .driver_info = BTUSB_ATH3012 }, |
| 142 | { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, | 141 | { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, |
| 143 | { USB_DEVICE(0x0cf3, 0x3005), .driver_info = BTUSB_ATH3012 }, | ||
| 144 | { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 }, | 142 | { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 }, |
| 145 | { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 }, | 143 | { USB_DEVICE(0x0cf3, 0x311D), .driver_info = BTUSB_ATH3012 }, |
| 146 | { USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 }, | 144 | { USB_DEVICE(0x0cf3, 0x311E), .driver_info = BTUSB_ATH3012 }, |
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c index a1c80b0c7663..6250fc2fb93a 100644 --- a/drivers/bluetooth/btusb.c +++ b/drivers/bluetooth/btusb.c | |||
| @@ -162,7 +162,6 @@ static const struct usb_device_id blacklist_table[] = { | |||
| 162 | { USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 }, | 162 | { USB_DEVICE(0x0b05, 0x17d0), .driver_info = BTUSB_ATH3012 }, |
| 163 | { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 }, | 163 | { USB_DEVICE(0x0cf3, 0x0036), .driver_info = BTUSB_ATH3012 }, |
| 164 | { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, | 164 | { USB_DEVICE(0x0cf3, 0x3004), .driver_info = BTUSB_ATH3012 }, |
| 165 | { USB_DEVICE(0x0cf3, 0x3005), .driver_info = BTUSB_ATH3012 }, | ||
| 166 | { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 }, | 165 | { USB_DEVICE(0x0cf3, 0x3008), .driver_info = BTUSB_ATH3012 }, |
| 167 | { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 }, | 166 | { USB_DEVICE(0x0cf3, 0x311d), .driver_info = BTUSB_ATH3012 }, |
| 168 | { USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 }, | 167 | { USB_DEVICE(0x0cf3, 0x311e), .driver_info = BTUSB_ATH3012 }, |
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c index 04680ead9275..fede8ca7147c 100644 --- a/drivers/bluetooth/hci_h5.c +++ b/drivers/bluetooth/hci_h5.c | |||
| @@ -406,6 +406,7 @@ static int h5_rx_3wire_hdr(struct hci_uart *hu, unsigned char c) | |||
| 406 | H5_HDR_PKT_TYPE(hdr) != HCI_3WIRE_LINK_PKT) { | 406 | H5_HDR_PKT_TYPE(hdr) != HCI_3WIRE_LINK_PKT) { |
| 407 | BT_ERR("Non-link packet received in non-active state"); | 407 | BT_ERR("Non-link packet received in non-active state"); |
| 408 | h5_reset_rx(h5); | 408 | h5_reset_rx(h5); |
| 409 | return 0; | ||
| 409 | } | 410 | } |
| 410 | 411 | ||
| 411 | h5->rx_func = h5_rx_payload; | 412 | h5->rx_func = h5_rx_payload; |
diff --git a/drivers/char/hw_random/core.c b/drivers/char/hw_random/core.c index 334601cc81cf..c4419ea1ab07 100644 --- a/drivers/char/hw_random/core.c +++ b/drivers/char/hw_random/core.c | |||
| @@ -55,16 +55,41 @@ static DEFINE_MUTEX(rng_mutex); | |||
| 55 | static int data_avail; | 55 | static int data_avail; |
| 56 | static u8 *rng_buffer; | 56 | static u8 *rng_buffer; |
| 57 | 57 | ||
| 58 | static inline int rng_get_data(struct hwrng *rng, u8 *buffer, size_t size, | ||
| 59 | int wait); | ||
| 60 | |||
| 58 | static size_t rng_buffer_size(void) | 61 | static size_t rng_buffer_size(void) |
| 59 | { | 62 | { |
| 60 | return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES; | 63 | return SMP_CACHE_BYTES < 32 ? 32 : SMP_CACHE_BYTES; |
| 61 | } | 64 | } |
| 62 | 65 | ||
| 66 | static void add_early_randomness(struct hwrng *rng) | ||
| 67 | { | ||
| 68 | unsigned char bytes[16]; | ||
| 69 | int bytes_read; | ||
| 70 | |||
| 71 | /* | ||
| 72 | * Currently only virtio-rng cannot return data during device | ||
| 73 | * probe, and that's handled in virtio-rng.c itself. If there | ||
| 74 | * are more such devices, this call to rng_get_data can be | ||
| 75 | * made conditional here instead of doing it per-device. | ||
| 76 | */ | ||
| 77 | bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1); | ||
| 78 | if (bytes_read > 0) | ||
| 79 | add_device_randomness(bytes, bytes_read); | ||
| 80 | } | ||
| 81 | |||
| 63 | static inline int hwrng_init(struct hwrng *rng) | 82 | static inline int hwrng_init(struct hwrng *rng) |
| 64 | { | 83 | { |
| 65 | if (!rng->init) | 84 | if (rng->init) { |
| 66 | return 0; | 85 | int ret; |
| 67 | return rng->init(rng); | 86 | |
| 87 | ret = rng->init(rng); | ||
| 88 | if (ret) | ||
| 89 | return ret; | ||
| 90 | } | ||
| 91 | add_early_randomness(rng); | ||
| 92 | return 0; | ||
| 68 | } | 93 | } |
| 69 | 94 | ||
| 70 | static inline void hwrng_cleanup(struct hwrng *rng) | 95 | static inline void hwrng_cleanup(struct hwrng *rng) |
| @@ -304,8 +329,6 @@ int hwrng_register(struct hwrng *rng) | |||
| 304 | { | 329 | { |
| 305 | int err = -EINVAL; | 330 | int err = -EINVAL; |
| 306 | struct hwrng *old_rng, *tmp; | 331 | struct hwrng *old_rng, *tmp; |
| 307 | unsigned char bytes[16]; | ||
| 308 | int bytes_read; | ||
| 309 | 332 | ||
| 310 | if (rng->name == NULL || | 333 | if (rng->name == NULL || |
| 311 | (rng->data_read == NULL && rng->read == NULL)) | 334 | (rng->data_read == NULL && rng->read == NULL)) |
| @@ -347,9 +370,17 @@ int hwrng_register(struct hwrng *rng) | |||
| 347 | INIT_LIST_HEAD(&rng->list); | 370 | INIT_LIST_HEAD(&rng->list); |
| 348 | list_add_tail(&rng->list, &rng_list); | 371 | list_add_tail(&rng->list, &rng_list); |
| 349 | 372 | ||
| 350 | bytes_read = rng_get_data(rng, bytes, sizeof(bytes), 1); | 373 | if (old_rng && !rng->init) { |
| 351 | if (bytes_read > 0) | 374 | /* |
| 352 | add_device_randomness(bytes, bytes_read); | 375 | * Use a new device's input to add some randomness to |
| 376 | * the system. If this rng device isn't going to be | ||
| 377 | * used right away, its init function hasn't been | ||
| 378 | * called yet; so only use the randomness from devices | ||
| 379 | * that don't need an init callback. | ||
| 380 | */ | ||
| 381 | add_early_randomness(rng); | ||
| 382 | } | ||
| 383 | |||
| 353 | out_unlock: | 384 | out_unlock: |
| 354 | mutex_unlock(&rng_mutex); | 385 | mutex_unlock(&rng_mutex); |
| 355 | out: | 386 | out: |
diff --git a/drivers/char/hw_random/virtio-rng.c b/drivers/char/hw_random/virtio-rng.c index f3e71501de54..e9b15bc18b4d 100644 --- a/drivers/char/hw_random/virtio-rng.c +++ b/drivers/char/hw_random/virtio-rng.c | |||
| @@ -38,6 +38,8 @@ struct virtrng_info { | |||
| 38 | int index; | 38 | int index; |
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | static bool probe_done; | ||
| 42 | |||
| 41 | static void random_recv_done(struct virtqueue *vq) | 43 | static void random_recv_done(struct virtqueue *vq) |
| 42 | { | 44 | { |
| 43 | struct virtrng_info *vi = vq->vdev->priv; | 45 | struct virtrng_info *vi = vq->vdev->priv; |
| @@ -67,6 +69,13 @@ static int virtio_read(struct hwrng *rng, void *buf, size_t size, bool wait) | |||
| 67 | int ret; | 69 | int ret; |
| 68 | struct virtrng_info *vi = (struct virtrng_info *)rng->priv; | 70 | struct virtrng_info *vi = (struct virtrng_info *)rng->priv; |
| 69 | 71 | ||
| 72 | /* | ||
| 73 | * Don't ask host for data till we're setup. This call can | ||
| 74 | * happen during hwrng_register(), after commit d9e7972619. | ||
| 75 | */ | ||
| 76 | if (unlikely(!probe_done)) | ||
| 77 | return 0; | ||
| 78 | |||
| 70 | if (!vi->busy) { | 79 | if (!vi->busy) { |
| 71 | vi->busy = true; | 80 | vi->busy = true; |
| 72 | init_completion(&vi->have_data); | 81 | init_completion(&vi->have_data); |
| @@ -137,6 +146,7 @@ static int probe_common(struct virtio_device *vdev) | |||
| 137 | return err; | 146 | return err; |
| 138 | } | 147 | } |
| 139 | 148 | ||
| 149 | probe_done = true; | ||
| 140 | return 0; | 150 | return 0; |
| 141 | } | 151 | } |
| 142 | 152 | ||
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index d915707d2ba1..93dcad0c1cbe 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c | |||
| @@ -138,7 +138,9 @@ static int i8k_smm(struct smm_regs *regs) | |||
| 138 | if (!alloc_cpumask_var(&old_mask, GFP_KERNEL)) | 138 | if (!alloc_cpumask_var(&old_mask, GFP_KERNEL)) |
| 139 | return -ENOMEM; | 139 | return -ENOMEM; |
| 140 | cpumask_copy(old_mask, ¤t->cpus_allowed); | 140 | cpumask_copy(old_mask, ¤t->cpus_allowed); |
| 141 | set_cpus_allowed_ptr(current, cpumask_of(0)); | 141 | rc = set_cpus_allowed_ptr(current, cpumask_of(0)); |
| 142 | if (rc) | ||
| 143 | goto out; | ||
| 142 | if (smp_processor_id() != 0) { | 144 | if (smp_processor_id() != 0) { |
| 143 | rc = -EBUSY; | 145 | rc = -EBUSY; |
| 144 | goto out; | 146 | goto out; |
diff --git a/drivers/char/random.c b/drivers/char/random.c index 0a7ac0a7b252..71529e196b84 100644 --- a/drivers/char/random.c +++ b/drivers/char/random.c | |||
| @@ -641,7 +641,7 @@ retry: | |||
| 641 | } while (unlikely(entropy_count < pool_size-2 && pnfrac)); | 641 | } while (unlikely(entropy_count < pool_size-2 && pnfrac)); |
| 642 | } | 642 | } |
| 643 | 643 | ||
| 644 | if (entropy_count < 0) { | 644 | if (unlikely(entropy_count < 0)) { |
| 645 | pr_warn("random: negative entropy/overflow: pool %s count %d\n", | 645 | pr_warn("random: negative entropy/overflow: pool %s count %d\n", |
| 646 | r->name, entropy_count); | 646 | r->name, entropy_count); |
| 647 | WARN_ON(1); | 647 | WARN_ON(1); |
| @@ -981,7 +981,7 @@ static size_t account(struct entropy_store *r, size_t nbytes, int min, | |||
| 981 | int reserved) | 981 | int reserved) |
| 982 | { | 982 | { |
| 983 | int entropy_count, orig; | 983 | int entropy_count, orig; |
| 984 | size_t ibytes; | 984 | size_t ibytes, nfrac; |
| 985 | 985 | ||
| 986 | BUG_ON(r->entropy_count > r->poolinfo->poolfracbits); | 986 | BUG_ON(r->entropy_count > r->poolinfo->poolfracbits); |
| 987 | 987 | ||
| @@ -999,7 +999,17 @@ retry: | |||
| 999 | } | 999 | } |
| 1000 | if (ibytes < min) | 1000 | if (ibytes < min) |
| 1001 | ibytes = 0; | 1001 | ibytes = 0; |
| 1002 | if ((entropy_count -= ibytes << (ENTROPY_SHIFT + 3)) < 0) | 1002 | |
| 1003 | if (unlikely(entropy_count < 0)) { | ||
| 1004 | pr_warn("random: negative entropy count: pool %s count %d\n", | ||
| 1005 | r->name, entropy_count); | ||
| 1006 | WARN_ON(1); | ||
| 1007 | entropy_count = 0; | ||
| 1008 | } | ||
| 1009 | nfrac = ibytes << (ENTROPY_SHIFT + 3); | ||
| 1010 | if ((size_t) entropy_count > nfrac) | ||
| 1011 | entropy_count -= nfrac; | ||
| 1012 | else | ||
| 1003 | entropy_count = 0; | 1013 | entropy_count = 0; |
| 1004 | 1014 | ||
| 1005 | if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) | 1015 | if (cmpxchg(&r->entropy_count, orig, entropy_count) != orig) |
| @@ -1376,6 +1386,7 @@ urandom_read(struct file *file, char __user *buf, size_t nbytes, loff_t *ppos) | |||
| 1376 | "with %d bits of entropy available\n", | 1386 | "with %d bits of entropy available\n", |
| 1377 | current->comm, nonblocking_pool.entropy_total); | 1387 | current->comm, nonblocking_pool.entropy_total); |
| 1378 | 1388 | ||
| 1389 | nbytes = min_t(size_t, nbytes, INT_MAX >> (ENTROPY_SHIFT + 3)); | ||
| 1379 | ret = extract_entropy_user(&nonblocking_pool, buf, nbytes); | 1390 | ret = extract_entropy_user(&nonblocking_pool, buf, nbytes); |
| 1380 | 1391 | ||
| 1381 | trace_urandom_read(8 * nbytes, ENTROPY_BITS(&nonblocking_pool), | 1392 | trace_urandom_read(8 * nbytes, ENTROPY_BITS(&nonblocking_pool), |
diff --git a/drivers/clk/clk-s2mps11.c b/drivers/clk/clk-s2mps11.c index 9b7b5859a420..3757e9e72d37 100644 --- a/drivers/clk/clk-s2mps11.c +++ b/drivers/clk/clk-s2mps11.c | |||
| @@ -230,16 +230,13 @@ static int s2mps11_clk_probe(struct platform_device *pdev) | |||
| 230 | goto err_reg; | 230 | goto err_reg; |
| 231 | } | 231 | } |
| 232 | 232 | ||
| 233 | s2mps11_clk->lookup = devm_kzalloc(&pdev->dev, | 233 | s2mps11_clk->lookup = clkdev_alloc(s2mps11_clk->clk, |
| 234 | sizeof(struct clk_lookup), GFP_KERNEL); | 234 | s2mps11_name(s2mps11_clk), NULL); |
| 235 | if (!s2mps11_clk->lookup) { | 235 | if (!s2mps11_clk->lookup) { |
| 236 | ret = -ENOMEM; | 236 | ret = -ENOMEM; |
| 237 | goto err_lup; | 237 | goto err_lup; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | s2mps11_clk->lookup->con_id = s2mps11_name(s2mps11_clk); | ||
| 241 | s2mps11_clk->lookup->clk = s2mps11_clk->clk; | ||
| 242 | |||
| 243 | clkdev_add(s2mps11_clk->lookup); | 240 | clkdev_add(s2mps11_clk->lookup); |
| 244 | } | 241 | } |
| 245 | 242 | ||
diff --git a/drivers/clk/qcom/mmcc-msm8960.c b/drivers/clk/qcom/mmcc-msm8960.c index 12f3c0b64fcd..4c449b3170f6 100644 --- a/drivers/clk/qcom/mmcc-msm8960.c +++ b/drivers/clk/qcom/mmcc-msm8960.c | |||
| @@ -1209,7 +1209,7 @@ static struct clk_branch rot_clk = { | |||
| 1209 | 1209 | ||
| 1210 | static u8 mmcc_pxo_hdmi_map[] = { | 1210 | static u8 mmcc_pxo_hdmi_map[] = { |
| 1211 | [P_PXO] = 0, | 1211 | [P_PXO] = 0, |
| 1212 | [P_HDMI_PLL] = 2, | 1212 | [P_HDMI_PLL] = 3, |
| 1213 | }; | 1213 | }; |
| 1214 | 1214 | ||
| 1215 | static const char *mmcc_pxo_hdmi[] = { | 1215 | static const char *mmcc_pxo_hdmi[] = { |
diff --git a/drivers/clk/samsung/clk-exynos4.c b/drivers/clk/samsung/clk-exynos4.c index 4f150c9dd38c..7f4a473a7ad7 100644 --- a/drivers/clk/samsung/clk-exynos4.c +++ b/drivers/clk/samsung/clk-exynos4.c | |||
| @@ -925,21 +925,13 @@ static struct samsung_gate_clock exynos4x12_gate_clks[] __initdata = { | |||
| 925 | GATE(CLK_RTC, "rtc", "aclk100", E4X12_GATE_IP_PERIR, 15, | 925 | GATE(CLK_RTC, "rtc", "aclk100", E4X12_GATE_IP_PERIR, 15, |
| 926 | 0, 0), | 926 | 0, 0), |
| 927 | GATE(CLK_KEYIF, "keyif", "aclk100", E4X12_GATE_IP_PERIR, 16, 0, 0), | 927 | GATE(CLK_KEYIF, "keyif", "aclk100", E4X12_GATE_IP_PERIR, 16, 0, 0), |
| 928 | GATE(CLK_SCLK_PWM_ISP, "sclk_pwm_isp", "div_pwm_isp", | 928 | GATE(CLK_PWM_ISP_SCLK, "pwm_isp_sclk", "div_pwm_isp", |
| 929 | E4X12_SRC_MASK_ISP, 0, CLK_SET_RATE_PARENT, 0), | ||
| 930 | GATE(CLK_SCLK_SPI0_ISP, "sclk_spi0_isp", "div_spi0_isp_pre", | ||
| 931 | E4X12_SRC_MASK_ISP, 4, CLK_SET_RATE_PARENT, 0), | ||
| 932 | GATE(CLK_SCLK_SPI1_ISP, "sclk_spi1_isp", "div_spi1_isp_pre", | ||
| 933 | E4X12_SRC_MASK_ISP, 8, CLK_SET_RATE_PARENT, 0), | ||
| 934 | GATE(CLK_SCLK_UART_ISP, "sclk_uart_isp", "div_uart_isp", | ||
| 935 | E4X12_SRC_MASK_ISP, 12, CLK_SET_RATE_PARENT, 0), | ||
| 936 | GATE(CLK_PWM_ISP_SCLK, "pwm_isp_sclk", "sclk_pwm_isp", | ||
| 937 | E4X12_GATE_IP_ISP, 0, 0, 0), | 929 | E4X12_GATE_IP_ISP, 0, 0, 0), |
| 938 | GATE(CLK_SPI0_ISP_SCLK, "spi0_isp_sclk", "sclk_spi0_isp", | 930 | GATE(CLK_SPI0_ISP_SCLK, "spi0_isp_sclk", "div_spi0_isp_pre", |
| 939 | E4X12_GATE_IP_ISP, 1, 0, 0), | 931 | E4X12_GATE_IP_ISP, 1, 0, 0), |
| 940 | GATE(CLK_SPI1_ISP_SCLK, "spi1_isp_sclk", "sclk_spi1_isp", | 932 | GATE(CLK_SPI1_ISP_SCLK, "spi1_isp_sclk", "div_spi1_isp_pre", |
| 941 | E4X12_GATE_IP_ISP, 2, 0, 0), | 933 | E4X12_GATE_IP_ISP, 2, 0, 0), |
| 942 | GATE(CLK_UART_ISP_SCLK, "uart_isp_sclk", "sclk_uart_isp", | 934 | GATE(CLK_UART_ISP_SCLK, "uart_isp_sclk", "div_uart_isp", |
| 943 | E4X12_GATE_IP_ISP, 3, 0, 0), | 935 | E4X12_GATE_IP_ISP, 3, 0, 0), |
| 944 | GATE(CLK_WDT, "watchdog", "aclk100", E4X12_GATE_IP_PERIR, 14, 0, 0), | 936 | GATE(CLK_WDT, "watchdog", "aclk100", E4X12_GATE_IP_PERIR, 14, 0, 0), |
| 945 | GATE(CLK_PCM0, "pcm0", "aclk100", E4X12_GATE_IP_MAUDIO, 2, | 937 | GATE(CLK_PCM0, "pcm0", "aclk100", E4X12_GATE_IP_MAUDIO, 2, |
diff --git a/drivers/clk/samsung/clk-exynos5250.c b/drivers/clk/samsung/clk-exynos5250.c index 1fad4c5e3f5d..184f64293b26 100644 --- a/drivers/clk/samsung/clk-exynos5250.c +++ b/drivers/clk/samsung/clk-exynos5250.c | |||
| @@ -661,7 +661,7 @@ static struct samsung_gate_clock exynos5250_gate_clks[] __initdata = { | |||
| 661 | GATE(CLK_RTC, "rtc", "div_aclk66", GATE_IP_PERIS, 20, 0, 0), | 661 | GATE(CLK_RTC, "rtc", "div_aclk66", GATE_IP_PERIS, 20, 0, 0), |
| 662 | GATE(CLK_TMU, "tmu", "div_aclk66", GATE_IP_PERIS, 21, 0, 0), | 662 | GATE(CLK_TMU, "tmu", "div_aclk66", GATE_IP_PERIS, 21, 0, 0), |
| 663 | GATE(CLK_SMMU_TV, "smmu_tv", "mout_aclk200_disp1_sub", | 663 | GATE(CLK_SMMU_TV, "smmu_tv", "mout_aclk200_disp1_sub", |
| 664 | GATE_IP_DISP1, 2, 0, 0), | 664 | GATE_IP_DISP1, 9, 0, 0), |
| 665 | GATE(CLK_SMMU_FIMD1, "smmu_fimd1", "mout_aclk200_disp1_sub", | 665 | GATE(CLK_SMMU_FIMD1, "smmu_fimd1", "mout_aclk200_disp1_sub", |
| 666 | GATE_IP_DISP1, 8, 0, 0), | 666 | GATE_IP_DISP1, 8, 0, 0), |
| 667 | GATE(CLK_SMMU_2D, "smmu_2d", "div_aclk200", GATE_IP_ACP, 7, 0, 0), | 667 | GATE(CLK_SMMU_2D, "smmu_2d", "div_aclk200", GATE_IP_ACP, 7, 0, 0), |
diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c index 9d7d7eed03fd..a4e6cc782e5c 100644 --- a/drivers/clk/samsung/clk-exynos5420.c +++ b/drivers/clk/samsung/clk-exynos5420.c | |||
| @@ -631,7 +631,8 @@ static struct samsung_mux_clock exynos5x_mux_clks[] __initdata = { | |||
| 631 | SRC_TOP4, 16, 1), | 631 | SRC_TOP4, 16, 1), |
| 632 | MUX(0, "mout_user_aclk266", mout_user_aclk266_p, SRC_TOP4, 20, 1), | 632 | MUX(0, "mout_user_aclk266", mout_user_aclk266_p, SRC_TOP4, 20, 1), |
| 633 | MUX(0, "mout_user_aclk166", mout_user_aclk166_p, SRC_TOP4, 24, 1), | 633 | MUX(0, "mout_user_aclk166", mout_user_aclk166_p, SRC_TOP4, 24, 1), |
| 634 | MUX(0, "mout_user_aclk333", mout_user_aclk333_p, SRC_TOP4, 28, 1), | 634 | MUX(CLK_MOUT_USER_ACLK333, "mout_user_aclk333", mout_user_aclk333_p, |
| 635 | SRC_TOP4, 28, 1), | ||
| 635 | 636 | ||
| 636 | MUX(0, "mout_user_aclk400_disp1", mout_user_aclk400_disp1_p, | 637 | MUX(0, "mout_user_aclk400_disp1", mout_user_aclk400_disp1_p, |
| 637 | SRC_TOP5, 0, 1), | 638 | SRC_TOP5, 0, 1), |
| @@ -684,7 +685,8 @@ static struct samsung_mux_clock exynos5x_mux_clks[] __initdata = { | |||
| 684 | SRC_TOP11, 12, 1), | 685 | SRC_TOP11, 12, 1), |
| 685 | MUX(0, "mout_sw_aclk266", mout_sw_aclk266_p, SRC_TOP11, 20, 1), | 686 | MUX(0, "mout_sw_aclk266", mout_sw_aclk266_p, SRC_TOP11, 20, 1), |
| 686 | MUX(0, "mout_sw_aclk166", mout_sw_aclk166_p, SRC_TOP11, 24, 1), | 687 | MUX(0, "mout_sw_aclk166", mout_sw_aclk166_p, SRC_TOP11, 24, 1), |
| 687 | MUX(0, "mout_sw_aclk333", mout_sw_aclk333_p, SRC_TOP11, 28, 1), | 688 | MUX(CLK_MOUT_SW_ACLK333, "mout_sw_aclk333", mout_sw_aclk333_p, |
| 689 | SRC_TOP11, 28, 1), | ||
| 688 | 690 | ||
| 689 | MUX(0, "mout_sw_aclk400_disp1", mout_sw_aclk400_disp1_p, | 691 | MUX(0, "mout_sw_aclk400_disp1", mout_sw_aclk400_disp1_p, |
| 690 | SRC_TOP12, 4, 1), | 692 | SRC_TOP12, 4, 1), |
| @@ -890,8 +892,6 @@ static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = { | |||
| 890 | GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0), | 892 | GATE_BUS_TOP, 9, CLK_IGNORE_UNUSED, 0), |
| 891 | GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen", | 893 | GATE(0, "aclk66_psgen", "mout_user_aclk66_psgen", |
| 892 | GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0), | 894 | GATE_BUS_TOP, 10, CLK_IGNORE_UNUSED, 0), |
| 893 | GATE(CLK_ACLK66_PERIC, "aclk66_peric", "mout_user_aclk66_peric", | ||
| 894 | GATE_BUS_TOP, 11, CLK_IGNORE_UNUSED, 0), | ||
| 895 | GATE(0, "aclk266_isp", "mout_user_aclk266_isp", | 895 | GATE(0, "aclk266_isp", "mout_user_aclk266_isp", |
| 896 | GATE_BUS_TOP, 13, 0, 0), | 896 | GATE_BUS_TOP, 13, 0, 0), |
| 897 | GATE(0, "aclk166", "mout_user_aclk166", | 897 | GATE(0, "aclk166", "mout_user_aclk166", |
| @@ -994,34 +994,61 @@ static struct samsung_gate_clock exynos5x_gate_clks[] __initdata = { | |||
| 994 | SRC_MASK_FSYS, 24, CLK_SET_RATE_PARENT, 0), | 994 | SRC_MASK_FSYS, 24, CLK_SET_RATE_PARENT, 0), |
| 995 | 995 | ||
| 996 | /* PERIC Block */ | 996 | /* PERIC Block */ |
| 997 | GATE(CLK_UART0, "uart0", "aclk66_peric", GATE_IP_PERIC, 0, 0, 0), | 997 | GATE(CLK_UART0, "uart0", "mout_user_aclk66_peric", |
| 998 | GATE(CLK_UART1, "uart1", "aclk66_peric", GATE_IP_PERIC, 1, 0, 0), | 998 | GATE_IP_PERIC, 0, 0, 0), |
| 999 | GATE(CLK_UART2, "uart2", "aclk66_peric", GATE_IP_PERIC, 2, 0, 0), | 999 | GATE(CLK_UART1, "uart1", "mout_user_aclk66_peric", |
| 1000 | GATE(CLK_UART3, "uart3", "aclk66_peric", GATE_IP_PERIC, 3, 0, 0), | 1000 | GATE_IP_PERIC, 1, 0, 0), |
| 1001 | GATE(CLK_I2C0, "i2c0", "aclk66_peric", GATE_IP_PERIC, 6, 0, 0), | 1001 | GATE(CLK_UART2, "uart2", "mout_user_aclk66_peric", |
| 1002 | GATE(CLK_I2C1, "i2c1", "aclk66_peric", GATE_IP_PERIC, 7, 0, 0), | 1002 | GATE_IP_PERIC, 2, 0, 0), |
| 1003 | GATE(CLK_I2C2, "i2c2", "aclk66_peric", GATE_IP_PERIC, 8, 0, 0), | 1003 | GATE(CLK_UART3, "uart3", "mout_user_aclk66_peric", |
| 1004 | GATE(CLK_I2C3, "i2c3", "aclk66_peric", GATE_IP_PERIC, 9, 0, 0), | 1004 | GATE_IP_PERIC, 3, 0, 0), |
| 1005 | GATE(CLK_USI0, "usi0", "aclk66_peric", GATE_IP_PERIC, 10, 0, 0), | 1005 | GATE(CLK_I2C0, "i2c0", "mout_user_aclk66_peric", |
| 1006 | GATE(CLK_USI1, "usi1", "aclk66_peric", GATE_IP_PERIC, 11, 0, 0), | 1006 | GATE_IP_PERIC, 6, 0, 0), |
| 1007 | GATE(CLK_USI2, "usi2", "aclk66_peric", GATE_IP_PERIC, 12, 0, 0), | 1007 | GATE(CLK_I2C1, "i2c1", "mout_user_aclk66_peric", |
| 1008 | GATE(CLK_USI3, "usi3", "aclk66_peric", GATE_IP_PERIC, 13, 0, 0), | 1008 | GATE_IP_PERIC, 7, 0, 0), |
| 1009 | GATE(CLK_I2C_HDMI, "i2c_hdmi", "aclk66_peric", GATE_IP_PERIC, 14, 0, 0), | 1009 | GATE(CLK_I2C2, "i2c2", "mout_user_aclk66_peric", |
| 1010 | GATE(CLK_TSADC, "tsadc", "aclk66_peric", GATE_IP_PERIC, 15, 0, 0), | 1010 | GATE_IP_PERIC, 8, 0, 0), |
| 1011 | GATE(CLK_SPI0, "spi0", "aclk66_peric", GATE_IP_PERIC, 16, 0, 0), | 1011 | GATE(CLK_I2C3, "i2c3", "mout_user_aclk66_peric", |
| 1012 | GATE(CLK_SPI1, "spi1", "aclk66_peric", GATE_IP_PERIC, 17, 0, 0), | 1012 | GATE_IP_PERIC, 9, 0, 0), |
| 1013 | GATE(CLK_SPI2, "spi2", "aclk66_peric", GATE_IP_PERIC, 18, 0, 0), | 1013 | GATE(CLK_USI0, "usi0", "mout_user_aclk66_peric", |
| 1014 | GATE(CLK_I2S1, "i2s1", "aclk66_peric", GATE_IP_PERIC, 20, 0, 0), | 1014 | GATE_IP_PERIC, 10, 0, 0), |
| 1015 | GATE(CLK_I2S2, "i2s2", "aclk66_peric", GATE_IP_PERIC, 21, 0, 0), | 1015 | GATE(CLK_USI1, "usi1", "mout_user_aclk66_peric", |
| 1016 | GATE(CLK_PCM1, "pcm1", "aclk66_peric", GATE_IP_PERIC, 22, 0, 0), | 1016 | GATE_IP_PERIC, 11, 0, 0), |
| 1017 | GATE(CLK_PCM2, "pcm2", "aclk66_peric", GATE_IP_PERIC, 23, 0, 0), | 1017 | GATE(CLK_USI2, "usi2", "mout_user_aclk66_peric", |
| 1018 | GATE(CLK_PWM, "pwm", "aclk66_peric", GATE_IP_PERIC, 24, 0, 0), | 1018 | GATE_IP_PERIC, 12, 0, 0), |
| 1019 | GATE(CLK_SPDIF, "spdif", "aclk66_peric", GATE_IP_PERIC, 26, 0, 0), | 1019 | GATE(CLK_USI3, "usi3", "mout_user_aclk66_peric", |
| 1020 | GATE(CLK_USI4, "usi4", "aclk66_peric", GATE_IP_PERIC, 28, 0, 0), | 1020 | GATE_IP_PERIC, 13, 0, 0), |
| 1021 | GATE(CLK_USI5, "usi5", "aclk66_peric", GATE_IP_PERIC, 30, 0, 0), | 1021 | GATE(CLK_I2C_HDMI, "i2c_hdmi", "mout_user_aclk66_peric", |
| 1022 | GATE(CLK_USI6, "usi6", "aclk66_peric", GATE_IP_PERIC, 31, 0, 0), | 1022 | GATE_IP_PERIC, 14, 0, 0), |
| 1023 | 1023 | GATE(CLK_TSADC, "tsadc", "mout_user_aclk66_peric", | |
| 1024 | GATE(CLK_KEYIF, "keyif", "aclk66_peric", GATE_BUS_PERIC, 22, 0, 0), | 1024 | GATE_IP_PERIC, 15, 0, 0), |
| 1025 | GATE(CLK_SPI0, "spi0", "mout_user_aclk66_peric", | ||
| 1026 | GATE_IP_PERIC, 16, 0, 0), | ||
| 1027 | GATE(CLK_SPI1, "spi1", "mout_user_aclk66_peric", | ||
| 1028 | GATE_IP_PERIC, 17, 0, 0), | ||
| 1029 | GATE(CLK_SPI2, "spi2", "mout_user_aclk66_peric", | ||
| 1030 | GATE_IP_PERIC, 18, 0, 0), | ||
| 1031 | GATE(CLK_I2S1, "i2s1", "mout_user_aclk66_peric", | ||
| 1032 | GATE_IP_PERIC, 20, 0, 0), | ||
| 1033 | GATE(CLK_I2S2, "i2s2", "mout_user_aclk66_peric", | ||
| 1034 | GATE_IP_PERIC, 21, 0, 0), | ||
| 1035 | GATE(CLK_PCM1, "pcm1", "mout_user_aclk66_peric", | ||
| 1036 | GATE_IP_PERIC, 22, 0, 0), | ||
| 1037 | GATE(CLK_PCM2, "pcm2", "mout_user_aclk66_peric", | ||
| 1038 | GATE_IP_PERIC, 23, 0, 0), | ||
| 1039 | GATE(CLK_PWM, "pwm", "mout_user_aclk66_peric", | ||
| 1040 | GATE_IP_PERIC, 24, 0, 0), | ||
| 1041 | GATE(CLK_SPDIF, "spdif", "mout_user_aclk66_peric", | ||
| 1042 | GATE_IP_PERIC, 26, 0, 0), | ||
| 1043 | GATE(CLK_USI4, "usi4", "mout_user_aclk66_peric", | ||
| 1044 | GATE_IP_PERIC, 28, 0, 0), | ||
| 1045 | GATE(CLK_USI5, "usi5", "mout_user_aclk66_peric", | ||
| 1046 | GATE_IP_PERIC, 30, 0, 0), | ||
| 1047 | GATE(CLK_USI6, "usi6", "mout_user_aclk66_peric", | ||
| 1048 | GATE_IP_PERIC, 31, 0, 0), | ||
| 1049 | |||
| 1050 | GATE(CLK_KEYIF, "keyif", "mout_user_aclk66_peric", | ||
| 1051 | GATE_BUS_PERIC, 22, 0, 0), | ||
| 1025 | 1052 | ||
| 1026 | /* PERIS Block */ | 1053 | /* PERIS Block */ |
| 1027 | GATE(CLK_CHIPID, "chipid", "aclk66_psgen", | 1054 | GATE(CLK_CHIPID, "chipid", "aclk66_psgen", |
diff --git a/drivers/clk/samsung/clk-s3c2410.c b/drivers/clk/samsung/clk-s3c2410.c index ba0716801db2..140f4733c02e 100644 --- a/drivers/clk/samsung/clk-s3c2410.c +++ b/drivers/clk/samsung/clk-s3c2410.c | |||
| @@ -152,6 +152,11 @@ struct samsung_clock_alias s3c2410_common_aliases[] __initdata = { | |||
| 152 | ALIAS(HCLK, NULL, "hclk"), | 152 | ALIAS(HCLK, NULL, "hclk"), |
| 153 | ALIAS(MPLL, NULL, "mpll"), | 153 | ALIAS(MPLL, NULL, "mpll"), |
| 154 | ALIAS(FCLK, NULL, "fclk"), | 154 | ALIAS(FCLK, NULL, "fclk"), |
| 155 | ALIAS(PCLK, NULL, "watchdog"), | ||
| 156 | ALIAS(PCLK_SDI, NULL, "sdi"), | ||
| 157 | ALIAS(HCLK_NAND, NULL, "nand"), | ||
| 158 | ALIAS(PCLK_I2S, NULL, "iis"), | ||
| 159 | ALIAS(PCLK_I2C, NULL, "i2c"), | ||
| 155 | }; | 160 | }; |
| 156 | 161 | ||
| 157 | /* S3C2410 specific clocks */ | 162 | /* S3C2410 specific clocks */ |
| @@ -378,7 +383,7 @@ void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f, | |||
| 378 | if (!np) | 383 | if (!np) |
| 379 | s3c2410_common_clk_register_fixed_ext(ctx, xti_f); | 384 | s3c2410_common_clk_register_fixed_ext(ctx, xti_f); |
| 380 | 385 | ||
| 381 | if (current_soc == 2410) { | 386 | if (current_soc == S3C2410) { |
| 382 | if (_get_rate("xti") == 12 * MHZ) { | 387 | if (_get_rate("xti") == 12 * MHZ) { |
| 383 | s3c2410_plls[mpll].rate_table = pll_s3c2410_12mhz_tbl; | 388 | s3c2410_plls[mpll].rate_table = pll_s3c2410_12mhz_tbl; |
| 384 | s3c2410_plls[upll].rate_table = pll_s3c2410_12mhz_tbl; | 389 | s3c2410_plls[upll].rate_table = pll_s3c2410_12mhz_tbl; |
| @@ -432,7 +437,7 @@ void __init s3c2410_common_clk_init(struct device_node *np, unsigned long xti_f, | |||
| 432 | samsung_clk_register_fixed_factor(ctx, s3c2410_ffactor, | 437 | samsung_clk_register_fixed_factor(ctx, s3c2410_ffactor, |
| 433 | ARRAY_SIZE(s3c2410_ffactor)); | 438 | ARRAY_SIZE(s3c2410_ffactor)); |
| 434 | samsung_clk_register_alias(ctx, s3c2410_aliases, | 439 | samsung_clk_register_alias(ctx, s3c2410_aliases, |
| 435 | ARRAY_SIZE(s3c2410_common_aliases)); | 440 | ARRAY_SIZE(s3c2410_aliases)); |
| 436 | break; | 441 | break; |
| 437 | case S3C2440: | 442 | case S3C2440: |
| 438 | samsung_clk_register_mux(ctx, s3c2440_muxes, | 443 | samsung_clk_register_mux(ctx, s3c2440_muxes, |
diff --git a/drivers/clk/samsung/clk-s3c64xx.c b/drivers/clk/samsung/clk-s3c64xx.c index efa16ee592c8..8889ff1c10fc 100644 --- a/drivers/clk/samsung/clk-s3c64xx.c +++ b/drivers/clk/samsung/clk-s3c64xx.c | |||
| @@ -418,8 +418,10 @@ static struct samsung_clock_alias s3c64xx_clock_aliases[] = { | |||
| 418 | ALIAS(SCLK_MMC2, "s3c-sdhci.2", "mmc_busclk.2"), | 418 | ALIAS(SCLK_MMC2, "s3c-sdhci.2", "mmc_busclk.2"), |
| 419 | ALIAS(SCLK_MMC1, "s3c-sdhci.1", "mmc_busclk.2"), | 419 | ALIAS(SCLK_MMC1, "s3c-sdhci.1", "mmc_busclk.2"), |
| 420 | ALIAS(SCLK_MMC0, "s3c-sdhci.0", "mmc_busclk.2"), | 420 | ALIAS(SCLK_MMC0, "s3c-sdhci.0", "mmc_busclk.2"), |
| 421 | ALIAS(SCLK_SPI1, "s3c6410-spi.1", "spi-bus"), | 421 | ALIAS(PCLK_SPI1, "s3c6410-spi.1", "spi_busclk0"), |
| 422 | ALIAS(SCLK_SPI0, "s3c6410-spi.0", "spi-bus"), | 422 | ALIAS(SCLK_SPI1, "s3c6410-spi.1", "spi_busclk2"), |
| 423 | ALIAS(PCLK_SPI0, "s3c6410-spi.0", "spi_busclk0"), | ||
| 424 | ALIAS(SCLK_SPI0, "s3c6410-spi.0", "spi_busclk2"), | ||
| 423 | ALIAS(SCLK_AUDIO1, "samsung-pcm.1", "audio-bus"), | 425 | ALIAS(SCLK_AUDIO1, "samsung-pcm.1", "audio-bus"), |
| 424 | ALIAS(SCLK_AUDIO1, "samsung-i2s.1", "audio-bus"), | 426 | ALIAS(SCLK_AUDIO1, "samsung-i2s.1", "audio-bus"), |
| 425 | ALIAS(SCLK_AUDIO0, "samsung-pcm.0", "audio-bus"), | 427 | ALIAS(SCLK_AUDIO0, "samsung-pcm.0", "audio-bus"), |
diff --git a/drivers/clk/spear/spear3xx_clock.c b/drivers/clk/spear/spear3xx_clock.c index c2d204315546..bb5f387774e2 100644 --- a/drivers/clk/spear/spear3xx_clock.c +++ b/drivers/clk/spear/spear3xx_clock.c | |||
| @@ -211,7 +211,7 @@ static inline void spear310_clk_init(void) { } | |||
| 211 | /* array of all spear 320 clock lookups */ | 211 | /* array of all spear 320 clock lookups */ |
| 212 | #ifdef CONFIG_MACH_SPEAR320 | 212 | #ifdef CONFIG_MACH_SPEAR320 |
| 213 | 213 | ||
| 214 | #define SPEAR320_CONTROL_REG (soc_config_base + 0x0000) | 214 | #define SPEAR320_CONTROL_REG (soc_config_base + 0x0010) |
| 215 | #define SPEAR320_EXT_CTRL_REG (soc_config_base + 0x0018) | 215 | #define SPEAR320_EXT_CTRL_REG (soc_config_base + 0x0018) |
| 216 | 216 | ||
| 217 | #define SPEAR320_UARTX_PCLK_MASK 0x1 | 217 | #define SPEAR320_UARTX_PCLK_MASK 0x1 |
| @@ -245,7 +245,8 @@ static const char *smii0_parents[] = { "smii_125m_pad", "ras_pll2_clk", | |||
| 245 | "ras_syn0_gclk", }; | 245 | "ras_syn0_gclk", }; |
| 246 | static const char *uartx_parents[] = { "ras_syn1_gclk", "ras_apb_clk", }; | 246 | static const char *uartx_parents[] = { "ras_syn1_gclk", "ras_apb_clk", }; |
| 247 | 247 | ||
| 248 | static void __init spear320_clk_init(void __iomem *soc_config_base) | 248 | static void __init spear320_clk_init(void __iomem *soc_config_base, |
| 249 | struct clk *ras_apb_clk) | ||
| 249 | { | 250 | { |
| 250 | struct clk *clk; | 251 | struct clk *clk; |
| 251 | 252 | ||
| @@ -342,6 +343,8 @@ static void __init spear320_clk_init(void __iomem *soc_config_base) | |||
| 342 | SPEAR320_CONTROL_REG, UART1_PCLK_SHIFT, UART1_PCLK_MASK, | 343 | SPEAR320_CONTROL_REG, UART1_PCLK_SHIFT, UART1_PCLK_MASK, |
| 343 | 0, &_lock); | 344 | 0, &_lock); |
| 344 | clk_register_clkdev(clk, NULL, "a3000000.serial"); | 345 | clk_register_clkdev(clk, NULL, "a3000000.serial"); |
| 346 | /* Enforce ras_apb_clk */ | ||
| 347 | clk_set_parent(clk, ras_apb_clk); | ||
| 345 | 348 | ||
| 346 | clk = clk_register_mux(NULL, "uart2_clk", uartx_parents, | 349 | clk = clk_register_mux(NULL, "uart2_clk", uartx_parents, |
| 347 | ARRAY_SIZE(uartx_parents), | 350 | ARRAY_SIZE(uartx_parents), |
| @@ -349,6 +352,8 @@ static void __init spear320_clk_init(void __iomem *soc_config_base) | |||
| 349 | SPEAR320_EXT_CTRL_REG, SPEAR320_UART2_PCLK_SHIFT, | 352 | SPEAR320_EXT_CTRL_REG, SPEAR320_UART2_PCLK_SHIFT, |
| 350 | SPEAR320_UARTX_PCLK_MASK, 0, &_lock); | 353 | SPEAR320_UARTX_PCLK_MASK, 0, &_lock); |
| 351 | clk_register_clkdev(clk, NULL, "a4000000.serial"); | 354 | clk_register_clkdev(clk, NULL, "a4000000.serial"); |
| 355 | /* Enforce ras_apb_clk */ | ||
| 356 | clk_set_parent(clk, ras_apb_clk); | ||
| 352 | 357 | ||
| 353 | clk = clk_register_mux(NULL, "uart3_clk", uartx_parents, | 358 | clk = clk_register_mux(NULL, "uart3_clk", uartx_parents, |
| 354 | ARRAY_SIZE(uartx_parents), | 359 | ARRAY_SIZE(uartx_parents), |
| @@ -379,12 +384,12 @@ static void __init spear320_clk_init(void __iomem *soc_config_base) | |||
| 379 | clk_register_clkdev(clk, NULL, "60100000.serial"); | 384 | clk_register_clkdev(clk, NULL, "60100000.serial"); |
| 380 | } | 385 | } |
| 381 | #else | 386 | #else |
| 382 | static inline void spear320_clk_init(void __iomem *soc_config_base) { } | 387 | static inline void spear320_clk_init(void __iomem *sb, struct clk *rc) { } |
| 383 | #endif | 388 | #endif |
| 384 | 389 | ||
| 385 | void __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_base) | 390 | void __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_base) |
| 386 | { | 391 | { |
| 387 | struct clk *clk, *clk1; | 392 | struct clk *clk, *clk1, *ras_apb_clk; |
| 388 | 393 | ||
| 389 | clk = clk_register_fixed_rate(NULL, "osc_32k_clk", NULL, CLK_IS_ROOT, | 394 | clk = clk_register_fixed_rate(NULL, "osc_32k_clk", NULL, CLK_IS_ROOT, |
| 390 | 32000); | 395 | 32000); |
| @@ -613,6 +618,7 @@ void __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_ | |||
| 613 | clk = clk_register_gate(NULL, "ras_apb_clk", "apb_clk", 0, RAS_CLK_ENB, | 618 | clk = clk_register_gate(NULL, "ras_apb_clk", "apb_clk", 0, RAS_CLK_ENB, |
| 614 | RAS_APB_CLK_ENB, 0, &_lock); | 619 | RAS_APB_CLK_ENB, 0, &_lock); |
| 615 | clk_register_clkdev(clk, "ras_apb_clk", NULL); | 620 | clk_register_clkdev(clk, "ras_apb_clk", NULL); |
| 621 | ras_apb_clk = clk; | ||
| 616 | 622 | ||
| 617 | clk = clk_register_gate(NULL, "ras_32k_clk", "osc_32k_clk", 0, | 623 | clk = clk_register_gate(NULL, "ras_32k_clk", "osc_32k_clk", 0, |
| 618 | RAS_CLK_ENB, RAS_32K_CLK_ENB, 0, &_lock); | 624 | RAS_CLK_ENB, RAS_32K_CLK_ENB, 0, &_lock); |
| @@ -659,5 +665,5 @@ void __init spear3xx_clk_init(void __iomem *misc_base, void __iomem *soc_config_ | |||
| 659 | else if (of_machine_is_compatible("st,spear310")) | 665 | else if (of_machine_is_compatible("st,spear310")) |
| 660 | spear310_clk_init(); | 666 | spear310_clk_init(); |
| 661 | else if (of_machine_is_compatible("st,spear320")) | 667 | else if (of_machine_is_compatible("st,spear320")) |
| 662 | spear320_clk_init(soc_config_base); | 668 | spear320_clk_init(soc_config_base, ras_apb_clk); |
| 663 | } | 669 | } |
diff --git a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c index 44cd27c5c401..670f90d629d7 100644 --- a/drivers/clk/sunxi/clk-sun6i-apb0-gates.c +++ b/drivers/clk/sunxi/clk-sun6i-apb0-gates.c | |||
| @@ -29,7 +29,7 @@ static int sun6i_a31_apb0_gates_clk_probe(struct platform_device *pdev) | |||
| 29 | 29 | ||
| 30 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 30 | r = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 31 | reg = devm_ioremap_resource(&pdev->dev, r); | 31 | reg = devm_ioremap_resource(&pdev->dev, r); |
| 32 | if (!reg) | 32 | if (IS_ERR(reg)) |
| 33 | return PTR_ERR(reg); | 33 | return PTR_ERR(reg); |
| 34 | 34 | ||
| 35 | clk_parent = of_clk_get_parent_name(np, 0); | 35 | clk_parent = of_clk_get_parent_name(np, 0); |
diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c index 5428c9c547cd..72d97279eae1 100644 --- a/drivers/clk/ti/apll.c +++ b/drivers/clk/ti/apll.c | |||
| @@ -77,13 +77,11 @@ static int dra7_apll_enable(struct clk_hw *hw) | |||
| 77 | if (i == MAX_APLL_WAIT_TRIES) { | 77 | if (i == MAX_APLL_WAIT_TRIES) { |
| 78 | pr_warn("clock: %s failed transition to '%s'\n", | 78 | pr_warn("clock: %s failed transition to '%s'\n", |
| 79 | clk_name, (state) ? "locked" : "bypassed"); | 79 | clk_name, (state) ? "locked" : "bypassed"); |
| 80 | } else { | 80 | r = -EBUSY; |
| 81 | } else | ||
| 81 | pr_debug("clock: %s transition to '%s' in %d loops\n", | 82 | pr_debug("clock: %s transition to '%s' in %d loops\n", |
| 82 | clk_name, (state) ? "locked" : "bypassed", i); | 83 | clk_name, (state) ? "locked" : "bypassed", i); |
| 83 | 84 | ||
| 84 | r = 0; | ||
| 85 | } | ||
| 86 | |||
| 87 | return r; | 85 | return r; |
| 88 | } | 86 | } |
| 89 | 87 | ||
| @@ -338,7 +336,7 @@ static void __init of_omap2_apll_setup(struct device_node *node) | |||
| 338 | const char *parent_name; | 336 | const char *parent_name; |
| 339 | u32 val; | 337 | u32 val; |
| 340 | 338 | ||
| 341 | ad = kzalloc(sizeof(*clk_hw), GFP_KERNEL); | 339 | ad = kzalloc(sizeof(*ad), GFP_KERNEL); |
| 342 | clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL); | 340 | clk_hw = kzalloc(sizeof(*clk_hw), GFP_KERNEL); |
| 343 | init = kzalloc(sizeof(*init), GFP_KERNEL); | 341 | init = kzalloc(sizeof(*init), GFP_KERNEL); |
| 344 | 342 | ||
diff --git a/drivers/clk/ti/clk-7xx.c b/drivers/clk/ti/clk-7xx.c index e1581335937d..cb8e6f14e880 100644 --- a/drivers/clk/ti/clk-7xx.c +++ b/drivers/clk/ti/clk-7xx.c | |||
| @@ -16,7 +16,7 @@ | |||
| 16 | #include <linux/clkdev.h> | 16 | #include <linux/clkdev.h> |
| 17 | #include <linux/clk/ti.h> | 17 | #include <linux/clk/ti.h> |
| 18 | 18 | ||
| 19 | #define DRA7_DPLL_ABE_DEFFREQ 361267200 | 19 | #define DRA7_DPLL_ABE_DEFFREQ 180633600 |
| 20 | #define DRA7_DPLL_GMAC_DEFFREQ 1000000000 | 20 | #define DRA7_DPLL_GMAC_DEFFREQ 1000000000 |
| 21 | 21 | ||
| 22 | 22 | ||
| @@ -322,6 +322,11 @@ int __init dra7xx_dt_clk_init(void) | |||
| 322 | if (rc) | 322 | if (rc) |
| 323 | pr_err("%s: failed to configure ABE DPLL!\n", __func__); | 323 | pr_err("%s: failed to configure ABE DPLL!\n", __func__); |
| 324 | 324 | ||
| 325 | dpll_ck = clk_get_sys(NULL, "dpll_abe_m2x2_ck"); | ||
| 326 | rc = clk_set_rate(dpll_ck, DRA7_DPLL_ABE_DEFFREQ * 2); | ||
| 327 | if (rc) | ||
| 328 | pr_err("%s: failed to configure ABE DPLL m2x2!\n", __func__); | ||
| 329 | |||
| 325 | dpll_ck = clk_get_sys(NULL, "dpll_gmac_ck"); | 330 | dpll_ck = clk_get_sys(NULL, "dpll_gmac_ck"); |
| 326 | rc = clk_set_rate(dpll_ck, DRA7_DPLL_GMAC_DEFFREQ); | 331 | rc = clk_set_rate(dpll_ck, DRA7_DPLL_GMAC_DEFFREQ); |
| 327 | if (rc) | 332 | if (rc) |
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c index abd956d5f838..79791e1bf282 100644 --- a/drivers/clk/ti/dpll.c +++ b/drivers/clk/ti/dpll.c | |||
| @@ -161,7 +161,8 @@ cleanup: | |||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \ | 163 | #if defined(CONFIG_ARCH_OMAP4) || defined(CONFIG_SOC_OMAP5) || \ |
| 164 | defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) | 164 | defined(CONFIG_SOC_DRA7XX) || defined(CONFIG_SOC_AM33XX) || \ |
| 165 | defined(CONFIG_SOC_AM43XX) | ||
| 165 | /** | 166 | /** |
| 166 | * ti_clk_register_dpll_x2 - Registers a DPLLx2 clock | 167 | * ti_clk_register_dpll_x2 - Registers a DPLLx2 clock |
| 167 | * @node: device node for this clock | 168 | * @node: device node for this clock |
| @@ -322,7 +323,7 @@ CLK_OF_DECLARE(ti_omap4_dpll_x2_clock, "ti,omap4-dpll-x2-clock", | |||
| 322 | of_ti_omap4_dpll_x2_setup); | 323 | of_ti_omap4_dpll_x2_setup); |
| 323 | #endif | 324 | #endif |
| 324 | 325 | ||
| 325 | #ifdef CONFIG_SOC_AM33XX | 326 | #if defined(CONFIG_SOC_AM33XX) || defined(CONFIG_SOC_AM43XX) |
| 326 | static void __init of_ti_am3_dpll_x2_setup(struct device_node *node) | 327 | static void __init of_ti_am3_dpll_x2_setup(struct device_node *node) |
| 327 | { | 328 | { |
| 328 | ti_clk_register_dpll_x2(node, &dpll_x2_ck_ops, NULL); | 329 | ti_clk_register_dpll_x2(node, &dpll_x2_ck_ops, NULL); |
diff --git a/drivers/clk/ti/mux.c b/drivers/clk/ti/mux.c index 0197a478720c..e9d650e51287 100644 --- a/drivers/clk/ti/mux.c +++ b/drivers/clk/ti/mux.c | |||
| @@ -160,7 +160,7 @@ static void of_mux_clk_setup(struct device_node *node) | |||
| 160 | u8 clk_mux_flags = 0; | 160 | u8 clk_mux_flags = 0; |
| 161 | u32 mask = 0; | 161 | u32 mask = 0; |
| 162 | u32 shift = 0; | 162 | u32 shift = 0; |
| 163 | u32 flags = 0; | 163 | u32 flags = CLK_SET_RATE_NO_REPARENT; |
| 164 | 164 | ||
| 165 | num_parents = of_clk_get_parent_count(node); | 165 | num_parents = of_clk_get_parent_count(node); |
| 166 | if (num_parents < 2) { | 166 | if (num_parents < 2) { |
diff --git a/drivers/clocksource/exynos_mct.c b/drivers/clocksource/exynos_mct.c index f71d55f5e6e5..ab51bf20a3ed 100644 --- a/drivers/clocksource/exynos_mct.c +++ b/drivers/clocksource/exynos_mct.c | |||
| @@ -162,7 +162,7 @@ static void exynos4_mct_frc_start(void) | |||
| 162 | exynos4_mct_write(reg, EXYNOS4_MCT_G_TCON); | 162 | exynos4_mct_write(reg, EXYNOS4_MCT_G_TCON); |
| 163 | } | 163 | } |
| 164 | 164 | ||
| 165 | static cycle_t exynos4_frc_read(struct clocksource *cs) | 165 | static cycle_t notrace _exynos4_frc_read(void) |
| 166 | { | 166 | { |
| 167 | unsigned int lo, hi; | 167 | unsigned int lo, hi; |
| 168 | u32 hi2 = __raw_readl(reg_base + EXYNOS4_MCT_G_CNT_U); | 168 | u32 hi2 = __raw_readl(reg_base + EXYNOS4_MCT_G_CNT_U); |
| @@ -176,6 +176,11 @@ static cycle_t exynos4_frc_read(struct clocksource *cs) | |||
| 176 | return ((cycle_t)hi << 32) | lo; | 176 | return ((cycle_t)hi << 32) | lo; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | static cycle_t exynos4_frc_read(struct clocksource *cs) | ||
| 180 | { | ||
| 181 | return _exynos4_frc_read(); | ||
| 182 | } | ||
| 183 | |||
| 179 | static void exynos4_frc_resume(struct clocksource *cs) | 184 | static void exynos4_frc_resume(struct clocksource *cs) |
| 180 | { | 185 | { |
| 181 | exynos4_mct_frc_start(); | 186 | exynos4_mct_frc_start(); |
| @@ -192,13 +197,24 @@ struct clocksource mct_frc = { | |||
| 192 | 197 | ||
| 193 | static u64 notrace exynos4_read_sched_clock(void) | 198 | static u64 notrace exynos4_read_sched_clock(void) |
| 194 | { | 199 | { |
| 195 | return exynos4_frc_read(&mct_frc); | 200 | return _exynos4_frc_read(); |
| 201 | } | ||
| 202 | |||
| 203 | static struct delay_timer exynos4_delay_timer; | ||
| 204 | |||
| 205 | static cycles_t exynos4_read_current_timer(void) | ||
| 206 | { | ||
| 207 | return _exynos4_frc_read(); | ||
| 196 | } | 208 | } |
| 197 | 209 | ||
| 198 | static void __init exynos4_clocksource_init(void) | 210 | static void __init exynos4_clocksource_init(void) |
| 199 | { | 211 | { |
| 200 | exynos4_mct_frc_start(); | 212 | exynos4_mct_frc_start(); |
| 201 | 213 | ||
| 214 | exynos4_delay_timer.read_current_timer = &exynos4_read_current_timer; | ||
| 215 | exynos4_delay_timer.freq = clk_rate; | ||
| 216 | register_current_timer_delay(&exynos4_delay_timer); | ||
| 217 | |||
| 202 | if (clocksource_register_hz(&mct_frc, clk_rate)) | 218 | if (clocksource_register_hz(&mct_frc, clk_rate)) |
| 203 | panic("%s: can't register clocksource\n", mct_frc.name); | 219 | panic("%s: can't register clocksource\n", mct_frc.name); |
| 204 | 220 | ||
diff --git a/drivers/cpufreq/Kconfig.arm b/drivers/cpufreq/Kconfig.arm index ebac67115009..7364a538e056 100644 --- a/drivers/cpufreq/Kconfig.arm +++ b/drivers/cpufreq/Kconfig.arm | |||
| @@ -104,6 +104,7 @@ config ARM_IMX6Q_CPUFREQ | |||
| 104 | tristate "Freescale i.MX6 cpufreq support" | 104 | tristate "Freescale i.MX6 cpufreq support" |
| 105 | depends on ARCH_MXC | 105 | depends on ARCH_MXC |
| 106 | depends on REGULATOR_ANATOP | 106 | depends on REGULATOR_ANATOP |
| 107 | select PM_OPP | ||
| 107 | help | 108 | help |
| 108 | This adds cpufreq driver support for Freescale i.MX6 series SoCs. | 109 | This adds cpufreq driver support for Freescale i.MX6 series SoCs. |
| 109 | 110 | ||
| @@ -118,7 +119,7 @@ config ARM_INTEGRATOR | |||
| 118 | If in doubt, say Y. | 119 | If in doubt, say Y. |
| 119 | 120 | ||
| 120 | config ARM_KIRKWOOD_CPUFREQ | 121 | config ARM_KIRKWOOD_CPUFREQ |
| 121 | def_bool MACH_KIRKWOOD | 122 | def_bool ARCH_KIRKWOOD || MACH_KIRKWOOD |
| 122 | help | 123 | help |
| 123 | This adds the CPUFreq driver for Marvell Kirkwood | 124 | This adds the CPUFreq driver for Marvell Kirkwood |
| 124 | SoCs. | 125 | SoCs. |
diff --git a/drivers/cpufreq/Makefile b/drivers/cpufreq/Makefile index 738c8b7b17dc..db6d9a2fea4d 100644 --- a/drivers/cpufreq/Makefile +++ b/drivers/cpufreq/Makefile | |||
| @@ -49,7 +49,7 @@ obj-$(CONFIG_ARM_BIG_LITTLE_CPUFREQ) += arm_big_little.o | |||
| 49 | # LITTLE drivers, so that it is probed last. | 49 | # LITTLE drivers, so that it is probed last. |
| 50 | obj-$(CONFIG_ARM_DT_BL_CPUFREQ) += arm_big_little_dt.o | 50 | obj-$(CONFIG_ARM_DT_BL_CPUFREQ) += arm_big_little_dt.o |
| 51 | 51 | ||
| 52 | obj-$(CONFIG_ARCH_DAVINCI_DA850) += davinci-cpufreq.o | 52 | obj-$(CONFIG_ARCH_DAVINCI) += davinci-cpufreq.o |
| 53 | obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o | 53 | obj-$(CONFIG_UX500_SOC_DB8500) += dbx500-cpufreq.o |
| 54 | obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o | 54 | obj-$(CONFIG_ARM_EXYNOS_CPUFREQ) += exynos-cpufreq.o |
| 55 | obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o | 55 | obj-$(CONFIG_ARM_EXYNOS4210_CPUFREQ) += exynos4210-cpufreq.o |
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c index ee1ae303a07c..86beda9f950b 100644 --- a/drivers/cpufreq/cpufreq-cpu0.c +++ b/drivers/cpufreq/cpufreq-cpu0.c | |||
| @@ -152,11 +152,8 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev) | |||
| 152 | goto out_put_reg; | 152 | goto out_put_reg; |
| 153 | } | 153 | } |
| 154 | 154 | ||
| 155 | ret = of_init_opp_table(cpu_dev); | 155 | /* OPPs might be populated at runtime, don't check for error here */ |
| 156 | if (ret) { | 156 | of_init_opp_table(cpu_dev); |
| 157 | pr_err("failed to init OPP table: %d\n", ret); | ||
| 158 | goto out_put_clk; | ||
| 159 | } | ||
| 160 | 157 | ||
| 161 | ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); | 158 | ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table); |
| 162 | if (ret) { | 159 | if (ret) { |
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 62259d27f03e..6f024852c6fb 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c | |||
| @@ -1153,10 +1153,12 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif) | |||
| 1153 | * the creation of a brand new one. So we need to perform this update | 1153 | * the creation of a brand new one. So we need to perform this update |
| 1154 | * by invoking update_policy_cpu(). | 1154 | * by invoking update_policy_cpu(). |
| 1155 | */ | 1155 | */ |
| 1156 | if (recover_policy && cpu != policy->cpu) | 1156 | if (recover_policy && cpu != policy->cpu) { |
| 1157 | update_policy_cpu(policy, cpu); | 1157 | update_policy_cpu(policy, cpu); |
| 1158 | else | 1158 | WARN_ON(kobject_move(&policy->kobj, &dev->kobj)); |
| 1159 | } else { | ||
| 1159 | policy->cpu = cpu; | 1160 | policy->cpu = cpu; |
| 1161 | } | ||
| 1160 | 1162 | ||
| 1161 | cpumask_copy(policy->cpus, cpumask_of(cpu)); | 1163 | cpumask_copy(policy->cpus, cpumask_of(cpu)); |
| 1162 | 1164 | ||
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 924bb2d42b1c..86631cb6f7de 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -128,6 +128,7 @@ static struct pstate_funcs pstate_funcs; | |||
| 128 | 128 | ||
| 129 | struct perf_limits { | 129 | struct perf_limits { |
| 130 | int no_turbo; | 130 | int no_turbo; |
| 131 | int turbo_disabled; | ||
| 131 | int max_perf_pct; | 132 | int max_perf_pct; |
| 132 | int min_perf_pct; | 133 | int min_perf_pct; |
| 133 | int32_t max_perf; | 134 | int32_t max_perf; |
| @@ -287,7 +288,10 @@ static ssize_t store_no_turbo(struct kobject *a, struct attribute *b, | |||
| 287 | if (ret != 1) | 288 | if (ret != 1) |
| 288 | return -EINVAL; | 289 | return -EINVAL; |
| 289 | limits.no_turbo = clamp_t(int, input, 0 , 1); | 290 | limits.no_turbo = clamp_t(int, input, 0 , 1); |
| 290 | 291 | if (limits.turbo_disabled) { | |
| 292 | pr_warn("Turbo disabled by BIOS or unavailable on processor\n"); | ||
| 293 | limits.no_turbo = limits.turbo_disabled; | ||
| 294 | } | ||
| 291 | return count; | 295 | return count; |
| 292 | } | 296 | } |
| 293 | 297 | ||
| @@ -357,21 +361,21 @@ static int byt_get_min_pstate(void) | |||
| 357 | { | 361 | { |
| 358 | u64 value; | 362 | u64 value; |
| 359 | rdmsrl(BYT_RATIOS, value); | 363 | rdmsrl(BYT_RATIOS, value); |
| 360 | return (value >> 8) & 0x3F; | 364 | return (value >> 8) & 0x7F; |
| 361 | } | 365 | } |
| 362 | 366 | ||
| 363 | static int byt_get_max_pstate(void) | 367 | static int byt_get_max_pstate(void) |
| 364 | { | 368 | { |
| 365 | u64 value; | 369 | u64 value; |
| 366 | rdmsrl(BYT_RATIOS, value); | 370 | rdmsrl(BYT_RATIOS, value); |
| 367 | return (value >> 16) & 0x3F; | 371 | return (value >> 16) & 0x7F; |
| 368 | } | 372 | } |
| 369 | 373 | ||
| 370 | static int byt_get_turbo_pstate(void) | 374 | static int byt_get_turbo_pstate(void) |
| 371 | { | 375 | { |
| 372 | u64 value; | 376 | u64 value; |
| 373 | rdmsrl(BYT_TURBO_RATIOS, value); | 377 | rdmsrl(BYT_TURBO_RATIOS, value); |
| 374 | return value & 0x3F; | 378 | return value & 0x7F; |
| 375 | } | 379 | } |
| 376 | 380 | ||
| 377 | static void byt_set_pstate(struct cpudata *cpudata, int pstate) | 381 | static void byt_set_pstate(struct cpudata *cpudata, int pstate) |
| @@ -381,7 +385,7 @@ static void byt_set_pstate(struct cpudata *cpudata, int pstate) | |||
| 381 | u32 vid; | 385 | u32 vid; |
| 382 | 386 | ||
| 383 | val = pstate << 8; | 387 | val = pstate << 8; |
| 384 | if (limits.no_turbo) | 388 | if (limits.no_turbo && !limits.turbo_disabled) |
| 385 | val |= (u64)1 << 32; | 389 | val |= (u64)1 << 32; |
| 386 | 390 | ||
| 387 | vid_fp = cpudata->vid.min + mul_fp( | 391 | vid_fp = cpudata->vid.min + mul_fp( |
| @@ -405,8 +409,8 @@ static void byt_get_vid(struct cpudata *cpudata) | |||
| 405 | 409 | ||
| 406 | 410 | ||
| 407 | rdmsrl(BYT_VIDS, value); | 411 | rdmsrl(BYT_VIDS, value); |
| 408 | cpudata->vid.min = int_tofp((value >> 8) & 0x3f); | 412 | cpudata->vid.min = int_tofp((value >> 8) & 0x7f); |
| 409 | cpudata->vid.max = int_tofp((value >> 16) & 0x3f); | 413 | cpudata->vid.max = int_tofp((value >> 16) & 0x7f); |
| 410 | cpudata->vid.ratio = div_fp( | 414 | cpudata->vid.ratio = div_fp( |
| 411 | cpudata->vid.max - cpudata->vid.min, | 415 | cpudata->vid.max - cpudata->vid.min, |
| 412 | int_tofp(cpudata->pstate.max_pstate - | 416 | int_tofp(cpudata->pstate.max_pstate - |
| @@ -448,7 +452,7 @@ static void core_set_pstate(struct cpudata *cpudata, int pstate) | |||
| 448 | u64 val; | 452 | u64 val; |
| 449 | 453 | ||
| 450 | val = pstate << 8; | 454 | val = pstate << 8; |
| 451 | if (limits.no_turbo) | 455 | if (limits.no_turbo && !limits.turbo_disabled) |
| 452 | val |= (u64)1 << 32; | 456 | val |= (u64)1 << 32; |
| 453 | 457 | ||
| 454 | wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val); | 458 | wrmsrl_on_cpu(cpudata->cpu, MSR_IA32_PERF_CTL, val); |
| @@ -696,9 +700,8 @@ static int intel_pstate_init_cpu(unsigned int cpunum) | |||
| 696 | 700 | ||
| 697 | cpu = all_cpu_data[cpunum]; | 701 | cpu = all_cpu_data[cpunum]; |
| 698 | 702 | ||
| 699 | intel_pstate_get_cpu_pstates(cpu); | ||
| 700 | |||
| 701 | cpu->cpu = cpunum; | 703 | cpu->cpu = cpunum; |
| 704 | intel_pstate_get_cpu_pstates(cpu); | ||
| 702 | 705 | ||
| 703 | init_timer_deferrable(&cpu->timer); | 706 | init_timer_deferrable(&cpu->timer); |
| 704 | cpu->timer.function = intel_pstate_timer_func; | 707 | cpu->timer.function = intel_pstate_timer_func; |
| @@ -741,7 +744,7 @@ static int intel_pstate_set_policy(struct cpufreq_policy *policy) | |||
| 741 | limits.min_perf = int_tofp(1); | 744 | limits.min_perf = int_tofp(1); |
| 742 | limits.max_perf_pct = 100; | 745 | limits.max_perf_pct = 100; |
| 743 | limits.max_perf = int_tofp(1); | 746 | limits.max_perf = int_tofp(1); |
| 744 | limits.no_turbo = 0; | 747 | limits.no_turbo = limits.turbo_disabled; |
| 745 | return 0; | 748 | return 0; |
| 746 | } | 749 | } |
| 747 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; | 750 | limits.min_perf_pct = (policy->min * 100) / policy->cpuinfo.max_freq; |
| @@ -784,6 +787,7 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | |||
| 784 | { | 787 | { |
| 785 | struct cpudata *cpu; | 788 | struct cpudata *cpu; |
| 786 | int rc; | 789 | int rc; |
| 790 | u64 misc_en; | ||
| 787 | 791 | ||
| 788 | rc = intel_pstate_init_cpu(policy->cpu); | 792 | rc = intel_pstate_init_cpu(policy->cpu); |
| 789 | if (rc) | 793 | if (rc) |
| @@ -791,8 +795,13 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | |||
| 791 | 795 | ||
| 792 | cpu = all_cpu_data[policy->cpu]; | 796 | cpu = all_cpu_data[policy->cpu]; |
| 793 | 797 | ||
| 794 | if (!limits.no_turbo && | 798 | rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); |
| 795 | limits.min_perf_pct == 100 && limits.max_perf_pct == 100) | 799 | if (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || |
| 800 | cpu->pstate.max_pstate == cpu->pstate.turbo_pstate) { | ||
| 801 | limits.turbo_disabled = 1; | ||
| 802 | limits.no_turbo = 1; | ||
| 803 | } | ||
| 804 | if (limits.min_perf_pct == 100 && limits.max_perf_pct == 100) | ||
| 796 | policy->policy = CPUFREQ_POLICY_PERFORMANCE; | 805 | policy->policy = CPUFREQ_POLICY_PERFORMANCE; |
| 797 | else | 806 | else |
| 798 | policy->policy = CPUFREQ_POLICY_POWERSAVE; | 807 | policy->policy = CPUFREQ_POLICY_POWERSAVE; |
diff --git a/drivers/cpufreq/sa1110-cpufreq.c b/drivers/cpufreq/sa1110-cpufreq.c index 546376719d8f..b5befc211172 100644 --- a/drivers/cpufreq/sa1110-cpufreq.c +++ b/drivers/cpufreq/sa1110-cpufreq.c | |||
| @@ -349,7 +349,7 @@ static int __init sa1110_clk_init(void) | |||
| 349 | name = "K4S641632D"; | 349 | name = "K4S641632D"; |
| 350 | if (machine_is_h3100()) | 350 | if (machine_is_h3100()) |
| 351 | name = "KM416S4030CT"; | 351 | name = "KM416S4030CT"; |
| 352 | if (machine_is_jornada720()) | 352 | if (machine_is_jornada720() || machine_is_h3600()) |
| 353 | name = "K4S281632B-1H"; | 353 | name = "K4S281632B-1H"; |
| 354 | if (machine_is_nanoengine()) | 354 | if (machine_is_nanoengine()) |
| 355 | name = "MT48LC8M16A2TG-75"; | 355 | name = "MT48LC8M16A2TG-75"; |
diff --git a/drivers/crypto/caam/jr.c b/drivers/crypto/caam/jr.c index 1d80bd3636c5..b512a4ba7569 100644 --- a/drivers/crypto/caam/jr.c +++ b/drivers/crypto/caam/jr.c | |||
| @@ -453,8 +453,8 @@ static int caam_jr_probe(struct platform_device *pdev) | |||
| 453 | int error; | 453 | int error; |
| 454 | 454 | ||
| 455 | jrdev = &pdev->dev; | 455 | jrdev = &pdev->dev; |
| 456 | jrpriv = kmalloc(sizeof(struct caam_drv_private_jr), | 456 | jrpriv = devm_kmalloc(jrdev, sizeof(struct caam_drv_private_jr), |
| 457 | GFP_KERNEL); | 457 | GFP_KERNEL); |
| 458 | if (!jrpriv) | 458 | if (!jrpriv) |
| 459 | return -ENOMEM; | 459 | return -ENOMEM; |
| 460 | 460 | ||
| @@ -487,10 +487,8 @@ static int caam_jr_probe(struct platform_device *pdev) | |||
| 487 | 487 | ||
| 488 | /* Now do the platform independent part */ | 488 | /* Now do the platform independent part */ |
| 489 | error = caam_jr_init(jrdev); /* now turn on hardware */ | 489 | error = caam_jr_init(jrdev); /* now turn on hardware */ |
| 490 | if (error) { | 490 | if (error) |
| 491 | kfree(jrpriv); | ||
| 492 | return error; | 491 | return error; |
| 493 | } | ||
| 494 | 492 | ||
| 495 | jrpriv->dev = jrdev; | 493 | jrpriv->dev = jrdev; |
| 496 | spin_lock(&driver_data.jr_alloc_lock); | 494 | spin_lock(&driver_data.jr_alloc_lock); |
diff --git a/drivers/dma/cppi41.c b/drivers/dma/cppi41.c index d028f36ae655..8f8b0b608875 100644 --- a/drivers/dma/cppi41.c +++ b/drivers/dma/cppi41.c | |||
| @@ -86,6 +86,9 @@ | |||
| 86 | 86 | ||
| 87 | #define USBSS_IRQ_PD_COMP (1 << 2) | 87 | #define USBSS_IRQ_PD_COMP (1 << 2) |
| 88 | 88 | ||
| 89 | /* Packet Descriptor */ | ||
| 90 | #define PD2_ZERO_LENGTH (1 << 19) | ||
| 91 | |||
| 89 | struct cppi41_channel { | 92 | struct cppi41_channel { |
| 90 | struct dma_chan chan; | 93 | struct dma_chan chan; |
| 91 | struct dma_async_tx_descriptor txd; | 94 | struct dma_async_tx_descriptor txd; |
| @@ -307,7 +310,7 @@ static irqreturn_t cppi41_irq(int irq, void *data) | |||
| 307 | __iormb(); | 310 | __iormb(); |
| 308 | 311 | ||
| 309 | while (val) { | 312 | while (val) { |
| 310 | u32 desc; | 313 | u32 desc, len; |
| 311 | 314 | ||
| 312 | q_num = __fls(val); | 315 | q_num = __fls(val); |
| 313 | val &= ~(1 << q_num); | 316 | val &= ~(1 << q_num); |
| @@ -319,9 +322,13 @@ static irqreturn_t cppi41_irq(int irq, void *data) | |||
| 319 | q_num, desc); | 322 | q_num, desc); |
| 320 | continue; | 323 | continue; |
| 321 | } | 324 | } |
| 322 | c->residue = pd_trans_len(c->desc->pd6) - | ||
| 323 | pd_trans_len(c->desc->pd0); | ||
| 324 | 325 | ||
| 326 | if (c->desc->pd2 & PD2_ZERO_LENGTH) | ||
| 327 | len = 0; | ||
| 328 | else | ||
| 329 | len = pd_trans_len(c->desc->pd0); | ||
| 330 | |||
| 331 | c->residue = pd_trans_len(c->desc->pd6) - len; | ||
| 325 | dma_cookie_complete(&c->txd); | 332 | dma_cookie_complete(&c->txd); |
| 326 | c->txd.callback(c->txd.callback_param); | 333 | c->txd.callback(c->txd.callback_param); |
| 327 | } | 334 | } |
diff --git a/drivers/dma/edma.c b/drivers/dma/edma.c index d08c4dedef35..b512caf46944 100644 --- a/drivers/dma/edma.c +++ b/drivers/dma/edma.c | |||
| @@ -982,6 +982,7 @@ static void __init edma_chan_init(struct edma_cc *ecc, | |||
| 982 | 982 | ||
| 983 | #define EDMA_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ | 983 | #define EDMA_DMA_BUSWIDTHS (BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | \ |
| 984 | BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ | 984 | BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | \ |
| 985 | BIT(DMA_SLAVE_BUSWIDTH_3_BYTES) | \ | ||
| 985 | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES)) | 986 | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES)) |
| 986 | 987 | ||
| 987 | static int edma_dma_device_slave_caps(struct dma_chan *dchan, | 988 | static int edma_dma_device_slave_caps(struct dma_chan *dchan, |
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 128714622bf5..14867e3ac8ff 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c | |||
| @@ -255,6 +255,7 @@ struct sdma_channel { | |||
| 255 | enum dma_slave_buswidth word_size; | 255 | enum dma_slave_buswidth word_size; |
| 256 | unsigned int buf_tail; | 256 | unsigned int buf_tail; |
| 257 | unsigned int num_bd; | 257 | unsigned int num_bd; |
| 258 | unsigned int period_len; | ||
| 258 | struct sdma_buffer_descriptor *bd; | 259 | struct sdma_buffer_descriptor *bd; |
| 259 | dma_addr_t bd_phys; | 260 | dma_addr_t bd_phys; |
| 260 | unsigned int pc_from_device, pc_to_device; | 261 | unsigned int pc_from_device, pc_to_device; |
| @@ -593,6 +594,12 @@ static void sdma_event_disable(struct sdma_channel *sdmac, unsigned int event) | |||
| 593 | 594 | ||
| 594 | static void sdma_handle_channel_loop(struct sdma_channel *sdmac) | 595 | static void sdma_handle_channel_loop(struct sdma_channel *sdmac) |
| 595 | { | 596 | { |
| 597 | if (sdmac->desc.callback) | ||
| 598 | sdmac->desc.callback(sdmac->desc.callback_param); | ||
| 599 | } | ||
| 600 | |||
| 601 | static void sdma_update_channel_loop(struct sdma_channel *sdmac) | ||
| 602 | { | ||
| 596 | struct sdma_buffer_descriptor *bd; | 603 | struct sdma_buffer_descriptor *bd; |
| 597 | 604 | ||
| 598 | /* | 605 | /* |
| @@ -611,9 +618,6 @@ static void sdma_handle_channel_loop(struct sdma_channel *sdmac) | |||
| 611 | bd->mode.status |= BD_DONE; | 618 | bd->mode.status |= BD_DONE; |
| 612 | sdmac->buf_tail++; | 619 | sdmac->buf_tail++; |
| 613 | sdmac->buf_tail %= sdmac->num_bd; | 620 | sdmac->buf_tail %= sdmac->num_bd; |
| 614 | |||
| 615 | if (sdmac->desc.callback) | ||
| 616 | sdmac->desc.callback(sdmac->desc.callback_param); | ||
| 617 | } | 621 | } |
| 618 | } | 622 | } |
| 619 | 623 | ||
| @@ -669,6 +673,9 @@ static irqreturn_t sdma_int_handler(int irq, void *dev_id) | |||
| 669 | int channel = fls(stat) - 1; | 673 | int channel = fls(stat) - 1; |
| 670 | struct sdma_channel *sdmac = &sdma->channel[channel]; | 674 | struct sdma_channel *sdmac = &sdma->channel[channel]; |
| 671 | 675 | ||
| 676 | if (sdmac->flags & IMX_DMA_SG_LOOP) | ||
| 677 | sdma_update_channel_loop(sdmac); | ||
| 678 | |||
| 672 | tasklet_schedule(&sdmac->tasklet); | 679 | tasklet_schedule(&sdmac->tasklet); |
| 673 | 680 | ||
| 674 | __clear_bit(channel, &stat); | 681 | __clear_bit(channel, &stat); |
| @@ -1129,6 +1136,7 @@ static struct dma_async_tx_descriptor *sdma_prep_dma_cyclic( | |||
| 1129 | sdmac->status = DMA_IN_PROGRESS; | 1136 | sdmac->status = DMA_IN_PROGRESS; |
| 1130 | 1137 | ||
| 1131 | sdmac->buf_tail = 0; | 1138 | sdmac->buf_tail = 0; |
| 1139 | sdmac->period_len = period_len; | ||
| 1132 | 1140 | ||
| 1133 | sdmac->flags |= IMX_DMA_SG_LOOP; | 1141 | sdmac->flags |= IMX_DMA_SG_LOOP; |
| 1134 | sdmac->direction = direction; | 1142 | sdmac->direction = direction; |
| @@ -1225,9 +1233,15 @@ static enum dma_status sdma_tx_status(struct dma_chan *chan, | |||
| 1225 | struct dma_tx_state *txstate) | 1233 | struct dma_tx_state *txstate) |
| 1226 | { | 1234 | { |
| 1227 | struct sdma_channel *sdmac = to_sdma_chan(chan); | 1235 | struct sdma_channel *sdmac = to_sdma_chan(chan); |
| 1236 | u32 residue; | ||
| 1237 | |||
| 1238 | if (sdmac->flags & IMX_DMA_SG_LOOP) | ||
| 1239 | residue = (sdmac->num_bd - sdmac->buf_tail) * sdmac->period_len; | ||
| 1240 | else | ||
| 1241 | residue = sdmac->chn_count - sdmac->chn_real_count; | ||
| 1228 | 1242 | ||
| 1229 | dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie, | 1243 | dma_set_tx_state(txstate, chan->completed_cookie, chan->cookie, |
| 1230 | sdmac->chn_count - sdmac->chn_real_count); | 1244 | residue); |
| 1231 | 1245 | ||
| 1232 | return sdmac->status; | 1246 | return sdmac->status; |
| 1233 | } | 1247 | } |
diff --git a/drivers/firewire/Kconfig b/drivers/firewire/Kconfig index 4199849e3758..145974f9662b 100644 --- a/drivers/firewire/Kconfig +++ b/drivers/firewire/Kconfig | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | menu "IEEE 1394 (FireWire) support" | 1 | menu "IEEE 1394 (FireWire) support" |
| 2 | depends on HAS_DMA | ||
| 2 | depends on PCI || COMPILE_TEST | 3 | depends on PCI || COMPILE_TEST |
| 3 | # firewire-core does not depend on PCI but is | 4 | # firewire-core does not depend on PCI but is |
| 4 | # not useful without PCI controller driver | 5 | # not useful without PCI controller driver |
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index 57985410f12f..a66a3217f1d9 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
| @@ -336,10 +336,10 @@ static const struct { | |||
| 336 | QUIRK_CYCLE_TIMER | QUIRK_IR_WAKE}, | 336 | QUIRK_CYCLE_TIMER | QUIRK_IR_WAKE}, |
| 337 | 337 | ||
| 338 | {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT6315, 0, | 338 | {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT6315, 0, |
| 339 | QUIRK_CYCLE_TIMER | QUIRK_NO_MSI}, | 339 | QUIRK_CYCLE_TIMER /* FIXME: necessary? */ | QUIRK_NO_MSI}, |
| 340 | 340 | ||
| 341 | {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT6315, PCI_ANY_ID, | 341 | {PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_VT6315, PCI_ANY_ID, |
| 342 | 0}, | 342 | QUIRK_NO_MSI}, |
| 343 | 343 | ||
| 344 | {PCI_VENDOR_ID_VIA, PCI_ANY_ID, PCI_ANY_ID, | 344 | {PCI_VENDOR_ID_VIA, PCI_ANY_ID, PCI_ANY_ID, |
| 345 | QUIRK_CYCLE_TIMER | QUIRK_NO_MSI}, | 345 | QUIRK_CYCLE_TIMER | QUIRK_NO_MSI}, |
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c index eff1a2f22f09..dc79346689e6 100644 --- a/drivers/firmware/efi/efi.c +++ b/drivers/firmware/efi/efi.c | |||
| @@ -346,6 +346,7 @@ static __initdata struct { | |||
| 346 | 346 | ||
| 347 | struct param_info { | 347 | struct param_info { |
| 348 | int verbose; | 348 | int verbose; |
| 349 | int found; | ||
| 349 | void *params; | 350 | void *params; |
| 350 | }; | 351 | }; |
| 351 | 352 | ||
| @@ -362,16 +363,12 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname, | |||
| 362 | (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) | 363 | (strcmp(uname, "chosen") != 0 && strcmp(uname, "chosen@0") != 0)) |
| 363 | return 0; | 364 | return 0; |
| 364 | 365 | ||
| 365 | pr_info("Getting parameters from FDT:\n"); | ||
| 366 | |||
| 367 | for (i = 0; i < ARRAY_SIZE(dt_params); i++) { | 366 | for (i = 0; i < ARRAY_SIZE(dt_params); i++) { |
| 368 | prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); | 367 | prop = of_get_flat_dt_prop(node, dt_params[i].propname, &len); |
| 369 | if (!prop) { | 368 | if (!prop) |
| 370 | pr_err("Can't find %s in device tree!\n", | ||
| 371 | dt_params[i].name); | ||
| 372 | return 0; | 369 | return 0; |
| 373 | } | ||
| 374 | dest = info->params + dt_params[i].offset; | 370 | dest = info->params + dt_params[i].offset; |
| 371 | info->found++; | ||
| 375 | 372 | ||
| 376 | val = of_read_number(prop, len / sizeof(u32)); | 373 | val = of_read_number(prop, len / sizeof(u32)); |
| 377 | 374 | ||
| @@ -390,10 +387,21 @@ static int __init fdt_find_uefi_params(unsigned long node, const char *uname, | |||
| 390 | int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose) | 387 | int __init efi_get_fdt_params(struct efi_fdt_params *params, int verbose) |
| 391 | { | 388 | { |
| 392 | struct param_info info; | 389 | struct param_info info; |
| 390 | int ret; | ||
| 391 | |||
| 392 | pr_info("Getting EFI parameters from FDT:\n"); | ||
| 393 | 393 | ||
| 394 | info.verbose = verbose; | 394 | info.verbose = verbose; |
| 395 | info.found = 0; | ||
| 395 | info.params = params; | 396 | info.params = params; |
| 396 | 397 | ||
| 397 | return of_scan_flat_dt(fdt_find_uefi_params, &info); | 398 | ret = of_scan_flat_dt(fdt_find_uefi_params, &info); |
| 399 | if (!info.found) | ||
| 400 | pr_info("UEFI not found.\n"); | ||
| 401 | else if (!ret) | ||
| 402 | pr_err("Can't find '%s' in device tree!\n", | ||
| 403 | dt_params[info.found].name); | ||
| 404 | |||
| 405 | return ret; | ||
| 398 | } | 406 | } |
| 399 | #endif /* CONFIG_EFI_PARAMS_FROM_FDT */ | 407 | #endif /* CONFIG_EFI_PARAMS_FROM_FDT */ |
diff --git a/drivers/firmware/efi/fdt.c b/drivers/firmware/efi/fdt.c index 82d774161cc9..507a3df46a5d 100644 --- a/drivers/firmware/efi/fdt.c +++ b/drivers/firmware/efi/fdt.c | |||
| @@ -23,16 +23,6 @@ static efi_status_t update_fdt(efi_system_table_t *sys_table, void *orig_fdt, | |||
| 23 | u32 fdt_val32; | 23 | u32 fdt_val32; |
| 24 | u64 fdt_val64; | 24 | u64 fdt_val64; |
| 25 | 25 | ||
| 26 | /* | ||
| 27 | * Copy definition of linux_banner here. Since this code is | ||
| 28 | * built as part of the decompressor for ARM v7, pulling | ||
| 29 | * in version.c where linux_banner is defined for the | ||
| 30 | * kernel brings other kernel dependencies with it. | ||
| 31 | */ | ||
| 32 | const char linux_banner[] = | ||
| 33 | "Linux version " UTS_RELEASE " (" LINUX_COMPILE_BY "@" | ||
| 34 | LINUX_COMPILE_HOST ") (" LINUX_COMPILER ") " UTS_VERSION "\n"; | ||
| 35 | |||
| 36 | /* Do some checks on provided FDT, if it exists*/ | 26 | /* Do some checks on provided FDT, if it exists*/ |
| 37 | if (orig_fdt) { | 27 | if (orig_fdt) { |
| 38 | if (fdt_check_header(orig_fdt)) { | 28 | if (fdt_check_header(orig_fdt)) { |
diff --git a/drivers/gpio/gpio-mcp23s08.c b/drivers/gpio/gpio-mcp23s08.c index fe7c0e211f9a..57adbc90fdad 100644 --- a/drivers/gpio/gpio-mcp23s08.c +++ b/drivers/gpio/gpio-mcp23s08.c | |||
| @@ -900,8 +900,6 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
| 900 | if (spi_present_mask & (1 << addr)) | 900 | if (spi_present_mask & (1 << addr)) |
| 901 | chips++; | 901 | chips++; |
| 902 | } | 902 | } |
| 903 | if (!chips) | ||
| 904 | return -ENODEV; | ||
| 905 | } else { | 903 | } else { |
| 906 | type = spi_get_device_id(spi)->driver_data; | 904 | type = spi_get_device_id(spi)->driver_data; |
| 907 | pdata = dev_get_platdata(&spi->dev); | 905 | pdata = dev_get_platdata(&spi->dev); |
| @@ -940,10 +938,6 @@ static int mcp23s08_probe(struct spi_device *spi) | |||
| 940 | if (!(spi_present_mask & (1 << addr))) | 938 | if (!(spi_present_mask & (1 << addr))) |
| 941 | continue; | 939 | continue; |
| 942 | chips--; | 940 | chips--; |
| 943 | if (chips < 0) { | ||
| 944 | dev_err(&spi->dev, "FATAL: invalid negative chip id\n"); | ||
| 945 | goto fail; | ||
| 946 | } | ||
| 947 | data->mcp[addr] = &data->chip[chips]; | 941 | data->mcp[addr] = &data->chip[chips]; |
| 948 | status = mcp23s08_probe_one(data->mcp[addr], &spi->dev, spi, | 942 | status = mcp23s08_probe_one(data->mcp[addr], &spi->dev, spi, |
| 949 | 0x40 | (addr << 1), type, base, | 943 | 0x40 | (addr << 1), type, base, |
diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 0c9f803fc1ac..b6ae89ea8811 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c | |||
| @@ -284,6 +284,7 @@ static int gpio_rcar_irq_domain_map(struct irq_domain *h, unsigned int irq, | |||
| 284 | 284 | ||
| 285 | static struct irq_domain_ops gpio_rcar_irq_domain_ops = { | 285 | static struct irq_domain_ops gpio_rcar_irq_domain_ops = { |
| 286 | .map = gpio_rcar_irq_domain_map, | 286 | .map = gpio_rcar_irq_domain_map, |
| 287 | .xlate = irq_domain_xlate_twocell, | ||
| 287 | }; | 288 | }; |
| 288 | 289 | ||
| 289 | struct gpio_rcar_info { | 290 | struct gpio_rcar_info { |
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 6c656392d67d..d44344140627 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
| @@ -1464,12 +1464,13 @@ static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv) | |||
| 1464 | #else | 1464 | #else |
| 1465 | static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv) | 1465 | static int i915_kick_out_vgacon(struct drm_i915_private *dev_priv) |
| 1466 | { | 1466 | { |
| 1467 | int ret; | 1467 | int ret = 0; |
| 1468 | 1468 | ||
| 1469 | DRM_INFO("Replacing VGA console driver\n"); | 1469 | DRM_INFO("Replacing VGA console driver\n"); |
| 1470 | 1470 | ||
| 1471 | console_lock(); | 1471 | console_lock(); |
| 1472 | ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1); | 1472 | if (con_is_bound(&vga_con)) |
| 1473 | ret = do_take_over_console(&dummy_con, 0, MAX_NR_CONSOLES - 1, 1); | ||
| 1473 | if (ret == 0) { | 1474 | if (ret == 0) { |
| 1474 | ret = do_unregister_con_driver(&vga_con); | 1475 | ret = do_unregister_con_driver(&vga_con); |
| 1475 | 1476 | ||
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a47fbf60b781..374f964323ad 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
| @@ -656,6 +656,7 @@ enum intel_sbi_destination { | |||
| 656 | #define QUIRK_PIPEA_FORCE (1<<0) | 656 | #define QUIRK_PIPEA_FORCE (1<<0) |
| 657 | #define QUIRK_LVDS_SSC_DISABLE (1<<1) | 657 | #define QUIRK_LVDS_SSC_DISABLE (1<<1) |
| 658 | #define QUIRK_INVERT_BRIGHTNESS (1<<2) | 658 | #define QUIRK_INVERT_BRIGHTNESS (1<<2) |
| 659 | #define QUIRK_BACKLIGHT_PRESENT (1<<3) | ||
| 659 | 660 | ||
| 660 | struct intel_fbdev; | 661 | struct intel_fbdev; |
| 661 | struct intel_fbc_work; | 662 | struct intel_fbc_work; |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index f36126383d26..d893e4da5dce 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
| @@ -1616,22 +1616,6 @@ out: | |||
| 1616 | return ret; | 1616 | return ret; |
| 1617 | } | 1617 | } |
| 1618 | 1618 | ||
| 1619 | void i915_gem_release_all_mmaps(struct drm_i915_private *dev_priv) | ||
| 1620 | { | ||
| 1621 | struct i915_vma *vma; | ||
| 1622 | |||
| 1623 | /* | ||
| 1624 | * Only the global gtt is relevant for gtt memory mappings, so restrict | ||
| 1625 | * list traversal to objects bound into the global address space. Note | ||
| 1626 | * that the active list should be empty, but better safe than sorry. | ||
| 1627 | */ | ||
| 1628 | WARN_ON(!list_empty(&dev_priv->gtt.base.active_list)); | ||
| 1629 | list_for_each_entry(vma, &dev_priv->gtt.base.active_list, mm_list) | ||
| 1630 | i915_gem_release_mmap(vma->obj); | ||
| 1631 | list_for_each_entry(vma, &dev_priv->gtt.base.inactive_list, mm_list) | ||
| 1632 | i915_gem_release_mmap(vma->obj); | ||
| 1633 | } | ||
| 1634 | |||
| 1635 | /** | 1619 | /** |
| 1636 | * i915_gem_release_mmap - remove physical page mappings | 1620 | * i915_gem_release_mmap - remove physical page mappings |
| 1637 | * @obj: obj in question | 1621 | * @obj: obj in question |
| @@ -1657,6 +1641,15 @@ i915_gem_release_mmap(struct drm_i915_gem_object *obj) | |||
| 1657 | obj->fault_mappable = false; | 1641 | obj->fault_mappable = false; |
| 1658 | } | 1642 | } |
| 1659 | 1643 | ||
| 1644 | void | ||
| 1645 | i915_gem_release_all_mmaps(struct drm_i915_private *dev_priv) | ||
| 1646 | { | ||
| 1647 | struct drm_i915_gem_object *obj; | ||
| 1648 | |||
| 1649 | list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) | ||
| 1650 | i915_gem_release_mmap(obj); | ||
| 1651 | } | ||
| 1652 | |||
| 1660 | uint32_t | 1653 | uint32_t |
| 1661 | i915_gem_get_gtt_size(struct drm_device *dev, uint32_t size, int tiling_mode) | 1654 | i915_gem_get_gtt_size(struct drm_device *dev, uint32_t size, int tiling_mode) |
| 1662 | { | 1655 | { |
diff --git a/drivers/gpu/drm/i915/i915_gem_render_state.c b/drivers/gpu/drm/i915/i915_gem_render_state.c index 3521f998a178..34894b573064 100644 --- a/drivers/gpu/drm/i915/i915_gem_render_state.c +++ b/drivers/gpu/drm/i915/i915_gem_render_state.c | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | struct i915_render_state { | 31 | struct i915_render_state { |
| 32 | struct drm_i915_gem_object *obj; | 32 | struct drm_i915_gem_object *obj; |
| 33 | unsigned long ggtt_offset; | 33 | unsigned long ggtt_offset; |
| 34 | void *batch; | 34 | u32 *batch; |
| 35 | u32 size; | 35 | u32 size; |
| 36 | u32 len; | 36 | u32 len; |
| 37 | }; | 37 | }; |
| @@ -80,7 +80,7 @@ free: | |||
| 80 | 80 | ||
| 81 | static void render_state_free(struct i915_render_state *so) | 81 | static void render_state_free(struct i915_render_state *so) |
| 82 | { | 82 | { |
| 83 | kunmap(so->batch); | 83 | kunmap(kmap_to_page(so->batch)); |
| 84 | i915_gem_object_ggtt_unpin(so->obj); | 84 | i915_gem_object_ggtt_unpin(so->obj); |
| 85 | drm_gem_object_unreference(&so->obj->base); | 85 | drm_gem_object_unreference(&so->obj->base); |
| 86 | kfree(so); | 86 | kfree(so); |
diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index 62ef55ba061c..7465ab0fd396 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c | |||
| @@ -74,6 +74,50 @@ static unsigned long i915_stolen_to_physical(struct drm_device *dev) | |||
| 74 | if (base == 0) | 74 | if (base == 0) |
| 75 | return 0; | 75 | return 0; |
| 76 | 76 | ||
| 77 | /* make sure we don't clobber the GTT if it's within stolen memory */ | ||
| 78 | if (INTEL_INFO(dev)->gen <= 4 && !IS_G33(dev) && !IS_G4X(dev)) { | ||
| 79 | struct { | ||
| 80 | u32 start, end; | ||
| 81 | } stolen[2] = { | ||
| 82 | { .start = base, .end = base + dev_priv->gtt.stolen_size, }, | ||
| 83 | { .start = base, .end = base + dev_priv->gtt.stolen_size, }, | ||
| 84 | }; | ||
| 85 | u64 gtt_start, gtt_end; | ||
| 86 | |||
| 87 | gtt_start = I915_READ(PGTBL_CTL); | ||
| 88 | if (IS_GEN4(dev)) | ||
| 89 | gtt_start = (gtt_start & PGTBL_ADDRESS_LO_MASK) | | ||
| 90 | (gtt_start & PGTBL_ADDRESS_HI_MASK) << 28; | ||
| 91 | else | ||
| 92 | gtt_start &= PGTBL_ADDRESS_LO_MASK; | ||
| 93 | gtt_end = gtt_start + gtt_total_entries(dev_priv->gtt) * 4; | ||
| 94 | |||
| 95 | if (gtt_start >= stolen[0].start && gtt_start < stolen[0].end) | ||
| 96 | stolen[0].end = gtt_start; | ||
| 97 | if (gtt_end > stolen[1].start && gtt_end <= stolen[1].end) | ||
| 98 | stolen[1].start = gtt_end; | ||
| 99 | |||
| 100 | /* pick the larger of the two chunks */ | ||
| 101 | if (stolen[0].end - stolen[0].start > | ||
| 102 | stolen[1].end - stolen[1].start) { | ||
| 103 | base = stolen[0].start; | ||
| 104 | dev_priv->gtt.stolen_size = stolen[0].end - stolen[0].start; | ||
| 105 | } else { | ||
| 106 | base = stolen[1].start; | ||
| 107 | dev_priv->gtt.stolen_size = stolen[1].end - stolen[1].start; | ||
| 108 | } | ||
| 109 | |||
| 110 | if (stolen[0].start != stolen[1].start || | ||
| 111 | stolen[0].end != stolen[1].end) { | ||
| 112 | DRM_DEBUG_KMS("GTT within stolen memory at 0x%llx-0x%llx\n", | ||
| 113 | (unsigned long long) gtt_start, | ||
| 114 | (unsigned long long) gtt_end - 1); | ||
| 115 | DRM_DEBUG_KMS("Stolen memory adjusted to 0x%x-0x%x\n", | ||
| 116 | base, base + (u32) dev_priv->gtt.stolen_size - 1); | ||
| 117 | } | ||
| 118 | } | ||
| 119 | |||
| 120 | |||
| 77 | /* Verify that nothing else uses this physical address. Stolen | 121 | /* Verify that nothing else uses this physical address. Stolen |
| 78 | * memory should be reserved by the BIOS and hidden from the | 122 | * memory should be reserved by the BIOS and hidden from the |
| 79 | * kernel. So if the region is already marked as busy, something | 123 | * kernel. So if the region is already marked as busy, something |
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c index 267f069765ad..c05c84f3f091 100644 --- a/drivers/gpu/drm/i915/i915_irq.c +++ b/drivers/gpu/drm/i915/i915_irq.c | |||
| @@ -2845,7 +2845,7 @@ static int semaphore_passed(struct intel_engine_cs *ring) | |||
| 2845 | { | 2845 | { |
| 2846 | struct drm_i915_private *dev_priv = ring->dev->dev_private; | 2846 | struct drm_i915_private *dev_priv = ring->dev->dev_private; |
| 2847 | struct intel_engine_cs *signaller; | 2847 | struct intel_engine_cs *signaller; |
| 2848 | u32 seqno, ctl; | 2848 | u32 seqno; |
| 2849 | 2849 | ||
| 2850 | ring->hangcheck.deadlock++; | 2850 | ring->hangcheck.deadlock++; |
| 2851 | 2851 | ||
| @@ -2857,15 +2857,12 @@ static int semaphore_passed(struct intel_engine_cs *ring) | |||
| 2857 | if (signaller->hangcheck.deadlock >= I915_NUM_RINGS) | 2857 | if (signaller->hangcheck.deadlock >= I915_NUM_RINGS) |
| 2858 | return -1; | 2858 | return -1; |
| 2859 | 2859 | ||
| 2860 | /* cursory check for an unkickable deadlock */ | ||
| 2861 | ctl = I915_READ_CTL(signaller); | ||
| 2862 | if (ctl & RING_WAIT_SEMAPHORE && semaphore_passed(signaller) < 0) | ||
| 2863 | return -1; | ||
| 2864 | |||
| 2865 | if (i915_seqno_passed(signaller->get_seqno(signaller, false), seqno)) | 2860 | if (i915_seqno_passed(signaller->get_seqno(signaller, false), seqno)) |
| 2866 | return 1; | 2861 | return 1; |
| 2867 | 2862 | ||
| 2868 | if (signaller->hangcheck.deadlock) | 2863 | /* cursory check for an unkickable deadlock */ |
| 2864 | if (I915_READ_CTL(signaller) & RING_WAIT_SEMAPHORE && | ||
| 2865 | semaphore_passed(signaller) < 0) | ||
| 2869 | return -1; | 2866 | return -1; |
| 2870 | 2867 | ||
| 2871 | return 0; | 2868 | return 0; |
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h index e691b30b2817..a5bab61bfc00 100644 --- a/drivers/gpu/drm/i915/i915_reg.h +++ b/drivers/gpu/drm/i915/i915_reg.h | |||
| @@ -942,6 +942,9 @@ enum punit_power_well { | |||
| 942 | /* | 942 | /* |
| 943 | * Instruction and interrupt control regs | 943 | * Instruction and interrupt control regs |
| 944 | */ | 944 | */ |
| 945 | #define PGTBL_CTL 0x02020 | ||
| 946 | #define PGTBL_ADDRESS_LO_MASK 0xfffff000 /* bits [31:12] */ | ||
| 947 | #define PGTBL_ADDRESS_HI_MASK 0x000000f0 /* bits [35:32] (gen4) */ | ||
| 945 | #define PGTBL_ER 0x02024 | 948 | #define PGTBL_ER 0x02024 |
| 946 | #define RENDER_RING_BASE 0x02000 | 949 | #define RENDER_RING_BASE 0x02000 |
| 947 | #define BSD_RING_BASE 0x04000 | 950 | #define BSD_RING_BASE 0x04000 |
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c index 556c916dbf9d..f0be855ddf45 100644 --- a/drivers/gpu/drm/i915/intel_display.c +++ b/drivers/gpu/drm/i915/intel_display.c | |||
| @@ -11591,6 +11591,14 @@ static void quirk_invert_brightness(struct drm_device *dev) | |||
| 11591 | DRM_INFO("applying inverted panel brightness quirk\n"); | 11591 | DRM_INFO("applying inverted panel brightness quirk\n"); |
| 11592 | } | 11592 | } |
| 11593 | 11593 | ||
| 11594 | /* Some VBT's incorrectly indicate no backlight is present */ | ||
| 11595 | static void quirk_backlight_present(struct drm_device *dev) | ||
| 11596 | { | ||
| 11597 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
| 11598 | dev_priv->quirks |= QUIRK_BACKLIGHT_PRESENT; | ||
| 11599 | DRM_INFO("applying backlight present quirk\n"); | ||
| 11600 | } | ||
| 11601 | |||
| 11594 | struct intel_quirk { | 11602 | struct intel_quirk { |
| 11595 | int device; | 11603 | int device; |
| 11596 | int subsystem_vendor; | 11604 | int subsystem_vendor; |
| @@ -11659,6 +11667,15 @@ static struct intel_quirk intel_quirks[] = { | |||
| 11659 | 11667 | ||
| 11660 | /* Acer Aspire 5336 */ | 11668 | /* Acer Aspire 5336 */ |
| 11661 | { 0x2a42, 0x1025, 0x048a, quirk_invert_brightness }, | 11669 | { 0x2a42, 0x1025, 0x048a, quirk_invert_brightness }, |
| 11670 | |||
| 11671 | /* Acer C720 and C720P Chromebooks (Celeron 2955U) have backlights */ | ||
| 11672 | { 0x0a06, 0x1025, 0x0a11, quirk_backlight_present }, | ||
| 11673 | |||
| 11674 | /* Toshiba CB35 Chromebook (Celeron 2955U) */ | ||
| 11675 | { 0x0a06, 0x1179, 0x0a88, quirk_backlight_present }, | ||
| 11676 | |||
| 11677 | /* HP Chromebook 14 (Celeron 2955U) */ | ||
| 11678 | { 0x0a06, 0x103c, 0x21ed, quirk_backlight_present }, | ||
| 11662 | }; | 11679 | }; |
| 11663 | 11680 | ||
| 11664 | static void intel_init_quirks(struct drm_device *dev) | 11681 | static void intel_init_quirks(struct drm_device *dev) |
| @@ -11897,6 +11914,7 @@ static void intel_sanitize_crtc(struct intel_crtc *crtc) | |||
| 11897 | * ... */ | 11914 | * ... */ |
| 11898 | plane = crtc->plane; | 11915 | plane = crtc->plane; |
| 11899 | crtc->plane = !plane; | 11916 | crtc->plane = !plane; |
| 11917 | crtc->primary_enabled = true; | ||
| 11900 | dev_priv->display.crtc_disable(&crtc->base); | 11918 | dev_priv->display.crtc_disable(&crtc->base); |
| 11901 | crtc->plane = plane; | 11919 | crtc->plane = plane; |
| 11902 | 11920 | ||
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 52fda950fd2a..8a1a4fbc06ac 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c | |||
| @@ -28,6 +28,8 @@ | |||
| 28 | #include <linux/i2c.h> | 28 | #include <linux/i2c.h> |
| 29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
| 30 | #include <linux/export.h> | 30 | #include <linux/export.h> |
| 31 | #include <linux/notifier.h> | ||
| 32 | #include <linux/reboot.h> | ||
| 31 | #include <drm/drmP.h> | 33 | #include <drm/drmP.h> |
| 32 | #include <drm/drm_crtc.h> | 34 | #include <drm/drm_crtc.h> |
| 33 | #include <drm/drm_crtc_helper.h> | 35 | #include <drm/drm_crtc_helper.h> |
| @@ -336,6 +338,37 @@ static u32 _pp_stat_reg(struct intel_dp *intel_dp) | |||
| 336 | return VLV_PIPE_PP_STATUS(vlv_power_sequencer_pipe(intel_dp)); | 338 | return VLV_PIPE_PP_STATUS(vlv_power_sequencer_pipe(intel_dp)); |
| 337 | } | 339 | } |
| 338 | 340 | ||
| 341 | /* Reboot notifier handler to shutdown panel power to guarantee T12 timing | ||
| 342 | This function only applicable when panel PM state is not to be tracked */ | ||
| 343 | static int edp_notify_handler(struct notifier_block *this, unsigned long code, | ||
| 344 | void *unused) | ||
| 345 | { | ||
| 346 | struct intel_dp *intel_dp = container_of(this, typeof(* intel_dp), | ||
| 347 | edp_notifier); | ||
| 348 | struct drm_device *dev = intel_dp_to_dev(intel_dp); | ||
| 349 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
| 350 | u32 pp_div; | ||
| 351 | u32 pp_ctrl_reg, pp_div_reg; | ||
| 352 | enum pipe pipe = vlv_power_sequencer_pipe(intel_dp); | ||
| 353 | |||
| 354 | if (!is_edp(intel_dp) || code != SYS_RESTART) | ||
| 355 | return 0; | ||
| 356 | |||
| 357 | if (IS_VALLEYVIEW(dev)) { | ||
| 358 | pp_ctrl_reg = VLV_PIPE_PP_CONTROL(pipe); | ||
| 359 | pp_div_reg = VLV_PIPE_PP_DIVISOR(pipe); | ||
| 360 | pp_div = I915_READ(pp_div_reg); | ||
| 361 | pp_div &= PP_REFERENCE_DIVIDER_MASK; | ||
| 362 | |||
| 363 | /* 0x1F write to PP_DIV_REG sets max cycle delay */ | ||
| 364 | I915_WRITE(pp_div_reg, pp_div | 0x1F); | ||
| 365 | I915_WRITE(pp_ctrl_reg, PANEL_UNLOCK_REGS | PANEL_POWER_OFF); | ||
| 366 | msleep(intel_dp->panel_power_cycle_delay); | ||
| 367 | } | ||
| 368 | |||
| 369 | return 0; | ||
| 370 | } | ||
| 371 | |||
| 339 | static bool edp_have_panel_power(struct intel_dp *intel_dp) | 372 | static bool edp_have_panel_power(struct intel_dp *intel_dp) |
| 340 | { | 373 | { |
| 341 | struct drm_device *dev = intel_dp_to_dev(intel_dp); | 374 | struct drm_device *dev = intel_dp_to_dev(intel_dp); |
| @@ -873,8 +906,8 @@ intel_dp_compute_config(struct intel_encoder *encoder, | |||
| 873 | mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, | 906 | mode_rate = intel_dp_link_required(adjusted_mode->crtc_clock, |
| 874 | bpp); | 907 | bpp); |
| 875 | 908 | ||
| 876 | for (lane_count = min_lane_count; lane_count <= max_lane_count; lane_count <<= 1) { | 909 | for (clock = min_clock; clock <= max_clock; clock++) { |
| 877 | for (clock = min_clock; clock <= max_clock; clock++) { | 910 | for (lane_count = min_lane_count; lane_count <= max_lane_count; lane_count <<= 1) { |
| 878 | link_clock = drm_dp_bw_code_to_link_rate(bws[clock]); | 911 | link_clock = drm_dp_bw_code_to_link_rate(bws[clock]); |
| 879 | link_avail = intel_dp_max_data_rate(link_clock, | 912 | link_avail = intel_dp_max_data_rate(link_clock, |
| 880 | lane_count); | 913 | lane_count); |
| @@ -3707,6 +3740,10 @@ void intel_dp_encoder_destroy(struct drm_encoder *encoder) | |||
| 3707 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); | 3740 | drm_modeset_lock(&dev->mode_config.connection_mutex, NULL); |
| 3708 | edp_panel_vdd_off_sync(intel_dp); | 3741 | edp_panel_vdd_off_sync(intel_dp); |
| 3709 | drm_modeset_unlock(&dev->mode_config.connection_mutex); | 3742 | drm_modeset_unlock(&dev->mode_config.connection_mutex); |
| 3743 | if (intel_dp->edp_notifier.notifier_call) { | ||
| 3744 | unregister_reboot_notifier(&intel_dp->edp_notifier); | ||
| 3745 | intel_dp->edp_notifier.notifier_call = NULL; | ||
| 3746 | } | ||
| 3710 | } | 3747 | } |
| 3711 | kfree(intel_dig_port); | 3748 | kfree(intel_dig_port); |
| 3712 | } | 3749 | } |
| @@ -4184,6 +4221,11 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, | |||
| 4184 | } | 4221 | } |
| 4185 | mutex_unlock(&dev->mode_config.mutex); | 4222 | mutex_unlock(&dev->mode_config.mutex); |
| 4186 | 4223 | ||
| 4224 | if (IS_VALLEYVIEW(dev)) { | ||
| 4225 | intel_dp->edp_notifier.notifier_call = edp_notify_handler; | ||
| 4226 | register_reboot_notifier(&intel_dp->edp_notifier); | ||
| 4227 | } | ||
| 4228 | |||
| 4187 | intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode); | 4229 | intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode); |
| 4188 | intel_panel_setup_backlight(connector); | 4230 | intel_panel_setup_backlight(connector); |
| 4189 | 4231 | ||
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h index eaa27ee9e367..f67340ed2c12 100644 --- a/drivers/gpu/drm/i915/intel_drv.h +++ b/drivers/gpu/drm/i915/intel_drv.h | |||
| @@ -538,6 +538,8 @@ struct intel_dp { | |||
| 538 | unsigned long last_power_on; | 538 | unsigned long last_power_on; |
| 539 | unsigned long last_backlight_off; | 539 | unsigned long last_backlight_off; |
| 540 | bool psr_setup_done; | 540 | bool psr_setup_done; |
| 541 | struct notifier_block edp_notifier; | ||
| 542 | |||
| 541 | bool use_tps3; | 543 | bool use_tps3; |
| 542 | struct intel_connector *attached_connector; | 544 | struct intel_connector *attached_connector; |
| 543 | 545 | ||
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index 02f99d768d49..3fd082933c87 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c | |||
| @@ -117,17 +117,18 @@ static void intel_dsi_device_ready(struct intel_encoder *encoder) | |||
| 117 | /* bandgap reset is needed after everytime we do power gate */ | 117 | /* bandgap reset is needed after everytime we do power gate */ |
| 118 | band_gap_reset(dev_priv); | 118 | band_gap_reset(dev_priv); |
| 119 | 119 | ||
| 120 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER); | ||
| 121 | usleep_range(2500, 3000); | ||
| 122 | |||
| 120 | val = I915_READ(MIPI_PORT_CTRL(pipe)); | 123 | val = I915_READ(MIPI_PORT_CTRL(pipe)); |
| 121 | I915_WRITE(MIPI_PORT_CTRL(pipe), val | LP_OUTPUT_HOLD); | 124 | I915_WRITE(MIPI_PORT_CTRL(pipe), val | LP_OUTPUT_HOLD); |
| 122 | usleep_range(1000, 1500); | 125 | usleep_range(1000, 1500); |
| 123 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_EXIT); | 126 | |
| 124 | usleep_range(2000, 2500); | 127 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_EXIT); |
| 125 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY); | 128 | usleep_range(2500, 3000); |
| 126 | usleep_range(2000, 2500); | 129 | |
| 127 | I915_WRITE(MIPI_DEVICE_READY(pipe), 0x00); | ||
| 128 | usleep_range(2000, 2500); | ||
| 129 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY); | 130 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY); |
| 130 | usleep_range(2000, 2500); | 131 | usleep_range(2500, 3000); |
| 131 | } | 132 | } |
| 132 | 133 | ||
| 133 | static void intel_dsi_enable(struct intel_encoder *encoder) | 134 | static void intel_dsi_enable(struct intel_encoder *encoder) |
| @@ -271,23 +272,23 @@ static void intel_dsi_clear_device_ready(struct intel_encoder *encoder) | |||
| 271 | 272 | ||
| 272 | DRM_DEBUG_KMS("\n"); | 273 | DRM_DEBUG_KMS("\n"); |
| 273 | 274 | ||
| 274 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER); | 275 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_ENTER); |
| 275 | usleep_range(2000, 2500); | 276 | usleep_range(2000, 2500); |
| 276 | 277 | ||
| 277 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_EXIT); | 278 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_EXIT); |
| 278 | usleep_range(2000, 2500); | 279 | usleep_range(2000, 2500); |
| 279 | 280 | ||
| 280 | I915_WRITE(MIPI_DEVICE_READY(pipe), ULPS_STATE_ENTER); | 281 | I915_WRITE(MIPI_DEVICE_READY(pipe), DEVICE_READY | ULPS_STATE_ENTER); |
| 281 | usleep_range(2000, 2500); | 282 | usleep_range(2000, 2500); |
| 282 | 283 | ||
| 283 | val = I915_READ(MIPI_PORT_CTRL(pipe)); | ||
| 284 | I915_WRITE(MIPI_PORT_CTRL(pipe), val & ~LP_OUTPUT_HOLD); | ||
| 285 | usleep_range(1000, 1500); | ||
| 286 | |||
| 287 | if (wait_for(((I915_READ(MIPI_PORT_CTRL(pipe)) & AFE_LATCHOUT) | 284 | if (wait_for(((I915_READ(MIPI_PORT_CTRL(pipe)) & AFE_LATCHOUT) |
| 288 | == 0x00000), 30)) | 285 | == 0x00000), 30)) |
| 289 | DRM_ERROR("DSI LP not going Low\n"); | 286 | DRM_ERROR("DSI LP not going Low\n"); |
| 290 | 287 | ||
| 288 | val = I915_READ(MIPI_PORT_CTRL(pipe)); | ||
| 289 | I915_WRITE(MIPI_PORT_CTRL(pipe), val & ~LP_OUTPUT_HOLD); | ||
| 290 | usleep_range(1000, 1500); | ||
| 291 | |||
| 291 | I915_WRITE(MIPI_DEVICE_READY(pipe), 0x00); | 292 | I915_WRITE(MIPI_DEVICE_READY(pipe), 0x00); |
| 292 | usleep_range(2000, 2500); | 293 | usleep_range(2000, 2500); |
| 293 | 294 | ||
diff --git a/drivers/gpu/drm/i915/intel_dsi_cmd.c b/drivers/gpu/drm/i915/intel_dsi_cmd.c index 3eeb21b9fddf..933c86305237 100644 --- a/drivers/gpu/drm/i915/intel_dsi_cmd.c +++ b/drivers/gpu/drm/i915/intel_dsi_cmd.c | |||
| @@ -404,12 +404,6 @@ int dpi_send_cmd(struct intel_dsi *intel_dsi, u32 cmd, bool hs) | |||
| 404 | else | 404 | else |
| 405 | cmd |= DPI_LP_MODE; | 405 | cmd |= DPI_LP_MODE; |
| 406 | 406 | ||
| 407 | /* DPI virtual channel?! */ | ||
| 408 | |||
| 409 | mask = DPI_FIFO_EMPTY; | ||
| 410 | if (wait_for((I915_READ(MIPI_GEN_FIFO_STAT(pipe)) & mask) == mask, 50)) | ||
| 411 | DRM_ERROR("Timeout waiting for DPI FIFO empty.\n"); | ||
| 412 | |||
| 413 | /* clear bit */ | 407 | /* clear bit */ |
| 414 | I915_WRITE(MIPI_INTR_STAT(pipe), SPL_PKT_SENT_INTERRUPT); | 408 | I915_WRITE(MIPI_INTR_STAT(pipe), SPL_PKT_SENT_INTERRUPT); |
| 415 | 409 | ||
diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c index 23126023aeba..5e5a72fca5fb 100644 --- a/drivers/gpu/drm/i915/intel_lvds.c +++ b/drivers/gpu/drm/i915/intel_lvds.c | |||
| @@ -111,6 +111,13 @@ static void intel_lvds_get_config(struct intel_encoder *encoder, | |||
| 111 | 111 | ||
| 112 | pipe_config->adjusted_mode.flags |= flags; | 112 | pipe_config->adjusted_mode.flags |= flags; |
| 113 | 113 | ||
| 114 | /* gen2/3 store dither state in pfit control, needs to match */ | ||
| 115 | if (INTEL_INFO(dev)->gen < 4) { | ||
| 116 | tmp = I915_READ(PFIT_CONTROL); | ||
| 117 | |||
| 118 | pipe_config->gmch_pfit.control |= tmp & PANEL_8TO6_DITHER_ENABLE; | ||
| 119 | } | ||
| 120 | |||
| 114 | dotclock = pipe_config->port_clock; | 121 | dotclock = pipe_config->port_clock; |
| 115 | 122 | ||
| 116 | if (HAS_PCH_SPLIT(dev_priv->dev)) | 123 | if (HAS_PCH_SPLIT(dev_priv->dev)) |
diff --git a/drivers/gpu/drm/i915/intel_opregion.c b/drivers/gpu/drm/i915/intel_opregion.c index 2e2c71fcc9ed..4f6b53998d79 100644 --- a/drivers/gpu/drm/i915/intel_opregion.c +++ b/drivers/gpu/drm/i915/intel_opregion.c | |||
| @@ -403,6 +403,15 @@ static u32 asle_set_backlight(struct drm_device *dev, u32 bclp) | |||
| 403 | 403 | ||
| 404 | DRM_DEBUG_DRIVER("bclp = 0x%08x\n", bclp); | 404 | DRM_DEBUG_DRIVER("bclp = 0x%08x\n", bclp); |
| 405 | 405 | ||
| 406 | /* | ||
| 407 | * If the acpi_video interface is not supposed to be used, don't | ||
| 408 | * bother processing backlight level change requests from firmware. | ||
| 409 | */ | ||
| 410 | if (!acpi_video_verify_backlight_support()) { | ||
| 411 | DRM_DEBUG_KMS("opregion backlight request ignored\n"); | ||
| 412 | return 0; | ||
| 413 | } | ||
| 414 | |||
| 406 | if (!(bclp & ASLE_BCLP_VALID)) | 415 | if (!(bclp & ASLE_BCLP_VALID)) |
| 407 | return ASLC_BACKLIGHT_FAILED; | 416 | return ASLC_BACKLIGHT_FAILED; |
| 408 | 417 | ||
diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c index 38a98570d10c..12b02fe1d0ae 100644 --- a/drivers/gpu/drm/i915/intel_panel.c +++ b/drivers/gpu/drm/i915/intel_panel.c | |||
| @@ -361,16 +361,16 @@ void intel_gmch_panel_fitting(struct intel_crtc *intel_crtc, | |||
| 361 | pfit_control |= ((intel_crtc->pipe << PFIT_PIPE_SHIFT) | | 361 | pfit_control |= ((intel_crtc->pipe << PFIT_PIPE_SHIFT) | |
| 362 | PFIT_FILTER_FUZZY); | 362 | PFIT_FILTER_FUZZY); |
| 363 | 363 | ||
| 364 | /* Make sure pre-965 set dither correctly for 18bpp panels. */ | ||
| 365 | if (INTEL_INFO(dev)->gen < 4 && pipe_config->pipe_bpp == 18) | ||
| 366 | pfit_control |= PANEL_8TO6_DITHER_ENABLE; | ||
| 367 | |||
| 368 | out: | 364 | out: |
| 369 | if ((pfit_control & PFIT_ENABLE) == 0) { | 365 | if ((pfit_control & PFIT_ENABLE) == 0) { |
| 370 | pfit_control = 0; | 366 | pfit_control = 0; |
| 371 | pfit_pgm_ratios = 0; | 367 | pfit_pgm_ratios = 0; |
| 372 | } | 368 | } |
| 373 | 369 | ||
| 370 | /* Make sure pre-965 set dither correctly for 18bpp panels. */ | ||
| 371 | if (INTEL_INFO(dev)->gen < 4 && pipe_config->pipe_bpp == 18) | ||
| 372 | pfit_control |= PANEL_8TO6_DITHER_ENABLE; | ||
| 373 | |||
| 374 | pipe_config->gmch_pfit.control = pfit_control; | 374 | pipe_config->gmch_pfit.control = pfit_control; |
| 375 | pipe_config->gmch_pfit.pgm_ratios = pfit_pgm_ratios; | 375 | pipe_config->gmch_pfit.pgm_ratios = pfit_pgm_ratios; |
| 376 | pipe_config->gmch_pfit.lvds_border_bits = border; | 376 | pipe_config->gmch_pfit.lvds_border_bits = border; |
| @@ -1118,8 +1118,12 @@ int intel_panel_setup_backlight(struct drm_connector *connector) | |||
| 1118 | int ret; | 1118 | int ret; |
| 1119 | 1119 | ||
| 1120 | if (!dev_priv->vbt.backlight.present) { | 1120 | if (!dev_priv->vbt.backlight.present) { |
| 1121 | DRM_DEBUG_KMS("native backlight control not available per VBT\n"); | 1121 | if (dev_priv->quirks & QUIRK_BACKLIGHT_PRESENT) { |
| 1122 | return 0; | 1122 | DRM_DEBUG_KMS("no backlight present per VBT, but present per quirk\n"); |
| 1123 | } else { | ||
| 1124 | DRM_DEBUG_KMS("no backlight present per VBT\n"); | ||
| 1125 | return 0; | ||
| 1126 | } | ||
| 1123 | } | 1127 | } |
| 1124 | 1128 | ||
| 1125 | /* set level and max in panel struct */ | 1129 | /* set level and max in panel struct */ |
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c index 26e962b7e702..2283c442a10d 100644 --- a/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/disp/nv50.c | |||
| @@ -1516,11 +1516,11 @@ nv50_disp_intr_unk20_2(struct nv50_disp_priv *priv, int head) | |||
| 1516 | } | 1516 | } |
| 1517 | 1517 | ||
| 1518 | switch ((ctrl & 0x000f0000) >> 16) { | 1518 | switch ((ctrl & 0x000f0000) >> 16) { |
| 1519 | case 6: datarate = pclk * 30 / 8; break; | 1519 | case 6: datarate = pclk * 30; break; |
| 1520 | case 5: datarate = pclk * 24 / 8; break; | 1520 | case 5: datarate = pclk * 24; break; |
| 1521 | case 2: | 1521 | case 2: |
| 1522 | default: | 1522 | default: |
| 1523 | datarate = pclk * 18 / 8; | 1523 | datarate = pclk * 18; |
| 1524 | break; | 1524 | break; |
| 1525 | } | 1525 | } |
| 1526 | 1526 | ||
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c index 48aa38a87e3f..fa30d8196f35 100644 --- a/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c +++ b/drivers/gpu/drm/nouveau/core/engine/disp/nvd0.c | |||
| @@ -1159,11 +1159,11 @@ nvd0_disp_intr_unk2_2(struct nv50_disp_priv *priv, int head) | |||
| 1159 | if (outp->info.type == DCB_OUTPUT_DP) { | 1159 | if (outp->info.type == DCB_OUTPUT_DP) { |
| 1160 | u32 sync = nv_rd32(priv, 0x660404 + (head * 0x300)); | 1160 | u32 sync = nv_rd32(priv, 0x660404 + (head * 0x300)); |
| 1161 | switch ((sync & 0x000003c0) >> 6) { | 1161 | switch ((sync & 0x000003c0) >> 6) { |
| 1162 | case 6: pclk = pclk * 30 / 8; break; | 1162 | case 6: pclk = pclk * 30; break; |
| 1163 | case 5: pclk = pclk * 24 / 8; break; | 1163 | case 5: pclk = pclk * 24; break; |
| 1164 | case 2: | 1164 | case 2: |
| 1165 | default: | 1165 | default: |
| 1166 | pclk = pclk * 18 / 8; | 1166 | pclk = pclk * 18; |
| 1167 | break; | 1167 | break; |
| 1168 | } | 1168 | } |
| 1169 | 1169 | ||
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c b/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c index 52c299c3d300..eb2d7789555d 100644 --- a/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c +++ b/drivers/gpu/drm/nouveau/core/engine/disp/outpdp.c | |||
| @@ -34,7 +34,7 @@ nvkm_output_dp_train(struct nvkm_output *base, u32 datarate, bool wait) | |||
| 34 | struct nvkm_output_dp *outp = (void *)base; | 34 | struct nvkm_output_dp *outp = (void *)base; |
| 35 | bool retrain = true; | 35 | bool retrain = true; |
| 36 | u8 link[2], stat[3]; | 36 | u8 link[2], stat[3]; |
| 37 | u32 rate; | 37 | u32 linkrate; |
| 38 | int ret, i; | 38 | int ret, i; |
| 39 | 39 | ||
| 40 | /* check that the link is trained at a high enough rate */ | 40 | /* check that the link is trained at a high enough rate */ |
| @@ -44,8 +44,10 @@ nvkm_output_dp_train(struct nvkm_output *base, u32 datarate, bool wait) | |||
| 44 | goto done; | 44 | goto done; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | rate = link[0] * 27000 * (link[1] & DPCD_LC01_LANE_COUNT_SET); | 47 | linkrate = link[0] * 27000 * (link[1] & DPCD_LC01_LANE_COUNT_SET); |
| 48 | if (rate < ((datarate / 8) * 10)) { | 48 | linkrate = (linkrate * 8) / 10; /* 8B/10B coding overhead */ |
| 49 | datarate = (datarate + 9) / 10; /* -> decakilobits */ | ||
| 50 | if (linkrate < datarate) { | ||
| 49 | DBG("link not trained at sufficient rate\n"); | 51 | DBG("link not trained at sufficient rate\n"); |
| 50 | goto done; | 52 | goto done; |
| 51 | } | 53 | } |
diff --git a/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c b/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c index e1832778e8b6..7a1ebdfa9e1b 100644 --- a/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c +++ b/drivers/gpu/drm/nouveau/core/engine/disp/sornv50.c | |||
| @@ -87,6 +87,7 @@ nv50_sor_mthd(struct nouveau_object *object, u32 mthd, void *args, u32 size) | |||
| 87 | struct nvkm_output_dp *outpdp = (void *)outp; | 87 | struct nvkm_output_dp *outpdp = (void *)outp; |
| 88 | switch (data) { | 88 | switch (data) { |
| 89 | case NV94_DISP_SOR_DP_PWR_STATE_OFF: | 89 | case NV94_DISP_SOR_DP_PWR_STATE_OFF: |
| 90 | nouveau_event_put(outpdp->irq); | ||
| 90 | ((struct nvkm_output_dp_impl *)nv_oclass(outp)) | 91 | ((struct nvkm_output_dp_impl *)nv_oclass(outp)) |
| 91 | ->lnk_pwr(outpdp, 0); | 92 | ->lnk_pwr(outpdp, 0); |
| 92 | atomic_set(&outpdp->lt.done, 0); | 93 | atomic_set(&outpdp->lt.done, 0); |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h b/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h index 0f57fcfe0bbf..2af9cfd2c60f 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h +++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramfuc.h | |||
| @@ -26,7 +26,7 @@ ramfuc_reg2(u32 addr1, u32 addr2) | |||
| 26 | }; | 26 | }; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | static inline struct ramfuc_reg | 29 | static noinline struct ramfuc_reg |
| 30 | ramfuc_reg(u32 addr) | 30 | ramfuc_reg(u32 addr) |
| 31 | { | 31 | { |
| 32 | return ramfuc_reg2(addr, addr); | 32 | return ramfuc_reg2(addr, addr); |
| @@ -107,7 +107,7 @@ ramfuc_nsec(struct ramfuc *ram, u32 nsec) | |||
| 107 | 107 | ||
| 108 | #define ram_init(s,p) ramfuc_init(&(s)->base, (p)) | 108 | #define ram_init(s,p) ramfuc_init(&(s)->base, (p)) |
| 109 | #define ram_exec(s,e) ramfuc_exec(&(s)->base, (e)) | 109 | #define ram_exec(s,e) ramfuc_exec(&(s)->base, (e)) |
| 110 | #define ram_have(s,r) ((s)->r_##r.addr != 0x000000) | 110 | #define ram_have(s,r) ((s)->r_##r.addr[0] != 0x000000) |
| 111 | #define ram_rd32(s,r) ramfuc_rd32(&(s)->base, &(s)->r_##r) | 111 | #define ram_rd32(s,r) ramfuc_rd32(&(s)->base, &(s)->r_##r) |
| 112 | #define ram_wr32(s,r,d) ramfuc_wr32(&(s)->base, &(s)->r_##r, (d)) | 112 | #define ram_wr32(s,r,d) ramfuc_wr32(&(s)->base, &(s)->r_##r, (d)) |
| 113 | #define ram_nuke(s,r) ramfuc_nuke(&(s)->base, &(s)->r_##r) | 113 | #define ram_nuke(s,r) ramfuc_nuke(&(s)->base, &(s)->r_##r) |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c index 1ad3ea503133..c5b46e302319 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c +++ b/drivers/gpu/drm/nouveau/core/subdev/fb/ramnve0.c | |||
| @@ -200,6 +200,7 @@ r1373f4_init(struct nve0_ramfuc *fuc) | |||
| 200 | /* (re)program mempll, if required */ | 200 | /* (re)program mempll, if required */ |
| 201 | if (ram->mode == 2) { | 201 | if (ram->mode == 2) { |
| 202 | ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000); | 202 | ram_mask(fuc, 0x1373f4, 0x00010000, 0x00000000); |
| 203 | ram_mask(fuc, 0x132000, 0x80000000, 0x80000000); | ||
| 203 | ram_mask(fuc, 0x132000, 0x00000001, 0x00000000); | 204 | ram_mask(fuc, 0x132000, 0x00000001, 0x00000000); |
| 204 | ram_mask(fuc, 0x132004, 0x103fffff, mcoef); | 205 | ram_mask(fuc, 0x132004, 0x103fffff, mcoef); |
| 205 | ram_mask(fuc, 0x132000, 0x00000001, 0x00000001); | 206 | ram_mask(fuc, 0x132000, 0x00000001, 0x00000001); |
diff --git a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c index cfde9eb44ad0..6212537b90c5 100644 --- a/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c +++ b/drivers/gpu/drm/nouveau/core/subdev/therm/temp.c | |||
| @@ -192,11 +192,11 @@ alarm_timer_callback(struct nouveau_alarm *alarm) | |||
| 192 | nouveau_therm_threshold_hyst_polling(therm, &sensor->thrs_shutdown, | 192 | nouveau_therm_threshold_hyst_polling(therm, &sensor->thrs_shutdown, |
| 193 | NOUVEAU_THERM_THRS_SHUTDOWN); | 193 | NOUVEAU_THERM_THRS_SHUTDOWN); |
| 194 | 194 | ||
| 195 | spin_unlock_irqrestore(&priv->sensor.alarm_program_lock, flags); | ||
| 196 | |||
| 195 | /* schedule the next poll in one second */ | 197 | /* schedule the next poll in one second */ |
| 196 | if (therm->temp_get(therm) >= 0 && list_empty(&alarm->head)) | 198 | if (therm->temp_get(therm) >= 0 && list_empty(&alarm->head)) |
| 197 | ptimer->alarm(ptimer, 1000 * 1000 * 1000, alarm); | 199 | ptimer->alarm(ptimer, 1000000000ULL, alarm); |
| 198 | |||
| 199 | spin_unlock_irqrestore(&priv->sensor.alarm_program_lock, flags); | ||
| 200 | } | 200 | } |
| 201 | 201 | ||
| 202 | void | 202 | void |
diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index ddd83756b9a2..5425ffe3931d 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c | |||
| @@ -652,12 +652,12 @@ int nouveau_pmops_resume(struct device *dev) | |||
| 652 | ret = nouveau_do_resume(drm_dev); | 652 | ret = nouveau_do_resume(drm_dev); |
| 653 | if (ret) | 653 | if (ret) |
| 654 | return ret; | 654 | return ret; |
| 655 | if (drm_dev->mode_config.num_crtc) | ||
| 656 | nouveau_fbcon_set_suspend(drm_dev, 0); | ||
| 657 | 655 | ||
| 658 | nouveau_fbcon_zfill_all(drm_dev); | 656 | if (drm_dev->mode_config.num_crtc) { |
| 659 | if (drm_dev->mode_config.num_crtc) | ||
| 660 | nouveau_display_resume(drm_dev); | 657 | nouveau_display_resume(drm_dev); |
| 658 | nouveau_fbcon_set_suspend(drm_dev, 0); | ||
| 659 | } | ||
| 660 | |||
| 661 | return 0; | 661 | return 0; |
| 662 | } | 662 | } |
| 663 | 663 | ||
| @@ -683,11 +683,12 @@ static int nouveau_pmops_thaw(struct device *dev) | |||
| 683 | ret = nouveau_do_resume(drm_dev); | 683 | ret = nouveau_do_resume(drm_dev); |
| 684 | if (ret) | 684 | if (ret) |
| 685 | return ret; | 685 | return ret; |
| 686 | if (drm_dev->mode_config.num_crtc) | 686 | |
| 687 | nouveau_fbcon_set_suspend(drm_dev, 0); | 687 | if (drm_dev->mode_config.num_crtc) { |
| 688 | nouveau_fbcon_zfill_all(drm_dev); | ||
| 689 | if (drm_dev->mode_config.num_crtc) | ||
| 690 | nouveau_display_resume(drm_dev); | 688 | nouveau_display_resume(drm_dev); |
| 689 | nouveau_fbcon_set_suspend(drm_dev, 0); | ||
| 690 | } | ||
| 691 | |||
| 691 | return 0; | 692 | return 0; |
| 692 | } | 693 | } |
| 693 | 694 | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index 64a42cfd3717..191665ee7f52 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c | |||
| @@ -531,17 +531,10 @@ nouveau_fbcon_set_suspend(struct drm_device *dev, int state) | |||
| 531 | if (state == 1) | 531 | if (state == 1) |
| 532 | nouveau_fbcon_save_disable_accel(dev); | 532 | nouveau_fbcon_save_disable_accel(dev); |
| 533 | fb_set_suspend(drm->fbcon->helper.fbdev, state); | 533 | fb_set_suspend(drm->fbcon->helper.fbdev, state); |
| 534 | if (state == 0) | 534 | if (state == 0) { |
| 535 | nouveau_fbcon_restore_accel(dev); | 535 | nouveau_fbcon_restore_accel(dev); |
| 536 | nouveau_fbcon_zfill(dev, drm->fbcon); | ||
| 537 | } | ||
| 536 | console_unlock(); | 538 | console_unlock(); |
| 537 | } | 539 | } |
| 538 | } | 540 | } |
| 539 | |||
| 540 | void | ||
| 541 | nouveau_fbcon_zfill_all(struct drm_device *dev) | ||
| 542 | { | ||
| 543 | struct nouveau_drm *drm = nouveau_drm(dev); | ||
| 544 | if (drm->fbcon) { | ||
| 545 | nouveau_fbcon_zfill(dev, drm->fbcon); | ||
| 546 | } | ||
| 547 | } | ||
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.h b/drivers/gpu/drm/nouveau/nouveau_fbcon.h index fdfc0c94fbcc..fcff797d2084 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.h +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.h | |||
| @@ -61,7 +61,6 @@ void nouveau_fbcon_gpu_lockup(struct fb_info *info); | |||
| 61 | int nouveau_fbcon_init(struct drm_device *dev); | 61 | int nouveau_fbcon_init(struct drm_device *dev); |
| 62 | void nouveau_fbcon_fini(struct drm_device *dev); | 62 | void nouveau_fbcon_fini(struct drm_device *dev); |
| 63 | void nouveau_fbcon_set_suspend(struct drm_device *dev, int state); | 63 | void nouveau_fbcon_set_suspend(struct drm_device *dev, int state); |
| 64 | void nouveau_fbcon_zfill_all(struct drm_device *dev); | ||
| 65 | void nouveau_fbcon_save_disable_accel(struct drm_device *dev); | 64 | void nouveau_fbcon_save_disable_accel(struct drm_device *dev); |
| 66 | void nouveau_fbcon_restore_accel(struct drm_device *dev); | 65 | void nouveau_fbcon_restore_accel(struct drm_device *dev); |
| 67 | 66 | ||
diff --git a/drivers/gpu/drm/nouveau/nv50_display.c b/drivers/gpu/drm/nouveau/nv50_display.c index afdf607df3e6..4c534b7b04da 100644 --- a/drivers/gpu/drm/nouveau/nv50_display.c +++ b/drivers/gpu/drm/nouveau/nv50_display.c | |||
| @@ -1741,7 +1741,8 @@ nv50_sor_dpms(struct drm_encoder *encoder, int mode) | |||
| 1741 | } | 1741 | } |
| 1742 | } | 1742 | } |
| 1743 | 1743 | ||
| 1744 | mthd = (ffs(nv_encoder->dcb->sorconf.link) - 1) << 2; | 1744 | mthd = (ffs(nv_encoder->dcb->heads) - 1) << 3; |
| 1745 | mthd |= (ffs(nv_encoder->dcb->sorconf.link) - 1) << 2; | ||
| 1745 | mthd |= nv_encoder->or; | 1746 | mthd |= nv_encoder->or; |
| 1746 | 1747 | ||
| 1747 | if (nv_encoder->dcb->type == DCB_OUTPUT_DP) { | 1748 | if (nv_encoder->dcb->type == DCB_OUTPUT_DP) { |
diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c index 34d6a85e9023..0bf1e20c6e44 100644 --- a/drivers/gpu/drm/qxl/qxl_irq.c +++ b/drivers/gpu/drm/qxl/qxl_irq.c | |||
| @@ -33,6 +33,9 @@ irqreturn_t qxl_irq_handler(int irq, void *arg) | |||
| 33 | 33 | ||
| 34 | pending = xchg(&qdev->ram_header->int_pending, 0); | 34 | pending = xchg(&qdev->ram_header->int_pending, 0); |
| 35 | 35 | ||
| 36 | if (!pending) | ||
| 37 | return IRQ_NONE; | ||
| 38 | |||
| 36 | atomic_inc(&qdev->irq_received); | 39 | atomic_inc(&qdev->irq_received); |
| 37 | 40 | ||
| 38 | if (pending & QXL_INTERRUPT_DISPLAY) { | 41 | if (pending & QXL_INTERRUPT_DISPLAY) { |
diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c index a03c73411a56..30d242b25078 100644 --- a/drivers/gpu/drm/radeon/atombios_crtc.c +++ b/drivers/gpu/drm/radeon/atombios_crtc.c | |||
| @@ -1414,8 +1414,8 @@ static int dce4_crtc_do_set_base(struct drm_crtc *crtc, | |||
| 1414 | tmp &= ~EVERGREEN_GRPH_SURFACE_UPDATE_H_RETRACE_EN; | 1414 | tmp &= ~EVERGREEN_GRPH_SURFACE_UPDATE_H_RETRACE_EN; |
| 1415 | WREG32(EVERGREEN_GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, tmp); | 1415 | WREG32(EVERGREEN_GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 1416 | 1416 | ||
| 1417 | /* set pageflip to happen anywhere in vblank interval */ | 1417 | /* set pageflip to happen only at start of vblank interval (front porch) */ |
| 1418 | WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0); | 1418 | WREG32(EVERGREEN_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 3); |
| 1419 | 1419 | ||
| 1420 | if (!atomic && fb && fb != crtc->primary->fb) { | 1420 | if (!atomic && fb && fb != crtc->primary->fb) { |
| 1421 | radeon_fb = to_radeon_framebuffer(fb); | 1421 | radeon_fb = to_radeon_framebuffer(fb); |
| @@ -1614,8 +1614,8 @@ static int avivo_crtc_do_set_base(struct drm_crtc *crtc, | |||
| 1614 | tmp &= ~AVIVO_D1GRPH_SURFACE_UPDATE_H_RETRACE_EN; | 1614 | tmp &= ~AVIVO_D1GRPH_SURFACE_UPDATE_H_RETRACE_EN; |
| 1615 | WREG32(AVIVO_D1GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, tmp); | 1615 | WREG32(AVIVO_D1GRPH_FLIP_CONTROL + radeon_crtc->crtc_offset, tmp); |
| 1616 | 1616 | ||
| 1617 | /* set pageflip to happen anywhere in vblank interval */ | 1617 | /* set pageflip to happen only at start of vblank interval (front porch) */ |
| 1618 | WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 0); | 1618 | WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + radeon_crtc->crtc_offset, 3); |
| 1619 | 1619 | ||
| 1620 | if (!atomic && fb && fb != crtc->primary->fb) { | 1620 | if (!atomic && fb && fb != crtc->primary->fb) { |
| 1621 | radeon_fb = to_radeon_framebuffer(fb); | 1621 | radeon_fb = to_radeon_framebuffer(fb); |
diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c index 35f4182c63b6..b1e11f8434e2 100644 --- a/drivers/gpu/drm/radeon/atombios_dp.c +++ b/drivers/gpu/drm/radeon/atombios_dp.c | |||
| @@ -127,7 +127,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan, | |||
| 127 | /* flags not zero */ | 127 | /* flags not zero */ |
| 128 | if (args.v1.ucReplyStatus == 2) { | 128 | if (args.v1.ucReplyStatus == 2) { |
| 129 | DRM_DEBUG_KMS("dp_aux_ch flags not zero\n"); | 129 | DRM_DEBUG_KMS("dp_aux_ch flags not zero\n"); |
| 130 | r = -EBUSY; | 130 | r = -EIO; |
| 131 | goto done; | 131 | goto done; |
| 132 | } | 132 | } |
| 133 | 133 | ||
diff --git a/drivers/gpu/drm/radeon/atombios_encoders.c b/drivers/gpu/drm/radeon/atombios_encoders.c index 2b2908440644..7d68203a3737 100644 --- a/drivers/gpu/drm/radeon/atombios_encoders.c +++ b/drivers/gpu/drm/radeon/atombios_encoders.c | |||
| @@ -183,7 +183,6 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder, | |||
| 183 | struct backlight_properties props; | 183 | struct backlight_properties props; |
| 184 | struct radeon_backlight_privdata *pdata; | 184 | struct radeon_backlight_privdata *pdata; |
| 185 | struct radeon_encoder_atom_dig *dig; | 185 | struct radeon_encoder_atom_dig *dig; |
| 186 | u8 backlight_level; | ||
| 187 | char bl_name[16]; | 186 | char bl_name[16]; |
| 188 | 187 | ||
| 189 | /* Mac laptops with multiple GPUs use the gmux driver for backlight | 188 | /* Mac laptops with multiple GPUs use the gmux driver for backlight |
| @@ -222,12 +221,17 @@ void radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder, | |||
| 222 | 221 | ||
| 223 | pdata->encoder = radeon_encoder; | 222 | pdata->encoder = radeon_encoder; |
| 224 | 223 | ||
| 225 | backlight_level = radeon_atom_get_backlight_level_from_reg(rdev); | ||
| 226 | |||
| 227 | dig = radeon_encoder->enc_priv; | 224 | dig = radeon_encoder->enc_priv; |
| 228 | dig->bl_dev = bd; | 225 | dig->bl_dev = bd; |
| 229 | 226 | ||
| 230 | bd->props.brightness = radeon_atom_backlight_get_brightness(bd); | 227 | bd->props.brightness = radeon_atom_backlight_get_brightness(bd); |
| 228 | /* Set a reasonable default here if the level is 0 otherwise | ||
| 229 | * fbdev will attempt to turn the backlight on after console | ||
| 230 | * unblanking and it will try and restore 0 which turns the backlight | ||
| 231 | * off again. | ||
| 232 | */ | ||
| 233 | if (bd->props.brightness == 0) | ||
| 234 | bd->props.brightness = RADEON_MAX_BL_LEVEL; | ||
| 231 | bd->props.power = FB_BLANK_UNBLANK; | 235 | bd->props.power = FB_BLANK_UNBLANK; |
| 232 | backlight_update_status(bd); | 236 | backlight_update_status(bd); |
| 233 | 237 | ||
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c index 10dae4106c08..584090ac3eb9 100644 --- a/drivers/gpu/drm/radeon/ci_dpm.c +++ b/drivers/gpu/drm/radeon/ci_dpm.c | |||
| @@ -1179,7 +1179,7 @@ static int ci_stop_dpm(struct radeon_device *rdev) | |||
| 1179 | tmp &= ~GLOBAL_PWRMGT_EN; | 1179 | tmp &= ~GLOBAL_PWRMGT_EN; |
| 1180 | WREG32_SMC(GENERAL_PWRMGT, tmp); | 1180 | WREG32_SMC(GENERAL_PWRMGT, tmp); |
| 1181 | 1181 | ||
| 1182 | tmp = RREG32(SCLK_PWRMGT_CNTL); | 1182 | tmp = RREG32_SMC(SCLK_PWRMGT_CNTL); |
| 1183 | tmp &= ~DYNAMIC_PM_EN; | 1183 | tmp &= ~DYNAMIC_PM_EN; |
| 1184 | WREG32_SMC(SCLK_PWRMGT_CNTL, tmp); | 1184 | WREG32_SMC(SCLK_PWRMGT_CNTL, tmp); |
| 1185 | 1185 | ||
diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c index dcd4518a9b08..c0ea66192fe0 100644 --- a/drivers/gpu/drm/radeon/cik.c +++ b/drivers/gpu/drm/radeon/cik.c | |||
| @@ -2291,6 +2291,7 @@ static void cik_tiling_mode_table_init(struct radeon_device *rdev) | |||
| 2291 | gb_tile_moden = 0; | 2291 | gb_tile_moden = 0; |
| 2292 | break; | 2292 | break; |
| 2293 | } | 2293 | } |
| 2294 | rdev->config.cik.macrotile_mode_array[reg_offset] = gb_tile_moden; | ||
| 2294 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); | 2295 | WREG32(GB_MACROTILE_MODE0 + (reg_offset * 4), gb_tile_moden); |
| 2295 | } | 2296 | } |
| 2296 | } else if (num_pipe_configs == 8) { | 2297 | } else if (num_pipe_configs == 8) { |
| @@ -7376,6 +7377,7 @@ static inline u32 cik_get_ih_wptr(struct radeon_device *rdev) | |||
| 7376 | tmp = RREG32(IH_RB_CNTL); | 7377 | tmp = RREG32(IH_RB_CNTL); |
| 7377 | tmp |= IH_WPTR_OVERFLOW_CLEAR; | 7378 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 7378 | WREG32(IH_RB_CNTL, tmp); | 7379 | WREG32(IH_RB_CNTL, tmp); |
| 7380 | wptr &= ~RB_OVERFLOW; | ||
| 7379 | } | 7381 | } |
| 7380 | return (wptr & rdev->ih.ptr_mask); | 7382 | return (wptr & rdev->ih.ptr_mask); |
| 7381 | } | 7383 | } |
| @@ -7676,14 +7678,16 @@ restart_ih: | |||
| 7676 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); | 7678 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); |
| 7677 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); | 7679 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); |
| 7678 | mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT); | 7680 | mc_client = RREG32(VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT); |
| 7681 | /* reset addr and status */ | ||
| 7682 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); | ||
| 7683 | if (addr == 0x0 && status == 0x0) | ||
| 7684 | break; | ||
| 7679 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); | 7685 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); |
| 7680 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", | 7686 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", |
| 7681 | addr); | 7687 | addr); |
| 7682 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", | 7688 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", |
| 7683 | status); | 7689 | status); |
| 7684 | cik_vm_decode_fault(rdev, status, addr, mc_client); | 7690 | cik_vm_decode_fault(rdev, status, addr, mc_client); |
| 7685 | /* reset addr and status */ | ||
| 7686 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); | ||
| 7687 | break; | 7691 | break; |
| 7688 | case 167: /* VCE */ | 7692 | case 167: /* VCE */ |
| 7689 | DRM_DEBUG("IH: VCE int: 0x%08x\n", src_data); | 7693 | DRM_DEBUG("IH: VCE int: 0x%08x\n", src_data); |
diff --git a/drivers/gpu/drm/radeon/evergreen.c b/drivers/gpu/drm/radeon/evergreen.c index e2f605224e8c..15e4f28015e1 100644 --- a/drivers/gpu/drm/radeon/evergreen.c +++ b/drivers/gpu/drm/radeon/evergreen.c | |||
| @@ -189,7 +189,7 @@ static const u32 evergreen_golden_registers[] = | |||
| 189 | 0x8c1c, 0xffffffff, 0x00001010, | 189 | 0x8c1c, 0xffffffff, 0x00001010, |
| 190 | 0x28350, 0xffffffff, 0x00000000, | 190 | 0x28350, 0xffffffff, 0x00000000, |
| 191 | 0xa008, 0xffffffff, 0x00010000, | 191 | 0xa008, 0xffffffff, 0x00010000, |
| 192 | 0x5cc, 0xffffffff, 0x00000001, | 192 | 0x5c4, 0xffffffff, 0x00000001, |
| 193 | 0x9508, 0xffffffff, 0x00000002, | 193 | 0x9508, 0xffffffff, 0x00000002, |
| 194 | 0x913c, 0x0000000f, 0x0000000a | 194 | 0x913c, 0x0000000f, 0x0000000a |
| 195 | }; | 195 | }; |
| @@ -476,7 +476,7 @@ static const u32 cedar_golden_registers[] = | |||
| 476 | 0x8c1c, 0xffffffff, 0x00001010, | 476 | 0x8c1c, 0xffffffff, 0x00001010, |
| 477 | 0x28350, 0xffffffff, 0x00000000, | 477 | 0x28350, 0xffffffff, 0x00000000, |
| 478 | 0xa008, 0xffffffff, 0x00010000, | 478 | 0xa008, 0xffffffff, 0x00010000, |
| 479 | 0x5cc, 0xffffffff, 0x00000001, | 479 | 0x5c4, 0xffffffff, 0x00000001, |
| 480 | 0x9508, 0xffffffff, 0x00000002 | 480 | 0x9508, 0xffffffff, 0x00000002 |
| 481 | }; | 481 | }; |
| 482 | 482 | ||
| @@ -635,7 +635,7 @@ static const u32 juniper_mgcg_init[] = | |||
| 635 | static const u32 supersumo_golden_registers[] = | 635 | static const u32 supersumo_golden_registers[] = |
| 636 | { | 636 | { |
| 637 | 0x5eb4, 0xffffffff, 0x00000002, | 637 | 0x5eb4, 0xffffffff, 0x00000002, |
| 638 | 0x5cc, 0xffffffff, 0x00000001, | 638 | 0x5c4, 0xffffffff, 0x00000001, |
| 639 | 0x7030, 0xffffffff, 0x00000011, | 639 | 0x7030, 0xffffffff, 0x00000011, |
| 640 | 0x7c30, 0xffffffff, 0x00000011, | 640 | 0x7c30, 0xffffffff, 0x00000011, |
| 641 | 0x6104, 0x01000300, 0x00000000, | 641 | 0x6104, 0x01000300, 0x00000000, |
| @@ -719,7 +719,7 @@ static const u32 sumo_golden_registers[] = | |||
| 719 | static const u32 wrestler_golden_registers[] = | 719 | static const u32 wrestler_golden_registers[] = |
| 720 | { | 720 | { |
| 721 | 0x5eb4, 0xffffffff, 0x00000002, | 721 | 0x5eb4, 0xffffffff, 0x00000002, |
| 722 | 0x5cc, 0xffffffff, 0x00000001, | 722 | 0x5c4, 0xffffffff, 0x00000001, |
| 723 | 0x7030, 0xffffffff, 0x00000011, | 723 | 0x7030, 0xffffffff, 0x00000011, |
| 724 | 0x7c30, 0xffffffff, 0x00000011, | 724 | 0x7c30, 0xffffffff, 0x00000011, |
| 725 | 0x6104, 0x01000300, 0x00000000, | 725 | 0x6104, 0x01000300, 0x00000000, |
| @@ -2642,8 +2642,9 @@ void evergreen_mc_resume(struct radeon_device *rdev, struct evergreen_mc_save *s | |||
| 2642 | for (i = 0; i < rdev->num_crtc; i++) { | 2642 | for (i = 0; i < rdev->num_crtc; i++) { |
| 2643 | if (save->crtc_enabled[i]) { | 2643 | if (save->crtc_enabled[i]) { |
| 2644 | tmp = RREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i]); | 2644 | tmp = RREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i]); |
| 2645 | if ((tmp & 0x3) != 0) { | 2645 | if ((tmp & 0x7) != 3) { |
| 2646 | tmp &= ~0x3; | 2646 | tmp &= ~0x7; |
| 2647 | tmp |= 0x3; | ||
| 2647 | WREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i], tmp); | 2648 | WREG32(EVERGREEN_MASTER_UPDATE_MODE + crtc_offsets[i], tmp); |
| 2648 | } | 2649 | } |
| 2649 | tmp = RREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i]); | 2650 | tmp = RREG32(EVERGREEN_GRPH_UPDATE + crtc_offsets[i]); |
| @@ -4755,6 +4756,7 @@ static u32 evergreen_get_ih_wptr(struct radeon_device *rdev) | |||
| 4755 | tmp = RREG32(IH_RB_CNTL); | 4756 | tmp = RREG32(IH_RB_CNTL); |
| 4756 | tmp |= IH_WPTR_OVERFLOW_CLEAR; | 4757 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 4757 | WREG32(IH_RB_CNTL, tmp); | 4758 | WREG32(IH_RB_CNTL, tmp); |
| 4759 | wptr &= ~RB_OVERFLOW; | ||
| 4758 | } | 4760 | } |
| 4759 | return (wptr & rdev->ih.ptr_mask); | 4761 | return (wptr & rdev->ih.ptr_mask); |
| 4760 | } | 4762 | } |
| @@ -5066,14 +5068,16 @@ restart_ih: | |||
| 5066 | case 147: | 5068 | case 147: |
| 5067 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); | 5069 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); |
| 5068 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); | 5070 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); |
| 5071 | /* reset addr and status */ | ||
| 5072 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); | ||
| 5073 | if (addr == 0x0 && status == 0x0) | ||
| 5074 | break; | ||
| 5069 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); | 5075 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); |
| 5070 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", | 5076 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", |
| 5071 | addr); | 5077 | addr); |
| 5072 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", | 5078 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", |
| 5073 | status); | 5079 | status); |
| 5074 | cayman_vm_decode_fault(rdev, status, addr); | 5080 | cayman_vm_decode_fault(rdev, status, addr); |
| 5075 | /* reset addr and status */ | ||
| 5076 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); | ||
| 5077 | break; | 5081 | break; |
| 5078 | case 176: /* CP_INT in ring buffer */ | 5082 | case 176: /* CP_INT in ring buffer */ |
| 5079 | case 177: /* CP_INT in IB1 */ | 5083 | case 177: /* CP_INT in IB1 */ |
diff --git a/drivers/gpu/drm/radeon/evergreen_reg.h b/drivers/gpu/drm/radeon/evergreen_reg.h index 333d143fca2c..23bff590fb6e 100644 --- a/drivers/gpu/drm/radeon/evergreen_reg.h +++ b/drivers/gpu/drm/radeon/evergreen_reg.h | |||
| @@ -239,7 +239,6 @@ | |||
| 239 | # define EVERGREEN_CRTC_V_BLANK (1 << 0) | 239 | # define EVERGREEN_CRTC_V_BLANK (1 << 0) |
| 240 | #define EVERGREEN_CRTC_STATUS_POSITION 0x6e90 | 240 | #define EVERGREEN_CRTC_STATUS_POSITION 0x6e90 |
| 241 | #define EVERGREEN_CRTC_STATUS_HV_COUNT 0x6ea0 | 241 | #define EVERGREEN_CRTC_STATUS_HV_COUNT 0x6ea0 |
| 242 | #define EVERGREEN_MASTER_UPDATE_MODE 0x6ef8 | ||
| 243 | #define EVERGREEN_CRTC_UPDATE_LOCK 0x6ed4 | 242 | #define EVERGREEN_CRTC_UPDATE_LOCK 0x6ed4 |
| 244 | #define EVERGREEN_MASTER_UPDATE_LOCK 0x6ef4 | 243 | #define EVERGREEN_MASTER_UPDATE_LOCK 0x6ef4 |
| 245 | #define EVERGREEN_MASTER_UPDATE_MODE 0x6ef8 | 244 | #define EVERGREEN_MASTER_UPDATE_MODE 0x6ef8 |
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c index c66952d4b00c..3c69f58e46ef 100644 --- a/drivers/gpu/drm/radeon/r600.c +++ b/drivers/gpu/drm/radeon/r600.c | |||
| @@ -3795,6 +3795,7 @@ static u32 r600_get_ih_wptr(struct radeon_device *rdev) | |||
| 3795 | tmp = RREG32(IH_RB_CNTL); | 3795 | tmp = RREG32(IH_RB_CNTL); |
| 3796 | tmp |= IH_WPTR_OVERFLOW_CLEAR; | 3796 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 3797 | WREG32(IH_RB_CNTL, tmp); | 3797 | WREG32(IH_RB_CNTL, tmp); |
| 3798 | wptr &= ~RB_OVERFLOW; | ||
| 3798 | } | 3799 | } |
| 3799 | return (wptr & rdev->ih.ptr_mask); | 3800 | return (wptr & rdev->ih.ptr_mask); |
| 3800 | } | 3801 | } |
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index 29d9cc04c04e..60c47f829122 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h | |||
| @@ -449,6 +449,7 @@ struct radeon_bo_va { | |||
| 449 | 449 | ||
| 450 | /* protected by vm mutex */ | 450 | /* protected by vm mutex */ |
| 451 | struct list_head vm_list; | 451 | struct list_head vm_list; |
| 452 | struct list_head vm_status; | ||
| 452 | 453 | ||
| 453 | /* constant after initialization */ | 454 | /* constant after initialization */ |
| 454 | struct radeon_vm *vm; | 455 | struct radeon_vm *vm; |
| @@ -684,10 +685,9 @@ struct radeon_flip_work { | |||
| 684 | struct work_struct unpin_work; | 685 | struct work_struct unpin_work; |
| 685 | struct radeon_device *rdev; | 686 | struct radeon_device *rdev; |
| 686 | int crtc_id; | 687 | int crtc_id; |
| 687 | struct drm_framebuffer *fb; | 688 | uint64_t base; |
| 688 | struct drm_pending_vblank_event *event; | 689 | struct drm_pending_vblank_event *event; |
| 689 | struct radeon_bo *old_rbo; | 690 | struct radeon_bo *old_rbo; |
| 690 | struct radeon_bo *new_rbo; | ||
| 691 | struct radeon_fence *fence; | 691 | struct radeon_fence *fence; |
| 692 | }; | 692 | }; |
| 693 | 693 | ||
| @@ -868,6 +868,9 @@ struct radeon_vm { | |||
| 868 | struct list_head va; | 868 | struct list_head va; |
| 869 | unsigned id; | 869 | unsigned id; |
| 870 | 870 | ||
| 871 | /* BOs freed, but not yet updated in the PT */ | ||
| 872 | struct list_head freed; | ||
| 873 | |||
| 871 | /* contains the page directory */ | 874 | /* contains the page directory */ |
| 872 | struct radeon_bo *page_directory; | 875 | struct radeon_bo *page_directory; |
| 873 | uint64_t pd_gpu_addr; | 876 | uint64_t pd_gpu_addr; |
| @@ -876,6 +879,8 @@ struct radeon_vm { | |||
| 876 | /* array of page tables, one for each page directory entry */ | 879 | /* array of page tables, one for each page directory entry */ |
| 877 | struct radeon_vm_pt *page_tables; | 880 | struct radeon_vm_pt *page_tables; |
| 878 | 881 | ||
| 882 | struct radeon_bo_va *ib_bo_va; | ||
| 883 | |||
| 879 | struct mutex mutex; | 884 | struct mutex mutex; |
| 880 | /* last fence for cs using this vm */ | 885 | /* last fence for cs using this vm */ |
| 881 | struct radeon_fence *fence; | 886 | struct radeon_fence *fence; |
| @@ -2833,9 +2838,10 @@ void radeon_vm_fence(struct radeon_device *rdev, | |||
| 2833 | uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr); | 2838 | uint64_t radeon_vm_map_gart(struct radeon_device *rdev, uint64_t addr); |
| 2834 | int radeon_vm_update_page_directory(struct radeon_device *rdev, | 2839 | int radeon_vm_update_page_directory(struct radeon_device *rdev, |
| 2835 | struct radeon_vm *vm); | 2840 | struct radeon_vm *vm); |
| 2841 | int radeon_vm_clear_freed(struct radeon_device *rdev, | ||
| 2842 | struct radeon_vm *vm); | ||
| 2836 | int radeon_vm_bo_update(struct radeon_device *rdev, | 2843 | int radeon_vm_bo_update(struct radeon_device *rdev, |
| 2837 | struct radeon_vm *vm, | 2844 | struct radeon_bo_va *bo_va, |
| 2838 | struct radeon_bo *bo, | ||
| 2839 | struct ttm_mem_reg *mem); | 2845 | struct ttm_mem_reg *mem); |
| 2840 | void radeon_vm_bo_invalidate(struct radeon_device *rdev, | 2846 | void radeon_vm_bo_invalidate(struct radeon_device *rdev, |
| 2841 | struct radeon_bo *bo); | 2847 | struct radeon_bo *bo); |
| @@ -2848,8 +2854,8 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev, | |||
| 2848 | struct radeon_bo_va *bo_va, | 2854 | struct radeon_bo_va *bo_va, |
| 2849 | uint64_t offset, | 2855 | uint64_t offset, |
| 2850 | uint32_t flags); | 2856 | uint32_t flags); |
| 2851 | int radeon_vm_bo_rmv(struct radeon_device *rdev, | 2857 | void radeon_vm_bo_rmv(struct radeon_device *rdev, |
| 2852 | struct radeon_bo_va *bo_va); | 2858 | struct radeon_bo_va *bo_va); |
| 2853 | 2859 | ||
| 2854 | /* audio */ | 2860 | /* audio */ |
| 2855 | void r600_audio_update_hdmi(struct work_struct *work); | 2861 | void r600_audio_update_hdmi(struct work_struct *work); |
diff --git a/drivers/gpu/drm/radeon/radeon_cs.c b/drivers/gpu/drm/radeon/radeon_cs.c index 71a143461478..ae763f60c8a0 100644 --- a/drivers/gpu/drm/radeon/radeon_cs.c +++ b/drivers/gpu/drm/radeon/radeon_cs.c | |||
| @@ -461,13 +461,23 @@ static int radeon_bo_vm_update_pte(struct radeon_cs_parser *p, | |||
| 461 | struct radeon_vm *vm) | 461 | struct radeon_vm *vm) |
| 462 | { | 462 | { |
| 463 | struct radeon_device *rdev = p->rdev; | 463 | struct radeon_device *rdev = p->rdev; |
| 464 | struct radeon_bo_va *bo_va; | ||
| 464 | int i, r; | 465 | int i, r; |
| 465 | 466 | ||
| 466 | r = radeon_vm_update_page_directory(rdev, vm); | 467 | r = radeon_vm_update_page_directory(rdev, vm); |
| 467 | if (r) | 468 | if (r) |
| 468 | return r; | 469 | return r; |
| 469 | 470 | ||
| 470 | r = radeon_vm_bo_update(rdev, vm, rdev->ring_tmp_bo.bo, | 471 | r = radeon_vm_clear_freed(rdev, vm); |
| 472 | if (r) | ||
| 473 | return r; | ||
| 474 | |||
| 475 | if (vm->ib_bo_va == NULL) { | ||
| 476 | DRM_ERROR("Tmp BO not in VM!\n"); | ||
| 477 | return -EINVAL; | ||
| 478 | } | ||
| 479 | |||
| 480 | r = radeon_vm_bo_update(rdev, vm->ib_bo_va, | ||
| 471 | &rdev->ring_tmp_bo.bo->tbo.mem); | 481 | &rdev->ring_tmp_bo.bo->tbo.mem); |
| 472 | if (r) | 482 | if (r) |
| 473 | return r; | 483 | return r; |
| @@ -480,7 +490,13 @@ static int radeon_bo_vm_update_pte(struct radeon_cs_parser *p, | |||
| 480 | continue; | 490 | continue; |
| 481 | 491 | ||
| 482 | bo = p->relocs[i].robj; | 492 | bo = p->relocs[i].robj; |
| 483 | r = radeon_vm_bo_update(rdev, vm, bo, &bo->tbo.mem); | 493 | bo_va = radeon_vm_bo_find(vm, bo); |
| 494 | if (bo_va == NULL) { | ||
| 495 | dev_err(rdev->dev, "bo %p not in vm %p\n", bo, vm); | ||
| 496 | return -EINVAL; | ||
| 497 | } | ||
| 498 | |||
| 499 | r = radeon_vm_bo_update(rdev, bo_va, &bo->tbo.mem); | ||
| 484 | if (r) | 500 | if (r) |
| 485 | return r; | 501 | return r; |
| 486 | } | 502 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c index 03686fab842d..697add2cd4e3 100644 --- a/drivers/gpu/drm/radeon/radeon_device.c +++ b/drivers/gpu/drm/radeon/radeon_device.c | |||
| @@ -1056,36 +1056,36 @@ static void radeon_check_arguments(struct radeon_device *rdev) | |||
| 1056 | if (!radeon_check_pot_argument(radeon_vm_size)) { | 1056 | if (!radeon_check_pot_argument(radeon_vm_size)) { |
| 1057 | dev_warn(rdev->dev, "VM size (%d) must be a power of 2\n", | 1057 | dev_warn(rdev->dev, "VM size (%d) must be a power of 2\n", |
| 1058 | radeon_vm_size); | 1058 | radeon_vm_size); |
| 1059 | radeon_vm_size = 4096; | 1059 | radeon_vm_size = 4; |
| 1060 | } | 1060 | } |
| 1061 | 1061 | ||
| 1062 | if (radeon_vm_size < 4) { | 1062 | if (radeon_vm_size < 1) { |
| 1063 | dev_warn(rdev->dev, "VM size (%d) to small, min is 4MB\n", | 1063 | dev_warn(rdev->dev, "VM size (%d) to small, min is 1GB\n", |
| 1064 | radeon_vm_size); | 1064 | radeon_vm_size); |
| 1065 | radeon_vm_size = 4096; | 1065 | radeon_vm_size = 4; |
| 1066 | } | 1066 | } |
| 1067 | 1067 | ||
| 1068 | /* | 1068 | /* |
| 1069 | * Max GPUVM size for Cayman, SI and CI are 40 bits. | 1069 | * Max GPUVM size for Cayman, SI and CI are 40 bits. |
| 1070 | */ | 1070 | */ |
| 1071 | if (radeon_vm_size > 1024*1024) { | 1071 | if (radeon_vm_size > 1024) { |
| 1072 | dev_warn(rdev->dev, "VM size (%d) to large, max is 1TB\n", | 1072 | dev_warn(rdev->dev, "VM size (%d) too large, max is 1TB\n", |
| 1073 | radeon_vm_size); | 1073 | radeon_vm_size); |
| 1074 | radeon_vm_size = 4096; | 1074 | radeon_vm_size = 4; |
| 1075 | } | 1075 | } |
| 1076 | 1076 | ||
| 1077 | /* defines number of bits in page table versus page directory, | 1077 | /* defines number of bits in page table versus page directory, |
| 1078 | * a page is 4KB so we have 12 bits offset, minimum 9 bits in the | 1078 | * a page is 4KB so we have 12 bits offset, minimum 9 bits in the |
| 1079 | * page table and the remaining bits are in the page directory */ | 1079 | * page table and the remaining bits are in the page directory */ |
| 1080 | if (radeon_vm_block_size < 9) { | 1080 | if (radeon_vm_block_size < 9) { |
| 1081 | dev_warn(rdev->dev, "VM page table size (%d) to small\n", | 1081 | dev_warn(rdev->dev, "VM page table size (%d) too small\n", |
| 1082 | radeon_vm_block_size); | 1082 | radeon_vm_block_size); |
| 1083 | radeon_vm_block_size = 9; | 1083 | radeon_vm_block_size = 9; |
| 1084 | } | 1084 | } |
| 1085 | 1085 | ||
| 1086 | if (radeon_vm_block_size > 24 || | 1086 | if (radeon_vm_block_size > 24 || |
| 1087 | radeon_vm_size < (1ull << radeon_vm_block_size)) { | 1087 | (radeon_vm_size * 1024) < (1ull << radeon_vm_block_size)) { |
| 1088 | dev_warn(rdev->dev, "VM page table size (%d) to large\n", | 1088 | dev_warn(rdev->dev, "VM page table size (%d) too large\n", |
| 1089 | radeon_vm_block_size); | 1089 | radeon_vm_block_size); |
| 1090 | radeon_vm_block_size = 9; | 1090 | radeon_vm_block_size = 9; |
| 1091 | } | 1091 | } |
| @@ -1238,7 +1238,7 @@ int radeon_device_init(struct radeon_device *rdev, | |||
| 1238 | /* Adjust VM size here. | 1238 | /* Adjust VM size here. |
| 1239 | * Max GPUVM size for cayman+ is 40 bits. | 1239 | * Max GPUVM size for cayman+ is 40 bits. |
| 1240 | */ | 1240 | */ |
| 1241 | rdev->vm_manager.max_pfn = radeon_vm_size << 8; | 1241 | rdev->vm_manager.max_pfn = radeon_vm_size << 18; |
| 1242 | 1242 | ||
| 1243 | /* Set asic functions */ | 1243 | /* Set asic functions */ |
| 1244 | r = radeon_asic_init(rdev); | 1244 | r = radeon_asic_init(rdev); |
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c index 13896edcf0b6..bf25061c8ac4 100644 --- a/drivers/gpu/drm/radeon/radeon_display.c +++ b/drivers/gpu/drm/radeon/radeon_display.c | |||
| @@ -366,7 +366,6 @@ void radeon_crtc_handle_flip(struct radeon_device *rdev, int crtc_id) | |||
| 366 | spin_unlock_irqrestore(&rdev->ddev->event_lock, flags); | 366 | spin_unlock_irqrestore(&rdev->ddev->event_lock, flags); |
| 367 | 367 | ||
| 368 | drm_vblank_put(rdev->ddev, radeon_crtc->crtc_id); | 368 | drm_vblank_put(rdev->ddev, radeon_crtc->crtc_id); |
| 369 | radeon_fence_unref(&work->fence); | ||
| 370 | radeon_irq_kms_pflip_irq_put(rdev, work->crtc_id); | 369 | radeon_irq_kms_pflip_irq_put(rdev, work->crtc_id); |
| 371 | queue_work(radeon_crtc->flip_queue, &work->unpin_work); | 370 | queue_work(radeon_crtc->flip_queue, &work->unpin_work); |
| 372 | } | 371 | } |
| @@ -386,51 +385,108 @@ static void radeon_flip_work_func(struct work_struct *__work) | |||
| 386 | struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[work->crtc_id]; | 385 | struct radeon_crtc *radeon_crtc = rdev->mode_info.crtcs[work->crtc_id]; |
| 387 | 386 | ||
| 388 | struct drm_crtc *crtc = &radeon_crtc->base; | 387 | struct drm_crtc *crtc = &radeon_crtc->base; |
| 389 | struct drm_framebuffer *fb = work->fb; | ||
| 390 | |||
| 391 | uint32_t tiling_flags, pitch_pixels; | ||
| 392 | uint64_t base; | ||
| 393 | |||
| 394 | unsigned long flags; | 388 | unsigned long flags; |
| 395 | int r; | 389 | int r; |
| 396 | 390 | ||
| 397 | down_read(&rdev->exclusive_lock); | 391 | down_read(&rdev->exclusive_lock); |
| 398 | while (work->fence) { | 392 | if (work->fence) { |
| 399 | r = radeon_fence_wait(work->fence, false); | 393 | r = radeon_fence_wait(work->fence, false); |
| 400 | if (r == -EDEADLK) { | 394 | if (r == -EDEADLK) { |
| 401 | up_read(&rdev->exclusive_lock); | 395 | up_read(&rdev->exclusive_lock); |
| 402 | r = radeon_gpu_reset(rdev); | 396 | r = radeon_gpu_reset(rdev); |
| 403 | down_read(&rdev->exclusive_lock); | 397 | down_read(&rdev->exclusive_lock); |
| 404 | } | 398 | } |
| 399 | if (r) | ||
| 400 | DRM_ERROR("failed to wait on page flip fence (%d)!\n", r); | ||
| 405 | 401 | ||
| 406 | if (r) { | 402 | /* We continue with the page flip even if we failed to wait on |
| 407 | DRM_ERROR("failed to wait on page flip fence (%d)!\n", | 403 | * the fence, otherwise the DRM core and userspace will be |
| 408 | r); | 404 | * confused about which BO the CRTC is scanning out |
| 409 | goto cleanup; | 405 | */ |
| 410 | } else | 406 | |
| 411 | radeon_fence_unref(&work->fence); | 407 | radeon_fence_unref(&work->fence); |
| 412 | } | 408 | } |
| 413 | 409 | ||
| 410 | /* We borrow the event spin lock for protecting flip_status */ | ||
| 411 | spin_lock_irqsave(&crtc->dev->event_lock, flags); | ||
| 412 | |||
| 413 | /* set the proper interrupt */ | ||
| 414 | radeon_irq_kms_pflip_irq_get(rdev, radeon_crtc->crtc_id); | ||
| 415 | |||
| 416 | /* do the flip (mmio) */ | ||
| 417 | radeon_page_flip(rdev, radeon_crtc->crtc_id, work->base); | ||
| 418 | |||
| 419 | radeon_crtc->flip_status = RADEON_FLIP_SUBMITTED; | ||
| 420 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | ||
| 421 | up_read(&rdev->exclusive_lock); | ||
| 422 | } | ||
| 423 | |||
| 424 | static int radeon_crtc_page_flip(struct drm_crtc *crtc, | ||
| 425 | struct drm_framebuffer *fb, | ||
| 426 | struct drm_pending_vblank_event *event, | ||
| 427 | uint32_t page_flip_flags) | ||
| 428 | { | ||
| 429 | struct drm_device *dev = crtc->dev; | ||
| 430 | struct radeon_device *rdev = dev->dev_private; | ||
| 431 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); | ||
| 432 | struct radeon_framebuffer *old_radeon_fb; | ||
| 433 | struct radeon_framebuffer *new_radeon_fb; | ||
| 434 | struct drm_gem_object *obj; | ||
| 435 | struct radeon_flip_work *work; | ||
| 436 | struct radeon_bo *new_rbo; | ||
| 437 | uint32_t tiling_flags, pitch_pixels; | ||
| 438 | uint64_t base; | ||
| 439 | unsigned long flags; | ||
| 440 | int r; | ||
| 441 | |||
| 442 | work = kzalloc(sizeof *work, GFP_KERNEL); | ||
| 443 | if (work == NULL) | ||
| 444 | return -ENOMEM; | ||
| 445 | |||
| 446 | INIT_WORK(&work->flip_work, radeon_flip_work_func); | ||
| 447 | INIT_WORK(&work->unpin_work, radeon_unpin_work_func); | ||
| 448 | |||
| 449 | work->rdev = rdev; | ||
| 450 | work->crtc_id = radeon_crtc->crtc_id; | ||
| 451 | work->event = event; | ||
| 452 | |||
| 453 | /* schedule unpin of the old buffer */ | ||
| 454 | old_radeon_fb = to_radeon_framebuffer(crtc->primary->fb); | ||
| 455 | obj = old_radeon_fb->obj; | ||
| 456 | |||
| 457 | /* take a reference to the old object */ | ||
| 458 | drm_gem_object_reference(obj); | ||
| 459 | work->old_rbo = gem_to_radeon_bo(obj); | ||
| 460 | |||
| 461 | new_radeon_fb = to_radeon_framebuffer(fb); | ||
| 462 | obj = new_radeon_fb->obj; | ||
| 463 | new_rbo = gem_to_radeon_bo(obj); | ||
| 464 | |||
| 465 | spin_lock(&new_rbo->tbo.bdev->fence_lock); | ||
| 466 | if (new_rbo->tbo.sync_obj) | ||
| 467 | work->fence = radeon_fence_ref(new_rbo->tbo.sync_obj); | ||
| 468 | spin_unlock(&new_rbo->tbo.bdev->fence_lock); | ||
| 469 | |||
| 414 | /* pin the new buffer */ | 470 | /* pin the new buffer */ |
| 415 | DRM_DEBUG_DRIVER("flip-ioctl() cur_fbo = %p, cur_bbo = %p\n", | 471 | DRM_DEBUG_DRIVER("flip-ioctl() cur_rbo = %p, new_rbo = %p\n", |
| 416 | work->old_rbo, work->new_rbo); | 472 | work->old_rbo, new_rbo); |
| 417 | 473 | ||
| 418 | r = radeon_bo_reserve(work->new_rbo, false); | 474 | r = radeon_bo_reserve(new_rbo, false); |
| 419 | if (unlikely(r != 0)) { | 475 | if (unlikely(r != 0)) { |
| 420 | DRM_ERROR("failed to reserve new rbo buffer before flip\n"); | 476 | DRM_ERROR("failed to reserve new rbo buffer before flip\n"); |
| 421 | goto cleanup; | 477 | goto cleanup; |
| 422 | } | 478 | } |
| 423 | /* Only 27 bit offset for legacy CRTC */ | 479 | /* Only 27 bit offset for legacy CRTC */ |
| 424 | r = radeon_bo_pin_restricted(work->new_rbo, RADEON_GEM_DOMAIN_VRAM, | 480 | r = radeon_bo_pin_restricted(new_rbo, RADEON_GEM_DOMAIN_VRAM, |
| 425 | ASIC_IS_AVIVO(rdev) ? 0 : 1 << 27, &base); | 481 | ASIC_IS_AVIVO(rdev) ? 0 : 1 << 27, &base); |
| 426 | if (unlikely(r != 0)) { | 482 | if (unlikely(r != 0)) { |
| 427 | radeon_bo_unreserve(work->new_rbo); | 483 | radeon_bo_unreserve(new_rbo); |
| 428 | r = -EINVAL; | 484 | r = -EINVAL; |
| 429 | DRM_ERROR("failed to pin new rbo buffer before flip\n"); | 485 | DRM_ERROR("failed to pin new rbo buffer before flip\n"); |
| 430 | goto cleanup; | 486 | goto cleanup; |
| 431 | } | 487 | } |
| 432 | radeon_bo_get_tiling_flags(work->new_rbo, &tiling_flags, NULL); | 488 | radeon_bo_get_tiling_flags(new_rbo, &tiling_flags, NULL); |
| 433 | radeon_bo_unreserve(work->new_rbo); | 489 | radeon_bo_unreserve(new_rbo); |
| 434 | 490 | ||
| 435 | if (!ASIC_IS_AVIVO(rdev)) { | 491 | if (!ASIC_IS_AVIVO(rdev)) { |
| 436 | /* crtc offset is from display base addr not FB location */ | 492 | /* crtc offset is from display base addr not FB location */ |
| @@ -467,6 +523,7 @@ static void radeon_flip_work_func(struct work_struct *__work) | |||
| 467 | } | 523 | } |
| 468 | base &= ~7; | 524 | base &= ~7; |
| 469 | } | 525 | } |
| 526 | work->base = base; | ||
| 470 | 527 | ||
| 471 | r = drm_vblank_get(crtc->dev, radeon_crtc->crtc_id); | 528 | r = drm_vblank_get(crtc->dev, radeon_crtc->crtc_id); |
| 472 | if (r) { | 529 | if (r) { |
| @@ -477,100 +534,42 @@ static void radeon_flip_work_func(struct work_struct *__work) | |||
| 477 | /* We borrow the event spin lock for protecting flip_work */ | 534 | /* We borrow the event spin lock for protecting flip_work */ |
| 478 | spin_lock_irqsave(&crtc->dev->event_lock, flags); | 535 | spin_lock_irqsave(&crtc->dev->event_lock, flags); |
| 479 | 536 | ||
| 480 | /* set the proper interrupt */ | 537 | if (radeon_crtc->flip_status != RADEON_FLIP_NONE) { |
| 481 | radeon_irq_kms_pflip_irq_get(rdev, radeon_crtc->crtc_id); | 538 | DRM_DEBUG_DRIVER("flip queue: crtc already busy\n"); |
| 539 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | ||
| 540 | r = -EBUSY; | ||
| 541 | goto vblank_cleanup; | ||
| 542 | } | ||
| 543 | radeon_crtc->flip_status = RADEON_FLIP_PENDING; | ||
| 544 | radeon_crtc->flip_work = work; | ||
| 482 | 545 | ||
| 483 | /* do the flip (mmio) */ | 546 | /* update crtc fb */ |
| 484 | radeon_page_flip(rdev, radeon_crtc->crtc_id, base); | 547 | crtc->primary->fb = fb; |
| 485 | 548 | ||
| 486 | radeon_crtc->flip_status = RADEON_FLIP_SUBMITTED; | ||
| 487 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | 549 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); |
| 488 | up_read(&rdev->exclusive_lock); | ||
| 489 | 550 | ||
| 490 | return; | 551 | queue_work(radeon_crtc->flip_queue, &work->flip_work); |
| 552 | return 0; | ||
| 553 | |||
| 554 | vblank_cleanup: | ||
| 555 | drm_vblank_put(crtc->dev, radeon_crtc->crtc_id); | ||
| 491 | 556 | ||
| 492 | pflip_cleanup: | 557 | pflip_cleanup: |
| 493 | if (unlikely(radeon_bo_reserve(work->new_rbo, false) != 0)) { | 558 | if (unlikely(radeon_bo_reserve(new_rbo, false) != 0)) { |
| 494 | DRM_ERROR("failed to reserve new rbo in error path\n"); | 559 | DRM_ERROR("failed to reserve new rbo in error path\n"); |
| 495 | goto cleanup; | 560 | goto cleanup; |
| 496 | } | 561 | } |
| 497 | if (unlikely(radeon_bo_unpin(work->new_rbo) != 0)) { | 562 | if (unlikely(radeon_bo_unpin(new_rbo) != 0)) { |
| 498 | DRM_ERROR("failed to unpin new rbo in error path\n"); | 563 | DRM_ERROR("failed to unpin new rbo in error path\n"); |
| 499 | } | 564 | } |
| 500 | radeon_bo_unreserve(work->new_rbo); | 565 | radeon_bo_unreserve(new_rbo); |
| 501 | 566 | ||
| 502 | cleanup: | 567 | cleanup: |
| 503 | drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base); | 568 | drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base); |
| 504 | radeon_fence_unref(&work->fence); | 569 | radeon_fence_unref(&work->fence); |
| 505 | kfree(work); | 570 | kfree(work); |
| 506 | up_read(&rdev->exclusive_lock); | ||
| 507 | } | ||
| 508 | |||
| 509 | static int radeon_crtc_page_flip(struct drm_crtc *crtc, | ||
| 510 | struct drm_framebuffer *fb, | ||
| 511 | struct drm_pending_vblank_event *event, | ||
| 512 | uint32_t page_flip_flags) | ||
| 513 | { | ||
| 514 | struct drm_device *dev = crtc->dev; | ||
| 515 | struct radeon_device *rdev = dev->dev_private; | ||
| 516 | struct radeon_crtc *radeon_crtc = to_radeon_crtc(crtc); | ||
| 517 | struct radeon_framebuffer *old_radeon_fb; | ||
| 518 | struct radeon_framebuffer *new_radeon_fb; | ||
| 519 | struct drm_gem_object *obj; | ||
| 520 | struct radeon_flip_work *work; | ||
| 521 | unsigned long flags; | ||
| 522 | |||
| 523 | work = kzalloc(sizeof *work, GFP_KERNEL); | ||
| 524 | if (work == NULL) | ||
| 525 | return -ENOMEM; | ||
| 526 | |||
| 527 | INIT_WORK(&work->flip_work, radeon_flip_work_func); | ||
| 528 | INIT_WORK(&work->unpin_work, radeon_unpin_work_func); | ||
| 529 | |||
| 530 | work->rdev = rdev; | ||
| 531 | work->crtc_id = radeon_crtc->crtc_id; | ||
| 532 | work->fb = fb; | ||
| 533 | work->event = event; | ||
| 534 | |||
| 535 | /* schedule unpin of the old buffer */ | ||
| 536 | old_radeon_fb = to_radeon_framebuffer(crtc->primary->fb); | ||
| 537 | obj = old_radeon_fb->obj; | ||
| 538 | |||
| 539 | /* take a reference to the old object */ | ||
| 540 | drm_gem_object_reference(obj); | ||
| 541 | work->old_rbo = gem_to_radeon_bo(obj); | ||
| 542 | |||
| 543 | new_radeon_fb = to_radeon_framebuffer(fb); | ||
| 544 | obj = new_radeon_fb->obj; | ||
| 545 | work->new_rbo = gem_to_radeon_bo(obj); | ||
| 546 | |||
| 547 | spin_lock(&work->new_rbo->tbo.bdev->fence_lock); | ||
| 548 | if (work->new_rbo->tbo.sync_obj) | ||
| 549 | work->fence = radeon_fence_ref(work->new_rbo->tbo.sync_obj); | ||
| 550 | spin_unlock(&work->new_rbo->tbo.bdev->fence_lock); | ||
| 551 | |||
| 552 | /* We borrow the event spin lock for protecting flip_work */ | ||
| 553 | spin_lock_irqsave(&crtc->dev->event_lock, flags); | ||
| 554 | 571 | ||
| 555 | if (radeon_crtc->flip_status != RADEON_FLIP_NONE) { | 572 | return r; |
| 556 | DRM_DEBUG_DRIVER("flip queue: crtc already busy\n"); | ||
| 557 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | ||
| 558 | drm_gem_object_unreference_unlocked(&work->old_rbo->gem_base); | ||
| 559 | radeon_fence_unref(&work->fence); | ||
| 560 | kfree(work); | ||
| 561 | return -EBUSY; | ||
| 562 | } | ||
| 563 | radeon_crtc->flip_status = RADEON_FLIP_PENDING; | ||
| 564 | radeon_crtc->flip_work = work; | ||
| 565 | |||
| 566 | /* update crtc fb */ | ||
| 567 | crtc->primary->fb = fb; | ||
| 568 | |||
| 569 | spin_unlock_irqrestore(&crtc->dev->event_lock, flags); | ||
| 570 | |||
| 571 | queue_work(radeon_crtc->flip_queue, &work->flip_work); | ||
| 572 | |||
| 573 | return 0; | ||
| 574 | } | 573 | } |
| 575 | 574 | ||
| 576 | static int | 575 | static int |
| @@ -830,6 +829,10 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector) | |||
| 830 | struct radeon_device *rdev = dev->dev_private; | 829 | struct radeon_device *rdev = dev->dev_private; |
| 831 | int ret = 0; | 830 | int ret = 0; |
| 832 | 831 | ||
| 832 | /* don't leak the edid if we already fetched it in detect() */ | ||
| 833 | if (radeon_connector->edid) | ||
| 834 | goto got_edid; | ||
| 835 | |||
| 833 | /* on hw with routers, select right port */ | 836 | /* on hw with routers, select right port */ |
| 834 | if (radeon_connector->router.ddc_valid) | 837 | if (radeon_connector->router.ddc_valid) |
| 835 | radeon_router_select_ddc_port(radeon_connector); | 838 | radeon_router_select_ddc_port(radeon_connector); |
| @@ -868,6 +871,7 @@ int radeon_ddc_get_modes(struct radeon_connector *radeon_connector) | |||
| 868 | radeon_connector->edid = radeon_bios_get_hardcoded_edid(rdev); | 871 | radeon_connector->edid = radeon_bios_get_hardcoded_edid(rdev); |
| 869 | } | 872 | } |
| 870 | if (radeon_connector->edid) { | 873 | if (radeon_connector->edid) { |
| 874 | got_edid: | ||
| 871 | drm_mode_connector_update_edid_property(&radeon_connector->base, radeon_connector->edid); | 875 | drm_mode_connector_update_edid_property(&radeon_connector->base, radeon_connector->edid); |
| 872 | ret = drm_add_edid_modes(&radeon_connector->base, radeon_connector->edid); | 876 | ret = drm_add_edid_modes(&radeon_connector->base, radeon_connector->edid); |
| 873 | drm_edid_to_eld(&radeon_connector->base, radeon_connector->edid); | 877 | drm_edid_to_eld(&radeon_connector->base, radeon_connector->edid); |
diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index cb1421369e3a..e9e361084249 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c | |||
| @@ -173,7 +173,7 @@ int radeon_dpm = -1; | |||
| 173 | int radeon_aspm = -1; | 173 | int radeon_aspm = -1; |
| 174 | int radeon_runtime_pm = -1; | 174 | int radeon_runtime_pm = -1; |
| 175 | int radeon_hard_reset = 0; | 175 | int radeon_hard_reset = 0; |
| 176 | int radeon_vm_size = 4096; | 176 | int radeon_vm_size = 4; |
| 177 | int radeon_vm_block_size = 9; | 177 | int radeon_vm_block_size = 9; |
| 178 | int radeon_deep_color = 0; | 178 | int radeon_deep_color = 0; |
| 179 | 179 | ||
| @@ -243,7 +243,7 @@ module_param_named(runpm, radeon_runtime_pm, int, 0444); | |||
| 243 | MODULE_PARM_DESC(hard_reset, "PCI config reset (1 = force enable, 0 = disable (default))"); | 243 | MODULE_PARM_DESC(hard_reset, "PCI config reset (1 = force enable, 0 = disable (default))"); |
| 244 | module_param_named(hard_reset, radeon_hard_reset, int, 0444); | 244 | module_param_named(hard_reset, radeon_hard_reset, int, 0444); |
| 245 | 245 | ||
| 246 | MODULE_PARM_DESC(vm_size, "VM address space size in megabytes (default 4GB)"); | 246 | MODULE_PARM_DESC(vm_size, "VM address space size in gigabytes (default 4GB)"); |
| 247 | module_param_named(vm_size, radeon_vm_size, int, 0444); | 247 | module_param_named(vm_size, radeon_vm_size, int, 0444); |
| 248 | 248 | ||
| 249 | MODULE_PARM_DESC(vm_block_size, "VM page table size in bits (default 9)"); | 249 | MODULE_PARM_DESC(vm_block_size, "VM page table size in bits (default 9)"); |
diff --git a/drivers/gpu/drm/radeon/radeon_kms.c b/drivers/gpu/drm/radeon/radeon_kms.c index 35d931881b4b..d25ae6acfd5a 100644 --- a/drivers/gpu/drm/radeon/radeon_kms.c +++ b/drivers/gpu/drm/radeon/radeon_kms.c | |||
| @@ -579,7 +579,7 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
| 579 | /* new gpu have virtual address space support */ | 579 | /* new gpu have virtual address space support */ |
| 580 | if (rdev->family >= CHIP_CAYMAN) { | 580 | if (rdev->family >= CHIP_CAYMAN) { |
| 581 | struct radeon_fpriv *fpriv; | 581 | struct radeon_fpriv *fpriv; |
| 582 | struct radeon_bo_va *bo_va; | 582 | struct radeon_vm *vm; |
| 583 | int r; | 583 | int r; |
| 584 | 584 | ||
| 585 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); | 585 | fpriv = kzalloc(sizeof(*fpriv), GFP_KERNEL); |
| @@ -587,7 +587,8 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
| 587 | return -ENOMEM; | 587 | return -ENOMEM; |
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | r = radeon_vm_init(rdev, &fpriv->vm); | 590 | vm = &fpriv->vm; |
| 591 | r = radeon_vm_init(rdev, vm); | ||
| 591 | if (r) { | 592 | if (r) { |
| 592 | kfree(fpriv); | 593 | kfree(fpriv); |
| 593 | return r; | 594 | return r; |
| @@ -596,22 +597,23 @@ int radeon_driver_open_kms(struct drm_device *dev, struct drm_file *file_priv) | |||
| 596 | if (rdev->accel_working) { | 597 | if (rdev->accel_working) { |
| 597 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); | 598 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); |
| 598 | if (r) { | 599 | if (r) { |
| 599 | radeon_vm_fini(rdev, &fpriv->vm); | 600 | radeon_vm_fini(rdev, vm); |
| 600 | kfree(fpriv); | 601 | kfree(fpriv); |
| 601 | return r; | 602 | return r; |
| 602 | } | 603 | } |
| 603 | 604 | ||
| 604 | /* map the ib pool buffer read only into | 605 | /* map the ib pool buffer read only into |
| 605 | * virtual address space */ | 606 | * virtual address space */ |
| 606 | bo_va = radeon_vm_bo_add(rdev, &fpriv->vm, | 607 | vm->ib_bo_va = radeon_vm_bo_add(rdev, vm, |
| 607 | rdev->ring_tmp_bo.bo); | 608 | rdev->ring_tmp_bo.bo); |
| 608 | r = radeon_vm_bo_set_addr(rdev, bo_va, RADEON_VA_IB_OFFSET, | 609 | r = radeon_vm_bo_set_addr(rdev, vm->ib_bo_va, |
| 610 | RADEON_VA_IB_OFFSET, | ||
| 609 | RADEON_VM_PAGE_READABLE | | 611 | RADEON_VM_PAGE_READABLE | |
| 610 | RADEON_VM_PAGE_SNOOPED); | 612 | RADEON_VM_PAGE_SNOOPED); |
| 611 | 613 | ||
| 612 | radeon_bo_unreserve(rdev->ring_tmp_bo.bo); | 614 | radeon_bo_unreserve(rdev->ring_tmp_bo.bo); |
| 613 | if (r) { | 615 | if (r) { |
| 614 | radeon_vm_fini(rdev, &fpriv->vm); | 616 | radeon_vm_fini(rdev, vm); |
| 615 | kfree(fpriv); | 617 | kfree(fpriv); |
| 616 | return r; | 618 | return r; |
| 617 | } | 619 | } |
| @@ -640,21 +642,19 @@ void radeon_driver_postclose_kms(struct drm_device *dev, | |||
| 640 | /* new gpu have virtual address space support */ | 642 | /* new gpu have virtual address space support */ |
| 641 | if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) { | 643 | if (rdev->family >= CHIP_CAYMAN && file_priv->driver_priv) { |
| 642 | struct radeon_fpriv *fpriv = file_priv->driver_priv; | 644 | struct radeon_fpriv *fpriv = file_priv->driver_priv; |
| 643 | struct radeon_bo_va *bo_va; | 645 | struct radeon_vm *vm = &fpriv->vm; |
| 644 | int r; | 646 | int r; |
| 645 | 647 | ||
| 646 | if (rdev->accel_working) { | 648 | if (rdev->accel_working) { |
| 647 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); | 649 | r = radeon_bo_reserve(rdev->ring_tmp_bo.bo, false); |
| 648 | if (!r) { | 650 | if (!r) { |
| 649 | bo_va = radeon_vm_bo_find(&fpriv->vm, | 651 | if (vm->ib_bo_va) |
| 650 | rdev->ring_tmp_bo.bo); | 652 | radeon_vm_bo_rmv(rdev, vm->ib_bo_va); |
| 651 | if (bo_va) | ||
| 652 | radeon_vm_bo_rmv(rdev, bo_va); | ||
| 653 | radeon_bo_unreserve(rdev->ring_tmp_bo.bo); | 653 | radeon_bo_unreserve(rdev->ring_tmp_bo.bo); |
| 654 | } | 654 | } |
| 655 | } | 655 | } |
| 656 | 656 | ||
| 657 | radeon_vm_fini(rdev, &fpriv->vm); | 657 | radeon_vm_fini(rdev, vm); |
| 658 | kfree(fpriv); | 658 | kfree(fpriv); |
| 659 | file_priv->driver_priv = NULL; | 659 | file_priv->driver_priv = NULL; |
| 660 | } | 660 | } |
diff --git a/drivers/gpu/drm/radeon/radeon_vm.c b/drivers/gpu/drm/radeon/radeon_vm.c index eecff6bbd341..725d3669014f 100644 --- a/drivers/gpu/drm/radeon/radeon_vm.c +++ b/drivers/gpu/drm/radeon/radeon_vm.c | |||
| @@ -332,6 +332,7 @@ struct radeon_bo_va *radeon_vm_bo_add(struct radeon_device *rdev, | |||
| 332 | bo_va->ref_count = 1; | 332 | bo_va->ref_count = 1; |
| 333 | INIT_LIST_HEAD(&bo_va->bo_list); | 333 | INIT_LIST_HEAD(&bo_va->bo_list); |
| 334 | INIT_LIST_HEAD(&bo_va->vm_list); | 334 | INIT_LIST_HEAD(&bo_va->vm_list); |
| 335 | INIT_LIST_HEAD(&bo_va->vm_status); | ||
| 335 | 336 | ||
| 336 | mutex_lock(&vm->mutex); | 337 | mutex_lock(&vm->mutex); |
| 337 | list_add(&bo_va->vm_list, &vm->va); | 338 | list_add(&bo_va->vm_list, &vm->va); |
| @@ -468,6 +469,19 @@ int radeon_vm_bo_set_addr(struct radeon_device *rdev, | |||
| 468 | head = &tmp->vm_list; | 469 | head = &tmp->vm_list; |
| 469 | } | 470 | } |
| 470 | 471 | ||
| 472 | if (bo_va->soffset) { | ||
| 473 | /* add a clone of the bo_va to clear the old address */ | ||
| 474 | tmp = kzalloc(sizeof(struct radeon_bo_va), GFP_KERNEL); | ||
| 475 | if (!tmp) { | ||
| 476 | mutex_unlock(&vm->mutex); | ||
| 477 | return -ENOMEM; | ||
| 478 | } | ||
| 479 | tmp->soffset = bo_va->soffset; | ||
| 480 | tmp->eoffset = bo_va->eoffset; | ||
| 481 | tmp->vm = vm; | ||
| 482 | list_add(&tmp->vm_status, &vm->freed); | ||
| 483 | } | ||
| 484 | |||
| 471 | bo_va->soffset = soffset; | 485 | bo_va->soffset = soffset; |
| 472 | bo_va->eoffset = eoffset; | 486 | bo_va->eoffset = eoffset; |
| 473 | bo_va->flags = flags; | 487 | bo_va->flags = flags; |
| @@ -823,25 +837,19 @@ static void radeon_vm_update_ptes(struct radeon_device *rdev, | |||
| 823 | * Object have to be reserved and mutex must be locked! | 837 | * Object have to be reserved and mutex must be locked! |
| 824 | */ | 838 | */ |
| 825 | int radeon_vm_bo_update(struct radeon_device *rdev, | 839 | int radeon_vm_bo_update(struct radeon_device *rdev, |
| 826 | struct radeon_vm *vm, | 840 | struct radeon_bo_va *bo_va, |
| 827 | struct radeon_bo *bo, | ||
| 828 | struct ttm_mem_reg *mem) | 841 | struct ttm_mem_reg *mem) |
| 829 | { | 842 | { |
| 843 | struct radeon_vm *vm = bo_va->vm; | ||
| 830 | struct radeon_ib ib; | 844 | struct radeon_ib ib; |
| 831 | struct radeon_bo_va *bo_va; | ||
| 832 | unsigned nptes, ndw; | 845 | unsigned nptes, ndw; |
| 833 | uint64_t addr; | 846 | uint64_t addr; |
| 834 | int r; | 847 | int r; |
| 835 | 848 | ||
| 836 | bo_va = radeon_vm_bo_find(vm, bo); | ||
| 837 | if (bo_va == NULL) { | ||
| 838 | dev_err(rdev->dev, "bo %p not in vm %p\n", bo, vm); | ||
| 839 | return -EINVAL; | ||
| 840 | } | ||
| 841 | 849 | ||
| 842 | if (!bo_va->soffset) { | 850 | if (!bo_va->soffset) { |
| 843 | dev_err(rdev->dev, "bo %p don't has a mapping in vm %p\n", | 851 | dev_err(rdev->dev, "bo %p don't has a mapping in vm %p\n", |
| 844 | bo, vm); | 852 | bo_va->bo, vm); |
| 845 | return -EINVAL; | 853 | return -EINVAL; |
| 846 | } | 854 | } |
| 847 | 855 | ||
| @@ -868,7 +876,7 @@ int radeon_vm_bo_update(struct radeon_device *rdev, | |||
| 868 | 876 | ||
| 869 | trace_radeon_vm_bo_update(bo_va); | 877 | trace_radeon_vm_bo_update(bo_va); |
| 870 | 878 | ||
| 871 | nptes = radeon_bo_ngpu_pages(bo); | 879 | nptes = (bo_va->eoffset - bo_va->soffset) / RADEON_GPU_PAGE_SIZE; |
| 872 | 880 | ||
| 873 | /* padding, etc. */ | 881 | /* padding, etc. */ |
| 874 | ndw = 64; | 882 | ndw = 64; |
| @@ -911,33 +919,61 @@ int radeon_vm_bo_update(struct radeon_device *rdev, | |||
| 911 | } | 919 | } |
| 912 | 920 | ||
| 913 | /** | 921 | /** |
| 922 | * radeon_vm_clear_freed - clear freed BOs in the PT | ||
| 923 | * | ||
| 924 | * @rdev: radeon_device pointer | ||
| 925 | * @vm: requested vm | ||
| 926 | * | ||
| 927 | * Make sure all freed BOs are cleared in the PT. | ||
| 928 | * Returns 0 for success. | ||
| 929 | * | ||
| 930 | * PTs have to be reserved and mutex must be locked! | ||
| 931 | */ | ||
| 932 | int radeon_vm_clear_freed(struct radeon_device *rdev, | ||
| 933 | struct radeon_vm *vm) | ||
| 934 | { | ||
| 935 | struct radeon_bo_va *bo_va, *tmp; | ||
| 936 | int r; | ||
| 937 | |||
| 938 | list_for_each_entry_safe(bo_va, tmp, &vm->freed, vm_status) { | ||
| 939 | list_del(&bo_va->vm_status); | ||
| 940 | r = radeon_vm_bo_update(rdev, bo_va, NULL); | ||
| 941 | kfree(bo_va); | ||
| 942 | if (r) | ||
| 943 | return r; | ||
| 944 | } | ||
| 945 | return 0; | ||
| 946 | |||
| 947 | } | ||
| 948 | |||
| 949 | /** | ||
| 914 | * radeon_vm_bo_rmv - remove a bo to a specific vm | 950 | * radeon_vm_bo_rmv - remove a bo to a specific vm |
| 915 | * | 951 | * |
| 916 | * @rdev: radeon_device pointer | 952 | * @rdev: radeon_device pointer |
| 917 | * @bo_va: requested bo_va | 953 | * @bo_va: requested bo_va |
| 918 | * | 954 | * |
| 919 | * Remove @bo_va->bo from the requested vm (cayman+). | 955 | * Remove @bo_va->bo from the requested vm (cayman+). |
| 920 | * Remove @bo_va->bo from the list of bos associated with the bo_va->vm and | ||
| 921 | * remove the ptes for @bo_va in the page table. | ||
| 922 | * Returns 0 for success. | ||
| 923 | * | 956 | * |
| 924 | * Object have to be reserved! | 957 | * Object have to be reserved! |
| 925 | */ | 958 | */ |
| 926 | int radeon_vm_bo_rmv(struct radeon_device *rdev, | 959 | void radeon_vm_bo_rmv(struct radeon_device *rdev, |
| 927 | struct radeon_bo_va *bo_va) | 960 | struct radeon_bo_va *bo_va) |
| 928 | { | 961 | { |
| 929 | int r = 0; | 962 | struct radeon_vm *vm = bo_va->vm; |
| 930 | 963 | ||
| 931 | mutex_lock(&bo_va->vm->mutex); | 964 | list_del(&bo_va->bo_list); |
| 932 | if (bo_va->soffset) | ||
| 933 | r = radeon_vm_bo_update(rdev, bo_va->vm, bo_va->bo, NULL); | ||
| 934 | 965 | ||
| 966 | mutex_lock(&vm->mutex); | ||
| 935 | list_del(&bo_va->vm_list); | 967 | list_del(&bo_va->vm_list); |
| 936 | mutex_unlock(&bo_va->vm->mutex); | ||
| 937 | list_del(&bo_va->bo_list); | ||
| 938 | 968 | ||
| 939 | kfree(bo_va); | 969 | if (bo_va->soffset) { |
| 940 | return r; | 970 | bo_va->bo = NULL; |
| 971 | list_add(&bo_va->vm_status, &vm->freed); | ||
| 972 | } else { | ||
| 973 | kfree(bo_va); | ||
| 974 | } | ||
| 975 | |||
| 976 | mutex_unlock(&vm->mutex); | ||
| 941 | } | 977 | } |
| 942 | 978 | ||
| 943 | /** | 979 | /** |
| @@ -975,11 +1011,13 @@ int radeon_vm_init(struct radeon_device *rdev, struct radeon_vm *vm) | |||
| 975 | int r; | 1011 | int r; |
| 976 | 1012 | ||
| 977 | vm->id = 0; | 1013 | vm->id = 0; |
| 1014 | vm->ib_bo_va = NULL; | ||
| 978 | vm->fence = NULL; | 1015 | vm->fence = NULL; |
| 979 | vm->last_flush = NULL; | 1016 | vm->last_flush = NULL; |
| 980 | vm->last_id_use = NULL; | 1017 | vm->last_id_use = NULL; |
| 981 | mutex_init(&vm->mutex); | 1018 | mutex_init(&vm->mutex); |
| 982 | INIT_LIST_HEAD(&vm->va); | 1019 | INIT_LIST_HEAD(&vm->va); |
| 1020 | INIT_LIST_HEAD(&vm->freed); | ||
| 983 | 1021 | ||
| 984 | pd_size = radeon_vm_directory_size(rdev); | 1022 | pd_size = radeon_vm_directory_size(rdev); |
| 985 | pd_entries = radeon_vm_num_pdes(rdev); | 1023 | pd_entries = radeon_vm_num_pdes(rdev); |
| @@ -1034,7 +1072,8 @@ void radeon_vm_fini(struct radeon_device *rdev, struct radeon_vm *vm) | |||
| 1034 | kfree(bo_va); | 1072 | kfree(bo_va); |
| 1035 | } | 1073 | } |
| 1036 | } | 1074 | } |
| 1037 | 1075 | list_for_each_entry_safe(bo_va, tmp, &vm->freed, vm_status) | |
| 1076 | kfree(bo_va); | ||
| 1038 | 1077 | ||
| 1039 | for (i = 0; i < radeon_vm_num_pdes(rdev); i++) | 1078 | for (i = 0; i < radeon_vm_num_pdes(rdev); i++) |
| 1040 | radeon_bo_unref(&vm->page_tables[i].bo); | 1079 | radeon_bo_unref(&vm->page_tables[i].bo); |
diff --git a/drivers/gpu/drm/radeon/rv515.c b/drivers/gpu/drm/radeon/rv515.c index 237dd29d9f1c..3e21e869015f 100644 --- a/drivers/gpu/drm/radeon/rv515.c +++ b/drivers/gpu/drm/radeon/rv515.c | |||
| @@ -406,8 +406,9 @@ void rv515_mc_resume(struct radeon_device *rdev, struct rv515_mc_save *save) | |||
| 406 | for (i = 0; i < rdev->num_crtc; i++) { | 406 | for (i = 0; i < rdev->num_crtc; i++) { |
| 407 | if (save->crtc_enabled[i]) { | 407 | if (save->crtc_enabled[i]) { |
| 408 | tmp = RREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + crtc_offsets[i]); | 408 | tmp = RREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + crtc_offsets[i]); |
| 409 | if ((tmp & 0x3) != 0) { | 409 | if ((tmp & 0x7) != 3) { |
| 410 | tmp &= ~0x3; | 410 | tmp &= ~0x7; |
| 411 | tmp |= 0x3; | ||
| 411 | WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + crtc_offsets[i], tmp); | 412 | WREG32(AVIVO_D1MODE_MASTER_UPDATE_MODE + crtc_offsets[i], tmp); |
| 412 | } | 413 | } |
| 413 | tmp = RREG32(AVIVO_D1GRPH_UPDATE + crtc_offsets[i]); | 414 | tmp = RREG32(AVIVO_D1GRPH_UPDATE + crtc_offsets[i]); |
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c index da041a43d82e..3c76e1dcdf04 100644 --- a/drivers/gpu/drm/radeon/rv770_dpm.c +++ b/drivers/gpu/drm/radeon/rv770_dpm.c | |||
| @@ -2329,12 +2329,6 @@ void rv770_get_engine_memory_ss(struct radeon_device *rdev) | |||
| 2329 | pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss, | 2329 | pi->mclk_ss = radeon_atombios_get_asic_ss_info(rdev, &ss, |
| 2330 | ASIC_INTERNAL_MEMORY_SS, 0); | 2330 | ASIC_INTERNAL_MEMORY_SS, 0); |
| 2331 | 2331 | ||
| 2332 | /* disable ss, causes hangs on some cayman boards */ | ||
| 2333 | if (rdev->family == CHIP_CAYMAN) { | ||
| 2334 | pi->sclk_ss = false; | ||
| 2335 | pi->mclk_ss = false; | ||
| 2336 | } | ||
| 2337 | |||
| 2338 | if (pi->sclk_ss || pi->mclk_ss) | 2332 | if (pi->sclk_ss || pi->mclk_ss) |
| 2339 | pi->dynamic_ss = true; | 2333 | pi->dynamic_ss = true; |
| 2340 | else | 2334 | else |
diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c index 730cee2c34cf..9e854fd016da 100644 --- a/drivers/gpu/drm/radeon/si.c +++ b/drivers/gpu/drm/radeon/si.c | |||
| @@ -6103,6 +6103,7 @@ static inline u32 si_get_ih_wptr(struct radeon_device *rdev) | |||
| 6103 | tmp = RREG32(IH_RB_CNTL); | 6103 | tmp = RREG32(IH_RB_CNTL); |
| 6104 | tmp |= IH_WPTR_OVERFLOW_CLEAR; | 6104 | tmp |= IH_WPTR_OVERFLOW_CLEAR; |
| 6105 | WREG32(IH_RB_CNTL, tmp); | 6105 | WREG32(IH_RB_CNTL, tmp); |
| 6106 | wptr &= ~RB_OVERFLOW; | ||
| 6106 | } | 6107 | } |
| 6107 | return (wptr & rdev->ih.ptr_mask); | 6108 | return (wptr & rdev->ih.ptr_mask); |
| 6108 | } | 6109 | } |
| @@ -6376,14 +6377,16 @@ restart_ih: | |||
| 6376 | case 147: | 6377 | case 147: |
| 6377 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); | 6378 | addr = RREG32(VM_CONTEXT1_PROTECTION_FAULT_ADDR); |
| 6378 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); | 6379 | status = RREG32(VM_CONTEXT1_PROTECTION_FAULT_STATUS); |
| 6380 | /* reset addr and status */ | ||
| 6381 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); | ||
| 6382 | if (addr == 0x0 && status == 0x0) | ||
| 6383 | break; | ||
| 6379 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); | 6384 | dev_err(rdev->dev, "GPU fault detected: %d 0x%08x\n", src_id, src_data); |
| 6380 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", | 6385 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_ADDR 0x%08X\n", |
| 6381 | addr); | 6386 | addr); |
| 6382 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", | 6387 | dev_err(rdev->dev, " VM_CONTEXT1_PROTECTION_FAULT_STATUS 0x%08X\n", |
| 6383 | status); | 6388 | status); |
| 6384 | si_vm_decode_fault(rdev, status, addr); | 6389 | si_vm_decode_fault(rdev, status, addr); |
| 6385 | /* reset addr and status */ | ||
| 6386 | WREG32_P(VM_CONTEXT1_CNTL2, 1, ~1); | ||
| 6387 | break; | 6390 | break; |
| 6388 | case 176: /* RINGID0 CP_INT */ | 6391 | case 176: /* RINGID0 CP_INT */ |
| 6389 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); | 6392 | radeon_fence_process(rdev, RADEON_RING_TYPE_GFX_INDEX); |
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c index 20da6ff183df..32e50be9c4ac 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.c +++ b/drivers/gpu/drm/radeon/trinity_dpm.c | |||
| @@ -1874,15 +1874,16 @@ int trinity_dpm_init(struct radeon_device *rdev) | |||
| 1874 | for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) | 1874 | for (i = 0; i < SUMO_MAX_HARDWARE_POWERLEVELS; i++) |
| 1875 | pi->at[i] = TRINITY_AT_DFLT; | 1875 | pi->at[i] = TRINITY_AT_DFLT; |
| 1876 | 1876 | ||
| 1877 | /* There are stability issues reported on latops with | 1877 | /* There are stability issues reported on with |
| 1878 | * bapm installed when switching between AC and battery | 1878 | * bapm enabled when switching between AC and battery |
| 1879 | * power. At the same time, some desktop boards hang | 1879 | * power. At the same time, some MSI boards hang |
| 1880 | * if it's not enabled and dpm is enabled. | 1880 | * if it's not enabled and dpm is enabled. Just enable |
| 1881 | * it for MSI boards right now. | ||
| 1881 | */ | 1882 | */ |
| 1882 | if (rdev->flags & RADEON_IS_MOBILITY) | 1883 | if (rdev->pdev->subsystem_vendor == 0x1462) |
| 1883 | pi->enable_bapm = false; | ||
| 1884 | else | ||
| 1885 | pi->enable_bapm = true; | 1884 | pi->enable_bapm = true; |
| 1885 | else | ||
| 1886 | pi->enable_bapm = false; | ||
| 1886 | pi->enable_nbps_policy = true; | 1887 | pi->enable_nbps_policy = true; |
| 1887 | pi->enable_sclk_ds = true; | 1888 | pi->enable_sclk_ds = true; |
| 1888 | pi->enable_gfx_power_gating = true; | 1889 | pi->enable_gfx_power_gating = true; |
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index 800c8b60f7a2..5e79c6ad914f 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
| @@ -810,7 +810,7 @@ config HID_ZYDACRON | |||
| 810 | 810 | ||
| 811 | config HID_SENSOR_HUB | 811 | config HID_SENSOR_HUB |
| 812 | tristate "HID Sensors framework support" | 812 | tristate "HID Sensors framework support" |
| 813 | depends on HID | 813 | depends on HID && HAS_IOMEM |
| 814 | select MFD_CORE | 814 | select MFD_CORE |
| 815 | default n | 815 | default n |
| 816 | ---help--- | 816 | ---help--- |
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h index 6d00bb9366fa..48b66bbffc94 100644 --- a/drivers/hid/hid-ids.h +++ b/drivers/hid/hid-ids.h | |||
| @@ -323,6 +323,7 @@ | |||
| 323 | 323 | ||
| 324 | #define USB_VENDOR_ID_ETURBOTOUCH 0x22b9 | 324 | #define USB_VENDOR_ID_ETURBOTOUCH 0x22b9 |
| 325 | #define USB_DEVICE_ID_ETURBOTOUCH 0x0006 | 325 | #define USB_DEVICE_ID_ETURBOTOUCH 0x0006 |
| 326 | #define USB_DEVICE_ID_ETURBOTOUCH_2968 0x2968 | ||
| 326 | 327 | ||
| 327 | #define USB_VENDOR_ID_EZKEY 0x0518 | 328 | #define USB_VENDOR_ID_EZKEY 0x0518 |
| 328 | #define USB_DEVICE_ID_BTC_8193 0x0002 | 329 | #define USB_DEVICE_ID_BTC_8193 0x0002 |
| @@ -715,6 +716,8 @@ | |||
| 715 | 716 | ||
| 716 | #define USB_VENDOR_ID_PENMOUNT 0x14e1 | 717 | #define USB_VENDOR_ID_PENMOUNT 0x14e1 |
| 717 | #define USB_DEVICE_ID_PENMOUNT_PCI 0x3500 | 718 | #define USB_DEVICE_ID_PENMOUNT_PCI 0x3500 |
| 719 | #define USB_DEVICE_ID_PENMOUNT_1610 0x1610 | ||
| 720 | #define USB_DEVICE_ID_PENMOUNT_1640 0x1640 | ||
| 718 | 721 | ||
| 719 | #define USB_VENDOR_ID_PETALYNX 0x18b1 | 722 | #define USB_VENDOR_ID_PETALYNX 0x18b1 |
| 720 | #define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037 | 723 | #define USB_DEVICE_ID_PETALYNX_MAXTER_REMOTE 0x0037 |
diff --git a/drivers/hid/hid-rmi.c b/drivers/hid/hid-rmi.c index 2451c7e5febd..578bbe65902b 100644 --- a/drivers/hid/hid-rmi.c +++ b/drivers/hid/hid-rmi.c | |||
| @@ -428,6 +428,7 @@ static int rmi_raw_event(struct hid_device *hdev, | |||
| 428 | return 0; | 428 | return 0; |
| 429 | } | 429 | } |
| 430 | 430 | ||
| 431 | #ifdef CONFIG_PM | ||
| 431 | static int rmi_post_reset(struct hid_device *hdev) | 432 | static int rmi_post_reset(struct hid_device *hdev) |
| 432 | { | 433 | { |
| 433 | return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); | 434 | return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); |
| @@ -437,6 +438,7 @@ static int rmi_post_resume(struct hid_device *hdev) | |||
| 437 | { | 438 | { |
| 438 | return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); | 439 | return rmi_set_mode(hdev, RMI_MODE_ATTN_REPORTS); |
| 439 | } | 440 | } |
| 441 | #endif /* CONFIG_PM */ | ||
| 440 | 442 | ||
| 441 | #define RMI4_MAX_PAGE 0xff | 443 | #define RMI4_MAX_PAGE 0xff |
| 442 | #define RMI4_PAGE_SIZE 0x0100 | 444 | #define RMI4_PAGE_SIZE 0x0100 |
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index a8d5c8faf8cf..e244e449cbba 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
| @@ -159,17 +159,18 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev, | |||
| 159 | { | 159 | { |
| 160 | struct hid_sensor_hub_callbacks_list *callback; | 160 | struct hid_sensor_hub_callbacks_list *callback; |
| 161 | struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev); | 161 | struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev); |
| 162 | unsigned long flags; | ||
| 162 | 163 | ||
| 163 | spin_lock(&pdata->dyn_callback_lock); | 164 | spin_lock_irqsave(&pdata->dyn_callback_lock, flags); |
| 164 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) | 165 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) |
| 165 | if (callback->usage_id == usage_id && | 166 | if (callback->usage_id == usage_id && |
| 166 | callback->hsdev == hsdev) { | 167 | callback->hsdev == hsdev) { |
| 167 | spin_unlock(&pdata->dyn_callback_lock); | 168 | spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); |
| 168 | return -EINVAL; | 169 | return -EINVAL; |
| 169 | } | 170 | } |
| 170 | callback = kzalloc(sizeof(*callback), GFP_ATOMIC); | 171 | callback = kzalloc(sizeof(*callback), GFP_ATOMIC); |
| 171 | if (!callback) { | 172 | if (!callback) { |
| 172 | spin_unlock(&pdata->dyn_callback_lock); | 173 | spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); |
| 173 | return -ENOMEM; | 174 | return -ENOMEM; |
| 174 | } | 175 | } |
| 175 | callback->hsdev = hsdev; | 176 | callback->hsdev = hsdev; |
| @@ -177,7 +178,7 @@ int sensor_hub_register_callback(struct hid_sensor_hub_device *hsdev, | |||
| 177 | callback->usage_id = usage_id; | 178 | callback->usage_id = usage_id; |
| 178 | callback->priv = NULL; | 179 | callback->priv = NULL; |
| 179 | list_add_tail(&callback->list, &pdata->dyn_callback_list); | 180 | list_add_tail(&callback->list, &pdata->dyn_callback_list); |
| 180 | spin_unlock(&pdata->dyn_callback_lock); | 181 | spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); |
| 181 | 182 | ||
| 182 | return 0; | 183 | return 0; |
| 183 | } | 184 | } |
| @@ -188,8 +189,9 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, | |||
| 188 | { | 189 | { |
| 189 | struct hid_sensor_hub_callbacks_list *callback; | 190 | struct hid_sensor_hub_callbacks_list *callback; |
| 190 | struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev); | 191 | struct sensor_hub_data *pdata = hid_get_drvdata(hsdev->hdev); |
| 192 | unsigned long flags; | ||
| 191 | 193 | ||
| 192 | spin_lock(&pdata->dyn_callback_lock); | 194 | spin_lock_irqsave(&pdata->dyn_callback_lock, flags); |
| 193 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) | 195 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) |
| 194 | if (callback->usage_id == usage_id && | 196 | if (callback->usage_id == usage_id && |
| 195 | callback->hsdev == hsdev) { | 197 | callback->hsdev == hsdev) { |
| @@ -197,7 +199,7 @@ int sensor_hub_remove_callback(struct hid_sensor_hub_device *hsdev, | |||
| 197 | kfree(callback); | 199 | kfree(callback); |
| 198 | break; | 200 | break; |
| 199 | } | 201 | } |
| 200 | spin_unlock(&pdata->dyn_callback_lock); | 202 | spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); |
| 201 | 203 | ||
| 202 | return 0; | 204 | return 0; |
| 203 | } | 205 | } |
| @@ -378,15 +380,16 @@ static int sensor_hub_suspend(struct hid_device *hdev, pm_message_t message) | |||
| 378 | { | 380 | { |
| 379 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); | 381 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); |
| 380 | struct hid_sensor_hub_callbacks_list *callback; | 382 | struct hid_sensor_hub_callbacks_list *callback; |
| 383 | unsigned long flags; | ||
| 381 | 384 | ||
| 382 | hid_dbg(hdev, " sensor_hub_suspend\n"); | 385 | hid_dbg(hdev, " sensor_hub_suspend\n"); |
| 383 | spin_lock(&pdata->dyn_callback_lock); | 386 | spin_lock_irqsave(&pdata->dyn_callback_lock, flags); |
| 384 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) { | 387 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) { |
| 385 | if (callback->usage_callback->suspend) | 388 | if (callback->usage_callback->suspend) |
| 386 | callback->usage_callback->suspend( | 389 | callback->usage_callback->suspend( |
| 387 | callback->hsdev, callback->priv); | 390 | callback->hsdev, callback->priv); |
| 388 | } | 391 | } |
| 389 | spin_unlock(&pdata->dyn_callback_lock); | 392 | spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); |
| 390 | 393 | ||
| 391 | return 0; | 394 | return 0; |
| 392 | } | 395 | } |
| @@ -395,15 +398,16 @@ static int sensor_hub_resume(struct hid_device *hdev) | |||
| 395 | { | 398 | { |
| 396 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); | 399 | struct sensor_hub_data *pdata = hid_get_drvdata(hdev); |
| 397 | struct hid_sensor_hub_callbacks_list *callback; | 400 | struct hid_sensor_hub_callbacks_list *callback; |
| 401 | unsigned long flags; | ||
| 398 | 402 | ||
| 399 | hid_dbg(hdev, " sensor_hub_resume\n"); | 403 | hid_dbg(hdev, " sensor_hub_resume\n"); |
| 400 | spin_lock(&pdata->dyn_callback_lock); | 404 | spin_lock_irqsave(&pdata->dyn_callback_lock, flags); |
| 401 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) { | 405 | list_for_each_entry(callback, &pdata->dyn_callback_list, list) { |
| 402 | if (callback->usage_callback->resume) | 406 | if (callback->usage_callback->resume) |
| 403 | callback->usage_callback->resume( | 407 | callback->usage_callback->resume( |
| 404 | callback->hsdev, callback->priv); | 408 | callback->hsdev, callback->priv); |
| 405 | } | 409 | } |
| 406 | spin_unlock(&pdata->dyn_callback_lock); | 410 | spin_unlock_irqrestore(&pdata->dyn_callback_lock, flags); |
| 407 | 411 | ||
| 408 | return 0; | 412 | return 0; |
| 409 | } | 413 | } |
| @@ -632,6 +636,7 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
| 632 | if (name == NULL) { | 636 | if (name == NULL) { |
| 633 | hid_err(hdev, "Failed MFD device name\n"); | 637 | hid_err(hdev, "Failed MFD device name\n"); |
| 634 | ret = -ENOMEM; | 638 | ret = -ENOMEM; |
| 639 | kfree(hsdev); | ||
| 635 | goto err_no_mem; | 640 | goto err_no_mem; |
| 636 | } | 641 | } |
| 637 | sd->hid_sensor_hub_client_devs[ | 642 | sd->hid_sensor_hub_client_devs[ |
diff --git a/drivers/hid/usbhid/hid-quirks.c b/drivers/hid/usbhid/hid-quirks.c index 59badc10a08c..31e6727cd009 100644 --- a/drivers/hid/usbhid/hid-quirks.c +++ b/drivers/hid/usbhid/hid-quirks.c | |||
| @@ -49,6 +49,7 @@ static const struct hid_blacklist { | |||
| 49 | 49 | ||
| 50 | { USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II, HID_QUIRK_MULTI_INPUT }, | 50 | { USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II, HID_QUIRK_MULTI_INPUT }, |
| 51 | { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT }, | 51 | { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH, HID_QUIRK_MULTI_INPUT }, |
| 52 | { USB_VENDOR_ID_ETURBOTOUCH, USB_DEVICE_ID_ETURBOTOUCH_2968, HID_QUIRK_MULTI_INPUT }, | ||
| 52 | { USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT }, | 53 | { USB_VENDOR_ID_GREENASIA, USB_DEVICE_ID_GREENASIA_DUAL_USB_JOYPAD, HID_QUIRK_MULTI_INPUT }, |
| 53 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, | 54 | { USB_VENDOR_ID_PANTHERLORD, USB_DEVICE_ID_PANTHERLORD_TWIN_USB_JOYSTICK, HID_QUIRK_MULTI_INPUT | HID_QUIRK_SKIP_OUTPUT_REPORTS }, |
| 54 | { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, | 55 | { USB_VENDOR_ID_PLAYDOTCOM, USB_DEVICE_ID_PLAYDOTCOM_EMS_USBII, HID_QUIRK_MULTI_INPUT }, |
| @@ -76,6 +77,8 @@ static const struct hid_blacklist { | |||
| 76 | { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, | 77 | { USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GX680R_LED_PANEL, HID_QUIRK_NO_INIT_REPORTS }, |
| 77 | { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS }, | 78 | { USB_VENDOR_ID_NEXIO, USB_DEVICE_ID_NEXIO_MULTITOUCH_PTI0750, HID_QUIRK_NO_INIT_REPORTS }, |
| 78 | { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, | 79 | { USB_VENDOR_ID_NOVATEK, USB_DEVICE_ID_NOVATEK_MOUSE, HID_QUIRK_NO_INIT_REPORTS }, |
| 80 | { USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1610, HID_QUIRK_NOGET }, | ||
| 81 | { USB_VENDOR_ID_PENMOUNT, USB_DEVICE_ID_PENMOUNT_1640, HID_QUIRK_NOGET }, | ||
| 79 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, | 82 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN, HID_QUIRK_NO_INIT_REPORTS }, |
| 80 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, | 83 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN1, HID_QUIRK_NO_INIT_REPORTS }, |
| 81 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS }, | 84 | { USB_VENDOR_ID_PIXART, USB_DEVICE_ID_PIXART_OPTICAL_TOUCH_SCREEN2, HID_QUIRK_NO_INIT_REPORTS }, |
diff --git a/drivers/hv/connection.c b/drivers/hv/connection.c index e84f4526eb36..ae22e3c1fc4c 100644 --- a/drivers/hv/connection.c +++ b/drivers/hv/connection.c | |||
| @@ -339,9 +339,13 @@ static void process_chn_event(u32 relid) | |||
| 339 | */ | 339 | */ |
| 340 | 340 | ||
| 341 | do { | 341 | do { |
| 342 | hv_begin_read(&channel->inbound); | 342 | if (read_state) |
| 343 | hv_begin_read(&channel->inbound); | ||
| 343 | channel->onchannel_callback(arg); | 344 | channel->onchannel_callback(arg); |
| 344 | bytes_to_read = hv_end_read(&channel->inbound); | 345 | if (read_state) |
| 346 | bytes_to_read = hv_end_read(&channel->inbound); | ||
| 347 | else | ||
| 348 | bytes_to_read = 0; | ||
| 345 | } while (read_state && (bytes_to_read != 0)); | 349 | } while (read_state && (bytes_to_read != 0)); |
| 346 | } else { | 350 | } else { |
| 347 | pr_err("no channel callback for relid - %u\n", relid); | 351 | pr_err("no channel callback for relid - %u\n", relid); |
diff --git a/drivers/hv/hv_fcopy.c b/drivers/hv/hv_fcopy.c index eaaa3d843b80..23b2ce294c4c 100644 --- a/drivers/hv/hv_fcopy.c +++ b/drivers/hv/hv_fcopy.c | |||
| @@ -246,8 +246,8 @@ void hv_fcopy_onchannelcallback(void *context) | |||
| 246 | /* | 246 | /* |
| 247 | * Send the information to the user-level daemon. | 247 | * Send the information to the user-level daemon. |
| 248 | */ | 248 | */ |
| 249 | fcopy_send_data(); | ||
| 250 | schedule_delayed_work(&fcopy_work, 5*HZ); | 249 | schedule_delayed_work(&fcopy_work, 5*HZ); |
| 250 | fcopy_send_data(); | ||
| 251 | return; | 251 | return; |
| 252 | } | 252 | } |
| 253 | icmsghdr->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; | 253 | icmsghdr->icflags = ICMSGHDRFLAG_TRANSACTION | ICMSGHDRFLAG_RESPONSE; |
diff --git a/drivers/hv/hv_kvp.c b/drivers/hv/hv_kvp.c index ea852537307e..521c14625b3a 100644 --- a/drivers/hv/hv_kvp.c +++ b/drivers/hv/hv_kvp.c | |||
| @@ -127,6 +127,17 @@ kvp_work_func(struct work_struct *dummy) | |||
| 127 | kvp_respond_to_host(NULL, HV_E_FAIL); | 127 | kvp_respond_to_host(NULL, HV_E_FAIL); |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | static void poll_channel(struct vmbus_channel *channel) | ||
| 131 | { | ||
| 132 | if (channel->target_cpu != smp_processor_id()) | ||
| 133 | smp_call_function_single(channel->target_cpu, | ||
| 134 | hv_kvp_onchannelcallback, | ||
| 135 | channel, true); | ||
| 136 | else | ||
| 137 | hv_kvp_onchannelcallback(channel); | ||
| 138 | } | ||
| 139 | |||
| 140 | |||
| 130 | static int kvp_handle_handshake(struct hv_kvp_msg *msg) | 141 | static int kvp_handle_handshake(struct hv_kvp_msg *msg) |
| 131 | { | 142 | { |
| 132 | int ret = 1; | 143 | int ret = 1; |
| @@ -155,7 +166,7 @@ static int kvp_handle_handshake(struct hv_kvp_msg *msg) | |||
| 155 | kvp_register(dm_reg_value); | 166 | kvp_register(dm_reg_value); |
| 156 | kvp_transaction.active = false; | 167 | kvp_transaction.active = false; |
| 157 | if (kvp_transaction.kvp_context) | 168 | if (kvp_transaction.kvp_context) |
| 158 | hv_kvp_onchannelcallback(kvp_transaction.kvp_context); | 169 | poll_channel(kvp_transaction.kvp_context); |
| 159 | } | 170 | } |
| 160 | return ret; | 171 | return ret; |
| 161 | } | 172 | } |
| @@ -568,7 +579,7 @@ response_done: | |||
| 568 | 579 | ||
| 569 | vmbus_sendpacket(channel, recv_buffer, buf_len, req_id, | 580 | vmbus_sendpacket(channel, recv_buffer, buf_len, req_id, |
| 570 | VM_PKT_DATA_INBAND, 0); | 581 | VM_PKT_DATA_INBAND, 0); |
| 571 | 582 | poll_channel(channel); | |
| 572 | } | 583 | } |
| 573 | 584 | ||
| 574 | /* | 585 | /* |
| @@ -603,7 +614,7 @@ void hv_kvp_onchannelcallback(void *context) | |||
| 603 | return; | 614 | return; |
| 604 | } | 615 | } |
| 605 | 616 | ||
| 606 | vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 2, &recvlen, | 617 | vmbus_recvpacket(channel, recv_buffer, PAGE_SIZE * 4, &recvlen, |
| 607 | &requestid); | 618 | &requestid); |
| 608 | 619 | ||
| 609 | if (recvlen > 0) { | 620 | if (recvlen > 0) { |
diff --git a/drivers/hv/hv_util.c b/drivers/hv/hv_util.c index dd761806f0e8..3b9c9ef0deb8 100644 --- a/drivers/hv/hv_util.c +++ b/drivers/hv/hv_util.c | |||
| @@ -319,7 +319,7 @@ static int util_probe(struct hv_device *dev, | |||
| 319 | (struct hv_util_service *)dev_id->driver_data; | 319 | (struct hv_util_service *)dev_id->driver_data; |
| 320 | int ret; | 320 | int ret; |
| 321 | 321 | ||
| 322 | srv->recv_buffer = kmalloc(PAGE_SIZE * 2, GFP_KERNEL); | 322 | srv->recv_buffer = kmalloc(PAGE_SIZE * 4, GFP_KERNEL); |
| 323 | if (!srv->recv_buffer) | 323 | if (!srv->recv_buffer) |
| 324 | return -ENOMEM; | 324 | return -ENOMEM; |
| 325 | if (srv->util_init) { | 325 | if (srv->util_init) { |
diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c index 5ffd81f19d01..0625e50d7a6e 100644 --- a/drivers/hwmon/adc128d818.c +++ b/drivers/hwmon/adc128d818.c | |||
| @@ -239,50 +239,50 @@ static ssize_t adc128_show_alarm(struct device *dev, | |||
| 239 | return sprintf(buf, "%u\n", !!(alarms & mask)); | 239 | return sprintf(buf, "%u\n", !!(alarms & mask)); |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | static SENSOR_DEVICE_ATTR_2(in0_input, S_IWUSR | S_IRUGO, | 242 | static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, |
| 243 | adc128_show_in, adc128_set_in, 0, 0); | 243 | adc128_show_in, NULL, 0, 0); |
| 244 | static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO, | 244 | static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO, |
| 245 | adc128_show_in, adc128_set_in, 0, 1); | 245 | adc128_show_in, adc128_set_in, 0, 1); |
| 246 | static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO, | 246 | static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO, |
| 247 | adc128_show_in, adc128_set_in, 0, 2); | 247 | adc128_show_in, adc128_set_in, 0, 2); |
| 248 | 248 | ||
| 249 | static SENSOR_DEVICE_ATTR_2(in1_input, S_IWUSR | S_IRUGO, | 249 | static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, |
| 250 | adc128_show_in, adc128_set_in, 1, 0); | 250 | adc128_show_in, NULL, 1, 0); |
| 251 | static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO, | 251 | static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO, |
| 252 | adc128_show_in, adc128_set_in, 1, 1); | 252 | adc128_show_in, adc128_set_in, 1, 1); |
| 253 | static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO, | 253 | static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO, |
| 254 | adc128_show_in, adc128_set_in, 1, 2); | 254 | adc128_show_in, adc128_set_in, 1, 2); |
| 255 | 255 | ||
| 256 | static SENSOR_DEVICE_ATTR_2(in2_input, S_IWUSR | S_IRUGO, | 256 | static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, |
| 257 | adc128_show_in, adc128_set_in, 2, 0); | 257 | adc128_show_in, NULL, 2, 0); |
| 258 | static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO, | 258 | static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO, |
| 259 | adc128_show_in, adc128_set_in, 2, 1); | 259 | adc128_show_in, adc128_set_in, 2, 1); |
| 260 | static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO, | 260 | static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO, |
| 261 | adc128_show_in, adc128_set_in, 2, 2); | 261 | adc128_show_in, adc128_set_in, 2, 2); |
| 262 | 262 | ||
| 263 | static SENSOR_DEVICE_ATTR_2(in3_input, S_IWUSR | S_IRUGO, | 263 | static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, |
| 264 | adc128_show_in, adc128_set_in, 3, 0); | 264 | adc128_show_in, NULL, 3, 0); |
| 265 | static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO, | 265 | static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO, |
| 266 | adc128_show_in, adc128_set_in, 3, 1); | 266 | adc128_show_in, adc128_set_in, 3, 1); |
| 267 | static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO, | 267 | static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO, |
| 268 | adc128_show_in, adc128_set_in, 3, 2); | 268 | adc128_show_in, adc128_set_in, 3, 2); |
| 269 | 269 | ||
| 270 | static SENSOR_DEVICE_ATTR_2(in4_input, S_IWUSR | S_IRUGO, | 270 | static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, |
| 271 | adc128_show_in, adc128_set_in, 4, 0); | 271 | adc128_show_in, NULL, 4, 0); |
| 272 | static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO, | 272 | static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO, |
| 273 | adc128_show_in, adc128_set_in, 4, 1); | 273 | adc128_show_in, adc128_set_in, 4, 1); |
| 274 | static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO, | 274 | static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO, |
| 275 | adc128_show_in, adc128_set_in, 4, 2); | 275 | adc128_show_in, adc128_set_in, 4, 2); |
| 276 | 276 | ||
| 277 | static SENSOR_DEVICE_ATTR_2(in5_input, S_IWUSR | S_IRUGO, | 277 | static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, |
| 278 | adc128_show_in, adc128_set_in, 5, 0); | 278 | adc128_show_in, NULL, 5, 0); |
| 279 | static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO, | 279 | static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO, |
| 280 | adc128_show_in, adc128_set_in, 5, 1); | 280 | adc128_show_in, adc128_set_in, 5, 1); |
| 281 | static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO, | 281 | static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO, |
| 282 | adc128_show_in, adc128_set_in, 5, 2); | 282 | adc128_show_in, adc128_set_in, 5, 2); |
| 283 | 283 | ||
| 284 | static SENSOR_DEVICE_ATTR_2(in6_input, S_IWUSR | S_IRUGO, | 284 | static SENSOR_DEVICE_ATTR_2(in6_input, S_IRUGO, |
| 285 | adc128_show_in, adc128_set_in, 6, 0); | 285 | adc128_show_in, NULL, 6, 0); |
| 286 | static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO, | 286 | static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO, |
| 287 | adc128_show_in, adc128_set_in, 6, 1); | 287 | adc128_show_in, adc128_set_in, 6, 1); |
| 288 | static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO, | 288 | static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO, |
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 3eb4281689b5..d74241bb278c 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
| @@ -185,7 +185,7 @@ static ssize_t set_temp_max(struct device *dev, | |||
| 185 | struct adm1021_data *data = dev_get_drvdata(dev); | 185 | struct adm1021_data *data = dev_get_drvdata(dev); |
| 186 | struct i2c_client *client = data->client; | 186 | struct i2c_client *client = data->client; |
| 187 | long temp; | 187 | long temp; |
| 188 | int err; | 188 | int reg_val, err; |
| 189 | 189 | ||
| 190 | err = kstrtol(buf, 10, &temp); | 190 | err = kstrtol(buf, 10, &temp); |
| 191 | if (err) | 191 | if (err) |
| @@ -193,10 +193,11 @@ static ssize_t set_temp_max(struct device *dev, | |||
| 193 | temp /= 1000; | 193 | temp /= 1000; |
| 194 | 194 | ||
| 195 | mutex_lock(&data->update_lock); | 195 | mutex_lock(&data->update_lock); |
| 196 | data->temp_max[index] = clamp_val(temp, -128, 127); | 196 | reg_val = clamp_val(temp, -128, 127); |
| 197 | data->temp_max[index] = reg_val * 1000; | ||
| 197 | if (!read_only) | 198 | if (!read_only) |
| 198 | i2c_smbus_write_byte_data(client, ADM1021_REG_TOS_W(index), | 199 | i2c_smbus_write_byte_data(client, ADM1021_REG_TOS_W(index), |
| 199 | data->temp_max[index]); | 200 | reg_val); |
| 200 | mutex_unlock(&data->update_lock); | 201 | mutex_unlock(&data->update_lock); |
| 201 | 202 | ||
| 202 | return count; | 203 | return count; |
| @@ -210,7 +211,7 @@ static ssize_t set_temp_min(struct device *dev, | |||
| 210 | struct adm1021_data *data = dev_get_drvdata(dev); | 211 | struct adm1021_data *data = dev_get_drvdata(dev); |
| 211 | struct i2c_client *client = data->client; | 212 | struct i2c_client *client = data->client; |
| 212 | long temp; | 213 | long temp; |
| 213 | int err; | 214 | int reg_val, err; |
| 214 | 215 | ||
| 215 | err = kstrtol(buf, 10, &temp); | 216 | err = kstrtol(buf, 10, &temp); |
| 216 | if (err) | 217 | if (err) |
| @@ -218,10 +219,11 @@ static ssize_t set_temp_min(struct device *dev, | |||
| 218 | temp /= 1000; | 219 | temp /= 1000; |
| 219 | 220 | ||
| 220 | mutex_lock(&data->update_lock); | 221 | mutex_lock(&data->update_lock); |
| 221 | data->temp_min[index] = clamp_val(temp, -128, 127); | 222 | reg_val = clamp_val(temp, -128, 127); |
| 223 | data->temp_min[index] = reg_val * 1000; | ||
| 222 | if (!read_only) | 224 | if (!read_only) |
| 223 | i2c_smbus_write_byte_data(client, ADM1021_REG_THYST_W(index), | 225 | i2c_smbus_write_byte_data(client, ADM1021_REG_THYST_W(index), |
| 224 | data->temp_min[index]); | 226 | reg_val); |
| 225 | mutex_unlock(&data->update_lock); | 227 | mutex_unlock(&data->update_lock); |
| 226 | 228 | ||
| 227 | return count; | 229 | return count; |
diff --git a/drivers/hwmon/adm1029.c b/drivers/hwmon/adm1029.c index 78339e880bd6..2804571b269e 100644 --- a/drivers/hwmon/adm1029.c +++ b/drivers/hwmon/adm1029.c | |||
| @@ -232,6 +232,9 @@ static ssize_t set_fan_div(struct device *dev, | |||
| 232 | /* Update the value */ | 232 | /* Update the value */ |
| 233 | reg = (reg & 0x3F) | (val << 6); | 233 | reg = (reg & 0x3F) | (val << 6); |
| 234 | 234 | ||
| 235 | /* Update the cache */ | ||
| 236 | data->fan_div[attr->index] = reg; | ||
| 237 | |||
| 235 | /* Write value */ | 238 | /* Write value */ |
| 236 | i2c_smbus_write_byte_data(client, | 239 | i2c_smbus_write_byte_data(client, |
| 237 | ADM1029_REG_FAN_DIV[attr->index], reg); | 240 | ADM1029_REG_FAN_DIV[attr->index], reg); |
diff --git a/drivers/hwmon/adm1031.c b/drivers/hwmon/adm1031.c index a8a540ca8c34..51c1a5a165ab 100644 --- a/drivers/hwmon/adm1031.c +++ b/drivers/hwmon/adm1031.c | |||
| @@ -365,6 +365,7 @@ set_auto_temp_min(struct device *dev, struct device_attribute *attr, | |||
| 365 | if (ret) | 365 | if (ret) |
| 366 | return ret; | 366 | return ret; |
| 367 | 367 | ||
| 368 | val = clamp_val(val, 0, 127000); | ||
| 368 | mutex_lock(&data->update_lock); | 369 | mutex_lock(&data->update_lock); |
| 369 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); | 370 | data->auto_temp[nr] = AUTO_TEMP_MIN_TO_REG(val, data->auto_temp[nr]); |
| 370 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), | 371 | adm1031_write_value(client, ADM1031_REG_AUTO_TEMP(nr), |
| @@ -394,6 +395,7 @@ set_auto_temp_max(struct device *dev, struct device_attribute *attr, | |||
| 394 | if (ret) | 395 | if (ret) |
| 395 | return ret; | 396 | return ret; |
| 396 | 397 | ||
| 398 | val = clamp_val(val, 0, 127000); | ||
| 397 | mutex_lock(&data->update_lock); | 399 | mutex_lock(&data->update_lock); |
| 398 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], | 400 | data->temp_max[nr] = AUTO_TEMP_MAX_TO_REG(val, data->auto_temp[nr], |
| 399 | data->pwm[nr]); | 401 | data->pwm[nr]); |
| @@ -696,7 +698,7 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
| 696 | if (ret) | 698 | if (ret) |
| 697 | return ret; | 699 | return ret; |
| 698 | 700 | ||
| 699 | val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875); | 701 | val = clamp_val(val, -55000, 127000); |
| 700 | mutex_lock(&data->update_lock); | 702 | mutex_lock(&data->update_lock); |
| 701 | data->temp_min[nr] = TEMP_TO_REG(val); | 703 | data->temp_min[nr] = TEMP_TO_REG(val); |
| 702 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), | 704 | adm1031_write_value(client, ADM1031_REG_TEMP_MIN(nr), |
| @@ -717,7 +719,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
| 717 | if (ret) | 719 | if (ret) |
| 718 | return ret; | 720 | return ret; |
| 719 | 721 | ||
| 720 | val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875); | 722 | val = clamp_val(val, -55000, 127000); |
| 721 | mutex_lock(&data->update_lock); | 723 | mutex_lock(&data->update_lock); |
| 722 | data->temp_max[nr] = TEMP_TO_REG(val); | 724 | data->temp_max[nr] = TEMP_TO_REG(val); |
| 723 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), | 725 | adm1031_write_value(client, ADM1031_REG_TEMP_MAX(nr), |
| @@ -738,7 +740,7 @@ static ssize_t set_temp_crit(struct device *dev, struct device_attribute *attr, | |||
| 738 | if (ret) | 740 | if (ret) |
| 739 | return ret; | 741 | return ret; |
| 740 | 742 | ||
| 741 | val = clamp_val(val, -55000, nr == 0 ? 127750 : 127875); | 743 | val = clamp_val(val, -55000, 127000); |
| 742 | mutex_lock(&data->update_lock); | 744 | mutex_lock(&data->update_lock); |
| 743 | data->temp_crit[nr] = TEMP_TO_REG(val); | 745 | data->temp_crit[nr] = TEMP_TO_REG(val); |
| 744 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), | 746 | adm1031_write_value(client, ADM1031_REG_TEMP_CRIT(nr), |
diff --git a/drivers/hwmon/adt7470.c b/drivers/hwmon/adt7470.c index 0f4dea5ccf17..9ee3913850d6 100644 --- a/drivers/hwmon/adt7470.c +++ b/drivers/hwmon/adt7470.c | |||
| @@ -515,7 +515,7 @@ static ssize_t set_temp_min(struct device *dev, | |||
| 515 | return -EINVAL; | 515 | return -EINVAL; |
| 516 | 516 | ||
| 517 | temp = DIV_ROUND_CLOSEST(temp, 1000); | 517 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
| 518 | temp = clamp_val(temp, 0, 255); | 518 | temp = clamp_val(temp, -128, 127); |
| 519 | 519 | ||
| 520 | mutex_lock(&data->lock); | 520 | mutex_lock(&data->lock); |
| 521 | data->temp_min[attr->index] = temp; | 521 | data->temp_min[attr->index] = temp; |
| @@ -549,7 +549,7 @@ static ssize_t set_temp_max(struct device *dev, | |||
| 549 | return -EINVAL; | 549 | return -EINVAL; |
| 550 | 550 | ||
| 551 | temp = DIV_ROUND_CLOSEST(temp, 1000); | 551 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
| 552 | temp = clamp_val(temp, 0, 255); | 552 | temp = clamp_val(temp, -128, 127); |
| 553 | 553 | ||
| 554 | mutex_lock(&data->lock); | 554 | mutex_lock(&data->lock); |
| 555 | data->temp_max[attr->index] = temp; | 555 | data->temp_max[attr->index] = temp; |
| @@ -826,7 +826,7 @@ static ssize_t set_pwm_tmin(struct device *dev, | |||
| 826 | return -EINVAL; | 826 | return -EINVAL; |
| 827 | 827 | ||
| 828 | temp = DIV_ROUND_CLOSEST(temp, 1000); | 828 | temp = DIV_ROUND_CLOSEST(temp, 1000); |
| 829 | temp = clamp_val(temp, 0, 255); | 829 | temp = clamp_val(temp, -128, 127); |
| 830 | 830 | ||
| 831 | mutex_lock(&data->lock); | 831 | mutex_lock(&data->lock); |
| 832 | data->pwm_tmin[attr->index] = temp; | 832 | data->pwm_tmin[attr->index] = temp; |
diff --git a/drivers/hwmon/amc6821.c b/drivers/hwmon/amc6821.c index eea817296513..9f2be3dd28f3 100644 --- a/drivers/hwmon/amc6821.c +++ b/drivers/hwmon/amc6821.c | |||
| @@ -704,7 +704,7 @@ static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, | |||
| 704 | get_temp_alarm, NULL, IDX_TEMP1_MAX); | 704 | get_temp_alarm, NULL, IDX_TEMP1_MAX); |
| 705 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, | 705 | static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, |
| 706 | get_temp_alarm, NULL, IDX_TEMP1_CRIT); | 706 | get_temp_alarm, NULL, IDX_TEMP1_CRIT); |
| 707 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO | S_IWUSR, | 707 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, |
| 708 | get_temp, NULL, IDX_TEMP2_INPUT); | 708 | get_temp, NULL, IDX_TEMP2_INPUT); |
| 709 | static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, get_temp, | 709 | static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, get_temp, |
| 710 | set_temp, IDX_TEMP2_MIN); | 710 | set_temp, IDX_TEMP2_MIN); |
diff --git a/drivers/hwmon/da9052-hwmon.c b/drivers/hwmon/da9052-hwmon.c index afd31042b452..d14ab3c45daa 100644 --- a/drivers/hwmon/da9052-hwmon.c +++ b/drivers/hwmon/da9052-hwmon.c | |||
| @@ -194,7 +194,7 @@ static ssize_t da9052_hwmon_show_name(struct device *dev, | |||
| 194 | struct device_attribute *devattr, | 194 | struct device_attribute *devattr, |
| 195 | char *buf) | 195 | char *buf) |
| 196 | { | 196 | { |
| 197 | return sprintf(buf, "da9052-hwmon\n"); | 197 | return sprintf(buf, "da9052\n"); |
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | static ssize_t show_label(struct device *dev, | 200 | static ssize_t show_label(struct device *dev, |
diff --git a/drivers/hwmon/da9055-hwmon.c b/drivers/hwmon/da9055-hwmon.c index 73b3865f1207..35eb7738d711 100644 --- a/drivers/hwmon/da9055-hwmon.c +++ b/drivers/hwmon/da9055-hwmon.c | |||
| @@ -204,7 +204,7 @@ static ssize_t da9055_hwmon_show_name(struct device *dev, | |||
| 204 | struct device_attribute *devattr, | 204 | struct device_attribute *devattr, |
| 205 | char *buf) | 205 | char *buf) |
| 206 | { | 206 | { |
| 207 | return sprintf(buf, "da9055-hwmon\n"); | 207 | return sprintf(buf, "da9055\n"); |
| 208 | } | 208 | } |
| 209 | 209 | ||
| 210 | static ssize_t show_label(struct device *dev, | 210 | static ssize_t show_label(struct device *dev, |
diff --git a/drivers/hwmon/emc2103.c b/drivers/hwmon/emc2103.c index fd892dd48e4c..78002de46cb6 100644 --- a/drivers/hwmon/emc2103.c +++ b/drivers/hwmon/emc2103.c | |||
| @@ -250,9 +250,7 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *da, | |||
| 250 | if (result < 0) | 250 | if (result < 0) |
| 251 | return result; | 251 | return result; |
| 252 | 252 | ||
| 253 | val = DIV_ROUND_CLOSEST(val, 1000); | 253 | val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127); |
| 254 | if ((val < -63) || (val > 127)) | ||
| 255 | return -EINVAL; | ||
| 256 | 254 | ||
| 257 | mutex_lock(&data->update_lock); | 255 | mutex_lock(&data->update_lock); |
| 258 | data->temp_min[nr] = val; | 256 | data->temp_min[nr] = val; |
| @@ -274,9 +272,7 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *da, | |||
| 274 | if (result < 0) | 272 | if (result < 0) |
| 275 | return result; | 273 | return result; |
| 276 | 274 | ||
| 277 | val = DIV_ROUND_CLOSEST(val, 1000); | 275 | val = clamp_val(DIV_ROUND_CLOSEST(val, 1000), -63, 127); |
| 278 | if ((val < -63) || (val > 127)) | ||
| 279 | return -EINVAL; | ||
| 280 | 276 | ||
| 281 | mutex_lock(&data->update_lock); | 277 | mutex_lock(&data->update_lock); |
| 282 | data->temp_max[nr] = val; | 278 | data->temp_max[nr] = val; |
| @@ -390,15 +386,14 @@ static ssize_t set_fan_target(struct device *dev, struct device_attribute *da, | |||
| 390 | { | 386 | { |
| 391 | struct emc2103_data *data = emc2103_update_device(dev); | 387 | struct emc2103_data *data = emc2103_update_device(dev); |
| 392 | struct i2c_client *client = to_i2c_client(dev); | 388 | struct i2c_client *client = to_i2c_client(dev); |
| 393 | long rpm_target; | 389 | unsigned long rpm_target; |
| 394 | 390 | ||
| 395 | int result = kstrtol(buf, 10, &rpm_target); | 391 | int result = kstrtoul(buf, 10, &rpm_target); |
| 396 | if (result < 0) | 392 | if (result < 0) |
| 397 | return result; | 393 | return result; |
| 398 | 394 | ||
| 399 | /* Datasheet states 16384 as maximum RPM target (table 3.2) */ | 395 | /* Datasheet states 16384 as maximum RPM target (table 3.2) */ |
| 400 | if ((rpm_target < 0) || (rpm_target > 16384)) | 396 | rpm_target = clamp_val(rpm_target, 0, 16384); |
| 401 | return -EINVAL; | ||
| 402 | 397 | ||
| 403 | mutex_lock(&data->update_lock); | 398 | mutex_lock(&data->update_lock); |
| 404 | 399 | ||
diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c index bdfbe9114889..ae66f42c4d6d 100644 --- a/drivers/hwmon/ntc_thermistor.c +++ b/drivers/hwmon/ntc_thermistor.c | |||
| @@ -512,7 +512,7 @@ static int ntc_thermistor_probe(struct platform_device *pdev) | |||
| 512 | } | 512 | } |
| 513 | 513 | ||
| 514 | dev_info(&pdev->dev, "Thermistor type: %s successfully probed.\n", | 514 | dev_info(&pdev->dev, "Thermistor type: %s successfully probed.\n", |
| 515 | pdev->name); | 515 | pdev_id->name); |
| 516 | 516 | ||
| 517 | return 0; | 517 | return 0; |
| 518 | err_after_sysfs: | 518 | err_after_sysfs: |
diff --git a/drivers/hwmon/smsc47m192.c b/drivers/hwmon/smsc47m192.c index efee4c59239f..34b9a601ad07 100644 --- a/drivers/hwmon/smsc47m192.c +++ b/drivers/hwmon/smsc47m192.c | |||
| @@ -86,7 +86,7 @@ static inline u8 IN_TO_REG(unsigned long val, int n) | |||
| 86 | */ | 86 | */ |
| 87 | static inline s8 TEMP_TO_REG(int val) | 87 | static inline s8 TEMP_TO_REG(int val) |
| 88 | { | 88 | { |
| 89 | return clamp_val(SCALE(val, 1, 1000), -128000, 127000); | 89 | return SCALE(clamp_val(val, -128000, 127000), 1, 1000); |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | static inline int TEMP_FROM_REG(s8 val) | 92 | static inline int TEMP_FROM_REG(s8 val) |
| @@ -384,6 +384,8 @@ static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, | |||
| 384 | err = kstrtoul(buf, 10, &val); | 384 | err = kstrtoul(buf, 10, &val); |
| 385 | if (err) | 385 | if (err) |
| 386 | return err; | 386 | return err; |
| 387 | if (val > 255) | ||
| 388 | return -EINVAL; | ||
| 387 | 389 | ||
| 388 | data->vrm = val; | 390 | data->vrm = val; |
| 389 | return count; | 391 | return count; |
diff --git a/drivers/i2c/busses/i2c-sun6i-p2wi.c b/drivers/i2c/busses/i2c-sun6i-p2wi.c index 09de4fd12d57..4d75d4759709 100644 --- a/drivers/i2c/busses/i2c-sun6i-p2wi.c +++ b/drivers/i2c/busses/i2c-sun6i-p2wi.c | |||
| @@ -22,7 +22,6 @@ | |||
| 22 | * | 22 | * |
| 23 | */ | 23 | */ |
| 24 | #include <linux/clk.h> | 24 | #include <linux/clk.h> |
| 25 | #include <linux/module.h> | ||
| 26 | #include <linux/i2c.h> | 25 | #include <linux/i2c.h> |
| 27 | #include <linux/io.h> | 26 | #include <linux/io.h> |
| 28 | #include <linux/interrupt.h> | 27 | #include <linux/interrupt.h> |
diff --git a/drivers/i2c/muxes/Kconfig b/drivers/i2c/muxes/Kconfig index f7f9865b8b89..f6d313e528de 100644 --- a/drivers/i2c/muxes/Kconfig +++ b/drivers/i2c/muxes/Kconfig | |||
| @@ -40,6 +40,7 @@ config I2C_MUX_PCA9541 | |||
| 40 | 40 | ||
| 41 | config I2C_MUX_PCA954x | 41 | config I2C_MUX_PCA954x |
| 42 | tristate "Philips PCA954x I2C Mux/switches" | 42 | tristate "Philips PCA954x I2C Mux/switches" |
| 43 | depends on GPIOLIB | ||
| 43 | help | 44 | help |
| 44 | If you say yes here you get support for the Philips PCA954x | 45 | If you say yes here you get support for the Philips PCA954x |
| 45 | I2C mux/switch devices. | 46 | I2C mux/switch devices. |
diff --git a/drivers/ide/Kconfig b/drivers/ide/Kconfig index 8fb46aab2d87..a04c49f2a011 100644 --- a/drivers/ide/Kconfig +++ b/drivers/ide/Kconfig | |||
| @@ -416,6 +416,7 @@ config BLK_DEV_CY82C693 | |||
| 416 | 416 | ||
| 417 | config BLK_DEV_CS5520 | 417 | config BLK_DEV_CS5520 |
| 418 | tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)" | 418 | tristate "Cyrix CS5510/20 MediaGX chipset support (VERY EXPERIMENTAL)" |
| 419 | depends on X86_32 || COMPILE_TEST | ||
| 419 | select BLK_DEV_IDEDMA_PCI | 420 | select BLK_DEV_IDEDMA_PCI |
| 420 | help | 421 | help |
| 421 | Include support for PIO tuning and virtual DMA on the Cyrix MediaGX | 422 | Include support for PIO tuning and virtual DMA on the Cyrix MediaGX |
| @@ -426,6 +427,7 @@ config BLK_DEV_CS5520 | |||
| 426 | 427 | ||
| 427 | config BLK_DEV_CS5530 | 428 | config BLK_DEV_CS5530 |
| 428 | tristate "Cyrix/National Semiconductor CS5530 MediaGX chipset support" | 429 | tristate "Cyrix/National Semiconductor CS5530 MediaGX chipset support" |
| 430 | depends on X86_32 || COMPILE_TEST | ||
| 429 | select BLK_DEV_IDEDMA_PCI | 431 | select BLK_DEV_IDEDMA_PCI |
| 430 | help | 432 | help |
| 431 | Include support for UDMA on the Cyrix MediaGX 5530 chipset. This | 433 | Include support for UDMA on the Cyrix MediaGX 5530 chipset. This |
| @@ -435,7 +437,7 @@ config BLK_DEV_CS5530 | |||
| 435 | 437 | ||
| 436 | config BLK_DEV_CS5535 | 438 | config BLK_DEV_CS5535 |
| 437 | tristate "AMD CS5535 chipset support" | 439 | tristate "AMD CS5535 chipset support" |
| 438 | depends on X86 && !X86_64 | 440 | depends on X86_32 |
| 439 | select BLK_DEV_IDEDMA_PCI | 441 | select BLK_DEV_IDEDMA_PCI |
| 440 | help | 442 | help |
| 441 | Include support for UDMA on the NSC/AMD CS5535 companion chipset. | 443 | Include support for UDMA on the NSC/AMD CS5535 companion chipset. |
| @@ -486,6 +488,7 @@ config BLK_DEV_JMICRON | |||
| 486 | 488 | ||
| 487 | config BLK_DEV_SC1200 | 489 | config BLK_DEV_SC1200 |
| 488 | tristate "National SCx200 chipset support" | 490 | tristate "National SCx200 chipset support" |
| 491 | depends on X86_32 || COMPILE_TEST | ||
| 489 | select BLK_DEV_IDEDMA_PCI | 492 | select BLK_DEV_IDEDMA_PCI |
| 490 | help | 493 | help |
| 491 | This driver adds support for the on-board IDE controller on the | 494 | This driver adds support for the on-board IDE controller on the |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 2a744a91370e..a3d3b1733c49 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
| @@ -853,8 +853,9 @@ static int init_irq (ide_hwif_t *hwif) | |||
| 853 | if (irq_handler == NULL) | 853 | if (irq_handler == NULL) |
| 854 | irq_handler = ide_intr; | 854 | irq_handler = ide_intr; |
| 855 | 855 | ||
| 856 | if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) | 856 | if (!host->get_lock) |
| 857 | goto out_up; | 857 | if (request_irq(hwif->irq, irq_handler, sa, hwif->name, hwif)) |
| 858 | goto out_up; | ||
| 858 | 859 | ||
| 859 | #if !defined(__mc68000__) | 860 | #if !defined(__mc68000__) |
| 860 | printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, | 861 | printk(KERN_INFO "%s at 0x%03lx-0x%03lx,0x%03lx on irq %d", hwif->name, |
| @@ -1533,7 +1534,8 @@ static void ide_unregister(ide_hwif_t *hwif) | |||
| 1533 | 1534 | ||
| 1534 | ide_proc_unregister_port(hwif); | 1535 | ide_proc_unregister_port(hwif); |
| 1535 | 1536 | ||
| 1536 | free_irq(hwif->irq, hwif); | 1537 | if (!hwif->host->get_lock) |
| 1538 | free_irq(hwif->irq, hwif); | ||
| 1537 | 1539 | ||
| 1538 | device_unregister(hwif->portdev); | 1540 | device_unregister(hwif->portdev); |
| 1539 | device_unregister(&hwif->gendev); | 1541 | device_unregister(&hwif->gendev); |
diff --git a/drivers/iio/accel/bma180.c b/drivers/iio/accel/bma180.c index a7e68c81f89d..a077cc86421b 100644 --- a/drivers/iio/accel/bma180.c +++ b/drivers/iio/accel/bma180.c | |||
| @@ -68,13 +68,13 @@ | |||
| 68 | /* Defaults values */ | 68 | /* Defaults values */ |
| 69 | #define BMA180_DEF_PMODE 0 | 69 | #define BMA180_DEF_PMODE 0 |
| 70 | #define BMA180_DEF_BW 20 | 70 | #define BMA180_DEF_BW 20 |
| 71 | #define BMA180_DEF_SCALE 250 | 71 | #define BMA180_DEF_SCALE 2452 |
| 72 | 72 | ||
| 73 | /* Available values for sysfs */ | 73 | /* Available values for sysfs */ |
| 74 | #define BMA180_FLP_FREQ_AVAILABLE \ | 74 | #define BMA180_FLP_FREQ_AVAILABLE \ |
| 75 | "10 20 40 75 150 300" | 75 | "10 20 40 75 150 300" |
| 76 | #define BMA180_SCALE_AVAILABLE \ | 76 | #define BMA180_SCALE_AVAILABLE \ |
| 77 | "0.000130 0.000190 0.000250 0.000380 0.000500 0.000990 0.001980" | 77 | "0.001275 0.001863 0.002452 0.003727 0.004903 0.009709 0.019417" |
| 78 | 78 | ||
| 79 | struct bma180_data { | 79 | struct bma180_data { |
| 80 | struct i2c_client *client; | 80 | struct i2c_client *client; |
| @@ -94,7 +94,7 @@ enum bma180_axis { | |||
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | static int bw_table[] = { 10, 20, 40, 75, 150, 300 }; /* Hz */ | 96 | static int bw_table[] = { 10, 20, 40, 75, 150, 300 }; /* Hz */ |
| 97 | static int scale_table[] = { 130, 190, 250, 380, 500, 990, 1980 }; | 97 | static int scale_table[] = { 1275, 1863, 2452, 3727, 4903, 9709, 19417 }; |
| 98 | 98 | ||
| 99 | static int bma180_get_acc_reg(struct bma180_data *data, enum bma180_axis axis) | 99 | static int bma180_get_acc_reg(struct bma180_data *data, enum bma180_axis axis) |
| 100 | { | 100 | { |
| @@ -376,6 +376,8 @@ static int bma180_write_raw(struct iio_dev *indio_dev, | |||
| 376 | mutex_unlock(&data->mutex); | 376 | mutex_unlock(&data->mutex); |
| 377 | return ret; | 377 | return ret; |
| 378 | case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: | 378 | case IIO_CHAN_INFO_LOW_PASS_FILTER_3DB_FREQUENCY: |
| 379 | if (val2) | ||
| 380 | return -EINVAL; | ||
| 379 | mutex_lock(&data->mutex); | 381 | mutex_lock(&data->mutex); |
| 380 | ret = bma180_set_bw(data, val); | 382 | ret = bma180_set_bw(data, val); |
| 381 | mutex_unlock(&data->mutex); | 383 | mutex_unlock(&data->mutex); |
diff --git a/drivers/iio/accel/hid-sensor-accel-3d.c b/drivers/iio/accel/hid-sensor-accel-3d.c index 69abf9163df7..54e464e4bb72 100644 --- a/drivers/iio/accel/hid-sensor-accel-3d.c +++ b/drivers/iio/accel/hid-sensor-accel-3d.c | |||
| @@ -110,7 +110,6 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev, | |||
| 110 | struct accel_3d_state *accel_state = iio_priv(indio_dev); | 110 | struct accel_3d_state *accel_state = iio_priv(indio_dev); |
| 111 | int report_id = -1; | 111 | int report_id = -1; |
| 112 | u32 address; | 112 | u32 address; |
| 113 | int ret; | ||
| 114 | int ret_type; | 113 | int ret_type; |
| 115 | s32 poll_value; | 114 | s32 poll_value; |
| 116 | 115 | ||
| @@ -151,14 +150,12 @@ static int accel_3d_read_raw(struct iio_dev *indio_dev, | |||
| 151 | ret_type = IIO_VAL_INT; | 150 | ret_type = IIO_VAL_INT; |
| 152 | break; | 151 | break; |
| 153 | case IIO_CHAN_INFO_SAMP_FREQ: | 152 | case IIO_CHAN_INFO_SAMP_FREQ: |
| 154 | ret = hid_sensor_read_samp_freq_value( | 153 | ret_type = hid_sensor_read_samp_freq_value( |
| 155 | &accel_state->common_attributes, val, val2); | 154 | &accel_state->common_attributes, val, val2); |
| 156 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 157 | break; | 155 | break; |
| 158 | case IIO_CHAN_INFO_HYSTERESIS: | 156 | case IIO_CHAN_INFO_HYSTERESIS: |
| 159 | ret = hid_sensor_read_raw_hyst_value( | 157 | ret_type = hid_sensor_read_raw_hyst_value( |
| 160 | &accel_state->common_attributes, val, val2); | 158 | &accel_state->common_attributes, val, val2); |
| 161 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 162 | break; | 159 | break; |
| 163 | default: | 160 | default: |
| 164 | ret_type = -EINVAL; | 161 | ret_type = -EINVAL; |
diff --git a/drivers/iio/accel/mma8452.c b/drivers/iio/accel/mma8452.c index 17aeea170566..2a5fa9a436e5 100644 --- a/drivers/iio/accel/mma8452.c +++ b/drivers/iio/accel/mma8452.c | |||
| @@ -111,8 +111,14 @@ static const int mma8452_samp_freq[8][2] = { | |||
| 111 | {6, 250000}, {1, 560000} | 111 | {6, 250000}, {1, 560000} |
| 112 | }; | 112 | }; |
| 113 | 113 | ||
| 114 | /* | ||
| 115 | * Hardware has fullscale of -2G, -4G, -8G corresponding to raw value -2048 | ||
| 116 | * The userspace interface uses m/s^2 and we declare micro units | ||
| 117 | * So scale factor is given by: | ||
| 118 | * g * N * 1000000 / 2048 for N = 2, 4, 8 and g=9.80665 | ||
| 119 | */ | ||
| 114 | static const int mma8452_scales[3][2] = { | 120 | static const int mma8452_scales[3][2] = { |
| 115 | {0, 977}, {0, 1953}, {0, 3906} | 121 | {0, 9577}, {0, 19154}, {0, 38307} |
| 116 | }; | 122 | }; |
| 117 | 123 | ||
| 118 | static ssize_t mma8452_show_samp_freq_avail(struct device *dev, | 124 | static ssize_t mma8452_show_samp_freq_avail(struct device *dev, |
diff --git a/drivers/iio/adc/ti_am335x_adc.c b/drivers/iio/adc/ti_am335x_adc.c index a4db3026bec6..d5dc4c6ce86c 100644 --- a/drivers/iio/adc/ti_am335x_adc.c +++ b/drivers/iio/adc/ti_am335x_adc.c | |||
| @@ -374,7 +374,7 @@ static int tiadc_read_raw(struct iio_dev *indio_dev, | |||
| 374 | return -EAGAIN; | 374 | return -EAGAIN; |
| 375 | } | 375 | } |
| 376 | } | 376 | } |
| 377 | map_val = chan->channel + TOTAL_CHANNELS; | 377 | map_val = adc_dev->channel_step[chan->scan_index]; |
| 378 | 378 | ||
| 379 | /* | 379 | /* |
| 380 | * We check the complete FIFO. We programmed just one entry but in case | 380 | * We check the complete FIFO. We programmed just one entry but in case |
diff --git a/drivers/iio/gyro/hid-sensor-gyro-3d.c b/drivers/iio/gyro/hid-sensor-gyro-3d.c index 40f4e4935d0d..fa034a3dad78 100644 --- a/drivers/iio/gyro/hid-sensor-gyro-3d.c +++ b/drivers/iio/gyro/hid-sensor-gyro-3d.c | |||
| @@ -110,7 +110,6 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev, | |||
| 110 | struct gyro_3d_state *gyro_state = iio_priv(indio_dev); | 110 | struct gyro_3d_state *gyro_state = iio_priv(indio_dev); |
| 111 | int report_id = -1; | 111 | int report_id = -1; |
| 112 | u32 address; | 112 | u32 address; |
| 113 | int ret; | ||
| 114 | int ret_type; | 113 | int ret_type; |
| 115 | s32 poll_value; | 114 | s32 poll_value; |
| 116 | 115 | ||
| @@ -151,14 +150,12 @@ static int gyro_3d_read_raw(struct iio_dev *indio_dev, | |||
| 151 | ret_type = IIO_VAL_INT; | 150 | ret_type = IIO_VAL_INT; |
| 152 | break; | 151 | break; |
| 153 | case IIO_CHAN_INFO_SAMP_FREQ: | 152 | case IIO_CHAN_INFO_SAMP_FREQ: |
| 154 | ret = hid_sensor_read_samp_freq_value( | 153 | ret_type = hid_sensor_read_samp_freq_value( |
| 155 | &gyro_state->common_attributes, val, val2); | 154 | &gyro_state->common_attributes, val, val2); |
| 156 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 157 | break; | 155 | break; |
| 158 | case IIO_CHAN_INFO_HYSTERESIS: | 156 | case IIO_CHAN_INFO_HYSTERESIS: |
| 159 | ret = hid_sensor_read_raw_hyst_value( | 157 | ret_type = hid_sensor_read_raw_hyst_value( |
| 160 | &gyro_state->common_attributes, val, val2); | 158 | &gyro_state->common_attributes, val, val2); |
| 161 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 162 | break; | 159 | break; |
| 163 | default: | 160 | default: |
| 164 | ret_type = -EINVAL; | 161 | ret_type = -EINVAL; |
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 36b1ae92e239..9f1a14009901 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
| @@ -966,7 +966,7 @@ static int iio_buffer_update_demux(struct iio_dev *indio_dev, | |||
| 966 | 966 | ||
| 967 | /* Now we have the two masks, work from least sig and build up sizes */ | 967 | /* Now we have the two masks, work from least sig and build up sizes */ |
| 968 | for_each_set_bit(out_ind, | 968 | for_each_set_bit(out_ind, |
| 969 | indio_dev->active_scan_mask, | 969 | buffer->scan_mask, |
| 970 | indio_dev->masklength) { | 970 | indio_dev->masklength) { |
| 971 | in_ind = find_next_bit(indio_dev->active_scan_mask, | 971 | in_ind = find_next_bit(indio_dev->active_scan_mask, |
| 972 | indio_dev->masklength, | 972 | indio_dev->masklength, |
diff --git a/drivers/iio/industrialio-event.c b/drivers/iio/industrialio-event.c index 258a973a1fb8..bfbf4d419f41 100644 --- a/drivers/iio/industrialio-event.c +++ b/drivers/iio/industrialio-event.c | |||
| @@ -345,6 +345,9 @@ static int iio_device_add_event(struct iio_dev *indio_dev, | |||
| 345 | &indio_dev->event_interface->dev_attr_list); | 345 | &indio_dev->event_interface->dev_attr_list); |
| 346 | kfree(postfix); | 346 | kfree(postfix); |
| 347 | 347 | ||
| 348 | if ((ret == -EBUSY) && (shared_by != IIO_SEPARATE)) | ||
| 349 | continue; | ||
| 350 | |||
| 348 | if (ret) | 351 | if (ret) |
| 349 | return ret; | 352 | return ret; |
| 350 | 353 | ||
diff --git a/drivers/iio/light/hid-sensor-als.c b/drivers/iio/light/hid-sensor-als.c index f34c94380b41..96e71e103ea7 100644 --- a/drivers/iio/light/hid-sensor-als.c +++ b/drivers/iio/light/hid-sensor-als.c | |||
| @@ -79,7 +79,6 @@ static int als_read_raw(struct iio_dev *indio_dev, | |||
| 79 | struct als_state *als_state = iio_priv(indio_dev); | 79 | struct als_state *als_state = iio_priv(indio_dev); |
| 80 | int report_id = -1; | 80 | int report_id = -1; |
| 81 | u32 address; | 81 | u32 address; |
| 82 | int ret; | ||
| 83 | int ret_type; | 82 | int ret_type; |
| 84 | s32 poll_value; | 83 | s32 poll_value; |
| 85 | 84 | ||
| @@ -129,14 +128,12 @@ static int als_read_raw(struct iio_dev *indio_dev, | |||
| 129 | ret_type = IIO_VAL_INT; | 128 | ret_type = IIO_VAL_INT; |
| 130 | break; | 129 | break; |
| 131 | case IIO_CHAN_INFO_SAMP_FREQ: | 130 | case IIO_CHAN_INFO_SAMP_FREQ: |
| 132 | ret = hid_sensor_read_samp_freq_value( | 131 | ret_type = hid_sensor_read_samp_freq_value( |
| 133 | &als_state->common_attributes, val, val2); | 132 | &als_state->common_attributes, val, val2); |
| 134 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 135 | break; | 133 | break; |
| 136 | case IIO_CHAN_INFO_HYSTERESIS: | 134 | case IIO_CHAN_INFO_HYSTERESIS: |
| 137 | ret = hid_sensor_read_raw_hyst_value( | 135 | ret_type = hid_sensor_read_raw_hyst_value( |
| 138 | &als_state->common_attributes, val, val2); | 136 | &als_state->common_attributes, val, val2); |
| 139 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 140 | break; | 137 | break; |
| 141 | default: | 138 | default: |
| 142 | ret_type = -EINVAL; | 139 | ret_type = -EINVAL; |
diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c index d203ef4d892f..412bae86d6ae 100644 --- a/drivers/iio/light/hid-sensor-prox.c +++ b/drivers/iio/light/hid-sensor-prox.c | |||
| @@ -74,7 +74,6 @@ static int prox_read_raw(struct iio_dev *indio_dev, | |||
| 74 | struct prox_state *prox_state = iio_priv(indio_dev); | 74 | struct prox_state *prox_state = iio_priv(indio_dev); |
| 75 | int report_id = -1; | 75 | int report_id = -1; |
| 76 | u32 address; | 76 | u32 address; |
| 77 | int ret; | ||
| 78 | int ret_type; | 77 | int ret_type; |
| 79 | s32 poll_value; | 78 | s32 poll_value; |
| 80 | 79 | ||
| @@ -125,14 +124,12 @@ static int prox_read_raw(struct iio_dev *indio_dev, | |||
| 125 | ret_type = IIO_VAL_INT; | 124 | ret_type = IIO_VAL_INT; |
| 126 | break; | 125 | break; |
| 127 | case IIO_CHAN_INFO_SAMP_FREQ: | 126 | case IIO_CHAN_INFO_SAMP_FREQ: |
| 128 | ret = hid_sensor_read_samp_freq_value( | 127 | ret_type = hid_sensor_read_samp_freq_value( |
| 129 | &prox_state->common_attributes, val, val2); | 128 | &prox_state->common_attributes, val, val2); |
| 130 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 131 | break; | 129 | break; |
| 132 | case IIO_CHAN_INFO_HYSTERESIS: | 130 | case IIO_CHAN_INFO_HYSTERESIS: |
| 133 | ret = hid_sensor_read_raw_hyst_value( | 131 | ret_type = hid_sensor_read_raw_hyst_value( |
| 134 | &prox_state->common_attributes, val, val2); | 132 | &prox_state->common_attributes, val, val2); |
| 135 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 136 | break; | 133 | break; |
| 137 | default: | 134 | default: |
| 138 | ret_type = -EINVAL; | 135 | ret_type = -EINVAL; |
diff --git a/drivers/iio/light/tcs3472.c b/drivers/iio/light/tcs3472.c index fe063a0a21cd..752569985d1d 100644 --- a/drivers/iio/light/tcs3472.c +++ b/drivers/iio/light/tcs3472.c | |||
| @@ -52,6 +52,7 @@ | |||
| 52 | 52 | ||
| 53 | struct tcs3472_data { | 53 | struct tcs3472_data { |
| 54 | struct i2c_client *client; | 54 | struct i2c_client *client; |
| 55 | struct mutex lock; | ||
| 55 | u8 enable; | 56 | u8 enable; |
| 56 | u8 control; | 57 | u8 control; |
| 57 | u8 atime; | 58 | u8 atime; |
| @@ -116,10 +117,17 @@ static int tcs3472_read_raw(struct iio_dev *indio_dev, | |||
| 116 | 117 | ||
| 117 | switch (mask) { | 118 | switch (mask) { |
| 118 | case IIO_CHAN_INFO_RAW: | 119 | case IIO_CHAN_INFO_RAW: |
| 120 | if (iio_buffer_enabled(indio_dev)) | ||
| 121 | return -EBUSY; | ||
| 122 | |||
| 123 | mutex_lock(&data->lock); | ||
| 119 | ret = tcs3472_req_data(data); | 124 | ret = tcs3472_req_data(data); |
| 120 | if (ret < 0) | 125 | if (ret < 0) { |
| 126 | mutex_unlock(&data->lock); | ||
| 121 | return ret; | 127 | return ret; |
| 128 | } | ||
| 122 | ret = i2c_smbus_read_word_data(data->client, chan->address); | 129 | ret = i2c_smbus_read_word_data(data->client, chan->address); |
| 130 | mutex_unlock(&data->lock); | ||
| 123 | if (ret < 0) | 131 | if (ret < 0) |
| 124 | return ret; | 132 | return ret; |
| 125 | *val = ret; | 133 | *val = ret; |
| @@ -255,6 +263,7 @@ static int tcs3472_probe(struct i2c_client *client, | |||
| 255 | data = iio_priv(indio_dev); | 263 | data = iio_priv(indio_dev); |
| 256 | i2c_set_clientdata(client, indio_dev); | 264 | i2c_set_clientdata(client, indio_dev); |
| 257 | data->client = client; | 265 | data->client = client; |
| 266 | mutex_init(&data->lock); | ||
| 258 | 267 | ||
| 259 | indio_dev->dev.parent = &client->dev; | 268 | indio_dev->dev.parent = &client->dev; |
| 260 | indio_dev->info = &tcs3472_info; | 269 | indio_dev->info = &tcs3472_info; |
diff --git a/drivers/iio/magnetometer/hid-sensor-magn-3d.c b/drivers/iio/magnetometer/hid-sensor-magn-3d.c index 41cf29e2a371..b2b0937d5133 100644 --- a/drivers/iio/magnetometer/hid-sensor-magn-3d.c +++ b/drivers/iio/magnetometer/hid-sensor-magn-3d.c | |||
| @@ -110,7 +110,6 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev, | |||
| 110 | struct magn_3d_state *magn_state = iio_priv(indio_dev); | 110 | struct magn_3d_state *magn_state = iio_priv(indio_dev); |
| 111 | int report_id = -1; | 111 | int report_id = -1; |
| 112 | u32 address; | 112 | u32 address; |
| 113 | int ret; | ||
| 114 | int ret_type; | 113 | int ret_type; |
| 115 | s32 poll_value; | 114 | s32 poll_value; |
| 116 | 115 | ||
| @@ -153,14 +152,12 @@ static int magn_3d_read_raw(struct iio_dev *indio_dev, | |||
| 153 | ret_type = IIO_VAL_INT; | 152 | ret_type = IIO_VAL_INT; |
| 154 | break; | 153 | break; |
| 155 | case IIO_CHAN_INFO_SAMP_FREQ: | 154 | case IIO_CHAN_INFO_SAMP_FREQ: |
| 156 | ret = hid_sensor_read_samp_freq_value( | 155 | ret_type = hid_sensor_read_samp_freq_value( |
| 157 | &magn_state->common_attributes, val, val2); | 156 | &magn_state->common_attributes, val, val2); |
| 158 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 159 | break; | 157 | break; |
| 160 | case IIO_CHAN_INFO_HYSTERESIS: | 158 | case IIO_CHAN_INFO_HYSTERESIS: |
| 161 | ret = hid_sensor_read_raw_hyst_value( | 159 | ret_type = hid_sensor_read_raw_hyst_value( |
| 162 | &magn_state->common_attributes, val, val2); | 160 | &magn_state->common_attributes, val, val2); |
| 163 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 164 | break; | 161 | break; |
| 165 | default: | 162 | default: |
| 166 | ret_type = -EINVAL; | 163 | ret_type = -EINVAL; |
diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c index 1cd190c73788..2c0d2a4fed8c 100644 --- a/drivers/iio/pressure/hid-sensor-press.c +++ b/drivers/iio/pressure/hid-sensor-press.c | |||
| @@ -78,7 +78,6 @@ static int press_read_raw(struct iio_dev *indio_dev, | |||
| 78 | struct press_state *press_state = iio_priv(indio_dev); | 78 | struct press_state *press_state = iio_priv(indio_dev); |
| 79 | int report_id = -1; | 79 | int report_id = -1; |
| 80 | u32 address; | 80 | u32 address; |
| 81 | int ret; | ||
| 82 | int ret_type; | 81 | int ret_type; |
| 83 | s32 poll_value; | 82 | s32 poll_value; |
| 84 | 83 | ||
| @@ -128,14 +127,12 @@ static int press_read_raw(struct iio_dev *indio_dev, | |||
| 128 | ret_type = IIO_VAL_INT; | 127 | ret_type = IIO_VAL_INT; |
| 129 | break; | 128 | break; |
| 130 | case IIO_CHAN_INFO_SAMP_FREQ: | 129 | case IIO_CHAN_INFO_SAMP_FREQ: |
| 131 | ret = hid_sensor_read_samp_freq_value( | 130 | ret_type = hid_sensor_read_samp_freq_value( |
| 132 | &press_state->common_attributes, val, val2); | 131 | &press_state->common_attributes, val, val2); |
| 133 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 134 | break; | 132 | break; |
| 135 | case IIO_CHAN_INFO_HYSTERESIS: | 133 | case IIO_CHAN_INFO_HYSTERESIS: |
| 136 | ret = hid_sensor_read_raw_hyst_value( | 134 | ret_type = hid_sensor_read_raw_hyst_value( |
| 137 | &press_state->common_attributes, val, val2); | 135 | &press_state->common_attributes, val, val2); |
| 138 | ret_type = IIO_VAL_INT_PLUS_MICRO; | ||
| 139 | break; | 136 | break; |
| 140 | default: | 137 | default: |
| 141 | ret_type = -EINVAL; | 138 | ret_type = -EINVAL; |
diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c index 5e153f6d4b48..768a0fb67dd6 100644 --- a/drivers/infiniband/hw/cxgb4/cm.c +++ b/drivers/infiniband/hw/cxgb4/cm.c | |||
| @@ -432,8 +432,17 @@ static void arp_failure_discard(void *handle, struct sk_buff *skb) | |||
| 432 | */ | 432 | */ |
| 433 | static void act_open_req_arp_failure(void *handle, struct sk_buff *skb) | 433 | static void act_open_req_arp_failure(void *handle, struct sk_buff *skb) |
| 434 | { | 434 | { |
| 435 | struct c4iw_ep *ep = handle; | ||
| 436 | |||
| 435 | printk(KERN_ERR MOD "ARP failure duing connect\n"); | 437 | printk(KERN_ERR MOD "ARP failure duing connect\n"); |
| 436 | kfree_skb(skb); | 438 | kfree_skb(skb); |
| 439 | connect_reply_upcall(ep, -EHOSTUNREACH); | ||
| 440 | state_set(&ep->com, DEAD); | ||
| 441 | remove_handle(ep->com.dev, &ep->com.dev->atid_idr, ep->atid); | ||
| 442 | cxgb4_free_atid(ep->com.dev->rdev.lldi.tids, ep->atid); | ||
| 443 | dst_release(ep->dst); | ||
| 444 | cxgb4_l2t_release(ep->l2t); | ||
| 445 | c4iw_put_ep(&ep->com); | ||
| 437 | } | 446 | } |
| 438 | 447 | ||
| 439 | /* | 448 | /* |
| @@ -658,7 +667,7 @@ static int send_connect(struct c4iw_ep *ep) | |||
| 658 | opt2 |= T5_OPT_2_VALID; | 667 | opt2 |= T5_OPT_2_VALID; |
| 659 | opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE); | 668 | opt2 |= V_CONG_CNTRL(CONG_ALG_TAHOE); |
| 660 | } | 669 | } |
| 661 | t4_set_arp_err_handler(skb, NULL, act_open_req_arp_failure); | 670 | t4_set_arp_err_handler(skb, ep, act_open_req_arp_failure); |
| 662 | 671 | ||
| 663 | if (is_t4(ep->com.dev->rdev.lldi.adapter_type)) { | 672 | if (is_t4(ep->com.dev->rdev.lldi.adapter_type)) { |
| 664 | if (ep->com.remote_addr.ss_family == AF_INET) { | 673 | if (ep->com.remote_addr.ss_family == AF_INET) { |
| @@ -2180,7 +2189,6 @@ static void reject_cr(struct c4iw_dev *dev, u32 hwtid, struct sk_buff *skb) | |||
| 2180 | PDBG("%s c4iw_dev %p tid %u\n", __func__, dev, hwtid); | 2189 | PDBG("%s c4iw_dev %p tid %u\n", __func__, dev, hwtid); |
| 2181 | BUG_ON(skb_cloned(skb)); | 2190 | BUG_ON(skb_cloned(skb)); |
| 2182 | skb_trim(skb, sizeof(struct cpl_tid_release)); | 2191 | skb_trim(skb, sizeof(struct cpl_tid_release)); |
| 2183 | skb_get(skb); | ||
| 2184 | release_tid(&dev->rdev, hwtid, skb); | 2192 | release_tid(&dev->rdev, hwtid, skb); |
| 2185 | return; | 2193 | return; |
| 2186 | } | 2194 | } |
| @@ -3917,7 +3925,7 @@ int __init c4iw_cm_init(void) | |||
| 3917 | return 0; | 3925 | return 0; |
| 3918 | } | 3926 | } |
| 3919 | 3927 | ||
| 3920 | void __exit c4iw_cm_term(void) | 3928 | void c4iw_cm_term(void) |
| 3921 | { | 3929 | { |
| 3922 | WARN_ON(!list_empty(&timeout_list)); | 3930 | WARN_ON(!list_empty(&timeout_list)); |
| 3923 | flush_workqueue(workq); | 3931 | flush_workqueue(workq); |
diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c index dd93aadc996e..7db82b24302b 100644 --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c | |||
| @@ -696,6 +696,7 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev) | |||
| 696 | pr_err(MOD "error allocating status page\n"); | 696 | pr_err(MOD "error allocating status page\n"); |
| 697 | goto err4; | 697 | goto err4; |
| 698 | } | 698 | } |
| 699 | rdev->status_page->db_off = 0; | ||
| 699 | return 0; | 700 | return 0; |
| 700 | err4: | 701 | err4: |
| 701 | c4iw_rqtpool_destroy(rdev); | 702 | c4iw_rqtpool_destroy(rdev); |
| @@ -729,7 +730,6 @@ static void c4iw_dealloc(struct uld_ctx *ctx) | |||
| 729 | if (ctx->dev->rdev.oc_mw_kva) | 730 | if (ctx->dev->rdev.oc_mw_kva) |
| 730 | iounmap(ctx->dev->rdev.oc_mw_kva); | 731 | iounmap(ctx->dev->rdev.oc_mw_kva); |
| 731 | ib_dealloc_device(&ctx->dev->ibdev); | 732 | ib_dealloc_device(&ctx->dev->ibdev); |
| 732 | iwpm_exit(RDMA_NL_C4IW); | ||
| 733 | ctx->dev = NULL; | 733 | ctx->dev = NULL; |
| 734 | } | 734 | } |
| 735 | 735 | ||
| @@ -826,12 +826,6 @@ static struct c4iw_dev *c4iw_alloc(const struct cxgb4_lld_info *infop) | |||
| 826 | setup_debugfs(devp); | 826 | setup_debugfs(devp); |
| 827 | } | 827 | } |
| 828 | 828 | ||
| 829 | ret = iwpm_init(RDMA_NL_C4IW); | ||
| 830 | if (ret) { | ||
| 831 | pr_err("port mapper initialization failed with %d\n", ret); | ||
| 832 | ib_dealloc_device(&devp->ibdev); | ||
| 833 | return ERR_PTR(ret); | ||
| 834 | } | ||
| 835 | 829 | ||
| 836 | return devp; | 830 | return devp; |
| 837 | } | 831 | } |
| @@ -1332,6 +1326,15 @@ static int __init c4iw_init_module(void) | |||
| 1332 | pr_err("%s[%u]: Failed to add netlink callback\n" | 1326 | pr_err("%s[%u]: Failed to add netlink callback\n" |
| 1333 | , __func__, __LINE__); | 1327 | , __func__, __LINE__); |
| 1334 | 1328 | ||
| 1329 | err = iwpm_init(RDMA_NL_C4IW); | ||
| 1330 | if (err) { | ||
| 1331 | pr_err("port mapper initialization failed with %d\n", err); | ||
| 1332 | ibnl_remove_client(RDMA_NL_C4IW); | ||
| 1333 | c4iw_cm_term(); | ||
| 1334 | debugfs_remove_recursive(c4iw_debugfs_root); | ||
| 1335 | return err; | ||
| 1336 | } | ||
| 1337 | |||
| 1335 | cxgb4_register_uld(CXGB4_ULD_RDMA, &c4iw_uld_info); | 1338 | cxgb4_register_uld(CXGB4_ULD_RDMA, &c4iw_uld_info); |
| 1336 | 1339 | ||
| 1337 | return 0; | 1340 | return 0; |
| @@ -1349,6 +1352,7 @@ static void __exit c4iw_exit_module(void) | |||
| 1349 | } | 1352 | } |
| 1350 | mutex_unlock(&dev_mutex); | 1353 | mutex_unlock(&dev_mutex); |
| 1351 | cxgb4_unregister_uld(CXGB4_ULD_RDMA); | 1354 | cxgb4_unregister_uld(CXGB4_ULD_RDMA); |
| 1355 | iwpm_exit(RDMA_NL_C4IW); | ||
| 1352 | ibnl_remove_client(RDMA_NL_C4IW); | 1356 | ibnl_remove_client(RDMA_NL_C4IW); |
| 1353 | c4iw_cm_term(); | 1357 | c4iw_cm_term(); |
| 1354 | debugfs_remove_recursive(c4iw_debugfs_root); | 1358 | debugfs_remove_recursive(c4iw_debugfs_root); |
diff --git a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h index 125bc5d1e175..361fff7a0742 100644 --- a/drivers/infiniband/hw/cxgb4/iw_cxgb4.h +++ b/drivers/infiniband/hw/cxgb4/iw_cxgb4.h | |||
| @@ -908,7 +908,7 @@ int c4iw_destroy_ctrl_qp(struct c4iw_rdev *rdev); | |||
| 908 | int c4iw_register_device(struct c4iw_dev *dev); | 908 | int c4iw_register_device(struct c4iw_dev *dev); |
| 909 | void c4iw_unregister_device(struct c4iw_dev *dev); | 909 | void c4iw_unregister_device(struct c4iw_dev *dev); |
| 910 | int __init c4iw_cm_init(void); | 910 | int __init c4iw_cm_init(void); |
| 911 | void __exit c4iw_cm_term(void); | 911 | void c4iw_cm_term(void); |
| 912 | void c4iw_release_dev_ucontext(struct c4iw_rdev *rdev, | 912 | void c4iw_release_dev_ucontext(struct c4iw_rdev *rdev, |
| 913 | struct c4iw_dev_ucontext *uctx); | 913 | struct c4iw_dev_ucontext *uctx); |
| 914 | void c4iw_init_dev_ucontext(struct c4iw_rdev *rdev, | 914 | void c4iw_init_dev_ucontext(struct c4iw_rdev *rdev, |
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index d13ddf1c0033..bbbcf389272c 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c | |||
| @@ -675,7 +675,7 @@ static int create_kernel_qp(struct mlx5_ib_dev *dev, | |||
| 675 | int err; | 675 | int err; |
| 676 | 676 | ||
| 677 | uuari = &dev->mdev.priv.uuari; | 677 | uuari = &dev->mdev.priv.uuari; |
| 678 | if (init_attr->create_flags & ~IB_QP_CREATE_SIGNATURE_EN) | 678 | if (init_attr->create_flags & ~(IB_QP_CREATE_SIGNATURE_EN | IB_QP_CREATE_BLOCK_MULTICAST_LOOPBACK)) |
| 679 | return -EINVAL; | 679 | return -EINVAL; |
| 680 | 680 | ||
| 681 | if (init_attr->qp_type == MLX5_IB_QPT_REG_UMR) | 681 | if (init_attr->qp_type == MLX5_IB_QPT_REG_UMR) |
diff --git a/drivers/input/input.c b/drivers/input/input.c index 1c4c0db05550..29ca0bb4f561 100644 --- a/drivers/input/input.c +++ b/drivers/input/input.c | |||
| @@ -257,9 +257,10 @@ static int input_handle_abs_event(struct input_dev *dev, | |||
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | static int input_get_disposition(struct input_dev *dev, | 259 | static int input_get_disposition(struct input_dev *dev, |
| 260 | unsigned int type, unsigned int code, int value) | 260 | unsigned int type, unsigned int code, int *pval) |
| 261 | { | 261 | { |
| 262 | int disposition = INPUT_IGNORE_EVENT; | 262 | int disposition = INPUT_IGNORE_EVENT; |
| 263 | int value = *pval; | ||
| 263 | 264 | ||
| 264 | switch (type) { | 265 | switch (type) { |
| 265 | 266 | ||
| @@ -357,6 +358,7 @@ static int input_get_disposition(struct input_dev *dev, | |||
| 357 | break; | 358 | break; |
| 358 | } | 359 | } |
| 359 | 360 | ||
| 361 | *pval = value; | ||
| 360 | return disposition; | 362 | return disposition; |
| 361 | } | 363 | } |
| 362 | 364 | ||
| @@ -365,7 +367,7 @@ static void input_handle_event(struct input_dev *dev, | |||
| 365 | { | 367 | { |
| 366 | int disposition; | 368 | int disposition; |
| 367 | 369 | ||
| 368 | disposition = input_get_disposition(dev, type, code, value); | 370 | disposition = input_get_disposition(dev, type, code, &value); |
| 369 | 371 | ||
| 370 | if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event) | 372 | if ((disposition & INPUT_PASS_TO_DEVICE) && dev->event) |
| 371 | dev->event(dev, type, code, value); | 373 | dev->event(dev, type, code, value); |
diff --git a/drivers/input/keyboard/st-keyscan.c b/drivers/input/keyboard/st-keyscan.c index 758b48731415..de7be4f03d91 100644 --- a/drivers/input/keyboard/st-keyscan.c +++ b/drivers/input/keyboard/st-keyscan.c | |||
| @@ -215,6 +215,7 @@ static int keyscan_probe(struct platform_device *pdev) | |||
| 215 | return 0; | 215 | return 0; |
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | #ifdef CONFIG_PM_SLEEP | ||
| 218 | static int keyscan_suspend(struct device *dev) | 219 | static int keyscan_suspend(struct device *dev) |
| 219 | { | 220 | { |
| 220 | struct platform_device *pdev = to_platform_device(dev); | 221 | struct platform_device *pdev = to_platform_device(dev); |
| @@ -249,6 +250,7 @@ static int keyscan_resume(struct device *dev) | |||
| 249 | mutex_unlock(&input->mutex); | 250 | mutex_unlock(&input->mutex); |
| 250 | return retval; | 251 | return retval; |
| 251 | } | 252 | } |
| 253 | #endif | ||
| 252 | 254 | ||
| 253 | static SIMPLE_DEV_PM_OPS(keyscan_dev_pm_ops, keyscan_suspend, keyscan_resume); | 255 | static SIMPLE_DEV_PM_OPS(keyscan_dev_pm_ops, keyscan_suspend, keyscan_resume); |
| 254 | 256 | ||
diff --git a/drivers/input/misc/sirfsoc-onkey.c b/drivers/input/misc/sirfsoc-onkey.c index e4104f9b2e6d..fed5102e1802 100644 --- a/drivers/input/misc/sirfsoc-onkey.c +++ b/drivers/input/misc/sirfsoc-onkey.c | |||
| @@ -213,7 +213,7 @@ static struct platform_driver sirfsoc_pwrc_driver = { | |||
| 213 | 213 | ||
| 214 | module_platform_driver(sirfsoc_pwrc_driver); | 214 | module_platform_driver(sirfsoc_pwrc_driver); |
| 215 | 215 | ||
| 216 | MODULE_LICENSE("GPLv2"); | 216 | MODULE_LICENSE("GPL v2"); |
| 217 | MODULE_AUTHOR("Binghua Duan <Binghua.Duan@csr.com>, Xianglong Du <Xianglong.Du@csr.com>"); | 217 | MODULE_AUTHOR("Binghua Duan <Binghua.Duan@csr.com>, Xianglong Du <Xianglong.Du@csr.com>"); |
| 218 | MODULE_DESCRIPTION("CSR Prima2 PWRC Driver"); | 218 | MODULE_DESCRIPTION("CSR Prima2 PWRC Driver"); |
| 219 | MODULE_ALIAS("platform:sirfsoc-pwrc"); | 219 | MODULE_ALIAS("platform:sirfsoc-pwrc"); |
diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c index ec772d962f06..ef9e0b8a9aa7 100644 --- a/drivers/input/mouse/synaptics.c +++ b/drivers/input/mouse/synaptics.c | |||
| @@ -132,7 +132,8 @@ static const struct min_max_quirk min_max_pnpid_table[] = { | |||
| 132 | 1232, 5710, 1156, 4696 | 132 | 1232, 5710, 1156, 4696 |
| 133 | }, | 133 | }, |
| 134 | { | 134 | { |
| 135 | (const char * const []){"LEN0034", "LEN0036", "LEN2004", NULL}, | 135 | (const char * const []){"LEN0034", "LEN0036", "LEN2002", |
| 136 | "LEN2004", NULL}, | ||
| 136 | 1024, 5112, 2024, 4832 | 137 | 1024, 5112, 2024, 4832 |
| 137 | }, | 138 | }, |
| 138 | { | 139 | { |
| @@ -168,7 +169,7 @@ static const char * const topbuttonpad_pnp_ids[] = { | |||
| 168 | "LEN0049", | 169 | "LEN0049", |
| 169 | "LEN2000", | 170 | "LEN2000", |
| 170 | "LEN2001", /* Edge E431 */ | 171 | "LEN2001", /* Edge E431 */ |
| 171 | "LEN2002", | 172 | "LEN2002", /* Edge E531 */ |
| 172 | "LEN2003", | 173 | "LEN2003", |
| 173 | "LEN2004", /* L440 */ | 174 | "LEN2004", /* L440 */ |
| 174 | "LEN2005", | 175 | "LEN2005", |
diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h index 381b20d4c561..136b7b204f56 100644 --- a/drivers/input/serio/i8042-x86ia64io.h +++ b/drivers/input/serio/i8042-x86ia64io.h | |||
| @@ -402,6 +402,13 @@ static const struct dmi_system_id __initconst i8042_dmi_nomux_table[] = { | |||
| 402 | }, | 402 | }, |
| 403 | }, | 403 | }, |
| 404 | { | 404 | { |
| 405 | /* Acer Aspire 5710 */ | ||
| 406 | .matches = { | ||
| 407 | DMI_MATCH(DMI_SYS_VENDOR, "Acer"), | ||
| 408 | DMI_MATCH(DMI_PRODUCT_NAME, "Aspire 5710"), | ||
| 409 | }, | ||
| 410 | }, | ||
| 411 | { | ||
| 405 | /* Gericom Bellagio */ | 412 | /* Gericom Bellagio */ |
| 406 | .matches = { | 413 | .matches = { |
| 407 | DMI_MATCH(DMI_SYS_VENDOR, "Gericom"), | 414 | DMI_MATCH(DMI_SYS_VENDOR, "Gericom"), |
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 977d05cd9e2e..e73cf2c71f35 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
| @@ -1217,9 +1217,9 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) | |||
| 1217 | * a=(pi*r^2)/C. | 1217 | * a=(pi*r^2)/C. |
| 1218 | */ | 1218 | */ |
| 1219 | int a = data[5]; | 1219 | int a = data[5]; |
| 1220 | int x_res = input_abs_get_res(input, ABS_X); | 1220 | int x_res = input_abs_get_res(input, ABS_MT_POSITION_X); |
| 1221 | int y_res = input_abs_get_res(input, ABS_Y); | 1221 | int y_res = input_abs_get_res(input, ABS_MT_POSITION_Y); |
| 1222 | width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE); | 1222 | width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE); |
| 1223 | height = width * y_res / x_res; | 1223 | height = width * y_res / x_res; |
| 1224 | } | 1224 | } |
| 1225 | 1225 | ||
| @@ -1587,7 +1587,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev, | |||
| 1587 | input_abs_set_res(input_dev, ABS_X, features->x_resolution); | 1587 | input_abs_set_res(input_dev, ABS_X, features->x_resolution); |
| 1588 | input_abs_set_res(input_dev, ABS_Y, features->y_resolution); | 1588 | input_abs_set_res(input_dev, ABS_Y, features->y_resolution); |
| 1589 | } else { | 1589 | } else { |
| 1590 | if (features->touch_max <= 2) { | 1590 | if (features->touch_max == 1) { |
| 1591 | input_set_abs_params(input_dev, ABS_X, 0, | 1591 | input_set_abs_params(input_dev, ABS_X, 0, |
| 1592 | features->x_max, features->x_fuzz, 0); | 1592 | features->x_max, features->x_fuzz, 0); |
| 1593 | input_set_abs_params(input_dev, ABS_Y, 0, | 1593 | input_set_abs_params(input_dev, ABS_Y, 0, |
| @@ -1815,14 +1815,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
| 1815 | case MTTPC: | 1815 | case MTTPC: |
| 1816 | case MTTPC_B: | 1816 | case MTTPC_B: |
| 1817 | case TABLETPC2FG: | 1817 | case TABLETPC2FG: |
| 1818 | if (features->device_type == BTN_TOOL_FINGER) { | 1818 | if (features->device_type == BTN_TOOL_FINGER && features->touch_max > 1) |
| 1819 | unsigned int flags = INPUT_MT_DIRECT; | 1819 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT); |
| 1820 | |||
| 1821 | if (wacom_wac->features.type == TABLETPC2FG) | ||
| 1822 | flags = 0; | ||
| 1823 | |||
| 1824 | input_mt_init_slots(input_dev, features->touch_max, flags); | ||
| 1825 | } | ||
| 1826 | /* fall through */ | 1820 | /* fall through */ |
| 1827 | 1821 | ||
| 1828 | case TABLETPC: | 1822 | case TABLETPC: |
| @@ -1883,10 +1877,6 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
| 1883 | __set_bit(BTN_RIGHT, input_dev->keybit); | 1877 | __set_bit(BTN_RIGHT, input_dev->keybit); |
| 1884 | 1878 | ||
| 1885 | if (features->touch_max) { | 1879 | if (features->touch_max) { |
| 1886 | /* touch interface */ | ||
| 1887 | unsigned int flags = INPUT_MT_POINTER; | ||
| 1888 | |||
| 1889 | __set_bit(INPUT_PROP_POINTER, input_dev->propbit); | ||
| 1890 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { | 1880 | if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) { |
| 1891 | input_set_abs_params(input_dev, | 1881 | input_set_abs_params(input_dev, |
| 1892 | ABS_MT_TOUCH_MAJOR, | 1882 | ABS_MT_TOUCH_MAJOR, |
| @@ -1894,12 +1884,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
| 1894 | input_set_abs_params(input_dev, | 1884 | input_set_abs_params(input_dev, |
| 1895 | ABS_MT_TOUCH_MINOR, | 1885 | ABS_MT_TOUCH_MINOR, |
| 1896 | 0, features->y_max, 0, 0); | 1886 | 0, features->y_max, 0, 0); |
| 1897 | } else { | ||
| 1898 | __set_bit(BTN_TOOL_FINGER, input_dev->keybit); | ||
| 1899 | __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); | ||
| 1900 | flags = 0; | ||
| 1901 | } | 1887 | } |
| 1902 | input_mt_init_slots(input_dev, features->touch_max, flags); | 1888 | input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER); |
| 1903 | } else { | 1889 | } else { |
| 1904 | /* buttons/keys only interface */ | 1890 | /* buttons/keys only interface */ |
| 1905 | __clear_bit(ABS_X, input_dev->absbit); | 1891 | __clear_bit(ABS_X, input_dev->absbit); |
diff --git a/drivers/input/touchscreen/ti_am335x_tsc.c b/drivers/input/touchscreen/ti_am335x_tsc.c index 4e793a17361f..2ce649520fe0 100644 --- a/drivers/input/touchscreen/ti_am335x_tsc.c +++ b/drivers/input/touchscreen/ti_am335x_tsc.c | |||
| @@ -359,9 +359,12 @@ static int titsc_parse_dt(struct platform_device *pdev, | |||
| 359 | */ | 359 | */ |
| 360 | err = of_property_read_u32(node, "ti,coordinate-readouts", | 360 | err = of_property_read_u32(node, "ti,coordinate-readouts", |
| 361 | &ts_dev->coordinate_readouts); | 361 | &ts_dev->coordinate_readouts); |
| 362 | if (err < 0) | 362 | if (err < 0) { |
| 363 | dev_warn(&pdev->dev, "please use 'ti,coordinate-readouts' instead\n"); | ||
| 363 | err = of_property_read_u32(node, "ti,coordiante-readouts", | 364 | err = of_property_read_u32(node, "ti,coordiante-readouts", |
| 364 | &ts_dev->coordinate_readouts); | 365 | &ts_dev->coordinate_readouts); |
| 366 | } | ||
| 367 | |||
| 365 | if (err < 0) | 368 | if (err < 0) |
| 366 | return err; | 369 | return err; |
| 367 | 370 | ||
diff --git a/drivers/iommu/fsl_pamu.c b/drivers/iommu/fsl_pamu.c index b99dd88e31b9..bb446d742a2d 100644 --- a/drivers/iommu/fsl_pamu.c +++ b/drivers/iommu/fsl_pamu.c | |||
| @@ -170,10 +170,10 @@ int pamu_disable_liodn(int liodn) | |||
| 170 | static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size) | 170 | static unsigned int map_addrspace_size_to_wse(phys_addr_t addrspace_size) |
| 171 | { | 171 | { |
| 172 | /* Bug if not a power of 2 */ | 172 | /* Bug if not a power of 2 */ |
| 173 | BUG_ON(!is_power_of_2(addrspace_size)); | 173 | BUG_ON((addrspace_size & (addrspace_size - 1))); |
| 174 | 174 | ||
| 175 | /* window size is 2^(WSE+1) bytes */ | 175 | /* window size is 2^(WSE+1) bytes */ |
| 176 | return __ffs(addrspace_size) - 1; | 176 | return fls64(addrspace_size) - 2; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| 179 | /* Derive the PAACE window count encoding for the subwindow count */ | 179 | /* Derive the PAACE window count encoding for the subwindow count */ |
| @@ -351,7 +351,7 @@ int pamu_config_ppaace(int liodn, phys_addr_t win_addr, phys_addr_t win_size, | |||
| 351 | struct paace *ppaace; | 351 | struct paace *ppaace; |
| 352 | unsigned long fspi; | 352 | unsigned long fspi; |
| 353 | 353 | ||
| 354 | if (!is_power_of_2(win_size) || win_size < PAMU_PAGE_SIZE) { | 354 | if ((win_size & (win_size - 1)) || win_size < PAMU_PAGE_SIZE) { |
| 355 | pr_debug("window size too small or not a power of two %llx\n", win_size); | 355 | pr_debug("window size too small or not a power of two %llx\n", win_size); |
| 356 | return -EINVAL; | 356 | return -EINVAL; |
| 357 | } | 357 | } |
| @@ -464,7 +464,7 @@ int pamu_config_spaace(int liodn, u32 subwin_cnt, u32 subwin, | |||
| 464 | return -ENOENT; | 464 | return -ENOENT; |
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | if (!is_power_of_2(subwin_size) || subwin_size < PAMU_PAGE_SIZE) { | 467 | if ((subwin_size & (subwin_size - 1)) || subwin_size < PAMU_PAGE_SIZE) { |
| 468 | pr_debug("subwindow size out of range, or not a power of 2\n"); | 468 | pr_debug("subwindow size out of range, or not a power of 2\n"); |
| 469 | return -EINVAL; | 469 | return -EINVAL; |
| 470 | } | 470 | } |
diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c index 93072ba44b1d..af47648301a9 100644 --- a/drivers/iommu/fsl_pamu_domain.c +++ b/drivers/iommu/fsl_pamu_domain.c | |||
| @@ -301,7 +301,7 @@ static int check_size(u64 size, dma_addr_t iova) | |||
| 301 | * Size must be a power of two and at least be equal | 301 | * Size must be a power of two and at least be equal |
| 302 | * to PAMU page size. | 302 | * to PAMU page size. |
| 303 | */ | 303 | */ |
| 304 | if (!is_power_of_2(size) || size < PAMU_PAGE_SIZE) { | 304 | if ((size & (size - 1)) || size < PAMU_PAGE_SIZE) { |
| 305 | pr_debug("%s: size too small or not a power of two\n", __func__); | 305 | pr_debug("%s: size too small or not a power of two\n", __func__); |
| 306 | return -EINVAL; | 306 | return -EINVAL; |
| 307 | } | 307 | } |
| @@ -335,11 +335,6 @@ static struct fsl_dma_domain *iommu_alloc_dma_domain(void) | |||
| 335 | return domain; | 335 | return domain; |
| 336 | } | 336 | } |
| 337 | 337 | ||
| 338 | static inline struct device_domain_info *find_domain(struct device *dev) | ||
| 339 | { | ||
| 340 | return dev->archdata.iommu_domain; | ||
| 341 | } | ||
| 342 | |||
| 343 | static void remove_device_ref(struct device_domain_info *info, u32 win_cnt) | 338 | static void remove_device_ref(struct device_domain_info *info, u32 win_cnt) |
| 344 | { | 339 | { |
| 345 | unsigned long flags; | 340 | unsigned long flags; |
| @@ -380,7 +375,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d | |||
| 380 | * Check here if the device is already attached to domain or not. | 375 | * Check here if the device is already attached to domain or not. |
| 381 | * If the device is already attached to a domain detach it. | 376 | * If the device is already attached to a domain detach it. |
| 382 | */ | 377 | */ |
| 383 | old_domain_info = find_domain(dev); | 378 | old_domain_info = dev->archdata.iommu_domain; |
| 384 | if (old_domain_info && old_domain_info->domain != dma_domain) { | 379 | if (old_domain_info && old_domain_info->domain != dma_domain) { |
| 385 | spin_unlock_irqrestore(&device_domain_lock, flags); | 380 | spin_unlock_irqrestore(&device_domain_lock, flags); |
| 386 | detach_device(dev, old_domain_info->domain); | 381 | detach_device(dev, old_domain_info->domain); |
| @@ -399,7 +394,7 @@ static void attach_device(struct fsl_dma_domain *dma_domain, int liodn, struct d | |||
| 399 | * the info for the first LIODN as all | 394 | * the info for the first LIODN as all |
| 400 | * LIODNs share the same domain | 395 | * LIODNs share the same domain |
| 401 | */ | 396 | */ |
| 402 | if (!old_domain_info) | 397 | if (!dev->archdata.iommu_domain) |
| 403 | dev->archdata.iommu_domain = info; | 398 | dev->archdata.iommu_domain = info; |
| 404 | spin_unlock_irqrestore(&device_domain_lock, flags); | 399 | spin_unlock_irqrestore(&device_domain_lock, flags); |
| 405 | 400 | ||
| @@ -1042,12 +1037,15 @@ root_bus: | |||
| 1042 | group = get_shared_pci_device_group(pdev); | 1037 | group = get_shared_pci_device_group(pdev); |
| 1043 | } | 1038 | } |
| 1044 | 1039 | ||
| 1040 | if (!group) | ||
| 1041 | group = ERR_PTR(-ENODEV); | ||
| 1042 | |||
| 1045 | return group; | 1043 | return group; |
| 1046 | } | 1044 | } |
| 1047 | 1045 | ||
| 1048 | static int fsl_pamu_add_device(struct device *dev) | 1046 | static int fsl_pamu_add_device(struct device *dev) |
| 1049 | { | 1047 | { |
| 1050 | struct iommu_group *group = NULL; | 1048 | struct iommu_group *group = ERR_PTR(-ENODEV); |
| 1051 | struct pci_dev *pdev; | 1049 | struct pci_dev *pdev; |
| 1052 | const u32 *prop; | 1050 | const u32 *prop; |
| 1053 | int ret, len; | 1051 | int ret, len; |
| @@ -1070,7 +1068,7 @@ static int fsl_pamu_add_device(struct device *dev) | |||
| 1070 | group = get_device_iommu_group(dev); | 1068 | group = get_device_iommu_group(dev); |
| 1071 | } | 1069 | } |
| 1072 | 1070 | ||
| 1073 | if (!group || IS_ERR(group)) | 1071 | if (IS_ERR(group)) |
| 1074 | return PTR_ERR(group); | 1072 | return PTR_ERR(group); |
| 1075 | 1073 | ||
| 1076 | ret = iommu_group_add_device(group, dev); | 1074 | ret = iommu_group_add_device(group, dev); |
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 7e11c9d6ae8c..7c131cf7cc13 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c | |||
| @@ -42,6 +42,7 @@ | |||
| 42 | #include <linux/irqchip/chained_irq.h> | 42 | #include <linux/irqchip/chained_irq.h> |
| 43 | #include <linux/irqchip/arm-gic.h> | 43 | #include <linux/irqchip/arm-gic.h> |
| 44 | 44 | ||
| 45 | #include <asm/cputype.h> | ||
| 45 | #include <asm/irq.h> | 46 | #include <asm/irq.h> |
| 46 | #include <asm/exception.h> | 47 | #include <asm/exception.h> |
| 47 | #include <asm/smp_plat.h> | 48 | #include <asm/smp_plat.h> |
| @@ -954,7 +955,9 @@ void __init gic_init_bases(unsigned int gic_nr, int irq_start, | |||
| 954 | } | 955 | } |
| 955 | 956 | ||
| 956 | for_each_possible_cpu(cpu) { | 957 | for_each_possible_cpu(cpu) { |
| 957 | unsigned long offset = percpu_offset * cpu_logical_map(cpu); | 958 | u32 mpidr = cpu_logical_map(cpu); |
| 959 | u32 core_id = MPIDR_AFFINITY_LEVEL(mpidr, 0); | ||
| 960 | unsigned long offset = percpu_offset * core_id; | ||
| 958 | *per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset; | 961 | *per_cpu_ptr(gic->dist_base.percpu_base, cpu) = dist_base + offset; |
| 959 | *per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset; | 962 | *per_cpu_ptr(gic->cpu_base.percpu_base, cpu) = cpu_base + offset; |
| 960 | } | 963 | } |
| @@ -1071,8 +1074,10 @@ gic_of_init(struct device_node *node, struct device_node *parent) | |||
| 1071 | gic_cnt++; | 1074 | gic_cnt++; |
| 1072 | return 0; | 1075 | return 0; |
| 1073 | } | 1076 | } |
| 1077 | IRQCHIP_DECLARE(gic_400, "arm,gic-400", gic_of_init); | ||
| 1074 | IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init); | 1078 | IRQCHIP_DECLARE(cortex_a15_gic, "arm,cortex-a15-gic", gic_of_init); |
| 1075 | IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init); | 1079 | IRQCHIP_DECLARE(cortex_a9_gic, "arm,cortex-a9-gic", gic_of_init); |
| 1080 | IRQCHIP_DECLARE(cortex_a7_gic, "arm,cortex-a7-gic", gic_of_init); | ||
| 1076 | IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init); | 1081 | IRQCHIP_DECLARE(msm_8660_qgic, "qcom,msm-8660-qgic", gic_of_init); |
| 1077 | IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init); | 1082 | IRQCHIP_DECLARE(msm_qgic2, "qcom,msm-qgic2", gic_of_init); |
| 1078 | 1083 | ||
diff --git a/drivers/isdn/gigaset/bas-gigaset.c b/drivers/isdn/gigaset/bas-gigaset.c index c44950d3eb7b..b7ae0a0dd5b6 100644 --- a/drivers/isdn/gigaset/bas-gigaset.c +++ b/drivers/isdn/gigaset/bas-gigaset.c | |||
| @@ -2400,6 +2400,7 @@ allocerr: | |||
| 2400 | error: | 2400 | error: |
| 2401 | freeurbs(cs); | 2401 | freeurbs(cs); |
| 2402 | usb_set_intfdata(interface, NULL); | 2402 | usb_set_intfdata(interface, NULL); |
| 2403 | usb_put_dev(udev); | ||
| 2403 | gigaset_freecs(cs); | 2404 | gigaset_freecs(cs); |
| 2404 | return rc; | 2405 | return rc; |
| 2405 | } | 2406 | } |
diff --git a/drivers/isdn/hisax/l3ni1.c b/drivers/isdn/hisax/l3ni1.c index 0df6691d045c..8dc791bfaa6f 100644 --- a/drivers/isdn/hisax/l3ni1.c +++ b/drivers/isdn/hisax/l3ni1.c | |||
| @@ -2059,13 +2059,17 @@ static int l3ni1_cmd_global(struct PStack *st, isdn_ctrl *ic) | |||
| 2059 | memcpy(p, ic->parm.ni1_io.data, ic->parm.ni1_io.datalen); /* copy data */ | 2059 | memcpy(p, ic->parm.ni1_io.data, ic->parm.ni1_io.datalen); /* copy data */ |
| 2060 | l = (p - temp) + ic->parm.ni1_io.datalen; /* total length */ | 2060 | l = (p - temp) + ic->parm.ni1_io.datalen; /* total length */ |
| 2061 | 2061 | ||
| 2062 | if (ic->parm.ni1_io.timeout > 0) | 2062 | if (ic->parm.ni1_io.timeout > 0) { |
| 2063 | if (!(pc = ni1_new_l3_process(st, -1))) | 2063 | pc = ni1_new_l3_process(st, -1); |
| 2064 | { free_invoke_id(st, id); | 2064 | if (!pc) { |
| 2065 | free_invoke_id(st, id); | ||
| 2065 | return (-2); | 2066 | return (-2); |
| 2066 | } | 2067 | } |
| 2067 | pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; /* remember id */ | 2068 | /* remember id */ |
| 2068 | pc->prot.ni1.proc = ic->parm.ni1_io.proc; /* and procedure */ | 2069 | pc->prot.ni1.ll_id = ic->parm.ni1_io.ll_id; |
| 2070 | /* and procedure */ | ||
| 2071 | pc->prot.ni1.proc = ic->parm.ni1_io.proc; | ||
| 2072 | } | ||
| 2069 | 2073 | ||
| 2070 | if (!(skb = l3_alloc_skb(l))) | 2074 | if (!(skb = l3_alloc_skb(l))) |
| 2071 | { free_invoke_id(st, id); | 2075 | { free_invoke_id(st, id); |
diff --git a/drivers/isdn/i4l/isdn_ppp.c b/drivers/isdn/i4l/isdn_ppp.c index 61ac63237446..62f0688d45a5 100644 --- a/drivers/isdn/i4l/isdn_ppp.c +++ b/drivers/isdn/i4l/isdn_ppp.c | |||
| @@ -442,7 +442,7 @@ static int get_filter(void __user *arg, struct sock_filter **p) | |||
| 442 | { | 442 | { |
| 443 | struct sock_fprog uprog; | 443 | struct sock_fprog uprog; |
| 444 | struct sock_filter *code = NULL; | 444 | struct sock_filter *code = NULL; |
| 445 | int len, err; | 445 | int len; |
| 446 | 446 | ||
| 447 | if (copy_from_user(&uprog, arg, sizeof(uprog))) | 447 | if (copy_from_user(&uprog, arg, sizeof(uprog))) |
| 448 | return -EFAULT; | 448 | return -EFAULT; |
| @@ -458,12 +458,6 @@ static int get_filter(void __user *arg, struct sock_filter **p) | |||
| 458 | if (IS_ERR(code)) | 458 | if (IS_ERR(code)) |
| 459 | return PTR_ERR(code); | 459 | return PTR_ERR(code); |
| 460 | 460 | ||
| 461 | err = sk_chk_filter(code, uprog.len); | ||
| 462 | if (err) { | ||
| 463 | kfree(code); | ||
| 464 | return err; | ||
| 465 | } | ||
| 466 | |||
| 467 | *p = code; | 461 | *p = code; |
| 468 | return uprog.len; | 462 | return uprog.len; |
| 469 | } | 463 | } |
| @@ -644,9 +638,15 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg) | |||
| 644 | fprog.len = len; | 638 | fprog.len = len; |
| 645 | fprog.filter = code; | 639 | fprog.filter = code; |
| 646 | 640 | ||
| 647 | if (is->pass_filter) | 641 | if (is->pass_filter) { |
| 648 | sk_unattached_filter_destroy(is->pass_filter); | 642 | sk_unattached_filter_destroy(is->pass_filter); |
| 649 | err = sk_unattached_filter_create(&is->pass_filter, &fprog); | 643 | is->pass_filter = NULL; |
| 644 | } | ||
| 645 | if (fprog.filter != NULL) | ||
| 646 | err = sk_unattached_filter_create(&is->pass_filter, | ||
| 647 | &fprog); | ||
| 648 | else | ||
| 649 | err = 0; | ||
| 650 | kfree(code); | 650 | kfree(code); |
| 651 | 651 | ||
| 652 | return err; | 652 | return err; |
| @@ -663,9 +663,15 @@ isdn_ppp_ioctl(int min, struct file *file, unsigned int cmd, unsigned long arg) | |||
| 663 | fprog.len = len; | 663 | fprog.len = len; |
| 664 | fprog.filter = code; | 664 | fprog.filter = code; |
| 665 | 665 | ||
| 666 | if (is->active_filter) | 666 | if (is->active_filter) { |
| 667 | sk_unattached_filter_destroy(is->active_filter); | 667 | sk_unattached_filter_destroy(is->active_filter); |
| 668 | err = sk_unattached_filter_create(&is->active_filter, &fprog); | 668 | is->active_filter = NULL; |
| 669 | } | ||
| 670 | if (fprog.filter != NULL) | ||
| 671 | err = sk_unattached_filter_create(&is->active_filter, | ||
| 672 | &fprog); | ||
| 673 | else | ||
| 674 | err = 0; | ||
| 669 | kfree(code); | 675 | kfree(code); |
| 670 | 676 | ||
| 671 | return err; | 677 | return err; |
diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index 4e84095833db..d724459860d9 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c | |||
| @@ -1541,7 +1541,7 @@ struct dm_bufio_client *dm_bufio_client_create(struct block_device *bdev, unsign | |||
| 1541 | BUG_ON(block_size < 1 << SECTOR_SHIFT || | 1541 | BUG_ON(block_size < 1 << SECTOR_SHIFT || |
| 1542 | (block_size & (block_size - 1))); | 1542 | (block_size & (block_size - 1))); |
| 1543 | 1543 | ||
| 1544 | c = kmalloc(sizeof(*c), GFP_KERNEL); | 1544 | c = kzalloc(sizeof(*c), GFP_KERNEL); |
| 1545 | if (!c) { | 1545 | if (!c) { |
| 1546 | r = -ENOMEM; | 1546 | r = -ENOMEM; |
| 1547 | goto bad_client; | 1547 | goto bad_client; |
diff --git a/drivers/md/dm-cache-metadata.c b/drivers/md/dm-cache-metadata.c index 4ead4ba60656..d2899e7eb3aa 100644 --- a/drivers/md/dm-cache-metadata.c +++ b/drivers/md/dm-cache-metadata.c | |||
| @@ -425,6 +425,15 @@ static int __open_metadata(struct dm_cache_metadata *cmd) | |||
| 425 | 425 | ||
| 426 | disk_super = dm_block_data(sblock); | 426 | disk_super = dm_block_data(sblock); |
| 427 | 427 | ||
| 428 | /* Verify the data block size hasn't changed */ | ||
| 429 | if (le32_to_cpu(disk_super->data_block_size) != cmd->data_block_size) { | ||
| 430 | DMERR("changing the data block size (from %u to %llu) is not supported", | ||
| 431 | le32_to_cpu(disk_super->data_block_size), | ||
| 432 | (unsigned long long)cmd->data_block_size); | ||
| 433 | r = -EINVAL; | ||
| 434 | goto bad; | ||
| 435 | } | ||
| 436 | |||
| 428 | r = __check_incompat_features(disk_super, cmd); | 437 | r = __check_incompat_features(disk_super, cmd); |
| 429 | if (r < 0) | 438 | if (r < 0) |
| 430 | goto bad; | 439 | goto bad; |
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 5f054c44b485..2c63326638b6 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c | |||
| @@ -231,7 +231,7 @@ struct cache { | |||
| 231 | /* | 231 | /* |
| 232 | * cache_size entries, dirty if set | 232 | * cache_size entries, dirty if set |
| 233 | */ | 233 | */ |
| 234 | dm_cblock_t nr_dirty; | 234 | atomic_t nr_dirty; |
| 235 | unsigned long *dirty_bitset; | 235 | unsigned long *dirty_bitset; |
| 236 | 236 | ||
| 237 | /* | 237 | /* |
| @@ -492,7 +492,7 @@ static bool is_dirty(struct cache *cache, dm_cblock_t b) | |||
| 492 | static void set_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cblock) | 492 | static void set_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cblock) |
| 493 | { | 493 | { |
| 494 | if (!test_and_set_bit(from_cblock(cblock), cache->dirty_bitset)) { | 494 | if (!test_and_set_bit(from_cblock(cblock), cache->dirty_bitset)) { |
| 495 | cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) + 1); | 495 | atomic_inc(&cache->nr_dirty); |
| 496 | policy_set_dirty(cache->policy, oblock); | 496 | policy_set_dirty(cache->policy, oblock); |
| 497 | } | 497 | } |
| 498 | } | 498 | } |
| @@ -501,8 +501,7 @@ static void clear_dirty(struct cache *cache, dm_oblock_t oblock, dm_cblock_t cbl | |||
| 501 | { | 501 | { |
| 502 | if (test_and_clear_bit(from_cblock(cblock), cache->dirty_bitset)) { | 502 | if (test_and_clear_bit(from_cblock(cblock), cache->dirty_bitset)) { |
| 503 | policy_clear_dirty(cache->policy, oblock); | 503 | policy_clear_dirty(cache->policy, oblock); |
| 504 | cache->nr_dirty = to_cblock(from_cblock(cache->nr_dirty) - 1); | 504 | if (atomic_dec_return(&cache->nr_dirty) == 0) |
| 505 | if (!from_cblock(cache->nr_dirty)) | ||
| 506 | dm_table_event(cache->ti->table); | 505 | dm_table_event(cache->ti->table); |
| 507 | } | 506 | } |
| 508 | } | 507 | } |
| @@ -2269,7 +2268,7 @@ static int cache_create(struct cache_args *ca, struct cache **result) | |||
| 2269 | atomic_set(&cache->quiescing_ack, 0); | 2268 | atomic_set(&cache->quiescing_ack, 0); |
| 2270 | 2269 | ||
| 2271 | r = -ENOMEM; | 2270 | r = -ENOMEM; |
| 2272 | cache->nr_dirty = 0; | 2271 | atomic_set(&cache->nr_dirty, 0); |
| 2273 | cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size)); | 2272 | cache->dirty_bitset = alloc_bitset(from_cblock(cache->cache_size)); |
| 2274 | if (!cache->dirty_bitset) { | 2273 | if (!cache->dirty_bitset) { |
| 2275 | *error = "could not allocate dirty bitset"; | 2274 | *error = "could not allocate dirty bitset"; |
| @@ -2808,7 +2807,7 @@ static void cache_status(struct dm_target *ti, status_type_t type, | |||
| 2808 | 2807 | ||
| 2809 | residency = policy_residency(cache->policy); | 2808 | residency = policy_residency(cache->policy); |
| 2810 | 2809 | ||
| 2811 | DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %llu ", | 2810 | DMEMIT("%u %llu/%llu %u %llu/%llu %u %u %u %u %u %u %lu ", |
| 2812 | (unsigned)(DM_CACHE_METADATA_BLOCK_SIZE >> SECTOR_SHIFT), | 2811 | (unsigned)(DM_CACHE_METADATA_BLOCK_SIZE >> SECTOR_SHIFT), |
| 2813 | (unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata), | 2812 | (unsigned long long)(nr_blocks_metadata - nr_free_blocks_metadata), |
| 2814 | (unsigned long long)nr_blocks_metadata, | 2813 | (unsigned long long)nr_blocks_metadata, |
| @@ -2821,7 +2820,7 @@ static void cache_status(struct dm_target *ti, status_type_t type, | |||
| 2821 | (unsigned) atomic_read(&cache->stats.write_miss), | 2820 | (unsigned) atomic_read(&cache->stats.write_miss), |
| 2822 | (unsigned) atomic_read(&cache->stats.demotion), | 2821 | (unsigned) atomic_read(&cache->stats.demotion), |
| 2823 | (unsigned) atomic_read(&cache->stats.promotion), | 2822 | (unsigned) atomic_read(&cache->stats.promotion), |
| 2824 | (unsigned long long) from_cblock(cache->nr_dirty)); | 2823 | (unsigned long) atomic_read(&cache->nr_dirty)); |
| 2825 | 2824 | ||
| 2826 | if (writethrough_mode(&cache->features)) | 2825 | if (writethrough_mode(&cache->features)) |
| 2827 | DMEMIT("1 writethrough "); | 2826 | DMEMIT("1 writethrough "); |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 53b213226c01..4cba2d808afb 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2003 Christophe Saout <christophe@saout.de> | 2 | * Copyright (C) 2003 Jana Saout <jana@saout.de> |
| 3 | * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org> | 3 | * Copyright (C) 2004 Clemens Fruhwirth <clemens@endorphin.org> |
| 4 | * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved. | 4 | * Copyright (C) 2006-2009 Red Hat, Inc. All rights reserved. |
| 5 | * Copyright (C) 2013 Milan Broz <gmazyland@gmail.com> | 5 | * Copyright (C) 2013 Milan Broz <gmazyland@gmail.com> |
| @@ -1996,6 +1996,6 @@ static void __exit dm_crypt_exit(void) | |||
| 1996 | module_init(dm_crypt_init); | 1996 | module_init(dm_crypt_init); |
| 1997 | module_exit(dm_crypt_exit); | 1997 | module_exit(dm_crypt_exit); |
| 1998 | 1998 | ||
| 1999 | MODULE_AUTHOR("Christophe Saout <christophe@saout.de>"); | 1999 | MODULE_AUTHOR("Jana Saout <jana@saout.de>"); |
| 2000 | MODULE_DESCRIPTION(DM_NAME " target for transparent encryption / decryption"); | 2000 | MODULE_DESCRIPTION(DM_NAME " target for transparent encryption / decryption"); |
| 2001 | MODULE_LICENSE("GPL"); | 2001 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 3842ac738f98..db404a0f7e2c 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/device-mapper.h> | 10 | #include <linux/device-mapper.h> |
| 11 | 11 | ||
| 12 | #include <linux/bio.h> | 12 | #include <linux/bio.h> |
| 13 | #include <linux/completion.h> | ||
| 13 | #include <linux/mempool.h> | 14 | #include <linux/mempool.h> |
| 14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 15 | #include <linux/sched.h> | 16 | #include <linux/sched.h> |
| @@ -32,7 +33,7 @@ struct dm_io_client { | |||
| 32 | struct io { | 33 | struct io { |
| 33 | unsigned long error_bits; | 34 | unsigned long error_bits; |
| 34 | atomic_t count; | 35 | atomic_t count; |
| 35 | struct task_struct *sleeper; | 36 | struct completion *wait; |
| 36 | struct dm_io_client *client; | 37 | struct dm_io_client *client; |
| 37 | io_notify_fn callback; | 38 | io_notify_fn callback; |
| 38 | void *context; | 39 | void *context; |
| @@ -121,8 +122,8 @@ static void dec_count(struct io *io, unsigned int region, int error) | |||
| 121 | invalidate_kernel_vmap_range(io->vma_invalidate_address, | 122 | invalidate_kernel_vmap_range(io->vma_invalidate_address, |
| 122 | io->vma_invalidate_size); | 123 | io->vma_invalidate_size); |
| 123 | 124 | ||
| 124 | if (io->sleeper) | 125 | if (io->wait) |
| 125 | wake_up_process(io->sleeper); | 126 | complete(io->wait); |
| 126 | 127 | ||
| 127 | else { | 128 | else { |
| 128 | unsigned long r = io->error_bits; | 129 | unsigned long r = io->error_bits; |
| @@ -387,6 +388,7 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions, | |||
| 387 | */ | 388 | */ |
| 388 | volatile char io_[sizeof(struct io) + __alignof__(struct io) - 1]; | 389 | volatile char io_[sizeof(struct io) + __alignof__(struct io) - 1]; |
| 389 | struct io *io = (struct io *)PTR_ALIGN(&io_, __alignof__(struct io)); | 390 | struct io *io = (struct io *)PTR_ALIGN(&io_, __alignof__(struct io)); |
| 391 | DECLARE_COMPLETION_ONSTACK(wait); | ||
| 390 | 392 | ||
| 391 | if (num_regions > 1 && (rw & RW_MASK) != WRITE) { | 393 | if (num_regions > 1 && (rw & RW_MASK) != WRITE) { |
| 392 | WARN_ON(1); | 394 | WARN_ON(1); |
| @@ -395,7 +397,7 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions, | |||
| 395 | 397 | ||
| 396 | io->error_bits = 0; | 398 | io->error_bits = 0; |
| 397 | atomic_set(&io->count, 1); /* see dispatch_io() */ | 399 | atomic_set(&io->count, 1); /* see dispatch_io() */ |
| 398 | io->sleeper = current; | 400 | io->wait = &wait; |
| 399 | io->client = client; | 401 | io->client = client; |
| 400 | 402 | ||
| 401 | io->vma_invalidate_address = dp->vma_invalidate_address; | 403 | io->vma_invalidate_address = dp->vma_invalidate_address; |
| @@ -403,15 +405,7 @@ static int sync_io(struct dm_io_client *client, unsigned int num_regions, | |||
| 403 | 405 | ||
| 404 | dispatch_io(rw, num_regions, where, dp, io, 1); | 406 | dispatch_io(rw, num_regions, where, dp, io, 1); |
| 405 | 407 | ||
| 406 | while (1) { | 408 | wait_for_completion_io(&wait); |
| 407 | set_current_state(TASK_UNINTERRUPTIBLE); | ||
| 408 | |||
| 409 | if (!atomic_read(&io->count)) | ||
| 410 | break; | ||
| 411 | |||
| 412 | io_schedule(); | ||
| 413 | } | ||
| 414 | set_current_state(TASK_RUNNING); | ||
| 415 | 409 | ||
| 416 | if (error_bits) | 410 | if (error_bits) |
| 417 | *error_bits = io->error_bits; | 411 | *error_bits = io->error_bits; |
| @@ -434,7 +428,7 @@ static int async_io(struct dm_io_client *client, unsigned int num_regions, | |||
| 434 | io = mempool_alloc(client->pool, GFP_NOIO); | 428 | io = mempool_alloc(client->pool, GFP_NOIO); |
| 435 | io->error_bits = 0; | 429 | io->error_bits = 0; |
| 436 | atomic_set(&io->count, 1); /* see dispatch_io() */ | 430 | atomic_set(&io->count, 1); /* see dispatch_io() */ |
| 437 | io->sleeper = NULL; | 431 | io->wait = NULL; |
| 438 | io->client = client; | 432 | io->client = client; |
| 439 | io->callback = fn; | 433 | io->callback = fn; |
| 440 | io->context = context; | 434 | io->context = context; |
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 3f6fd9d33ba3..f4167b013d99 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
| @@ -1611,8 +1611,9 @@ static int multipath_busy(struct dm_target *ti) | |||
| 1611 | 1611 | ||
| 1612 | spin_lock_irqsave(&m->lock, flags); | 1612 | spin_lock_irqsave(&m->lock, flags); |
| 1613 | 1613 | ||
| 1614 | /* pg_init in progress, requeue until done */ | 1614 | /* pg_init in progress or no paths available */ |
| 1615 | if (!pg_ready(m)) { | 1615 | if (m->pg_init_in_progress || |
| 1616 | (!m->nr_valid_paths && m->queue_if_no_path)) { | ||
| 1616 | busy = 1; | 1617 | busy = 1; |
| 1617 | goto out; | 1618 | goto out; |
| 1618 | } | 1619 | } |
diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c index b086a945edcb..e9d33ad59df5 100644 --- a/drivers/md/dm-thin-metadata.c +++ b/drivers/md/dm-thin-metadata.c | |||
| @@ -613,6 +613,15 @@ static int __open_metadata(struct dm_pool_metadata *pmd) | |||
| 613 | 613 | ||
| 614 | disk_super = dm_block_data(sblock); | 614 | disk_super = dm_block_data(sblock); |
| 615 | 615 | ||
| 616 | /* Verify the data block size hasn't changed */ | ||
| 617 | if (le32_to_cpu(disk_super->data_block_size) != pmd->data_block_size) { | ||
| 618 | DMERR("changing the data block size (from %u to %llu) is not supported", | ||
| 619 | le32_to_cpu(disk_super->data_block_size), | ||
| 620 | (unsigned long long)pmd->data_block_size); | ||
| 621 | r = -EINVAL; | ||
| 622 | goto bad_unlock_sblock; | ||
| 623 | } | ||
| 624 | |||
| 616 | r = __check_incompat_features(disk_super, pmd); | 625 | r = __check_incompat_features(disk_super, pmd); |
| 617 | if (r < 0) | 626 | if (r < 0) |
| 618 | goto bad_unlock_sblock; | 627 | goto bad_unlock_sblock; |
diff --git a/drivers/md/dm-zero.c b/drivers/md/dm-zero.c index c99003e0d47a..b9a64bbce304 100644 --- a/drivers/md/dm-zero.c +++ b/drivers/md/dm-zero.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (C) 2003 Christophe Saout <christophe@saout.de> | 2 | * Copyright (C) 2003 Jana Saout <jana@saout.de> |
| 3 | * | 3 | * |
| 4 | * This file is released under the GPL. | 4 | * This file is released under the GPL. |
| 5 | */ | 5 | */ |
| @@ -79,6 +79,6 @@ static void __exit dm_zero_exit(void) | |||
| 79 | module_init(dm_zero_init) | 79 | module_init(dm_zero_init) |
| 80 | module_exit(dm_zero_exit) | 80 | module_exit(dm_zero_exit) |
| 81 | 81 | ||
| 82 | MODULE_AUTHOR("Christophe Saout <christophe@saout.de>"); | 82 | MODULE_AUTHOR("Jana Saout <jana@saout.de>"); |
| 83 | MODULE_DESCRIPTION(DM_NAME " dummy target returning zeros"); | 83 | MODULE_DESCRIPTION(DM_NAME " dummy target returning zeros"); |
| 84 | MODULE_LICENSE("GPL"); | 84 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 437d99045ef2..32b958dbc499 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
| @@ -54,6 +54,8 @@ static void do_deferred_remove(struct work_struct *w); | |||
| 54 | 54 | ||
| 55 | static DECLARE_WORK(deferred_remove_work, do_deferred_remove); | 55 | static DECLARE_WORK(deferred_remove_work, do_deferred_remove); |
| 56 | 56 | ||
| 57 | static struct workqueue_struct *deferred_remove_workqueue; | ||
| 58 | |||
| 57 | /* | 59 | /* |
| 58 | * For bio-based dm. | 60 | * For bio-based dm. |
| 59 | * One of these is allocated per bio. | 61 | * One of these is allocated per bio. |
| @@ -276,16 +278,24 @@ static int __init local_init(void) | |||
| 276 | if (r) | 278 | if (r) |
| 277 | goto out_free_rq_tio_cache; | 279 | goto out_free_rq_tio_cache; |
| 278 | 280 | ||
| 281 | deferred_remove_workqueue = alloc_workqueue("kdmremove", WQ_UNBOUND, 1); | ||
| 282 | if (!deferred_remove_workqueue) { | ||
| 283 | r = -ENOMEM; | ||
| 284 | goto out_uevent_exit; | ||
| 285 | } | ||
| 286 | |||
| 279 | _major = major; | 287 | _major = major; |
| 280 | r = register_blkdev(_major, _name); | 288 | r = register_blkdev(_major, _name); |
| 281 | if (r < 0) | 289 | if (r < 0) |
| 282 | goto out_uevent_exit; | 290 | goto out_free_workqueue; |
| 283 | 291 | ||
| 284 | if (!_major) | 292 | if (!_major) |
| 285 | _major = r; | 293 | _major = r; |
| 286 | 294 | ||
| 287 | return 0; | 295 | return 0; |
| 288 | 296 | ||
| 297 | out_free_workqueue: | ||
| 298 | destroy_workqueue(deferred_remove_workqueue); | ||
| 289 | out_uevent_exit: | 299 | out_uevent_exit: |
| 290 | dm_uevent_exit(); | 300 | dm_uevent_exit(); |
| 291 | out_free_rq_tio_cache: | 301 | out_free_rq_tio_cache: |
| @@ -299,6 +309,7 @@ out_free_io_cache: | |||
| 299 | static void local_exit(void) | 309 | static void local_exit(void) |
| 300 | { | 310 | { |
| 301 | flush_scheduled_work(); | 311 | flush_scheduled_work(); |
| 312 | destroy_workqueue(deferred_remove_workqueue); | ||
| 302 | 313 | ||
| 303 | kmem_cache_destroy(_rq_tio_cache); | 314 | kmem_cache_destroy(_rq_tio_cache); |
| 304 | kmem_cache_destroy(_io_cache); | 315 | kmem_cache_destroy(_io_cache); |
| @@ -407,7 +418,7 @@ static void dm_blk_close(struct gendisk *disk, fmode_t mode) | |||
| 407 | 418 | ||
| 408 | if (atomic_dec_and_test(&md->open_count) && | 419 | if (atomic_dec_and_test(&md->open_count) && |
| 409 | (test_bit(DMF_DEFERRED_REMOVE, &md->flags))) | 420 | (test_bit(DMF_DEFERRED_REMOVE, &md->flags))) |
| 410 | schedule_work(&deferred_remove_work); | 421 | queue_work(deferred_remove_workqueue, &deferred_remove_work); |
| 411 | 422 | ||
| 412 | dm_put(md); | 423 | dm_put(md); |
| 413 | 424 | ||
diff --git a/drivers/media/dvb-frontends/si2168.c b/drivers/media/dvb-frontends/si2168.c index 8637d2ed7623..2e3cdcfa0a67 100644 --- a/drivers/media/dvb-frontends/si2168.c +++ b/drivers/media/dvb-frontends/si2168.c | |||
| @@ -60,7 +60,7 @@ static int si2168_cmd_execute(struct si2168 *s, struct si2168_cmd *cmd) | |||
| 60 | jiffies_to_msecs(jiffies) - | 60 | jiffies_to_msecs(jiffies) - |
| 61 | (jiffies_to_msecs(timeout) - TIMEOUT)); | 61 | (jiffies_to_msecs(timeout) - TIMEOUT)); |
| 62 | 62 | ||
| 63 | if (!(cmd->args[0] >> 7) & 0x01) { | 63 | if (!((cmd->args[0] >> 7) & 0x01)) { |
| 64 | ret = -ETIMEDOUT; | 64 | ret = -ETIMEDOUT; |
| 65 | goto err_mutex_unlock; | 65 | goto err_mutex_unlock; |
| 66 | } | 66 | } |
| @@ -485,20 +485,6 @@ static int si2168_init(struct dvb_frontend *fe) | |||
| 485 | if (ret) | 485 | if (ret) |
| 486 | goto err; | 486 | goto err; |
| 487 | 487 | ||
| 488 | cmd.args[0] = 0x05; | ||
| 489 | cmd.args[1] = 0x00; | ||
| 490 | cmd.args[2] = 0xaa; | ||
| 491 | cmd.args[3] = 0x4d; | ||
| 492 | cmd.args[4] = 0x56; | ||
| 493 | cmd.args[5] = 0x40; | ||
| 494 | cmd.args[6] = 0x00; | ||
| 495 | cmd.args[7] = 0x00; | ||
| 496 | cmd.wlen = 8; | ||
| 497 | cmd.rlen = 1; | ||
| 498 | ret = si2168_cmd_execute(s, &cmd); | ||
| 499 | if (ret) | ||
| 500 | goto err; | ||
| 501 | |||
| 502 | /* cold state - try to download firmware */ | 488 | /* cold state - try to download firmware */ |
| 503 | dev_info(&s->client->dev, "%s: found a '%s' in cold state\n", | 489 | dev_info(&s->client->dev, "%s: found a '%s' in cold state\n", |
| 504 | KBUILD_MODNAME, si2168_ops.info.name); | 490 | KBUILD_MODNAME, si2168_ops.info.name); |
diff --git a/drivers/media/dvb-frontends/si2168_priv.h b/drivers/media/dvb-frontends/si2168_priv.h index 2a343e896f40..53f7f06ae343 100644 --- a/drivers/media/dvb-frontends/si2168_priv.h +++ b/drivers/media/dvb-frontends/si2168_priv.h | |||
| @@ -22,7 +22,7 @@ | |||
| 22 | #include <linux/firmware.h> | 22 | #include <linux/firmware.h> |
| 23 | #include <linux/i2c-mux.h> | 23 | #include <linux/i2c-mux.h> |
| 24 | 24 | ||
| 25 | #define SI2168_FIRMWARE "dvb-demod-si2168-01.fw" | 25 | #define SI2168_FIRMWARE "dvb-demod-si2168-02.fw" |
| 26 | 26 | ||
| 27 | /* state struct */ | 27 | /* state struct */ |
| 28 | struct si2168 { | 28 | struct si2168 { |
diff --git a/drivers/media/dvb-frontends/tda10071.c b/drivers/media/dvb-frontends/tda10071.c index 522fe00f5eee..9619be5d4827 100644 --- a/drivers/media/dvb-frontends/tda10071.c +++ b/drivers/media/dvb-frontends/tda10071.c | |||
| @@ -668,6 +668,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
| 668 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; | 668 | struct dtv_frontend_properties *c = &fe->dtv_property_cache; |
| 669 | int ret, i; | 669 | int ret, i; |
| 670 | u8 mode, rolloff, pilot, inversion, div; | 670 | u8 mode, rolloff, pilot, inversion, div; |
| 671 | fe_modulation_t modulation; | ||
| 671 | 672 | ||
| 672 | dev_dbg(&priv->i2c->dev, | 673 | dev_dbg(&priv->i2c->dev, |
| 673 | "%s: delivery_system=%d modulation=%d frequency=%d symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n", | 674 | "%s: delivery_system=%d modulation=%d frequency=%d symbol_rate=%d inversion=%d pilot=%d rolloff=%d\n", |
| @@ -702,10 +703,13 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
| 702 | 703 | ||
| 703 | switch (c->delivery_system) { | 704 | switch (c->delivery_system) { |
| 704 | case SYS_DVBS: | 705 | case SYS_DVBS: |
| 706 | modulation = QPSK; | ||
| 705 | rolloff = 0; | 707 | rolloff = 0; |
| 706 | pilot = 2; | 708 | pilot = 2; |
| 707 | break; | 709 | break; |
| 708 | case SYS_DVBS2: | 710 | case SYS_DVBS2: |
| 711 | modulation = c->modulation; | ||
| 712 | |||
| 709 | switch (c->rolloff) { | 713 | switch (c->rolloff) { |
| 710 | case ROLLOFF_20: | 714 | case ROLLOFF_20: |
| 711 | rolloff = 2; | 715 | rolloff = 2; |
| @@ -750,7 +754,7 @@ static int tda10071_set_frontend(struct dvb_frontend *fe) | |||
| 750 | 754 | ||
| 751 | for (i = 0, mode = 0xff; i < ARRAY_SIZE(TDA10071_MODCOD); i++) { | 755 | for (i = 0, mode = 0xff; i < ARRAY_SIZE(TDA10071_MODCOD); i++) { |
| 752 | if (c->delivery_system == TDA10071_MODCOD[i].delivery_system && | 756 | if (c->delivery_system == TDA10071_MODCOD[i].delivery_system && |
| 753 | c->modulation == TDA10071_MODCOD[i].modulation && | 757 | modulation == TDA10071_MODCOD[i].modulation && |
| 754 | c->fec_inner == TDA10071_MODCOD[i].fec) { | 758 | c->fec_inner == TDA10071_MODCOD[i].fec) { |
| 755 | mode = TDA10071_MODCOD[i].val; | 759 | mode = TDA10071_MODCOD[i].val; |
| 756 | dev_dbg(&priv->i2c->dev, "%s: mode found=%02x\n", | 760 | dev_dbg(&priv->i2c->dev, "%s: mode found=%02x\n", |
| @@ -834,10 +838,10 @@ static int tda10071_get_frontend(struct dvb_frontend *fe) | |||
| 834 | 838 | ||
| 835 | switch ((buf[1] >> 0) & 0x01) { | 839 | switch ((buf[1] >> 0) & 0x01) { |
| 836 | case 0: | 840 | case 0: |
| 837 | c->inversion = INVERSION_OFF; | 841 | c->inversion = INVERSION_ON; |
| 838 | break; | 842 | break; |
| 839 | case 1: | 843 | case 1: |
| 840 | c->inversion = INVERSION_ON; | 844 | c->inversion = INVERSION_OFF; |
| 841 | break; | 845 | break; |
| 842 | } | 846 | } |
| 843 | 847 | ||
| @@ -856,7 +860,7 @@ static int tda10071_get_frontend(struct dvb_frontend *fe) | |||
| 856 | if (ret) | 860 | if (ret) |
| 857 | goto error; | 861 | goto error; |
| 858 | 862 | ||
| 859 | c->symbol_rate = (buf[0] << 16) | (buf[1] << 8) | (buf[2] << 0); | 863 | c->symbol_rate = ((buf[0] << 16) | (buf[1] << 8) | (buf[2] << 0)) * 1000; |
| 860 | 864 | ||
| 861 | return ret; | 865 | return ret; |
| 862 | error: | 866 | error: |
diff --git a/drivers/media/dvb-frontends/tda10071_priv.h b/drivers/media/dvb-frontends/tda10071_priv.h index 4baf14bfb65a..420486192736 100644 --- a/drivers/media/dvb-frontends/tda10071_priv.h +++ b/drivers/media/dvb-frontends/tda10071_priv.h | |||
| @@ -55,6 +55,7 @@ static struct tda10071_modcod { | |||
| 55 | { SYS_DVBS2, QPSK, FEC_8_9, 0x0a }, | 55 | { SYS_DVBS2, QPSK, FEC_8_9, 0x0a }, |
| 56 | { SYS_DVBS2, QPSK, FEC_9_10, 0x0b }, | 56 | { SYS_DVBS2, QPSK, FEC_9_10, 0x0b }, |
| 57 | /* 8PSK */ | 57 | /* 8PSK */ |
| 58 | { SYS_DVBS2, PSK_8, FEC_AUTO, 0x00 }, | ||
| 58 | { SYS_DVBS2, PSK_8, FEC_3_5, 0x0c }, | 59 | { SYS_DVBS2, PSK_8, FEC_3_5, 0x0c }, |
| 59 | { SYS_DVBS2, PSK_8, FEC_2_3, 0x0d }, | 60 | { SYS_DVBS2, PSK_8, FEC_2_3, 0x0d }, |
| 60 | { SYS_DVBS2, PSK_8, FEC_3_4, 0x0e }, | 61 | { SYS_DVBS2, PSK_8, FEC_3_4, 0x0e }, |
diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c index e65c760e4e8b..0006d6bf8c18 100644 --- a/drivers/media/pci/saa7134/saa7134-empress.c +++ b/drivers/media/pci/saa7134/saa7134-empress.c | |||
| @@ -179,7 +179,7 @@ static const struct v4l2_file_operations ts_fops = | |||
| 179 | .read = vb2_fop_read, | 179 | .read = vb2_fop_read, |
| 180 | .poll = vb2_fop_poll, | 180 | .poll = vb2_fop_poll, |
| 181 | .mmap = vb2_fop_mmap, | 181 | .mmap = vb2_fop_mmap, |
| 182 | .ioctl = video_ioctl2, | 182 | .unlocked_ioctl = video_ioctl2, |
| 183 | }; | 183 | }; |
| 184 | 184 | ||
| 185 | static const struct v4l2_ioctl_ops ts_ioctl_ops = { | 185 | static const struct v4l2_ioctl_ops ts_ioctl_ops = { |
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index a7ed16497903..1e4ec697fb10 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c | |||
| @@ -269,6 +269,7 @@ err: | |||
| 269 | list_del(&buf->list); | 269 | list_del(&buf->list); |
| 270 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED); | 270 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED); |
| 271 | } | 271 | } |
| 272 | spin_unlock_irqrestore(&common->irqlock, flags); | ||
| 272 | 273 | ||
| 273 | return ret; | 274 | return ret; |
| 274 | } | 275 | } |
diff --git a/drivers/media/platform/davinci/vpif_display.c b/drivers/media/platform/davinci/vpif_display.c index 5bb085b19bcb..b431b58f39e3 100644 --- a/drivers/media/platform/davinci/vpif_display.c +++ b/drivers/media/platform/davinci/vpif_display.c | |||
| @@ -233,6 +233,7 @@ err: | |||
| 233 | list_del(&buf->list); | 233 | list_del(&buf->list); |
| 234 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED); | 234 | vb2_buffer_done(&buf->vb, VB2_BUF_STATE_QUEUED); |
| 235 | } | 235 | } |
| 236 | spin_unlock_irqrestore(&common->irqlock, flags); | ||
| 236 | 237 | ||
| 237 | return ret; | 238 | return ret; |
| 238 | } | 239 | } |
diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c index 271a752cee54..fa4cc7b880aa 100644 --- a/drivers/media/tuners/si2157.c +++ b/drivers/media/tuners/si2157.c | |||
| @@ -57,7 +57,7 @@ static int si2157_cmd_execute(struct si2157 *s, struct si2157_cmd *cmd) | |||
| 57 | jiffies_to_msecs(jiffies) - | 57 | jiffies_to_msecs(jiffies) - |
| 58 | (jiffies_to_msecs(timeout) - TIMEOUT)); | 58 | (jiffies_to_msecs(timeout) - TIMEOUT)); |
| 59 | 59 | ||
| 60 | if (!(buf[0] >> 7) & 0x01) { | 60 | if (!((buf[0] >> 7) & 0x01)) { |
| 61 | ret = -ETIMEDOUT; | 61 | ret = -ETIMEDOUT; |
| 62 | goto err_mutex_unlock; | 62 | goto err_mutex_unlock; |
| 63 | } else { | 63 | } else { |
diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c index 021e4d35e4d7..7b9b75f60774 100644 --- a/drivers/media/usb/dvb-usb-v2/af9035.c +++ b/drivers/media/usb/dvb-usb-v2/af9035.c | |||
| @@ -704,15 +704,41 @@ static int af9035_read_config(struct dvb_usb_device *d) | |||
| 704 | if (ret < 0) | 704 | if (ret < 0) |
| 705 | goto err; | 705 | goto err; |
| 706 | 706 | ||
| 707 | if (tmp == 0x00) | 707 | dev_dbg(&d->udev->dev, "%s: [%d]tuner=%02x\n", |
| 708 | dev_dbg(&d->udev->dev, | 708 | __func__, i, tmp); |
| 709 | "%s: [%d]tuner not set, using default\n", | 709 | |
| 710 | __func__, i); | 710 | /* tuner sanity check */ |
| 711 | else | 711 | if (state->chip_type == 0x9135) { |
| 712 | if (state->chip_version == 0x02) { | ||
| 713 | /* IT9135 BX (v2) */ | ||
| 714 | switch (tmp) { | ||
| 715 | case AF9033_TUNER_IT9135_60: | ||
| 716 | case AF9033_TUNER_IT9135_61: | ||
| 717 | case AF9033_TUNER_IT9135_62: | ||
| 718 | state->af9033_config[i].tuner = tmp; | ||
| 719 | break; | ||
| 720 | } | ||
| 721 | } else { | ||
| 722 | /* IT9135 AX (v1) */ | ||
| 723 | switch (tmp) { | ||
| 724 | case AF9033_TUNER_IT9135_38: | ||
| 725 | case AF9033_TUNER_IT9135_51: | ||
| 726 | case AF9033_TUNER_IT9135_52: | ||
| 727 | state->af9033_config[i].tuner = tmp; | ||
| 728 | break; | ||
| 729 | } | ||
| 730 | } | ||
| 731 | } else { | ||
| 732 | /* AF9035 */ | ||
| 712 | state->af9033_config[i].tuner = tmp; | 733 | state->af9033_config[i].tuner = tmp; |
| 734 | } | ||
| 713 | 735 | ||
| 714 | dev_dbg(&d->udev->dev, "%s: [%d]tuner=%02x\n", | 736 | if (state->af9033_config[i].tuner != tmp) { |
| 715 | __func__, i, state->af9033_config[i].tuner); | 737 | dev_info(&d->udev->dev, |
| 738 | "%s: [%d] overriding tuner from %02x to %02x\n", | ||
| 739 | KBUILD_MODNAME, i, tmp, | ||
| 740 | state->af9033_config[i].tuner); | ||
| 741 | } | ||
| 716 | 742 | ||
| 717 | switch (state->af9033_config[i].tuner) { | 743 | switch (state->af9033_config[i].tuner) { |
| 718 | case AF9033_TUNER_TUA9001: | 744 | case AF9033_TUNER_TUA9001: |
diff --git a/drivers/media/usb/gspca/pac7302.c b/drivers/media/usb/gspca/pac7302.c index 2fd1c5e31a0f..339adce7c7a5 100644 --- a/drivers/media/usb/gspca/pac7302.c +++ b/drivers/media/usb/gspca/pac7302.c | |||
| @@ -928,6 +928,7 @@ static const struct usb_device_id device_table[] = { | |||
| 928 | {USB_DEVICE(0x093a, 0x2620)}, | 928 | {USB_DEVICE(0x093a, 0x2620)}, |
| 929 | {USB_DEVICE(0x093a, 0x2621)}, | 929 | {USB_DEVICE(0x093a, 0x2621)}, |
| 930 | {USB_DEVICE(0x093a, 0x2622), .driver_info = FL_VFLIP}, | 930 | {USB_DEVICE(0x093a, 0x2622), .driver_info = FL_VFLIP}, |
| 931 | {USB_DEVICE(0x093a, 0x2623), .driver_info = FL_VFLIP}, | ||
| 931 | {USB_DEVICE(0x093a, 0x2624), .driver_info = FL_VFLIP}, | 932 | {USB_DEVICE(0x093a, 0x2624), .driver_info = FL_VFLIP}, |
| 932 | {USB_DEVICE(0x093a, 0x2625)}, | 933 | {USB_DEVICE(0x093a, 0x2625)}, |
| 933 | {USB_DEVICE(0x093a, 0x2626)}, | 934 | {USB_DEVICE(0x093a, 0x2626)}, |
diff --git a/drivers/media/usb/hdpvr/hdpvr-video.c b/drivers/media/usb/hdpvr/hdpvr-video.c index 0500c4175d5f..6bce01a674f9 100644 --- a/drivers/media/usb/hdpvr/hdpvr-video.c +++ b/drivers/media/usb/hdpvr/hdpvr-video.c | |||
| @@ -82,7 +82,7 @@ static void hdpvr_read_bulk_callback(struct urb *urb) | |||
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | /*=========================================================================*/ | 84 | /*=========================================================================*/ |
| 85 | /* bufffer bits */ | 85 | /* buffer bits */ |
| 86 | 86 | ||
| 87 | /* function expects dev->io_mutex to be hold by caller */ | 87 | /* function expects dev->io_mutex to be hold by caller */ |
| 88 | int hdpvr_cancel_queue(struct hdpvr_device *dev) | 88 | int hdpvr_cancel_queue(struct hdpvr_device *dev) |
| @@ -926,7 +926,7 @@ static int hdpvr_s_ctrl(struct v4l2_ctrl *ctrl) | |||
| 926 | case V4L2_CID_MPEG_AUDIO_ENCODING: | 926 | case V4L2_CID_MPEG_AUDIO_ENCODING: |
| 927 | if (dev->flags & HDPVR_FLAG_AC3_CAP) { | 927 | if (dev->flags & HDPVR_FLAG_AC3_CAP) { |
| 928 | opt->audio_codec = ctrl->val; | 928 | opt->audio_codec = ctrl->val; |
| 929 | return hdpvr_set_audio(dev, opt->audio_input, | 929 | return hdpvr_set_audio(dev, opt->audio_input + 1, |
| 930 | opt->audio_codec); | 930 | opt->audio_codec); |
| 931 | } | 931 | } |
| 932 | return 0; | 932 | return 0; |
| @@ -1198,7 +1198,7 @@ int hdpvr_register_videodev(struct hdpvr_device *dev, struct device *parent, | |||
| 1198 | v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops, | 1198 | v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops, |
| 1199 | V4L2_CID_MPEG_AUDIO_ENCODING, | 1199 | V4L2_CID_MPEG_AUDIO_ENCODING, |
| 1200 | ac3 ? V4L2_MPEG_AUDIO_ENCODING_AC3 : V4L2_MPEG_AUDIO_ENCODING_AAC, | 1200 | ac3 ? V4L2_MPEG_AUDIO_ENCODING_AC3 : V4L2_MPEG_AUDIO_ENCODING_AAC, |
| 1201 | 0x7, V4L2_MPEG_AUDIO_ENCODING_AAC); | 1201 | 0x7, ac3 ? dev->options.audio_codec : V4L2_MPEG_AUDIO_ENCODING_AAC); |
| 1202 | v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops, | 1202 | v4l2_ctrl_new_std_menu(hdl, &hdpvr_ctrl_ops, |
| 1203 | V4L2_CID_MPEG_VIDEO_ENCODING, | 1203 | V4L2_CID_MPEG_VIDEO_ENCODING, |
| 1204 | V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC, 0x3, | 1204 | V4L2_MPEG_VIDEO_ENCODING_MPEG_4_AVC, 0x3, |
diff --git a/drivers/media/v4l2-core/v4l2-dv-timings.c b/drivers/media/v4l2-core/v4l2-dv-timings.c index 4ae54caadd03..ce1c9f5d9dee 100644 --- a/drivers/media/v4l2-core/v4l2-dv-timings.c +++ b/drivers/media/v4l2-core/v4l2-dv-timings.c | |||
| @@ -610,10 +610,10 @@ struct v4l2_fract v4l2_calc_aspect_ratio(u8 hor_landscape, u8 vert_portrait) | |||
| 610 | aspect.denominator = 9; | 610 | aspect.denominator = 9; |
| 611 | } else if (ratio == 34) { | 611 | } else if (ratio == 34) { |
| 612 | aspect.numerator = 4; | 612 | aspect.numerator = 4; |
| 613 | aspect.numerator = 3; | 613 | aspect.denominator = 3; |
| 614 | } else if (ratio == 68) { | 614 | } else if (ratio == 68) { |
| 615 | aspect.numerator = 15; | 615 | aspect.numerator = 15; |
| 616 | aspect.numerator = 9; | 616 | aspect.denominator = 9; |
| 617 | } else { | 617 | } else { |
| 618 | aspect.numerator = hor_landscape + 99; | 618 | aspect.numerator = hor_landscape + 99; |
| 619 | aspect.denominator = 100; | 619 | aspect.denominator = 100; |
diff --git a/drivers/misc/atmel-ssc.c b/drivers/misc/atmel-ssc.c index 22de13727641..60843a275abd 100644 --- a/drivers/misc/atmel-ssc.c +++ b/drivers/misc/atmel-ssc.c | |||
| @@ -83,10 +83,17 @@ EXPORT_SYMBOL(ssc_free); | |||
| 83 | 83 | ||
| 84 | static struct atmel_ssc_platform_data at91rm9200_config = { | 84 | static struct atmel_ssc_platform_data at91rm9200_config = { |
| 85 | .use_dma = 0, | 85 | .use_dma = 0, |
| 86 | .has_fslen_ext = 0, | ||
| 87 | }; | ||
| 88 | |||
| 89 | static struct atmel_ssc_platform_data at91sam9rl_config = { | ||
| 90 | .use_dma = 0, | ||
| 91 | .has_fslen_ext = 1, | ||
| 86 | }; | 92 | }; |
| 87 | 93 | ||
| 88 | static struct atmel_ssc_platform_data at91sam9g45_config = { | 94 | static struct atmel_ssc_platform_data at91sam9g45_config = { |
| 89 | .use_dma = 1, | 95 | .use_dma = 1, |
| 96 | .has_fslen_ext = 1, | ||
| 90 | }; | 97 | }; |
| 91 | 98 | ||
| 92 | static const struct platform_device_id atmel_ssc_devtypes[] = { | 99 | static const struct platform_device_id atmel_ssc_devtypes[] = { |
| @@ -94,6 +101,9 @@ static const struct platform_device_id atmel_ssc_devtypes[] = { | |||
| 94 | .name = "at91rm9200_ssc", | 101 | .name = "at91rm9200_ssc", |
| 95 | .driver_data = (unsigned long) &at91rm9200_config, | 102 | .driver_data = (unsigned long) &at91rm9200_config, |
| 96 | }, { | 103 | }, { |
| 104 | .name = "at91sam9rl_ssc", | ||
| 105 | .driver_data = (unsigned long) &at91sam9rl_config, | ||
| 106 | }, { | ||
| 97 | .name = "at91sam9g45_ssc", | 107 | .name = "at91sam9g45_ssc", |
| 98 | .driver_data = (unsigned long) &at91sam9g45_config, | 108 | .driver_data = (unsigned long) &at91sam9g45_config, |
| 99 | }, { | 109 | }, { |
| @@ -107,6 +117,9 @@ static const struct of_device_id atmel_ssc_dt_ids[] = { | |||
| 107 | .compatible = "atmel,at91rm9200-ssc", | 117 | .compatible = "atmel,at91rm9200-ssc", |
| 108 | .data = &at91rm9200_config, | 118 | .data = &at91rm9200_config, |
| 109 | }, { | 119 | }, { |
| 120 | .compatible = "atmel,at91sam9rl-ssc", | ||
| 121 | .data = &at91sam9rl_config, | ||
| 122 | }, { | ||
| 110 | .compatible = "atmel,at91sam9g45-ssc", | 123 | .compatible = "atmel,at91sam9g45-ssc", |
| 111 | .data = &at91sam9g45_config, | 124 | .data = &at91sam9g45_config, |
| 112 | }, { | 125 | }, { |
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index e4ec355704a6..a7543ba3e190 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
| @@ -52,6 +52,11 @@ | |||
| 52 | /* Atmel chips */ | 52 | /* Atmel chips */ |
| 53 | #define AT49BV640D 0x02de | 53 | #define AT49BV640D 0x02de |
| 54 | #define AT49BV640DT 0x02db | 54 | #define AT49BV640DT 0x02db |
| 55 | /* Sharp chips */ | ||
| 56 | #define LH28F640BFHE_PTTL90 0x00b0 | ||
| 57 | #define LH28F640BFHE_PBTL90 0x00b1 | ||
| 58 | #define LH28F640BFHE_PTTL70A 0x00b2 | ||
| 59 | #define LH28F640BFHE_PBTL70A 0x00b3 | ||
| 55 | 60 | ||
| 56 | static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); | 61 | static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *); |
| 57 | static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); | 62 | static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *); |
| @@ -258,6 +263,36 @@ static void fixup_st_m28w320cb(struct mtd_info *mtd) | |||
| 258 | (cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e; | 263 | (cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e; |
| 259 | }; | 264 | }; |
| 260 | 265 | ||
| 266 | static int is_LH28F640BF(struct cfi_private *cfi) | ||
| 267 | { | ||
| 268 | /* Sharp LH28F640BF Family */ | ||
| 269 | if (cfi->mfr == CFI_MFR_SHARP && ( | ||
| 270 | cfi->id == LH28F640BFHE_PTTL90 || cfi->id == LH28F640BFHE_PBTL90 || | ||
| 271 | cfi->id == LH28F640BFHE_PTTL70A || cfi->id == LH28F640BFHE_PBTL70A)) | ||
| 272 | return 1; | ||
| 273 | return 0; | ||
| 274 | } | ||
| 275 | |||
| 276 | static void fixup_LH28F640BF(struct mtd_info *mtd) | ||
| 277 | { | ||
| 278 | struct map_info *map = mtd->priv; | ||
| 279 | struct cfi_private *cfi = map->fldrv_priv; | ||
| 280 | struct cfi_pri_intelext *extp = cfi->cmdset_priv; | ||
| 281 | |||
| 282 | /* Reset the Partition Configuration Register on LH28F640BF | ||
| 283 | * to a single partition (PCR = 0x000): PCR is embedded into A0-A15. */ | ||
| 284 | if (is_LH28F640BF(cfi)) { | ||
| 285 | printk(KERN_INFO "Reset Partition Config. Register: 1 Partition of 4 planes\n"); | ||
| 286 | map_write(map, CMD(0x60), 0); | ||
| 287 | map_write(map, CMD(0x04), 0); | ||
| 288 | |||
| 289 | /* We have set one single partition thus | ||
| 290 | * Simultaneous Operations are not allowed */ | ||
| 291 | printk(KERN_INFO "cfi_cmdset_0001: Simultaneous Operations disabled\n"); | ||
| 292 | extp->FeatureSupport &= ~512; | ||
| 293 | } | ||
| 294 | } | ||
| 295 | |||
| 261 | static void fixup_use_point(struct mtd_info *mtd) | 296 | static void fixup_use_point(struct mtd_info *mtd) |
| 262 | { | 297 | { |
| 263 | struct map_info *map = mtd->priv; | 298 | struct map_info *map = mtd->priv; |
| @@ -309,6 +344,8 @@ static struct cfi_fixup cfi_fixup_table[] = { | |||
| 309 | { CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct }, | 344 | { CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct }, |
| 310 | { CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb }, | 345 | { CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb }, |
| 311 | { CFI_MFR_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock }, | 346 | { CFI_MFR_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock }, |
| 347 | { CFI_MFR_SHARP, CFI_ID_ANY, fixup_unlock_powerup_lock }, | ||
| 348 | { CFI_MFR_SHARP, CFI_ID_ANY, fixup_LH28F640BF }, | ||
| 312 | { 0, 0, NULL } | 349 | { 0, 0, NULL } |
| 313 | }; | 350 | }; |
| 314 | 351 | ||
| @@ -1649,6 +1686,12 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip, | |||
| 1649 | initial_adr = adr; | 1686 | initial_adr = adr; |
| 1650 | cmd_adr = adr & ~(wbufsize-1); | 1687 | cmd_adr = adr & ~(wbufsize-1); |
| 1651 | 1688 | ||
| 1689 | /* Sharp LH28F640BF chips need the first address for the | ||
| 1690 | * Page Buffer Program command. See Table 5 of | ||
| 1691 | * LH28F320BF, LH28F640BF, LH28F128BF Series (Appendix FUM00701) */ | ||
| 1692 | if (is_LH28F640BF(cfi)) | ||
| 1693 | cmd_adr = adr; | ||
| 1694 | |||
| 1652 | /* Let's determine this according to the interleave only once */ | 1695 | /* Let's determine this according to the interleave only once */ |
| 1653 | write_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9); | 1696 | write_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9); |
| 1654 | 1697 | ||
diff --git a/drivers/mtd/devices/elm.c b/drivers/mtd/devices/elm.c index 7df86948e6d4..b4f61c7fc161 100644 --- a/drivers/mtd/devices/elm.c +++ b/drivers/mtd/devices/elm.c | |||
| @@ -475,6 +475,7 @@ static int elm_context_save(struct elm_info *info) | |||
| 475 | ELM_SYNDROME_FRAGMENT_1 + offset); | 475 | ELM_SYNDROME_FRAGMENT_1 + offset); |
| 476 | regs->elm_syndrome_fragment_0[i] = elm_read_reg(info, | 476 | regs->elm_syndrome_fragment_0[i] = elm_read_reg(info, |
| 477 | ELM_SYNDROME_FRAGMENT_0 + offset); | 477 | ELM_SYNDROME_FRAGMENT_0 + offset); |
| 478 | break; | ||
| 478 | default: | 479 | default: |
| 479 | return -EINVAL; | 480 | return -EINVAL; |
| 480 | } | 481 | } |
| @@ -520,6 +521,7 @@ static int elm_context_restore(struct elm_info *info) | |||
| 520 | regs->elm_syndrome_fragment_1[i]); | 521 | regs->elm_syndrome_fragment_1[i]); |
| 521 | elm_write_reg(info, ELM_SYNDROME_FRAGMENT_0 + offset, | 522 | elm_write_reg(info, ELM_SYNDROME_FRAGMENT_0 + offset, |
| 522 | regs->elm_syndrome_fragment_0[i]); | 523 | regs->elm_syndrome_fragment_0[i]); |
| 524 | break; | ||
| 523 | default: | 525 | default: |
| 524 | return -EINVAL; | 526 | return -EINVAL; |
| 525 | } | 527 | } |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 41167e9e991e..4f3e80c68a26 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
| @@ -4047,8 +4047,10 @@ int nand_scan_tail(struct mtd_info *mtd) | |||
| 4047 | ecc->layout->oobavail += ecc->layout->oobfree[i].length; | 4047 | ecc->layout->oobavail += ecc->layout->oobfree[i].length; |
| 4048 | mtd->oobavail = ecc->layout->oobavail; | 4048 | mtd->oobavail = ecc->layout->oobavail; |
| 4049 | 4049 | ||
| 4050 | /* ECC sanity check: warn noisily if it's too weak */ | 4050 | /* ECC sanity check: warn if it's too weak */ |
| 4051 | WARN_ON(!nand_ecc_strength_good(mtd)); | 4051 | if (!nand_ecc_strength_good(mtd)) |
| 4052 | pr_warn("WARNING: %s: the ECC used on your system is too weak compared to the one required by the NAND chip\n", | ||
| 4053 | mtd->name); | ||
| 4052 | 4054 | ||
| 4053 | /* | 4055 | /* |
| 4054 | * Set the number of read / write steps for one page depending on ECC | 4056 | * Set the number of read / write steps for one page depending on ECC |
diff --git a/drivers/mtd/ubi/fastmap.c b/drivers/mtd/ubi/fastmap.c index b04e7d059888..0431b46d9fd9 100644 --- a/drivers/mtd/ubi/fastmap.c +++ b/drivers/mtd/ubi/fastmap.c | |||
| @@ -125,7 +125,7 @@ static struct ubi_ainf_volume *add_vol(struct ubi_attach_info *ai, int vol_id, | |||
| 125 | parent = *p; | 125 | parent = *p; |
| 126 | av = rb_entry(parent, struct ubi_ainf_volume, rb); | 126 | av = rb_entry(parent, struct ubi_ainf_volume, rb); |
| 127 | 127 | ||
| 128 | if (vol_id < av->vol_id) | 128 | if (vol_id > av->vol_id) |
| 129 | p = &(*p)->rb_left; | 129 | p = &(*p)->rb_left; |
| 130 | else | 130 | else |
| 131 | p = &(*p)->rb_right; | 131 | p = &(*p)->rb_right; |
| @@ -423,7 +423,7 @@ static int scan_pool(struct ubi_device *ubi, struct ubi_attach_info *ai, | |||
| 423 | pnum, err); | 423 | pnum, err); |
| 424 | ret = err > 0 ? UBI_BAD_FASTMAP : err; | 424 | ret = err > 0 ? UBI_BAD_FASTMAP : err; |
| 425 | goto out; | 425 | goto out; |
| 426 | } else if (ret == UBI_IO_BITFLIPS) | 426 | } else if (err == UBI_IO_BITFLIPS) |
| 427 | scrub = 1; | 427 | scrub = 1; |
| 428 | 428 | ||
| 429 | /* | 429 | /* |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 3a451b6cd3d5..701f86cd5993 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
| @@ -4068,7 +4068,7 @@ static int bond_check_params(struct bond_params *params) | |||
| 4068 | } | 4068 | } |
| 4069 | 4069 | ||
| 4070 | if (ad_select) { | 4070 | if (ad_select) { |
| 4071 | bond_opt_initstr(&newval, lacp_rate); | 4071 | bond_opt_initstr(&newval, ad_select); |
| 4072 | valptr = bond_opt_parse(bond_opt_get(BOND_OPT_AD_SELECT), | 4072 | valptr = bond_opt_parse(bond_opt_get(BOND_OPT_AD_SELECT), |
| 4073 | &newval); | 4073 | &newval); |
| 4074 | if (!valptr) { | 4074 | if (!valptr) { |
diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c index 824108cd9fd5..12430be6448a 100644 --- a/drivers/net/can/c_can/c_can_platform.c +++ b/drivers/net/can/c_can/c_can_platform.c | |||
| @@ -287,7 +287,8 @@ static int c_can_plat_probe(struct platform_device *pdev) | |||
| 287 | break; | 287 | break; |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | priv->raminit_ctrlreg = devm_ioremap_resource(&pdev->dev, res); | 290 | priv->raminit_ctrlreg = devm_ioremap(&pdev->dev, res->start, |
| 291 | resource_size(res)); | ||
| 291 | if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0) | 292 | if (IS_ERR(priv->raminit_ctrlreg) || priv->instance < 0) |
| 292 | dev_info(&pdev->dev, "control memory is not used for raminit\n"); | 293 | dev_info(&pdev->dev, "control memory is not used for raminit\n"); |
| 293 | else | 294 | else |
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-main.c b/drivers/net/ethernet/amd/xgbe/xgbe-main.c index c83584a26713..5a1891faba8a 100644 --- a/drivers/net/ethernet/amd/xgbe/xgbe-main.c +++ b/drivers/net/ethernet/amd/xgbe/xgbe-main.c | |||
| @@ -339,7 +339,8 @@ static int xgbe_probe(struct platform_device *pdev) | |||
| 339 | /* Calculate the number of Tx and Rx rings to be created */ | 339 | /* Calculate the number of Tx and Rx rings to be created */ |
| 340 | pdata->tx_ring_count = min_t(unsigned int, num_online_cpus(), | 340 | pdata->tx_ring_count = min_t(unsigned int, num_online_cpus(), |
| 341 | pdata->hw_feat.tx_ch_cnt); | 341 | pdata->hw_feat.tx_ch_cnt); |
| 342 | if (netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count)) { | 342 | ret = netif_set_real_num_tx_queues(netdev, pdata->tx_ring_count); |
| 343 | if (ret) { | ||
| 343 | dev_err(dev, "error setting real tx queue count\n"); | 344 | dev_err(dev, "error setting real tx queue count\n"); |
| 344 | goto err_io; | 345 | goto err_io; |
| 345 | } | 346 | } |
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c index 141160ef249a..5776e503e4c5 100644 --- a/drivers/net/ethernet/broadcom/bcmsysport.c +++ b/drivers/net/ethernet/broadcom/bcmsysport.c | |||
| @@ -654,13 +654,13 @@ static int bcm_sysport_tx_poll(struct napi_struct *napi, int budget) | |||
| 654 | 654 | ||
| 655 | work_done = bcm_sysport_tx_reclaim(ring->priv, ring); | 655 | work_done = bcm_sysport_tx_reclaim(ring->priv, ring); |
| 656 | 656 | ||
| 657 | if (work_done < budget) { | 657 | if (work_done == 0) { |
| 658 | napi_complete(napi); | 658 | napi_complete(napi); |
| 659 | /* re-enable TX interrupt */ | 659 | /* re-enable TX interrupt */ |
| 660 | intrl2_1_mask_clear(ring->priv, BIT(ring->index)); | 660 | intrl2_1_mask_clear(ring->priv, BIT(ring->index)); |
| 661 | } | 661 | } |
| 662 | 662 | ||
| 663 | return work_done; | 663 | return 0; |
| 664 | } | 664 | } |
| 665 | 665 | ||
| 666 | static void bcm_sysport_tx_reclaim_all(struct bcm_sysport_priv *priv) | 666 | static void bcm_sysport_tx_reclaim_all(struct bcm_sysport_priv *priv) |
| @@ -1254,28 +1254,17 @@ static inline void umac_enable_set(struct bcm_sysport_priv *priv, | |||
| 1254 | usleep_range(1000, 2000); | 1254 | usleep_range(1000, 2000); |
| 1255 | } | 1255 | } |
| 1256 | 1256 | ||
| 1257 | static inline int umac_reset(struct bcm_sysport_priv *priv) | 1257 | static inline void umac_reset(struct bcm_sysport_priv *priv) |
| 1258 | { | 1258 | { |
| 1259 | unsigned int timeout = 0; | ||
| 1260 | u32 reg; | 1259 | u32 reg; |
| 1261 | int ret = 0; | ||
| 1262 | |||
| 1263 | umac_writel(priv, 0, UMAC_CMD); | ||
| 1264 | while (timeout++ < 1000) { | ||
| 1265 | reg = umac_readl(priv, UMAC_CMD); | ||
| 1266 | if (!(reg & CMD_SW_RESET)) | ||
| 1267 | break; | ||
| 1268 | |||
| 1269 | udelay(1); | ||
| 1270 | } | ||
| 1271 | |||
| 1272 | if (timeout == 1000) { | ||
| 1273 | dev_err(&priv->pdev->dev, | ||
| 1274 | "timeout waiting for MAC to come out of reset\n"); | ||
| 1275 | ret = -ETIMEDOUT; | ||
| 1276 | } | ||
| 1277 | 1260 | ||
| 1278 | return ret; | 1261 | reg = umac_readl(priv, UMAC_CMD); |
| 1262 | reg |= CMD_SW_RESET; | ||
| 1263 | umac_writel(priv, reg, UMAC_CMD); | ||
| 1264 | udelay(10); | ||
| 1265 | reg = umac_readl(priv, UMAC_CMD); | ||
| 1266 | reg &= ~CMD_SW_RESET; | ||
| 1267 | umac_writel(priv, reg, UMAC_CMD); | ||
| 1279 | } | 1268 | } |
| 1280 | 1269 | ||
| 1281 | static void umac_set_hw_addr(struct bcm_sysport_priv *priv, | 1270 | static void umac_set_hw_addr(struct bcm_sysport_priv *priv, |
| @@ -1303,11 +1292,7 @@ static int bcm_sysport_open(struct net_device *dev) | |||
| 1303 | int ret; | 1292 | int ret; |
| 1304 | 1293 | ||
| 1305 | /* Reset UniMAC */ | 1294 | /* Reset UniMAC */ |
| 1306 | ret = umac_reset(priv); | 1295 | umac_reset(priv); |
| 1307 | if (ret) { | ||
| 1308 | netdev_err(dev, "UniMAC reset failed\n"); | ||
| 1309 | return ret; | ||
| 1310 | } | ||
| 1311 | 1296 | ||
| 1312 | /* Flush TX and RX FIFOs at TOPCTRL level */ | 1297 | /* Flush TX and RX FIFOs at TOPCTRL level */ |
| 1313 | topctrl_flush(priv); | 1298 | topctrl_flush(priv); |
| @@ -1589,12 +1574,6 @@ static int bcm_sysport_probe(struct platform_device *pdev) | |||
| 1589 | BUILD_BUG_ON(sizeof(struct bcm_tsb) != 8); | 1574 | BUILD_BUG_ON(sizeof(struct bcm_tsb) != 8); |
| 1590 | dev->needed_headroom += sizeof(struct bcm_tsb); | 1575 | dev->needed_headroom += sizeof(struct bcm_tsb); |
| 1591 | 1576 | ||
| 1592 | /* We are interfaced to a switch which handles the multicast | ||
| 1593 | * filtering for us, so we do not support programming any | ||
| 1594 | * multicast hash table in this Ethernet MAC. | ||
| 1595 | */ | ||
| 1596 | dev->flags &= ~IFF_MULTICAST; | ||
| 1597 | |||
| 1598 | /* libphy will adjust the link state accordingly */ | 1577 | /* libphy will adjust the link state accordingly */ |
| 1599 | netif_carrier_off(dev); | 1578 | netif_carrier_off(dev); |
| 1600 | 1579 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h index 4cab09d3f807..8206a293e6b4 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x.h | |||
| @@ -346,6 +346,7 @@ struct sw_tx_bd { | |||
| 346 | u8 flags; | 346 | u8 flags; |
| 347 | /* Set on the first BD descriptor when there is a split BD */ | 347 | /* Set on the first BD descriptor when there is a split BD */ |
| 348 | #define BNX2X_TSO_SPLIT_BD (1<<0) | 348 | #define BNX2X_TSO_SPLIT_BD (1<<0) |
| 349 | #define BNX2X_HAS_SECOND_PBD (1<<1) | ||
| 349 | }; | 350 | }; |
| 350 | 351 | ||
| 351 | struct sw_rx_page { | 352 | struct sw_rx_page { |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c index 47c5814114e1..c43e7238de21 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c | |||
| @@ -227,6 +227,12 @@ static u16 bnx2x_free_tx_pkt(struct bnx2x *bp, struct bnx2x_fp_txdata *txdata, | |||
| 227 | --nbd; | 227 | --nbd; |
| 228 | bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); | 228 | bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); |
| 229 | 229 | ||
| 230 | if (tx_buf->flags & BNX2X_HAS_SECOND_PBD) { | ||
| 231 | /* Skip second parse bd... */ | ||
| 232 | --nbd; | ||
| 233 | bd_idx = TX_BD(NEXT_TX_IDX(bd_idx)); | ||
| 234 | } | ||
| 235 | |||
| 230 | /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */ | 236 | /* TSO headers+data bds share a common mapping. See bnx2x_tx_split() */ |
| 231 | if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) { | 237 | if (tx_buf->flags & BNX2X_TSO_SPLIT_BD) { |
| 232 | tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd; | 238 | tx_data_bd = &txdata->tx_desc_ring[bd_idx].reg_bd; |
| @@ -797,7 +803,8 @@ static void bnx2x_tpa_stop(struct bnx2x *bp, struct bnx2x_fastpath *fp, | |||
| 797 | 803 | ||
| 798 | return; | 804 | return; |
| 799 | } | 805 | } |
| 800 | bnx2x_frag_free(fp, new_data); | 806 | if (new_data) |
| 807 | bnx2x_frag_free(fp, new_data); | ||
| 801 | drop: | 808 | drop: |
| 802 | /* drop the packet and keep the buffer in the bin */ | 809 | /* drop the packet and keep the buffer in the bin */ |
| 803 | DP(NETIF_MSG_RX_STATUS, | 810 | DP(NETIF_MSG_RX_STATUS, |
| @@ -3888,6 +3895,9 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 3888 | /* set encapsulation flag in start BD */ | 3895 | /* set encapsulation flag in start BD */ |
| 3889 | SET_FLAG(tx_start_bd->general_data, | 3896 | SET_FLAG(tx_start_bd->general_data, |
| 3890 | ETH_TX_START_BD_TUNNEL_EXIST, 1); | 3897 | ETH_TX_START_BD_TUNNEL_EXIST, 1); |
| 3898 | |||
| 3899 | tx_buf->flags |= BNX2X_HAS_SECOND_PBD; | ||
| 3900 | |||
| 3891 | nbd++; | 3901 | nbd++; |
| 3892 | } else if (xmit_type & XMIT_CSUM) { | 3902 | } else if (xmit_type & XMIT_CSUM) { |
| 3893 | /* Set PBD in checksum offload case w/o encapsulation */ | 3903 | /* Set PBD in checksum offload case w/o encapsulation */ |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c index bd0600cf7266..25eddd90f482 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_ethtool.c | |||
| @@ -379,6 +379,7 @@ static int bnx2x_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | |||
| 379 | break; | 379 | break; |
| 380 | case PORT_FIBRE: | 380 | case PORT_FIBRE: |
| 381 | case PORT_DA: | 381 | case PORT_DA: |
| 382 | case PORT_NONE: | ||
| 382 | if (!(bp->port.supported[0] & SUPPORTED_FIBRE || | 383 | if (!(bp->port.supported[0] & SUPPORTED_FIBRE || |
| 383 | bp->port.supported[1] & SUPPORTED_FIBRE)) { | 384 | bp->port.supported[1] & SUPPORTED_FIBRE)) { |
| 384 | DP(BNX2X_MSG_ETHTOOL, | 385 | DP(BNX2X_MSG_ETHTOOL, |
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c index 2887034523e0..6a8b1453a1b9 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c | |||
| @@ -12937,7 +12937,7 @@ static int bnx2x_get_num_non_def_sbs(struct pci_dev *pdev, int cnic_cnt) | |||
| 12937 | * without the default SB. | 12937 | * without the default SB. |
| 12938 | * For VFs there is no default SB, then we return (index+1). | 12938 | * For VFs there is no default SB, then we return (index+1). |
| 12939 | */ | 12939 | */ |
| 12940 | pci_read_config_word(pdev, pdev->msix_cap + PCI_MSI_FLAGS, &control); | 12940 | pci_read_config_word(pdev, pdev->msix_cap + PCI_MSIX_FLAGS, &control); |
| 12941 | 12941 | ||
| 12942 | index = control & PCI_MSIX_FLAGS_QSIZE; | 12942 | index = control & PCI_MSIX_FLAGS_QSIZE; |
| 12943 | 12943 | ||
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c index 5ba1cfbd60da..4e615debe472 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c | |||
| @@ -1149,6 +1149,11 @@ static netdev_tx_t bcmgenet_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 1149 | goto out; | 1149 | goto out; |
| 1150 | } | 1150 | } |
| 1151 | 1151 | ||
| 1152 | if (skb_padto(skb, ETH_ZLEN)) { | ||
| 1153 | ret = NETDEV_TX_OK; | ||
| 1154 | goto out; | ||
| 1155 | } | ||
| 1156 | |||
| 1152 | /* set the SKB transmit checksum */ | 1157 | /* set the SKB transmit checksum */ |
| 1153 | if (priv->desc_64b_en) { | 1158 | if (priv->desc_64b_en) { |
| 1154 | ret = bcmgenet_put_tx_csum(dev, skb); | 1159 | ret = bcmgenet_put_tx_csum(dev, skb); |
| @@ -1408,13 +1413,6 @@ static int bcmgenet_alloc_rx_buffers(struct bcmgenet_priv *priv) | |||
| 1408 | if (cb->skb) | 1413 | if (cb->skb) |
| 1409 | continue; | 1414 | continue; |
| 1410 | 1415 | ||
| 1411 | /* set the DMA descriptor length once and for all | ||
| 1412 | * it will only change if we support dynamically sizing | ||
| 1413 | * priv->rx_buf_len, but we do not | ||
| 1414 | */ | ||
| 1415 | dmadesc_set_length_status(priv, priv->rx_bd_assign_ptr, | ||
| 1416 | priv->rx_buf_len << DMA_BUFLENGTH_SHIFT); | ||
| 1417 | |||
| 1418 | ret = bcmgenet_rx_refill(priv, cb); | 1416 | ret = bcmgenet_rx_refill(priv, cb); |
| 1419 | if (ret) | 1417 | if (ret) |
| 1420 | break; | 1418 | break; |
| @@ -2535,14 +2533,17 @@ static int bcmgenet_probe(struct platform_device *pdev) | |||
| 2535 | netif_set_real_num_tx_queues(priv->dev, priv->hw_params->tx_queues + 1); | 2533 | netif_set_real_num_tx_queues(priv->dev, priv->hw_params->tx_queues + 1); |
| 2536 | netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1); | 2534 | netif_set_real_num_rx_queues(priv->dev, priv->hw_params->rx_queues + 1); |
| 2537 | 2535 | ||
| 2538 | err = register_netdev(dev); | 2536 | /* libphy will determine the link state */ |
| 2539 | if (err) | 2537 | netif_carrier_off(dev); |
| 2540 | goto err_clk_disable; | ||
| 2541 | 2538 | ||
| 2542 | /* Turn off the main clock, WOL clock is handled separately */ | 2539 | /* Turn off the main clock, WOL clock is handled separately */ |
| 2543 | if (!IS_ERR(priv->clk)) | 2540 | if (!IS_ERR(priv->clk)) |
| 2544 | clk_disable_unprepare(priv->clk); | 2541 | clk_disable_unprepare(priv->clk); |
| 2545 | 2542 | ||
| 2543 | err = register_netdev(dev); | ||
| 2544 | if (err) | ||
| 2545 | goto err; | ||
| 2546 | |||
| 2546 | return err; | 2547 | return err; |
| 2547 | 2548 | ||
| 2548 | err_clk_disable: | 2549 | err_clk_disable: |
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.h b/drivers/net/ethernet/broadcom/genet/bcmgenet.h index 0f117105fed1..e23c993b1362 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmgenet.h +++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.h | |||
| @@ -331,9 +331,9 @@ struct bcmgenet_mib_counters { | |||
| 331 | #define EXT_ENERGY_DET_MASK (1 << 12) | 331 | #define EXT_ENERGY_DET_MASK (1 << 12) |
| 332 | 332 | ||
| 333 | #define EXT_RGMII_OOB_CTRL 0x0C | 333 | #define EXT_RGMII_OOB_CTRL 0x0C |
| 334 | #define RGMII_MODE_EN (1 << 0) | ||
| 335 | #define RGMII_LINK (1 << 4) | 334 | #define RGMII_LINK (1 << 4) |
| 336 | #define OOB_DISABLE (1 << 5) | 335 | #define OOB_DISABLE (1 << 5) |
| 336 | #define RGMII_MODE_EN (1 << 6) | ||
| 337 | #define ID_MODE_DIS (1 << 16) | 337 | #define ID_MODE_DIS (1 << 16) |
| 338 | 338 | ||
| 339 | #define EXT_GPHY_CTRL 0x1C | 339 | #define EXT_GPHY_CTRL 0x1C |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 34a26e42f19d..1e187fb760f8 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
| @@ -2902,7 +2902,7 @@ static int be_open(struct net_device *netdev) | |||
| 2902 | for_all_evt_queues(adapter, eqo, i) { | 2902 | for_all_evt_queues(adapter, eqo, i) { |
| 2903 | napi_enable(&eqo->napi); | 2903 | napi_enable(&eqo->napi); |
| 2904 | be_enable_busy_poll(eqo); | 2904 | be_enable_busy_poll(eqo); |
| 2905 | be_eq_notify(adapter, eqo->q.id, true, false, 0); | 2905 | be_eq_notify(adapter, eqo->q.id, true, true, 0); |
| 2906 | } | 2906 | } |
| 2907 | adapter->flags |= BE_FLAGS_NAPI_ENABLED; | 2907 | adapter->flags |= BE_FLAGS_NAPI_ENABLED; |
| 2908 | 2908 | ||
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index fab39e295441..36fc429298e3 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c | |||
| @@ -2990,11 +2990,11 @@ static int ucc_geth_startup(struct ucc_geth_private *ugeth) | |||
| 2990 | if (ug_info->rxExtendedFiltering) { | 2990 | if (ug_info->rxExtendedFiltering) { |
| 2991 | size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; | 2991 | size += THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING; |
| 2992 | if (ug_info->largestexternallookupkeysize == | 2992 | if (ug_info->largestexternallookupkeysize == |
| 2993 | QE_FLTR_TABLE_LOOKUP_KEY_SIZE_8_BYTES) | 2993 | QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_8_BYTES) |
| 2994 | size += | 2994 | size += |
| 2995 | THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8; | 2995 | THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_8; |
| 2996 | if (ug_info->largestexternallookupkeysize == | 2996 | if (ug_info->largestexternallookupkeysize == |
| 2997 | QE_FLTR_TABLE_LOOKUP_KEY_SIZE_16_BYTES) | 2997 | QE_FLTR_LARGEST_EXTERNAL_TABLE_LOOKUP_KEY_SIZE_16_BYTES) |
| 2998 | size += | 2998 | size += |
| 2999 | THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16; | 2999 | THREAD_RX_PRAM_ADDITIONAL_FOR_EXTENDED_FILTERING_16; |
| 3000 | } | 3000 | } |
diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c index a2db388cc31e..ee74f9536b31 100644 --- a/drivers/net/ethernet/intel/igb/e1000_82575.c +++ b/drivers/net/ethernet/intel/igb/e1000_82575.c | |||
| @@ -1481,6 +1481,13 @@ static s32 igb_init_hw_82575(struct e1000_hw *hw) | |||
| 1481 | s32 ret_val; | 1481 | s32 ret_val; |
| 1482 | u16 i, rar_count = mac->rar_entry_count; | 1482 | u16 i, rar_count = mac->rar_entry_count; |
| 1483 | 1483 | ||
| 1484 | if ((hw->mac.type >= e1000_i210) && | ||
| 1485 | !(igb_get_flash_presence_i210(hw))) { | ||
| 1486 | ret_val = igb_pll_workaround_i210(hw); | ||
| 1487 | if (ret_val) | ||
| 1488 | return ret_val; | ||
| 1489 | } | ||
| 1490 | |||
| 1484 | /* Initialize identification LED */ | 1491 | /* Initialize identification LED */ |
| 1485 | ret_val = igb_id_led_init(hw); | 1492 | ret_val = igb_id_led_init(hw); |
| 1486 | if (ret_val) { | 1493 | if (ret_val) { |
diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h index 2a8bb35c2df2..217f8138851b 100644 --- a/drivers/net/ethernet/intel/igb/e1000_defines.h +++ b/drivers/net/ethernet/intel/igb/e1000_defines.h | |||
| @@ -46,14 +46,15 @@ | |||
| 46 | #define E1000_CTRL_EXT_SDP3_DIR 0x00000800 /* SDP3 Data direction */ | 46 | #define E1000_CTRL_EXT_SDP3_DIR 0x00000800 /* SDP3 Data direction */ |
| 47 | 47 | ||
| 48 | /* Physical Func Reset Done Indication */ | 48 | /* Physical Func Reset Done Indication */ |
| 49 | #define E1000_CTRL_EXT_PFRSTD 0x00004000 | 49 | #define E1000_CTRL_EXT_PFRSTD 0x00004000 |
| 50 | #define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 | 50 | #define E1000_CTRL_EXT_SDLPE 0X00040000 /* SerDes Low Power Enable */ |
| 51 | #define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES 0x00C00000 | 51 | #define E1000_CTRL_EXT_LINK_MODE_MASK 0x00C00000 |
| 52 | #define E1000_CTRL_EXT_LINK_MODE_1000BASE_KX 0x00400000 | 52 | #define E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES 0x00C00000 |
| 53 | #define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000 | 53 | #define E1000_CTRL_EXT_LINK_MODE_1000BASE_KX 0x00400000 |
| 54 | #define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000 | 54 | #define E1000_CTRL_EXT_LINK_MODE_SGMII 0x00800000 |
| 55 | #define E1000_CTRL_EXT_EIAME 0x01000000 | 55 | #define E1000_CTRL_EXT_LINK_MODE_GMII 0x00000000 |
| 56 | #define E1000_CTRL_EXT_IRCA 0x00000001 | 56 | #define E1000_CTRL_EXT_EIAME 0x01000000 |
| 57 | #define E1000_CTRL_EXT_IRCA 0x00000001 | ||
| 57 | /* Interrupt delay cancellation */ | 58 | /* Interrupt delay cancellation */ |
| 58 | /* Driver loaded bit for FW */ | 59 | /* Driver loaded bit for FW */ |
| 59 | #define E1000_CTRL_EXT_DRV_LOAD 0x10000000 | 60 | #define E1000_CTRL_EXT_DRV_LOAD 0x10000000 |
| @@ -62,6 +63,7 @@ | |||
| 62 | /* packet buffer parity error detection enabled */ | 63 | /* packet buffer parity error detection enabled */ |
| 63 | /* descriptor FIFO parity error detection enable */ | 64 | /* descriptor FIFO parity error detection enable */ |
| 64 | #define E1000_CTRL_EXT_PBA_CLR 0x80000000 /* PBA Clear */ | 65 | #define E1000_CTRL_EXT_PBA_CLR 0x80000000 /* PBA Clear */ |
| 66 | #define E1000_CTRL_EXT_PHYPDEN 0x00100000 | ||
| 65 | #define E1000_I2CCMD_REG_ADDR_SHIFT 16 | 67 | #define E1000_I2CCMD_REG_ADDR_SHIFT 16 |
| 66 | #define E1000_I2CCMD_PHY_ADDR_SHIFT 24 | 68 | #define E1000_I2CCMD_PHY_ADDR_SHIFT 24 |
| 67 | #define E1000_I2CCMD_OPCODE_READ 0x08000000 | 69 | #define E1000_I2CCMD_OPCODE_READ 0x08000000 |
diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h index 89925e405849..ce55ea5d750c 100644 --- a/drivers/net/ethernet/intel/igb/e1000_hw.h +++ b/drivers/net/ethernet/intel/igb/e1000_hw.h | |||
| @@ -567,4 +567,7 @@ struct net_device *igb_get_hw_dev(struct e1000_hw *hw); | |||
| 567 | /* These functions must be implemented by drivers */ | 567 | /* These functions must be implemented by drivers */ |
| 568 | s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); | 568 | s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); |
| 569 | s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); | 569 | s32 igb_write_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value); |
| 570 | |||
| 571 | void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value); | ||
| 572 | void igb_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value); | ||
| 570 | #endif /* _E1000_HW_H_ */ | 573 | #endif /* _E1000_HW_H_ */ |
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c index 337161f440dd..65d931669f81 100644 --- a/drivers/net/ethernet/intel/igb/e1000_i210.c +++ b/drivers/net/ethernet/intel/igb/e1000_i210.c | |||
| @@ -834,3 +834,69 @@ s32 igb_init_nvm_params_i210(struct e1000_hw *hw) | |||
| 834 | } | 834 | } |
| 835 | return ret_val; | 835 | return ret_val; |
| 836 | } | 836 | } |
| 837 | |||
| 838 | /** | ||
| 839 | * igb_pll_workaround_i210 | ||
| 840 | * @hw: pointer to the HW structure | ||
| 841 | * | ||
| 842 | * Works around an errata in the PLL circuit where it occasionally | ||
| 843 | * provides the wrong clock frequency after power up. | ||
| 844 | **/ | ||
| 845 | s32 igb_pll_workaround_i210(struct e1000_hw *hw) | ||
| 846 | { | ||
| 847 | s32 ret_val; | ||
| 848 | u32 wuc, mdicnfg, ctrl, ctrl_ext, reg_val; | ||
| 849 | u16 nvm_word, phy_word, pci_word, tmp_nvm; | ||
| 850 | int i; | ||
| 851 | |||
| 852 | /* Get and set needed register values */ | ||
| 853 | wuc = rd32(E1000_WUC); | ||
| 854 | mdicnfg = rd32(E1000_MDICNFG); | ||
| 855 | reg_val = mdicnfg & ~E1000_MDICNFG_EXT_MDIO; | ||
| 856 | wr32(E1000_MDICNFG, reg_val); | ||
| 857 | |||
| 858 | /* Get data from NVM, or set default */ | ||
| 859 | ret_val = igb_read_invm_word_i210(hw, E1000_INVM_AUTOLOAD, | ||
| 860 | &nvm_word); | ||
| 861 | if (ret_val) | ||
| 862 | nvm_word = E1000_INVM_DEFAULT_AL; | ||
| 863 | tmp_nvm = nvm_word | E1000_INVM_PLL_WO_VAL; | ||
| 864 | for (i = 0; i < E1000_MAX_PLL_TRIES; i++) { | ||
| 865 | /* check current state directly from internal PHY */ | ||
| 866 | igb_read_phy_reg_gs40g(hw, (E1000_PHY_PLL_FREQ_PAGE | | ||
| 867 | E1000_PHY_PLL_FREQ_REG), &phy_word); | ||
| 868 | if ((phy_word & E1000_PHY_PLL_UNCONF) | ||
| 869 | != E1000_PHY_PLL_UNCONF) { | ||
| 870 | ret_val = 0; | ||
| 871 | break; | ||
| 872 | } else { | ||
| 873 | ret_val = -E1000_ERR_PHY; | ||
| 874 | } | ||
| 875 | /* directly reset the internal PHY */ | ||
| 876 | ctrl = rd32(E1000_CTRL); | ||
| 877 | wr32(E1000_CTRL, ctrl|E1000_CTRL_PHY_RST); | ||
| 878 | |||
| 879 | ctrl_ext = rd32(E1000_CTRL_EXT); | ||
| 880 | ctrl_ext |= (E1000_CTRL_EXT_PHYPDEN | E1000_CTRL_EXT_SDLPE); | ||
| 881 | wr32(E1000_CTRL_EXT, ctrl_ext); | ||
| 882 | |||
| 883 | wr32(E1000_WUC, 0); | ||
| 884 | reg_val = (E1000_INVM_AUTOLOAD << 4) | (tmp_nvm << 16); | ||
| 885 | wr32(E1000_EEARBC_I210, reg_val); | ||
| 886 | |||
| 887 | igb_read_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word); | ||
| 888 | pci_word |= E1000_PCI_PMCSR_D3; | ||
| 889 | igb_write_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word); | ||
| 890 | usleep_range(1000, 2000); | ||
| 891 | pci_word &= ~E1000_PCI_PMCSR_D3; | ||
| 892 | igb_write_pci_cfg(hw, E1000_PCI_PMCSR, &pci_word); | ||
| 893 | reg_val = (E1000_INVM_AUTOLOAD << 4) | (nvm_word << 16); | ||
| 894 | wr32(E1000_EEARBC_I210, reg_val); | ||
| 895 | |||
| 896 | /* restore WUC register */ | ||
| 897 | wr32(E1000_WUC, wuc); | ||
| 898 | } | ||
| 899 | /* restore MDICNFG setting */ | ||
| 900 | wr32(E1000_MDICNFG, mdicnfg); | ||
| 901 | return ret_val; | ||
| 902 | } | ||
diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.h b/drivers/net/ethernet/intel/igb/e1000_i210.h index 9f34976687ba..3442b6357d01 100644 --- a/drivers/net/ethernet/intel/igb/e1000_i210.h +++ b/drivers/net/ethernet/intel/igb/e1000_i210.h | |||
| @@ -33,6 +33,7 @@ s32 igb_read_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 *data); | |||
| 33 | s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data); | 33 | s32 igb_write_xmdio_reg(struct e1000_hw *hw, u16 addr, u8 dev_addr, u16 data); |
| 34 | s32 igb_init_nvm_params_i210(struct e1000_hw *hw); | 34 | s32 igb_init_nvm_params_i210(struct e1000_hw *hw); |
| 35 | bool igb_get_flash_presence_i210(struct e1000_hw *hw); | 35 | bool igb_get_flash_presence_i210(struct e1000_hw *hw); |
| 36 | s32 igb_pll_workaround_i210(struct e1000_hw *hw); | ||
| 36 | 37 | ||
| 37 | #define E1000_STM_OPCODE 0xDB00 | 38 | #define E1000_STM_OPCODE 0xDB00 |
| 38 | #define E1000_EEPROM_FLASH_SIZE_WORD 0x11 | 39 | #define E1000_EEPROM_FLASH_SIZE_WORD 0x11 |
| @@ -78,4 +79,15 @@ enum E1000_INVM_STRUCTURE_TYPE { | |||
| 78 | #define NVM_LED_1_CFG_DEFAULT_I211 0x0184 | 79 | #define NVM_LED_1_CFG_DEFAULT_I211 0x0184 |
| 79 | #define NVM_LED_0_2_CFG_DEFAULT_I211 0x200C | 80 | #define NVM_LED_0_2_CFG_DEFAULT_I211 0x200C |
| 80 | 81 | ||
| 82 | /* PLL Defines */ | ||
| 83 | #define E1000_PCI_PMCSR 0x44 | ||
| 84 | #define E1000_PCI_PMCSR_D3 0x03 | ||
| 85 | #define E1000_MAX_PLL_TRIES 5 | ||
| 86 | #define E1000_PHY_PLL_UNCONF 0xFF | ||
| 87 | #define E1000_PHY_PLL_FREQ_PAGE 0xFC0000 | ||
| 88 | #define E1000_PHY_PLL_FREQ_REG 0x000E | ||
| 89 | #define E1000_INVM_DEFAULT_AL 0x202F | ||
| 90 | #define E1000_INVM_AUTOLOAD 0x0A | ||
| 91 | #define E1000_INVM_PLL_WO_VAL 0x0010 | ||
| 92 | |||
| 81 | #endif | 93 | #endif |
diff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h index 1cc4b1a7e597..f5ba4e4eafb9 100644 --- a/drivers/net/ethernet/intel/igb/e1000_regs.h +++ b/drivers/net/ethernet/intel/igb/e1000_regs.h | |||
| @@ -66,6 +66,7 @@ | |||
| 66 | #define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */ | 66 | #define E1000_PBA 0x01000 /* Packet Buffer Allocation - RW */ |
| 67 | #define E1000_PBS 0x01008 /* Packet Buffer Size */ | 67 | #define E1000_PBS 0x01008 /* Packet Buffer Size */ |
| 68 | #define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */ | 68 | #define E1000_EEMNGCTL 0x01010 /* MNG EEprom Control */ |
| 69 | #define E1000_EEARBC_I210 0x12024 /* EEPROM Auto Read Bus Control */ | ||
| 69 | #define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */ | 70 | #define E1000_EEWR 0x0102C /* EEPROM Write Register - RW */ |
| 70 | #define E1000_I2CCMD 0x01028 /* SFPI2C Command Register - RW */ | 71 | #define E1000_I2CCMD 0x01028 /* SFPI2C Command Register - RW */ |
| 71 | #define E1000_FRTIMER 0x01048 /* Free Running Timer - RW */ | 72 | #define E1000_FRTIMER 0x01048 /* Free Running Timer - RW */ |
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index f145adbb55ac..a9537ba7a5a0 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
| @@ -7215,6 +7215,20 @@ static int igb_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | |||
| 7215 | } | 7215 | } |
| 7216 | } | 7216 | } |
| 7217 | 7217 | ||
| 7218 | void igb_read_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value) | ||
| 7219 | { | ||
| 7220 | struct igb_adapter *adapter = hw->back; | ||
| 7221 | |||
| 7222 | pci_read_config_word(adapter->pdev, reg, value); | ||
| 7223 | } | ||
| 7224 | |||
| 7225 | void igb_write_pci_cfg(struct e1000_hw *hw, u32 reg, u16 *value) | ||
| 7226 | { | ||
| 7227 | struct igb_adapter *adapter = hw->back; | ||
| 7228 | |||
| 7229 | pci_write_config_word(adapter->pdev, reg, *value); | ||
| 7230 | } | ||
| 7231 | |||
| 7218 | s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) | 7232 | s32 igb_read_pcie_cap_reg(struct e1000_hw *hw, u32 reg, u16 *value) |
| 7219 | { | 7233 | { |
| 7220 | struct igb_adapter *adapter = hw->back; | 7234 | struct igb_adapter *adapter = hw->back; |
| @@ -7578,6 +7592,8 @@ static int igb_sriov_reinit(struct pci_dev *dev) | |||
| 7578 | 7592 | ||
| 7579 | if (netif_running(netdev)) | 7593 | if (netif_running(netdev)) |
| 7580 | igb_close(netdev); | 7594 | igb_close(netdev); |
| 7595 | else | ||
| 7596 | igb_reset(adapter); | ||
| 7581 | 7597 | ||
| 7582 | igb_clear_interrupt_scheme(adapter); | 7598 | igb_clear_interrupt_scheme(adapter); |
| 7583 | 7599 | ||
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c index 45beca17fa50..dadd9a5f6323 100644 --- a/drivers/net/ethernet/marvell/mvneta.c +++ b/drivers/net/ethernet/marvell/mvneta.c | |||
| @@ -1207,7 +1207,7 @@ static u32 mvneta_txq_desc_csum(int l3_offs, int l3_proto, | |||
| 1207 | command = l3_offs << MVNETA_TX_L3_OFF_SHIFT; | 1207 | command = l3_offs << MVNETA_TX_L3_OFF_SHIFT; |
| 1208 | command |= ip_hdr_len << MVNETA_TX_IP_HLEN_SHIFT; | 1208 | command |= ip_hdr_len << MVNETA_TX_IP_HLEN_SHIFT; |
| 1209 | 1209 | ||
| 1210 | if (l3_proto == swab16(ETH_P_IP)) | 1210 | if (l3_proto == htons(ETH_P_IP)) |
| 1211 | command |= MVNETA_TXD_IP_CSUM; | 1211 | command |= MVNETA_TXD_IP_CSUM; |
| 1212 | else | 1212 | else |
| 1213 | command |= MVNETA_TX_L3_IP6; | 1213 | command |= MVNETA_TX_L3_IP6; |
| @@ -2529,7 +2529,7 @@ static void mvneta_adjust_link(struct net_device *ndev) | |||
| 2529 | 2529 | ||
| 2530 | if (phydev->speed == SPEED_1000) | 2530 | if (phydev->speed == SPEED_1000) |
| 2531 | val |= MVNETA_GMAC_CONFIG_GMII_SPEED; | 2531 | val |= MVNETA_GMAC_CONFIG_GMII_SPEED; |
| 2532 | else | 2532 | else if (phydev->speed == SPEED_100) |
| 2533 | val |= MVNETA_GMAC_CONFIG_MII_SPEED; | 2533 | val |= MVNETA_GMAC_CONFIG_MII_SPEED; |
| 2534 | 2534 | ||
| 2535 | mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val); | 2535 | mvreg_write(pp, MVNETA_GMAC_AUTONEG_CONFIG, val); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/cq.c b/drivers/net/ethernet/mellanox/mlx4/cq.c index 80f725228f5b..56022d647837 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/cq.c | |||
| @@ -294,8 +294,6 @@ int mlx4_cq_alloc(struct mlx4_dev *dev, int nent, | |||
| 294 | init_completion(&cq->free); | 294 | init_completion(&cq->free); |
| 295 | 295 | ||
| 296 | cq->irq = priv->eq_table.eq[cq->vector].irq; | 296 | cq->irq = priv->eq_table.eq[cq->vector].irq; |
| 297 | cq->irq_affinity_change = false; | ||
| 298 | |||
| 299 | return 0; | 297 | return 0; |
| 300 | 298 | ||
| 301 | err_radix: | 299 | err_radix: |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_cq.c b/drivers/net/ethernet/mellanox/mlx4/en_cq.c index 4b2130760eed..82322b1c8411 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_cq.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_cq.c | |||
| @@ -128,11 +128,16 @@ int mlx4_en_activate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq, | |||
| 128 | mlx4_warn(mdev, "Failed assigning an EQ to %s, falling back to legacy EQ's\n", | 128 | mlx4_warn(mdev, "Failed assigning an EQ to %s, falling back to legacy EQ's\n", |
| 129 | name); | 129 | name); |
| 130 | } | 130 | } |
| 131 | |||
| 131 | } | 132 | } |
| 132 | } else { | 133 | } else { |
| 133 | cq->vector = (cq->ring + 1 + priv->port) % | 134 | cq->vector = (cq->ring + 1 + priv->port) % |
| 134 | mdev->dev->caps.num_comp_vectors; | 135 | mdev->dev->caps.num_comp_vectors; |
| 135 | } | 136 | } |
| 137 | |||
| 138 | cq->irq_desc = | ||
| 139 | irq_to_desc(mlx4_eq_get_irq(mdev->dev, | ||
| 140 | cq->vector)); | ||
| 136 | } else { | 141 | } else { |
| 137 | /* For TX we use the same irq per | 142 | /* For TX we use the same irq per |
| 138 | ring we assigned for the RX */ | 143 | ring we assigned for the RX */ |
| @@ -187,8 +192,6 @@ void mlx4_en_destroy_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq **pcq) | |||
| 187 | mlx4_en_unmap_buffer(&cq->wqres.buf); | 192 | mlx4_en_unmap_buffer(&cq->wqres.buf); |
| 188 | mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); | 193 | mlx4_free_hwq_res(mdev->dev, &cq->wqres, cq->buf_size); |
| 189 | if (priv->mdev->dev->caps.comp_pool && cq->vector) { | 194 | if (priv->mdev->dev->caps.comp_pool && cq->vector) { |
| 190 | if (!cq->is_tx) | ||
| 191 | irq_set_affinity_hint(cq->mcq.irq, NULL); | ||
| 192 | mlx4_release_eq(priv->mdev->dev, cq->vector); | 195 | mlx4_release_eq(priv->mdev->dev, cq->vector); |
| 193 | } | 196 | } |
| 194 | cq->vector = 0; | 197 | cq->vector = 0; |
| @@ -204,6 +207,7 @@ void mlx4_en_deactivate_cq(struct mlx4_en_priv *priv, struct mlx4_en_cq *cq) | |||
| 204 | if (!cq->is_tx) { | 207 | if (!cq->is_tx) { |
| 205 | napi_hash_del(&cq->napi); | 208 | napi_hash_del(&cq->napi); |
| 206 | synchronize_rcu(); | 209 | synchronize_rcu(); |
| 210 | irq_set_affinity_hint(cq->mcq.irq, NULL); | ||
| 207 | } | 211 | } |
| 208 | netif_napi_del(&cq->napi); | 212 | netif_napi_del(&cq->napi); |
| 209 | 213 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c index fa1a069e14e6..68d763d2d030 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c | |||
| @@ -417,6 +417,8 @@ static int mlx4_en_get_coalesce(struct net_device *dev, | |||
| 417 | 417 | ||
| 418 | coal->tx_coalesce_usecs = priv->tx_usecs; | 418 | coal->tx_coalesce_usecs = priv->tx_usecs; |
| 419 | coal->tx_max_coalesced_frames = priv->tx_frames; | 419 | coal->tx_max_coalesced_frames = priv->tx_frames; |
| 420 | coal->tx_max_coalesced_frames_irq = priv->tx_work_limit; | ||
| 421 | |||
| 420 | coal->rx_coalesce_usecs = priv->rx_usecs; | 422 | coal->rx_coalesce_usecs = priv->rx_usecs; |
| 421 | coal->rx_max_coalesced_frames = priv->rx_frames; | 423 | coal->rx_max_coalesced_frames = priv->rx_frames; |
| 422 | 424 | ||
| @@ -426,6 +428,7 @@ static int mlx4_en_get_coalesce(struct net_device *dev, | |||
| 426 | coal->rx_coalesce_usecs_high = priv->rx_usecs_high; | 428 | coal->rx_coalesce_usecs_high = priv->rx_usecs_high; |
| 427 | coal->rate_sample_interval = priv->sample_interval; | 429 | coal->rate_sample_interval = priv->sample_interval; |
| 428 | coal->use_adaptive_rx_coalesce = priv->adaptive_rx_coal; | 430 | coal->use_adaptive_rx_coalesce = priv->adaptive_rx_coal; |
| 431 | |||
| 429 | return 0; | 432 | return 0; |
| 430 | } | 433 | } |
| 431 | 434 | ||
| @@ -434,6 +437,9 @@ static int mlx4_en_set_coalesce(struct net_device *dev, | |||
| 434 | { | 437 | { |
| 435 | struct mlx4_en_priv *priv = netdev_priv(dev); | 438 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 436 | 439 | ||
| 440 | if (!coal->tx_max_coalesced_frames_irq) | ||
| 441 | return -EINVAL; | ||
| 442 | |||
| 437 | priv->rx_frames = (coal->rx_max_coalesced_frames == | 443 | priv->rx_frames = (coal->rx_max_coalesced_frames == |
| 438 | MLX4_EN_AUTO_CONF) ? | 444 | MLX4_EN_AUTO_CONF) ? |
| 439 | MLX4_EN_RX_COAL_TARGET : | 445 | MLX4_EN_RX_COAL_TARGET : |
| @@ -457,6 +463,7 @@ static int mlx4_en_set_coalesce(struct net_device *dev, | |||
| 457 | priv->rx_usecs_high = coal->rx_coalesce_usecs_high; | 463 | priv->rx_usecs_high = coal->rx_coalesce_usecs_high; |
| 458 | priv->sample_interval = coal->rate_sample_interval; | 464 | priv->sample_interval = coal->rate_sample_interval; |
| 459 | priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce; | 465 | priv->adaptive_rx_coal = coal->use_adaptive_rx_coalesce; |
| 466 | priv->tx_work_limit = coal->tx_max_coalesced_frames_irq; | ||
| 460 | 467 | ||
| 461 | return mlx4_en_moderation_update(priv); | 468 | return mlx4_en_moderation_update(priv); |
| 462 | } | 469 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 7d4fb7bf2593..7345c43b019e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
| @@ -2336,7 +2336,7 @@ static void mlx4_en_add_vxlan_port(struct net_device *dev, | |||
| 2336 | struct mlx4_en_priv *priv = netdev_priv(dev); | 2336 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 2337 | __be16 current_port; | 2337 | __be16 current_port; |
| 2338 | 2338 | ||
| 2339 | if (!(priv->mdev->dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_VXLAN_OFFLOADS)) | 2339 | if (priv->mdev->dev->caps.tunnel_offload_mode != MLX4_TUNNEL_OFFLOAD_MODE_VXLAN) |
| 2340 | return; | 2340 | return; |
| 2341 | 2341 | ||
| 2342 | if (sa_family == AF_INET6) | 2342 | if (sa_family == AF_INET6) |
| @@ -2473,6 +2473,7 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
| 2473 | MLX4_WQE_CTRL_SOLICITED); | 2473 | MLX4_WQE_CTRL_SOLICITED); |
| 2474 | priv->num_tx_rings_p_up = mdev->profile.num_tx_rings_p_up; | 2474 | priv->num_tx_rings_p_up = mdev->profile.num_tx_rings_p_up; |
| 2475 | priv->tx_ring_num = prof->tx_ring_num; | 2475 | priv->tx_ring_num = prof->tx_ring_num; |
| 2476 | priv->tx_work_limit = MLX4_EN_DEFAULT_TX_WORK; | ||
| 2476 | 2477 | ||
| 2477 | priv->tx_ring = kzalloc(sizeof(struct mlx4_en_tx_ring *) * MAX_TX_RINGS, | 2478 | priv->tx_ring = kzalloc(sizeof(struct mlx4_en_tx_ring *) * MAX_TX_RINGS, |
| 2478 | GFP_KERNEL); | 2479 | GFP_KERNEL); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c index d2d415732d99..5535862f27cc 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/if_ether.h> | 40 | #include <linux/if_ether.h> |
| 41 | #include <linux/if_vlan.h> | 41 | #include <linux/if_vlan.h> |
| 42 | #include <linux/vmalloc.h> | 42 | #include <linux/vmalloc.h> |
| 43 | #include <linux/irq.h> | ||
| 43 | 44 | ||
| 44 | #include "mlx4_en.h" | 45 | #include "mlx4_en.h" |
| 45 | 46 | ||
| @@ -782,6 +783,7 @@ int mlx4_en_process_rx_cq(struct net_device *dev, struct mlx4_en_cq *cq, int bud | |||
| 782 | PKT_HASH_TYPE_L3); | 783 | PKT_HASH_TYPE_L3); |
| 783 | 784 | ||
| 784 | skb_record_rx_queue(gro_skb, cq->ring); | 785 | skb_record_rx_queue(gro_skb, cq->ring); |
| 786 | skb_mark_napi_id(gro_skb, &cq->napi); | ||
| 785 | 787 | ||
| 786 | if (ring->hwtstamp_rx_filter == HWTSTAMP_FILTER_ALL) { | 788 | if (ring->hwtstamp_rx_filter == HWTSTAMP_FILTER_ALL) { |
| 787 | timestamp = mlx4_en_get_cqe_ts(cqe); | 789 | timestamp = mlx4_en_get_cqe_ts(cqe); |
| @@ -896,16 +898,25 @@ int mlx4_en_poll_rx_cq(struct napi_struct *napi, int budget) | |||
| 896 | 898 | ||
| 897 | /* If we used up all the quota - we're probably not done yet... */ | 899 | /* If we used up all the quota - we're probably not done yet... */ |
| 898 | if (done == budget) { | 900 | if (done == budget) { |
| 901 | int cpu_curr; | ||
| 902 | const struct cpumask *aff; | ||
| 903 | |||
| 899 | INC_PERF_COUNTER(priv->pstats.napi_quota); | 904 | INC_PERF_COUNTER(priv->pstats.napi_quota); |
| 900 | if (unlikely(cq->mcq.irq_affinity_change)) { | 905 | |
| 901 | cq->mcq.irq_affinity_change = false; | 906 | cpu_curr = smp_processor_id(); |
| 907 | aff = irq_desc_get_irq_data(cq->irq_desc)->affinity; | ||
| 908 | |||
| 909 | if (unlikely(!cpumask_test_cpu(cpu_curr, aff))) { | ||
| 910 | /* Current cpu is not according to smp_irq_affinity - | ||
| 911 | * probably affinity changed. need to stop this NAPI | ||
| 912 | * poll, and restart it on the right CPU | ||
| 913 | */ | ||
| 902 | napi_complete(napi); | 914 | napi_complete(napi); |
| 903 | mlx4_en_arm_cq(priv, cq); | 915 | mlx4_en_arm_cq(priv, cq); |
| 904 | return 0; | 916 | return 0; |
| 905 | } | 917 | } |
| 906 | } else { | 918 | } else { |
| 907 | /* Done for now */ | 919 | /* Done for now */ |
| 908 | cq->mcq.irq_affinity_change = false; | ||
| 909 | napi_complete(napi); | 920 | napi_complete(napi); |
| 910 | mlx4_en_arm_cq(priv, cq); | 921 | mlx4_en_arm_cq(priv, cq); |
| 911 | } | 922 | } |
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 8be7483f8236..5045bab59633 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c | |||
| @@ -351,9 +351,8 @@ int mlx4_en_free_tx_buf(struct net_device *dev, struct mlx4_en_tx_ring *ring) | |||
| 351 | return cnt; | 351 | return cnt; |
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | static int mlx4_en_process_tx_cq(struct net_device *dev, | 354 | static bool mlx4_en_process_tx_cq(struct net_device *dev, |
| 355 | struct mlx4_en_cq *cq, | 355 | struct mlx4_en_cq *cq) |
| 356 | int budget) | ||
| 357 | { | 356 | { |
| 358 | struct mlx4_en_priv *priv = netdev_priv(dev); | 357 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 359 | struct mlx4_cq *mcq = &cq->mcq; | 358 | struct mlx4_cq *mcq = &cq->mcq; |
| @@ -372,9 +371,10 @@ static int mlx4_en_process_tx_cq(struct net_device *dev, | |||
| 372 | int factor = priv->cqe_factor; | 371 | int factor = priv->cqe_factor; |
| 373 | u64 timestamp = 0; | 372 | u64 timestamp = 0; |
| 374 | int done = 0; | 373 | int done = 0; |
| 374 | int budget = priv->tx_work_limit; | ||
| 375 | 375 | ||
| 376 | if (!priv->port_up) | 376 | if (!priv->port_up) |
| 377 | return 0; | 377 | return true; |
| 378 | 378 | ||
| 379 | index = cons_index & size_mask; | 379 | index = cons_index & size_mask; |
| 380 | cqe = &buf[(index << factor) + factor]; | 380 | cqe = &buf[(index << factor) + factor]; |
| @@ -447,7 +447,7 @@ static int mlx4_en_process_tx_cq(struct net_device *dev, | |||
| 447 | netif_tx_wake_queue(ring->tx_queue); | 447 | netif_tx_wake_queue(ring->tx_queue); |
| 448 | ring->wake_queue++; | 448 | ring->wake_queue++; |
| 449 | } | 449 | } |
| 450 | return done; | 450 | return done < budget; |
| 451 | } | 451 | } |
| 452 | 452 | ||
| 453 | void mlx4_en_tx_irq(struct mlx4_cq *mcq) | 453 | void mlx4_en_tx_irq(struct mlx4_cq *mcq) |
| @@ -467,24 +467,16 @@ int mlx4_en_poll_tx_cq(struct napi_struct *napi, int budget) | |||
| 467 | struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi); | 467 | struct mlx4_en_cq *cq = container_of(napi, struct mlx4_en_cq, napi); |
| 468 | struct net_device *dev = cq->dev; | 468 | struct net_device *dev = cq->dev; |
| 469 | struct mlx4_en_priv *priv = netdev_priv(dev); | 469 | struct mlx4_en_priv *priv = netdev_priv(dev); |
| 470 | int done; | 470 | int clean_complete; |
| 471 | 471 | ||
| 472 | done = mlx4_en_process_tx_cq(dev, cq, budget); | 472 | clean_complete = mlx4_en_process_tx_cq(dev, cq); |
| 473 | if (!clean_complete) | ||
| 474 | return budget; | ||
| 473 | 475 | ||
| 474 | /* If we used up all the quota - we're probably not done yet... */ | 476 | napi_complete(napi); |
| 475 | if (done < budget) { | 477 | mlx4_en_arm_cq(priv, cq); |
| 476 | /* Done for now */ | 478 | |
| 477 | cq->mcq.irq_affinity_change = false; | 479 | return 0; |
| 478 | napi_complete(napi); | ||
| 479 | mlx4_en_arm_cq(priv, cq); | ||
| 480 | return done; | ||
| 481 | } else if (unlikely(cq->mcq.irq_affinity_change)) { | ||
| 482 | cq->mcq.irq_affinity_change = false; | ||
| 483 | napi_complete(napi); | ||
| 484 | mlx4_en_arm_cq(priv, cq); | ||
| 485 | return 0; | ||
| 486 | } | ||
| 487 | return budget; | ||
| 488 | } | 480 | } |
| 489 | 481 | ||
| 490 | static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv, | 482 | static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv, |
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c index d954ec1eac17..2a004b347e1d 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c | |||
| @@ -53,11 +53,6 @@ enum { | |||
| 53 | MLX4_EQ_ENTRY_SIZE = 0x20 | 53 | MLX4_EQ_ENTRY_SIZE = 0x20 |
| 54 | }; | 54 | }; |
| 55 | 55 | ||
| 56 | struct mlx4_irq_notify { | ||
| 57 | void *arg; | ||
| 58 | struct irq_affinity_notify notify; | ||
| 59 | }; | ||
| 60 | |||
| 61 | #define MLX4_EQ_STATUS_OK ( 0 << 28) | 56 | #define MLX4_EQ_STATUS_OK ( 0 << 28) |
| 62 | #define MLX4_EQ_STATUS_WRITE_FAIL (10 << 28) | 57 | #define MLX4_EQ_STATUS_WRITE_FAIL (10 << 28) |
| 63 | #define MLX4_EQ_OWNER_SW ( 0 << 24) | 58 | #define MLX4_EQ_OWNER_SW ( 0 << 24) |
| @@ -1088,57 +1083,6 @@ static void mlx4_unmap_clr_int(struct mlx4_dev *dev) | |||
| 1088 | iounmap(priv->clr_base); | 1083 | iounmap(priv->clr_base); |
| 1089 | } | 1084 | } |
| 1090 | 1085 | ||
| 1091 | static void mlx4_irq_notifier_notify(struct irq_affinity_notify *notify, | ||
| 1092 | const cpumask_t *mask) | ||
| 1093 | { | ||
| 1094 | struct mlx4_irq_notify *n = container_of(notify, | ||
| 1095 | struct mlx4_irq_notify, | ||
| 1096 | notify); | ||
| 1097 | struct mlx4_priv *priv = (struct mlx4_priv *)n->arg; | ||
| 1098 | struct radix_tree_iter iter; | ||
| 1099 | void **slot; | ||
| 1100 | |||
| 1101 | radix_tree_for_each_slot(slot, &priv->cq_table.tree, &iter, 0) { | ||
| 1102 | struct mlx4_cq *cq = (struct mlx4_cq *)(*slot); | ||
| 1103 | |||
| 1104 | if (cq->irq == notify->irq) | ||
| 1105 | cq->irq_affinity_change = true; | ||
| 1106 | } | ||
| 1107 | } | ||
| 1108 | |||
| 1109 | static void mlx4_release_irq_notifier(struct kref *ref) | ||
| 1110 | { | ||
| 1111 | struct mlx4_irq_notify *n = container_of(ref, struct mlx4_irq_notify, | ||
| 1112 | notify.kref); | ||
| 1113 | kfree(n); | ||
| 1114 | } | ||
| 1115 | |||
| 1116 | static void mlx4_assign_irq_notifier(struct mlx4_priv *priv, | ||
| 1117 | struct mlx4_dev *dev, int irq) | ||
| 1118 | { | ||
| 1119 | struct mlx4_irq_notify *irq_notifier = NULL; | ||
| 1120 | int err = 0; | ||
| 1121 | |||
| 1122 | irq_notifier = kzalloc(sizeof(*irq_notifier), GFP_KERNEL); | ||
| 1123 | if (!irq_notifier) { | ||
| 1124 | mlx4_warn(dev, "Failed to allocate irq notifier. irq %d\n", | ||
| 1125 | irq); | ||
| 1126 | return; | ||
| 1127 | } | ||
| 1128 | |||
| 1129 | irq_notifier->notify.irq = irq; | ||
| 1130 | irq_notifier->notify.notify = mlx4_irq_notifier_notify; | ||
| 1131 | irq_notifier->notify.release = mlx4_release_irq_notifier; | ||
| 1132 | irq_notifier->arg = priv; | ||
| 1133 | err = irq_set_affinity_notifier(irq, &irq_notifier->notify); | ||
| 1134 | if (err) { | ||
| 1135 | kfree(irq_notifier); | ||
| 1136 | irq_notifier = NULL; | ||
| 1137 | mlx4_warn(dev, "Failed to set irq notifier. irq %d\n", irq); | ||
| 1138 | } | ||
| 1139 | } | ||
| 1140 | |||
| 1141 | |||
| 1142 | int mlx4_alloc_eq_table(struct mlx4_dev *dev) | 1086 | int mlx4_alloc_eq_table(struct mlx4_dev *dev) |
| 1143 | { | 1087 | { |
| 1144 | struct mlx4_priv *priv = mlx4_priv(dev); | 1088 | struct mlx4_priv *priv = mlx4_priv(dev); |
| @@ -1409,8 +1353,6 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char *name, struct cpu_rmap *rmap, | |||
| 1409 | continue; | 1353 | continue; |
| 1410 | /*we dont want to break here*/ | 1354 | /*we dont want to break here*/ |
| 1411 | } | 1355 | } |
| 1412 | mlx4_assign_irq_notifier(priv, dev, | ||
| 1413 | priv->eq_table.eq[vec].irq); | ||
| 1414 | 1356 | ||
| 1415 | eq_set_ci(&priv->eq_table.eq[vec], 1); | 1357 | eq_set_ci(&priv->eq_table.eq[vec], 1); |
| 1416 | } | 1358 | } |
| @@ -1427,6 +1369,14 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char *name, struct cpu_rmap *rmap, | |||
| 1427 | } | 1369 | } |
| 1428 | EXPORT_SYMBOL(mlx4_assign_eq); | 1370 | EXPORT_SYMBOL(mlx4_assign_eq); |
| 1429 | 1371 | ||
| 1372 | int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec) | ||
| 1373 | { | ||
| 1374 | struct mlx4_priv *priv = mlx4_priv(dev); | ||
| 1375 | |||
| 1376 | return priv->eq_table.eq[vec].irq; | ||
| 1377 | } | ||
| 1378 | EXPORT_SYMBOL(mlx4_eq_get_irq); | ||
| 1379 | |||
| 1430 | void mlx4_release_eq(struct mlx4_dev *dev, int vec) | 1380 | void mlx4_release_eq(struct mlx4_dev *dev, int vec) |
| 1431 | { | 1381 | { |
| 1432 | struct mlx4_priv *priv = mlx4_priv(dev); | 1382 | struct mlx4_priv *priv = mlx4_priv(dev); |
| @@ -1438,9 +1388,6 @@ void mlx4_release_eq(struct mlx4_dev *dev, int vec) | |||
| 1438 | Belonging to a legacy EQ*/ | 1388 | Belonging to a legacy EQ*/ |
| 1439 | mutex_lock(&priv->msix_ctl.pool_lock); | 1389 | mutex_lock(&priv->msix_ctl.pool_lock); |
| 1440 | if (priv->msix_ctl.pool_bm & 1ULL << i) { | 1390 | if (priv->msix_ctl.pool_bm & 1ULL << i) { |
| 1441 | irq_set_affinity_notifier( | ||
| 1442 | priv->eq_table.eq[vec].irq, | ||
| 1443 | NULL); | ||
| 1444 | free_irq(priv->eq_table.eq[vec].irq, | 1391 | free_irq(priv->eq_table.eq[vec].irq, |
| 1445 | &priv->eq_table.eq[vec]); | 1392 | &priv->eq_table.eq[vec]); |
| 1446 | priv->msix_ctl.pool_bm &= ~(1ULL << i); | 1393 | priv->msix_ctl.pool_bm &= ~(1ULL << i); |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index 0e15295bedd6..d72a5a894fc6 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | |||
| @@ -126,6 +126,8 @@ enum { | |||
| 126 | #define MAX_TX_RINGS (MLX4_EN_MAX_TX_RING_P_UP * \ | 126 | #define MAX_TX_RINGS (MLX4_EN_MAX_TX_RING_P_UP * \ |
| 127 | MLX4_EN_NUM_UP) | 127 | MLX4_EN_NUM_UP) |
| 128 | 128 | ||
| 129 | #define MLX4_EN_DEFAULT_TX_WORK 256 | ||
| 130 | |||
| 129 | /* Target number of packets to coalesce with interrupt moderation */ | 131 | /* Target number of packets to coalesce with interrupt moderation */ |
| 130 | #define MLX4_EN_RX_COAL_TARGET 44 | 132 | #define MLX4_EN_RX_COAL_TARGET 44 |
| 131 | #define MLX4_EN_RX_COAL_TIME 0x10 | 133 | #define MLX4_EN_RX_COAL_TIME 0x10 |
| @@ -343,6 +345,7 @@ struct mlx4_en_cq { | |||
| 343 | #define CQ_USER_PEND (MLX4_EN_CQ_STATE_POLL | MLX4_EN_CQ_STATE_POLL_YIELD) | 345 | #define CQ_USER_PEND (MLX4_EN_CQ_STATE_POLL | MLX4_EN_CQ_STATE_POLL_YIELD) |
| 344 | spinlock_t poll_lock; /* protects from LLS/napi conflicts */ | 346 | spinlock_t poll_lock; /* protects from LLS/napi conflicts */ |
| 345 | #endif /* CONFIG_NET_RX_BUSY_POLL */ | 347 | #endif /* CONFIG_NET_RX_BUSY_POLL */ |
| 348 | struct irq_desc *irq_desc; | ||
| 346 | }; | 349 | }; |
| 347 | 350 | ||
| 348 | struct mlx4_en_port_profile { | 351 | struct mlx4_en_port_profile { |
| @@ -542,6 +545,7 @@ struct mlx4_en_priv { | |||
| 542 | __be32 ctrl_flags; | 545 | __be32 ctrl_flags; |
| 543 | u32 flags; | 546 | u32 flags; |
| 544 | u8 num_tx_rings_p_up; | 547 | u8 num_tx_rings_p_up; |
| 548 | u32 tx_work_limit; | ||
| 545 | u32 tx_ring_num; | 549 | u32 tx_ring_num; |
| 546 | u32 rx_ring_num; | 550 | u32 rx_ring_num; |
| 547 | u32 rx_skb_size; | 551 | u32 rx_skb_size; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c b/drivers/net/ethernet/mellanox/mlx5/core/mr.c index ba0401d4af50..184c3615f479 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mr.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c | |||
| @@ -94,6 +94,11 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr, | |||
| 94 | write_lock_irq(&table->lock); | 94 | write_lock_irq(&table->lock); |
| 95 | err = radix_tree_insert(&table->tree, mlx5_base_mkey(mr->key), mr); | 95 | err = radix_tree_insert(&table->tree, mlx5_base_mkey(mr->key), mr); |
| 96 | write_unlock_irq(&table->lock); | 96 | write_unlock_irq(&table->lock); |
| 97 | if (err) { | ||
| 98 | mlx5_core_warn(dev, "failed radix tree insert of mr 0x%x, %d\n", | ||
| 99 | mlx5_base_mkey(mr->key), err); | ||
| 100 | mlx5_core_destroy_mkey(dev, mr); | ||
| 101 | } | ||
| 97 | 102 | ||
| 98 | return err; | 103 | return err; |
| 99 | } | 104 | } |
| @@ -104,12 +109,22 @@ int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) | |||
| 104 | struct mlx5_mr_table *table = &dev->priv.mr_table; | 109 | struct mlx5_mr_table *table = &dev->priv.mr_table; |
| 105 | struct mlx5_destroy_mkey_mbox_in in; | 110 | struct mlx5_destroy_mkey_mbox_in in; |
| 106 | struct mlx5_destroy_mkey_mbox_out out; | 111 | struct mlx5_destroy_mkey_mbox_out out; |
| 112 | struct mlx5_core_mr *deleted_mr; | ||
| 107 | unsigned long flags; | 113 | unsigned long flags; |
| 108 | int err; | 114 | int err; |
| 109 | 115 | ||
| 110 | memset(&in, 0, sizeof(in)); | 116 | memset(&in, 0, sizeof(in)); |
| 111 | memset(&out, 0, sizeof(out)); | 117 | memset(&out, 0, sizeof(out)); |
| 112 | 118 | ||
| 119 | write_lock_irqsave(&table->lock, flags); | ||
| 120 | deleted_mr = radix_tree_delete(&table->tree, mlx5_base_mkey(mr->key)); | ||
| 121 | write_unlock_irqrestore(&table->lock, flags); | ||
| 122 | if (!deleted_mr) { | ||
| 123 | mlx5_core_warn(dev, "failed radix tree delete of mr 0x%x\n", | ||
| 124 | mlx5_base_mkey(mr->key)); | ||
| 125 | return -ENOENT; | ||
| 126 | } | ||
| 127 | |||
| 113 | in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_MKEY); | 128 | in.hdr.opcode = cpu_to_be16(MLX5_CMD_OP_DESTROY_MKEY); |
| 114 | in.mkey = cpu_to_be32(mlx5_mkey_to_idx(mr->key)); | 129 | in.mkey = cpu_to_be32(mlx5_mkey_to_idx(mr->key)); |
| 115 | err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); | 130 | err = mlx5_cmd_exec(dev, &in, sizeof(in), &out, sizeof(out)); |
| @@ -119,10 +134,6 @@ int mlx5_core_destroy_mkey(struct mlx5_core_dev *dev, struct mlx5_core_mr *mr) | |||
| 119 | if (out.hdr.status) | 134 | if (out.hdr.status) |
| 120 | return mlx5_cmd_status_to_err(&out.hdr); | 135 | return mlx5_cmd_status_to_err(&out.hdr); |
| 121 | 136 | ||
| 122 | write_lock_irqsave(&table->lock, flags); | ||
| 123 | radix_tree_delete(&table->tree, mlx5_base_mkey(mr->key)); | ||
| 124 | write_unlock_irqrestore(&table->lock, flags); | ||
| 125 | |||
| 126 | return err; | 137 | return err; |
| 127 | } | 138 | } |
| 128 | EXPORT_SYMBOL(mlx5_core_destroy_mkey); | 139 | EXPORT_SYMBOL(mlx5_core_destroy_mkey); |
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c index be425ad5e824..61623e9af574 100644 --- a/drivers/net/ethernet/realtek/r8169.c +++ b/drivers/net/ethernet/realtek/r8169.c | |||
| @@ -538,6 +538,7 @@ enum rtl_register_content { | |||
| 538 | MagicPacket = (1 << 5), /* Wake up when receives a Magic Packet */ | 538 | MagicPacket = (1 << 5), /* Wake up when receives a Magic Packet */ |
| 539 | LinkUp = (1 << 4), /* Wake up when the cable connection is re-established */ | 539 | LinkUp = (1 << 4), /* Wake up when the cable connection is re-established */ |
| 540 | Jumbo_En0 = (1 << 2), /* 8168 only. Reserved in the 8168b */ | 540 | Jumbo_En0 = (1 << 2), /* 8168 only. Reserved in the 8168b */ |
| 541 | Rdy_to_L23 = (1 << 1), /* L23 Enable */ | ||
| 541 | Beacon_en = (1 << 0), /* 8168 only. Reserved in the 8168b */ | 542 | Beacon_en = (1 << 0), /* 8168 only. Reserved in the 8168b */ |
| 542 | 543 | ||
| 543 | /* Config4 register */ | 544 | /* Config4 register */ |
| @@ -4239,6 +4240,8 @@ static void rtl_init_rxcfg(struct rtl8169_private *tp) | |||
| 4239 | RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST); | 4240 | RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST); |
| 4240 | break; | 4241 | break; |
| 4241 | case RTL_GIGA_MAC_VER_40: | 4242 | case RTL_GIGA_MAC_VER_40: |
| 4243 | RTL_W32(RxConfig, RX128_INT_EN | RX_MULTI_EN | RX_DMA_BURST | RX_EARLY_OFF); | ||
| 4244 | break; | ||
| 4242 | case RTL_GIGA_MAC_VER_41: | 4245 | case RTL_GIGA_MAC_VER_41: |
| 4243 | case RTL_GIGA_MAC_VER_42: | 4246 | case RTL_GIGA_MAC_VER_42: |
| 4244 | case RTL_GIGA_MAC_VER_43: | 4247 | case RTL_GIGA_MAC_VER_43: |
| @@ -4897,6 +4900,21 @@ static void rtl_enable_clock_request(struct pci_dev *pdev) | |||
| 4897 | PCI_EXP_LNKCTL_CLKREQ_EN); | 4900 | PCI_EXP_LNKCTL_CLKREQ_EN); |
| 4898 | } | 4901 | } |
| 4899 | 4902 | ||
| 4903 | static void rtl_pcie_state_l2l3_enable(struct rtl8169_private *tp, bool enable) | ||
| 4904 | { | ||
| 4905 | void __iomem *ioaddr = tp->mmio_addr; | ||
| 4906 | u8 data; | ||
| 4907 | |||
| 4908 | data = RTL_R8(Config3); | ||
| 4909 | |||
| 4910 | if (enable) | ||
| 4911 | data |= Rdy_to_L23; | ||
| 4912 | else | ||
| 4913 | data &= ~Rdy_to_L23; | ||
| 4914 | |||
| 4915 | RTL_W8(Config3, data); | ||
| 4916 | } | ||
| 4917 | |||
| 4900 | #define R8168_CPCMD_QUIRK_MASK (\ | 4918 | #define R8168_CPCMD_QUIRK_MASK (\ |
| 4901 | EnableBist | \ | 4919 | EnableBist | \ |
| 4902 | Mac_dbgo_oe | \ | 4920 | Mac_dbgo_oe | \ |
| @@ -5246,6 +5264,7 @@ static void rtl_hw_start_8411(struct rtl8169_private *tp) | |||
| 5246 | }; | 5264 | }; |
| 5247 | 5265 | ||
| 5248 | rtl_hw_start_8168f(tp); | 5266 | rtl_hw_start_8168f(tp); |
| 5267 | rtl_pcie_state_l2l3_enable(tp, false); | ||
| 5249 | 5268 | ||
| 5250 | rtl_ephy_init(tp, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1)); | 5269 | rtl_ephy_init(tp, e_info_8168f_1, ARRAY_SIZE(e_info_8168f_1)); |
| 5251 | 5270 | ||
| @@ -5284,6 +5303,8 @@ static void rtl_hw_start_8168g_1(struct rtl8169_private *tp) | |||
| 5284 | 5303 | ||
| 5285 | rtl_w1w0_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x06, ERIAR_EXGMAC); | 5304 | rtl_w1w0_eri(tp, 0x2fc, ERIAR_MASK_0001, 0x01, 0x06, ERIAR_EXGMAC); |
| 5286 | rtl_w1w0_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC); | 5305 | rtl_w1w0_eri(tp, 0x1b0, ERIAR_MASK_0011, 0x0000, 0x1000, ERIAR_EXGMAC); |
| 5306 | |||
| 5307 | rtl_pcie_state_l2l3_enable(tp, false); | ||
| 5287 | } | 5308 | } |
| 5288 | 5309 | ||
| 5289 | static void rtl_hw_start_8168g_2(struct rtl8169_private *tp) | 5310 | static void rtl_hw_start_8168g_2(struct rtl8169_private *tp) |
| @@ -5536,6 +5557,8 @@ static void rtl_hw_start_8105e_1(struct rtl8169_private *tp) | |||
| 5536 | RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN); | 5557 | RTL_W8(DLLPR, RTL_R8(DLLPR) | PFM_EN); |
| 5537 | 5558 | ||
| 5538 | rtl_ephy_init(tp, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1)); | 5559 | rtl_ephy_init(tp, e_info_8105e_1, ARRAY_SIZE(e_info_8105e_1)); |
| 5560 | |||
| 5561 | rtl_pcie_state_l2l3_enable(tp, false); | ||
| 5539 | } | 5562 | } |
| 5540 | 5563 | ||
| 5541 | static void rtl_hw_start_8105e_2(struct rtl8169_private *tp) | 5564 | static void rtl_hw_start_8105e_2(struct rtl8169_private *tp) |
| @@ -5571,6 +5594,8 @@ static void rtl_hw_start_8402(struct rtl8169_private *tp) | |||
| 5571 | rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); | 5594 | rtl_eri_write(tp, 0xc0, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); |
| 5572 | rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); | 5595 | rtl_eri_write(tp, 0xb8, ERIAR_MASK_0011, 0x0000, ERIAR_EXGMAC); |
| 5573 | rtl_w1w0_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0e00, 0xff00, ERIAR_EXGMAC); | 5596 | rtl_w1w0_eri(tp, 0x0d4, ERIAR_MASK_0011, 0x0e00, 0xff00, ERIAR_EXGMAC); |
| 5597 | |||
| 5598 | rtl_pcie_state_l2l3_enable(tp, false); | ||
| 5574 | } | 5599 | } |
| 5575 | 5600 | ||
| 5576 | static void rtl_hw_start_8106(struct rtl8169_private *tp) | 5601 | static void rtl_hw_start_8106(struct rtl8169_private *tp) |
| @@ -5583,6 +5608,8 @@ static void rtl_hw_start_8106(struct rtl8169_private *tp) | |||
| 5583 | RTL_W32(MISC, (RTL_R32(MISC) | DISABLE_LAN_EN) & ~EARLY_TALLY_EN); | 5608 | RTL_W32(MISC, (RTL_R32(MISC) | DISABLE_LAN_EN) & ~EARLY_TALLY_EN); |
| 5584 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); | 5609 | RTL_W8(MCU, RTL_R8(MCU) | EN_NDP | EN_OOB_RESET); |
| 5585 | RTL_W8(DLLPR, RTL_R8(DLLPR) & ~PFM_EN); | 5610 | RTL_W8(DLLPR, RTL_R8(DLLPR) & ~PFM_EN); |
| 5611 | |||
| 5612 | rtl_pcie_state_l2l3_enable(tp, false); | ||
| 5586 | } | 5613 | } |
| 5587 | 5614 | ||
| 5588 | static void rtl_hw_start_8101(struct net_device *dev) | 5615 | static void rtl_hw_start_8101(struct net_device *dev) |
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c index b3e148ef5683..9d3748361a1e 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000_core.c | |||
| @@ -320,11 +320,8 @@ static void dwmac1000_set_eee_timer(void __iomem *ioaddr, int ls, int tw) | |||
| 320 | 320 | ||
| 321 | static void dwmac1000_ctrl_ane(void __iomem *ioaddr, bool restart) | 321 | static void dwmac1000_ctrl_ane(void __iomem *ioaddr, bool restart) |
| 322 | { | 322 | { |
| 323 | u32 value; | ||
| 324 | |||
| 325 | value = readl(ioaddr + GMAC_AN_CTRL); | ||
| 326 | /* auto negotiation enable and External Loopback enable */ | 323 | /* auto negotiation enable and External Loopback enable */ |
| 327 | value = GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_ELE; | 324 | u32 value = GMAC_AN_CTRL_ANE | GMAC_AN_CTRL_ELE; |
| 328 | 325 | ||
| 329 | if (restart) | 326 | if (restart) |
| 330 | value |= GMAC_AN_CTRL_RAN; | 327 | value |= GMAC_AN_CTRL_RAN; |
diff --git a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c index 7e6628a91514..1e2bcf5f89e1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/enh_desc.c +++ b/drivers/net/ethernet/stmicro/stmmac/enh_desc.c | |||
| @@ -145,7 +145,7 @@ static void enh_desc_get_ext_status(void *data, struct stmmac_extra_stats *x, | |||
| 145 | x->rx_msg_type_delay_req++; | 145 | x->rx_msg_type_delay_req++; |
| 146 | else if (p->des4.erx.msg_type == RDES_EXT_DELAY_RESP) | 146 | else if (p->des4.erx.msg_type == RDES_EXT_DELAY_RESP) |
| 147 | x->rx_msg_type_delay_resp++; | 147 | x->rx_msg_type_delay_resp++; |
| 148 | else if (p->des4.erx.msg_type == RDES_EXT_DELAY_REQ) | 148 | else if (p->des4.erx.msg_type == RDES_EXT_PDELAY_REQ) |
| 149 | x->rx_msg_type_pdelay_req++; | 149 | x->rx_msg_type_pdelay_req++; |
| 150 | else if (p->des4.erx.msg_type == RDES_EXT_PDELAY_RESP) | 150 | else if (p->des4.erx.msg_type == RDES_EXT_PDELAY_RESP) |
| 151 | x->rx_msg_type_pdelay_resp++; | 151 | x->rx_msg_type_pdelay_resp++; |
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c index 1c24a8f368bd..d813bfb1a847 100644 --- a/drivers/net/ethernet/sun/sunvnet.c +++ b/drivers/net/ethernet/sun/sunvnet.c | |||
| @@ -610,6 +610,13 @@ static int __vnet_tx_trigger(struct vnet_port *port) | |||
| 610 | return err; | 610 | return err; |
| 611 | } | 611 | } |
| 612 | 612 | ||
| 613 | static inline bool port_is_up(struct vnet_port *vnet) | ||
| 614 | { | ||
| 615 | struct vio_driver_state *vio = &vnet->vio; | ||
| 616 | |||
| 617 | return !!(vio->hs_state & VIO_HS_COMPLETE); | ||
| 618 | } | ||
| 619 | |||
| 613 | struct vnet_port *__tx_port_find(struct vnet *vp, struct sk_buff *skb) | 620 | struct vnet_port *__tx_port_find(struct vnet *vp, struct sk_buff *skb) |
| 614 | { | 621 | { |
| 615 | unsigned int hash = vnet_hashfn(skb->data); | 622 | unsigned int hash = vnet_hashfn(skb->data); |
| @@ -617,14 +624,19 @@ struct vnet_port *__tx_port_find(struct vnet *vp, struct sk_buff *skb) | |||
| 617 | struct vnet_port *port; | 624 | struct vnet_port *port; |
| 618 | 625 | ||
| 619 | hlist_for_each_entry(port, hp, hash) { | 626 | hlist_for_each_entry(port, hp, hash) { |
| 627 | if (!port_is_up(port)) | ||
| 628 | continue; | ||
| 620 | if (ether_addr_equal(port->raddr, skb->data)) | 629 | if (ether_addr_equal(port->raddr, skb->data)) |
| 621 | return port; | 630 | return port; |
| 622 | } | 631 | } |
| 623 | port = NULL; | 632 | list_for_each_entry(port, &vp->port_list, list) { |
| 624 | if (!list_empty(&vp->port_list)) | 633 | if (!port->switch_port) |
| 625 | port = list_entry(vp->port_list.next, struct vnet_port, list); | 634 | continue; |
| 626 | 635 | if (!port_is_up(port)) | |
| 627 | return port; | 636 | continue; |
| 637 | return port; | ||
| 638 | } | ||
| 639 | return NULL; | ||
| 628 | } | 640 | } |
| 629 | 641 | ||
| 630 | struct vnet_port *tx_port_find(struct vnet *vp, struct sk_buff *skb) | 642 | struct vnet_port *tx_port_find(struct vnet *vp, struct sk_buff *skb) |
| @@ -1083,6 +1095,24 @@ static struct vnet *vnet_find_or_create(const u64 *local_mac) | |||
| 1083 | return vp; | 1095 | return vp; |
| 1084 | } | 1096 | } |
| 1085 | 1097 | ||
| 1098 | static void vnet_cleanup(void) | ||
| 1099 | { | ||
| 1100 | struct vnet *vp; | ||
| 1101 | struct net_device *dev; | ||
| 1102 | |||
| 1103 | mutex_lock(&vnet_list_mutex); | ||
| 1104 | while (!list_empty(&vnet_list)) { | ||
| 1105 | vp = list_first_entry(&vnet_list, struct vnet, list); | ||
| 1106 | list_del(&vp->list); | ||
| 1107 | dev = vp->dev; | ||
| 1108 | /* vio_unregister_driver() should have cleaned up port_list */ | ||
| 1109 | BUG_ON(!list_empty(&vp->port_list)); | ||
| 1110 | unregister_netdev(dev); | ||
| 1111 | free_netdev(dev); | ||
| 1112 | } | ||
| 1113 | mutex_unlock(&vnet_list_mutex); | ||
| 1114 | } | ||
| 1115 | |||
| 1086 | static const char *local_mac_prop = "local-mac-address"; | 1116 | static const char *local_mac_prop = "local-mac-address"; |
| 1087 | 1117 | ||
| 1088 | static struct vnet *vnet_find_parent(struct mdesc_handle *hp, | 1118 | static struct vnet *vnet_find_parent(struct mdesc_handle *hp, |
| @@ -1240,7 +1270,6 @@ static int vnet_port_remove(struct vio_dev *vdev) | |||
| 1240 | 1270 | ||
| 1241 | kfree(port); | 1271 | kfree(port); |
| 1242 | 1272 | ||
| 1243 | unregister_netdev(vp->dev); | ||
| 1244 | } | 1273 | } |
| 1245 | return 0; | 1274 | return 0; |
| 1246 | } | 1275 | } |
| @@ -1268,6 +1297,7 @@ static int __init vnet_init(void) | |||
| 1268 | static void __exit vnet_exit(void) | 1297 | static void __exit vnet_exit(void) |
| 1269 | { | 1298 | { |
| 1270 | vio_unregister_driver(&vnet_port_driver); | 1299 | vio_unregister_driver(&vnet_port_driver); |
| 1300 | vnet_cleanup(); | ||
| 1271 | } | 1301 | } |
| 1272 | 1302 | ||
| 1273 | module_init(vnet_init); | 1303 | module_init(vnet_init); |
diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c index eb78203cd58e..2aa57270838f 100644 --- a/drivers/net/fddi/defxx.c +++ b/drivers/net/fddi/defxx.c | |||
| @@ -291,7 +291,11 @@ static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type); | |||
| 291 | 291 | ||
| 292 | static int dfx_rcv_init(DFX_board_t *bp, int get_buffers); | 292 | static int dfx_rcv_init(DFX_board_t *bp, int get_buffers); |
| 293 | static void dfx_rcv_queue_process(DFX_board_t *bp); | 293 | static void dfx_rcv_queue_process(DFX_board_t *bp); |
| 294 | #ifdef DYNAMIC_BUFFERS | ||
| 294 | static void dfx_rcv_flush(DFX_board_t *bp); | 295 | static void dfx_rcv_flush(DFX_board_t *bp); |
| 296 | #else | ||
| 297 | static inline void dfx_rcv_flush(DFX_board_t *bp) {} | ||
| 298 | #endif | ||
| 295 | 299 | ||
| 296 | static netdev_tx_t dfx_xmt_queue_pkt(struct sk_buff *skb, | 300 | static netdev_tx_t dfx_xmt_queue_pkt(struct sk_buff *skb, |
| 297 | struct net_device *dev); | 301 | struct net_device *dev); |
| @@ -2849,7 +2853,7 @@ static int dfx_hw_dma_uninit(DFX_board_t *bp, PI_UINT32 type) | |||
| 2849 | * Align an sk_buff to a boundary power of 2 | 2853 | * Align an sk_buff to a boundary power of 2 |
| 2850 | * | 2854 | * |
| 2851 | */ | 2855 | */ |
| 2852 | 2856 | #ifdef DYNAMIC_BUFFERS | |
| 2853 | static void my_skb_align(struct sk_buff *skb, int n) | 2857 | static void my_skb_align(struct sk_buff *skb, int n) |
| 2854 | { | 2858 | { |
| 2855 | unsigned long x = (unsigned long)skb->data; | 2859 | unsigned long x = (unsigned long)skb->data; |
| @@ -2859,7 +2863,7 @@ static void my_skb_align(struct sk_buff *skb, int n) | |||
| 2859 | 2863 | ||
| 2860 | skb_reserve(skb, v - x); | 2864 | skb_reserve(skb, v - x); |
| 2861 | } | 2865 | } |
| 2862 | 2866 | #endif | |
| 2863 | 2867 | ||
| 2864 | /* | 2868 | /* |
| 2865 | * ================ | 2869 | * ================ |
| @@ -3074,10 +3078,7 @@ static void dfx_rcv_queue_process( | |||
| 3074 | break; | 3078 | break; |
| 3075 | } | 3079 | } |
| 3076 | else { | 3080 | else { |
| 3077 | #ifndef DYNAMIC_BUFFERS | 3081 | if (!rx_in_place) { |
| 3078 | if (! rx_in_place) | ||
| 3079 | #endif | ||
| 3080 | { | ||
| 3081 | /* Receive buffer allocated, pass receive packet up */ | 3082 | /* Receive buffer allocated, pass receive packet up */ |
| 3082 | 3083 | ||
| 3083 | skb_copy_to_linear_data(skb, | 3084 | skb_copy_to_linear_data(skb, |
| @@ -3453,10 +3454,6 @@ static void dfx_rcv_flush( DFX_board_t *bp ) | |||
| 3453 | } | 3454 | } |
| 3454 | 3455 | ||
| 3455 | } | 3456 | } |
| 3456 | #else | ||
| 3457 | static inline void dfx_rcv_flush( DFX_board_t *bp ) | ||
| 3458 | { | ||
| 3459 | } | ||
| 3460 | #endif /* DYNAMIC_BUFFERS */ | 3457 | #endif /* DYNAMIC_BUFFERS */ |
| 3461 | 3458 | ||
| 3462 | /* | 3459 | /* |
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c index 4ed38eaecea8..d97d5f39a04e 100644 --- a/drivers/net/hyperv/netvsc.c +++ b/drivers/net/hyperv/netvsc.c | |||
| @@ -378,8 +378,10 @@ static int netvsc_init_buf(struct hv_device *device) | |||
| 378 | 378 | ||
| 379 | net_device->send_section_map = | 379 | net_device->send_section_map = |
| 380 | kzalloc(net_device->map_words * sizeof(ulong), GFP_KERNEL); | 380 | kzalloc(net_device->map_words * sizeof(ulong), GFP_KERNEL); |
| 381 | if (net_device->send_section_map == NULL) | 381 | if (net_device->send_section_map == NULL) { |
| 382 | ret = -ENOMEM; | ||
| 382 | goto cleanup; | 383 | goto cleanup; |
| 384 | } | ||
| 383 | 385 | ||
| 384 | goto exit; | 386 | goto exit; |
| 385 | 387 | ||
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 6a999e6814a0..9408157a246c 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c | |||
| @@ -1323,15 +1323,15 @@ static bool dp83640_rxtstamp(struct phy_device *phydev, | |||
| 1323 | { | 1323 | { |
| 1324 | struct dp83640_private *dp83640 = phydev->priv; | 1324 | struct dp83640_private *dp83640 = phydev->priv; |
| 1325 | 1325 | ||
| 1326 | if (!dp83640->hwts_rx_en) | ||
| 1327 | return false; | ||
| 1328 | |||
| 1329 | if (is_status_frame(skb, type)) { | 1326 | if (is_status_frame(skb, type)) { |
| 1330 | decode_status_frame(dp83640, skb); | 1327 | decode_status_frame(dp83640, skb); |
| 1331 | kfree_skb(skb); | 1328 | kfree_skb(skb); |
| 1332 | return true; | 1329 | return true; |
| 1333 | } | 1330 | } |
| 1334 | 1331 | ||
| 1332 | if (!dp83640->hwts_rx_en) | ||
| 1333 | return false; | ||
| 1334 | |||
| 1335 | SKB_PTP_TYPE(skb) = type; | 1335 | SKB_PTP_TYPE(skb) = type; |
| 1336 | skb_queue_tail(&dp83640->rx_queue, skb); | 1336 | skb_queue_tail(&dp83640->rx_queue, skb); |
| 1337 | schedule_work(&dp83640->ts_work); | 1337 | schedule_work(&dp83640->ts_work); |
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 2e58aa54484c..203651ebccb0 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c | |||
| @@ -187,6 +187,50 @@ struct mii_bus *of_mdio_find_bus(struct device_node *mdio_bus_np) | |||
| 187 | return d ? to_mii_bus(d) : NULL; | 187 | return d ? to_mii_bus(d) : NULL; |
| 188 | } | 188 | } |
| 189 | EXPORT_SYMBOL(of_mdio_find_bus); | 189 | EXPORT_SYMBOL(of_mdio_find_bus); |
| 190 | |||
| 191 | /* Walk the list of subnodes of a mdio bus and look for a node that matches the | ||
| 192 | * phy's address with its 'reg' property. If found, set the of_node pointer for | ||
| 193 | * the phy. This allows auto-probed pyh devices to be supplied with information | ||
| 194 | * passed in via DT. | ||
| 195 | */ | ||
| 196 | static void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
| 197 | struct phy_device *phydev) | ||
| 198 | { | ||
| 199 | struct device *dev = &phydev->dev; | ||
| 200 | struct device_node *child; | ||
| 201 | |||
| 202 | if (dev->of_node || !mdio->dev.of_node) | ||
| 203 | return; | ||
| 204 | |||
| 205 | for_each_available_child_of_node(mdio->dev.of_node, child) { | ||
| 206 | int addr; | ||
| 207 | int ret; | ||
| 208 | |||
| 209 | ret = of_property_read_u32(child, "reg", &addr); | ||
| 210 | if (ret < 0) { | ||
| 211 | dev_err(dev, "%s has invalid PHY address\n", | ||
| 212 | child->full_name); | ||
| 213 | continue; | ||
| 214 | } | ||
| 215 | |||
| 216 | /* A PHY must have a reg property in the range [0-31] */ | ||
| 217 | if (addr >= PHY_MAX_ADDR) { | ||
| 218 | dev_err(dev, "%s PHY address %i is too large\n", | ||
| 219 | child->full_name, addr); | ||
| 220 | continue; | ||
| 221 | } | ||
| 222 | |||
| 223 | if (addr == phydev->addr) { | ||
| 224 | dev->of_node = child; | ||
| 225 | return; | ||
| 226 | } | ||
| 227 | } | ||
| 228 | } | ||
| 229 | #else /* !IS_ENABLED(CONFIG_OF_MDIO) */ | ||
| 230 | static inline void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
| 231 | struct phy_device *phydev) | ||
| 232 | { | ||
| 233 | } | ||
| 190 | #endif | 234 | #endif |
| 191 | 235 | ||
| 192 | /** | 236 | /** |
| @@ -211,6 +255,7 @@ int mdiobus_register(struct mii_bus *bus) | |||
| 211 | 255 | ||
| 212 | bus->dev.parent = bus->parent; | 256 | bus->dev.parent = bus->parent; |
| 213 | bus->dev.class = &mdio_bus_class; | 257 | bus->dev.class = &mdio_bus_class; |
| 258 | bus->dev.driver = bus->parent->driver; | ||
| 214 | bus->dev.groups = NULL; | 259 | bus->dev.groups = NULL; |
| 215 | dev_set_name(&bus->dev, "%s", bus->id); | 260 | dev_set_name(&bus->dev, "%s", bus->id); |
| 216 | 261 | ||
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 35d753d22f78..22c57be4dfa0 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
| @@ -355,7 +355,7 @@ int phy_device_register(struct phy_device *phydev) | |||
| 355 | phydev->bus->phy_map[phydev->addr] = phydev; | 355 | phydev->bus->phy_map[phydev->addr] = phydev; |
| 356 | 356 | ||
| 357 | /* Run all of the fixups for this PHY */ | 357 | /* Run all of the fixups for this PHY */ |
| 358 | err = phy_init_hw(phydev); | 358 | err = phy_scan_fixups(phydev); |
| 359 | if (err) { | 359 | if (err) { |
| 360 | pr_err("PHY %d failed to initialize\n", phydev->addr); | 360 | pr_err("PHY %d failed to initialize\n", phydev->addr); |
| 361 | goto out; | 361 | goto out; |
| @@ -575,6 +575,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, | |||
| 575 | u32 flags, phy_interface_t interface) | 575 | u32 flags, phy_interface_t interface) |
| 576 | { | 576 | { |
| 577 | struct device *d = &phydev->dev; | 577 | struct device *d = &phydev->dev; |
| 578 | struct module *bus_module; | ||
| 578 | int err; | 579 | int err; |
| 579 | 580 | ||
| 580 | /* Assume that if there is no driver, that it doesn't | 581 | /* Assume that if there is no driver, that it doesn't |
| @@ -599,6 +600,14 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, | |||
| 599 | return -EBUSY; | 600 | return -EBUSY; |
| 600 | } | 601 | } |
| 601 | 602 | ||
| 603 | /* Increment the bus module reference count */ | ||
| 604 | bus_module = phydev->bus->dev.driver ? | ||
| 605 | phydev->bus->dev.driver->owner : NULL; | ||
| 606 | if (!try_module_get(bus_module)) { | ||
| 607 | dev_err(&dev->dev, "failed to get the bus module\n"); | ||
| 608 | return -EIO; | ||
| 609 | } | ||
| 610 | |||
| 602 | phydev->attached_dev = dev; | 611 | phydev->attached_dev = dev; |
| 603 | dev->phydev = phydev; | 612 | dev->phydev = phydev; |
| 604 | 613 | ||
| @@ -664,6 +673,10 @@ EXPORT_SYMBOL(phy_attach); | |||
| 664 | void phy_detach(struct phy_device *phydev) | 673 | void phy_detach(struct phy_device *phydev) |
| 665 | { | 674 | { |
| 666 | int i; | 675 | int i; |
| 676 | |||
| 677 | if (phydev->bus->dev.driver) | ||
| 678 | module_put(phydev->bus->dev.driver->owner); | ||
| 679 | |||
| 667 | phydev->attached_dev->phydev = NULL; | 680 | phydev->attached_dev->phydev = NULL; |
| 668 | phydev->attached_dev = NULL; | 681 | phydev->attached_dev = NULL; |
| 669 | phy_suspend(phydev); | 682 | phy_suspend(phydev); |
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c index 91d6c1272fcf..d5b77ef3a210 100644 --- a/drivers/net/ppp/ppp_generic.c +++ b/drivers/net/ppp/ppp_generic.c | |||
| @@ -539,7 +539,7 @@ static int get_filter(void __user *arg, struct sock_filter **p) | |||
| 539 | { | 539 | { |
| 540 | struct sock_fprog uprog; | 540 | struct sock_fprog uprog; |
| 541 | struct sock_filter *code = NULL; | 541 | struct sock_filter *code = NULL; |
| 542 | int len, err; | 542 | int len; |
| 543 | 543 | ||
| 544 | if (copy_from_user(&uprog, arg, sizeof(uprog))) | 544 | if (copy_from_user(&uprog, arg, sizeof(uprog))) |
| 545 | return -EFAULT; | 545 | return -EFAULT; |
| @@ -554,12 +554,6 @@ static int get_filter(void __user *arg, struct sock_filter **p) | |||
| 554 | if (IS_ERR(code)) | 554 | if (IS_ERR(code)) |
| 555 | return PTR_ERR(code); | 555 | return PTR_ERR(code); |
| 556 | 556 | ||
| 557 | err = sk_chk_filter(code, uprog.len); | ||
| 558 | if (err) { | ||
| 559 | kfree(code); | ||
| 560 | return err; | ||
| 561 | } | ||
| 562 | |||
| 563 | *p = code; | 557 | *p = code; |
| 564 | return uprog.len; | 558 | return uprog.len; |
| 565 | } | 559 | } |
| @@ -763,10 +757,15 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 763 | }; | 757 | }; |
| 764 | 758 | ||
| 765 | ppp_lock(ppp); | 759 | ppp_lock(ppp); |
| 766 | if (ppp->pass_filter) | 760 | if (ppp->pass_filter) { |
| 767 | sk_unattached_filter_destroy(ppp->pass_filter); | 761 | sk_unattached_filter_destroy(ppp->pass_filter); |
| 768 | err = sk_unattached_filter_create(&ppp->pass_filter, | 762 | ppp->pass_filter = NULL; |
| 769 | &fprog); | 763 | } |
| 764 | if (fprog.filter != NULL) | ||
| 765 | err = sk_unattached_filter_create(&ppp->pass_filter, | ||
| 766 | &fprog); | ||
| 767 | else | ||
| 768 | err = 0; | ||
| 770 | kfree(code); | 769 | kfree(code); |
| 771 | ppp_unlock(ppp); | 770 | ppp_unlock(ppp); |
| 772 | } | 771 | } |
| @@ -784,10 +783,15 @@ static long ppp_ioctl(struct file *file, unsigned int cmd, unsigned long arg) | |||
| 784 | }; | 783 | }; |
| 785 | 784 | ||
| 786 | ppp_lock(ppp); | 785 | ppp_lock(ppp); |
| 787 | if (ppp->active_filter) | 786 | if (ppp->active_filter) { |
| 788 | sk_unattached_filter_destroy(ppp->active_filter); | 787 | sk_unattached_filter_destroy(ppp->active_filter); |
| 789 | err = sk_unattached_filter_create(&ppp->active_filter, | 788 | ppp->active_filter = NULL; |
| 790 | &fprog); | 789 | } |
| 790 | if (fprog.filter != NULL) | ||
| 791 | err = sk_unattached_filter_create(&ppp->active_filter, | ||
| 792 | &fprog); | ||
| 793 | else | ||
| 794 | err = 0; | ||
| 791 | kfree(code); | 795 | kfree(code); |
| 792 | ppp_unlock(ppp); | 796 | ppp_unlock(ppp); |
| 793 | } | 797 | } |
diff --git a/drivers/net/ppp/pppoe.c b/drivers/net/ppp/pppoe.c index 2ea7efd11857..6c9c16d76935 100644 --- a/drivers/net/ppp/pppoe.c +++ b/drivers/net/ppp/pppoe.c | |||
| @@ -675,7 +675,7 @@ static int pppoe_connect(struct socket *sock, struct sockaddr *uservaddr, | |||
| 675 | po->chan.hdrlen = (sizeof(struct pppoe_hdr) + | 675 | po->chan.hdrlen = (sizeof(struct pppoe_hdr) + |
| 676 | dev->hard_header_len); | 676 | dev->hard_header_len); |
| 677 | 677 | ||
| 678 | po->chan.mtu = dev->mtu - sizeof(struct pppoe_hdr); | 678 | po->chan.mtu = dev->mtu - sizeof(struct pppoe_hdr) - 2; |
| 679 | po->chan.private = sk; | 679 | po->chan.private = sk; |
| 680 | po->chan.ops = &pppoe_chan_ops; | 680 | po->chan.ops = &pppoe_chan_ops; |
| 681 | 681 | ||
diff --git a/drivers/net/usb/cdc_ether.c b/drivers/net/usb/cdc_ether.c index 9ea4bfe5d318..2a32d9167d3b 100644 --- a/drivers/net/usb/cdc_ether.c +++ b/drivers/net/usb/cdc_ether.c | |||
| @@ -341,6 +341,22 @@ next_desc: | |||
| 341 | usb_driver_release_interface(driver, info->data); | 341 | usb_driver_release_interface(driver, info->data); |
| 342 | return -ENODEV; | 342 | return -ENODEV; |
| 343 | } | 343 | } |
| 344 | |||
| 345 | /* Some devices don't initialise properly. In particular | ||
| 346 | * the packet filter is not reset. There are devices that | ||
| 347 | * don't do reset all the way. So the packet filter should | ||
| 348 | * be set to a sane initial value. | ||
| 349 | */ | ||
| 350 | usb_control_msg(dev->udev, | ||
| 351 | usb_sndctrlpipe(dev->udev, 0), | ||
| 352 | USB_CDC_SET_ETHERNET_PACKET_FILTER, | ||
| 353 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, | ||
| 354 | USB_CDC_PACKET_TYPE_ALL_MULTICAST | USB_CDC_PACKET_TYPE_DIRECTED | USB_CDC_PACKET_TYPE_BROADCAST, | ||
| 355 | intf->cur_altsetting->desc.bInterfaceNumber, | ||
| 356 | NULL, | ||
| 357 | 0, | ||
| 358 | USB_CTRL_SET_TIMEOUT | ||
| 359 | ); | ||
| 344 | return 0; | 360 | return 0; |
| 345 | 361 | ||
| 346 | bad_desc: | 362 | bad_desc: |
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index a3a05869309d..a4272ed62da8 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
| @@ -258,10 +258,8 @@ struct hso_serial { | |||
| 258 | * so as not to drop characters on the floor. | 258 | * so as not to drop characters on the floor. |
| 259 | */ | 259 | */ |
| 260 | int curr_rx_urb_idx; | 260 | int curr_rx_urb_idx; |
| 261 | u16 curr_rx_urb_offset; | ||
| 262 | u8 rx_urb_filled[MAX_RX_URBS]; | 261 | u8 rx_urb_filled[MAX_RX_URBS]; |
| 263 | struct tasklet_struct unthrottle_tasklet; | 262 | struct tasklet_struct unthrottle_tasklet; |
| 264 | struct work_struct retry_unthrottle_workqueue; | ||
| 265 | }; | 263 | }; |
| 266 | 264 | ||
| 267 | struct hso_device { | 265 | struct hso_device { |
| @@ -1252,14 +1250,6 @@ static void hso_unthrottle(struct tty_struct *tty) | |||
| 1252 | tasklet_hi_schedule(&serial->unthrottle_tasklet); | 1250 | tasklet_hi_schedule(&serial->unthrottle_tasklet); |
| 1253 | } | 1251 | } |
| 1254 | 1252 | ||
| 1255 | static void hso_unthrottle_workfunc(struct work_struct *work) | ||
| 1256 | { | ||
| 1257 | struct hso_serial *serial = | ||
| 1258 | container_of(work, struct hso_serial, | ||
| 1259 | retry_unthrottle_workqueue); | ||
| 1260 | hso_unthrottle_tasklet(serial); | ||
| 1261 | } | ||
| 1262 | |||
| 1263 | /* open the requested serial port */ | 1253 | /* open the requested serial port */ |
| 1264 | static int hso_serial_open(struct tty_struct *tty, struct file *filp) | 1254 | static int hso_serial_open(struct tty_struct *tty, struct file *filp) |
| 1265 | { | 1255 | { |
| @@ -1295,8 +1285,6 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp) | |||
| 1295 | tasklet_init(&serial->unthrottle_tasklet, | 1285 | tasklet_init(&serial->unthrottle_tasklet, |
| 1296 | (void (*)(unsigned long))hso_unthrottle_tasklet, | 1286 | (void (*)(unsigned long))hso_unthrottle_tasklet, |
| 1297 | (unsigned long)serial); | 1287 | (unsigned long)serial); |
| 1298 | INIT_WORK(&serial->retry_unthrottle_workqueue, | ||
| 1299 | hso_unthrottle_workfunc); | ||
| 1300 | result = hso_start_serial_device(serial->parent, GFP_KERNEL); | 1288 | result = hso_start_serial_device(serial->parent, GFP_KERNEL); |
| 1301 | if (result) { | 1289 | if (result) { |
| 1302 | hso_stop_serial_device(serial->parent); | 1290 | hso_stop_serial_device(serial->parent); |
| @@ -1345,7 +1333,6 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp) | |||
| 1345 | if (!usb_gone) | 1333 | if (!usb_gone) |
| 1346 | hso_stop_serial_device(serial->parent); | 1334 | hso_stop_serial_device(serial->parent); |
| 1347 | tasklet_kill(&serial->unthrottle_tasklet); | 1335 | tasklet_kill(&serial->unthrottle_tasklet); |
| 1348 | cancel_work_sync(&serial->retry_unthrottle_workqueue); | ||
| 1349 | } | 1336 | } |
| 1350 | 1337 | ||
| 1351 | if (!usb_gone) | 1338 | if (!usb_gone) |
| @@ -2013,8 +2000,7 @@ static void ctrl_callback(struct urb *urb) | |||
| 2013 | static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) | 2000 | static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) |
| 2014 | { | 2001 | { |
| 2015 | struct tty_struct *tty; | 2002 | struct tty_struct *tty; |
| 2016 | int write_length_remaining = 0; | 2003 | int count; |
| 2017 | int curr_write_len; | ||
| 2018 | 2004 | ||
| 2019 | /* Sanity check */ | 2005 | /* Sanity check */ |
| 2020 | if (urb == NULL || serial == NULL) { | 2006 | if (urb == NULL || serial == NULL) { |
| @@ -2024,29 +2010,28 @@ static int put_rxbuf_data(struct urb *urb, struct hso_serial *serial) | |||
| 2024 | 2010 | ||
| 2025 | tty = tty_port_tty_get(&serial->port); | 2011 | tty = tty_port_tty_get(&serial->port); |
| 2026 | 2012 | ||
| 2013 | if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { | ||
| 2014 | tty_kref_put(tty); | ||
| 2015 | return -1; | ||
| 2016 | } | ||
| 2017 | |||
| 2027 | /* Push data to tty */ | 2018 | /* Push data to tty */ |
| 2028 | write_length_remaining = urb->actual_length - | ||
| 2029 | serial->curr_rx_urb_offset; | ||
| 2030 | D1("data to push to tty"); | 2019 | D1("data to push to tty"); |
| 2031 | while (write_length_remaining) { | 2020 | count = tty_buffer_request_room(&serial->port, urb->actual_length); |
| 2032 | if (tty && test_bit(TTY_THROTTLED, &tty->flags)) { | 2021 | if (count >= urb->actual_length) { |
| 2033 | tty_kref_put(tty); | 2022 | tty_insert_flip_string(&serial->port, urb->transfer_buffer, |
| 2034 | return -1; | 2023 | urb->actual_length); |
| 2035 | } | ||
| 2036 | curr_write_len = tty_insert_flip_string(&serial->port, | ||
| 2037 | urb->transfer_buffer + serial->curr_rx_urb_offset, | ||
| 2038 | write_length_remaining); | ||
| 2039 | serial->curr_rx_urb_offset += curr_write_len; | ||
| 2040 | write_length_remaining -= curr_write_len; | ||
| 2041 | tty_flip_buffer_push(&serial->port); | 2024 | tty_flip_buffer_push(&serial->port); |
| 2025 | } else { | ||
| 2026 | dev_warn(&serial->parent->usb->dev, | ||
| 2027 | "dropping data, %d bytes lost\n", urb->actual_length); | ||
| 2042 | } | 2028 | } |
| 2029 | |||
| 2043 | tty_kref_put(tty); | 2030 | tty_kref_put(tty); |
| 2044 | 2031 | ||
| 2045 | if (write_length_remaining == 0) { | 2032 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; |
| 2046 | serial->curr_rx_urb_offset = 0; | 2033 | |
| 2047 | serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0; | 2034 | return 0; |
| 2048 | } | ||
| 2049 | return write_length_remaining; | ||
| 2050 | } | 2035 | } |
| 2051 | 2036 | ||
| 2052 | 2037 | ||
| @@ -2217,7 +2202,6 @@ static int hso_stop_serial_device(struct hso_device *hso_dev) | |||
| 2217 | } | 2202 | } |
| 2218 | } | 2203 | } |
| 2219 | serial->curr_rx_urb_idx = 0; | 2204 | serial->curr_rx_urb_idx = 0; |
| 2220 | serial->curr_rx_urb_offset = 0; | ||
| 2221 | 2205 | ||
| 2222 | if (serial->tx_urb) | 2206 | if (serial->tx_urb) |
| 2223 | usb_kill_urb(serial->tx_urb); | 2207 | usb_kill_urb(serial->tx_urb); |
diff --git a/drivers/net/usb/huawei_cdc_ncm.c b/drivers/net/usb/huawei_cdc_ncm.c index 5d95a13dbe2a..735f7dadb9a0 100644 --- a/drivers/net/usb/huawei_cdc_ncm.c +++ b/drivers/net/usb/huawei_cdc_ncm.c | |||
| @@ -194,6 +194,9 @@ static const struct usb_device_id huawei_cdc_ncm_devs[] = { | |||
| 194 | { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x76), | 194 | { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x02, 0x76), |
| 195 | .driver_info = (unsigned long)&huawei_cdc_ncm_info, | 195 | .driver_info = (unsigned long)&huawei_cdc_ncm_info, |
| 196 | }, | 196 | }, |
| 197 | { USB_VENDOR_AND_INTERFACE_INFO(0x12d1, 0xff, 0x03, 0x16), | ||
| 198 | .driver_info = (unsigned long)&huawei_cdc_ncm_info, | ||
| 199 | }, | ||
| 197 | 200 | ||
| 198 | /* Terminating entry */ | 201 | /* Terminating entry */ |
| 199 | { | 202 | { |
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c index cf62d7e8329f..22756db53dca 100644 --- a/drivers/net/usb/qmi_wwan.c +++ b/drivers/net/usb/qmi_wwan.c | |||
| @@ -667,6 +667,7 @@ static const struct usb_device_id products[] = { | |||
| 667 | {QMI_FIXED_INTF(0x05c6, 0x9084, 4)}, | 667 | {QMI_FIXED_INTF(0x05c6, 0x9084, 4)}, |
| 668 | {QMI_FIXED_INTF(0x05c6, 0x920d, 0)}, | 668 | {QMI_FIXED_INTF(0x05c6, 0x920d, 0)}, |
| 669 | {QMI_FIXED_INTF(0x05c6, 0x920d, 5)}, | 669 | {QMI_FIXED_INTF(0x05c6, 0x920d, 5)}, |
| 670 | {QMI_FIXED_INTF(0x0846, 0x68a2, 8)}, | ||
| 670 | {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */ | 671 | {QMI_FIXED_INTF(0x12d1, 0x140c, 1)}, /* Huawei E173 */ |
| 671 | {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */ | 672 | {QMI_FIXED_INTF(0x12d1, 0x14ac, 1)}, /* Huawei E1820 */ |
| 672 | {QMI_FIXED_INTF(0x16d8, 0x6003, 0)}, /* CMOTech 6003 */ | 673 | {QMI_FIXED_INTF(0x16d8, 0x6003, 0)}, /* CMOTech 6003 */ |
| @@ -741,6 +742,7 @@ static const struct usb_device_id products[] = { | |||
| 741 | {QMI_FIXED_INTF(0x19d2, 0x1424, 2)}, | 742 | {QMI_FIXED_INTF(0x19d2, 0x1424, 2)}, |
| 742 | {QMI_FIXED_INTF(0x19d2, 0x1425, 2)}, | 743 | {QMI_FIXED_INTF(0x19d2, 0x1425, 2)}, |
| 743 | {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */ | 744 | {QMI_FIXED_INTF(0x19d2, 0x1426, 2)}, /* ZTE MF91 */ |
| 745 | {QMI_FIXED_INTF(0x19d2, 0x1428, 2)}, /* Telewell TW-LTE 4G v2 */ | ||
| 744 | {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ | 746 | {QMI_FIXED_INTF(0x19d2, 0x2002, 4)}, /* ZTE (Vodafone) K3765-Z */ |
| 745 | {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ | 747 | {QMI_FIXED_INTF(0x0f3d, 0x68a2, 8)}, /* Sierra Wireless MC7700 */ |
| 746 | {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ | 748 | {QMI_FIXED_INTF(0x114f, 0x68a2, 8)}, /* Sierra Wireless MC7750 */ |
| @@ -756,6 +758,7 @@ static const struct usb_device_id products[] = { | |||
| 756 | {QMI_FIXED_INTF(0x1199, 0x9054, 8)}, /* Sierra Wireless Modem */ | 758 | {QMI_FIXED_INTF(0x1199, 0x9054, 8)}, /* Sierra Wireless Modem */ |
| 757 | {QMI_FIXED_INTF(0x1199, 0x9055, 8)}, /* Netgear AirCard 341U */ | 759 | {QMI_FIXED_INTF(0x1199, 0x9055, 8)}, /* Netgear AirCard 341U */ |
| 758 | {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */ | 760 | {QMI_FIXED_INTF(0x1199, 0x9056, 8)}, /* Sierra Wireless Modem */ |
| 761 | {QMI_FIXED_INTF(0x1199, 0x9057, 8)}, | ||
| 759 | {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */ | 762 | {QMI_FIXED_INTF(0x1199, 0x9061, 8)}, /* Sierra Wireless Modem */ |
| 760 | {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ | 763 | {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ |
| 761 | {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ | 764 | {QMI_FIXED_INTF(0x1bbb, 0x0203, 2)}, /* Alcatel L800MA */ |
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c index 25431965a625..3eab74c7c554 100644 --- a/drivers/net/usb/r8152.c +++ b/drivers/net/usb/r8152.c | |||
| @@ -282,7 +282,7 @@ | |||
| 282 | /* USB_DEV_STAT */ | 282 | /* USB_DEV_STAT */ |
| 283 | #define STAT_SPEED_MASK 0x0006 | 283 | #define STAT_SPEED_MASK 0x0006 |
| 284 | #define STAT_SPEED_HIGH 0x0000 | 284 | #define STAT_SPEED_HIGH 0x0000 |
| 285 | #define STAT_SPEED_FULL 0x0001 | 285 | #define STAT_SPEED_FULL 0x0002 |
| 286 | 286 | ||
| 287 | /* USB_TX_AGG */ | 287 | /* USB_TX_AGG */ |
| 288 | #define TX_AGG_MAX_THRESHOLD 0x03 | 288 | #define TX_AGG_MAX_THRESHOLD 0x03 |
| @@ -1359,7 +1359,7 @@ static void r8152_csum_workaround(struct r8152 *tp, struct sk_buff *skb, | |||
| 1359 | struct sk_buff_head seg_list; | 1359 | struct sk_buff_head seg_list; |
| 1360 | struct sk_buff *segs, *nskb; | 1360 | struct sk_buff *segs, *nskb; |
| 1361 | 1361 | ||
| 1362 | features &= ~(NETIF_F_IP_CSUM | NETIF_F_SG | NETIF_F_TSO); | 1362 | features &= ~(NETIF_F_SG | NETIF_F_IPV6_CSUM | NETIF_F_TSO6); |
| 1363 | segs = skb_gso_segment(skb, features); | 1363 | segs = skb_gso_segment(skb, features); |
| 1364 | if (IS_ERR(segs) || !segs) | 1364 | if (IS_ERR(segs) || !segs) |
| 1365 | goto drop; | 1365 | goto drop; |
| @@ -2292,9 +2292,8 @@ static void r8152b_exit_oob(struct r8152 *tp) | |||
| 2292 | /* rx share fifo credit full threshold */ | 2292 | /* rx share fifo credit full threshold */ |
| 2293 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_NORMAL); | 2293 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL0, RXFIFO_THR1_NORMAL); |
| 2294 | 2294 | ||
| 2295 | ocp_data = ocp_read_word(tp, MCU_TYPE_USB, USB_DEV_STAT); | 2295 | if (tp->udev->speed == USB_SPEED_FULL || |
| 2296 | ocp_data &= STAT_SPEED_MASK; | 2296 | tp->udev->speed == USB_SPEED_LOW) { |
| 2297 | if (ocp_data == STAT_SPEED_FULL) { | ||
| 2298 | /* rx share fifo credit near full threshold */ | 2297 | /* rx share fifo credit near full threshold */ |
| 2299 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, | 2298 | ocp_write_dword(tp, MCU_TYPE_PLA, PLA_RXFIFO_CTRL1, |
| 2300 | RXFIFO_THR2_FULL); | 2299 | RXFIFO_THR2_FULL); |
| @@ -3204,8 +3203,13 @@ static void rtl8152_get_ethtool_stats(struct net_device *dev, | |||
| 3204 | struct r8152 *tp = netdev_priv(dev); | 3203 | struct r8152 *tp = netdev_priv(dev); |
| 3205 | struct tally_counter tally; | 3204 | struct tally_counter tally; |
| 3206 | 3205 | ||
| 3206 | if (usb_autopm_get_interface(tp->intf) < 0) | ||
| 3207 | return; | ||
| 3208 | |||
| 3207 | generic_ocp_read(tp, PLA_TALLYCNT, sizeof(tally), &tally, MCU_TYPE_PLA); | 3209 | generic_ocp_read(tp, PLA_TALLYCNT, sizeof(tally), &tally, MCU_TYPE_PLA); |
| 3208 | 3210 | ||
| 3211 | usb_autopm_put_interface(tp->intf); | ||
| 3212 | |||
| 3209 | data[0] = le64_to_cpu(tally.tx_packets); | 3213 | data[0] = le64_to_cpu(tally.tx_packets); |
| 3210 | data[1] = le64_to_cpu(tally.rx_packets); | 3214 | data[1] = le64_to_cpu(tally.rx_packets); |
| 3211 | data[2] = le64_to_cpu(tally.tx_errors); | 3215 | data[2] = le64_to_cpu(tally.tx_errors); |
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 424db65e4396..d07bf4cb893f 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
| @@ -1714,6 +1714,18 @@ static int smsc95xx_resume(struct usb_interface *intf) | |||
| 1714 | return ret; | 1714 | return ret; |
| 1715 | } | 1715 | } |
| 1716 | 1716 | ||
| 1717 | static int smsc95xx_reset_resume(struct usb_interface *intf) | ||
| 1718 | { | ||
| 1719 | struct usbnet *dev = usb_get_intfdata(intf); | ||
| 1720 | int ret; | ||
| 1721 | |||
| 1722 | ret = smsc95xx_reset(dev); | ||
| 1723 | if (ret < 0) | ||
| 1724 | return ret; | ||
| 1725 | |||
| 1726 | return smsc95xx_resume(intf); | ||
| 1727 | } | ||
| 1728 | |||
| 1717 | static void smsc95xx_rx_csum_offload(struct sk_buff *skb) | 1729 | static void smsc95xx_rx_csum_offload(struct sk_buff *skb) |
| 1718 | { | 1730 | { |
| 1719 | skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2); | 1731 | skb->csum = *(u16 *)(skb_tail_pointer(skb) - 2); |
| @@ -2004,7 +2016,7 @@ static struct usb_driver smsc95xx_driver = { | |||
| 2004 | .probe = usbnet_probe, | 2016 | .probe = usbnet_probe, |
| 2005 | .suspend = smsc95xx_suspend, | 2017 | .suspend = smsc95xx_suspend, |
| 2006 | .resume = smsc95xx_resume, | 2018 | .resume = smsc95xx_resume, |
| 2007 | .reset_resume = smsc95xx_resume, | 2019 | .reset_resume = smsc95xx_reset_resume, |
| 2008 | .disconnect = usbnet_disconnect, | 2020 | .disconnect = usbnet_disconnect, |
| 2009 | .disable_hub_initiated_lpm = 1, | 2021 | .disable_hub_initiated_lpm = 1, |
| 2010 | .supports_autosuspend = 1, | 2022 | .supports_autosuspend = 1, |
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c index ade33ef82823..9f79192c9aa0 100644 --- a/drivers/net/vxlan.c +++ b/drivers/net/vxlan.c | |||
| @@ -339,7 +339,7 @@ static int vxlan_fdb_info(struct sk_buff *skb, struct vxlan_dev *vxlan, | |||
| 339 | ndm->ndm_state = fdb->state; | 339 | ndm->ndm_state = fdb->state; |
| 340 | ndm->ndm_ifindex = vxlan->dev->ifindex; | 340 | ndm->ndm_ifindex = vxlan->dev->ifindex; |
| 341 | ndm->ndm_flags = fdb->flags; | 341 | ndm->ndm_flags = fdb->flags; |
| 342 | ndm->ndm_type = NDA_DST; | 342 | ndm->ndm_type = RTN_UNICAST; |
| 343 | 343 | ||
| 344 | if (send_eth && nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->eth_addr)) | 344 | if (send_eth && nla_put(skb, NDA_LLADDR, ETH_ALEN, &fdb->eth_addr)) |
| 345 | goto nla_put_failure; | 345 | goto nla_put_failure; |
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 93ace042d0aa..1f041271f7fe 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c | |||
| @@ -2363,7 +2363,7 @@ static char *type_strings[] = { | |||
| 2363 | "FarSync TE1" | 2363 | "FarSync TE1" |
| 2364 | }; | 2364 | }; |
| 2365 | 2365 | ||
| 2366 | static void | 2366 | static int |
| 2367 | fst_init_card(struct fst_card_info *card) | 2367 | fst_init_card(struct fst_card_info *card) |
| 2368 | { | 2368 | { |
| 2369 | int i; | 2369 | int i; |
| @@ -2374,24 +2374,21 @@ fst_init_card(struct fst_card_info *card) | |||
| 2374 | * we'll have to revise it in some way then. | 2374 | * we'll have to revise it in some way then. |
| 2375 | */ | 2375 | */ |
| 2376 | for (i = 0; i < card->nports; i++) { | 2376 | for (i = 0; i < card->nports; i++) { |
| 2377 | err = register_hdlc_device(card->ports[i].dev); | 2377 | err = register_hdlc_device(card->ports[i].dev); |
| 2378 | if (err < 0) { | 2378 | if (err < 0) { |
| 2379 | int j; | ||
| 2380 | pr_err("Cannot register HDLC device for port %d (errno %d)\n", | 2379 | pr_err("Cannot register HDLC device for port %d (errno %d)\n", |
| 2381 | i, -err); | 2380 | i, -err); |
| 2382 | for (j = i; j < card->nports; j++) { | 2381 | while (i--) |
| 2383 | free_netdev(card->ports[j].dev); | 2382 | unregister_hdlc_device(card->ports[i].dev); |
| 2384 | card->ports[j].dev = NULL; | 2383 | return err; |
| 2385 | } | 2384 | } |
| 2386 | card->nports = i; | ||
| 2387 | break; | ||
| 2388 | } | ||
| 2389 | } | 2385 | } |
| 2390 | 2386 | ||
| 2391 | pr_info("%s-%s: %s IRQ%d, %d ports\n", | 2387 | pr_info("%s-%s: %s IRQ%d, %d ports\n", |
| 2392 | port_to_dev(&card->ports[0])->name, | 2388 | port_to_dev(&card->ports[0])->name, |
| 2393 | port_to_dev(&card->ports[card->nports - 1])->name, | 2389 | port_to_dev(&card->ports[card->nports - 1])->name, |
| 2394 | type_strings[card->type], card->irq, card->nports); | 2390 | type_strings[card->type], card->irq, card->nports); |
| 2391 | return 0; | ||
| 2395 | } | 2392 | } |
| 2396 | 2393 | ||
| 2397 | static const struct net_device_ops fst_ops = { | 2394 | static const struct net_device_ops fst_ops = { |
| @@ -2447,15 +2444,12 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2447 | /* Try to enable the device */ | 2444 | /* Try to enable the device */ |
| 2448 | if ((err = pci_enable_device(pdev)) != 0) { | 2445 | if ((err = pci_enable_device(pdev)) != 0) { |
| 2449 | pr_err("Failed to enable card. Err %d\n", -err); | 2446 | pr_err("Failed to enable card. Err %d\n", -err); |
| 2450 | kfree(card); | 2447 | goto enable_fail; |
| 2451 | return err; | ||
| 2452 | } | 2448 | } |
| 2453 | 2449 | ||
| 2454 | if ((err = pci_request_regions(pdev, "FarSync")) !=0) { | 2450 | if ((err = pci_request_regions(pdev, "FarSync")) !=0) { |
| 2455 | pr_err("Failed to allocate regions. Err %d\n", -err); | 2451 | pr_err("Failed to allocate regions. Err %d\n", -err); |
| 2456 | pci_disable_device(pdev); | 2452 | goto regions_fail; |
| 2457 | kfree(card); | ||
| 2458 | return err; | ||
| 2459 | } | 2453 | } |
| 2460 | 2454 | ||
| 2461 | /* Get virtual addresses of memory regions */ | 2455 | /* Get virtual addresses of memory regions */ |
| @@ -2464,30 +2458,21 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2464 | card->phys_ctlmem = pci_resource_start(pdev, 3); | 2458 | card->phys_ctlmem = pci_resource_start(pdev, 3); |
| 2465 | if ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) { | 2459 | if ((card->mem = ioremap(card->phys_mem, FST_MEMSIZE)) == NULL) { |
| 2466 | pr_err("Physical memory remap failed\n"); | 2460 | pr_err("Physical memory remap failed\n"); |
| 2467 | pci_release_regions(pdev); | 2461 | err = -ENODEV; |
| 2468 | pci_disable_device(pdev); | 2462 | goto ioremap_physmem_fail; |
| 2469 | kfree(card); | ||
| 2470 | return -ENODEV; | ||
| 2471 | } | 2463 | } |
| 2472 | if ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) { | 2464 | if ((card->ctlmem = ioremap(card->phys_ctlmem, 0x10)) == NULL) { |
| 2473 | pr_err("Control memory remap failed\n"); | 2465 | pr_err("Control memory remap failed\n"); |
| 2474 | pci_release_regions(pdev); | 2466 | err = -ENODEV; |
| 2475 | pci_disable_device(pdev); | 2467 | goto ioremap_ctlmem_fail; |
| 2476 | iounmap(card->mem); | ||
| 2477 | kfree(card); | ||
| 2478 | return -ENODEV; | ||
| 2479 | } | 2468 | } |
| 2480 | dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); | 2469 | dbg(DBG_PCI, "kernel mem %p, ctlmem %p\n", card->mem, card->ctlmem); |
| 2481 | 2470 | ||
| 2482 | /* Register the interrupt handler */ | 2471 | /* Register the interrupt handler */ |
| 2483 | if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) { | 2472 | if (request_irq(pdev->irq, fst_intr, IRQF_SHARED, FST_DEV_NAME, card)) { |
| 2484 | pr_err("Unable to register interrupt %d\n", card->irq); | 2473 | pr_err("Unable to register interrupt %d\n", card->irq); |
| 2485 | pci_release_regions(pdev); | 2474 | err = -ENODEV; |
| 2486 | pci_disable_device(pdev); | 2475 | goto irq_fail; |
| 2487 | iounmap(card->ctlmem); | ||
| 2488 | iounmap(card->mem); | ||
| 2489 | kfree(card); | ||
| 2490 | return -ENODEV; | ||
| 2491 | } | 2476 | } |
| 2492 | 2477 | ||
| 2493 | /* Record info we need */ | 2478 | /* Record info we need */ |
| @@ -2513,13 +2498,8 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2513 | while (i--) | 2498 | while (i--) |
| 2514 | free_netdev(card->ports[i].dev); | 2499 | free_netdev(card->ports[i].dev); |
| 2515 | pr_err("FarSync: out of memory\n"); | 2500 | pr_err("FarSync: out of memory\n"); |
| 2516 | free_irq(card->irq, card); | 2501 | err = -ENOMEM; |
| 2517 | pci_release_regions(pdev); | 2502 | goto hdlcdev_fail; |
| 2518 | pci_disable_device(pdev); | ||
| 2519 | iounmap(card->ctlmem); | ||
| 2520 | iounmap(card->mem); | ||
| 2521 | kfree(card); | ||
| 2522 | return -ENODEV; | ||
| 2523 | } | 2503 | } |
| 2524 | card->ports[i].dev = dev; | 2504 | card->ports[i].dev = dev; |
| 2525 | card->ports[i].card = card; | 2505 | card->ports[i].card = card; |
| @@ -2565,9 +2545,16 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2565 | pci_set_drvdata(pdev, card); | 2545 | pci_set_drvdata(pdev, card); |
| 2566 | 2546 | ||
| 2567 | /* Remainder of card setup */ | 2547 | /* Remainder of card setup */ |
| 2548 | if (no_of_cards_added >= FST_MAX_CARDS) { | ||
| 2549 | pr_err("FarSync: too many cards\n"); | ||
| 2550 | err = -ENOMEM; | ||
| 2551 | goto card_array_fail; | ||
| 2552 | } | ||
| 2568 | fst_card_array[no_of_cards_added] = card; | 2553 | fst_card_array[no_of_cards_added] = card; |
| 2569 | card->card_no = no_of_cards_added++; /* Record instance and bump it */ | 2554 | card->card_no = no_of_cards_added++; /* Record instance and bump it */ |
| 2570 | fst_init_card(card); | 2555 | err = fst_init_card(card); |
| 2556 | if (err) | ||
| 2557 | goto init_card_fail; | ||
| 2571 | if (card->family == FST_FAMILY_TXU) { | 2558 | if (card->family == FST_FAMILY_TXU) { |
| 2572 | /* | 2559 | /* |
| 2573 | * Allocate a dma buffer for transmit and receives | 2560 | * Allocate a dma buffer for transmit and receives |
| @@ -2577,29 +2564,46 @@ fst_add_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 2577 | &card->rx_dma_handle_card); | 2564 | &card->rx_dma_handle_card); |
| 2578 | if (card->rx_dma_handle_host == NULL) { | 2565 | if (card->rx_dma_handle_host == NULL) { |
| 2579 | pr_err("Could not allocate rx dma buffer\n"); | 2566 | pr_err("Could not allocate rx dma buffer\n"); |
| 2580 | fst_disable_intr(card); | 2567 | err = -ENOMEM; |
| 2581 | pci_release_regions(pdev); | 2568 | goto rx_dma_fail; |
| 2582 | pci_disable_device(pdev); | ||
| 2583 | iounmap(card->ctlmem); | ||
| 2584 | iounmap(card->mem); | ||
| 2585 | kfree(card); | ||
| 2586 | return -ENOMEM; | ||
| 2587 | } | 2569 | } |
| 2588 | card->tx_dma_handle_host = | 2570 | card->tx_dma_handle_host = |
| 2589 | pci_alloc_consistent(card->device, FST_MAX_MTU, | 2571 | pci_alloc_consistent(card->device, FST_MAX_MTU, |
| 2590 | &card->tx_dma_handle_card); | 2572 | &card->tx_dma_handle_card); |
| 2591 | if (card->tx_dma_handle_host == NULL) { | 2573 | if (card->tx_dma_handle_host == NULL) { |
| 2592 | pr_err("Could not allocate tx dma buffer\n"); | 2574 | pr_err("Could not allocate tx dma buffer\n"); |
| 2593 | fst_disable_intr(card); | 2575 | err = -ENOMEM; |
| 2594 | pci_release_regions(pdev); | 2576 | goto tx_dma_fail; |
| 2595 | pci_disable_device(pdev); | ||
| 2596 | iounmap(card->ctlmem); | ||
| 2597 | iounmap(card->mem); | ||
| 2598 | kfree(card); | ||
| 2599 | return -ENOMEM; | ||
| 2600 | } | 2577 | } |
| 2601 | } | 2578 | } |
| 2602 | return 0; /* Success */ | 2579 | return 0; /* Success */ |
| 2580 | |||
| 2581 | tx_dma_fail: | ||
| 2582 | pci_free_consistent(card->device, FST_MAX_MTU, | ||
| 2583 | card->rx_dma_handle_host, | ||
| 2584 | card->rx_dma_handle_card); | ||
| 2585 | rx_dma_fail: | ||
| 2586 | fst_disable_intr(card); | ||
| 2587 | for (i = 0 ; i < card->nports ; i++) | ||
| 2588 | unregister_hdlc_device(card->ports[i].dev); | ||
| 2589 | init_card_fail: | ||
| 2590 | fst_card_array[card->card_no] = NULL; | ||
| 2591 | card_array_fail: | ||
| 2592 | for (i = 0 ; i < card->nports ; i++) | ||
| 2593 | free_netdev(card->ports[i].dev); | ||
| 2594 | hdlcdev_fail: | ||
| 2595 | free_irq(card->irq, card); | ||
| 2596 | irq_fail: | ||
| 2597 | iounmap(card->ctlmem); | ||
| 2598 | ioremap_ctlmem_fail: | ||
| 2599 | iounmap(card->mem); | ||
| 2600 | ioremap_physmem_fail: | ||
| 2601 | pci_release_regions(pdev); | ||
| 2602 | regions_fail: | ||
| 2603 | pci_disable_device(pdev); | ||
| 2604 | enable_fail: | ||
| 2605 | kfree(card); | ||
| 2606 | return err; | ||
| 2603 | } | 2607 | } |
| 2604 | 2608 | ||
| 2605 | /* | 2609 | /* |
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index 5895f1978691..fa9fdfa128c1 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
| @@ -122,8 +122,12 @@ static int x25_asy_change_mtu(struct net_device *dev, int newmtu) | |||
| 122 | { | 122 | { |
| 123 | struct x25_asy *sl = netdev_priv(dev); | 123 | struct x25_asy *sl = netdev_priv(dev); |
| 124 | unsigned char *xbuff, *rbuff; | 124 | unsigned char *xbuff, *rbuff; |
| 125 | int len = 2 * newmtu; | 125 | int len; |
| 126 | 126 | ||
| 127 | if (newmtu > 65534) | ||
| 128 | return -EINVAL; | ||
| 129 | |||
| 130 | len = 2 * newmtu; | ||
| 127 | xbuff = kmalloc(len + 4, GFP_ATOMIC); | 131 | xbuff = kmalloc(len + 4, GFP_ATOMIC); |
| 128 | rbuff = kmalloc(len + 4, GFP_ATOMIC); | 132 | rbuff = kmalloc(len + 4, GFP_ATOMIC); |
| 129 | 133 | ||
diff --git a/drivers/net/wireless/ath/ath10k/core.c b/drivers/net/wireless/ath/ath10k/core.c index 82017f56e661..e6c56c5bb0f6 100644 --- a/drivers/net/wireless/ath/ath10k/core.c +++ b/drivers/net/wireless/ath/ath10k/core.c | |||
| @@ -795,7 +795,11 @@ int ath10k_core_start(struct ath10k *ar) | |||
| 795 | if (status) | 795 | if (status) |
| 796 | goto err_htc_stop; | 796 | goto err_htc_stop; |
| 797 | 797 | ||
| 798 | ar->free_vdev_map = (1 << TARGET_NUM_VDEVS) - 1; | 798 | if (test_bit(ATH10K_FW_FEATURE_WMI_10X, ar->fw_features)) |
| 799 | ar->free_vdev_map = (1 << TARGET_10X_NUM_VDEVS) - 1; | ||
| 800 | else | ||
| 801 | ar->free_vdev_map = (1 << TARGET_NUM_VDEVS) - 1; | ||
| 802 | |||
| 799 | INIT_LIST_HEAD(&ar->arvifs); | 803 | INIT_LIST_HEAD(&ar->arvifs); |
| 800 | 804 | ||
| 801 | if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags)) | 805 | if (!test_bit(ATH10K_FLAG_FIRST_BOOT_DONE, &ar->dev_flags)) |
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 6c102b1312ff..eebc860c3655 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c | |||
| @@ -312,7 +312,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt, | |||
| 312 | int msdu_len, msdu_chaining = 0; | 312 | int msdu_len, msdu_chaining = 0; |
| 313 | struct sk_buff *msdu; | 313 | struct sk_buff *msdu; |
| 314 | struct htt_rx_desc *rx_desc; | 314 | struct htt_rx_desc *rx_desc; |
| 315 | bool corrupted = false; | ||
| 316 | 315 | ||
| 317 | lockdep_assert_held(&htt->rx_ring.lock); | 316 | lockdep_assert_held(&htt->rx_ring.lock); |
| 318 | 317 | ||
| @@ -439,9 +438,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt, | |||
| 439 | last_msdu = __le32_to_cpu(rx_desc->msdu_end.info0) & | 438 | last_msdu = __le32_to_cpu(rx_desc->msdu_end.info0) & |
| 440 | RX_MSDU_END_INFO0_LAST_MSDU; | 439 | RX_MSDU_END_INFO0_LAST_MSDU; |
| 441 | 440 | ||
| 442 | if (msdu_chaining && !last_msdu) | ||
| 443 | corrupted = true; | ||
| 444 | |||
| 445 | if (last_msdu) { | 441 | if (last_msdu) { |
| 446 | msdu->next = NULL; | 442 | msdu->next = NULL; |
| 447 | break; | 443 | break; |
| @@ -457,20 +453,6 @@ static int ath10k_htt_rx_amsdu_pop(struct ath10k_htt *htt, | |||
| 457 | msdu_chaining = -1; | 453 | msdu_chaining = -1; |
| 458 | 454 | ||
| 459 | /* | 455 | /* |
| 460 | * Apparently FW sometimes reports weird chained MSDU sequences with | ||
| 461 | * more than one rx descriptor. This seems like a bug but needs more | ||
| 462 | * analyzing. For the time being fix it by dropping such sequences to | ||
| 463 | * avoid blowing up the host system. | ||
| 464 | */ | ||
| 465 | if (corrupted) { | ||
| 466 | ath10k_warn("failed to pop chained msdus, dropping\n"); | ||
| 467 | ath10k_htt_rx_free_msdu_chain(*head_msdu); | ||
| 468 | *head_msdu = NULL; | ||
| 469 | *tail_msdu = NULL; | ||
| 470 | msdu_chaining = -EINVAL; | ||
| 471 | } | ||
| 472 | |||
| 473 | /* | ||
| 474 | * Don't refill the ring yet. | 456 | * Don't refill the ring yet. |
| 475 | * | 457 | * |
| 476 | * First, the elements popped here are still in use - it is not | 458 | * First, the elements popped here are still in use - it is not |
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 66acb2cbd9df..7c28cb55610b 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c | |||
| @@ -887,6 +887,15 @@ ath_tx_get_tid_subframe(struct ath_softc *sc, struct ath_txq *txq, | |||
| 887 | 887 | ||
| 888 | tx_info = IEEE80211_SKB_CB(skb); | 888 | tx_info = IEEE80211_SKB_CB(skb); |
| 889 | tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT; | 889 | tx_info->flags &= ~IEEE80211_TX_CTL_CLEAR_PS_FILT; |
| 890 | |||
| 891 | /* | ||
| 892 | * No aggregation session is running, but there may be frames | ||
| 893 | * from a previous session or a failed attempt in the queue. | ||
| 894 | * Send them out as normal data frames | ||
| 895 | */ | ||
| 896 | if (!tid->active) | ||
| 897 | tx_info->flags &= ~IEEE80211_TX_CTL_AMPDU; | ||
| 898 | |||
| 890 | if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) { | 899 | if (!(tx_info->flags & IEEE80211_TX_CTL_AMPDU)) { |
| 891 | bf->bf_state.bf_type = 0; | 900 | bf->bf_state.bf_type = 0; |
| 892 | return bf; | 901 | return bf; |
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/usb.c b/drivers/net/wireless/brcm80211/brcmfmac/usb.c index 6db51a666f61..d06fcb05adf2 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/usb.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/usb.c | |||
| @@ -1184,8 +1184,6 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) | |||
| 1184 | bus->bus_priv.usb = bus_pub; | 1184 | bus->bus_priv.usb = bus_pub; |
| 1185 | dev_set_drvdata(dev, bus); | 1185 | dev_set_drvdata(dev, bus); |
| 1186 | bus->ops = &brcmf_usb_bus_ops; | 1186 | bus->ops = &brcmf_usb_bus_ops; |
| 1187 | bus->chip = bus_pub->devid; | ||
| 1188 | bus->chiprev = bus_pub->chiprev; | ||
| 1189 | bus->proto_type = BRCMF_PROTO_BCDC; | 1187 | bus->proto_type = BRCMF_PROTO_BCDC; |
| 1190 | bus->always_use_fws_queue = true; | 1188 | bus->always_use_fws_queue = true; |
| 1191 | 1189 | ||
| @@ -1194,6 +1192,9 @@ static int brcmf_usb_probe_cb(struct brcmf_usbdev_info *devinfo) | |||
| 1194 | if (ret) | 1192 | if (ret) |
| 1195 | goto fail; | 1193 | goto fail; |
| 1196 | } | 1194 | } |
| 1195 | bus->chip = bus_pub->devid; | ||
| 1196 | bus->chiprev = bus_pub->chiprev; | ||
| 1197 | |||
| 1197 | /* request firmware here */ | 1198 | /* request firmware here */ |
| 1198 | brcmf_fw_get_firmwares(dev, 0, brcmf_usb_get_fwname(devinfo), NULL, | 1199 | brcmf_fw_get_firmwares(dev, 0, brcmf_usb_get_fwname(devinfo), NULL, |
| 1199 | brcmf_usb_probe_phase2); | 1200 | brcmf_usb_probe_phase2); |
diff --git a/drivers/net/wireless/iwlwifi/dvm/rxon.c b/drivers/net/wireless/iwlwifi/dvm/rxon.c index ed50de6362ed..6dc5dd3ced44 100644 --- a/drivers/net/wireless/iwlwifi/dvm/rxon.c +++ b/drivers/net/wireless/iwlwifi/dvm/rxon.c | |||
| @@ -1068,13 +1068,6 @@ int iwlagn_commit_rxon(struct iwl_priv *priv, struct iwl_rxon_context *ctx) | |||
| 1068 | /* recalculate basic rates */ | 1068 | /* recalculate basic rates */ |
| 1069 | iwl_calc_basic_rates(priv, ctx); | 1069 | iwl_calc_basic_rates(priv, ctx); |
| 1070 | 1070 | ||
| 1071 | /* | ||
| 1072 | * force CTS-to-self frames protection if RTS-CTS is not preferred | ||
| 1073 | * one aggregation protection method | ||
| 1074 | */ | ||
| 1075 | if (!priv->hw_params.use_rts_for_aggregation) | ||
| 1076 | ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; | ||
| 1077 | |||
| 1078 | if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) || | 1071 | if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) || |
| 1079 | !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK)) | 1072 | !(ctx->staging.flags & RXON_FLG_BAND_24G_MSK)) |
| 1080 | ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; | 1073 | ctx->staging.flags |= RXON_FLG_SHORT_SLOT_MSK; |
| @@ -1480,11 +1473,6 @@ void iwlagn_bss_info_changed(struct ieee80211_hw *hw, | |||
| 1480 | else | 1473 | else |
| 1481 | ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; | 1474 | ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; |
| 1482 | 1475 | ||
| 1483 | if (bss_conf->use_cts_prot) | ||
| 1484 | ctx->staging.flags |= RXON_FLG_SELF_CTS_EN; | ||
| 1485 | else | ||
| 1486 | ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN; | ||
| 1487 | |||
| 1488 | memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); | 1476 | memcpy(ctx->staging.bssid_addr, bss_conf->bssid, ETH_ALEN); |
| 1489 | 1477 | ||
| 1490 | if (vif->type == NL80211_IFTYPE_AP || | 1478 | if (vif->type == NL80211_IFTYPE_AP || |
diff --git a/drivers/net/wireless/iwlwifi/iwl-fw.h b/drivers/net/wireless/iwlwifi/iwl-fw.h index 0aa7c0085c9f..b1a33322b9ba 100644 --- a/drivers/net/wireless/iwlwifi/iwl-fw.h +++ b/drivers/net/wireless/iwlwifi/iwl-fw.h | |||
| @@ -88,6 +88,7 @@ | |||
| 88 | * P2P client interfaces simultaneously if they are in different bindings. | 88 | * P2P client interfaces simultaneously if they are in different bindings. |
| 89 | * @IWL_UCODE_TLV_FLAGS_P2P_BSS_PS_SCM: support power save on BSS station and | 89 | * @IWL_UCODE_TLV_FLAGS_P2P_BSS_PS_SCM: support power save on BSS station and |
| 90 | * P2P client interfaces simultaneously if they are in same bindings. | 90 | * P2P client interfaces simultaneously if they are in same bindings. |
| 91 | * @IWL_UCODE_TLV_FLAGS_UAPSD_SUPPORT: General support for uAPSD | ||
| 91 | * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save | 92 | * @IWL_UCODE_TLV_FLAGS_P2P_PS_UAPSD: P2P client supports uAPSD power save |
| 92 | * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering. | 93 | * @IWL_UCODE_TLV_FLAGS_BCAST_FILTERING: uCode supports broadcast filtering. |
| 93 | * @IWL_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients | 94 | * @IWL_UCODE_TLV_FLAGS_GO_UAPSD: AP/GO interfaces support uAPSD clients |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c index 8b5302777632..8b79081d4885 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c | |||
| @@ -667,10 +667,9 @@ static void iwl_mvm_mac_ctxt_cmd_common(struct iwl_mvm *mvm, | |||
| 667 | if (vif->bss_conf.qos) | 667 | if (vif->bss_conf.qos) |
| 668 | cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA); | 668 | cmd->qos_flags |= cpu_to_le32(MAC_QOS_FLG_UPDATE_EDCA); |
| 669 | 669 | ||
| 670 | if (vif->bss_conf.use_cts_prot) { | 670 | if (vif->bss_conf.use_cts_prot) |
| 671 | cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT); | 671 | cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_TGG_PROTECT); |
| 672 | cmd->protection_flags |= cpu_to_le32(MAC_PROT_FLG_SELF_CTS_EN); | 672 | |
| 673 | } | ||
| 674 | IWL_DEBUG_RATE(mvm, "use_cts_prot %d, ht_operation_mode %d\n", | 673 | IWL_DEBUG_RATE(mvm, "use_cts_prot %d, ht_operation_mode %d\n", |
| 675 | vif->bss_conf.use_cts_prot, | 674 | vif->bss_conf.use_cts_prot, |
| 676 | vif->bss_conf.ht_operation_mode); | 675 | vif->bss_conf.ht_operation_mode); |
| @@ -1073,8 +1072,12 @@ static int iwl_mvm_mac_ctxt_cmd_ap(struct iwl_mvm *mvm, | |||
| 1073 | /* Fill the common data for all mac context types */ | 1072 | /* Fill the common data for all mac context types */ |
| 1074 | iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action); | 1073 | iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action); |
| 1075 | 1074 | ||
| 1076 | /* Also enable probe requests to pass */ | 1075 | /* |
| 1077 | cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST); | 1076 | * pass probe requests and beacons from other APs (needed |
| 1077 | * for ht protection) | ||
| 1078 | */ | ||
| 1079 | cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST | | ||
| 1080 | MAC_FILTER_IN_BEACON); | ||
| 1078 | 1081 | ||
| 1079 | /* Fill the data specific for ap mode */ | 1082 | /* Fill the data specific for ap mode */ |
| 1080 | iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.ap, | 1083 | iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.ap, |
| @@ -1095,6 +1098,13 @@ static int iwl_mvm_mac_ctxt_cmd_go(struct iwl_mvm *mvm, | |||
| 1095 | /* Fill the common data for all mac context types */ | 1098 | /* Fill the common data for all mac context types */ |
| 1096 | iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action); | 1099 | iwl_mvm_mac_ctxt_cmd_common(mvm, vif, &cmd, action); |
| 1097 | 1100 | ||
| 1101 | /* | ||
| 1102 | * pass probe requests and beacons from other APs (needed | ||
| 1103 | * for ht protection) | ||
| 1104 | */ | ||
| 1105 | cmd.filter_flags |= cpu_to_le32(MAC_FILTER_IN_PROBE_REQUEST | | ||
| 1106 | MAC_FILTER_IN_BEACON); | ||
| 1107 | |||
| 1098 | /* Fill the data specific for GO mode */ | 1108 | /* Fill the data specific for GO mode */ |
| 1099 | iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.go.ap, | 1109 | iwl_mvm_mac_ctxt_cmd_fill_ap(mvm, vif, &cmd.go.ap, |
| 1100 | action == FW_CTXT_ACTION_ADD); | 1110 | action == FW_CTXT_ACTION_ADD); |
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c index 7215f5980186..98556d03c1ed 100644 --- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c +++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c | |||
| @@ -1159,8 +1159,12 @@ static void iwl_mvm_bcast_filter_iterator(void *_data, u8 *mac, | |||
| 1159 | 1159 | ||
| 1160 | bcast_mac = &cmd->macs[mvmvif->id]; | 1160 | bcast_mac = &cmd->macs[mvmvif->id]; |
| 1161 | 1161 | ||
| 1162 | /* enable filtering only for associated stations */ | 1162 | /* |
| 1163 | if (vif->type != NL80211_IFTYPE_STATION || !vif->bss_conf.assoc) | 1163 | * enable filtering only for associated stations, but not for P2P |
| 1164 | * Clients | ||
| 1165 | */ | ||
| 1166 | if (vif->type != NL80211_IFTYPE_STATION || vif->p2p || | ||
| 1167 | !vif->bss_conf.assoc) | ||
| 1164 | return; | 1168 | return; |
| 1165 | 1169 | ||
| 1166 | bcast_mac->default_discard = 1; | 1170 | bcast_mac->default_discard = 1; |
| @@ -1237,10 +1241,6 @@ static int iwl_mvm_configure_bcast_filter(struct iwl_mvm *mvm, | |||
| 1237 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING)) | 1241 | if (!(mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_BCAST_FILTERING)) |
| 1238 | return 0; | 1242 | return 0; |
| 1239 | 1243 | ||
| 1240 | /* bcast filtering isn't supported for P2P client */ | ||
| 1241 | if (vif->p2p) | ||
| 1242 | return 0; | ||
| 1243 | |||
| 1244 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) | 1244 | if (!iwl_mvm_bcast_filter_build_cmd(mvm, &cmd)) |
| 1245 | return 0; | 1245 | return 0; |
| 1246 | 1246 | ||
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c index 4b6c7d4bd199..eac2b424f6a0 100644 --- a/drivers/net/wireless/iwlwifi/mvm/scan.c +++ b/drivers/net/wireless/iwlwifi/mvm/scan.c | |||
| @@ -588,9 +588,7 @@ static void iwl_build_scan_cmd(struct iwl_mvm *mvm, | |||
| 588 | struct iwl_scan_offload_cmd *scan, | 588 | struct iwl_scan_offload_cmd *scan, |
| 589 | struct iwl_mvm_scan_params *params) | 589 | struct iwl_mvm_scan_params *params) |
| 590 | { | 590 | { |
| 591 | scan->channel_count = | 591 | scan->channel_count = req->n_channels; |
| 592 | mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels + | ||
| 593 | mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; | ||
| 594 | scan->quiet_time = cpu_to_le16(IWL_ACTIVE_QUIET_TIME); | 592 | scan->quiet_time = cpu_to_le16(IWL_ACTIVE_QUIET_TIME); |
| 595 | scan->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH); | 593 | scan->quiet_plcp_th = cpu_to_le16(IWL_PLCP_QUIET_THRESH); |
| 596 | scan->good_CRC_th = IWL_GOOD_CRC_TH_DEFAULT; | 594 | scan->good_CRC_th = IWL_GOOD_CRC_TH_DEFAULT; |
| @@ -669,61 +667,37 @@ static void iwl_build_channel_cfg(struct iwl_mvm *mvm, | |||
| 669 | struct cfg80211_sched_scan_request *req, | 667 | struct cfg80211_sched_scan_request *req, |
| 670 | struct iwl_scan_channel_cfg *channels, | 668 | struct iwl_scan_channel_cfg *channels, |
| 671 | enum ieee80211_band band, | 669 | enum ieee80211_band band, |
| 672 | int *head, int *tail, | 670 | int *head, |
| 673 | u32 ssid_bitmap, | 671 | u32 ssid_bitmap, |
| 674 | struct iwl_mvm_scan_params *params) | 672 | struct iwl_mvm_scan_params *params) |
| 675 | { | 673 | { |
| 676 | struct ieee80211_supported_band *s_band; | 674 | int i, index = 0; |
| 677 | int n_channels = req->n_channels; | ||
| 678 | int i, j, index = 0; | ||
| 679 | bool partial; | ||
| 680 | 675 | ||
| 681 | /* | 676 | for (i = 0; i < req->n_channels; i++) { |
| 682 | * We have to configure all supported channels, even if we don't want to | 677 | struct ieee80211_channel *chan = req->channels[i]; |
| 683 | * scan on them, but we have to send channels in the order that we want | 678 | |
| 684 | * to scan. So add requested channels to head of the list and others to | 679 | if (chan->band != band) |
| 685 | * the end. | 680 | continue; |
| 686 | */ | 681 | |
| 687 | s_band = &mvm->nvm_data->bands[band]; | 682 | index = *head; |
| 688 | 683 | (*head)++; | |
| 689 | for (i = 0; i < s_band->n_channels && *head <= *tail; i++) { | 684 | |
| 690 | partial = false; | 685 | channels->channel_number[index] = cpu_to_le16(chan->hw_value); |
| 691 | for (j = 0; j < n_channels; j++) | ||
| 692 | if (s_band->channels[i].center_freq == | ||
| 693 | req->channels[j]->center_freq) { | ||
| 694 | index = *head; | ||
| 695 | (*head)++; | ||
| 696 | /* | ||
| 697 | * Channels that came with the request will be | ||
| 698 | * in partial scan . | ||
| 699 | */ | ||
| 700 | partial = true; | ||
| 701 | break; | ||
| 702 | } | ||
| 703 | if (!partial) { | ||
| 704 | index = *tail; | ||
| 705 | (*tail)--; | ||
| 706 | } | ||
| 707 | channels->channel_number[index] = | ||
| 708 | cpu_to_le16(ieee80211_frequency_to_channel( | ||
| 709 | s_band->channels[i].center_freq)); | ||
| 710 | channels->dwell_time[index][0] = params->dwell[band].active; | 686 | channels->dwell_time[index][0] = params->dwell[band].active; |
| 711 | channels->dwell_time[index][1] = params->dwell[band].passive; | 687 | channels->dwell_time[index][1] = params->dwell[band].passive; |
| 712 | 688 | ||
| 713 | channels->iter_count[index] = cpu_to_le16(1); | 689 | channels->iter_count[index] = cpu_to_le16(1); |
| 714 | channels->iter_interval[index] = 0; | 690 | channels->iter_interval[index] = 0; |
| 715 | 691 | ||
| 716 | if (!(s_band->channels[i].flags & IEEE80211_CHAN_NO_IR)) | 692 | if (!(chan->flags & IEEE80211_CHAN_NO_IR)) |
| 717 | channels->type[index] |= | 693 | channels->type[index] |= |
| 718 | cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE); | 694 | cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_ACTIVE); |
| 719 | 695 | ||
| 720 | channels->type[index] |= | 696 | channels->type[index] |= |
| 721 | cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_FULL); | 697 | cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_FULL | |
| 722 | if (partial) | 698 | IWL_SCAN_OFFLOAD_CHANNEL_PARTIAL); |
| 723 | channels->type[index] |= | ||
| 724 | cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_PARTIAL); | ||
| 725 | 699 | ||
| 726 | if (s_band->channels[i].flags & IEEE80211_CHAN_NO_HT40) | 700 | if (chan->flags & IEEE80211_CHAN_NO_HT40) |
| 727 | channels->type[index] |= | 701 | channels->type[index] |= |
| 728 | cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_NARROW); | 702 | cpu_to_le32(IWL_SCAN_OFFLOAD_CHANNEL_NARROW); |
| 729 | 703 | ||
| @@ -740,7 +714,6 @@ int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm, | |||
| 740 | int band_2ghz = mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels; | 714 | int band_2ghz = mvm->nvm_data->bands[IEEE80211_BAND_2GHZ].n_channels; |
| 741 | int band_5ghz = mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; | 715 | int band_5ghz = mvm->nvm_data->bands[IEEE80211_BAND_5GHZ].n_channels; |
| 742 | int head = 0; | 716 | int head = 0; |
| 743 | int tail = band_2ghz + band_5ghz - 1; | ||
| 744 | u32 ssid_bitmap; | 717 | u32 ssid_bitmap; |
| 745 | int cmd_len; | 718 | int cmd_len; |
| 746 | int ret; | 719 | int ret; |
| @@ -772,7 +745,7 @@ int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm, | |||
| 772 | &scan_cfg->scan_cmd.tx_cmd[0], | 745 | &scan_cfg->scan_cmd.tx_cmd[0], |
| 773 | scan_cfg->data); | 746 | scan_cfg->data); |
| 774 | iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg, | 747 | iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg, |
| 775 | IEEE80211_BAND_2GHZ, &head, &tail, | 748 | IEEE80211_BAND_2GHZ, &head, |
| 776 | ssid_bitmap, ¶ms); | 749 | ssid_bitmap, ¶ms); |
| 777 | } | 750 | } |
| 778 | if (band_5ghz) { | 751 | if (band_5ghz) { |
| @@ -782,7 +755,7 @@ int iwl_mvm_config_sched_scan(struct iwl_mvm *mvm, | |||
| 782 | scan_cfg->data + | 755 | scan_cfg->data + |
| 783 | SCAN_OFFLOAD_PROBE_REQ_SIZE); | 756 | SCAN_OFFLOAD_PROBE_REQ_SIZE); |
| 784 | iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg, | 757 | iwl_build_channel_cfg(mvm, req, &scan_cfg->channel_cfg, |
| 785 | IEEE80211_BAND_5GHZ, &head, &tail, | 758 | IEEE80211_BAND_5GHZ, &head, |
| 786 | ssid_bitmap, ¶ms); | 759 | ssid_bitmap, ¶ms); |
| 787 | } | 760 | } |
| 788 | 761 | ||
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c index 7091a18d5a72..98950e45c7b0 100644 --- a/drivers/net/wireless/iwlwifi/pcie/drv.c +++ b/drivers/net/wireless/iwlwifi/pcie/drv.c | |||
| @@ -367,6 +367,7 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { | |||
| 367 | {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)}, | 367 | {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)}, |
| 368 | {IWL_PCI_DEVICE(0x095A, 0x5412, iwl7265_2ac_cfg)}, | 368 | {IWL_PCI_DEVICE(0x095A, 0x5412, iwl7265_2ac_cfg)}, |
| 369 | {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)}, | 369 | {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)}, |
| 370 | {IWL_PCI_DEVICE(0x095A, 0x5510, iwl7265_2ac_cfg)}, | ||
| 370 | {IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)}, | 371 | {IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)}, |
| 371 | {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)}, | 372 | {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)}, |
| 372 | {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)}, | 373 | {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)}, |
| @@ -380,7 +381,7 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { | |||
| 380 | {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)}, | 381 | {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)}, |
| 381 | {IWL_PCI_DEVICE(0x095A, 0x9112, iwl7265_2ac_cfg)}, | 382 | {IWL_PCI_DEVICE(0x095A, 0x9112, iwl7265_2ac_cfg)}, |
| 382 | {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)}, | 383 | {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)}, |
| 383 | {IWL_PCI_DEVICE(0x095A, 0x9200, iwl7265_2ac_cfg)}, | 384 | {IWL_PCI_DEVICE(0x095B, 0x9200, iwl7265_2ac_cfg)}, |
| 384 | {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)}, | 385 | {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)}, |
| 385 | {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)}, | 386 | {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)}, |
| 386 | {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)}, | 387 | {IWL_PCI_DEVICE(0x095A, 0x9410, iwl7265_2ac_cfg)}, |
diff --git a/drivers/net/wireless/mwifiex/11n_aggr.c b/drivers/net/wireless/mwifiex/11n_aggr.c index 5b32106182f8..fe0f66f73507 100644 --- a/drivers/net/wireless/mwifiex/11n_aggr.c +++ b/drivers/net/wireless/mwifiex/11n_aggr.c | |||
| @@ -185,6 +185,7 @@ mwifiex_11n_aggregate_pkt(struct mwifiex_private *priv, | |||
| 185 | skb_reserve(skb_aggr, headroom + sizeof(struct txpd)); | 185 | skb_reserve(skb_aggr, headroom + sizeof(struct txpd)); |
| 186 | tx_info_aggr = MWIFIEX_SKB_TXCB(skb_aggr); | 186 | tx_info_aggr = MWIFIEX_SKB_TXCB(skb_aggr); |
| 187 | 187 | ||
| 188 | memset(tx_info_aggr, 0, sizeof(*tx_info_aggr)); | ||
| 188 | tx_info_aggr->bss_type = tx_info_src->bss_type; | 189 | tx_info_aggr->bss_type = tx_info_src->bss_type; |
| 189 | tx_info_aggr->bss_num = tx_info_src->bss_num; | 190 | tx_info_aggr->bss_num = tx_info_src->bss_num; |
| 190 | 191 | ||
diff --git a/drivers/net/wireless/mwifiex/cfg80211.c b/drivers/net/wireless/mwifiex/cfg80211.c index e95dec91a561..b511613bba2d 100644 --- a/drivers/net/wireless/mwifiex/cfg80211.c +++ b/drivers/net/wireless/mwifiex/cfg80211.c | |||
| @@ -220,6 +220,7 @@ mwifiex_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev *wdev, | |||
| 220 | } | 220 | } |
| 221 | 221 | ||
| 222 | tx_info = MWIFIEX_SKB_TXCB(skb); | 222 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 223 | memset(tx_info, 0, sizeof(*tx_info)); | ||
| 223 | tx_info->bss_num = priv->bss_num; | 224 | tx_info->bss_num = priv->bss_num; |
| 224 | tx_info->bss_type = priv->bss_type; | 225 | tx_info->bss_type = priv->bss_type; |
| 225 | tx_info->pkt_len = pkt_len; | 226 | tx_info->pkt_len = pkt_len; |
diff --git a/drivers/net/wireless/mwifiex/cmdevt.c b/drivers/net/wireless/mwifiex/cmdevt.c index 8dee6c86f4f1..c161141f6c39 100644 --- a/drivers/net/wireless/mwifiex/cmdevt.c +++ b/drivers/net/wireless/mwifiex/cmdevt.c | |||
| @@ -453,6 +453,7 @@ int mwifiex_process_event(struct mwifiex_adapter *adapter) | |||
| 453 | 453 | ||
| 454 | if (skb) { | 454 | if (skb) { |
| 455 | rx_info = MWIFIEX_SKB_RXCB(skb); | 455 | rx_info = MWIFIEX_SKB_RXCB(skb); |
| 456 | memset(rx_info, 0, sizeof(*rx_info)); | ||
| 456 | rx_info->bss_num = priv->bss_num; | 457 | rx_info->bss_num = priv->bss_num; |
| 457 | rx_info->bss_type = priv->bss_type; | 458 | rx_info->bss_type = priv->bss_type; |
| 458 | } | 459 | } |
diff --git a/drivers/net/wireless/mwifiex/main.c b/drivers/net/wireless/mwifiex/main.c index cbabc12fbda3..e91cd0fa5ca8 100644 --- a/drivers/net/wireless/mwifiex/main.c +++ b/drivers/net/wireless/mwifiex/main.c | |||
| @@ -645,6 +645,7 @@ mwifiex_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
| 645 | } | 645 | } |
| 646 | 646 | ||
| 647 | tx_info = MWIFIEX_SKB_TXCB(skb); | 647 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 648 | memset(tx_info, 0, sizeof(*tx_info)); | ||
| 648 | tx_info->bss_num = priv->bss_num; | 649 | tx_info->bss_num = priv->bss_num; |
| 649 | tx_info->bss_type = priv->bss_type; | 650 | tx_info->bss_type = priv->bss_type; |
| 650 | tx_info->pkt_len = skb->len; | 651 | tx_info->pkt_len = skb->len; |
diff --git a/drivers/net/wireless/mwifiex/sta_tx.c b/drivers/net/wireless/mwifiex/sta_tx.c index 5fce7e78a36e..70eb863c7249 100644 --- a/drivers/net/wireless/mwifiex/sta_tx.c +++ b/drivers/net/wireless/mwifiex/sta_tx.c | |||
| @@ -150,6 +150,7 @@ int mwifiex_send_null_packet(struct mwifiex_private *priv, u8 flags) | |||
| 150 | return -1; | 150 | return -1; |
| 151 | 151 | ||
| 152 | tx_info = MWIFIEX_SKB_TXCB(skb); | 152 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 153 | memset(tx_info, 0, sizeof(*tx_info)); | ||
| 153 | tx_info->bss_num = priv->bss_num; | 154 | tx_info->bss_num = priv->bss_num; |
| 154 | tx_info->bss_type = priv->bss_type; | 155 | tx_info->bss_type = priv->bss_type; |
| 155 | tx_info->pkt_len = data_len - (sizeof(struct txpd) + INTF_HEADER_LEN); | 156 | tx_info->pkt_len = data_len - (sizeof(struct txpd) + INTF_HEADER_LEN); |
diff --git a/drivers/net/wireless/mwifiex/tdls.c b/drivers/net/wireless/mwifiex/tdls.c index e73034fbbde9..0e88364e0c67 100644 --- a/drivers/net/wireless/mwifiex/tdls.c +++ b/drivers/net/wireless/mwifiex/tdls.c | |||
| @@ -605,6 +605,7 @@ int mwifiex_send_tdls_data_frame(struct mwifiex_private *priv, const u8 *peer, | |||
| 605 | } | 605 | } |
| 606 | 606 | ||
| 607 | tx_info = MWIFIEX_SKB_TXCB(skb); | 607 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 608 | memset(tx_info, 0, sizeof(*tx_info)); | ||
| 608 | tx_info->bss_num = priv->bss_num; | 609 | tx_info->bss_num = priv->bss_num; |
| 609 | tx_info->bss_type = priv->bss_type; | 610 | tx_info->bss_type = priv->bss_type; |
| 610 | 611 | ||
| @@ -760,6 +761,7 @@ int mwifiex_send_tdls_action_frame(struct mwifiex_private *priv, const u8 *peer, | |||
| 760 | skb->priority = MWIFIEX_PRIO_VI; | 761 | skb->priority = MWIFIEX_PRIO_VI; |
| 761 | 762 | ||
| 762 | tx_info = MWIFIEX_SKB_TXCB(skb); | 763 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 764 | memset(tx_info, 0, sizeof(*tx_info)); | ||
| 763 | tx_info->bss_num = priv->bss_num; | 765 | tx_info->bss_num = priv->bss_num; |
| 764 | tx_info->bss_type = priv->bss_type; | 766 | tx_info->bss_type = priv->bss_type; |
| 765 | tx_info->flags |= MWIFIEX_BUF_FLAG_TDLS_PKT; | 767 | tx_info->flags |= MWIFIEX_BUF_FLAG_TDLS_PKT; |
diff --git a/drivers/net/wireless/mwifiex/txrx.c b/drivers/net/wireless/mwifiex/txrx.c index 37f26afd4314..fd7e5b9b4581 100644 --- a/drivers/net/wireless/mwifiex/txrx.c +++ b/drivers/net/wireless/mwifiex/txrx.c | |||
| @@ -55,6 +55,7 @@ int mwifiex_handle_rx_packet(struct mwifiex_adapter *adapter, | |||
| 55 | return -1; | 55 | return -1; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | memset(rx_info, 0, sizeof(*rx_info)); | ||
| 58 | rx_info->bss_num = priv->bss_num; | 59 | rx_info->bss_num = priv->bss_num; |
| 59 | rx_info->bss_type = priv->bss_type; | 60 | rx_info->bss_type = priv->bss_type; |
| 60 | 61 | ||
diff --git a/drivers/net/wireless/mwifiex/uap_txrx.c b/drivers/net/wireless/mwifiex/uap_txrx.c index 9a56bc61cb1d..b0601b91cc4f 100644 --- a/drivers/net/wireless/mwifiex/uap_txrx.c +++ b/drivers/net/wireless/mwifiex/uap_txrx.c | |||
| @@ -175,6 +175,7 @@ static void mwifiex_uap_queue_bridged_pkt(struct mwifiex_private *priv, | |||
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | tx_info = MWIFIEX_SKB_TXCB(skb); | 177 | tx_info = MWIFIEX_SKB_TXCB(skb); |
| 178 | memset(tx_info, 0, sizeof(*tx_info)); | ||
| 178 | tx_info->bss_num = priv->bss_num; | 179 | tx_info->bss_num = priv->bss_num; |
| 179 | tx_info->bss_type = priv->bss_type; | 180 | tx_info->bss_type = priv->bss_type; |
| 180 | tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT; | 181 | tx_info->flags |= MWIFIEX_BUF_FLAG_BRIDGED_PKT; |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index e11dab2216c6..832006b5aab1 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
| @@ -231,9 +231,12 @@ static enum hrtimer_restart rt2800usb_tx_sta_fifo_timeout(struct hrtimer *timer) | |||
| 231 | */ | 231 | */ |
| 232 | static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev) | 232 | static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev) |
| 233 | { | 233 | { |
| 234 | __le32 reg; | 234 | __le32 *reg; |
| 235 | u32 fw_mode; | 235 | u32 fw_mode; |
| 236 | 236 | ||
| 237 | reg = kmalloc(sizeof(*reg), GFP_KERNEL); | ||
| 238 | if (reg == NULL) | ||
| 239 | return -ENOMEM; | ||
| 237 | /* cannot use rt2x00usb_register_read here as it uses different | 240 | /* cannot use rt2x00usb_register_read here as it uses different |
| 238 | * mode (MULTI_READ vs. DEVICE_MODE) and does not pass the | 241 | * mode (MULTI_READ vs. DEVICE_MODE) and does not pass the |
| 239 | * magic value USB_MODE_AUTORUN (0x11) to the device, thus the | 242 | * magic value USB_MODE_AUTORUN (0x11) to the device, thus the |
| @@ -241,8 +244,9 @@ static int rt2800usb_autorun_detect(struct rt2x00_dev *rt2x00dev) | |||
| 241 | */ | 244 | */ |
| 242 | rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE, | 245 | rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE, |
| 243 | USB_VENDOR_REQUEST_IN, 0, USB_MODE_AUTORUN, | 246 | USB_VENDOR_REQUEST_IN, 0, USB_MODE_AUTORUN, |
| 244 | ®, sizeof(reg), REGISTER_TIMEOUT_FIRMWARE); | 247 | reg, sizeof(*reg), REGISTER_TIMEOUT_FIRMWARE); |
| 245 | fw_mode = le32_to_cpu(reg); | 248 | fw_mode = le32_to_cpu(*reg); |
| 249 | kfree(reg); | ||
| 246 | 250 | ||
| 247 | if ((fw_mode & 0x00000003) == 2) | 251 | if ((fw_mode & 0x00000003) == 2) |
| 248 | return 1; | 252 | return 1; |
| @@ -261,6 +265,7 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev, | |||
| 261 | int status; | 265 | int status; |
| 262 | u32 offset; | 266 | u32 offset; |
| 263 | u32 length; | 267 | u32 length; |
| 268 | int retval; | ||
| 264 | 269 | ||
| 265 | /* | 270 | /* |
| 266 | * Check which section of the firmware we need. | 271 | * Check which section of the firmware we need. |
| @@ -278,7 +283,10 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev, | |||
| 278 | /* | 283 | /* |
| 279 | * Write firmware to device. | 284 | * Write firmware to device. |
| 280 | */ | 285 | */ |
| 281 | if (rt2800usb_autorun_detect(rt2x00dev)) { | 286 | retval = rt2800usb_autorun_detect(rt2x00dev); |
| 287 | if (retval < 0) | ||
| 288 | return retval; | ||
| 289 | if (retval) { | ||
| 282 | rt2x00_info(rt2x00dev, | 290 | rt2x00_info(rt2x00dev, |
| 283 | "Firmware loading not required - NIC in AutoRun mode\n"); | 291 | "Firmware loading not required - NIC in AutoRun mode\n"); |
| 284 | } else { | 292 | } else { |
| @@ -763,7 +771,12 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry, | |||
| 763 | */ | 771 | */ |
| 764 | static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev) | 772 | static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev) |
| 765 | { | 773 | { |
| 766 | if (rt2800usb_autorun_detect(rt2x00dev)) | 774 | int retval; |
| 775 | |||
| 776 | retval = rt2800usb_autorun_detect(rt2x00dev); | ||
| 777 | if (retval < 0) | ||
| 778 | return retval; | ||
| 779 | if (retval) | ||
| 767 | return 1; | 780 | return 1; |
| 768 | return rt2800_efuse_detect(rt2x00dev); | 781 | return rt2800_efuse_detect(rt2x00dev); |
| 769 | } | 782 | } |
| @@ -772,7 +785,10 @@ static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev) | |||
| 772 | { | 785 | { |
| 773 | int retval; | 786 | int retval; |
| 774 | 787 | ||
| 775 | if (rt2800usb_efuse_detect(rt2x00dev)) | 788 | retval = rt2800usb_efuse_detect(rt2x00dev); |
| 789 | if (retval < 0) | ||
| 790 | return retval; | ||
| 791 | if (retval) | ||
| 776 | retval = rt2800_read_eeprom_efuse(rt2x00dev); | 792 | retval = rt2800_read_eeprom_efuse(rt2x00dev); |
| 777 | else | 793 | else |
| 778 | retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, | 794 | retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom, |
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c index 1844a47636b6..c65b636bcab9 100644 --- a/drivers/net/xen-netback/netback.c +++ b/drivers/net/xen-netback/netback.c | |||
| @@ -1030,14 +1030,21 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, | |||
| 1030 | { | 1030 | { |
| 1031 | struct gnttab_map_grant_ref *gop_map = *gopp_map; | 1031 | struct gnttab_map_grant_ref *gop_map = *gopp_map; |
| 1032 | u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; | 1032 | u16 pending_idx = XENVIF_TX_CB(skb)->pending_idx; |
| 1033 | /* This always points to the shinfo of the skb being checked, which | ||
| 1034 | * could be either the first or the one on the frag_list | ||
| 1035 | */ | ||
| 1033 | struct skb_shared_info *shinfo = skb_shinfo(skb); | 1036 | struct skb_shared_info *shinfo = skb_shinfo(skb); |
| 1037 | /* If this is non-NULL, we are currently checking the frag_list skb, and | ||
| 1038 | * this points to the shinfo of the first one | ||
| 1039 | */ | ||
| 1040 | struct skb_shared_info *first_shinfo = NULL; | ||
| 1034 | int nr_frags = shinfo->nr_frags; | 1041 | int nr_frags = shinfo->nr_frags; |
| 1042 | const bool sharedslot = nr_frags && | ||
| 1043 | frag_get_pending_idx(&shinfo->frags[0]) == pending_idx; | ||
| 1035 | int i, err; | 1044 | int i, err; |
| 1036 | struct sk_buff *first_skb = NULL; | ||
| 1037 | 1045 | ||
| 1038 | /* Check status of header. */ | 1046 | /* Check status of header. */ |
| 1039 | err = (*gopp_copy)->status; | 1047 | err = (*gopp_copy)->status; |
| 1040 | (*gopp_copy)++; | ||
| 1041 | if (unlikely(err)) { | 1048 | if (unlikely(err)) { |
| 1042 | if (net_ratelimit()) | 1049 | if (net_ratelimit()) |
| 1043 | netdev_dbg(queue->vif->dev, | 1050 | netdev_dbg(queue->vif->dev, |
| @@ -1045,8 +1052,12 @@ static int xenvif_tx_check_gop(struct xenvif_queue *queue, | |||
| 1045 | (*gopp_copy)->status, | 1052 | (*gopp_copy)->status, |
| 1046 | pending_idx, | 1053 | pending_idx, |
| 1047 | (*gopp_copy)->source.u.ref); | 1054 | (*gopp_copy)->source.u.ref); |
| 1048 | xenvif_idx_release(queue, pending_idx, XEN_NETIF_RSP_ERROR); | 1055 | /* The first frag might still have this slot mapped */ |
| 1056 | if (!sharedslot) | ||
| 1057 | xenvif_idx_release(queue, pending_idx, | ||
| 1058 | XEN_NETIF_RSP_ERROR); | ||
| 1049 | } | 1059 | } |
| 1060 | (*gopp_copy)++; | ||
| 1050 | 1061 | ||
| 1051 | check_frags: | 1062 | check_frags: |
| 1052 | for (i = 0; i < nr_frags; i++, gop_map++) { | 1063 | for (i = 0; i < nr_frags; i++, gop_map++) { |
| @@ -1062,8 +1073,19 @@ check_frags: | |||
| 1062 | pending_idx, | 1073 | pending_idx, |
| 1063 | gop_map->handle); | 1074 | gop_map->handle); |
| 1064 | /* Had a previous error? Invalidate this fragment. */ | 1075 | /* Had a previous error? Invalidate this fragment. */ |
| 1065 | if (unlikely(err)) | 1076 | if (unlikely(err)) { |
| 1066 | xenvif_idx_unmap(queue, pending_idx); | 1077 | xenvif_idx_unmap(queue, pending_idx); |
| 1078 | /* If the mapping of the first frag was OK, but | ||
| 1079 | * the header's copy failed, and they are | ||
| 1080 | * sharing a slot, send an error | ||
| 1081 | */ | ||
| 1082 | if (i == 0 && sharedslot) | ||
| 1083 | xenvif_idx_release(queue, pending_idx, | ||
| 1084 | XEN_NETIF_RSP_ERROR); | ||
| 1085 | else | ||
| 1086 | xenvif_idx_release(queue, pending_idx, | ||
| 1087 | XEN_NETIF_RSP_OKAY); | ||
| 1088 | } | ||
| 1067 | continue; | 1089 | continue; |
| 1068 | } | 1090 | } |
| 1069 | 1091 | ||
| @@ -1075,42 +1097,53 @@ check_frags: | |||
| 1075 | gop_map->status, | 1097 | gop_map->status, |
| 1076 | pending_idx, | 1098 | pending_idx, |
| 1077 | gop_map->ref); | 1099 | gop_map->ref); |
| 1100 | |||
| 1078 | xenvif_idx_release(queue, pending_idx, XEN_NETIF_RSP_ERROR); | 1101 | xenvif_idx_release(queue, pending_idx, XEN_NETIF_RSP_ERROR); |
| 1079 | 1102 | ||
| 1080 | /* Not the first error? Preceding frags already invalidated. */ | 1103 | /* Not the first error? Preceding frags already invalidated. */ |
| 1081 | if (err) | 1104 | if (err) |
| 1082 | continue; | 1105 | continue; |
| 1083 | /* First error: invalidate preceding fragments. */ | 1106 | |
| 1107 | /* First error: if the header haven't shared a slot with the | ||
| 1108 | * first frag, release it as well. | ||
| 1109 | */ | ||
| 1110 | if (!sharedslot) | ||
| 1111 | xenvif_idx_release(queue, | ||
| 1112 | XENVIF_TX_CB(skb)->pending_idx, | ||
| 1113 | XEN_NETIF_RSP_OKAY); | ||
| 1114 | |||
| 1115 | /* Invalidate preceding fragments of this skb. */ | ||
| 1084 | for (j = 0; j < i; j++) { | 1116 | for (j = 0; j < i; j++) { |
| 1085 | pending_idx = frag_get_pending_idx(&shinfo->frags[j]); | 1117 | pending_idx = frag_get_pending_idx(&shinfo->frags[j]); |
| 1086 | xenvif_idx_unmap(queue, pending_idx); | 1118 | xenvif_idx_unmap(queue, pending_idx); |
| 1119 | xenvif_idx_release(queue, pending_idx, | ||
| 1120 | XEN_NETIF_RSP_OKAY); | ||
| 1121 | } | ||
| 1122 | |||
| 1123 | /* And if we found the error while checking the frag_list, unmap | ||
| 1124 | * the first skb's frags | ||
| 1125 | */ | ||
| 1126 | if (first_shinfo) { | ||
| 1127 | for (j = 0; j < first_shinfo->nr_frags; j++) { | ||
| 1128 | pending_idx = frag_get_pending_idx(&first_shinfo->frags[j]); | ||
| 1129 | xenvif_idx_unmap(queue, pending_idx); | ||
| 1130 | xenvif_idx_release(queue, pending_idx, | ||
| 1131 | XEN_NETIF_RSP_OKAY); | ||
| 1132 | } | ||
| 1087 | } | 1133 | } |
| 1088 | 1134 | ||
| 1089 | /* Remember the error: invalidate all subsequent fragments. */ | 1135 | /* Remember the error: invalidate all subsequent fragments. */ |
| 1090 | err = newerr; | 1136 | err = newerr; |
| 1091 | } | 1137 | } |
| 1092 | 1138 | ||
| 1093 | if (skb_has_frag_list(skb)) { | 1139 | if (skb_has_frag_list(skb) && !first_shinfo) { |
| 1094 | first_skb = skb; | 1140 | first_shinfo = skb_shinfo(skb); |
| 1095 | skb = shinfo->frag_list; | 1141 | shinfo = skb_shinfo(skb_shinfo(skb)->frag_list); |
| 1096 | shinfo = skb_shinfo(skb); | ||
| 1097 | nr_frags = shinfo->nr_frags; | 1142 | nr_frags = shinfo->nr_frags; |
| 1098 | 1143 | ||
| 1099 | goto check_frags; | 1144 | goto check_frags; |
| 1100 | } | 1145 | } |
| 1101 | 1146 | ||
| 1102 | /* There was a mapping error in the frag_list skb. We have to unmap | ||
| 1103 | * the first skb's frags | ||
| 1104 | */ | ||
| 1105 | if (first_skb && err) { | ||
| 1106 | int j; | ||
| 1107 | shinfo = skb_shinfo(first_skb); | ||
| 1108 | for (j = 0; j < shinfo->nr_frags; j++) { | ||
| 1109 | pending_idx = frag_get_pending_idx(&shinfo->frags[j]); | ||
| 1110 | xenvif_idx_unmap(queue, pending_idx); | ||
| 1111 | } | ||
| 1112 | } | ||
| 1113 | |||
| 1114 | *gopp_map = gop_map; | 1147 | *gopp_map = gop_map; |
| 1115 | return err; | 1148 | return err; |
| 1116 | } | 1149 | } |
| @@ -1518,7 +1551,16 @@ static int xenvif_tx_submit(struct xenvif_queue *queue) | |||
| 1518 | 1551 | ||
| 1519 | /* Check the remap error code. */ | 1552 | /* Check the remap error code. */ |
| 1520 | if (unlikely(xenvif_tx_check_gop(queue, skb, &gop_map, &gop_copy))) { | 1553 | if (unlikely(xenvif_tx_check_gop(queue, skb, &gop_map, &gop_copy))) { |
| 1554 | /* If there was an error, xenvif_tx_check_gop is | ||
| 1555 | * expected to release all the frags which were mapped, | ||
| 1556 | * so kfree_skb shouldn't do it again | ||
| 1557 | */ | ||
| 1521 | skb_shinfo(skb)->nr_frags = 0; | 1558 | skb_shinfo(skb)->nr_frags = 0; |
| 1559 | if (skb_has_frag_list(skb)) { | ||
| 1560 | struct sk_buff *nskb = | ||
| 1561 | skb_shinfo(skb)->frag_list; | ||
| 1562 | skb_shinfo(nskb)->nr_frags = 0; | ||
| 1563 | } | ||
| 1522 | kfree_skb(skb); | 1564 | kfree_skb(skb); |
| 1523 | continue; | 1565 | continue; |
| 1524 | } | 1566 | } |
| @@ -1822,8 +1864,6 @@ void xenvif_idx_unmap(struct xenvif_queue *queue, u16 pending_idx) | |||
| 1822 | tx_unmap_op.status); | 1864 | tx_unmap_op.status); |
| 1823 | BUG(); | 1865 | BUG(); |
| 1824 | } | 1866 | } |
| 1825 | |||
| 1826 | xenvif_idx_release(queue, pending_idx, XEN_NETIF_RSP_OKAY); | ||
| 1827 | } | 1867 | } |
| 1828 | 1868 | ||
| 1829 | static inline int rx_work_todo(struct xenvif_queue *queue) | 1869 | static inline int rx_work_todo(struct xenvif_queue *queue) |
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 2ccb4a02368b..055222bae6e4 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
| @@ -1439,16 +1439,11 @@ static void xennet_disconnect_backend(struct netfront_info *info) | |||
| 1439 | unsigned int i = 0; | 1439 | unsigned int i = 0; |
| 1440 | unsigned int num_queues = info->netdev->real_num_tx_queues; | 1440 | unsigned int num_queues = info->netdev->real_num_tx_queues; |
| 1441 | 1441 | ||
| 1442 | netif_carrier_off(info->netdev); | ||
| 1443 | |||
| 1442 | for (i = 0; i < num_queues; ++i) { | 1444 | for (i = 0; i < num_queues; ++i) { |
| 1443 | struct netfront_queue *queue = &info->queues[i]; | 1445 | struct netfront_queue *queue = &info->queues[i]; |
| 1444 | 1446 | ||
| 1445 | /* Stop old i/f to prevent errors whilst we rebuild the state. */ | ||
| 1446 | spin_lock_bh(&queue->rx_lock); | ||
| 1447 | spin_lock_irq(&queue->tx_lock); | ||
| 1448 | netif_carrier_off(queue->info->netdev); | ||
| 1449 | spin_unlock_irq(&queue->tx_lock); | ||
| 1450 | spin_unlock_bh(&queue->rx_lock); | ||
| 1451 | |||
| 1452 | if (queue->tx_irq && (queue->tx_irq == queue->rx_irq)) | 1447 | if (queue->tx_irq && (queue->tx_irq == queue->rx_irq)) |
| 1453 | unbind_from_irqhandler(queue->tx_irq, queue); | 1448 | unbind_from_irqhandler(queue->tx_irq, queue); |
| 1454 | if (queue->tx_irq && (queue->tx_irq != queue->rx_irq)) { | 1449 | if (queue->tx_irq && (queue->tx_irq != queue->rx_irq)) { |
| @@ -1458,6 +1453,8 @@ static void xennet_disconnect_backend(struct netfront_info *info) | |||
| 1458 | queue->tx_evtchn = queue->rx_evtchn = 0; | 1453 | queue->tx_evtchn = queue->rx_evtchn = 0; |
| 1459 | queue->tx_irq = queue->rx_irq = 0; | 1454 | queue->tx_irq = queue->rx_irq = 0; |
| 1460 | 1455 | ||
| 1456 | napi_synchronize(&queue->napi); | ||
| 1457 | |||
| 1461 | /* End access and free the pages */ | 1458 | /* End access and free the pages */ |
| 1462 | xennet_end_access(queue->tx_ring_ref, queue->tx.sring); | 1459 | xennet_end_access(queue->tx_ring_ref, queue->tx.sring); |
| 1463 | xennet_end_access(queue->rx_ring_ref, queue->rx.sring); | 1460 | xennet_end_access(queue->rx_ring_ref, queue->rx.sring); |
| @@ -2046,13 +2043,15 @@ static int xennet_connect(struct net_device *dev) | |||
| 2046 | /* By now, the queue structures have been set up */ | 2043 | /* By now, the queue structures have been set up */ |
| 2047 | for (j = 0; j < num_queues; ++j) { | 2044 | for (j = 0; j < num_queues; ++j) { |
| 2048 | queue = &np->queues[j]; | 2045 | queue = &np->queues[j]; |
| 2049 | spin_lock_bh(&queue->rx_lock); | ||
| 2050 | spin_lock_irq(&queue->tx_lock); | ||
| 2051 | 2046 | ||
| 2052 | /* Step 1: Discard all pending TX packet fragments. */ | 2047 | /* Step 1: Discard all pending TX packet fragments. */ |
| 2048 | spin_lock_irq(&queue->tx_lock); | ||
| 2053 | xennet_release_tx_bufs(queue); | 2049 | xennet_release_tx_bufs(queue); |
| 2050 | spin_unlock_irq(&queue->tx_lock); | ||
| 2054 | 2051 | ||
| 2055 | /* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */ | 2052 | /* Step 2: Rebuild the RX buffer freelist and the RX ring itself. */ |
| 2053 | spin_lock_bh(&queue->rx_lock); | ||
| 2054 | |||
| 2056 | for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) { | 2055 | for (requeue_idx = 0, i = 0; i < NET_RX_RING_SIZE; i++) { |
| 2057 | skb_frag_t *frag; | 2056 | skb_frag_t *frag; |
| 2058 | const struct page *page; | 2057 | const struct page *page; |
| @@ -2076,6 +2075,8 @@ static int xennet_connect(struct net_device *dev) | |||
| 2076 | } | 2075 | } |
| 2077 | 2076 | ||
| 2078 | queue->rx.req_prod_pvt = requeue_idx; | 2077 | queue->rx.req_prod_pvt = requeue_idx; |
| 2078 | |||
| 2079 | spin_unlock_bh(&queue->rx_lock); | ||
| 2079 | } | 2080 | } |
| 2080 | 2081 | ||
| 2081 | /* | 2082 | /* |
| @@ -2087,13 +2088,17 @@ static int xennet_connect(struct net_device *dev) | |||
| 2087 | netif_carrier_on(np->netdev); | 2088 | netif_carrier_on(np->netdev); |
| 2088 | for (j = 0; j < num_queues; ++j) { | 2089 | for (j = 0; j < num_queues; ++j) { |
| 2089 | queue = &np->queues[j]; | 2090 | queue = &np->queues[j]; |
| 2091 | |||
| 2090 | notify_remote_via_irq(queue->tx_irq); | 2092 | notify_remote_via_irq(queue->tx_irq); |
| 2091 | if (queue->tx_irq != queue->rx_irq) | 2093 | if (queue->tx_irq != queue->rx_irq) |
| 2092 | notify_remote_via_irq(queue->rx_irq); | 2094 | notify_remote_via_irq(queue->rx_irq); |
| 2093 | xennet_tx_buf_gc(queue); | ||
| 2094 | xennet_alloc_rx_buffers(queue); | ||
| 2095 | 2095 | ||
| 2096 | spin_lock_irq(&queue->tx_lock); | ||
| 2097 | xennet_tx_buf_gc(queue); | ||
| 2096 | spin_unlock_irq(&queue->tx_lock); | 2098 | spin_unlock_irq(&queue->tx_lock); |
| 2099 | |||
| 2100 | spin_lock_bh(&queue->rx_lock); | ||
| 2101 | xennet_alloc_rx_buffers(queue); | ||
| 2097 | spin_unlock_bh(&queue->rx_lock); | 2102 | spin_unlock_bh(&queue->rx_lock); |
| 2098 | } | 2103 | } |
| 2099 | 2104 | ||
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index b777d8f46bd5..9aa012e6ea0a 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
| @@ -26,6 +26,54 @@ | |||
| 26 | #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ | 26 | #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ |
| 27 | #include <asm/page.h> | 27 | #include <asm/page.h> |
| 28 | 28 | ||
| 29 | /* | ||
| 30 | * of_fdt_limit_memory - limit the number of regions in the /memory node | ||
| 31 | * @limit: maximum entries | ||
| 32 | * | ||
| 33 | * Adjust the flattened device tree to have at most 'limit' number of | ||
| 34 | * memory entries in the /memory node. This function may be called | ||
| 35 | * any time after initial_boot_param is set. | ||
| 36 | */ | ||
| 37 | void of_fdt_limit_memory(int limit) | ||
| 38 | { | ||
| 39 | int memory; | ||
| 40 | int len; | ||
| 41 | const void *val; | ||
| 42 | int nr_address_cells = OF_ROOT_NODE_ADDR_CELLS_DEFAULT; | ||
| 43 | int nr_size_cells = OF_ROOT_NODE_SIZE_CELLS_DEFAULT; | ||
| 44 | const uint32_t *addr_prop; | ||
| 45 | const uint32_t *size_prop; | ||
| 46 | int root_offset; | ||
| 47 | int cell_size; | ||
| 48 | |||
| 49 | root_offset = fdt_path_offset(initial_boot_params, "/"); | ||
| 50 | if (root_offset < 0) | ||
| 51 | return; | ||
| 52 | |||
| 53 | addr_prop = fdt_getprop(initial_boot_params, root_offset, | ||
| 54 | "#address-cells", NULL); | ||
| 55 | if (addr_prop) | ||
| 56 | nr_address_cells = fdt32_to_cpu(*addr_prop); | ||
| 57 | |||
| 58 | size_prop = fdt_getprop(initial_boot_params, root_offset, | ||
| 59 | "#size-cells", NULL); | ||
| 60 | if (size_prop) | ||
| 61 | nr_size_cells = fdt32_to_cpu(*size_prop); | ||
| 62 | |||
| 63 | cell_size = sizeof(uint32_t)*(nr_address_cells + nr_size_cells); | ||
| 64 | |||
| 65 | memory = fdt_path_offset(initial_boot_params, "/memory"); | ||
| 66 | if (memory > 0) { | ||
| 67 | val = fdt_getprop(initial_boot_params, memory, "reg", &len); | ||
| 68 | if (len > limit*cell_size) { | ||
| 69 | len = limit*cell_size; | ||
| 70 | pr_debug("Limiting number of entries to %d\n", limit); | ||
| 71 | fdt_setprop(initial_boot_params, memory, "reg", val, | ||
| 72 | len); | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | |||
| 29 | /** | 77 | /** |
| 30 | * of_fdt_is_compatible - Return true if given node from the given blob has | 78 | * of_fdt_is_compatible - Return true if given node from the given blob has |
| 31 | * compat in its compatible list | 79 | * compat in its compatible list |
| @@ -937,7 +985,7 @@ int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, | |||
| 937 | } | 985 | } |
| 938 | #endif | 986 | #endif |
| 939 | 987 | ||
| 940 | bool __init early_init_dt_scan(void *params) | 988 | bool __init early_init_dt_verify(void *params) |
| 941 | { | 989 | { |
| 942 | if (!params) | 990 | if (!params) |
| 943 | return false; | 991 | return false; |
| @@ -951,6 +999,12 @@ bool __init early_init_dt_scan(void *params) | |||
| 951 | return false; | 999 | return false; |
| 952 | } | 1000 | } |
| 953 | 1001 | ||
| 1002 | return true; | ||
| 1003 | } | ||
| 1004 | |||
| 1005 | |||
| 1006 | void __init early_init_dt_scan_nodes(void) | ||
| 1007 | { | ||
| 954 | /* Retrieve various information from the /chosen node */ | 1008 | /* Retrieve various information from the /chosen node */ |
| 955 | of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); | 1009 | of_scan_flat_dt(early_init_dt_scan_chosen, boot_command_line); |
| 956 | 1010 | ||
| @@ -959,7 +1013,17 @@ bool __init early_init_dt_scan(void *params) | |||
| 959 | 1013 | ||
| 960 | /* Setup memory, calling early_init_dt_add_memory_arch */ | 1014 | /* Setup memory, calling early_init_dt_add_memory_arch */ |
| 961 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); | 1015 | of_scan_flat_dt(early_init_dt_scan_memory, NULL); |
| 1016 | } | ||
| 1017 | |||
| 1018 | bool __init early_init_dt_scan(void *params) | ||
| 1019 | { | ||
| 1020 | bool status; | ||
| 1021 | |||
| 1022 | status = early_init_dt_verify(params); | ||
| 1023 | if (!status) | ||
| 1024 | return false; | ||
| 962 | 1025 | ||
| 1026 | early_init_dt_scan_nodes(); | ||
| 963 | return true; | 1027 | return true; |
| 964 | } | 1028 | } |
| 965 | 1029 | ||
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c index a3bf2122a8d5..401b2453da45 100644 --- a/drivers/of/of_mdio.c +++ b/drivers/of/of_mdio.c | |||
| @@ -182,40 +182,6 @@ int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | |||
| 182 | } | 182 | } |
| 183 | EXPORT_SYMBOL(of_mdiobus_register); | 183 | EXPORT_SYMBOL(of_mdiobus_register); |
| 184 | 184 | ||
| 185 | /** | ||
| 186 | * of_mdiobus_link_phydev - Find a device node for a phy | ||
| 187 | * @mdio: pointer to mii_bus structure | ||
| 188 | * @phydev: phydev for which the of_node pointer should be set | ||
| 189 | * | ||
| 190 | * Walk the list of subnodes of a mdio bus and look for a node that matches the | ||
| 191 | * phy's address with its 'reg' property. If found, set the of_node pointer for | ||
| 192 | * the phy. This allows auto-probed pyh devices to be supplied with information | ||
| 193 | * passed in via DT. | ||
| 194 | */ | ||
| 195 | void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
| 196 | struct phy_device *phydev) | ||
| 197 | { | ||
| 198 | struct device *dev = &phydev->dev; | ||
| 199 | struct device_node *child; | ||
| 200 | |||
| 201 | if (dev->of_node || !mdio->dev.of_node) | ||
| 202 | return; | ||
| 203 | |||
| 204 | for_each_available_child_of_node(mdio->dev.of_node, child) { | ||
| 205 | int addr; | ||
| 206 | |||
| 207 | addr = of_mdio_parse_addr(&mdio->dev, child); | ||
| 208 | if (addr < 0) | ||
| 209 | continue; | ||
| 210 | |||
| 211 | if (addr == phydev->addr) { | ||
| 212 | dev->of_node = child; | ||
| 213 | return; | ||
| 214 | } | ||
| 215 | } | ||
| 216 | } | ||
| 217 | EXPORT_SYMBOL(of_mdiobus_link_phydev); | ||
| 218 | |||
| 219 | /* Helper function for of_phy_find_device */ | 185 | /* Helper function for of_phy_find_device */ |
| 220 | static int of_phy_match(struct device *dev, void *phy_np) | 186 | static int of_phy_match(struct device *dev, void *phy_np) |
| 221 | { | 187 | { |
diff --git a/drivers/parport/Kconfig b/drivers/parport/Kconfig index 2872ece81f35..44333bd8f908 100644 --- a/drivers/parport/Kconfig +++ b/drivers/parport/Kconfig | |||
| @@ -5,6 +5,12 @@ | |||
| 5 | # Parport configuration. | 5 | # Parport configuration. |
| 6 | # | 6 | # |
| 7 | 7 | ||
| 8 | config ARCH_MIGHT_HAVE_PC_PARPORT | ||
| 9 | bool | ||
| 10 | help | ||
| 11 | Select this config option from the architecture Kconfig if | ||
| 12 | the architecture might have PC parallel port hardware. | ||
| 13 | |||
| 8 | menuconfig PARPORT | 14 | menuconfig PARPORT |
| 9 | tristate "Parallel port support" | 15 | tristate "Parallel port support" |
| 10 | depends on HAS_IOMEM | 16 | depends on HAS_IOMEM |
| @@ -31,12 +37,6 @@ menuconfig PARPORT | |||
| 31 | 37 | ||
| 32 | If unsure, say Y. | 38 | If unsure, say Y. |
| 33 | 39 | ||
| 34 | config ARCH_MIGHT_HAVE_PC_PARPORT | ||
| 35 | bool | ||
| 36 | help | ||
| 37 | Select this config option from the architecture Kconfig if | ||
| 38 | the architecture might have PC parallel port hardware. | ||
| 39 | |||
| 40 | if PARPORT | 40 | if PARPORT |
| 41 | 41 | ||
| 42 | config PARPORT_PC | 42 | config PARPORT_PC |
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 63a54a340863..1c8592b0e146 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
| @@ -3135,8 +3135,13 @@ static int pci_af_flr(struct pci_dev *dev, int probe) | |||
| 3135 | if (probe) | 3135 | if (probe) |
| 3136 | return 0; | 3136 | return 0; |
| 3137 | 3137 | ||
| 3138 | /* Wait for Transaction Pending bit clean */ | 3138 | /* |
| 3139 | if (pci_wait_for_pending(dev, pos + PCI_AF_STATUS, PCI_AF_STATUS_TP)) | 3139 | * Wait for Transaction Pending bit to clear. A word-aligned test |
| 3140 | * is used, so we use the conrol offset rather than status and shift | ||
| 3141 | * the test bit to match. | ||
| 3142 | */ | ||
| 3143 | if (pci_wait_for_pending(dev, pos + PCI_AF_CTRL, | ||
| 3144 | PCI_AF_STATUS_TP << 8)) | ||
| 3140 | goto clear; | 3145 | goto clear; |
| 3141 | 3146 | ||
| 3142 | dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n"); | 3147 | dev_err(&dev->dev, "transaction is not cleared; proceeding with reset anyway\n"); |
diff --git a/drivers/phy/Kconfig b/drivers/phy/Kconfig index 16a2f067c242..64b98d242ea6 100644 --- a/drivers/phy/Kconfig +++ b/drivers/phy/Kconfig | |||
| @@ -112,6 +112,7 @@ config PHY_EXYNOS5250_SATA | |||
| 112 | config PHY_SUN4I_USB | 112 | config PHY_SUN4I_USB |
| 113 | tristate "Allwinner sunxi SoC USB PHY driver" | 113 | tristate "Allwinner sunxi SoC USB PHY driver" |
| 114 | depends on ARCH_SUNXI && HAS_IOMEM && OF | 114 | depends on ARCH_SUNXI && HAS_IOMEM && OF |
| 115 | depends on RESET_CONTROLLER | ||
| 115 | select GENERIC_PHY | 116 | select GENERIC_PHY |
| 116 | help | 117 | help |
| 117 | Enable this to support the transceiver that is part of Allwinner | 118 | Enable this to support the transceiver that is part of Allwinner |
| @@ -122,6 +123,7 @@ config PHY_SUN4I_USB | |||
| 122 | 123 | ||
| 123 | config PHY_SAMSUNG_USB2 | 124 | config PHY_SAMSUNG_USB2 |
| 124 | tristate "Samsung USB 2.0 PHY driver" | 125 | tristate "Samsung USB 2.0 PHY driver" |
| 126 | depends on HAS_IOMEM | ||
| 125 | select GENERIC_PHY | 127 | select GENERIC_PHY |
| 126 | select MFD_SYSCON | 128 | select MFD_SYSCON |
| 127 | help | 129 | help |
diff --git a/drivers/phy/phy-core.c b/drivers/phy/phy-core.c index c64a2f3b2d62..49c446530101 100644 --- a/drivers/phy/phy-core.c +++ b/drivers/phy/phy-core.c | |||
| @@ -614,8 +614,9 @@ struct phy *phy_create(struct device *dev, const struct phy_ops *ops, | |||
| 614 | return phy; | 614 | return phy; |
| 615 | 615 | ||
| 616 | put_dev: | 616 | put_dev: |
| 617 | put_device(&phy->dev); | 617 | put_device(&phy->dev); /* calls phy_release() which frees resources */ |
| 618 | ida_remove(&phy_ida, phy->id); | 618 | return ERR_PTR(ret); |
| 619 | |||
| 619 | free_phy: | 620 | free_phy: |
| 620 | kfree(phy); | 621 | kfree(phy); |
| 621 | return ERR_PTR(ret); | 622 | return ERR_PTR(ret); |
| @@ -799,7 +800,7 @@ static void phy_release(struct device *dev) | |||
| 799 | 800 | ||
| 800 | phy = to_phy(dev); | 801 | phy = to_phy(dev); |
| 801 | dev_vdbg(dev, "releasing '%s'\n", dev_name(dev)); | 802 | dev_vdbg(dev, "releasing '%s'\n", dev_name(dev)); |
| 802 | ida_remove(&phy_ida, phy->id); | 803 | ida_simple_remove(&phy_ida, phy->id); |
| 803 | kfree(phy); | 804 | kfree(phy); |
| 804 | } | 805 | } |
| 805 | 806 | ||
diff --git a/drivers/phy/phy-omap-usb2.c b/drivers/phy/phy-omap-usb2.c index 7007c11fe07d..34b396146c8a 100644 --- a/drivers/phy/phy-omap-usb2.c +++ b/drivers/phy/phy-omap-usb2.c | |||
| @@ -233,8 +233,8 @@ static int omap_usb2_probe(struct platform_device *pdev) | |||
| 233 | if (phy_data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) { | 233 | if (phy_data->flags & OMAP_USB2_CALIBRATE_FALSE_DISCONNECT) { |
| 234 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 234 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 235 | phy->phy_base = devm_ioremap_resource(&pdev->dev, res); | 235 | phy->phy_base = devm_ioremap_resource(&pdev->dev, res); |
| 236 | if (!phy->phy_base) | 236 | if (IS_ERR(phy->phy_base)) |
| 237 | return -ENOMEM; | 237 | return PTR_ERR(phy->phy_base); |
| 238 | phy->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT; | 238 | phy->flags |= OMAP_USB2_CALIBRATE_FALSE_DISCONNECT; |
| 239 | } | 239 | } |
| 240 | 240 | ||
| @@ -262,7 +262,6 @@ static int omap_usb2_probe(struct platform_device *pdev) | |||
| 262 | otg->phy = &phy->phy; | 262 | otg->phy = &phy->phy; |
| 263 | 263 | ||
| 264 | platform_set_drvdata(pdev, phy); | 264 | platform_set_drvdata(pdev, phy); |
| 265 | pm_runtime_enable(phy->dev); | ||
| 266 | 265 | ||
| 267 | generic_phy = devm_phy_create(phy->dev, &ops, NULL); | 266 | generic_phy = devm_phy_create(phy->dev, &ops, NULL); |
| 268 | if (IS_ERR(generic_phy)) | 267 | if (IS_ERR(generic_phy)) |
| @@ -270,10 +269,13 @@ static int omap_usb2_probe(struct platform_device *pdev) | |||
| 270 | 269 | ||
| 271 | phy_set_drvdata(generic_phy, phy); | 270 | phy_set_drvdata(generic_phy, phy); |
| 272 | 271 | ||
| 272 | pm_runtime_enable(phy->dev); | ||
| 273 | phy_provider = devm_of_phy_provider_register(phy->dev, | 273 | phy_provider = devm_of_phy_provider_register(phy->dev, |
| 274 | of_phy_simple_xlate); | 274 | of_phy_simple_xlate); |
| 275 | if (IS_ERR(phy_provider)) | 275 | if (IS_ERR(phy_provider)) { |
| 276 | pm_runtime_disable(phy->dev); | ||
| 276 | return PTR_ERR(phy_provider); | 277 | return PTR_ERR(phy_provider); |
| 278 | } | ||
| 277 | 279 | ||
| 278 | phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); | 280 | phy->wkupclk = devm_clk_get(phy->dev, "wkupclk"); |
| 279 | if (IS_ERR(phy->wkupclk)) { | 281 | if (IS_ERR(phy->wkupclk)) { |
| @@ -317,6 +319,7 @@ static int omap_usb2_remove(struct platform_device *pdev) | |||
| 317 | if (!IS_ERR(phy->optclk)) | 319 | if (!IS_ERR(phy->optclk)) |
| 318 | clk_unprepare(phy->optclk); | 320 | clk_unprepare(phy->optclk); |
| 319 | usb_remove_phy(&phy->phy); | 321 | usb_remove_phy(&phy->phy); |
| 322 | pm_runtime_disable(phy->dev); | ||
| 320 | 323 | ||
| 321 | return 0; | 324 | return 0; |
| 322 | } | 325 | } |
diff --git a/drivers/phy/phy-samsung-usb2.c b/drivers/phy/phy-samsung-usb2.c index 8a8c6bc8709a..1e69a32c221d 100644 --- a/drivers/phy/phy-samsung-usb2.c +++ b/drivers/phy/phy-samsung-usb2.c | |||
| @@ -107,6 +107,7 @@ static const struct of_device_id samsung_usb2_phy_of_match[] = { | |||
| 107 | #endif | 107 | #endif |
| 108 | { }, | 108 | { }, |
| 109 | }; | 109 | }; |
| 110 | MODULE_DEVICE_TABLE(of, samsung_usb2_phy_of_match); | ||
| 110 | 111 | ||
| 111 | static int samsung_usb2_phy_probe(struct platform_device *pdev) | 112 | static int samsung_usb2_phy_probe(struct platform_device *pdev) |
| 112 | { | 113 | { |
diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c index edf5d2fd2b22..86db2235ab00 100644 --- a/drivers/pinctrl/berlin/berlin.c +++ b/drivers/pinctrl/berlin/berlin.c | |||
| @@ -320,7 +320,7 @@ int berlin_pinctrl_probe(struct platform_device *pdev, | |||
| 320 | 320 | ||
| 321 | regmap = dev_get_regmap(&pdev->dev, NULL); | 321 | regmap = dev_get_regmap(&pdev->dev, NULL); |
| 322 | if (!regmap) | 322 | if (!regmap) |
| 323 | return PTR_ERR(regmap); | 323 | return -ENODEV; |
| 324 | 324 | ||
| 325 | pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL); | 325 | pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL); |
| 326 | if (!pctrl) | 326 | if (!pctrl) |
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 1bd6363bc95e..9f43916637ca 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c | |||
| @@ -1431,7 +1431,7 @@ static void st_gpio_irqmux_handler(unsigned irq, struct irq_desc *desc) | |||
| 1431 | 1431 | ||
| 1432 | status = readl(info->irqmux_base); | 1432 | status = readl(info->irqmux_base); |
| 1433 | 1433 | ||
| 1434 | for_each_set_bit(n, &status, ST_GPIO_PINS_PER_BANK) | 1434 | for_each_set_bit(n, &status, info->nbanks) |
| 1435 | __gpio_irq_handler(&info->banks[n]); | 1435 | __gpio_irq_handler(&info->banks[n]); |
| 1436 | 1436 | ||
| 1437 | chained_irq_exit(chip, desc); | 1437 | chained_irq_exit(chip, desc); |
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index f1ca75e6d7b1..5f38c7f67834 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c | |||
| @@ -211,6 +211,10 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 211 | configlen++; | 211 | configlen++; |
| 212 | 212 | ||
| 213 | pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL); | 213 | pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL); |
| 214 | if (!pinconfig) { | ||
| 215 | kfree(*map); | ||
| 216 | return -ENOMEM; | ||
| 217 | } | ||
| 214 | 218 | ||
| 215 | if (!of_property_read_u32(node, "allwinner,drive", &val)) { | 219 | if (!of_property_read_u32(node, "allwinner,drive", &val)) { |
| 216 | u16 strength = (val + 1) * 10; | 220 | u16 strength = (val + 1) * 10; |
diff --git a/drivers/pnp/pnpacpi/core.c b/drivers/pnp/pnpacpi/core.c index b81448b2c75d..a5c6cb773e5f 100644 --- a/drivers/pnp/pnpacpi/core.c +++ b/drivers/pnp/pnpacpi/core.c | |||
| @@ -319,8 +319,7 @@ static int __init acpi_pnp_match(struct device *dev, void *_pnp) | |||
| 319 | struct pnp_dev *pnp = _pnp; | 319 | struct pnp_dev *pnp = _pnp; |
| 320 | 320 | ||
| 321 | /* true means it matched */ | 321 | /* true means it matched */ |
| 322 | return !acpi->physical_node_count | 322 | return pnp->data == acpi; |
| 323 | && compare_pnp_id(pnp->id, acpi_device_hid(acpi)); | ||
| 324 | } | 323 | } |
| 325 | 324 | ||
| 326 | static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev) | 325 | static struct acpi_device * __init acpi_pnp_find_companion(struct device *dev) |
diff --git a/drivers/rapidio/devices/tsi721_dma.c b/drivers/rapidio/devices/tsi721_dma.c index 9b60b1f3261c..44341dc5b148 100644 --- a/drivers/rapidio/devices/tsi721_dma.c +++ b/drivers/rapidio/devices/tsi721_dma.c | |||
| @@ -287,6 +287,12 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan) | |||
| 287 | "desc %p not ACKed\n", tx_desc); | 287 | "desc %p not ACKed\n", tx_desc); |
| 288 | } | 288 | } |
| 289 | 289 | ||
| 290 | if (ret == NULL) { | ||
| 291 | dev_dbg(bdma_chan->dchan.device->dev, | ||
| 292 | "%s: unable to obtain tx descriptor\n", __func__); | ||
| 293 | goto err_out; | ||
| 294 | } | ||
| 295 | |||
| 290 | i = bdma_chan->wr_count_next % bdma_chan->bd_num; | 296 | i = bdma_chan->wr_count_next % bdma_chan->bd_num; |
| 291 | if (i == bdma_chan->bd_num - 1) { | 297 | if (i == bdma_chan->bd_num - 1) { |
| 292 | i = 0; | 298 | i = 0; |
| @@ -297,7 +303,7 @@ struct tsi721_tx_desc *tsi721_desc_get(struct tsi721_bdma_chan *bdma_chan) | |||
| 297 | tx_desc->txd.phys = bdma_chan->bd_phys + | 303 | tx_desc->txd.phys = bdma_chan->bd_phys + |
| 298 | i * sizeof(struct tsi721_dma_desc); | 304 | i * sizeof(struct tsi721_dma_desc); |
| 299 | tx_desc->hw_desc = &((struct tsi721_dma_desc *)bdma_chan->bd_base)[i]; | 305 | tx_desc->hw_desc = &((struct tsi721_dma_desc *)bdma_chan->bd_base)[i]; |
| 300 | 306 | err_out: | |
| 301 | spin_unlock_bh(&bdma_chan->lock); | 307 | spin_unlock_bh(&bdma_chan->lock); |
| 302 | 308 | ||
| 303 | return ret; | 309 | return ret; |
diff --git a/drivers/s390/char/raw3270.c b/drivers/s390/char/raw3270.c index 15b3459f8656..220acb4cbee5 100644 --- a/drivers/s390/char/raw3270.c +++ b/drivers/s390/char/raw3270.c | |||
| @@ -633,7 +633,6 @@ raw3270_reset_device_cb(struct raw3270_request *rq, void *data) | |||
| 633 | } else | 633 | } else |
| 634 | raw3270_writesf_readpart(rp); | 634 | raw3270_writesf_readpart(rp); |
| 635 | memset(&rp->init_reset, 0, sizeof(rp->init_reset)); | 635 | memset(&rp->init_reset, 0, sizeof(rp->init_reset)); |
| 636 | memset(&rp->init_data, 0, sizeof(rp->init_data)); | ||
| 637 | } | 636 | } |
| 638 | 637 | ||
| 639 | static int | 638 | static int |
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index 69ef4f8cfac8..4038437ff033 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
| @@ -901,10 +901,15 @@ static int ap_device_probe(struct device *dev) | |||
| 901 | int rc; | 901 | int rc; |
| 902 | 902 | ||
| 903 | ap_dev->drv = ap_drv; | 903 | ap_dev->drv = ap_drv; |
| 904 | |||
| 905 | spin_lock_bh(&ap_device_list_lock); | ||
| 906 | list_add(&ap_dev->list, &ap_device_list); | ||
| 907 | spin_unlock_bh(&ap_device_list_lock); | ||
| 908 | |||
| 904 | rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; | 909 | rc = ap_drv->probe ? ap_drv->probe(ap_dev) : -ENODEV; |
| 905 | if (!rc) { | 910 | if (rc) { |
| 906 | spin_lock_bh(&ap_device_list_lock); | 911 | spin_lock_bh(&ap_device_list_lock); |
| 907 | list_add(&ap_dev->list, &ap_device_list); | 912 | list_del_init(&ap_dev->list); |
| 908 | spin_unlock_bh(&ap_device_list_lock); | 913 | spin_unlock_bh(&ap_device_list_lock); |
| 909 | } | 914 | } |
| 910 | return rc; | 915 | return rc; |
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index f7e316368c99..3f50dfcb3227 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c | |||
| @@ -733,6 +733,14 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) | |||
| 733 | scsi_next_command(cmd); | 733 | scsi_next_command(cmd); |
| 734 | return; | 734 | return; |
| 735 | } | 735 | } |
| 736 | } else if (blk_rq_bytes(req) == 0 && result && !sense_deferred) { | ||
| 737 | /* | ||
| 738 | * Certain non BLOCK_PC requests are commands that don't | ||
| 739 | * actually transfer anything (FLUSH), so cannot use | ||
| 740 | * good_bytes != blk_rq_bytes(req) as the signal for an error. | ||
| 741 | * This sets the error explicitly for the problem case. | ||
| 742 | */ | ||
| 743 | error = __scsi_error_from_host_byte(cmd, result); | ||
| 736 | } | 744 | } |
| 737 | 745 | ||
| 738 | /* no bidi support for !REQ_TYPE_BLOCK_PC yet */ | 746 | /* no bidi support for !REQ_TYPE_BLOCK_PC yet */ |
diff --git a/drivers/staging/media/omap4iss/Kconfig b/drivers/staging/media/omap4iss/Kconfig index 78b0fba7047e..8afc6fee40c5 100644 --- a/drivers/staging/media/omap4iss/Kconfig +++ b/drivers/staging/media/omap4iss/Kconfig | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | config VIDEO_OMAP4 | 1 | config VIDEO_OMAP4 |
| 2 | bool "OMAP 4 Camera support" | 2 | bool "OMAP 4 Camera support" |
| 3 | depends on VIDEO_V4L2 && VIDEO_V4L2_SUBDEV_API && I2C && ARCH_OMAP4 | 3 | depends on VIDEO_V4L2=y && VIDEO_V4L2_SUBDEV_API && I2C=y && ARCH_OMAP4 |
| 4 | select VIDEOBUF2_DMA_CONTIG | 4 | select VIDEOBUF2_DMA_CONTIG |
| 5 | ---help--- | 5 | ---help--- |
| 6 | Driver for an OMAP 4 ISS controller. | 6 | Driver for an OMAP 4 ISS controller. |
diff --git a/drivers/staging/rtl8723au/os_dep/usb_intf.c b/drivers/staging/rtl8723au/os_dep/usb_intf.c index 8b25c1aa2025..ebb19b22f47f 100644 --- a/drivers/staging/rtl8723au/os_dep/usb_intf.c +++ b/drivers/staging/rtl8723au/os_dep/usb_intf.c | |||
| @@ -530,8 +530,10 @@ int rtw_resume_process23a(struct rtw_adapter *padapter) | |||
| 530 | pwrpriv->bkeepfwalive = false; | 530 | pwrpriv->bkeepfwalive = false; |
| 531 | 531 | ||
| 532 | DBG_8723A("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive); | 532 | DBG_8723A("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive); |
| 533 | if (pm_netdev_open23a(pnetdev, true) != 0) | 533 | if (pm_netdev_open23a(pnetdev, true) != 0) { |
| 534 | up(&pwrpriv->lock); | ||
| 534 | goto exit; | 535 | goto exit; |
| 536 | } | ||
| 535 | 537 | ||
| 536 | netif_device_attach(pnetdev); | 538 | netif_device_attach(pnetdev); |
| 537 | netif_carrier_on(pnetdev); | 539 | netif_carrier_on(pnetdev); |
diff --git a/drivers/staging/vt6655/bssdb.c b/drivers/staging/vt6655/bssdb.c index 59679cd46816..69b80e80b011 100644 --- a/drivers/staging/vt6655/bssdb.c +++ b/drivers/staging/vt6655/bssdb.c | |||
| @@ -981,7 +981,7 @@ start: | |||
| 981 | pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1)); | 981 | pDevice->byERPFlag &= ~(WLAN_SET_ERP_USE_PROTECTION(1)); |
| 982 | } | 982 | } |
| 983 | 983 | ||
| 984 | { | 984 | if (pDevice->eCommandState == WLAN_ASSOCIATE_WAIT) { |
| 985 | pDevice->byReAssocCount++; | 985 | pDevice->byReAssocCount++; |
| 986 | /* 10 sec timeout */ | 986 | /* 10 sec timeout */ |
| 987 | if ((pDevice->byReAssocCount > 10) && (!pDevice->bLinkPass)) { | 987 | if ((pDevice->byReAssocCount > 10) && (!pDevice->bLinkPass)) { |
diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 1d3908d044d0..5a5fd937a442 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c | |||
| @@ -2318,6 +2318,7 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { | |||
| 2318 | int handled = 0; | 2318 | int handled = 0; |
| 2319 | unsigned char byData = 0; | 2319 | unsigned char byData = 0; |
| 2320 | int ii = 0; | 2320 | int ii = 0; |
| 2321 | unsigned long flags; | ||
| 2321 | 2322 | ||
| 2322 | MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); | 2323 | MACvReadISR(pDevice->PortOffset, &pDevice->dwIsr); |
| 2323 | 2324 | ||
| @@ -2331,7 +2332,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { | |||
| 2331 | 2332 | ||
| 2332 | handled = 1; | 2333 | handled = 1; |
| 2333 | MACvIntDisable(pDevice->PortOffset); | 2334 | MACvIntDisable(pDevice->PortOffset); |
| 2334 | spin_lock_irq(&pDevice->lock); | 2335 | |
| 2336 | spin_lock_irqsave(&pDevice->lock, flags); | ||
| 2335 | 2337 | ||
| 2336 | //Make sure current page is 0 | 2338 | //Make sure current page is 0 |
| 2337 | VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel); | 2339 | VNSvInPortB(pDevice->PortOffset + MAC_REG_PAGE1SEL, &byOrgPageSel); |
| @@ -2560,7 +2562,8 @@ static irqreturn_t device_intr(int irq, void *dev_instance) { | |||
| 2560 | if (byOrgPageSel == 1) | 2562 | if (byOrgPageSel == 1) |
| 2561 | MACvSelectPage1(pDevice->PortOffset); | 2563 | MACvSelectPage1(pDevice->PortOffset); |
| 2562 | 2564 | ||
| 2563 | spin_unlock_irq(&pDevice->lock); | 2565 | spin_unlock_irqrestore(&pDevice->lock, flags); |
| 2566 | |||
| 2564 | MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); | 2567 | MACvIntEnable(pDevice->PortOffset, IMR_MASK_VALUE); |
| 2565 | 2568 | ||
| 2566 | return IRQ_RETVAL(handled); | 2569 | return IRQ_RETVAL(handled); |
diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c index a99c63152b8d..2c516f2eebed 100644 --- a/drivers/thermal/imx_thermal.c +++ b/drivers/thermal/imx_thermal.c | |||
| @@ -306,7 +306,7 @@ static int imx_get_sensor_data(struct platform_device *pdev) | |||
| 306 | { | 306 | { |
| 307 | struct imx_thermal_data *data = platform_get_drvdata(pdev); | 307 | struct imx_thermal_data *data = platform_get_drvdata(pdev); |
| 308 | struct regmap *map; | 308 | struct regmap *map; |
| 309 | int t1, t2, n1, n2; | 309 | int t1, n1; |
| 310 | int ret; | 310 | int ret; |
| 311 | u32 val; | 311 | u32 val; |
| 312 | u64 temp64; | 312 | u64 temp64; |
| @@ -333,14 +333,10 @@ static int imx_get_sensor_data(struct platform_device *pdev) | |||
| 333 | /* | 333 | /* |
| 334 | * Sensor data layout: | 334 | * Sensor data layout: |
| 335 | * [31:20] - sensor value @ 25C | 335 | * [31:20] - sensor value @ 25C |
| 336 | * [19:8] - sensor value of hot | ||
| 337 | * [7:0] - hot temperature value | ||
| 338 | * Use universal formula now and only need sensor value @ 25C | 336 | * Use universal formula now and only need sensor value @ 25C |
| 339 | * slope = 0.4297157 - (0.0015976 * 25C fuse) | 337 | * slope = 0.4297157 - (0.0015976 * 25C fuse) |
| 340 | */ | 338 | */ |
| 341 | n1 = val >> 20; | 339 | n1 = val >> 20; |
| 342 | n2 = (val & 0xfff00) >> 8; | ||
| 343 | t2 = val & 0xff; | ||
| 344 | t1 = 25; /* t1 always 25C */ | 340 | t1 = 25; /* t1 always 25C */ |
| 345 | 341 | ||
| 346 | /* | 342 | /* |
| @@ -366,16 +362,16 @@ static int imx_get_sensor_data(struct platform_device *pdev) | |||
| 366 | data->c2 = n1 * data->c1 + 1000 * t1; | 362 | data->c2 = n1 * data->c1 + 1000 * t1; |
| 367 | 363 | ||
| 368 | /* | 364 | /* |
| 369 | * Set the default passive cooling trip point to 20 °C below the | 365 | * Set the default passive cooling trip point, |
| 370 | * maximum die temperature. Can be changed from userspace. | 366 | * can be changed from userspace. |
| 371 | */ | 367 | */ |
| 372 | data->temp_passive = 1000 * (t2 - 20); | 368 | data->temp_passive = IMX_TEMP_PASSIVE; |
| 373 | 369 | ||
| 374 | /* | 370 | /* |
| 375 | * The maximum die temperature is t2, let's give 5 °C cushion | 371 | * The maximum die temperature set to 20 C higher than |
| 376 | * for noise and possible temperature rise between measurements. | 372 | * IMX_TEMP_PASSIVE. |
| 377 | */ | 373 | */ |
| 378 | data->temp_critical = 1000 * (t2 - 5); | 374 | data->temp_critical = 1000 * 20 + data->temp_passive; |
| 379 | 375 | ||
| 380 | return 0; | 376 | return 0; |
| 381 | } | 377 | } |
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 04b1be7fa018..4b2b999b7611 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c | |||
| @@ -156,8 +156,8 @@ static int of_thermal_bind(struct thermal_zone_device *thermal, | |||
| 156 | 156 | ||
| 157 | ret = thermal_zone_bind_cooling_device(thermal, | 157 | ret = thermal_zone_bind_cooling_device(thermal, |
| 158 | tbp->trip_id, cdev, | 158 | tbp->trip_id, cdev, |
| 159 | tbp->min, | 159 | tbp->max, |
| 160 | tbp->max); | 160 | tbp->min); |
| 161 | if (ret) | 161 | if (ret) |
| 162 | return ret; | 162 | return ret; |
| 163 | } | 163 | } |
| @@ -712,11 +712,12 @@ thermal_of_build_thermal_zone(struct device_node *np) | |||
| 712 | } | 712 | } |
| 713 | 713 | ||
| 714 | i = 0; | 714 | i = 0; |
| 715 | for_each_child_of_node(child, gchild) | 715 | for_each_child_of_node(child, gchild) { |
| 716 | ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++], | 716 | ret = thermal_of_populate_bind_params(gchild, &tz->tbps[i++], |
| 717 | tz->trips, tz->ntrips); | 717 | tz->trips, tz->ntrips); |
| 718 | if (ret) | 718 | if (ret) |
| 719 | goto free_tbps; | 719 | goto free_tbps; |
| 720 | } | ||
| 720 | 721 | ||
| 721 | finish: | 722 | finish: |
| 722 | of_node_put(child); | 723 | of_node_put(child); |
diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c index fdb07199d9c2..1967bee4f076 100644 --- a/drivers/thermal/thermal_hwmon.c +++ b/drivers/thermal/thermal_hwmon.c | |||
| @@ -140,6 +140,12 @@ thermal_hwmon_lookup_temp(const struct thermal_hwmon_device *hwmon, | |||
| 140 | return NULL; | 140 | return NULL; |
| 141 | } | 141 | } |
| 142 | 142 | ||
| 143 | static bool thermal_zone_crit_temp_valid(struct thermal_zone_device *tz) | ||
| 144 | { | ||
| 145 | unsigned long temp; | ||
| 146 | return tz->ops->get_crit_temp && !tz->ops->get_crit_temp(tz, &temp); | ||
| 147 | } | ||
| 148 | |||
| 143 | int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) | 149 | int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) |
| 144 | { | 150 | { |
| 145 | struct thermal_hwmon_device *hwmon; | 151 | struct thermal_hwmon_device *hwmon; |
| @@ -189,21 +195,18 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) | |||
| 189 | if (result) | 195 | if (result) |
| 190 | goto free_temp_mem; | 196 | goto free_temp_mem; |
| 191 | 197 | ||
| 192 | if (tz->ops->get_crit_temp) { | 198 | if (thermal_zone_crit_temp_valid(tz)) { |
| 193 | unsigned long temperature; | 199 | snprintf(temp->temp_crit.name, |
| 194 | if (!tz->ops->get_crit_temp(tz, &temperature)) { | 200 | sizeof(temp->temp_crit.name), |
| 195 | snprintf(temp->temp_crit.name, | ||
| 196 | sizeof(temp->temp_crit.name), | ||
| 197 | "temp%d_crit", hwmon->count); | 201 | "temp%d_crit", hwmon->count); |
| 198 | temp->temp_crit.attr.attr.name = temp->temp_crit.name; | 202 | temp->temp_crit.attr.attr.name = temp->temp_crit.name; |
| 199 | temp->temp_crit.attr.attr.mode = 0444; | 203 | temp->temp_crit.attr.attr.mode = 0444; |
| 200 | temp->temp_crit.attr.show = temp_crit_show; | 204 | temp->temp_crit.attr.show = temp_crit_show; |
| 201 | sysfs_attr_init(&temp->temp_crit.attr.attr); | 205 | sysfs_attr_init(&temp->temp_crit.attr.attr); |
| 202 | result = device_create_file(hwmon->device, | 206 | result = device_create_file(hwmon->device, |
| 203 | &temp->temp_crit.attr); | 207 | &temp->temp_crit.attr); |
| 204 | if (result) | 208 | if (result) |
| 205 | goto unregister_input; | 209 | goto unregister_input; |
| 206 | } | ||
| 207 | } | 210 | } |
| 208 | 211 | ||
| 209 | mutex_lock(&thermal_hwmon_list_lock); | 212 | mutex_lock(&thermal_hwmon_list_lock); |
| @@ -250,7 +253,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz) | |||
| 250 | } | 253 | } |
| 251 | 254 | ||
| 252 | device_remove_file(hwmon->device, &temp->temp_input.attr); | 255 | device_remove_file(hwmon->device, &temp->temp_input.attr); |
| 253 | if (tz->ops->get_crit_temp) | 256 | if (thermal_zone_crit_temp_valid(tz)) |
| 254 | device_remove_file(hwmon->device, &temp->temp_crit.attr); | 257 | device_remove_file(hwmon->device, &temp->temp_crit.attr); |
| 255 | 258 | ||
| 256 | mutex_lock(&thermal_hwmon_list_lock); | 259 | mutex_lock(&thermal_hwmon_list_lock); |
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c index a1271b55103a..634b6ce0e63a 100644 --- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c +++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c | |||
| @@ -1155,7 +1155,7 @@ static struct ti_bandgap *ti_bandgap_build(struct platform_device *pdev) | |||
| 1155 | /* register shadow for context save and restore */ | 1155 | /* register shadow for context save and restore */ |
| 1156 | bgp->regval = devm_kzalloc(&pdev->dev, sizeof(*bgp->regval) * | 1156 | bgp->regval = devm_kzalloc(&pdev->dev, sizeof(*bgp->regval) * |
| 1157 | bgp->conf->sensor_count, GFP_KERNEL); | 1157 | bgp->conf->sensor_count, GFP_KERNEL); |
| 1158 | if (!bgp) { | 1158 | if (!bgp->regval) { |
| 1159 | dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n"); | 1159 | dev_err(&pdev->dev, "Unable to allocate mem for driver ref\n"); |
| 1160 | return ERR_PTR(-ENOMEM); | 1160 | return ERR_PTR(-ENOMEM); |
| 1161 | } | 1161 | } |
diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c index c9f5c9dcc15c..008c223eaf26 100644 --- a/drivers/tty/serial/arc_uart.c +++ b/drivers/tty/serial/arc_uart.c | |||
| @@ -177,7 +177,7 @@ static void arc_serial_tx_chars(struct arc_uart_port *uart) | |||
| 177 | uart->port.icount.tx++; | 177 | uart->port.icount.tx++; |
| 178 | uart->port.x_char = 0; | 178 | uart->port.x_char = 0; |
| 179 | sent = 1; | 179 | sent = 1; |
| 180 | } else if (xmit->tail != xmit->head) { /* TODO: uart_circ_empty */ | 180 | } else if (!uart_circ_empty(xmit)) { |
| 181 | ch = xmit->buf[xmit->tail]; | 181 | ch = xmit->buf[xmit->tail]; |
| 182 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 182 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
| 183 | uart->port.icount.tx++; | 183 | uart->port.icount.tx++; |
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index e2f93874989b..044e86d528ae 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
| @@ -567,6 +567,9 @@ static void imx_start_tx(struct uart_port *port) | |||
| 567 | struct imx_port *sport = (struct imx_port *)port; | 567 | struct imx_port *sport = (struct imx_port *)port; |
| 568 | unsigned long temp; | 568 | unsigned long temp; |
| 569 | 569 | ||
| 570 | if (uart_circ_empty(&port->state->xmit)) | ||
| 571 | return; | ||
| 572 | |||
| 570 | if (USE_IRDA(sport)) { | 573 | if (USE_IRDA(sport)) { |
| 571 | /* half duplex in IrDA mode; have to disable receive mode */ | 574 | /* half duplex in IrDA mode; have to disable receive mode */ |
| 572 | temp = readl(sport->port.membase + UCR4); | 575 | temp = readl(sport->port.membase + UCR4); |
diff --git a/drivers/tty/serial/ip22zilog.c b/drivers/tty/serial/ip22zilog.c index 1efd4c36ba0c..99b7b8697861 100644 --- a/drivers/tty/serial/ip22zilog.c +++ b/drivers/tty/serial/ip22zilog.c | |||
| @@ -603,6 +603,8 @@ static void ip22zilog_start_tx(struct uart_port *port) | |||
| 603 | } else { | 603 | } else { |
| 604 | struct circ_buf *xmit = &port->state->xmit; | 604 | struct circ_buf *xmit = &port->state->xmit; |
| 605 | 605 | ||
| 606 | if (uart_circ_empty(xmit)) | ||
| 607 | return; | ||
| 606 | writeb(xmit->buf[xmit->tail], &channel->data); | 608 | writeb(xmit->buf[xmit->tail], &channel->data); |
| 607 | ZSDELAY(); | 609 | ZSDELAY(); |
| 608 | ZS_WSYNC(channel); | 610 | ZS_WSYNC(channel); |
diff --git a/drivers/tty/serial/m32r_sio.c b/drivers/tty/serial/m32r_sio.c index 68f2c53e0b54..5702828fb62e 100644 --- a/drivers/tty/serial/m32r_sio.c +++ b/drivers/tty/serial/m32r_sio.c | |||
| @@ -266,9 +266,11 @@ static void m32r_sio_start_tx(struct uart_port *port) | |||
| 266 | if (!(up->ier & UART_IER_THRI)) { | 266 | if (!(up->ier & UART_IER_THRI)) { |
| 267 | up->ier |= UART_IER_THRI; | 267 | up->ier |= UART_IER_THRI; |
| 268 | serial_out(up, UART_IER, up->ier); | 268 | serial_out(up, UART_IER, up->ier); |
| 269 | serial_out(up, UART_TX, xmit->buf[xmit->tail]); | 269 | if (!uart_circ_empty(xmit)) { |
| 270 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 270 | serial_out(up, UART_TX, xmit->buf[xmit->tail]); |
| 271 | up->port.icount.tx++; | 271 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
| 272 | up->port.icount.tx++; | ||
| 273 | } | ||
| 272 | } | 274 | } |
| 273 | while((serial_in(up, UART_LSR) & UART_EMPTY) != UART_EMPTY); | 275 | while((serial_in(up, UART_LSR) & UART_EMPTY) != UART_EMPTY); |
| 274 | #else | 276 | #else |
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c index 8193635103ee..f7ad5b903055 100644 --- a/drivers/tty/serial/pmac_zilog.c +++ b/drivers/tty/serial/pmac_zilog.c | |||
| @@ -653,6 +653,8 @@ static void pmz_start_tx(struct uart_port *port) | |||
| 653 | } else { | 653 | } else { |
| 654 | struct circ_buf *xmit = &port->state->xmit; | 654 | struct circ_buf *xmit = &port->state->xmit; |
| 655 | 655 | ||
| 656 | if (uart_circ_empty(xmit)) | ||
| 657 | goto out; | ||
| 656 | write_zsdata(uap, xmit->buf[xmit->tail]); | 658 | write_zsdata(uap, xmit->buf[xmit->tail]); |
| 657 | zssync(uap); | 659 | zssync(uap); |
| 658 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); | 660 | xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); |
| @@ -661,6 +663,7 @@ static void pmz_start_tx(struct uart_port *port) | |||
| 661 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) | 663 | if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) |
| 662 | uart_write_wakeup(&uap->port); | 664 | uart_write_wakeup(&uap->port); |
| 663 | } | 665 | } |
| 666 | out: | ||
| 664 | pmz_debug("pmz: start_tx() done.\n"); | 667 | pmz_debug("pmz: start_tx() done.\n"); |
| 665 | } | 668 | } |
| 666 | 669 | ||
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index 80a58eca785b..2f57df9a71d9 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c | |||
| @@ -427,6 +427,9 @@ static void sunsab_start_tx(struct uart_port *port) | |||
| 427 | struct circ_buf *xmit = &up->port.state->xmit; | 427 | struct circ_buf *xmit = &up->port.state->xmit; |
| 428 | int i; | 428 | int i; |
| 429 | 429 | ||
| 430 | if (uart_circ_empty(xmit)) | ||
| 431 | return; | ||
| 432 | |||
| 430 | up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR); | 433 | up->interrupt_mask1 &= ~(SAB82532_IMR1_ALLS|SAB82532_IMR1_XPR); |
| 431 | writeb(up->interrupt_mask1, &up->regs->w.imr1); | 434 | writeb(up->interrupt_mask1, &up->regs->w.imr1); |
| 432 | 435 | ||
diff --git a/drivers/tty/serial/sunzilog.c b/drivers/tty/serial/sunzilog.c index a85db8b87156..02df3940b95e 100644 --- a/drivers/tty/serial/sunzilog.c +++ b/drivers/tty/serial/sunzilog.c | |||
| @@ -703,6 +703,8 @@ static void sunzilog_start_tx(struct uart_port *port) | |||
| 703 | } else { | 703 | } else { |
| 704 | struct circ_buf *xmit = &port->state->xmit; | 704 | struct circ_buf *xmit = &port->state->xmit; |
| 705 | 705 | ||
| 706 | if (uart_circ_empty(xmit)) | ||
| 707 | return; | ||
| 706 | writeb(xmit->buf[xmit->tail], &channel->data); | 708 | writeb(xmit->buf[xmit->tail], &channel->data); |
| 707 | ZSDELAY(); | 709 | ZSDELAY(); |
| 708 | ZS_WSYNC(channel); | 710 | ZS_WSYNC(channel); |
diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 9d2b673f90e3..b8125aa64ad8 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c | |||
| @@ -1169,8 +1169,8 @@ static int ep_enable(struct usb_ep *ep, | |||
| 1169 | 1169 | ||
| 1170 | if (hwep->type == USB_ENDPOINT_XFER_CONTROL) | 1170 | if (hwep->type == USB_ENDPOINT_XFER_CONTROL) |
| 1171 | cap |= QH_IOS; | 1171 | cap |= QH_IOS; |
| 1172 | if (hwep->num) | 1172 | |
| 1173 | cap |= QH_ZLT; | 1173 | cap |= QH_ZLT; |
| 1174 | cap |= (hwep->ep.maxpacket << __ffs(QH_MAX_PKT)) & QH_MAX_PKT; | 1174 | cap |= (hwep->ep.maxpacket << __ffs(QH_MAX_PKT)) & QH_MAX_PKT; |
| 1175 | /* | 1175 | /* |
| 1176 | * For ISO-TX, we set mult at QH as the largest value, and use | 1176 | * For ISO-TX, we set mult at QH as the largest value, and use |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 21b99b4b4082..0e950ad8cb25 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
| @@ -889,6 +889,25 @@ static int hub_usb3_port_disable(struct usb_hub *hub, int port1) | |||
| 889 | if (!hub_is_superspeed(hub->hdev)) | 889 | if (!hub_is_superspeed(hub->hdev)) |
| 890 | return -EINVAL; | 890 | return -EINVAL; |
| 891 | 891 | ||
| 892 | ret = hub_port_status(hub, port1, &portstatus, &portchange); | ||
| 893 | if (ret < 0) | ||
| 894 | return ret; | ||
| 895 | |||
| 896 | /* | ||
| 897 | * USB controller Advanced Micro Devices, Inc. [AMD] FCH USB XHCI | ||
| 898 | * Controller [1022:7814] will have spurious result making the following | ||
| 899 | * usb 3.0 device hotplugging route to the 2.0 root hub and recognized | ||
| 900 | * as high-speed device if we set the usb 3.0 port link state to | ||
| 901 | * Disabled. Since it's already in USB_SS_PORT_LS_RX_DETECT state, we | ||
| 902 | * check the state here to avoid the bug. | ||
| 903 | */ | ||
| 904 | if ((portstatus & USB_PORT_STAT_LINK_STATE) == | ||
| 905 | USB_SS_PORT_LS_RX_DETECT) { | ||
| 906 | dev_dbg(&hub->ports[port1 - 1]->dev, | ||
| 907 | "Not disabling port; link state is RxDetect\n"); | ||
| 908 | return ret; | ||
| 909 | } | ||
| 910 | |||
| 892 | ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); | 911 | ret = hub_set_port_link_state(hub, port1, USB_SS_PORT_LS_SS_DISABLED); |
| 893 | if (ret) | 912 | if (ret) |
| 894 | return ret; | 913 | return ret; |
diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c index 762e4a5f5ae9..330df5ce435b 100644 --- a/drivers/usb/serial/cp210x.c +++ b/drivers/usb/serial/cp210x.c | |||
| @@ -153,6 +153,7 @@ static const struct usb_device_id id_table[] = { | |||
| 153 | { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ | 153 | { USB_DEVICE(0x1843, 0x0200) }, /* Vaisala USB Instrument Cable */ |
| 154 | { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ | 154 | { USB_DEVICE(0x18EF, 0xE00F) }, /* ELV USB-I2C-Interface */ |
| 155 | { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ | 155 | { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ |
| 156 | { USB_DEVICE(0x1B1C, 0x1C00) }, /* Corsair USB Dongle */ | ||
| 156 | { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ | 157 | { USB_DEVICE(0x1BE3, 0x07A6) }, /* WAGO 750-923 USB Service Cable */ |
| 157 | { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */ | 158 | { USB_DEVICE(0x1E29, 0x0102) }, /* Festo CPX-USB */ |
| 158 | { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */ | 159 | { USB_DEVICE(0x1E29, 0x0501) }, /* Festo CMSP */ |
diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index 115662c16dcc..8a3813be1b28 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c | |||
| @@ -720,7 +720,8 @@ static const struct usb_device_id id_table_combined[] = { | |||
| 720 | { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, | 720 | { USB_DEVICE(FTDI_VID, FTDI_ACG_HFDUAL_PID) }, |
| 721 | { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) }, | 721 | { USB_DEVICE(FTDI_VID, FTDI_YEI_SERVOCENTER31_PID) }, |
| 722 | { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) }, | 722 | { USB_DEVICE(FTDI_VID, FTDI_THORLABS_PID) }, |
| 723 | { USB_DEVICE(TESTO_VID, TESTO_USB_INTERFACE_PID) }, | 723 | { USB_DEVICE(TESTO_VID, TESTO_1_PID) }, |
| 724 | { USB_DEVICE(TESTO_VID, TESTO_3_PID) }, | ||
| 724 | { USB_DEVICE(FTDI_VID, FTDI_GAMMA_SCOUT_PID) }, | 725 | { USB_DEVICE(FTDI_VID, FTDI_GAMMA_SCOUT_PID) }, |
| 725 | { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, | 726 | { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13M_PID) }, |
| 726 | { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, | 727 | { USB_DEVICE(FTDI_VID, FTDI_TACTRIX_OPENPORT_13S_PID) }, |
| @@ -944,6 +945,8 @@ static const struct usb_device_id id_table_combined[] = { | |||
| 944 | { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) }, | 945 | { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_2_PID) }, |
| 945 | { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) }, | 946 | { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_3_PID) }, |
| 946 | { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) }, | 947 | { USB_DEVICE(BRAINBOXES_VID, BRAINBOXES_US_842_4_PID) }, |
| 948 | /* Infineon Devices */ | ||
| 949 | { USB_DEVICE_INTERFACE_NUMBER(INFINEON_VID, INFINEON_TRIBOARD_PID, 1) }, | ||
| 947 | { } /* Terminating entry */ | 950 | { } /* Terminating entry */ |
| 948 | }; | 951 | }; |
| 949 | 952 | ||
diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h index 500474c48f4b..c4777bc6aee0 100644 --- a/drivers/usb/serial/ftdi_sio_ids.h +++ b/drivers/usb/serial/ftdi_sio_ids.h | |||
| @@ -584,6 +584,12 @@ | |||
| 584 | #define RATOC_PRODUCT_ID_USB60F 0xb020 | 584 | #define RATOC_PRODUCT_ID_USB60F 0xb020 |
| 585 | 585 | ||
| 586 | /* | 586 | /* |
| 587 | * Infineon Technologies | ||
| 588 | */ | ||
| 589 | #define INFINEON_VID 0x058b | ||
| 590 | #define INFINEON_TRIBOARD_PID 0x0028 /* DAS JTAG TriBoard TC1798 V1.0 */ | ||
| 591 | |||
| 592 | /* | ||
| 587 | * Acton Research Corp. | 593 | * Acton Research Corp. |
| 588 | */ | 594 | */ |
| 589 | #define ACTON_VID 0x0647 /* Vendor ID */ | 595 | #define ACTON_VID 0x0647 /* Vendor ID */ |
| @@ -798,7 +804,8 @@ | |||
| 798 | * Submitted by Colin Leroy | 804 | * Submitted by Colin Leroy |
| 799 | */ | 805 | */ |
| 800 | #define TESTO_VID 0x128D | 806 | #define TESTO_VID 0x128D |
| 801 | #define TESTO_USB_INTERFACE_PID 0x0001 | 807 | #define TESTO_1_PID 0x0001 |
| 808 | #define TESTO_3_PID 0x0003 | ||
| 802 | 809 | ||
| 803 | /* | 810 | /* |
| 804 | * Mobility Electronics products. | 811 | * Mobility Electronics products. |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index ac73f49cd9f0..a9688940543d 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
| @@ -1487,6 +1487,8 @@ static const struct usb_device_id option_ids[] = { | |||
| 1487 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | 1487 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, |
| 1488 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */ | 1488 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1426, 0xff, 0xff, 0xff), /* ZTE MF91 */ |
| 1489 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | 1489 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, |
| 1490 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1428, 0xff, 0xff, 0xff), /* Telewell TW-LTE 4G v2 */ | ||
| 1491 | .driver_info = (kernel_ulong_t)&net_intf2_blacklist }, | ||
| 1490 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff) }, | 1492 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1533, 0xff, 0xff, 0xff) }, |
| 1491 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1534, 0xff, 0xff, 0xff) }, | 1493 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1534, 0xff, 0xff, 0xff) }, |
| 1492 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1535, 0xff, 0xff, 0xff) }, | 1494 | { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1535, 0xff, 0xff, 0xff) }, |
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c index b7a506f2bb14..5c660c77f03b 100644 --- a/drivers/xen/balloon.c +++ b/drivers/xen/balloon.c | |||
| @@ -426,20 +426,18 @@ static enum bp_state decrease_reservation(unsigned long nr_pages, gfp_t gfp) | |||
| 426 | * p2m are consistent. | 426 | * p2m are consistent. |
| 427 | */ | 427 | */ |
| 428 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { | 428 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { |
| 429 | unsigned long p; | ||
| 430 | struct page *scratch_page = get_balloon_scratch_page(); | ||
| 431 | |||
| 432 | if (!PageHighMem(page)) { | 429 | if (!PageHighMem(page)) { |
| 430 | struct page *scratch_page = get_balloon_scratch_page(); | ||
| 431 | |||
| 433 | ret = HYPERVISOR_update_va_mapping( | 432 | ret = HYPERVISOR_update_va_mapping( |
| 434 | (unsigned long)__va(pfn << PAGE_SHIFT), | 433 | (unsigned long)__va(pfn << PAGE_SHIFT), |
| 435 | pfn_pte(page_to_pfn(scratch_page), | 434 | pfn_pte(page_to_pfn(scratch_page), |
| 436 | PAGE_KERNEL_RO), 0); | 435 | PAGE_KERNEL_RO), 0); |
| 437 | BUG_ON(ret); | 436 | BUG_ON(ret); |
| 438 | } | ||
| 439 | p = page_to_pfn(scratch_page); | ||
| 440 | __set_phys_to_machine(pfn, pfn_to_mfn(p)); | ||
| 441 | 437 | ||
| 442 | put_balloon_scratch_page(); | 438 | put_balloon_scratch_page(); |
| 439 | } | ||
| 440 | __set_phys_to_machine(pfn, INVALID_P2M_ENTRY); | ||
| 443 | } | 441 | } |
| 444 | #endif | 442 | #endif |
| 445 | 443 | ||
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 5d4de88fe5b8..eeba7544f0cd 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
| @@ -1195,18 +1195,20 @@ static int gnttab_expand(unsigned int req_entries) | |||
| 1195 | int gnttab_init(void) | 1195 | int gnttab_init(void) |
| 1196 | { | 1196 | { |
| 1197 | int i; | 1197 | int i; |
| 1198 | unsigned long max_nr_grant_frames; | ||
| 1198 | unsigned int max_nr_glist_frames, nr_glist_frames; | 1199 | unsigned int max_nr_glist_frames, nr_glist_frames; |
| 1199 | unsigned int nr_init_grefs; | 1200 | unsigned int nr_init_grefs; |
| 1200 | int ret; | 1201 | int ret; |
| 1201 | 1202 | ||
| 1202 | gnttab_request_version(); | 1203 | gnttab_request_version(); |
| 1204 | max_nr_grant_frames = gnttab_max_grant_frames(); | ||
| 1203 | nr_grant_frames = 1; | 1205 | nr_grant_frames = 1; |
| 1204 | 1206 | ||
| 1205 | /* Determine the maximum number of frames required for the | 1207 | /* Determine the maximum number of frames required for the |
| 1206 | * grant reference free list on the current hypervisor. | 1208 | * grant reference free list on the current hypervisor. |
| 1207 | */ | 1209 | */ |
| 1208 | BUG_ON(grefs_per_grant_frame == 0); | 1210 | BUG_ON(grefs_per_grant_frame == 0); |
| 1209 | max_nr_glist_frames = (gnttab_max_grant_frames() * | 1211 | max_nr_glist_frames = (max_nr_grant_frames * |
| 1210 | grefs_per_grant_frame / RPP); | 1212 | grefs_per_grant_frame / RPP); |
| 1211 | 1213 | ||
| 1212 | gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), | 1214 | gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), |
| @@ -1223,6 +1225,11 @@ int gnttab_init(void) | |||
| 1223 | } | 1225 | } |
| 1224 | } | 1226 | } |
| 1225 | 1227 | ||
| 1228 | ret = arch_gnttab_init(max_nr_grant_frames, | ||
| 1229 | nr_status_frames(max_nr_grant_frames)); | ||
| 1230 | if (ret < 0) | ||
| 1231 | goto ini_nomem; | ||
| 1232 | |||
| 1226 | if (gnttab_setup() < 0) { | 1233 | if (gnttab_setup() < 0) { |
| 1227 | ret = -ENODEV; | 1234 | ret = -ENODEV; |
| 1228 | goto ini_nomem; | 1235 | goto ini_nomem; |
diff --git a/drivers/xen/manage.c b/drivers/xen/manage.c index c3667b202f2f..5f1e1f3cd186 100644 --- a/drivers/xen/manage.c +++ b/drivers/xen/manage.c | |||
| @@ -88,7 +88,6 @@ static int xen_suspend(void *data) | |||
| 88 | 88 | ||
| 89 | if (!si->cancelled) { | 89 | if (!si->cancelled) { |
| 90 | xen_irq_resume(); | 90 | xen_irq_resume(); |
| 91 | xen_console_resume(); | ||
| 92 | xen_timer_resume(); | 91 | xen_timer_resume(); |
| 93 | } | 92 | } |
| 94 | 93 | ||
| @@ -135,6 +134,10 @@ static void do_suspend(void) | |||
| 135 | 134 | ||
| 136 | err = stop_machine(xen_suspend, &si, cpumask_of(0)); | 135 | err = stop_machine(xen_suspend, &si, cpumask_of(0)); |
| 137 | 136 | ||
| 137 | /* Resume console as early as possible. */ | ||
| 138 | if (!si.cancelled) | ||
| 139 | xen_console_resume(); | ||
| 140 | |||
| 138 | raw_notifier_call_chain(&xen_resume_notifier, 0, NULL); | 141 | raw_notifier_call_chain(&xen_resume_notifier, 0, NULL); |
| 139 | 142 | ||
| 140 | dpm_resume_start(si.cancelled ? PMSG_THAW : PMSG_RESTORE); | 143 | dpm_resume_start(si.cancelled ? PMSG_THAW : PMSG_RESTORE); |
diff --git a/firmware/Makefile b/firmware/Makefile index 5747417069ca..0862d34cf7d1 100644 --- a/firmware/Makefile +++ b/firmware/Makefile | |||
| @@ -219,6 +219,12 @@ $(obj)/%.fw: $(obj)/%.H16 $(ihex2fw_dep) | |||
| 219 | obj-y += $(patsubst %,%.gen.o, $(fw-external-y)) | 219 | obj-y += $(patsubst %,%.gen.o, $(fw-external-y)) |
| 220 | obj-$(CONFIG_FIRMWARE_IN_KERNEL) += $(patsubst %,%.gen.o, $(fw-shipped-y)) | 220 | obj-$(CONFIG_FIRMWARE_IN_KERNEL) += $(patsubst %,%.gen.o, $(fw-shipped-y)) |
| 221 | 221 | ||
| 222 | ifeq ($(KBUILD_SRC),) | ||
| 223 | # Makefile.build only creates subdirectories for O= builds, but external | ||
| 224 | # firmware might live outside the kernel source tree | ||
| 225 | _dummy := $(foreach d,$(addprefix $(obj)/,$(dir $(fw-external-y))), $(shell [ -d $(d) ] || mkdir -p $(d))) | ||
| 226 | endif | ||
| 227 | |||
| 222 | # Remove .S files and binaries created from ihex | 228 | # Remove .S files and binaries created from ihex |
| 223 | # (during 'make clean' .config isn't included so they're all in $(fw-shipped-)) | 229 | # (during 'make clean' .config isn't included so they're all in $(fw-shipped-)) |
| 224 | targets := $(fw-shipped-) $(patsubst $(obj)/%,%, \ | 230 | targets := $(fw-shipped-) $(patsubst $(obj)/%,%, \ |
diff --git a/fs/afs/main.c b/fs/afs/main.c index 42dd2e499ed8..35de0c04729f 100644 --- a/fs/afs/main.c +++ b/fs/afs/main.c | |||
| @@ -55,13 +55,13 @@ static int __init afs_get_client_UUID(void) | |||
| 55 | afs_uuid.time_low = uuidtime; | 55 | afs_uuid.time_low = uuidtime; |
| 56 | afs_uuid.time_mid = uuidtime >> 32; | 56 | afs_uuid.time_mid = uuidtime >> 32; |
| 57 | afs_uuid.time_hi_and_version = (uuidtime >> 48) & AFS_UUID_TIMEHI_MASK; | 57 | afs_uuid.time_hi_and_version = (uuidtime >> 48) & AFS_UUID_TIMEHI_MASK; |
| 58 | afs_uuid.time_hi_and_version = AFS_UUID_VERSION_TIME; | 58 | afs_uuid.time_hi_and_version |= AFS_UUID_VERSION_TIME; |
| 59 | 59 | ||
| 60 | get_random_bytes(&clockseq, 2); | 60 | get_random_bytes(&clockseq, 2); |
| 61 | afs_uuid.clock_seq_low = clockseq; | 61 | afs_uuid.clock_seq_low = clockseq; |
| 62 | afs_uuid.clock_seq_hi_and_reserved = | 62 | afs_uuid.clock_seq_hi_and_reserved = |
| 63 | (clockseq >> 8) & AFS_UUID_CLOCKHI_MASK; | 63 | (clockseq >> 8) & AFS_UUID_CLOCKHI_MASK; |
| 64 | afs_uuid.clock_seq_hi_and_reserved = AFS_UUID_VARIANT_STD; | 64 | afs_uuid.clock_seq_hi_and_reserved |= AFS_UUID_VARIANT_STD; |
| 65 | 65 | ||
| 66 | _debug("AFS UUID: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", | 66 | _debug("AFS UUID: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", |
| 67 | afs_uuid.time_low, | 67 | afs_uuid.time_low, |
| @@ -830,16 +830,20 @@ void exit_aio(struct mm_struct *mm) | |||
| 830 | static void put_reqs_available(struct kioctx *ctx, unsigned nr) | 830 | static void put_reqs_available(struct kioctx *ctx, unsigned nr) |
| 831 | { | 831 | { |
| 832 | struct kioctx_cpu *kcpu; | 832 | struct kioctx_cpu *kcpu; |
| 833 | unsigned long flags; | ||
| 833 | 834 | ||
| 834 | preempt_disable(); | 835 | preempt_disable(); |
| 835 | kcpu = this_cpu_ptr(ctx->cpu); | 836 | kcpu = this_cpu_ptr(ctx->cpu); |
| 836 | 837 | ||
| 838 | local_irq_save(flags); | ||
| 837 | kcpu->reqs_available += nr; | 839 | kcpu->reqs_available += nr; |
| 840 | |||
| 838 | while (kcpu->reqs_available >= ctx->req_batch * 2) { | 841 | while (kcpu->reqs_available >= ctx->req_batch * 2) { |
| 839 | kcpu->reqs_available -= ctx->req_batch; | 842 | kcpu->reqs_available -= ctx->req_batch; |
| 840 | atomic_add(ctx->req_batch, &ctx->reqs_available); | 843 | atomic_add(ctx->req_batch, &ctx->reqs_available); |
| 841 | } | 844 | } |
| 842 | 845 | ||
| 846 | local_irq_restore(flags); | ||
| 843 | preempt_enable(); | 847 | preempt_enable(); |
| 844 | } | 848 | } |
| 845 | 849 | ||
| @@ -847,10 +851,12 @@ static bool get_reqs_available(struct kioctx *ctx) | |||
| 847 | { | 851 | { |
| 848 | struct kioctx_cpu *kcpu; | 852 | struct kioctx_cpu *kcpu; |
| 849 | bool ret = false; | 853 | bool ret = false; |
| 854 | unsigned long flags; | ||
| 850 | 855 | ||
| 851 | preempt_disable(); | 856 | preempt_disable(); |
| 852 | kcpu = this_cpu_ptr(ctx->cpu); | 857 | kcpu = this_cpu_ptr(ctx->cpu); |
| 853 | 858 | ||
| 859 | local_irq_save(flags); | ||
| 854 | if (!kcpu->reqs_available) { | 860 | if (!kcpu->reqs_available) { |
| 855 | int old, avail = atomic_read(&ctx->reqs_available); | 861 | int old, avail = atomic_read(&ctx->reqs_available); |
| 856 | 862 | ||
| @@ -869,6 +875,7 @@ static bool get_reqs_available(struct kioctx *ctx) | |||
| 869 | ret = true; | 875 | ret = true; |
| 870 | kcpu->reqs_available--; | 876 | kcpu->reqs_available--; |
| 871 | out: | 877 | out: |
| 878 | local_irq_restore(flags); | ||
| 872 | preempt_enable(); | 879 | preempt_enable(); |
| 873 | return ret; | 880 | return ret; |
| 874 | } | 881 | } |
diff --git a/fs/btrfs/ordered-data.c b/fs/btrfs/ordered-data.c index e12441c7cf1d..7187b14faa6c 100644 --- a/fs/btrfs/ordered-data.c +++ b/fs/btrfs/ordered-data.c | |||
| @@ -484,8 +484,19 @@ void btrfs_wait_logged_extents(struct btrfs_root *log, u64 transid) | |||
| 484 | log_list); | 484 | log_list); |
| 485 | list_del_init(&ordered->log_list); | 485 | list_del_init(&ordered->log_list); |
| 486 | spin_unlock_irq(&log->log_extents_lock[index]); | 486 | spin_unlock_irq(&log->log_extents_lock[index]); |
| 487 | |||
| 488 | if (!test_bit(BTRFS_ORDERED_IO_DONE, &ordered->flags) && | ||
| 489 | !test_bit(BTRFS_ORDERED_DIRECT, &ordered->flags)) { | ||
| 490 | struct inode *inode = ordered->inode; | ||
| 491 | u64 start = ordered->file_offset; | ||
| 492 | u64 end = ordered->file_offset + ordered->len - 1; | ||
| 493 | |||
| 494 | WARN_ON(!inode); | ||
| 495 | filemap_fdatawrite_range(inode->i_mapping, start, end); | ||
| 496 | } | ||
| 487 | wait_event(ordered->wait, test_bit(BTRFS_ORDERED_IO_DONE, | 497 | wait_event(ordered->wait, test_bit(BTRFS_ORDERED_IO_DONE, |
| 488 | &ordered->flags)); | 498 | &ordered->flags)); |
| 499 | |||
| 489 | btrfs_put_ordered_extent(ordered); | 500 | btrfs_put_ordered_extent(ordered); |
| 490 | spin_lock_irq(&log->log_extents_lock[index]); | 501 | spin_lock_irq(&log->log_extents_lock[index]); |
| 491 | } | 502 | } |
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 6104676857f5..6cb82f62cb7c 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -1680,11 +1680,11 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
| 1680 | if (device->bdev == root->fs_info->fs_devices->latest_bdev) | 1680 | if (device->bdev == root->fs_info->fs_devices->latest_bdev) |
| 1681 | root->fs_info->fs_devices->latest_bdev = next_device->bdev; | 1681 | root->fs_info->fs_devices->latest_bdev = next_device->bdev; |
| 1682 | 1682 | ||
| 1683 | if (device->bdev) | 1683 | if (device->bdev) { |
| 1684 | device->fs_devices->open_devices--; | 1684 | device->fs_devices->open_devices--; |
| 1685 | 1685 | /* remove sysfs entry */ | |
| 1686 | /* remove sysfs entry */ | 1686 | btrfs_kobj_rm_device(root->fs_info, device); |
| 1687 | btrfs_kobj_rm_device(root->fs_info, device); | 1687 | } |
| 1688 | 1688 | ||
| 1689 | call_rcu(&device->rcu, free_device); | 1689 | call_rcu(&device->rcu, free_device); |
| 1690 | 1690 | ||
diff --git a/fs/coredump.c b/fs/coredump.c index 0b2528fb640e..a93f7e6ea4cf 100644 --- a/fs/coredump.c +++ b/fs/coredump.c | |||
| @@ -306,7 +306,7 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm, | |||
| 306 | if (unlikely(nr < 0)) | 306 | if (unlikely(nr < 0)) |
| 307 | return nr; | 307 | return nr; |
| 308 | 308 | ||
| 309 | tsk->flags = PF_DUMPCORE; | 309 | tsk->flags |= PF_DUMPCORE; |
| 310 | if (atomic_read(&mm->mm_users) == nr + 1) | 310 | if (atomic_read(&mm->mm_users) == nr + 1) |
| 311 | goto done; | 311 | goto done; |
| 312 | /* | 312 | /* |
diff --git a/fs/direct-io.c b/fs/direct-io.c index 98040ba388ac..17e39b047de5 100644 --- a/fs/direct-io.c +++ b/fs/direct-io.c | |||
| @@ -71,7 +71,6 @@ struct dio_submit { | |||
| 71 | been performed at the start of a | 71 | been performed at the start of a |
| 72 | write */ | 72 | write */ |
| 73 | int pages_in_io; /* approximate total IO pages */ | 73 | int pages_in_io; /* approximate total IO pages */ |
| 74 | size_t size; /* total request size (doesn't change)*/ | ||
| 75 | sector_t block_in_file; /* Current offset into the underlying | 74 | sector_t block_in_file; /* Current offset into the underlying |
| 76 | file in dio_block units. */ | 75 | file in dio_block units. */ |
| 77 | unsigned blocks_available; /* At block_in_file. changes */ | 76 | unsigned blocks_available; /* At block_in_file. changes */ |
| @@ -198,9 +197,8 @@ static inline int dio_refill_pages(struct dio *dio, struct dio_submit *sdio) | |||
| 198 | * L1 cache. | 197 | * L1 cache. |
| 199 | */ | 198 | */ |
| 200 | static inline struct page *dio_get_page(struct dio *dio, | 199 | static inline struct page *dio_get_page(struct dio *dio, |
| 201 | struct dio_submit *sdio, size_t *from, size_t *to) | 200 | struct dio_submit *sdio) |
| 202 | { | 201 | { |
| 203 | int n; | ||
| 204 | if (dio_pages_present(sdio) == 0) { | 202 | if (dio_pages_present(sdio) == 0) { |
| 205 | int ret; | 203 | int ret; |
| 206 | 204 | ||
| @@ -209,10 +207,7 @@ static inline struct page *dio_get_page(struct dio *dio, | |||
| 209 | return ERR_PTR(ret); | 207 | return ERR_PTR(ret); |
| 210 | BUG_ON(dio_pages_present(sdio) == 0); | 208 | BUG_ON(dio_pages_present(sdio) == 0); |
| 211 | } | 209 | } |
| 212 | n = sdio->head++; | 210 | return dio->pages[sdio->head]; |
| 213 | *from = n ? 0 : sdio->from; | ||
| 214 | *to = (n == sdio->tail - 1) ? sdio->to : PAGE_SIZE; | ||
| 215 | return dio->pages[n]; | ||
| 216 | } | 211 | } |
| 217 | 212 | ||
| 218 | /** | 213 | /** |
| @@ -911,11 +906,15 @@ static int do_direct_IO(struct dio *dio, struct dio_submit *sdio, | |||
| 911 | while (sdio->block_in_file < sdio->final_block_in_request) { | 906 | while (sdio->block_in_file < sdio->final_block_in_request) { |
| 912 | struct page *page; | 907 | struct page *page; |
| 913 | size_t from, to; | 908 | size_t from, to; |
| 914 | page = dio_get_page(dio, sdio, &from, &to); | 909 | |
| 910 | page = dio_get_page(dio, sdio); | ||
| 915 | if (IS_ERR(page)) { | 911 | if (IS_ERR(page)) { |
| 916 | ret = PTR_ERR(page); | 912 | ret = PTR_ERR(page); |
| 917 | goto out; | 913 | goto out; |
| 918 | } | 914 | } |
| 915 | from = sdio->head ? 0 : sdio->from; | ||
| 916 | to = (sdio->head == sdio->tail - 1) ? sdio->to : PAGE_SIZE; | ||
| 917 | sdio->head++; | ||
| 919 | 918 | ||
| 920 | while (from < to) { | 919 | while (from < to) { |
| 921 | unsigned this_chunk_bytes; /* # of bytes mapped */ | 920 | unsigned this_chunk_bytes; /* # of bytes mapped */ |
| @@ -1104,7 +1103,8 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | |||
| 1104 | unsigned blkbits = i_blkbits; | 1103 | unsigned blkbits = i_blkbits; |
| 1105 | unsigned blocksize_mask = (1 << blkbits) - 1; | 1104 | unsigned blocksize_mask = (1 << blkbits) - 1; |
| 1106 | ssize_t retval = -EINVAL; | 1105 | ssize_t retval = -EINVAL; |
| 1107 | loff_t end = offset + iov_iter_count(iter); | 1106 | size_t count = iov_iter_count(iter); |
| 1107 | loff_t end = offset + count; | ||
| 1108 | struct dio *dio; | 1108 | struct dio *dio; |
| 1109 | struct dio_submit sdio = { 0, }; | 1109 | struct dio_submit sdio = { 0, }; |
| 1110 | struct buffer_head map_bh = { 0, }; | 1110 | struct buffer_head map_bh = { 0, }; |
| @@ -1287,10 +1287,9 @@ do_blockdev_direct_IO(int rw, struct kiocb *iocb, struct inode *inode, | |||
| 1287 | */ | 1287 | */ |
| 1288 | BUG_ON(retval == -EIOCBQUEUED); | 1288 | BUG_ON(retval == -EIOCBQUEUED); |
| 1289 | if (dio->is_async && retval == 0 && dio->result && | 1289 | if (dio->is_async && retval == 0 && dio->result && |
| 1290 | ((rw == READ) || (dio->result == sdio.size))) | 1290 | (rw == READ || dio->result == count)) |
| 1291 | retval = -EIOCBQUEUED; | 1291 | retval = -EIOCBQUEUED; |
| 1292 | 1292 | else | |
| 1293 | if (retval != -EIOCBQUEUED) | ||
| 1294 | dio_await_completion(dio); | 1293 | dio_await_completion(dio); |
| 1295 | 1294 | ||
| 1296 | if (drop_refcount(dio) == 0) { | 1295 | if (drop_refcount(dio) == 0) { |
diff --git a/fs/ext4/extents_status.c b/fs/ext4/extents_status.c index 3f5c188953a4..0b7e28e7eaa4 100644 --- a/fs/ext4/extents_status.c +++ b/fs/ext4/extents_status.c | |||
| @@ -966,10 +966,10 @@ retry: | |||
| 966 | continue; | 966 | continue; |
| 967 | } | 967 | } |
| 968 | 968 | ||
| 969 | if (ei->i_es_lru_nr == 0 || ei == locked_ei) | 969 | if (ei->i_es_lru_nr == 0 || ei == locked_ei || |
| 970 | !write_trylock(&ei->i_es_lock)) | ||
| 970 | continue; | 971 | continue; |
| 971 | 972 | ||
| 972 | write_lock(&ei->i_es_lock); | ||
| 973 | shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan); | 973 | shrunk = __es_try_to_reclaim_extents(ei, nr_to_scan); |
| 974 | if (ei->i_es_lru_nr == 0) | 974 | if (ei->i_es_lru_nr == 0) |
| 975 | list_del_init(&ei->i_es_lru); | 975 | list_del_init(&ei->i_es_lru); |
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c index a87455df38bc..5b87fc36aab8 100644 --- a/fs/ext4/ialloc.c +++ b/fs/ext4/ialloc.c | |||
| @@ -338,7 +338,7 @@ out: | |||
| 338 | fatal = err; | 338 | fatal = err; |
| 339 | } else { | 339 | } else { |
| 340 | ext4_error(sb, "bit already cleared for inode %lu", ino); | 340 | ext4_error(sb, "bit already cleared for inode %lu", ino); |
| 341 | if (!EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { | 341 | if (gdp && !EXT4_MB_GRP_IBITMAP_CORRUPT(grp)) { |
| 342 | int count; | 342 | int count; |
| 343 | count = ext4_free_inodes_count(sb, gdp); | 343 | count = ext4_free_inodes_count(sb, gdp); |
| 344 | percpu_counter_sub(&sbi->s_freeinodes_counter, | 344 | percpu_counter_sub(&sbi->s_freeinodes_counter, |
| @@ -874,6 +874,13 @@ got: | |||
| 874 | goto out; | 874 | goto out; |
| 875 | } | 875 | } |
| 876 | 876 | ||
| 877 | BUFFER_TRACE(group_desc_bh, "get_write_access"); | ||
| 878 | err = ext4_journal_get_write_access(handle, group_desc_bh); | ||
| 879 | if (err) { | ||
| 880 | ext4_std_error(sb, err); | ||
| 881 | goto out; | ||
| 882 | } | ||
| 883 | |||
| 877 | /* We may have to initialize the block bitmap if it isn't already */ | 884 | /* We may have to initialize the block bitmap if it isn't already */ |
| 878 | if (ext4_has_group_desc_csum(sb) && | 885 | if (ext4_has_group_desc_csum(sb) && |
| 879 | gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { | 886 | gdp->bg_flags & cpu_to_le16(EXT4_BG_BLOCK_UNINIT)) { |
| @@ -910,13 +917,6 @@ got: | |||
| 910 | } | 917 | } |
| 911 | } | 918 | } |
| 912 | 919 | ||
| 913 | BUFFER_TRACE(group_desc_bh, "get_write_access"); | ||
| 914 | err = ext4_journal_get_write_access(handle, group_desc_bh); | ||
| 915 | if (err) { | ||
| 916 | ext4_std_error(sb, err); | ||
| 917 | goto out; | ||
| 918 | } | ||
| 919 | |||
| 920 | /* Update the relevant bg descriptor fields */ | 920 | /* Update the relevant bg descriptor fields */ |
| 921 | if (ext4_has_group_desc_csum(sb)) { | 921 | if (ext4_has_group_desc_csum(sb)) { |
| 922 | int free; | 922 | int free; |
diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c index 7f72f50a8fa7..2dcb936be90e 100644 --- a/fs/ext4/mballoc.c +++ b/fs/ext4/mballoc.c | |||
| @@ -752,8 +752,8 @@ void ext4_mb_generate_buddy(struct super_block *sb, | |||
| 752 | 752 | ||
| 753 | if (free != grp->bb_free) { | 753 | if (free != grp->bb_free) { |
| 754 | ext4_grp_locked_error(sb, group, 0, 0, | 754 | ext4_grp_locked_error(sb, group, 0, 0, |
| 755 | "%u clusters in bitmap, %u in gd; " | 755 | "block bitmap and bg descriptor " |
| 756 | "block bitmap corrupt.", | 756 | "inconsistent: %u vs %u free clusters", |
| 757 | free, grp->bb_free); | 757 | free, grp->bb_free); |
| 758 | /* | 758 | /* |
| 759 | * If we intend to continue, we consider group descriptor | 759 | * If we intend to continue, we consider group descriptor |
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index b9b9aabfb4d2..6df7bc611dbd 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -1525,8 +1525,6 @@ static int handle_mount_opt(struct super_block *sb, char *opt, int token, | |||
| 1525 | arg = JBD2_DEFAULT_MAX_COMMIT_AGE; | 1525 | arg = JBD2_DEFAULT_MAX_COMMIT_AGE; |
| 1526 | sbi->s_commit_interval = HZ * arg; | 1526 | sbi->s_commit_interval = HZ * arg; |
| 1527 | } else if (token == Opt_max_batch_time) { | 1527 | } else if (token == Opt_max_batch_time) { |
| 1528 | if (arg == 0) | ||
| 1529 | arg = EXT4_DEF_MAX_BATCH_TIME; | ||
| 1530 | sbi->s_max_batch_time = arg; | 1528 | sbi->s_max_batch_time = arg; |
| 1531 | } else if (token == Opt_min_batch_time) { | 1529 | } else if (token == Opt_min_batch_time) { |
| 1532 | sbi->s_min_batch_time = arg; | 1530 | sbi->s_min_batch_time = arg; |
| @@ -2809,10 +2807,11 @@ static void print_daily_error_info(unsigned long arg) | |||
| 2809 | es = sbi->s_es; | 2807 | es = sbi->s_es; |
| 2810 | 2808 | ||
| 2811 | if (es->s_error_count) | 2809 | if (es->s_error_count) |
| 2812 | ext4_msg(sb, KERN_NOTICE, "error count: %u", | 2810 | /* fsck newer than v1.41.13 is needed to clean this condition. */ |
| 2811 | ext4_msg(sb, KERN_NOTICE, "error count since last fsck: %u", | ||
| 2813 | le32_to_cpu(es->s_error_count)); | 2812 | le32_to_cpu(es->s_error_count)); |
| 2814 | if (es->s_first_error_time) { | 2813 | if (es->s_first_error_time) { |
| 2815 | printk(KERN_NOTICE "EXT4-fs (%s): initial error at %u: %.*s:%d", | 2814 | printk(KERN_NOTICE "EXT4-fs (%s): initial error at time %u: %.*s:%d", |
| 2816 | sb->s_id, le32_to_cpu(es->s_first_error_time), | 2815 | sb->s_id, le32_to_cpu(es->s_first_error_time), |
| 2817 | (int) sizeof(es->s_first_error_func), | 2816 | (int) sizeof(es->s_first_error_func), |
| 2818 | es->s_first_error_func, | 2817 | es->s_first_error_func, |
| @@ -2826,7 +2825,7 @@ static void print_daily_error_info(unsigned long arg) | |||
| 2826 | printk("\n"); | 2825 | printk("\n"); |
| 2827 | } | 2826 | } |
| 2828 | if (es->s_last_error_time) { | 2827 | if (es->s_last_error_time) { |
| 2829 | printk(KERN_NOTICE "EXT4-fs (%s): last error at %u: %.*s:%d", | 2828 | printk(KERN_NOTICE "EXT4-fs (%s): last error at time %u: %.*s:%d", |
| 2830 | sb->s_id, le32_to_cpu(es->s_last_error_time), | 2829 | sb->s_id, le32_to_cpu(es->s_last_error_time), |
| 2831 | (int) sizeof(es->s_last_error_func), | 2830 | (int) sizeof(es->s_last_error_func), |
| 2832 | es->s_last_error_func, | 2831 | es->s_last_error_func, |
| @@ -3880,38 +3879,19 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 3880 | goto failed_mount2; | 3879 | goto failed_mount2; |
| 3881 | } | 3880 | } |
| 3882 | } | 3881 | } |
| 3883 | |||
| 3884 | /* | ||
| 3885 | * set up enough so that it can read an inode, | ||
| 3886 | * and create new inode for buddy allocator | ||
| 3887 | */ | ||
| 3888 | sbi->s_gdb_count = db_count; | ||
| 3889 | if (!test_opt(sb, NOLOAD) && | ||
| 3890 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) | ||
| 3891 | sb->s_op = &ext4_sops; | ||
| 3892 | else | ||
| 3893 | sb->s_op = &ext4_nojournal_sops; | ||
| 3894 | |||
| 3895 | ext4_ext_init(sb); | ||
| 3896 | err = ext4_mb_init(sb); | ||
| 3897 | if (err) { | ||
| 3898 | ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", | ||
| 3899 | err); | ||
| 3900 | goto failed_mount2; | ||
| 3901 | } | ||
| 3902 | |||
| 3903 | if (!ext4_check_descriptors(sb, &first_not_zeroed)) { | 3882 | if (!ext4_check_descriptors(sb, &first_not_zeroed)) { |
| 3904 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); | 3883 | ext4_msg(sb, KERN_ERR, "group descriptors corrupted!"); |
| 3905 | goto failed_mount2a; | 3884 | goto failed_mount2; |
| 3906 | } | 3885 | } |
| 3907 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) | 3886 | if (EXT4_HAS_INCOMPAT_FEATURE(sb, EXT4_FEATURE_INCOMPAT_FLEX_BG)) |
| 3908 | if (!ext4_fill_flex_info(sb)) { | 3887 | if (!ext4_fill_flex_info(sb)) { |
| 3909 | ext4_msg(sb, KERN_ERR, | 3888 | ext4_msg(sb, KERN_ERR, |
| 3910 | "unable to initialize " | 3889 | "unable to initialize " |
| 3911 | "flex_bg meta info!"); | 3890 | "flex_bg meta info!"); |
| 3912 | goto failed_mount2a; | 3891 | goto failed_mount2; |
| 3913 | } | 3892 | } |
| 3914 | 3893 | ||
| 3894 | sbi->s_gdb_count = db_count; | ||
| 3915 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); | 3895 | get_random_bytes(&sbi->s_next_generation, sizeof(u32)); |
| 3916 | spin_lock_init(&sbi->s_next_gen_lock); | 3896 | spin_lock_init(&sbi->s_next_gen_lock); |
| 3917 | 3897 | ||
| @@ -3946,6 +3926,14 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 3946 | sbi->s_stripe = ext4_get_stripe_size(sbi); | 3926 | sbi->s_stripe = ext4_get_stripe_size(sbi); |
| 3947 | sbi->s_extent_max_zeroout_kb = 32; | 3927 | sbi->s_extent_max_zeroout_kb = 32; |
| 3948 | 3928 | ||
| 3929 | /* | ||
| 3930 | * set up enough so that it can read an inode | ||
| 3931 | */ | ||
| 3932 | if (!test_opt(sb, NOLOAD) && | ||
| 3933 | EXT4_HAS_COMPAT_FEATURE(sb, EXT4_FEATURE_COMPAT_HAS_JOURNAL)) | ||
| 3934 | sb->s_op = &ext4_sops; | ||
| 3935 | else | ||
| 3936 | sb->s_op = &ext4_nojournal_sops; | ||
| 3949 | sb->s_export_op = &ext4_export_ops; | 3937 | sb->s_export_op = &ext4_export_ops; |
| 3950 | sb->s_xattr = ext4_xattr_handlers; | 3938 | sb->s_xattr = ext4_xattr_handlers; |
| 3951 | #ifdef CONFIG_QUOTA | 3939 | #ifdef CONFIG_QUOTA |
| @@ -4135,13 +4123,21 @@ no_journal: | |||
| 4135 | if (err) { | 4123 | if (err) { |
| 4136 | ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " | 4124 | ext4_msg(sb, KERN_ERR, "failed to reserve %llu clusters for " |
| 4137 | "reserved pool", ext4_calculate_resv_clusters(sb)); | 4125 | "reserved pool", ext4_calculate_resv_clusters(sb)); |
| 4138 | goto failed_mount5; | 4126 | goto failed_mount4a; |
| 4139 | } | 4127 | } |
| 4140 | 4128 | ||
| 4141 | err = ext4_setup_system_zone(sb); | 4129 | err = ext4_setup_system_zone(sb); |
| 4142 | if (err) { | 4130 | if (err) { |
| 4143 | ext4_msg(sb, KERN_ERR, "failed to initialize system " | 4131 | ext4_msg(sb, KERN_ERR, "failed to initialize system " |
| 4144 | "zone (%d)", err); | 4132 | "zone (%d)", err); |
| 4133 | goto failed_mount4a; | ||
| 4134 | } | ||
| 4135 | |||
| 4136 | ext4_ext_init(sb); | ||
| 4137 | err = ext4_mb_init(sb); | ||
| 4138 | if (err) { | ||
| 4139 | ext4_msg(sb, KERN_ERR, "failed to initialize mballoc (%d)", | ||
| 4140 | err); | ||
| 4145 | goto failed_mount5; | 4141 | goto failed_mount5; |
| 4146 | } | 4142 | } |
| 4147 | 4143 | ||
| @@ -4218,8 +4214,11 @@ failed_mount8: | |||
| 4218 | failed_mount7: | 4214 | failed_mount7: |
| 4219 | ext4_unregister_li_request(sb); | 4215 | ext4_unregister_li_request(sb); |
| 4220 | failed_mount6: | 4216 | failed_mount6: |
| 4221 | ext4_release_system_zone(sb); | 4217 | ext4_mb_release(sb); |
| 4222 | failed_mount5: | 4218 | failed_mount5: |
| 4219 | ext4_ext_release(sb); | ||
| 4220 | ext4_release_system_zone(sb); | ||
| 4221 | failed_mount4a: | ||
| 4223 | dput(sb->s_root); | 4222 | dput(sb->s_root); |
| 4224 | sb->s_root = NULL; | 4223 | sb->s_root = NULL; |
| 4225 | failed_mount4: | 4224 | failed_mount4: |
| @@ -4243,14 +4242,11 @@ failed_mount3: | |||
| 4243 | percpu_counter_destroy(&sbi->s_extent_cache_cnt); | 4242 | percpu_counter_destroy(&sbi->s_extent_cache_cnt); |
| 4244 | if (sbi->s_mmp_tsk) | 4243 | if (sbi->s_mmp_tsk) |
| 4245 | kthread_stop(sbi->s_mmp_tsk); | 4244 | kthread_stop(sbi->s_mmp_tsk); |
| 4246 | failed_mount2a: | ||
| 4247 | ext4_mb_release(sb); | ||
| 4248 | failed_mount2: | 4245 | failed_mount2: |
| 4249 | for (i = 0; i < db_count; i++) | 4246 | for (i = 0; i < db_count; i++) |
| 4250 | brelse(sbi->s_group_desc[i]); | 4247 | brelse(sbi->s_group_desc[i]); |
| 4251 | ext4_kvfree(sbi->s_group_desc); | 4248 | ext4_kvfree(sbi->s_group_desc); |
| 4252 | failed_mount: | 4249 | failed_mount: |
| 4253 | ext4_ext_release(sb); | ||
| 4254 | if (sbi->s_chksum_driver) | 4250 | if (sbi->s_chksum_driver) |
| 4255 | crypto_free_shash(sbi->s_chksum_driver); | 4251 | crypto_free_shash(sbi->s_chksum_driver); |
| 4256 | if (sbi->s_proc) { | 4252 | if (sbi->s_proc) { |
diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c index 0924521306b4..f8cf619edb5f 100644 --- a/fs/f2fs/data.c +++ b/fs/f2fs/data.c | |||
| @@ -608,8 +608,8 @@ static int __allocate_data_block(struct dnode_of_data *dn) | |||
| 608 | * b. do not use extent cache for better performance | 608 | * b. do not use extent cache for better performance |
| 609 | * c. give the block addresses to blockdev | 609 | * c. give the block addresses to blockdev |
| 610 | */ | 610 | */ |
| 611 | static int get_data_block(struct inode *inode, sector_t iblock, | 611 | static int __get_data_block(struct inode *inode, sector_t iblock, |
| 612 | struct buffer_head *bh_result, int create) | 612 | struct buffer_head *bh_result, int create, bool fiemap) |
| 613 | { | 613 | { |
| 614 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); | 614 | struct f2fs_sb_info *sbi = F2FS_SB(inode->i_sb); |
| 615 | unsigned int blkbits = inode->i_sb->s_blocksize_bits; | 615 | unsigned int blkbits = inode->i_sb->s_blocksize_bits; |
| @@ -637,7 +637,7 @@ static int get_data_block(struct inode *inode, sector_t iblock, | |||
| 637 | err = 0; | 637 | err = 0; |
| 638 | goto unlock_out; | 638 | goto unlock_out; |
| 639 | } | 639 | } |
| 640 | if (dn.data_blkaddr == NEW_ADDR) | 640 | if (dn.data_blkaddr == NEW_ADDR && !fiemap) |
| 641 | goto put_out; | 641 | goto put_out; |
| 642 | 642 | ||
| 643 | if (dn.data_blkaddr != NULL_ADDR) { | 643 | if (dn.data_blkaddr != NULL_ADDR) { |
| @@ -671,7 +671,7 @@ get_next: | |||
| 671 | err = 0; | 671 | err = 0; |
| 672 | goto unlock_out; | 672 | goto unlock_out; |
| 673 | } | 673 | } |
| 674 | if (dn.data_blkaddr == NEW_ADDR) | 674 | if (dn.data_blkaddr == NEW_ADDR && !fiemap) |
| 675 | goto put_out; | 675 | goto put_out; |
| 676 | 676 | ||
| 677 | end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode)); | 677 | end_offset = ADDRS_PER_PAGE(dn.node_page, F2FS_I(inode)); |
| @@ -708,10 +708,23 @@ out: | |||
| 708 | return err; | 708 | return err; |
| 709 | } | 709 | } |
| 710 | 710 | ||
| 711 | static int get_data_block(struct inode *inode, sector_t iblock, | ||
| 712 | struct buffer_head *bh_result, int create) | ||
| 713 | { | ||
| 714 | return __get_data_block(inode, iblock, bh_result, create, false); | ||
| 715 | } | ||
| 716 | |||
| 717 | static int get_data_block_fiemap(struct inode *inode, sector_t iblock, | ||
| 718 | struct buffer_head *bh_result, int create) | ||
| 719 | { | ||
| 720 | return __get_data_block(inode, iblock, bh_result, create, true); | ||
| 721 | } | ||
| 722 | |||
| 711 | int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, | 723 | int f2fs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo, |
| 712 | u64 start, u64 len) | 724 | u64 start, u64 len) |
| 713 | { | 725 | { |
| 714 | return generic_block_fiemap(inode, fieinfo, start, len, get_data_block); | 726 | return generic_block_fiemap(inode, fieinfo, |
| 727 | start, len, get_data_block_fiemap); | ||
| 715 | } | 728 | } |
| 716 | 729 | ||
| 717 | static int f2fs_read_data_page(struct file *file, struct page *page) | 730 | static int f2fs_read_data_page(struct file *file, struct page *page) |
diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index 966acb039e3b..a4addd72ebbd 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c | |||
| @@ -376,11 +376,11 @@ static struct page *init_inode_metadata(struct inode *inode, | |||
| 376 | 376 | ||
| 377 | put_error: | 377 | put_error: |
| 378 | f2fs_put_page(page, 1); | 378 | f2fs_put_page(page, 1); |
| 379 | error: | ||
| 379 | /* once the failed inode becomes a bad inode, i_mode is S_IFREG */ | 380 | /* once the failed inode becomes a bad inode, i_mode is S_IFREG */ |
| 380 | truncate_inode_pages(&inode->i_data, 0); | 381 | truncate_inode_pages(&inode->i_data, 0); |
| 381 | truncate_blocks(inode, 0); | 382 | truncate_blocks(inode, 0); |
| 382 | remove_dirty_dir_inode(inode); | 383 | remove_dirty_dir_inode(inode); |
| 383 | error: | ||
| 384 | remove_inode_page(inode); | 384 | remove_inode_page(inode); |
| 385 | return ERR_PTR(err); | 385 | return ERR_PTR(err); |
| 386 | } | 386 | } |
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index e51c732b0dd9..58df97e174d0 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h | |||
| @@ -342,9 +342,6 @@ struct f2fs_sm_info { | |||
| 342 | struct dirty_seglist_info *dirty_info; /* dirty segment information */ | 342 | struct dirty_seglist_info *dirty_info; /* dirty segment information */ |
| 343 | struct curseg_info *curseg_array; /* active segment information */ | 343 | struct curseg_info *curseg_array; /* active segment information */ |
| 344 | 344 | ||
| 345 | struct list_head wblist_head; /* list of under-writeback pages */ | ||
| 346 | spinlock_t wblist_lock; /* lock for checkpoint */ | ||
| 347 | |||
| 348 | block_t seg0_blkaddr; /* block address of 0'th segment */ | 345 | block_t seg0_blkaddr; /* block address of 0'th segment */ |
| 349 | block_t main_blkaddr; /* start block address of main area */ | 346 | block_t main_blkaddr; /* start block address of main area */ |
| 350 | block_t ssa_blkaddr; /* start block address of SSA area */ | 347 | block_t ssa_blkaddr; /* start block address of SSA area */ |
| @@ -644,7 +641,8 @@ static inline void f2fs_unlock_all(struct f2fs_sb_info *sbi) | |||
| 644 | */ | 641 | */ |
| 645 | static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid) | 642 | static inline int check_nid_range(struct f2fs_sb_info *sbi, nid_t nid) |
| 646 | { | 643 | { |
| 647 | WARN_ON((nid >= NM_I(sbi)->max_nid)); | 644 | if (unlikely(nid < F2FS_ROOT_INO(sbi))) |
| 645 | return -EINVAL; | ||
| 648 | if (unlikely(nid >= NM_I(sbi)->max_nid)) | 646 | if (unlikely(nid >= NM_I(sbi)->max_nid)) |
| 649 | return -EINVAL; | 647 | return -EINVAL; |
| 650 | return 0; | 648 | return 0; |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index c58e33075719..7d8b96275092 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
| @@ -659,16 +659,19 @@ static int expand_inode_data(struct inode *inode, loff_t offset, | |||
| 659 | off_start = offset & (PAGE_CACHE_SIZE - 1); | 659 | off_start = offset & (PAGE_CACHE_SIZE - 1); |
| 660 | off_end = (offset + len) & (PAGE_CACHE_SIZE - 1); | 660 | off_end = (offset + len) & (PAGE_CACHE_SIZE - 1); |
| 661 | 661 | ||
| 662 | f2fs_lock_op(sbi); | ||
| 663 | |||
| 662 | for (index = pg_start; index <= pg_end; index++) { | 664 | for (index = pg_start; index <= pg_end; index++) { |
| 663 | struct dnode_of_data dn; | 665 | struct dnode_of_data dn; |
| 664 | 666 | ||
| 665 | f2fs_lock_op(sbi); | 667 | if (index == pg_end && !off_end) |
| 668 | goto noalloc; | ||
| 669 | |||
| 666 | set_new_dnode(&dn, inode, NULL, NULL, 0); | 670 | set_new_dnode(&dn, inode, NULL, NULL, 0); |
| 667 | ret = f2fs_reserve_block(&dn, index); | 671 | ret = f2fs_reserve_block(&dn, index); |
| 668 | f2fs_unlock_op(sbi); | ||
| 669 | if (ret) | 672 | if (ret) |
| 670 | break; | 673 | break; |
| 671 | 674 | noalloc: | |
| 672 | if (pg_start == pg_end) | 675 | if (pg_start == pg_end) |
| 673 | new_size = offset + len; | 676 | new_size = offset + len; |
| 674 | else if (index == pg_start && off_start) | 677 | else if (index == pg_start && off_start) |
| @@ -683,8 +686,9 @@ static int expand_inode_data(struct inode *inode, loff_t offset, | |||
| 683 | i_size_read(inode) < new_size) { | 686 | i_size_read(inode) < new_size) { |
| 684 | i_size_write(inode, new_size); | 687 | i_size_write(inode, new_size); |
| 685 | mark_inode_dirty(inode); | 688 | mark_inode_dirty(inode); |
| 686 | f2fs_write_inode(inode, NULL); | 689 | update_inode_page(inode); |
| 687 | } | 690 | } |
| 691 | f2fs_unlock_op(sbi); | ||
| 688 | 692 | ||
| 689 | return ret; | 693 | return ret; |
| 690 | } | 694 | } |
diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c index adc622c6bdce..2cf6962f6cc8 100644 --- a/fs/f2fs/inode.c +++ b/fs/f2fs/inode.c | |||
| @@ -78,6 +78,7 @@ static int do_read_inode(struct inode *inode) | |||
| 78 | if (check_nid_range(sbi, inode->i_ino)) { | 78 | if (check_nid_range(sbi, inode->i_ino)) { |
| 79 | f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu", | 79 | f2fs_msg(inode->i_sb, KERN_ERR, "bad inode number: %lu", |
| 80 | (unsigned long) inode->i_ino); | 80 | (unsigned long) inode->i_ino); |
| 81 | WARN_ON(1); | ||
| 81 | return -EINVAL; | 82 | return -EINVAL; |
| 82 | } | 83 | } |
| 83 | 84 | ||
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 9138c32aa698..a6bdddc33ce2 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c | |||
| @@ -417,9 +417,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | f2fs_set_link(new_dir, new_entry, new_page, old_inode); | 419 | f2fs_set_link(new_dir, new_entry, new_page, old_inode); |
| 420 | down_write(&F2FS_I(old_inode)->i_sem); | ||
| 421 | F2FS_I(old_inode)->i_pino = new_dir->i_ino; | ||
| 422 | up_write(&F2FS_I(old_inode)->i_sem); | ||
| 423 | 420 | ||
| 424 | new_inode->i_ctime = CURRENT_TIME; | 421 | new_inode->i_ctime = CURRENT_TIME; |
| 425 | down_write(&F2FS_I(new_inode)->i_sem); | 422 | down_write(&F2FS_I(new_inode)->i_sem); |
| @@ -448,6 +445,10 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 448 | } | 445 | } |
| 449 | } | 446 | } |
| 450 | 447 | ||
| 448 | down_write(&F2FS_I(old_inode)->i_sem); | ||
| 449 | file_lost_pino(old_inode); | ||
| 450 | up_write(&F2FS_I(old_inode)->i_sem); | ||
| 451 | |||
| 451 | old_inode->i_ctime = CURRENT_TIME; | 452 | old_inode->i_ctime = CURRENT_TIME; |
| 452 | mark_inode_dirty(old_inode); | 453 | mark_inode_dirty(old_inode); |
| 453 | 454 | ||
| @@ -457,9 +458,6 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 457 | if (old_dir != new_dir) { | 458 | if (old_dir != new_dir) { |
| 458 | f2fs_set_link(old_inode, old_dir_entry, | 459 | f2fs_set_link(old_inode, old_dir_entry, |
| 459 | old_dir_page, new_dir); | 460 | old_dir_page, new_dir); |
| 460 | down_write(&F2FS_I(old_inode)->i_sem); | ||
| 461 | F2FS_I(old_inode)->i_pino = new_dir->i_ino; | ||
| 462 | up_write(&F2FS_I(old_inode)->i_sem); | ||
| 463 | update_inode_page(old_inode); | 461 | update_inode_page(old_inode); |
| 464 | } else { | 462 | } else { |
| 465 | kunmap(old_dir_page); | 463 | kunmap(old_dir_page); |
| @@ -474,7 +472,8 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
| 474 | return 0; | 472 | return 0; |
| 475 | 473 | ||
| 476 | put_out_dir: | 474 | put_out_dir: |
| 477 | f2fs_put_page(new_page, 1); | 475 | kunmap(new_page); |
| 476 | f2fs_put_page(new_page, 0); | ||
| 478 | out_dir: | 477 | out_dir: |
| 479 | if (old_dir_entry) { | 478 | if (old_dir_entry) { |
| 480 | kunmap(old_dir_page); | 479 | kunmap(old_dir_page); |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 9dfb9a042fd2..4b697ccc9b0c 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
| @@ -42,6 +42,8 @@ bool available_free_memory(struct f2fs_sb_info *sbi, int type) | |||
| 42 | mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12; | 42 | mem_size = (nm_i->nat_cnt * sizeof(struct nat_entry)) >> 12; |
| 43 | res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2); | 43 | res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 2); |
| 44 | } else if (type == DIRTY_DENTS) { | 44 | } else if (type == DIRTY_DENTS) { |
| 45 | if (sbi->sb->s_bdi->dirty_exceeded) | ||
| 46 | return false; | ||
| 45 | mem_size = get_pages(sbi, F2FS_DIRTY_DENTS); | 47 | mem_size = get_pages(sbi, F2FS_DIRTY_DENTS); |
| 46 | res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1); | 48 | res = mem_size < ((val.totalram * nm_i->ram_thresh / 100) >> 1); |
| 47 | } | 49 | } |
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index f25f0e07e26f..d04613df710a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
| @@ -272,14 +272,15 @@ int create_flush_cmd_control(struct f2fs_sb_info *sbi) | |||
| 272 | return -ENOMEM; | 272 | return -ENOMEM; |
| 273 | spin_lock_init(&fcc->issue_lock); | 273 | spin_lock_init(&fcc->issue_lock); |
| 274 | init_waitqueue_head(&fcc->flush_wait_queue); | 274 | init_waitqueue_head(&fcc->flush_wait_queue); |
| 275 | sbi->sm_info->cmd_control_info = fcc; | ||
| 275 | fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, | 276 | fcc->f2fs_issue_flush = kthread_run(issue_flush_thread, sbi, |
| 276 | "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); | 277 | "f2fs_flush-%u:%u", MAJOR(dev), MINOR(dev)); |
| 277 | if (IS_ERR(fcc->f2fs_issue_flush)) { | 278 | if (IS_ERR(fcc->f2fs_issue_flush)) { |
| 278 | err = PTR_ERR(fcc->f2fs_issue_flush); | 279 | err = PTR_ERR(fcc->f2fs_issue_flush); |
| 279 | kfree(fcc); | 280 | kfree(fcc); |
| 281 | sbi->sm_info->cmd_control_info = NULL; | ||
| 280 | return err; | 282 | return err; |
| 281 | } | 283 | } |
| 282 | sbi->sm_info->cmd_control_info = fcc; | ||
| 283 | 284 | ||
| 284 | return err; | 285 | return err; |
| 285 | } | 286 | } |
| @@ -1885,8 +1886,6 @@ int build_segment_manager(struct f2fs_sb_info *sbi) | |||
| 1885 | 1886 | ||
| 1886 | /* init sm info */ | 1887 | /* init sm info */ |
| 1887 | sbi->sm_info = sm_info; | 1888 | sbi->sm_info = sm_info; |
| 1888 | INIT_LIST_HEAD(&sm_info->wblist_head); | ||
| 1889 | spin_lock_init(&sm_info->wblist_lock); | ||
| 1890 | sm_info->seg0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr); | 1889 | sm_info->seg0_blkaddr = le32_to_cpu(raw_super->segment0_blkaddr); |
| 1891 | sm_info->main_blkaddr = le32_to_cpu(raw_super->main_blkaddr); | 1890 | sm_info->main_blkaddr = le32_to_cpu(raw_super->main_blkaddr); |
| 1892 | sm_info->segment_count = le32_to_cpu(raw_super->segment_count); | 1891 | sm_info->segment_count = le32_to_cpu(raw_super->segment_count); |
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index b2b18637cb9e..8f96d9372ade 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
| @@ -689,9 +689,7 @@ static struct inode *f2fs_nfs_get_inode(struct super_block *sb, | |||
| 689 | struct f2fs_sb_info *sbi = F2FS_SB(sb); | 689 | struct f2fs_sb_info *sbi = F2FS_SB(sb); |
| 690 | struct inode *inode; | 690 | struct inode *inode; |
| 691 | 691 | ||
| 692 | if (unlikely(ino < F2FS_ROOT_INO(sbi))) | 692 | if (check_nid_range(sbi, ino)) |
| 693 | return ERR_PTR(-ESTALE); | ||
| 694 | if (unlikely(ino >= NM_I(sbi)->max_nid)) | ||
| 695 | return ERR_PTR(-ESTALE); | 693 | return ERR_PTR(-ESTALE); |
| 696 | 694 | ||
| 697 | /* | 695 | /* |
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index 098f97bdcf1b..ca887314aba9 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
| @@ -643,9 +643,8 @@ struct fuse_copy_state { | |||
| 643 | unsigned long seglen; | 643 | unsigned long seglen; |
| 644 | unsigned long addr; | 644 | unsigned long addr; |
| 645 | struct page *pg; | 645 | struct page *pg; |
| 646 | void *mapaddr; | ||
| 647 | void *buf; | ||
| 648 | unsigned len; | 646 | unsigned len; |
| 647 | unsigned offset; | ||
| 649 | unsigned move_pages:1; | 648 | unsigned move_pages:1; |
| 650 | }; | 649 | }; |
| 651 | 650 | ||
| @@ -666,23 +665,17 @@ static void fuse_copy_finish(struct fuse_copy_state *cs) | |||
| 666 | if (cs->currbuf) { | 665 | if (cs->currbuf) { |
| 667 | struct pipe_buffer *buf = cs->currbuf; | 666 | struct pipe_buffer *buf = cs->currbuf; |
| 668 | 667 | ||
| 669 | if (!cs->write) { | 668 | if (cs->write) |
| 670 | kunmap_atomic(cs->mapaddr); | ||
| 671 | } else { | ||
| 672 | kunmap_atomic(cs->mapaddr); | ||
| 673 | buf->len = PAGE_SIZE - cs->len; | 669 | buf->len = PAGE_SIZE - cs->len; |
| 674 | } | ||
| 675 | cs->currbuf = NULL; | 670 | cs->currbuf = NULL; |
| 676 | cs->mapaddr = NULL; | 671 | } else if (cs->pg) { |
| 677 | } else if (cs->mapaddr) { | ||
| 678 | kunmap_atomic(cs->mapaddr); | ||
| 679 | if (cs->write) { | 672 | if (cs->write) { |
| 680 | flush_dcache_page(cs->pg); | 673 | flush_dcache_page(cs->pg); |
| 681 | set_page_dirty_lock(cs->pg); | 674 | set_page_dirty_lock(cs->pg); |
| 682 | } | 675 | } |
| 683 | put_page(cs->pg); | 676 | put_page(cs->pg); |
| 684 | cs->mapaddr = NULL; | ||
| 685 | } | 677 | } |
| 678 | cs->pg = NULL; | ||
| 686 | } | 679 | } |
| 687 | 680 | ||
| 688 | /* | 681 | /* |
| @@ -691,7 +684,7 @@ static void fuse_copy_finish(struct fuse_copy_state *cs) | |||
| 691 | */ | 684 | */ |
| 692 | static int fuse_copy_fill(struct fuse_copy_state *cs) | 685 | static int fuse_copy_fill(struct fuse_copy_state *cs) |
| 693 | { | 686 | { |
| 694 | unsigned long offset; | 687 | struct page *page; |
| 695 | int err; | 688 | int err; |
| 696 | 689 | ||
| 697 | unlock_request(cs->fc, cs->req); | 690 | unlock_request(cs->fc, cs->req); |
| @@ -706,14 +699,12 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) | |||
| 706 | 699 | ||
| 707 | BUG_ON(!cs->nr_segs); | 700 | BUG_ON(!cs->nr_segs); |
| 708 | cs->currbuf = buf; | 701 | cs->currbuf = buf; |
| 709 | cs->mapaddr = kmap_atomic(buf->page); | 702 | cs->pg = buf->page; |
| 703 | cs->offset = buf->offset; | ||
| 710 | cs->len = buf->len; | 704 | cs->len = buf->len; |
| 711 | cs->buf = cs->mapaddr + buf->offset; | ||
| 712 | cs->pipebufs++; | 705 | cs->pipebufs++; |
| 713 | cs->nr_segs--; | 706 | cs->nr_segs--; |
| 714 | } else { | 707 | } else { |
| 715 | struct page *page; | ||
| 716 | |||
| 717 | if (cs->nr_segs == cs->pipe->buffers) | 708 | if (cs->nr_segs == cs->pipe->buffers) |
| 718 | return -EIO; | 709 | return -EIO; |
| 719 | 710 | ||
| @@ -726,8 +717,8 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) | |||
| 726 | buf->len = 0; | 717 | buf->len = 0; |
| 727 | 718 | ||
| 728 | cs->currbuf = buf; | 719 | cs->currbuf = buf; |
| 729 | cs->mapaddr = kmap_atomic(page); | 720 | cs->pg = page; |
| 730 | cs->buf = cs->mapaddr; | 721 | cs->offset = 0; |
| 731 | cs->len = PAGE_SIZE; | 722 | cs->len = PAGE_SIZE; |
| 732 | cs->pipebufs++; | 723 | cs->pipebufs++; |
| 733 | cs->nr_segs++; | 724 | cs->nr_segs++; |
| @@ -740,14 +731,13 @@ static int fuse_copy_fill(struct fuse_copy_state *cs) | |||
| 740 | cs->iov++; | 731 | cs->iov++; |
| 741 | cs->nr_segs--; | 732 | cs->nr_segs--; |
| 742 | } | 733 | } |
| 743 | err = get_user_pages_fast(cs->addr, 1, cs->write, &cs->pg); | 734 | err = get_user_pages_fast(cs->addr, 1, cs->write, &page); |
| 744 | if (err < 0) | 735 | if (err < 0) |
| 745 | return err; | 736 | return err; |
| 746 | BUG_ON(err != 1); | 737 | BUG_ON(err != 1); |
| 747 | offset = cs->addr % PAGE_SIZE; | 738 | cs->pg = page; |
| 748 | cs->mapaddr = kmap_atomic(cs->pg); | 739 | cs->offset = cs->addr % PAGE_SIZE; |
| 749 | cs->buf = cs->mapaddr + offset; | 740 | cs->len = min(PAGE_SIZE - cs->offset, cs->seglen); |
| 750 | cs->len = min(PAGE_SIZE - offset, cs->seglen); | ||
| 751 | cs->seglen -= cs->len; | 741 | cs->seglen -= cs->len; |
| 752 | cs->addr += cs->len; | 742 | cs->addr += cs->len; |
| 753 | } | 743 | } |
| @@ -760,15 +750,20 @@ static int fuse_copy_do(struct fuse_copy_state *cs, void **val, unsigned *size) | |||
| 760 | { | 750 | { |
| 761 | unsigned ncpy = min(*size, cs->len); | 751 | unsigned ncpy = min(*size, cs->len); |
| 762 | if (val) { | 752 | if (val) { |
| 753 | void *pgaddr = kmap_atomic(cs->pg); | ||
| 754 | void *buf = pgaddr + cs->offset; | ||
| 755 | |||
| 763 | if (cs->write) | 756 | if (cs->write) |
| 764 | memcpy(cs->buf, *val, ncpy); | 757 | memcpy(buf, *val, ncpy); |
| 765 | else | 758 | else |
| 766 | memcpy(*val, cs->buf, ncpy); | 759 | memcpy(*val, buf, ncpy); |
| 760 | |||
| 761 | kunmap_atomic(pgaddr); | ||
| 767 | *val += ncpy; | 762 | *val += ncpy; |
| 768 | } | 763 | } |
| 769 | *size -= ncpy; | 764 | *size -= ncpy; |
| 770 | cs->len -= ncpy; | 765 | cs->len -= ncpy; |
| 771 | cs->buf += ncpy; | 766 | cs->offset += ncpy; |
| 772 | return ncpy; | 767 | return ncpy; |
| 773 | } | 768 | } |
| 774 | 769 | ||
| @@ -874,8 +869,8 @@ static int fuse_try_move_page(struct fuse_copy_state *cs, struct page **pagep) | |||
| 874 | out_fallback_unlock: | 869 | out_fallback_unlock: |
| 875 | unlock_page(newpage); | 870 | unlock_page(newpage); |
| 876 | out_fallback: | 871 | out_fallback: |
| 877 | cs->mapaddr = kmap_atomic(buf->page); | 872 | cs->pg = buf->page; |
| 878 | cs->buf = cs->mapaddr + buf->offset; | 873 | cs->offset = buf->offset; |
| 879 | 874 | ||
| 880 | err = lock_request(cs->fc, cs->req); | 875 | err = lock_request(cs->fc, cs->req); |
| 881 | if (err) | 876 | if (err) |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index 42198359fa1b..0c6048247a34 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
| @@ -198,7 +198,8 @@ static int fuse_dentry_revalidate(struct dentry *entry, unsigned int flags) | |||
| 198 | inode = ACCESS_ONCE(entry->d_inode); | 198 | inode = ACCESS_ONCE(entry->d_inode); |
| 199 | if (inode && is_bad_inode(inode)) | 199 | if (inode && is_bad_inode(inode)) |
| 200 | goto invalid; | 200 | goto invalid; |
| 201 | else if (fuse_dentry_time(entry) < get_jiffies_64()) { | 201 | else if (time_before64(fuse_dentry_time(entry), get_jiffies_64()) || |
| 202 | (flags & LOOKUP_REVAL)) { | ||
| 202 | int err; | 203 | int err; |
| 203 | struct fuse_entry_out outarg; | 204 | struct fuse_entry_out outarg; |
| 204 | struct fuse_req *req; | 205 | struct fuse_req *req; |
| @@ -814,13 +815,6 @@ static int fuse_rename_common(struct inode *olddir, struct dentry *oldent, | |||
| 814 | return err; | 815 | return err; |
| 815 | } | 816 | } |
| 816 | 817 | ||
| 817 | static int fuse_rename(struct inode *olddir, struct dentry *oldent, | ||
| 818 | struct inode *newdir, struct dentry *newent) | ||
| 819 | { | ||
| 820 | return fuse_rename_common(olddir, oldent, newdir, newent, 0, | ||
| 821 | FUSE_RENAME, sizeof(struct fuse_rename_in)); | ||
| 822 | } | ||
| 823 | |||
| 824 | static int fuse_rename2(struct inode *olddir, struct dentry *oldent, | 818 | static int fuse_rename2(struct inode *olddir, struct dentry *oldent, |
| 825 | struct inode *newdir, struct dentry *newent, | 819 | struct inode *newdir, struct dentry *newent, |
| 826 | unsigned int flags) | 820 | unsigned int flags) |
| @@ -831,17 +825,30 @@ static int fuse_rename2(struct inode *olddir, struct dentry *oldent, | |||
| 831 | if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) | 825 | if (flags & ~(RENAME_NOREPLACE | RENAME_EXCHANGE)) |
| 832 | return -EINVAL; | 826 | return -EINVAL; |
| 833 | 827 | ||
| 834 | if (fc->no_rename2 || fc->minor < 23) | 828 | if (flags) { |
| 835 | return -EINVAL; | 829 | if (fc->no_rename2 || fc->minor < 23) |
| 830 | return -EINVAL; | ||
| 836 | 831 | ||
| 837 | err = fuse_rename_common(olddir, oldent, newdir, newent, flags, | 832 | err = fuse_rename_common(olddir, oldent, newdir, newent, flags, |
| 838 | FUSE_RENAME2, sizeof(struct fuse_rename2_in)); | 833 | FUSE_RENAME2, |
| 839 | if (err == -ENOSYS) { | 834 | sizeof(struct fuse_rename2_in)); |
| 840 | fc->no_rename2 = 1; | 835 | if (err == -ENOSYS) { |
| 841 | err = -EINVAL; | 836 | fc->no_rename2 = 1; |
| 837 | err = -EINVAL; | ||
| 838 | } | ||
| 839 | } else { | ||
| 840 | err = fuse_rename_common(olddir, oldent, newdir, newent, 0, | ||
| 841 | FUSE_RENAME, | ||
| 842 | sizeof(struct fuse_rename_in)); | ||
| 842 | } | 843 | } |
| 844 | |||
| 843 | return err; | 845 | return err; |
| 846 | } | ||
| 844 | 847 | ||
| 848 | static int fuse_rename(struct inode *olddir, struct dentry *oldent, | ||
| 849 | struct inode *newdir, struct dentry *newent) | ||
| 850 | { | ||
| 851 | return fuse_rename2(olddir, oldent, newdir, newent, 0); | ||
| 845 | } | 852 | } |
| 846 | 853 | ||
| 847 | static int fuse_link(struct dentry *entry, struct inode *newdir, | 854 | static int fuse_link(struct dentry *entry, struct inode *newdir, |
| @@ -985,7 +992,7 @@ int fuse_update_attributes(struct inode *inode, struct kstat *stat, | |||
| 985 | int err; | 992 | int err; |
| 986 | bool r; | 993 | bool r; |
| 987 | 994 | ||
| 988 | if (fi->i_time < get_jiffies_64()) { | 995 | if (time_before64(fi->i_time, get_jiffies_64())) { |
| 989 | r = true; | 996 | r = true; |
| 990 | err = fuse_do_getattr(inode, stat, file); | 997 | err = fuse_do_getattr(inode, stat, file); |
| 991 | } else { | 998 | } else { |
| @@ -1171,7 +1178,7 @@ static int fuse_permission(struct inode *inode, int mask) | |||
| 1171 | ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) { | 1178 | ((mask & MAY_EXEC) && S_ISREG(inode->i_mode))) { |
| 1172 | struct fuse_inode *fi = get_fuse_inode(inode); | 1179 | struct fuse_inode *fi = get_fuse_inode(inode); |
| 1173 | 1180 | ||
| 1174 | if (fi->i_time < get_jiffies_64()) { | 1181 | if (time_before64(fi->i_time, get_jiffies_64())) { |
| 1175 | refreshed = true; | 1182 | refreshed = true; |
| 1176 | 1183 | ||
| 1177 | err = fuse_perm_getattr(inode, mask); | 1184 | err = fuse_perm_getattr(inode, mask); |
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 6e16dad13e9b..40ac2628ddcf 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c | |||
| @@ -1687,7 +1687,7 @@ static int fuse_writepage_locked(struct page *page) | |||
| 1687 | error = -EIO; | 1687 | error = -EIO; |
| 1688 | req->ff = fuse_write_file_get(fc, fi); | 1688 | req->ff = fuse_write_file_get(fc, fi); |
| 1689 | if (!req->ff) | 1689 | if (!req->ff) |
| 1690 | goto err_free; | 1690 | goto err_nofile; |
| 1691 | 1691 | ||
| 1692 | fuse_write_fill(req, req->ff, page_offset(page), 0); | 1692 | fuse_write_fill(req, req->ff, page_offset(page), 0); |
| 1693 | 1693 | ||
| @@ -1715,6 +1715,8 @@ static int fuse_writepage_locked(struct page *page) | |||
| 1715 | 1715 | ||
| 1716 | return 0; | 1716 | return 0; |
| 1717 | 1717 | ||
| 1718 | err_nofile: | ||
| 1719 | __free_page(tmp_page); | ||
| 1718 | err_free: | 1720 | err_free: |
| 1719 | fuse_request_free(req); | 1721 | fuse_request_free(req); |
| 1720 | err: | 1722 | err: |
| @@ -1955,8 +1957,8 @@ static int fuse_writepages(struct address_space *mapping, | |||
| 1955 | data.ff = NULL; | 1957 | data.ff = NULL; |
| 1956 | 1958 | ||
| 1957 | err = -ENOMEM; | 1959 | err = -ENOMEM; |
| 1958 | data.orig_pages = kzalloc(sizeof(struct page *) * | 1960 | data.orig_pages = kcalloc(FUSE_MAX_PAGES_PER_REQ, |
| 1959 | FUSE_MAX_PAGES_PER_REQ, | 1961 | sizeof(struct page *), |
| 1960 | GFP_NOFS); | 1962 | GFP_NOFS); |
| 1961 | if (!data.orig_pages) | 1963 | if (!data.orig_pages) |
| 1962 | goto out; | 1964 | goto out; |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 754dcf23de8a..03246cd9d47a 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
| @@ -478,6 +478,17 @@ static const match_table_t tokens = { | |||
| 478 | {OPT_ERR, NULL} | 478 | {OPT_ERR, NULL} |
| 479 | }; | 479 | }; |
| 480 | 480 | ||
| 481 | static int fuse_match_uint(substring_t *s, unsigned int *res) | ||
| 482 | { | ||
| 483 | int err = -ENOMEM; | ||
| 484 | char *buf = match_strdup(s); | ||
| 485 | if (buf) { | ||
| 486 | err = kstrtouint(buf, 10, res); | ||
| 487 | kfree(buf); | ||
| 488 | } | ||
| 489 | return err; | ||
| 490 | } | ||
| 491 | |||
| 481 | static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) | 492 | static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) |
| 482 | { | 493 | { |
| 483 | char *p; | 494 | char *p; |
| @@ -488,6 +499,7 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) | |||
| 488 | while ((p = strsep(&opt, ",")) != NULL) { | 499 | while ((p = strsep(&opt, ",")) != NULL) { |
| 489 | int token; | 500 | int token; |
| 490 | int value; | 501 | int value; |
| 502 | unsigned uv; | ||
| 491 | substring_t args[MAX_OPT_ARGS]; | 503 | substring_t args[MAX_OPT_ARGS]; |
| 492 | if (!*p) | 504 | if (!*p) |
| 493 | continue; | 505 | continue; |
| @@ -511,18 +523,18 @@ static int parse_fuse_opt(char *opt, struct fuse_mount_data *d, int is_bdev) | |||
| 511 | break; | 523 | break; |
| 512 | 524 | ||
| 513 | case OPT_USER_ID: | 525 | case OPT_USER_ID: |
| 514 | if (match_int(&args[0], &value)) | 526 | if (fuse_match_uint(&args[0], &uv)) |
| 515 | return 0; | 527 | return 0; |
| 516 | d->user_id = make_kuid(current_user_ns(), value); | 528 | d->user_id = make_kuid(current_user_ns(), uv); |
| 517 | if (!uid_valid(d->user_id)) | 529 | if (!uid_valid(d->user_id)) |
| 518 | return 0; | 530 | return 0; |
| 519 | d->user_id_present = 1; | 531 | d->user_id_present = 1; |
| 520 | break; | 532 | break; |
| 521 | 533 | ||
| 522 | case OPT_GROUP_ID: | 534 | case OPT_GROUP_ID: |
| 523 | if (match_int(&args[0], &value)) | 535 | if (fuse_match_uint(&args[0], &uv)) |
| 524 | return 0; | 536 | return 0; |
| 525 | d->group_id = make_kgid(current_user_ns(), value); | 537 | d->group_id = make_kgid(current_user_ns(), uv); |
| 526 | if (!gid_valid(d->group_id)) | 538 | if (!gid_valid(d->group_id)) |
| 527 | return 0; | 539 | return 0; |
| 528 | d->group_id_present = 1; | 540 | d->group_id_present = 1; |
| @@ -895,9 +907,6 @@ static void process_init_reply(struct fuse_conn *fc, struct fuse_req *req) | |||
| 895 | fc->writeback_cache = 1; | 907 | fc->writeback_cache = 1; |
| 896 | if (arg->time_gran && arg->time_gran <= 1000000000) | 908 | if (arg->time_gran && arg->time_gran <= 1000000000) |
| 897 | fc->sb->s_time_gran = arg->time_gran; | 909 | fc->sb->s_time_gran = arg->time_gran; |
| 898 | else | ||
| 899 | fc->sb->s_time_gran = 1000000000; | ||
| 900 | |||
| 901 | } else { | 910 | } else { |
| 902 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; | 911 | ra_pages = fc->max_read / PAGE_CACHE_SIZE; |
| 903 | fc->no_lock = 1; | 912 | fc->no_lock = 1; |
| @@ -926,7 +935,7 @@ static void fuse_send_init(struct fuse_conn *fc, struct fuse_req *req) | |||
| 926 | FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | | 935 | FUSE_SPLICE_WRITE | FUSE_SPLICE_MOVE | FUSE_SPLICE_READ | |
| 927 | FUSE_FLOCK_LOCKS | FUSE_IOCTL_DIR | FUSE_AUTO_INVAL_DATA | | 936 | FUSE_FLOCK_LOCKS | FUSE_IOCTL_DIR | FUSE_AUTO_INVAL_DATA | |
| 928 | FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO | | 937 | FUSE_DO_READDIRPLUS | FUSE_READDIRPLUS_AUTO | FUSE_ASYNC_DIO | |
| 929 | FUSE_WRITEBACK_CACHE; | 938 | FUSE_WRITEBACK_CACHE | FUSE_NO_OPEN_SUPPORT; |
| 930 | req->in.h.opcode = FUSE_INIT; | 939 | req->in.h.opcode = FUSE_INIT; |
| 931 | req->in.numargs = 1; | 940 | req->in.numargs = 1; |
| 932 | req->in.args[0].size = sizeof(*arg); | 941 | req->in.args[0].size = sizeof(*arg); |
| @@ -1006,7 +1015,7 @@ static int fuse_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1006 | 1015 | ||
| 1007 | sb->s_flags &= ~(MS_NOSEC | MS_I_VERSION); | 1016 | sb->s_flags &= ~(MS_NOSEC | MS_I_VERSION); |
| 1008 | 1017 | ||
| 1009 | if (!parse_fuse_opt((char *) data, &d, is_bdev)) | 1018 | if (!parse_fuse_opt(data, &d, is_bdev)) |
| 1010 | goto err; | 1019 | goto err; |
| 1011 | 1020 | ||
| 1012 | if (is_bdev) { | 1021 | if (is_bdev) { |
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 4fc3a3046174..26b3f952e6b1 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
| @@ -981,7 +981,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
| 981 | int error = 0; | 981 | int error = 0; |
| 982 | 982 | ||
| 983 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; | 983 | state = (fl->fl_type == F_WRLCK) ? LM_ST_EXCLUSIVE : LM_ST_SHARED; |
| 984 | flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT | GL_NOCACHE; | 984 | flags = (IS_SETLKW(cmd) ? 0 : LM_FLAG_TRY) | GL_EXACT; |
| 985 | 985 | ||
| 986 | mutex_lock(&fp->f_fl_mutex); | 986 | mutex_lock(&fp->f_fl_mutex); |
| 987 | 987 | ||
| @@ -991,7 +991,7 @@ static int do_flock(struct file *file, int cmd, struct file_lock *fl) | |||
| 991 | goto out; | 991 | goto out; |
| 992 | flock_lock_file_wait(file, | 992 | flock_lock_file_wait(file, |
| 993 | &(struct file_lock){.fl_type = F_UNLCK}); | 993 | &(struct file_lock){.fl_type = F_UNLCK}); |
| 994 | gfs2_glock_dq_wait(fl_gh); | 994 | gfs2_glock_dq(fl_gh); |
| 995 | gfs2_holder_reinit(state, flags, fl_gh); | 995 | gfs2_holder_reinit(state, flags, fl_gh); |
| 996 | } else { | 996 | } else { |
| 997 | error = gfs2_glock_get(GFS2_SB(&ip->i_inode), ip->i_no_addr, | 997 | error = gfs2_glock_get(GFS2_SB(&ip->i_inode), ip->i_no_addr, |
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index c355f7320e44..ee4e04fe60fc 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
| @@ -731,14 +731,14 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number, | |||
| 731 | cachep = gfs2_glock_aspace_cachep; | 731 | cachep = gfs2_glock_aspace_cachep; |
| 732 | else | 732 | else |
| 733 | cachep = gfs2_glock_cachep; | 733 | cachep = gfs2_glock_cachep; |
| 734 | gl = kmem_cache_alloc(cachep, GFP_KERNEL); | 734 | gl = kmem_cache_alloc(cachep, GFP_NOFS); |
| 735 | if (!gl) | 735 | if (!gl) |
| 736 | return -ENOMEM; | 736 | return -ENOMEM; |
| 737 | 737 | ||
| 738 | memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb)); | 738 | memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb)); |
| 739 | 739 | ||
| 740 | if (glops->go_flags & GLOF_LVB) { | 740 | if (glops->go_flags & GLOF_LVB) { |
| 741 | gl->gl_lksb.sb_lvbptr = kzalloc(GFS2_MIN_LVB_SIZE, GFP_KERNEL); | 741 | gl->gl_lksb.sb_lvbptr = kzalloc(GFS2_MIN_LVB_SIZE, GFP_NOFS); |
| 742 | if (!gl->gl_lksb.sb_lvbptr) { | 742 | if (!gl->gl_lksb.sb_lvbptr) { |
| 743 | kmem_cache_free(cachep, gl); | 743 | kmem_cache_free(cachep, gl); |
| 744 | return -ENOMEM; | 744 | return -ENOMEM; |
| @@ -1404,12 +1404,16 @@ __acquires(&lru_lock) | |||
| 1404 | gl = list_entry(list->next, struct gfs2_glock, gl_lru); | 1404 | gl = list_entry(list->next, struct gfs2_glock, gl_lru); |
| 1405 | list_del_init(&gl->gl_lru); | 1405 | list_del_init(&gl->gl_lru); |
| 1406 | if (!spin_trylock(&gl->gl_spin)) { | 1406 | if (!spin_trylock(&gl->gl_spin)) { |
| 1407 | add_back_to_lru: | ||
| 1407 | list_add(&gl->gl_lru, &lru_list); | 1408 | list_add(&gl->gl_lru, &lru_list); |
| 1408 | atomic_inc(&lru_count); | 1409 | atomic_inc(&lru_count); |
| 1409 | continue; | 1410 | continue; |
| 1410 | } | 1411 | } |
| 1412 | if (test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { | ||
| 1413 | spin_unlock(&gl->gl_spin); | ||
| 1414 | goto add_back_to_lru; | ||
| 1415 | } | ||
| 1411 | clear_bit(GLF_LRU, &gl->gl_flags); | 1416 | clear_bit(GLF_LRU, &gl->gl_flags); |
| 1412 | spin_unlock(&lru_lock); | ||
| 1413 | gl->gl_lockref.count++; | 1417 | gl->gl_lockref.count++; |
| 1414 | if (demote_ok(gl)) | 1418 | if (demote_ok(gl)) |
| 1415 | handle_callback(gl, LM_ST_UNLOCKED, 0, false); | 1419 | handle_callback(gl, LM_ST_UNLOCKED, 0, false); |
| @@ -1417,7 +1421,7 @@ __acquires(&lru_lock) | |||
| 1417 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) | 1421 | if (queue_delayed_work(glock_workqueue, &gl->gl_work, 0) == 0) |
| 1418 | gl->gl_lockref.count--; | 1422 | gl->gl_lockref.count--; |
| 1419 | spin_unlock(&gl->gl_spin); | 1423 | spin_unlock(&gl->gl_spin); |
| 1420 | spin_lock(&lru_lock); | 1424 | cond_resched_lock(&lru_lock); |
| 1421 | } | 1425 | } |
| 1422 | } | 1426 | } |
| 1423 | 1427 | ||
| @@ -1442,7 +1446,7 @@ static long gfs2_scan_glock_lru(int nr) | |||
| 1442 | gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru); | 1446 | gl = list_entry(lru_list.next, struct gfs2_glock, gl_lru); |
| 1443 | 1447 | ||
| 1444 | /* Test for being demotable */ | 1448 | /* Test for being demotable */ |
| 1445 | if (!test_and_set_bit(GLF_LOCK, &gl->gl_flags)) { | 1449 | if (!test_bit(GLF_LOCK, &gl->gl_flags)) { |
| 1446 | list_move(&gl->gl_lru, &dispose); | 1450 | list_move(&gl->gl_lru, &dispose); |
| 1447 | atomic_dec(&lru_count); | 1451 | atomic_dec(&lru_count); |
| 1448 | freed++; | 1452 | freed++; |
diff --git a/fs/gfs2/glops.c b/fs/gfs2/glops.c index fc1100781bbc..2ffc67dce87f 100644 --- a/fs/gfs2/glops.c +++ b/fs/gfs2/glops.c | |||
| @@ -234,8 +234,8 @@ static void inode_go_sync(struct gfs2_glock *gl) | |||
| 234 | * inode_go_inval - prepare a inode glock to be released | 234 | * inode_go_inval - prepare a inode glock to be released |
| 235 | * @gl: the glock | 235 | * @gl: the glock |
| 236 | * @flags: | 236 | * @flags: |
| 237 | * | 237 | * |
| 238 | * Normally we invlidate everything, but if we are moving into | 238 | * Normally we invalidate everything, but if we are moving into |
| 239 | * LM_ST_DEFERRED from LM_ST_SHARED or LM_ST_EXCLUSIVE then we | 239 | * LM_ST_DEFERRED from LM_ST_SHARED or LM_ST_EXCLUSIVE then we |
| 240 | * can keep hold of the metadata, since it won't have changed. | 240 | * can keep hold of the metadata, since it won't have changed. |
| 241 | * | 241 | * |
diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c index 91f274de1246..4fafea1c9ecf 100644 --- a/fs/gfs2/lock_dlm.c +++ b/fs/gfs2/lock_dlm.c | |||
| @@ -1036,8 +1036,8 @@ static int set_recover_size(struct gfs2_sbd *sdp, struct dlm_slot *slots, | |||
| 1036 | 1036 | ||
| 1037 | new_size = old_size + RECOVER_SIZE_INC; | 1037 | new_size = old_size + RECOVER_SIZE_INC; |
| 1038 | 1038 | ||
| 1039 | submit = kzalloc(new_size * sizeof(uint32_t), GFP_NOFS); | 1039 | submit = kcalloc(new_size, sizeof(uint32_t), GFP_NOFS); |
| 1040 | result = kzalloc(new_size * sizeof(uint32_t), GFP_NOFS); | 1040 | result = kcalloc(new_size, sizeof(uint32_t), GFP_NOFS); |
| 1041 | if (!submit || !result) { | 1041 | if (!submit || !result) { |
| 1042 | kfree(submit); | 1042 | kfree(submit); |
| 1043 | kfree(result); | 1043 | kfree(result); |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index db629d1bd1bd..f4cb9c0d6bbd 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
| @@ -337,7 +337,7 @@ static bool gfs2_unaligned_extlen(struct gfs2_rbm *rbm, u32 n_unaligned, u32 *le | |||
| 337 | 337 | ||
| 338 | /** | 338 | /** |
| 339 | * gfs2_free_extlen - Return extent length of free blocks | 339 | * gfs2_free_extlen - Return extent length of free blocks |
| 340 | * @rbm: Starting position | 340 | * @rrbm: Starting position |
| 341 | * @len: Max length to check | 341 | * @len: Max length to check |
| 342 | * | 342 | * |
| 343 | * Starting at the block specified by the rbm, see how many free blocks | 343 | * Starting at the block specified by the rbm, see how many free blocks |
| @@ -2522,7 +2522,7 @@ void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state) | |||
| 2522 | 2522 | ||
| 2523 | /** | 2523 | /** |
| 2524 | * gfs2_rlist_free - free a resource group list | 2524 | * gfs2_rlist_free - free a resource group list |
| 2525 | * @list: the list of resource groups | 2525 | * @rlist: the list of resource groups |
| 2526 | * | 2526 | * |
| 2527 | */ | 2527 | */ |
| 2528 | 2528 | ||
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index 38cfcf5f6fce..6f0f590cc5a3 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
| @@ -1588,9 +1588,12 @@ int jbd2_journal_stop(handle_t *handle) | |||
| 1588 | * to perform a synchronous write. We do this to detect the | 1588 | * to perform a synchronous write. We do this to detect the |
| 1589 | * case where a single process is doing a stream of sync | 1589 | * case where a single process is doing a stream of sync |
| 1590 | * writes. No point in waiting for joiners in that case. | 1590 | * writes. No point in waiting for joiners in that case. |
| 1591 | * | ||
| 1592 | * Setting max_batch_time to 0 disables this completely. | ||
| 1591 | */ | 1593 | */ |
| 1592 | pid = current->pid; | 1594 | pid = current->pid; |
| 1593 | if (handle->h_sync && journal->j_last_sync_writer != pid) { | 1595 | if (handle->h_sync && journal->j_last_sync_writer != pid && |
| 1596 | journal->j_max_batch_time) { | ||
| 1594 | u64 commit_time, trans_time; | 1597 | u64 commit_time, trans_time; |
| 1595 | 1598 | ||
| 1596 | journal->j_last_sync_writer = pid; | 1599 | journal->j_last_sync_writer = pid; |
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c index d171b98a6cdd..f973ae9b05f1 100644 --- a/fs/kernfs/mount.c +++ b/fs/kernfs/mount.c | |||
| @@ -211,6 +211,36 @@ void kernfs_kill_sb(struct super_block *sb) | |||
| 211 | kernfs_put(root_kn); | 211 | kernfs_put(root_kn); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | /** | ||
| 215 | * kernfs_pin_sb: try to pin the superblock associated with a kernfs_root | ||
| 216 | * @kernfs_root: the kernfs_root in question | ||
| 217 | * @ns: the namespace tag | ||
| 218 | * | ||
| 219 | * Pin the superblock so the superblock won't be destroyed in subsequent | ||
| 220 | * operations. This can be used to block ->kill_sb() which may be useful | ||
| 221 | * for kernfs users which dynamically manage superblocks. | ||
| 222 | * | ||
| 223 | * Returns NULL if there's no superblock associated to this kernfs_root, or | ||
| 224 | * -EINVAL if the superblock is being freed. | ||
| 225 | */ | ||
| 226 | struct super_block *kernfs_pin_sb(struct kernfs_root *root, const void *ns) | ||
| 227 | { | ||
| 228 | struct kernfs_super_info *info; | ||
| 229 | struct super_block *sb = NULL; | ||
| 230 | |||
| 231 | mutex_lock(&kernfs_mutex); | ||
| 232 | list_for_each_entry(info, &root->supers, node) { | ||
| 233 | if (info->ns == ns) { | ||
| 234 | sb = info->sb; | ||
| 235 | if (!atomic_inc_not_zero(&info->sb->s_active)) | ||
| 236 | sb = ERR_PTR(-EINVAL); | ||
| 237 | break; | ||
| 238 | } | ||
| 239 | } | ||
| 240 | mutex_unlock(&kernfs_mutex); | ||
| 241 | return sb; | ||
| 242 | } | ||
| 243 | |||
| 214 | void __init kernfs_init(void) | 244 | void __init kernfs_init(void) |
| 215 | { | 245 | { |
| 216 | kernfs_node_cache = kmem_cache_create("kernfs_node_cache", | 246 | kernfs_node_cache = kmem_cache_create("kernfs_node_cache", |
diff --git a/fs/namei.c b/fs/namei.c index 985c6f368485..9eb787e5c167 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
| @@ -2256,9 +2256,10 @@ done: | |||
| 2256 | goto out; | 2256 | goto out; |
| 2257 | } | 2257 | } |
| 2258 | path->dentry = dentry; | 2258 | path->dentry = dentry; |
| 2259 | path->mnt = mntget(nd->path.mnt); | 2259 | path->mnt = nd->path.mnt; |
| 2260 | if (should_follow_link(dentry, nd->flags & LOOKUP_FOLLOW)) | 2260 | if (should_follow_link(dentry, nd->flags & LOOKUP_FOLLOW)) |
| 2261 | return 1; | 2261 | return 1; |
| 2262 | mntget(path->mnt); | ||
| 2262 | follow_mount(path); | 2263 | follow_mount(path); |
| 2263 | error = 0; | 2264 | error = 0; |
| 2264 | out: | 2265 | out: |
diff --git a/fs/nfs/direct.c b/fs/nfs/direct.c index 8f98138cbc43..f11b9eed0de1 100644 --- a/fs/nfs/direct.c +++ b/fs/nfs/direct.c | |||
| @@ -756,7 +756,6 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) | |||
| 756 | spin_unlock(&dreq->lock); | 756 | spin_unlock(&dreq->lock); |
| 757 | 757 | ||
| 758 | while (!list_empty(&hdr->pages)) { | 758 | while (!list_empty(&hdr->pages)) { |
| 759 | bool do_destroy = true; | ||
| 760 | 759 | ||
| 761 | req = nfs_list_entry(hdr->pages.next); | 760 | req = nfs_list_entry(hdr->pages.next); |
| 762 | nfs_list_remove_request(req); | 761 | nfs_list_remove_request(req); |
| @@ -765,7 +764,6 @@ static void nfs_direct_write_completion(struct nfs_pgio_header *hdr) | |||
| 765 | case NFS_IOHDR_NEED_COMMIT: | 764 | case NFS_IOHDR_NEED_COMMIT: |
| 766 | kref_get(&req->wb_kref); | 765 | kref_get(&req->wb_kref); |
| 767 | nfs_mark_request_commit(req, hdr->lseg, &cinfo); | 766 | nfs_mark_request_commit(req, hdr->lseg, &cinfo); |
| 768 | do_destroy = false; | ||
| 769 | } | 767 | } |
| 770 | nfs_unlock_and_release_request(req); | 768 | nfs_unlock_and_release_request(req); |
| 771 | } | 769 | } |
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index 82ddbf46660e..f415cbf9f6c3 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h | |||
| @@ -244,6 +244,7 @@ void nfs_pgio_data_release(struct nfs_pgio_data *); | |||
| 244 | int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *); | 244 | int nfs_generic_pgio(struct nfs_pageio_descriptor *, struct nfs_pgio_header *); |
| 245 | int nfs_initiate_pgio(struct rpc_clnt *, struct nfs_pgio_data *, | 245 | int nfs_initiate_pgio(struct rpc_clnt *, struct nfs_pgio_data *, |
| 246 | const struct rpc_call_ops *, int, int); | 246 | const struct rpc_call_ops *, int, int); |
| 247 | void nfs_free_request(struct nfs_page *req); | ||
| 247 | 248 | ||
| 248 | static inline void nfs_iocounter_init(struct nfs_io_counter *c) | 249 | static inline void nfs_iocounter_init(struct nfs_io_counter *c) |
| 249 | { | 250 | { |
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c index 871d6eda8dba..8f854dde4150 100644 --- a/fs/nfs/nfs3acl.c +++ b/fs/nfs/nfs3acl.c | |||
| @@ -247,3 +247,46 @@ const struct xattr_handler *nfs3_xattr_handlers[] = { | |||
| 247 | &posix_acl_default_xattr_handler, | 247 | &posix_acl_default_xattr_handler, |
| 248 | NULL, | 248 | NULL, |
| 249 | }; | 249 | }; |
| 250 | |||
| 251 | static int | ||
| 252 | nfs3_list_one_acl(struct inode *inode, int type, const char *name, void *data, | ||
| 253 | size_t size, ssize_t *result) | ||
| 254 | { | ||
| 255 | struct posix_acl *acl; | ||
| 256 | char *p = data + *result; | ||
| 257 | |||
| 258 | acl = get_acl(inode, type); | ||
| 259 | if (!acl) | ||
| 260 | return 0; | ||
| 261 | |||
| 262 | posix_acl_release(acl); | ||
| 263 | |||
| 264 | *result += strlen(name); | ||
| 265 | *result += 1; | ||
| 266 | if (!size) | ||
| 267 | return 0; | ||
| 268 | if (*result > size) | ||
| 269 | return -ERANGE; | ||
| 270 | |||
| 271 | strcpy(p, name); | ||
| 272 | return 0; | ||
| 273 | } | ||
| 274 | |||
| 275 | ssize_t | ||
| 276 | nfs3_listxattr(struct dentry *dentry, char *data, size_t size) | ||
| 277 | { | ||
| 278 | struct inode *inode = dentry->d_inode; | ||
| 279 | ssize_t result = 0; | ||
| 280 | int error; | ||
| 281 | |||
| 282 | error = nfs3_list_one_acl(inode, ACL_TYPE_ACCESS, | ||
| 283 | POSIX_ACL_XATTR_ACCESS, data, size, &result); | ||
| 284 | if (error) | ||
| 285 | return error; | ||
| 286 | |||
| 287 | error = nfs3_list_one_acl(inode, ACL_TYPE_DEFAULT, | ||
| 288 | POSIX_ACL_XATTR_DEFAULT, data, size, &result); | ||
| 289 | if (error) | ||
| 290 | return error; | ||
| 291 | return result; | ||
| 292 | } | ||
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index e7daa42bbc86..f0afa291fd58 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c | |||
| @@ -885,7 +885,7 @@ static const struct inode_operations nfs3_dir_inode_operations = { | |||
| 885 | .getattr = nfs_getattr, | 885 | .getattr = nfs_getattr, |
| 886 | .setattr = nfs_setattr, | 886 | .setattr = nfs_setattr, |
| 887 | #ifdef CONFIG_NFS_V3_ACL | 887 | #ifdef CONFIG_NFS_V3_ACL |
| 888 | .listxattr = generic_listxattr, | 888 | .listxattr = nfs3_listxattr, |
| 889 | .getxattr = generic_getxattr, | 889 | .getxattr = generic_getxattr, |
| 890 | .setxattr = generic_setxattr, | 890 | .setxattr = generic_setxattr, |
| 891 | .removexattr = generic_removexattr, | 891 | .removexattr = generic_removexattr, |
| @@ -899,7 +899,7 @@ static const struct inode_operations nfs3_file_inode_operations = { | |||
| 899 | .getattr = nfs_getattr, | 899 | .getattr = nfs_getattr, |
| 900 | .setattr = nfs_setattr, | 900 | .setattr = nfs_setattr, |
| 901 | #ifdef CONFIG_NFS_V3_ACL | 901 | #ifdef CONFIG_NFS_V3_ACL |
| 902 | .listxattr = generic_listxattr, | 902 | .listxattr = nfs3_listxattr, |
| 903 | .getxattr = generic_getxattr, | 903 | .getxattr = generic_getxattr, |
| 904 | .setxattr = generic_setxattr, | 904 | .setxattr = generic_setxattr, |
| 905 | .removexattr = generic_removexattr, | 905 | .removexattr = generic_removexattr, |
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index b6ee3a6ee96d..17fab89f6358 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c | |||
| @@ -29,8 +29,6 @@ | |||
| 29 | static struct kmem_cache *nfs_page_cachep; | 29 | static struct kmem_cache *nfs_page_cachep; |
| 30 | static const struct rpc_call_ops nfs_pgio_common_ops; | 30 | static const struct rpc_call_ops nfs_pgio_common_ops; |
| 31 | 31 | ||
| 32 | static void nfs_free_request(struct nfs_page *); | ||
| 33 | |||
| 34 | static bool nfs_pgarray_set(struct nfs_page_array *p, unsigned int pagecount) | 32 | static bool nfs_pgarray_set(struct nfs_page_array *p, unsigned int pagecount) |
| 35 | { | 33 | { |
| 36 | p->npages = pagecount; | 34 | p->npages = pagecount; |
| @@ -239,20 +237,28 @@ nfs_page_group_init(struct nfs_page *req, struct nfs_page *prev) | |||
| 239 | WARN_ON_ONCE(prev == req); | 237 | WARN_ON_ONCE(prev == req); |
| 240 | 238 | ||
| 241 | if (!prev) { | 239 | if (!prev) { |
| 240 | /* a head request */ | ||
| 242 | req->wb_head = req; | 241 | req->wb_head = req; |
| 243 | req->wb_this_page = req; | 242 | req->wb_this_page = req; |
| 244 | } else { | 243 | } else { |
| 244 | /* a subrequest */ | ||
| 245 | WARN_ON_ONCE(prev->wb_this_page != prev->wb_head); | 245 | WARN_ON_ONCE(prev->wb_this_page != prev->wb_head); |
| 246 | WARN_ON_ONCE(!test_bit(PG_HEADLOCK, &prev->wb_head->wb_flags)); | 246 | WARN_ON_ONCE(!test_bit(PG_HEADLOCK, &prev->wb_head->wb_flags)); |
| 247 | req->wb_head = prev->wb_head; | 247 | req->wb_head = prev->wb_head; |
| 248 | req->wb_this_page = prev->wb_this_page; | 248 | req->wb_this_page = prev->wb_this_page; |
| 249 | prev->wb_this_page = req; | 249 | prev->wb_this_page = req; |
| 250 | 250 | ||
| 251 | /* All subrequests take a ref on the head request until | ||
| 252 | * nfs_page_group_destroy is called */ | ||
| 253 | kref_get(&req->wb_head->wb_kref); | ||
| 254 | |||
| 251 | /* grab extra ref if head request has extra ref from | 255 | /* grab extra ref if head request has extra ref from |
| 252 | * the write/commit path to handle handoff between write | 256 | * the write/commit path to handle handoff between write |
| 253 | * and commit lists */ | 257 | * and commit lists */ |
| 254 | if (test_bit(PG_INODE_REF, &prev->wb_head->wb_flags)) | 258 | if (test_bit(PG_INODE_REF, &prev->wb_head->wb_flags)) { |
| 259 | set_bit(PG_INODE_REF, &req->wb_flags); | ||
| 255 | kref_get(&req->wb_kref); | 260 | kref_get(&req->wb_kref); |
| 261 | } | ||
| 256 | } | 262 | } |
| 257 | } | 263 | } |
| 258 | 264 | ||
| @@ -269,6 +275,10 @@ nfs_page_group_destroy(struct kref *kref) | |||
| 269 | struct nfs_page *req = container_of(kref, struct nfs_page, wb_kref); | 275 | struct nfs_page *req = container_of(kref, struct nfs_page, wb_kref); |
| 270 | struct nfs_page *tmp, *next; | 276 | struct nfs_page *tmp, *next; |
| 271 | 277 | ||
| 278 | /* subrequests must release the ref on the head request */ | ||
| 279 | if (req->wb_head != req) | ||
| 280 | nfs_release_request(req->wb_head); | ||
| 281 | |||
| 272 | if (!nfs_page_group_sync_on_bit(req, PG_TEARDOWN)) | 282 | if (!nfs_page_group_sync_on_bit(req, PG_TEARDOWN)) |
| 273 | return; | 283 | return; |
| 274 | 284 | ||
| @@ -394,7 +404,7 @@ static void nfs_clear_request(struct nfs_page *req) | |||
| 394 | * | 404 | * |
| 395 | * Note: Should never be called with the spinlock held! | 405 | * Note: Should never be called with the spinlock held! |
| 396 | */ | 406 | */ |
| 397 | static void nfs_free_request(struct nfs_page *req) | 407 | void nfs_free_request(struct nfs_page *req) |
| 398 | { | 408 | { |
| 399 | WARN_ON_ONCE(req->wb_this_page != req); | 409 | WARN_ON_ONCE(req->wb_this_page != req); |
| 400 | 410 | ||
| @@ -925,7 +935,6 @@ static int __nfs_pageio_add_request(struct nfs_pageio_descriptor *desc, | |||
| 925 | nfs_pageio_doio(desc); | 935 | nfs_pageio_doio(desc); |
| 926 | if (desc->pg_error < 0) | 936 | if (desc->pg_error < 0) |
| 927 | return 0; | 937 | return 0; |
| 928 | desc->pg_moreio = 0; | ||
| 929 | if (desc->pg_recoalesce) | 938 | if (desc->pg_recoalesce) |
| 930 | return 0; | 939 | return 0; |
| 931 | /* retry add_request for this subreq */ | 940 | /* retry add_request for this subreq */ |
| @@ -972,6 +981,7 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc) | |||
| 972 | desc->pg_count = 0; | 981 | desc->pg_count = 0; |
| 973 | desc->pg_base = 0; | 982 | desc->pg_base = 0; |
| 974 | desc->pg_recoalesce = 0; | 983 | desc->pg_recoalesce = 0; |
| 984 | desc->pg_moreio = 0; | ||
| 975 | 985 | ||
| 976 | while (!list_empty(&head)) { | 986 | while (!list_empty(&head)) { |
| 977 | struct nfs_page *req; | 987 | struct nfs_page *req; |
diff --git a/fs/nfs/write.c b/fs/nfs/write.c index 98ff061ccaf3..5e2f10304548 100644 --- a/fs/nfs/write.c +++ b/fs/nfs/write.c | |||
| @@ -46,6 +46,7 @@ static const struct rpc_call_ops nfs_commit_ops; | |||
| 46 | static const struct nfs_pgio_completion_ops nfs_async_write_completion_ops; | 46 | static const struct nfs_pgio_completion_ops nfs_async_write_completion_ops; |
| 47 | static const struct nfs_commit_completion_ops nfs_commit_completion_ops; | 47 | static const struct nfs_commit_completion_ops nfs_commit_completion_ops; |
| 48 | static const struct nfs_rw_ops nfs_rw_write_ops; | 48 | static const struct nfs_rw_ops nfs_rw_write_ops; |
| 49 | static void nfs_clear_request_commit(struct nfs_page *req); | ||
| 49 | 50 | ||
| 50 | static struct kmem_cache *nfs_wdata_cachep; | 51 | static struct kmem_cache *nfs_wdata_cachep; |
| 51 | static mempool_t *nfs_wdata_mempool; | 52 | static mempool_t *nfs_wdata_mempool; |
| @@ -91,8 +92,15 @@ static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error) | |||
| 91 | set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); | 92 | set_bit(NFS_CONTEXT_ERROR_WRITE, &ctx->flags); |
| 92 | } | 93 | } |
| 93 | 94 | ||
| 95 | /* | ||
| 96 | * nfs_page_find_head_request_locked - find head request associated with @page | ||
| 97 | * | ||
| 98 | * must be called while holding the inode lock. | ||
| 99 | * | ||
| 100 | * returns matching head request with reference held, or NULL if not found. | ||
| 101 | */ | ||
| 94 | static struct nfs_page * | 102 | static struct nfs_page * |
| 95 | nfs_page_find_request_locked(struct nfs_inode *nfsi, struct page *page) | 103 | nfs_page_find_head_request_locked(struct nfs_inode *nfsi, struct page *page) |
| 96 | { | 104 | { |
| 97 | struct nfs_page *req = NULL; | 105 | struct nfs_page *req = NULL; |
| 98 | 106 | ||
| @@ -104,25 +112,33 @@ nfs_page_find_request_locked(struct nfs_inode *nfsi, struct page *page) | |||
| 104 | /* Linearly search the commit list for the correct req */ | 112 | /* Linearly search the commit list for the correct req */ |
| 105 | list_for_each_entry_safe(freq, t, &nfsi->commit_info.list, wb_list) { | 113 | list_for_each_entry_safe(freq, t, &nfsi->commit_info.list, wb_list) { |
| 106 | if (freq->wb_page == page) { | 114 | if (freq->wb_page == page) { |
| 107 | req = freq; | 115 | req = freq->wb_head; |
| 108 | break; | 116 | break; |
| 109 | } | 117 | } |
| 110 | } | 118 | } |
| 111 | } | 119 | } |
| 112 | 120 | ||
| 113 | if (req) | 121 | if (req) { |
| 122 | WARN_ON_ONCE(req->wb_head != req); | ||
| 123 | |||
| 114 | kref_get(&req->wb_kref); | 124 | kref_get(&req->wb_kref); |
| 125 | } | ||
| 115 | 126 | ||
| 116 | return req; | 127 | return req; |
| 117 | } | 128 | } |
| 118 | 129 | ||
| 119 | static struct nfs_page *nfs_page_find_request(struct page *page) | 130 | /* |
| 131 | * nfs_page_find_head_request - find head request associated with @page | ||
| 132 | * | ||
| 133 | * returns matching head request with reference held, or NULL if not found. | ||
| 134 | */ | ||
| 135 | static struct nfs_page *nfs_page_find_head_request(struct page *page) | ||
| 120 | { | 136 | { |
| 121 | struct inode *inode = page_file_mapping(page)->host; | 137 | struct inode *inode = page_file_mapping(page)->host; |
| 122 | struct nfs_page *req = NULL; | 138 | struct nfs_page *req = NULL; |
| 123 | 139 | ||
| 124 | spin_lock(&inode->i_lock); | 140 | spin_lock(&inode->i_lock); |
| 125 | req = nfs_page_find_request_locked(NFS_I(inode), page); | 141 | req = nfs_page_find_head_request_locked(NFS_I(inode), page); |
| 126 | spin_unlock(&inode->i_lock); | 142 | spin_unlock(&inode->i_lock); |
| 127 | return req; | 143 | return req; |
| 128 | } | 144 | } |
| @@ -274,36 +290,246 @@ static void nfs_end_page_writeback(struct nfs_page *req) | |||
| 274 | clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC); | 290 | clear_bdi_congested(&nfss->backing_dev_info, BLK_RW_ASYNC); |
| 275 | } | 291 | } |
| 276 | 292 | ||
| 277 | static struct nfs_page *nfs_find_and_lock_request(struct page *page, bool nonblock) | 293 | |
| 294 | /* nfs_page_group_clear_bits | ||
| 295 | * @req - an nfs request | ||
| 296 | * clears all page group related bits from @req | ||
| 297 | */ | ||
| 298 | static void | ||
| 299 | nfs_page_group_clear_bits(struct nfs_page *req) | ||
| 300 | { | ||
| 301 | clear_bit(PG_TEARDOWN, &req->wb_flags); | ||
| 302 | clear_bit(PG_UNLOCKPAGE, &req->wb_flags); | ||
| 303 | clear_bit(PG_UPTODATE, &req->wb_flags); | ||
| 304 | clear_bit(PG_WB_END, &req->wb_flags); | ||
| 305 | clear_bit(PG_REMOVE, &req->wb_flags); | ||
| 306 | } | ||
| 307 | |||
| 308 | |||
| 309 | /* | ||
| 310 | * nfs_unroll_locks_and_wait - unlock all newly locked reqs and wait on @req | ||
| 311 | * | ||
| 312 | * this is a helper function for nfs_lock_and_join_requests | ||
| 313 | * | ||
| 314 | * @inode - inode associated with request page group, must be holding inode lock | ||
| 315 | * @head - head request of page group, must be holding head lock | ||
| 316 | * @req - request that couldn't lock and needs to wait on the req bit lock | ||
| 317 | * @nonblock - if true, don't actually wait | ||
| 318 | * | ||
| 319 | * NOTE: this must be called holding page_group bit lock and inode spin lock | ||
| 320 | * and BOTH will be released before returning. | ||
| 321 | * | ||
| 322 | * returns 0 on success, < 0 on error. | ||
| 323 | */ | ||
| 324 | static int | ||
| 325 | nfs_unroll_locks_and_wait(struct inode *inode, struct nfs_page *head, | ||
| 326 | struct nfs_page *req, bool nonblock) | ||
| 327 | __releases(&inode->i_lock) | ||
| 328 | { | ||
| 329 | struct nfs_page *tmp; | ||
| 330 | int ret; | ||
| 331 | |||
| 332 | /* relinquish all the locks successfully grabbed this run */ | ||
| 333 | for (tmp = head ; tmp != req; tmp = tmp->wb_this_page) | ||
| 334 | nfs_unlock_request(tmp); | ||
| 335 | |||
| 336 | WARN_ON_ONCE(test_bit(PG_TEARDOWN, &req->wb_flags)); | ||
| 337 | |||
| 338 | /* grab a ref on the request that will be waited on */ | ||
| 339 | kref_get(&req->wb_kref); | ||
| 340 | |||
| 341 | nfs_page_group_unlock(head); | ||
| 342 | spin_unlock(&inode->i_lock); | ||
| 343 | |||
| 344 | /* release ref from nfs_page_find_head_request_locked */ | ||
| 345 | nfs_release_request(head); | ||
| 346 | |||
| 347 | if (!nonblock) | ||
| 348 | ret = nfs_wait_on_request(req); | ||
| 349 | else | ||
| 350 | ret = -EAGAIN; | ||
| 351 | nfs_release_request(req); | ||
| 352 | |||
| 353 | return ret; | ||
| 354 | } | ||
| 355 | |||
| 356 | /* | ||
| 357 | * nfs_destroy_unlinked_subrequests - destroy recently unlinked subrequests | ||
| 358 | * | ||
| 359 | * @destroy_list - request list (using wb_this_page) terminated by @old_head | ||
| 360 | * @old_head - the old head of the list | ||
| 361 | * | ||
| 362 | * All subrequests must be locked and removed from all lists, so at this point | ||
| 363 | * they are only "active" in this function, and possibly in nfs_wait_on_request | ||
| 364 | * with a reference held by some other context. | ||
| 365 | */ | ||
| 366 | static void | ||
| 367 | nfs_destroy_unlinked_subrequests(struct nfs_page *destroy_list, | ||
| 368 | struct nfs_page *old_head) | ||
| 369 | { | ||
| 370 | while (destroy_list) { | ||
| 371 | struct nfs_page *subreq = destroy_list; | ||
| 372 | |||
| 373 | destroy_list = (subreq->wb_this_page == old_head) ? | ||
| 374 | NULL : subreq->wb_this_page; | ||
| 375 | |||
| 376 | WARN_ON_ONCE(old_head != subreq->wb_head); | ||
| 377 | |||
| 378 | /* make sure old group is not used */ | ||
| 379 | subreq->wb_head = subreq; | ||
| 380 | subreq->wb_this_page = subreq; | ||
| 381 | |||
| 382 | nfs_clear_request_commit(subreq); | ||
| 383 | |||
| 384 | /* subreq is now totally disconnected from page group or any | ||
| 385 | * write / commit lists. last chance to wake any waiters */ | ||
| 386 | nfs_unlock_request(subreq); | ||
| 387 | |||
| 388 | if (!test_bit(PG_TEARDOWN, &subreq->wb_flags)) { | ||
| 389 | /* release ref on old head request */ | ||
| 390 | nfs_release_request(old_head); | ||
| 391 | |||
| 392 | nfs_page_group_clear_bits(subreq); | ||
| 393 | |||
| 394 | /* release the PG_INODE_REF reference */ | ||
| 395 | if (test_and_clear_bit(PG_INODE_REF, &subreq->wb_flags)) | ||
| 396 | nfs_release_request(subreq); | ||
| 397 | else | ||
| 398 | WARN_ON_ONCE(1); | ||
| 399 | } else { | ||
| 400 | WARN_ON_ONCE(test_bit(PG_CLEAN, &subreq->wb_flags)); | ||
| 401 | /* zombie requests have already released the last | ||
| 402 | * reference and were waiting on the rest of the | ||
| 403 | * group to complete. Since it's no longer part of a | ||
| 404 | * group, simply free the request */ | ||
| 405 | nfs_page_group_clear_bits(subreq); | ||
| 406 | nfs_free_request(subreq); | ||
| 407 | } | ||
| 408 | } | ||
| 409 | } | ||
| 410 | |||
| 411 | /* | ||
| 412 | * nfs_lock_and_join_requests - join all subreqs to the head req and return | ||
| 413 | * a locked reference, cancelling any pending | ||
| 414 | * operations for this page. | ||
| 415 | * | ||
| 416 | * @page - the page used to lookup the "page group" of nfs_page structures | ||
| 417 | * @nonblock - if true, don't block waiting for request locks | ||
| 418 | * | ||
| 419 | * This function joins all sub requests to the head request by first | ||
| 420 | * locking all requests in the group, cancelling any pending operations | ||
| 421 | * and finally updating the head request to cover the whole range covered by | ||
| 422 | * the (former) group. All subrequests are removed from any write or commit | ||
| 423 | * lists, unlinked from the group and destroyed. | ||
| 424 | * | ||
| 425 | * Returns a locked, referenced pointer to the head request - which after | ||
| 426 | * this call is guaranteed to be the only request associated with the page. | ||
| 427 | * Returns NULL if no requests are found for @page, or a ERR_PTR if an | ||
| 428 | * error was encountered. | ||
| 429 | */ | ||
| 430 | static struct nfs_page * | ||
| 431 | nfs_lock_and_join_requests(struct page *page, bool nonblock) | ||
| 278 | { | 432 | { |
| 279 | struct inode *inode = page_file_mapping(page)->host; | 433 | struct inode *inode = page_file_mapping(page)->host; |
| 280 | struct nfs_page *req; | 434 | struct nfs_page *head, *subreq; |
| 435 | struct nfs_page *destroy_list = NULL; | ||
| 436 | unsigned int total_bytes; | ||
| 281 | int ret; | 437 | int ret; |
| 282 | 438 | ||
| 439 | try_again: | ||
| 440 | total_bytes = 0; | ||
| 441 | |||
| 442 | WARN_ON_ONCE(destroy_list); | ||
| 443 | |||
| 283 | spin_lock(&inode->i_lock); | 444 | spin_lock(&inode->i_lock); |
| 284 | for (;;) { | 445 | |
| 285 | req = nfs_page_find_request_locked(NFS_I(inode), page); | 446 | /* |
| 286 | if (req == NULL) | 447 | * A reference is taken only on the head request which acts as a |
| 287 | break; | 448 | * reference to the whole page group - the group will not be destroyed |
| 288 | if (nfs_lock_request(req)) | 449 | * until the head reference is released. |
| 289 | break; | 450 | */ |
| 290 | /* Note: If we hold the page lock, as is the case in nfs_writepage, | 451 | head = nfs_page_find_head_request_locked(NFS_I(inode), page); |
| 291 | * then the call to nfs_lock_request() will always | 452 | |
| 292 | * succeed provided that someone hasn't already marked the | 453 | if (!head) { |
| 293 | * request as dirty (in which case we don't care). | ||
| 294 | */ | ||
| 295 | spin_unlock(&inode->i_lock); | 454 | spin_unlock(&inode->i_lock); |
| 296 | if (!nonblock) | 455 | return NULL; |
| 297 | ret = nfs_wait_on_request(req); | 456 | } |
| 298 | else | 457 | |
| 299 | ret = -EAGAIN; | 458 | /* lock each request in the page group */ |
| 300 | nfs_release_request(req); | 459 | nfs_page_group_lock(head); |
| 301 | if (ret != 0) | 460 | subreq = head; |
| 461 | do { | ||
| 462 | /* | ||
| 463 | * Subrequests are always contiguous, non overlapping | ||
| 464 | * and in order. If not, it's a programming error. | ||
| 465 | */ | ||
| 466 | WARN_ON_ONCE(subreq->wb_offset != | ||
| 467 | (head->wb_offset + total_bytes)); | ||
| 468 | |||
| 469 | /* keep track of how many bytes this group covers */ | ||
| 470 | total_bytes += subreq->wb_bytes; | ||
| 471 | |||
| 472 | if (!nfs_lock_request(subreq)) { | ||
| 473 | /* releases page group bit lock and | ||
| 474 | * inode spin lock and all references */ | ||
| 475 | ret = nfs_unroll_locks_and_wait(inode, head, | ||
| 476 | subreq, nonblock); | ||
| 477 | |||
| 478 | if (ret == 0) | ||
| 479 | goto try_again; | ||
| 480 | |||
| 302 | return ERR_PTR(ret); | 481 | return ERR_PTR(ret); |
| 303 | spin_lock(&inode->i_lock); | 482 | } |
| 483 | |||
| 484 | subreq = subreq->wb_this_page; | ||
| 485 | } while (subreq != head); | ||
| 486 | |||
| 487 | /* Now that all requests are locked, make sure they aren't on any list. | ||
| 488 | * Commit list removal accounting is done after locks are dropped */ | ||
| 489 | subreq = head; | ||
| 490 | do { | ||
| 491 | nfs_list_remove_request(subreq); | ||
| 492 | subreq = subreq->wb_this_page; | ||
| 493 | } while (subreq != head); | ||
| 494 | |||
| 495 | /* unlink subrequests from head, destroy them later */ | ||
| 496 | if (head->wb_this_page != head) { | ||
| 497 | /* destroy list will be terminated by head */ | ||
| 498 | destroy_list = head->wb_this_page; | ||
| 499 | head->wb_this_page = head; | ||
| 500 | |||
| 501 | /* change head request to cover whole range that | ||
| 502 | * the former page group covered */ | ||
| 503 | head->wb_bytes = total_bytes; | ||
| 304 | } | 504 | } |
| 505 | |||
| 506 | /* | ||
| 507 | * prepare head request to be added to new pgio descriptor | ||
| 508 | */ | ||
| 509 | nfs_page_group_clear_bits(head); | ||
| 510 | |||
| 511 | /* | ||
| 512 | * some part of the group was still on the inode list - otherwise | ||
| 513 | * the group wouldn't be involved in async write. | ||
| 514 | * grab a reference for the head request, iff it needs one. | ||
| 515 | */ | ||
| 516 | if (!test_and_set_bit(PG_INODE_REF, &head->wb_flags)) | ||
| 517 | kref_get(&head->wb_kref); | ||
| 518 | |||
| 519 | nfs_page_group_unlock(head); | ||
| 520 | |||
| 521 | /* drop lock to clear_request_commit the head req and clean up | ||
| 522 | * requests on destroy list */ | ||
| 305 | spin_unlock(&inode->i_lock); | 523 | spin_unlock(&inode->i_lock); |
| 306 | return req; | 524 | |
| 525 | nfs_destroy_unlinked_subrequests(destroy_list, head); | ||
| 526 | |||
| 527 | /* clean up commit list state */ | ||
| 528 | nfs_clear_request_commit(head); | ||
| 529 | |||
| 530 | /* still holds ref on head from nfs_page_find_head_request_locked | ||
| 531 | * and still has lock on head from lock loop */ | ||
| 532 | return head; | ||
| 307 | } | 533 | } |
| 308 | 534 | ||
| 309 | /* | 535 | /* |
| @@ -316,7 +542,7 @@ static int nfs_page_async_flush(struct nfs_pageio_descriptor *pgio, | |||
| 316 | struct nfs_page *req; | 542 | struct nfs_page *req; |
| 317 | int ret = 0; | 543 | int ret = 0; |
| 318 | 544 | ||
| 319 | req = nfs_find_and_lock_request(page, nonblock); | 545 | req = nfs_lock_and_join_requests(page, nonblock); |
| 320 | if (!req) | 546 | if (!req) |
| 321 | goto out; | 547 | goto out; |
| 322 | ret = PTR_ERR(req); | 548 | ret = PTR_ERR(req); |
| @@ -448,7 +674,9 @@ static void nfs_inode_add_request(struct inode *inode, struct nfs_page *req) | |||
| 448 | set_page_private(req->wb_page, (unsigned long)req); | 674 | set_page_private(req->wb_page, (unsigned long)req); |
| 449 | } | 675 | } |
| 450 | nfsi->npages++; | 676 | nfsi->npages++; |
| 451 | set_bit(PG_INODE_REF, &req->wb_flags); | 677 | /* this a head request for a page group - mark it as having an |
| 678 | * extra reference so sub groups can follow suit */ | ||
| 679 | WARN_ON(test_and_set_bit(PG_INODE_REF, &req->wb_flags)); | ||
| 452 | kref_get(&req->wb_kref); | 680 | kref_get(&req->wb_kref); |
| 453 | spin_unlock(&inode->i_lock); | 681 | spin_unlock(&inode->i_lock); |
| 454 | } | 682 | } |
| @@ -474,7 +702,9 @@ static void nfs_inode_remove_request(struct nfs_page *req) | |||
| 474 | nfsi->npages--; | 702 | nfsi->npages--; |
| 475 | spin_unlock(&inode->i_lock); | 703 | spin_unlock(&inode->i_lock); |
| 476 | } | 704 | } |
| 477 | nfs_release_request(req); | 705 | |
| 706 | if (test_and_clear_bit(PG_INODE_REF, &req->wb_flags)) | ||
| 707 | nfs_release_request(req); | ||
| 478 | } | 708 | } |
| 479 | 709 | ||
| 480 | static void | 710 | static void |
| @@ -638,7 +868,6 @@ static void nfs_write_completion(struct nfs_pgio_header *hdr) | |||
| 638 | { | 868 | { |
| 639 | struct nfs_commit_info cinfo; | 869 | struct nfs_commit_info cinfo; |
| 640 | unsigned long bytes = 0; | 870 | unsigned long bytes = 0; |
| 641 | bool do_destroy; | ||
| 642 | 871 | ||
| 643 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) | 872 | if (test_bit(NFS_IOHDR_REDO, &hdr->flags)) |
| 644 | goto out; | 873 | goto out; |
| @@ -668,7 +897,6 @@ remove_req: | |||
| 668 | next: | 897 | next: |
| 669 | nfs_unlock_request(req); | 898 | nfs_unlock_request(req); |
| 670 | nfs_end_page_writeback(req); | 899 | nfs_end_page_writeback(req); |
| 671 | do_destroy = !test_bit(NFS_IOHDR_NEED_COMMIT, &hdr->flags); | ||
| 672 | nfs_release_request(req); | 900 | nfs_release_request(req); |
| 673 | } | 901 | } |
| 674 | out: | 902 | out: |
| @@ -769,7 +997,7 @@ static struct nfs_page *nfs_try_to_update_request(struct inode *inode, | |||
| 769 | spin_lock(&inode->i_lock); | 997 | spin_lock(&inode->i_lock); |
| 770 | 998 | ||
| 771 | for (;;) { | 999 | for (;;) { |
| 772 | req = nfs_page_find_request_locked(NFS_I(inode), page); | 1000 | req = nfs_page_find_head_request_locked(NFS_I(inode), page); |
| 773 | if (req == NULL) | 1001 | if (req == NULL) |
| 774 | goto out_unlock; | 1002 | goto out_unlock; |
| 775 | 1003 | ||
| @@ -877,7 +1105,7 @@ int nfs_flush_incompatible(struct file *file, struct page *page) | |||
| 877 | * dropped page. | 1105 | * dropped page. |
| 878 | */ | 1106 | */ |
| 879 | do { | 1107 | do { |
| 880 | req = nfs_page_find_request(page); | 1108 | req = nfs_page_find_head_request(page); |
| 881 | if (req == NULL) | 1109 | if (req == NULL) |
| 882 | return 0; | 1110 | return 0; |
| 883 | l_ctx = req->wb_lock_context; | 1111 | l_ctx = req->wb_lock_context; |
| @@ -1569,27 +1797,28 @@ int nfs_wb_page_cancel(struct inode *inode, struct page *page) | |||
| 1569 | struct nfs_page *req; | 1797 | struct nfs_page *req; |
| 1570 | int ret = 0; | 1798 | int ret = 0; |
| 1571 | 1799 | ||
| 1572 | for (;;) { | 1800 | wait_on_page_writeback(page); |
| 1573 | wait_on_page_writeback(page); | 1801 | |
| 1574 | req = nfs_page_find_request(page); | 1802 | /* blocking call to cancel all requests and join to a single (head) |
| 1575 | if (req == NULL) | 1803 | * request */ |
| 1576 | break; | 1804 | req = nfs_lock_and_join_requests(page, false); |
| 1577 | if (nfs_lock_request(req)) { | 1805 | |
| 1578 | nfs_clear_request_commit(req); | 1806 | if (IS_ERR(req)) { |
| 1579 | nfs_inode_remove_request(req); | 1807 | ret = PTR_ERR(req); |
| 1580 | /* | 1808 | } else if (req) { |
| 1581 | * In case nfs_inode_remove_request has marked the | 1809 | /* all requests from this page have been cancelled by |
| 1582 | * page as being dirty | 1810 | * nfs_lock_and_join_requests, so just remove the head |
| 1583 | */ | 1811 | * request from the inode / page_private pointer and |
| 1584 | cancel_dirty_page(page, PAGE_CACHE_SIZE); | 1812 | * release it */ |
| 1585 | nfs_unlock_and_release_request(req); | 1813 | nfs_inode_remove_request(req); |
| 1586 | break; | 1814 | /* |
| 1587 | } | 1815 | * In case nfs_inode_remove_request has marked the |
| 1588 | ret = nfs_wait_on_request(req); | 1816 | * page as being dirty |
| 1589 | nfs_release_request(req); | 1817 | */ |
| 1590 | if (ret < 0) | 1818 | cancel_dirty_page(page, PAGE_CACHE_SIZE); |
| 1591 | break; | 1819 | nfs_unlock_and_release_request(req); |
| 1592 | } | 1820 | } |
| 1821 | |||
| 1593 | return ret; | 1822 | return ret; |
| 1594 | } | 1823 | } |
| 1595 | 1824 | ||
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 2fc7abebeb9b..944275c8f56d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
| @@ -2641,7 +2641,7 @@ nfsd4_encode_rdattr_error(struct xdr_stream *xdr, __be32 nfserr) | |||
| 2641 | { | 2641 | { |
| 2642 | __be32 *p; | 2642 | __be32 *p; |
| 2643 | 2643 | ||
| 2644 | p = xdr_reserve_space(xdr, 6); | 2644 | p = xdr_reserve_space(xdr, 20); |
| 2645 | if (!p) | 2645 | if (!p) |
| 2646 | return NULL; | 2646 | return NULL; |
| 2647 | *p++ = htonl(2); | 2647 | *p++ = htonl(2); |
| @@ -2879,6 +2879,7 @@ again: | |||
| 2879 | * return the conflicting open: | 2879 | * return the conflicting open: |
| 2880 | */ | 2880 | */ |
| 2881 | if (conf->len) { | 2881 | if (conf->len) { |
| 2882 | kfree(conf->data); | ||
| 2882 | conf->len = 0; | 2883 | conf->len = 0; |
| 2883 | conf->data = NULL; | 2884 | conf->data = NULL; |
| 2884 | goto again; | 2885 | goto again; |
| @@ -2891,6 +2892,7 @@ again: | |||
| 2891 | if (conf->len) { | 2892 | if (conf->len) { |
| 2892 | p = xdr_encode_opaque_fixed(p, &ld->ld_clientid, 8); | 2893 | p = xdr_encode_opaque_fixed(p, &ld->ld_clientid, 8); |
| 2893 | p = xdr_encode_opaque(p, conf->data, conf->len); | 2894 | p = xdr_encode_opaque(p, conf->data, conf->len); |
| 2895 | kfree(conf->data); | ||
| 2894 | } else { /* non - nfsv4 lock in conflict, no clientid nor owner */ | 2896 | } else { /* non - nfsv4 lock in conflict, no clientid nor owner */ |
| 2895 | p = xdr_encode_hyper(p, (u64)0); /* clientid */ | 2897 | p = xdr_encode_hyper(p, (u64)0); /* clientid */ |
| 2896 | *p++ = cpu_to_be32(0); /* length of owner name */ | 2898 | *p++ = cpu_to_be32(0); /* length of owner name */ |
| @@ -2907,7 +2909,7 @@ nfsd4_encode_lock(struct nfsd4_compoundres *resp, __be32 nfserr, struct nfsd4_lo | |||
| 2907 | nfserr = nfsd4_encode_stateid(xdr, &lock->lk_resp_stateid); | 2909 | nfserr = nfsd4_encode_stateid(xdr, &lock->lk_resp_stateid); |
| 2908 | else if (nfserr == nfserr_denied) | 2910 | else if (nfserr == nfserr_denied) |
| 2909 | nfserr = nfsd4_encode_lock_denied(xdr, &lock->lk_denied); | 2911 | nfserr = nfsd4_encode_lock_denied(xdr, &lock->lk_denied); |
| 2910 | kfree(lock->lk_denied.ld_owner.data); | 2912 | |
| 2911 | return nfserr; | 2913 | return nfserr; |
| 2912 | } | 2914 | } |
| 2913 | 2915 | ||
| @@ -263,11 +263,10 @@ int do_fallocate(struct file *file, int mode, loff_t offset, loff_t len) | |||
| 263 | return -EPERM; | 263 | return -EPERM; |
| 264 | 264 | ||
| 265 | /* | 265 | /* |
| 266 | * We can not allow to do any fallocate operation on an active | 266 | * We cannot allow any fallocate operation on an active swapfile |
| 267 | * swapfile | ||
| 268 | */ | 267 | */ |
| 269 | if (IS_SWAPFILE(inode)) | 268 | if (IS_SWAPFILE(inode)) |
| 270 | ret = -ETXTBSY; | 269 | return -ETXTBSY; |
| 271 | 270 | ||
| 272 | /* | 271 | /* |
| 273 | * Revalidate the write permissions, in case security policy has | 272 | * Revalidate the write permissions, in case security policy has |
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c index 9cd5f63715c0..7f30bdc57d13 100644 --- a/fs/quota/dquot.c +++ b/fs/quota/dquot.c | |||
| @@ -702,6 +702,7 @@ dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) | |||
| 702 | struct dquot *dquot; | 702 | struct dquot *dquot; |
| 703 | unsigned long freed = 0; | 703 | unsigned long freed = 0; |
| 704 | 704 | ||
| 705 | spin_lock(&dq_list_lock); | ||
| 705 | head = free_dquots.prev; | 706 | head = free_dquots.prev; |
| 706 | while (head != &free_dquots && sc->nr_to_scan) { | 707 | while (head != &free_dquots && sc->nr_to_scan) { |
| 707 | dquot = list_entry(head, struct dquot, dq_free); | 708 | dquot = list_entry(head, struct dquot, dq_free); |
| @@ -713,6 +714,7 @@ dqcache_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) | |||
| 713 | freed++; | 714 | freed++; |
| 714 | head = free_dquots.prev; | 715 | head = free_dquots.prev; |
| 715 | } | 716 | } |
| 717 | spin_unlock(&dq_list_lock); | ||
| 716 | return freed; | 718 | return freed; |
| 717 | } | 719 | } |
| 718 | 720 | ||
diff --git a/fs/xattr.c b/fs/xattr.c index 3377dff18404..c69e6d43a0d2 100644 --- a/fs/xattr.c +++ b/fs/xattr.c | |||
| @@ -843,7 +843,7 @@ struct simple_xattr *simple_xattr_alloc(const void *value, size_t size) | |||
| 843 | 843 | ||
| 844 | /* wrap around? */ | 844 | /* wrap around? */ |
| 845 | len = sizeof(*new_xattr) + size; | 845 | len = sizeof(*new_xattr) + size; |
| 846 | if (len <= sizeof(*new_xattr)) | 846 | if (len < sizeof(*new_xattr)) |
| 847 | return NULL; | 847 | return NULL; |
| 848 | 848 | ||
| 849 | new_xattr = kmalloc(len, GFP_KERNEL); | 849 | new_xattr = kmalloc(len, GFP_KERNEL); |
diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c index 96175df211b1..75c3fe5f3d9d 100644 --- a/fs/xfs/xfs_bmap.c +++ b/fs/xfs/xfs_bmap.c | |||
| @@ -4298,8 +4298,8 @@ xfs_bmapi_delay( | |||
| 4298 | } | 4298 | } |
| 4299 | 4299 | ||
| 4300 | 4300 | ||
| 4301 | int | 4301 | static int |
| 4302 | __xfs_bmapi_allocate( | 4302 | xfs_bmapi_allocate( |
| 4303 | struct xfs_bmalloca *bma) | 4303 | struct xfs_bmalloca *bma) |
| 4304 | { | 4304 | { |
| 4305 | struct xfs_mount *mp = bma->ip->i_mount; | 4305 | struct xfs_mount *mp = bma->ip->i_mount; |
| @@ -4578,9 +4578,6 @@ xfs_bmapi_write( | |||
| 4578 | bma.flist = flist; | 4578 | bma.flist = flist; |
| 4579 | bma.firstblock = firstblock; | 4579 | bma.firstblock = firstblock; |
| 4580 | 4580 | ||
| 4581 | if (flags & XFS_BMAPI_STACK_SWITCH) | ||
| 4582 | bma.stack_switch = 1; | ||
| 4583 | |||
| 4584 | while (bno < end && n < *nmap) { | 4581 | while (bno < end && n < *nmap) { |
| 4585 | inhole = eof || bma.got.br_startoff > bno; | 4582 | inhole = eof || bma.got.br_startoff > bno; |
| 4586 | wasdelay = !inhole && isnullstartblock(bma.got.br_startblock); | 4583 | wasdelay = !inhole && isnullstartblock(bma.got.br_startblock); |
diff --git a/fs/xfs/xfs_bmap.h b/fs/xfs/xfs_bmap.h index 38ba36e9b2f0..b879ca56a64c 100644 --- a/fs/xfs/xfs_bmap.h +++ b/fs/xfs/xfs_bmap.h | |||
| @@ -77,7 +77,6 @@ typedef struct xfs_bmap_free | |||
| 77 | * from written to unwritten, otherwise convert from unwritten to written. | 77 | * from written to unwritten, otherwise convert from unwritten to written. |
| 78 | */ | 78 | */ |
| 79 | #define XFS_BMAPI_CONVERT 0x040 | 79 | #define XFS_BMAPI_CONVERT 0x040 |
| 80 | #define XFS_BMAPI_STACK_SWITCH 0x080 | ||
| 81 | 80 | ||
| 82 | #define XFS_BMAPI_FLAGS \ | 81 | #define XFS_BMAPI_FLAGS \ |
| 83 | { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ | 82 | { XFS_BMAPI_ENTIRE, "ENTIRE" }, \ |
| @@ -86,8 +85,7 @@ typedef struct xfs_bmap_free | |||
| 86 | { XFS_BMAPI_PREALLOC, "PREALLOC" }, \ | 85 | { XFS_BMAPI_PREALLOC, "PREALLOC" }, \ |
| 87 | { XFS_BMAPI_IGSTATE, "IGSTATE" }, \ | 86 | { XFS_BMAPI_IGSTATE, "IGSTATE" }, \ |
| 88 | { XFS_BMAPI_CONTIG, "CONTIG" }, \ | 87 | { XFS_BMAPI_CONTIG, "CONTIG" }, \ |
| 89 | { XFS_BMAPI_CONVERT, "CONVERT" }, \ | 88 | { XFS_BMAPI_CONVERT, "CONVERT" } |
| 90 | { XFS_BMAPI_STACK_SWITCH, "STACK_SWITCH" } | ||
| 91 | 89 | ||
| 92 | 90 | ||
| 93 | static inline int xfs_bmapi_aflag(int w) | 91 | static inline int xfs_bmapi_aflag(int w) |
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index 703b3ec1796c..64731ef3324d 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c | |||
| @@ -249,59 +249,6 @@ xfs_bmap_rtalloc( | |||
| 249 | } | 249 | } |
| 250 | 250 | ||
| 251 | /* | 251 | /* |
| 252 | * Stack switching interfaces for allocation | ||
| 253 | */ | ||
| 254 | static void | ||
| 255 | xfs_bmapi_allocate_worker( | ||
| 256 | struct work_struct *work) | ||
| 257 | { | ||
| 258 | struct xfs_bmalloca *args = container_of(work, | ||
| 259 | struct xfs_bmalloca, work); | ||
| 260 | unsigned long pflags; | ||
| 261 | unsigned long new_pflags = PF_FSTRANS; | ||
| 262 | |||
| 263 | /* | ||
| 264 | * we are in a transaction context here, but may also be doing work | ||
| 265 | * in kswapd context, and hence we may need to inherit that state | ||
| 266 | * temporarily to ensure that we don't block waiting for memory reclaim | ||
| 267 | * in any way. | ||
| 268 | */ | ||
| 269 | if (args->kswapd) | ||
| 270 | new_pflags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD; | ||
| 271 | |||
| 272 | current_set_flags_nested(&pflags, new_pflags); | ||
| 273 | |||
| 274 | args->result = __xfs_bmapi_allocate(args); | ||
| 275 | complete(args->done); | ||
| 276 | |||
| 277 | current_restore_flags_nested(&pflags, new_pflags); | ||
| 278 | } | ||
| 279 | |||
| 280 | /* | ||
| 281 | * Some allocation requests often come in with little stack to work on. Push | ||
| 282 | * them off to a worker thread so there is lots of stack to use. Otherwise just | ||
| 283 | * call directly to avoid the context switch overhead here. | ||
| 284 | */ | ||
| 285 | int | ||
| 286 | xfs_bmapi_allocate( | ||
| 287 | struct xfs_bmalloca *args) | ||
| 288 | { | ||
| 289 | DECLARE_COMPLETION_ONSTACK(done); | ||
| 290 | |||
| 291 | if (!args->stack_switch) | ||
| 292 | return __xfs_bmapi_allocate(args); | ||
| 293 | |||
| 294 | |||
| 295 | args->done = &done; | ||
| 296 | args->kswapd = current_is_kswapd(); | ||
| 297 | INIT_WORK_ONSTACK(&args->work, xfs_bmapi_allocate_worker); | ||
| 298 | queue_work(xfs_alloc_wq, &args->work); | ||
| 299 | wait_for_completion(&done); | ||
| 300 | destroy_work_on_stack(&args->work); | ||
| 301 | return args->result; | ||
| 302 | } | ||
| 303 | |||
| 304 | /* | ||
| 305 | * Check if the endoff is outside the last extent. If so the caller will grow | 252 | * Check if the endoff is outside the last extent. If so the caller will grow |
| 306 | * the allocation to a stripe unit boundary. All offsets are considered outside | 253 | * the allocation to a stripe unit boundary. All offsets are considered outside |
| 307 | * the end of file for an empty fork, so 1 is returned in *eof in that case. | 254 | * the end of file for an empty fork, so 1 is returned in *eof in that case. |
diff --git a/fs/xfs/xfs_bmap_util.h b/fs/xfs/xfs_bmap_util.h index 075f72232a64..2fdb72d2c908 100644 --- a/fs/xfs/xfs_bmap_util.h +++ b/fs/xfs/xfs_bmap_util.h | |||
| @@ -55,8 +55,6 @@ struct xfs_bmalloca { | |||
| 55 | bool userdata;/* set if is user data */ | 55 | bool userdata;/* set if is user data */ |
| 56 | bool aeof; /* allocated space at eof */ | 56 | bool aeof; /* allocated space at eof */ |
| 57 | bool conv; /* overwriting unwritten extents */ | 57 | bool conv; /* overwriting unwritten extents */ |
| 58 | bool stack_switch; | ||
| 59 | bool kswapd; /* allocation in kswapd context */ | ||
| 60 | int flags; | 58 | int flags; |
| 61 | struct completion *done; | 59 | struct completion *done; |
| 62 | struct work_struct work; | 60 | struct work_struct work; |
| @@ -66,8 +64,6 @@ struct xfs_bmalloca { | |||
| 66 | int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, | 64 | int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, |
| 67 | int *committed); | 65 | int *committed); |
| 68 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); | 66 | int xfs_bmap_rtalloc(struct xfs_bmalloca *ap); |
| 69 | int xfs_bmapi_allocate(struct xfs_bmalloca *args); | ||
| 70 | int __xfs_bmapi_allocate(struct xfs_bmalloca *args); | ||
| 71 | int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, | 67 | int xfs_bmap_eof(struct xfs_inode *ip, xfs_fileoff_t endoff, |
| 72 | int whichfork, int *eof); | 68 | int whichfork, int *eof); |
| 73 | int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, | 69 | int xfs_bmap_count_blocks(struct xfs_trans *tp, struct xfs_inode *ip, |
diff --git a/fs/xfs/xfs_btree.c b/fs/xfs/xfs_btree.c index bf810c6baf2b..cf893bc1e373 100644 --- a/fs/xfs/xfs_btree.c +++ b/fs/xfs/xfs_btree.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #include "xfs_error.h" | 33 | #include "xfs_error.h" |
| 34 | #include "xfs_trace.h" | 34 | #include "xfs_trace.h" |
| 35 | #include "xfs_cksum.h" | 35 | #include "xfs_cksum.h" |
| 36 | #include "xfs_alloc.h" | ||
| 36 | 37 | ||
| 37 | /* | 38 | /* |
| 38 | * Cursor allocation zone. | 39 | * Cursor allocation zone. |
| @@ -2323,7 +2324,7 @@ error1: | |||
| 2323 | * record (to be inserted into parent). | 2324 | * record (to be inserted into parent). |
| 2324 | */ | 2325 | */ |
| 2325 | STATIC int /* error */ | 2326 | STATIC int /* error */ |
| 2326 | xfs_btree_split( | 2327 | __xfs_btree_split( |
| 2327 | struct xfs_btree_cur *cur, | 2328 | struct xfs_btree_cur *cur, |
| 2328 | int level, | 2329 | int level, |
| 2329 | union xfs_btree_ptr *ptrp, | 2330 | union xfs_btree_ptr *ptrp, |
| @@ -2503,6 +2504,85 @@ error0: | |||
| 2503 | return error; | 2504 | return error; |
| 2504 | } | 2505 | } |
| 2505 | 2506 | ||
| 2507 | struct xfs_btree_split_args { | ||
| 2508 | struct xfs_btree_cur *cur; | ||
| 2509 | int level; | ||
| 2510 | union xfs_btree_ptr *ptrp; | ||
| 2511 | union xfs_btree_key *key; | ||
| 2512 | struct xfs_btree_cur **curp; | ||
| 2513 | int *stat; /* success/failure */ | ||
| 2514 | int result; | ||
| 2515 | bool kswapd; /* allocation in kswapd context */ | ||
| 2516 | struct completion *done; | ||
| 2517 | struct work_struct work; | ||
| 2518 | }; | ||
| 2519 | |||
| 2520 | /* | ||
| 2521 | * Stack switching interfaces for allocation | ||
| 2522 | */ | ||
| 2523 | static void | ||
| 2524 | xfs_btree_split_worker( | ||
| 2525 | struct work_struct *work) | ||
| 2526 | { | ||
| 2527 | struct xfs_btree_split_args *args = container_of(work, | ||
| 2528 | struct xfs_btree_split_args, work); | ||
| 2529 | unsigned long pflags; | ||
| 2530 | unsigned long new_pflags = PF_FSTRANS; | ||
| 2531 | |||
| 2532 | /* | ||
| 2533 | * we are in a transaction context here, but may also be doing work | ||
| 2534 | * in kswapd context, and hence we may need to inherit that state | ||
| 2535 | * temporarily to ensure that we don't block waiting for memory reclaim | ||
| 2536 | * in any way. | ||
| 2537 | */ | ||
| 2538 | if (args->kswapd) | ||
| 2539 | new_pflags |= PF_MEMALLOC | PF_SWAPWRITE | PF_KSWAPD; | ||
| 2540 | |||
| 2541 | current_set_flags_nested(&pflags, new_pflags); | ||
| 2542 | |||
| 2543 | args->result = __xfs_btree_split(args->cur, args->level, args->ptrp, | ||
| 2544 | args->key, args->curp, args->stat); | ||
| 2545 | complete(args->done); | ||
| 2546 | |||
| 2547 | current_restore_flags_nested(&pflags, new_pflags); | ||
| 2548 | } | ||
| 2549 | |||
| 2550 | /* | ||
| 2551 | * BMBT split requests often come in with little stack to work on. Push | ||
| 2552 | * them off to a worker thread so there is lots of stack to use. For the other | ||
| 2553 | * btree types, just call directly to avoid the context switch overhead here. | ||
| 2554 | */ | ||
| 2555 | STATIC int /* error */ | ||
| 2556 | xfs_btree_split( | ||
| 2557 | struct xfs_btree_cur *cur, | ||
| 2558 | int level, | ||
| 2559 | union xfs_btree_ptr *ptrp, | ||
| 2560 | union xfs_btree_key *key, | ||
| 2561 | struct xfs_btree_cur **curp, | ||
| 2562 | int *stat) /* success/failure */ | ||
| 2563 | { | ||
| 2564 | struct xfs_btree_split_args args; | ||
| 2565 | DECLARE_COMPLETION_ONSTACK(done); | ||
| 2566 | |||
| 2567 | if (cur->bc_btnum != XFS_BTNUM_BMAP) | ||
| 2568 | return __xfs_btree_split(cur, level, ptrp, key, curp, stat); | ||
| 2569 | |||
| 2570 | args.cur = cur; | ||
| 2571 | args.level = level; | ||
| 2572 | args.ptrp = ptrp; | ||
| 2573 | args.key = key; | ||
| 2574 | args.curp = curp; | ||
| 2575 | args.stat = stat; | ||
| 2576 | args.done = &done; | ||
| 2577 | args.kswapd = current_is_kswapd(); | ||
| 2578 | INIT_WORK_ONSTACK(&args.work, xfs_btree_split_worker); | ||
| 2579 | queue_work(xfs_alloc_wq, &args.work); | ||
| 2580 | wait_for_completion(&done); | ||
| 2581 | destroy_work_on_stack(&args.work); | ||
| 2582 | return args.result; | ||
| 2583 | } | ||
| 2584 | |||
| 2585 | |||
| 2506 | /* | 2586 | /* |
| 2507 | * Copy the old inode root contents into a real block and make the | 2587 | * Copy the old inode root contents into a real block and make the |
| 2508 | * broot point to it. | 2588 | * broot point to it. |
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 6c5eb4c551e3..6d3ec2b6ee29 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c | |||
| @@ -749,8 +749,7 @@ xfs_iomap_write_allocate( | |||
| 749 | * pointer that the caller gave to us. | 749 | * pointer that the caller gave to us. |
| 750 | */ | 750 | */ |
| 751 | error = xfs_bmapi_write(tp, ip, map_start_fsb, | 751 | error = xfs_bmapi_write(tp, ip, map_start_fsb, |
| 752 | count_fsb, | 752 | count_fsb, 0, |
| 753 | XFS_BMAPI_STACK_SWITCH, | ||
| 754 | &first_block, 1, | 753 | &first_block, 1, |
| 755 | imap, &nimaps, &free_list); | 754 | imap, &nimaps, &free_list); |
| 756 | if (error) | 755 | if (error) |
diff --git a/fs/xfs/xfs_sb.c b/fs/xfs/xfs_sb.c index c3453b11f563..7703fa6770ff 100644 --- a/fs/xfs/xfs_sb.c +++ b/fs/xfs/xfs_sb.c | |||
| @@ -483,10 +483,16 @@ xfs_sb_quota_to_disk( | |||
| 483 | } | 483 | } |
| 484 | 484 | ||
| 485 | /* | 485 | /* |
| 486 | * GQUOTINO and PQUOTINO cannot be used together in versions | 486 | * GQUOTINO and PQUOTINO cannot be used together in versions of |
| 487 | * of superblock that do not have pquotino. from->sb_flags | 487 | * superblock that do not have pquotino. from->sb_flags tells us which |
| 488 | * tells us which quota is active and should be copied to | 488 | * quota is active and should be copied to disk. If neither are active, |
| 489 | * disk. | 489 | * make sure we write NULLFSINO to the sb_gquotino field as a quota |
| 490 | * inode value of "0" is invalid when the XFS_SB_VERSION_QUOTA feature | ||
| 491 | * bit is set. | ||
| 492 | * | ||
| 493 | * Note that we don't need to handle the sb_uquotino or sb_pquotino here | ||
| 494 | * as they do not require any translation. Hence the main sb field loop | ||
| 495 | * will write them appropriately from the in-core superblock. | ||
| 490 | */ | 496 | */ |
| 491 | if ((*fields & XFS_SB_GQUOTINO) && | 497 | if ((*fields & XFS_SB_GQUOTINO) && |
| 492 | (from->sb_qflags & XFS_GQUOTA_ACCT)) | 498 | (from->sb_qflags & XFS_GQUOTA_ACCT)) |
| @@ -494,6 +500,17 @@ xfs_sb_quota_to_disk( | |||
| 494 | else if ((*fields & XFS_SB_PQUOTINO) && | 500 | else if ((*fields & XFS_SB_PQUOTINO) && |
| 495 | (from->sb_qflags & XFS_PQUOTA_ACCT)) | 501 | (from->sb_qflags & XFS_PQUOTA_ACCT)) |
| 496 | to->sb_gquotino = cpu_to_be64(from->sb_pquotino); | 502 | to->sb_gquotino = cpu_to_be64(from->sb_pquotino); |
| 503 | else { | ||
| 504 | /* | ||
| 505 | * We can't rely on just the fields being logged to tell us | ||
| 506 | * that it is safe to write NULLFSINO - we should only do that | ||
| 507 | * if quotas are not actually enabled. Hence only write | ||
| 508 | * NULLFSINO if both in-core quota inodes are NULL. | ||
| 509 | */ | ||
| 510 | if (from->sb_gquotino == NULLFSINO && | ||
| 511 | from->sb_pquotino == NULLFSINO) | ||
| 512 | to->sb_gquotino = cpu_to_be64(NULLFSINO); | ||
| 513 | } | ||
| 497 | 514 | ||
| 498 | *fields &= ~(XFS_SB_PQUOTINO | XFS_SB_GQUOTINO); | 515 | *fields &= ~(XFS_SB_PQUOTINO | XFS_SB_GQUOTINO); |
| 499 | } | 516 | } |
diff --git a/include/acpi/video.h b/include/acpi/video.h index ea4c7bbded4d..843ef1adfbfa 100644 --- a/include/acpi/video.h +++ b/include/acpi/video.h | |||
| @@ -22,6 +22,7 @@ extern void acpi_video_unregister(void); | |||
| 22 | extern void acpi_video_unregister_backlight(void); | 22 | extern void acpi_video_unregister_backlight(void); |
| 23 | extern int acpi_video_get_edid(struct acpi_device *device, int type, | 23 | extern int acpi_video_get_edid(struct acpi_device *device, int type, |
| 24 | int device_id, void **edid); | 24 | int device_id, void **edid); |
| 25 | extern bool acpi_video_verify_backlight_support(void); | ||
| 25 | #else | 26 | #else |
| 26 | static inline int acpi_video_register(void) { return 0; } | 27 | static inline int acpi_video_register(void) { return 0; } |
| 27 | static inline void acpi_video_unregister(void) { return; } | 28 | static inline void acpi_video_unregister(void) { return; } |
| @@ -31,6 +32,7 @@ static inline int acpi_video_get_edid(struct acpi_device *device, int type, | |||
| 31 | { | 32 | { |
| 32 | return -ENODEV; | 33 | return -ENODEV; |
| 33 | } | 34 | } |
| 35 | static inline bool acpi_video_verify_backlight_support(void) { return false; } | ||
| 34 | #endif | 36 | #endif |
| 35 | 37 | ||
| 36 | #endif | 38 | #endif |
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 471ba48c7ae4..c1c0b0cf39b4 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h | |||
| @@ -693,7 +693,7 @@ | |||
| 693 | . = ALIGN(PAGE_SIZE); \ | 693 | . = ALIGN(PAGE_SIZE); \ |
| 694 | *(.data..percpu..page_aligned) \ | 694 | *(.data..percpu..page_aligned) \ |
| 695 | . = ALIGN(cacheline); \ | 695 | . = ALIGN(cacheline); \ |
| 696 | *(.data..percpu..readmostly) \ | 696 | *(.data..percpu..read_mostly) \ |
| 697 | . = ALIGN(cacheline); \ | 697 | . = ALIGN(cacheline); \ |
| 698 | *(.data..percpu) \ | 698 | *(.data..percpu) \ |
| 699 | *(.data..percpu..shared_aligned) \ | 699 | *(.data..percpu..shared_aligned) \ |
diff --git a/include/dt-bindings/clock/exynos5420.h b/include/dt-bindings/clock/exynos5420.h index 97dcb89d37d3..21d51ae1d242 100644 --- a/include/dt-bindings/clock/exynos5420.h +++ b/include/dt-bindings/clock/exynos5420.h | |||
| @@ -63,7 +63,6 @@ | |||
| 63 | #define CLK_SCLK_MPHY_IXTAL24 161 | 63 | #define CLK_SCLK_MPHY_IXTAL24 161 |
| 64 | 64 | ||
| 65 | /* gate clocks */ | 65 | /* gate clocks */ |
| 66 | #define CLK_ACLK66_PERIC 256 | ||
| 67 | #define CLK_UART0 257 | 66 | #define CLK_UART0 257 |
| 68 | #define CLK_UART1 258 | 67 | #define CLK_UART1 258 |
| 69 | #define CLK_UART2 259 | 68 | #define CLK_UART2 259 |
| @@ -203,6 +202,8 @@ | |||
| 203 | #define CLK_MOUT_G3D 641 | 202 | #define CLK_MOUT_G3D 641 |
| 204 | #define CLK_MOUT_VPLL 642 | 203 | #define CLK_MOUT_VPLL 642 |
| 205 | #define CLK_MOUT_MAUDIO0 643 | 204 | #define CLK_MOUT_MAUDIO0 643 |
| 205 | #define CLK_MOUT_USER_ACLK333 644 | ||
| 206 | #define CLK_MOUT_SW_ACLK333 645 | ||
| 206 | 207 | ||
| 207 | /* divider clocks */ | 208 | /* divider clocks */ |
| 208 | #define CLK_DOUT_PIXEL 768 | 209 | #define CLK_DOUT_PIXEL 768 |
diff --git a/include/dt-bindings/pinctrl/dra.h b/include/dt-bindings/pinctrl/dra.h index 002a2855c046..3d33794e4f3e 100644 --- a/include/dt-bindings/pinctrl/dra.h +++ b/include/dt-bindings/pinctrl/dra.h | |||
| @@ -30,7 +30,8 @@ | |||
| 30 | #define MUX_MODE14 0xe | 30 | #define MUX_MODE14 0xe |
| 31 | #define MUX_MODE15 0xf | 31 | #define MUX_MODE15 0xf |
| 32 | 32 | ||
| 33 | #define PULL_ENA (1 << 16) | 33 | #define PULL_ENA (0 << 16) |
| 34 | #define PULL_DIS (1 << 16) | ||
| 34 | #define PULL_UP (1 << 17) | 35 | #define PULL_UP (1 << 17) |
| 35 | #define INPUT_EN (1 << 18) | 36 | #define INPUT_EN (1 << 18) |
| 36 | #define SLEWCONTROL (1 << 19) | 37 | #define SLEWCONTROL (1 << 19) |
| @@ -38,10 +39,10 @@ | |||
| 38 | #define WAKEUP_EVENT (1 << 25) | 39 | #define WAKEUP_EVENT (1 << 25) |
| 39 | 40 | ||
| 40 | /* Active pin states */ | 41 | /* Active pin states */ |
| 41 | #define PIN_OUTPUT 0 | 42 | #define PIN_OUTPUT (0 | PULL_DIS) |
| 42 | #define PIN_OUTPUT_PULLUP (PIN_OUTPUT | PULL_ENA | PULL_UP) | 43 | #define PIN_OUTPUT_PULLUP (PIN_OUTPUT | PULL_ENA | PULL_UP) |
| 43 | #define PIN_OUTPUT_PULLDOWN (PIN_OUTPUT | PULL_ENA) | 44 | #define PIN_OUTPUT_PULLDOWN (PIN_OUTPUT | PULL_ENA) |
| 44 | #define PIN_INPUT INPUT_EN | 45 | #define PIN_INPUT (INPUT_EN | PULL_DIS) |
| 45 | #define PIN_INPUT_SLEW (INPUT_EN | SLEWCONTROL) | 46 | #define PIN_INPUT_SLEW (INPUT_EN | SLEWCONTROL) |
| 46 | #define PIN_INPUT_PULLUP (PULL_ENA | INPUT_EN | PULL_UP) | 47 | #define PIN_INPUT_PULLUP (PULL_ENA | INPUT_EN | PULL_UP) |
| 47 | #define PIN_INPUT_PULLDOWN (PULL_ENA | INPUT_EN) | 48 | #define PIN_INPUT_PULLDOWN (PULL_ENA | INPUT_EN) |
diff --git a/include/linux/atmel-ssc.h b/include/linux/atmel-ssc.h index 571a12ebb018..7c0f6549898b 100644 --- a/include/linux/atmel-ssc.h +++ b/include/linux/atmel-ssc.h | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | struct atmel_ssc_platform_data { | 8 | struct atmel_ssc_platform_data { |
| 9 | int use_dma; | 9 | int use_dma; |
| 10 | int has_fslen_ext; | ||
| 10 | }; | 11 | }; |
| 11 | 12 | ||
| 12 | struct ssc_device { | 13 | struct ssc_device { |
| @@ -71,6 +72,12 @@ void ssc_free(struct ssc_device *ssc); | |||
| 71 | #define SSC_RFMR_DATNB_OFFSET 8 | 72 | #define SSC_RFMR_DATNB_OFFSET 8 |
| 72 | #define SSC_RFMR_FSEDGE_SIZE 1 | 73 | #define SSC_RFMR_FSEDGE_SIZE 1 |
| 73 | #define SSC_RFMR_FSEDGE_OFFSET 24 | 74 | #define SSC_RFMR_FSEDGE_OFFSET 24 |
| 75 | /* | ||
| 76 | * The FSLEN_EXT exist on at91sam9rl, at91sam9g10, | ||
| 77 | * at91sam9g20, and at91sam9g45 and newer SoCs | ||
| 78 | */ | ||
| 79 | #define SSC_RFMR_FSLEN_EXT_SIZE 4 | ||
| 80 | #define SSC_RFMR_FSLEN_EXT_OFFSET 28 | ||
| 74 | #define SSC_RFMR_FSLEN_SIZE 4 | 81 | #define SSC_RFMR_FSLEN_SIZE 4 |
| 75 | #define SSC_RFMR_FSLEN_OFFSET 16 | 82 | #define SSC_RFMR_FSLEN_OFFSET 16 |
| 76 | #define SSC_RFMR_FSOS_SIZE 4 | 83 | #define SSC_RFMR_FSOS_SIZE 4 |
| @@ -109,6 +116,12 @@ void ssc_free(struct ssc_device *ssc); | |||
| 109 | #define SSC_TFMR_FSDEN_OFFSET 23 | 116 | #define SSC_TFMR_FSDEN_OFFSET 23 |
| 110 | #define SSC_TFMR_FSEDGE_SIZE 1 | 117 | #define SSC_TFMR_FSEDGE_SIZE 1 |
| 111 | #define SSC_TFMR_FSEDGE_OFFSET 24 | 118 | #define SSC_TFMR_FSEDGE_OFFSET 24 |
| 119 | /* | ||
| 120 | * The FSLEN_EXT exist on at91sam9rl, at91sam9g10, | ||
| 121 | * at91sam9g20, and at91sam9g45 and newer SoCs | ||
| 122 | */ | ||
| 123 | #define SSC_TFMR_FSLEN_EXT_SIZE 4 | ||
| 124 | #define SSC_TFMR_FSLEN_EXT_OFFSET 28 | ||
| 112 | #define SSC_TFMR_FSLEN_SIZE 4 | 125 | #define SSC_TFMR_FSLEN_SIZE 4 |
| 113 | #define SSC_TFMR_FSLEN_OFFSET 16 | 126 | #define SSC_TFMR_FSLEN_OFFSET 16 |
| 114 | #define SSC_TFMR_FSOS_SIZE 3 | 127 | #define SSC_TFMR_FSOS_SIZE 3 |
diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h index ec4112d257bc..8f8ae95c6e27 100644 --- a/include/linux/cpufreq.h +++ b/include/linux/cpufreq.h | |||
| @@ -482,8 +482,8 @@ extern struct cpufreq_governor cpufreq_gov_conservative; | |||
| 482 | *********************************************************************/ | 482 | *********************************************************************/ |
| 483 | 483 | ||
| 484 | /* Special Values of .frequency field */ | 484 | /* Special Values of .frequency field */ |
| 485 | #define CPUFREQ_ENTRY_INVALID ~0 | 485 | #define CPUFREQ_ENTRY_INVALID ~0u |
| 486 | #define CPUFREQ_TABLE_END ~1 | 486 | #define CPUFREQ_TABLE_END ~1u |
| 487 | /* Special Values of .flags field */ | 487 | /* Special Values of .flags field */ |
| 488 | #define CPUFREQ_BOOST_FREQ (1 << 0) | 488 | #define CPUFREQ_BOOST_FREQ (1 << 0) |
| 489 | 489 | ||
diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h index d2c5cc7c583c..3d1c2aa51530 100644 --- a/include/linux/dmaengine.h +++ b/include/linux/dmaengine.h | |||
| @@ -299,6 +299,7 @@ enum dma_slave_buswidth { | |||
| 299 | DMA_SLAVE_BUSWIDTH_UNDEFINED = 0, | 299 | DMA_SLAVE_BUSWIDTH_UNDEFINED = 0, |
| 300 | DMA_SLAVE_BUSWIDTH_1_BYTE = 1, | 300 | DMA_SLAVE_BUSWIDTH_1_BYTE = 1, |
| 301 | DMA_SLAVE_BUSWIDTH_2_BYTES = 2, | 301 | DMA_SLAVE_BUSWIDTH_2_BYTES = 2, |
| 302 | DMA_SLAVE_BUSWIDTH_3_BYTES = 3, | ||
| 302 | DMA_SLAVE_BUSWIDTH_4_BYTES = 4, | 303 | DMA_SLAVE_BUSWIDTH_4_BYTES = 4, |
| 303 | DMA_SLAVE_BUSWIDTH_8_BYTES = 8, | 304 | DMA_SLAVE_BUSWIDTH_8_BYTES = 8, |
| 304 | }; | 305 | }; |
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h index 255cd5cc0754..a23c096b3080 100644 --- a/include/linux/hugetlb.h +++ b/include/linux/hugetlb.h | |||
| @@ -80,6 +80,7 @@ int dequeue_hwpoisoned_huge_page(struct page *page); | |||
| 80 | bool isolate_huge_page(struct page *page, struct list_head *list); | 80 | bool isolate_huge_page(struct page *page, struct list_head *list); |
| 81 | void putback_active_hugepage(struct page *page); | 81 | void putback_active_hugepage(struct page *page); |
| 82 | bool is_hugepage_active(struct page *page); | 82 | bool is_hugepage_active(struct page *page); |
| 83 | void free_huge_page(struct page *page); | ||
| 83 | 84 | ||
| 84 | #ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE | 85 | #ifdef CONFIG_ARCH_WANT_HUGE_PMD_SHARE |
| 85 | pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud); | 86 | pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud); |
diff --git a/include/linux/kernfs.h b/include/linux/kernfs.h index 145375ea0bd9..30faf797c2c3 100644 --- a/include/linux/kernfs.h +++ b/include/linux/kernfs.h | |||
| @@ -305,6 +305,7 @@ struct dentry *kernfs_mount_ns(struct file_system_type *fs_type, int flags, | |||
| 305 | struct kernfs_root *root, unsigned long magic, | 305 | struct kernfs_root *root, unsigned long magic, |
| 306 | bool *new_sb_created, const void *ns); | 306 | bool *new_sb_created, const void *ns); |
| 307 | void kernfs_kill_sb(struct super_block *sb); | 307 | void kernfs_kill_sb(struct super_block *sb); |
| 308 | struct super_block *kernfs_pin_sb(struct kernfs_root *root, const void *ns); | ||
| 308 | 309 | ||
| 309 | void kernfs_init(void); | 310 | void kernfs_init(void); |
| 310 | 311 | ||
diff --git a/include/linux/libata.h b/include/linux/libata.h index 5ab4e3a76721..92abb497ab14 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h | |||
| @@ -593,6 +593,7 @@ struct ata_host { | |||
| 593 | struct device *dev; | 593 | struct device *dev; |
| 594 | void __iomem * const *iomap; | 594 | void __iomem * const *iomap; |
| 595 | unsigned int n_ports; | 595 | unsigned int n_ports; |
| 596 | unsigned int n_tags; /* nr of NCQ tags */ | ||
| 596 | void *private_data; | 597 | void *private_data; |
| 597 | struct ata_port_operations *ops; | 598 | struct ata_port_operations *ops; |
| 598 | unsigned long flags; | 599 | unsigned long flags; |
diff --git a/include/linux/mfd/arizona/core.h b/include/linux/mfd/arizona/core.h index 6d9371f88875..a614b33d0a39 100644 --- a/include/linux/mfd/arizona/core.h +++ b/include/linux/mfd/arizona/core.h | |||
| @@ -110,6 +110,12 @@ struct arizona { | |||
| 110 | int clk32k_ref; | 110 | int clk32k_ref; |
| 111 | 111 | ||
| 112 | struct snd_soc_dapm_context *dapm; | 112 | struct snd_soc_dapm_context *dapm; |
| 113 | |||
| 114 | int tdm_width[ARIZONA_MAX_AIF]; | ||
| 115 | int tdm_slots[ARIZONA_MAX_AIF]; | ||
| 116 | |||
| 117 | uint16_t dac_comp_coeff; | ||
| 118 | uint8_t dac_comp_enabled; | ||
| 113 | }; | 119 | }; |
| 114 | 120 | ||
| 115 | int arizona_clk32k_enable(struct arizona *arizona); | 121 | int arizona_clk32k_enable(struct arizona *arizona); |
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index b12f4bbd064c..35b51e7af886 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
| @@ -578,8 +578,6 @@ struct mlx4_cq { | |||
| 578 | u32 cons_index; | 578 | u32 cons_index; |
| 579 | 579 | ||
| 580 | u16 irq; | 580 | u16 irq; |
| 581 | bool irq_affinity_change; | ||
| 582 | |||
| 583 | __be32 *set_ci_db; | 581 | __be32 *set_ci_db; |
| 584 | __be32 *arm_db; | 582 | __be32 *arm_db; |
| 585 | int arm_sn; | 583 | int arm_sn; |
| @@ -1167,6 +1165,8 @@ int mlx4_assign_eq(struct mlx4_dev *dev, char *name, struct cpu_rmap *rmap, | |||
| 1167 | int *vector); | 1165 | int *vector); |
| 1168 | void mlx4_release_eq(struct mlx4_dev *dev, int vec); | 1166 | void mlx4_release_eq(struct mlx4_dev *dev, int vec); |
| 1169 | 1167 | ||
| 1168 | int mlx4_eq_get_irq(struct mlx4_dev *dev, int vec); | ||
| 1169 | |||
| 1170 | int mlx4_get_phys_port_id(struct mlx4_dev *dev); | 1170 | int mlx4_get_phys_port_id(struct mlx4_dev *dev); |
| 1171 | int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port); | 1171 | int mlx4_wol_read(struct mlx4_dev *dev, u64 *config, int port); |
| 1172 | int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port); | 1172 | int mlx4_wol_write(struct mlx4_dev *dev, u64 config, int port); |
diff --git a/include/linux/mutex.h b/include/linux/mutex.h index 11692dea18aa..42aa9b9ecd5f 100644 --- a/include/linux/mutex.h +++ b/include/linux/mutex.h | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/lockdep.h> | 17 | #include <linux/lockdep.h> |
| 18 | #include <linux/atomic.h> | 18 | #include <linux/atomic.h> |
| 19 | #include <asm/processor.h> | 19 | #include <asm/processor.h> |
| 20 | #include <linux/osq_lock.h> | ||
| 20 | 21 | ||
| 21 | /* | 22 | /* |
| 22 | * Simple, straightforward mutexes with strict semantics: | 23 | * Simple, straightforward mutexes with strict semantics: |
| @@ -46,7 +47,6 @@ | |||
| 46 | * - detects multi-task circular deadlocks and prints out all affected | 47 | * - detects multi-task circular deadlocks and prints out all affected |
| 47 | * locks and tasks (and only those tasks) | 48 | * locks and tasks (and only those tasks) |
| 48 | */ | 49 | */ |
| 49 | struct optimistic_spin_queue; | ||
| 50 | struct mutex { | 50 | struct mutex { |
| 51 | /* 1: unlocked, 0: locked, negative: locked, possible waiters */ | 51 | /* 1: unlocked, 0: locked, negative: locked, possible waiters */ |
| 52 | atomic_t count; | 52 | atomic_t count; |
| @@ -56,7 +56,7 @@ struct mutex { | |||
| 56 | struct task_struct *owner; | 56 | struct task_struct *owner; |
| 57 | #endif | 57 | #endif |
| 58 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER | 58 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER |
| 59 | struct optimistic_spin_queue *osq; /* Spinner MCS lock */ | 59 | struct optimistic_spin_queue osq; /* Spinner MCS lock */ |
| 60 | #endif | 60 | #endif |
| 61 | #ifdef CONFIG_DEBUG_MUTEXES | 61 | #ifdef CONFIG_DEBUG_MUTEXES |
| 62 | const char *name; | 62 | const char *name; |
diff --git a/include/linux/of_fdt.h b/include/linux/of_fdt.h index 05117899fcb4..0ff360d5b3b3 100644 --- a/include/linux/of_fdt.h +++ b/include/linux/of_fdt.h | |||
| @@ -73,6 +73,8 @@ extern int early_init_dt_scan_root(unsigned long node, const char *uname, | |||
| 73 | int depth, void *data); | 73 | int depth, void *data); |
| 74 | 74 | ||
| 75 | extern bool early_init_dt_scan(void *params); | 75 | extern bool early_init_dt_scan(void *params); |
| 76 | extern bool early_init_dt_verify(void *params); | ||
| 77 | extern void early_init_dt_scan_nodes(void); | ||
| 76 | 78 | ||
| 77 | extern const char *of_flat_dt_get_machine_name(void); | 79 | extern const char *of_flat_dt_get_machine_name(void); |
| 78 | extern const void *of_flat_dt_match_machine(const void *default_match, | 80 | extern const void *of_flat_dt_match_machine(const void *default_match, |
| @@ -84,6 +86,7 @@ extern void unflatten_and_copy_device_tree(void); | |||
| 84 | extern void early_init_devtree(void *); | 86 | extern void early_init_devtree(void *); |
| 85 | extern void early_get_first_memblock_info(void *, phys_addr_t *); | 87 | extern void early_get_first_memblock_info(void *, phys_addr_t *); |
| 86 | extern u64 fdt_translate_address(const void *blob, int node_offset); | 88 | extern u64 fdt_translate_address(const void *blob, int node_offset); |
| 89 | extern void of_fdt_limit_memory(int limit); | ||
| 87 | #else /* CONFIG_OF_FLATTREE */ | 90 | #else /* CONFIG_OF_FLATTREE */ |
| 88 | static inline void early_init_fdt_scan_reserved_mem(void) {} | 91 | static inline void early_init_fdt_scan_reserved_mem(void) {} |
| 89 | static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } | 92 | static inline const char *of_flat_dt_get_machine_name(void) { return NULL; } |
diff --git a/include/linux/of_mdio.h b/include/linux/of_mdio.h index a70c9493d55a..d449018d0726 100644 --- a/include/linux/of_mdio.h +++ b/include/linux/of_mdio.h | |||
| @@ -25,9 +25,6 @@ struct phy_device *of_phy_attach(struct net_device *dev, | |||
| 25 | 25 | ||
| 26 | extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); | 26 | extern struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np); |
| 27 | 27 | ||
| 28 | extern void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
| 29 | struct phy_device *phydev); | ||
| 30 | |||
| 31 | #else /* CONFIG_OF */ | 28 | #else /* CONFIG_OF */ |
| 32 | static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) | 29 | static inline int of_mdiobus_register(struct mii_bus *mdio, struct device_node *np) |
| 33 | { | 30 | { |
| @@ -63,11 +60,6 @@ static inline struct mii_bus *of_mdio_find_bus(struct device_node *mdio_np) | |||
| 63 | { | 60 | { |
| 64 | return NULL; | 61 | return NULL; |
| 65 | } | 62 | } |
| 66 | |||
| 67 | static inline void of_mdiobus_link_phydev(struct mii_bus *mdio, | ||
| 68 | struct phy_device *phydev) | ||
| 69 | { | ||
| 70 | } | ||
| 71 | #endif /* CONFIG_OF */ | 63 | #endif /* CONFIG_OF */ |
| 72 | 64 | ||
| 73 | #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) | 65 | #if defined(CONFIG_OF) && defined(CONFIG_FIXED_PHY) |
diff --git a/include/linux/osq_lock.h b/include/linux/osq_lock.h new file mode 100644 index 000000000000..90230d5811c5 --- /dev/null +++ b/include/linux/osq_lock.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #ifndef __LINUX_OSQ_LOCK_H | ||
| 2 | #define __LINUX_OSQ_LOCK_H | ||
| 3 | |||
| 4 | /* | ||
| 5 | * An MCS like lock especially tailored for optimistic spinning for sleeping | ||
| 6 | * lock implementations (mutex, rwsem, etc). | ||
| 7 | */ | ||
| 8 | |||
| 9 | #define OSQ_UNLOCKED_VAL (0) | ||
| 10 | |||
| 11 | struct optimistic_spin_queue { | ||
| 12 | /* | ||
| 13 | * Stores an encoded value of the CPU # of the tail node in the queue. | ||
| 14 | * If the queue is empty, then it's set to OSQ_UNLOCKED_VAL. | ||
| 15 | */ | ||
| 16 | atomic_t tail; | ||
| 17 | }; | ||
| 18 | |||
| 19 | /* Init macro and function. */ | ||
| 20 | #define OSQ_LOCK_UNLOCKED { ATOMIC_INIT(OSQ_UNLOCKED_VAL) } | ||
| 21 | |||
| 22 | static inline void osq_lock_init(struct optimistic_spin_queue *lock) | ||
| 23 | { | ||
| 24 | atomic_set(&lock->tail, OSQ_UNLOCKED_VAL); | ||
| 25 | } | ||
| 26 | |||
| 27 | #endif | ||
diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index 0a97b583ee8d..e1474ae18c88 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h | |||
| @@ -399,6 +399,18 @@ static inline struct page *read_mapping_page(struct address_space *mapping, | |||
| 399 | } | 399 | } |
| 400 | 400 | ||
| 401 | /* | 401 | /* |
| 402 | * Get the offset in PAGE_SIZE. | ||
| 403 | * (TODO: hugepage should have ->index in PAGE_SIZE) | ||
| 404 | */ | ||
| 405 | static inline pgoff_t page_to_pgoff(struct page *page) | ||
| 406 | { | ||
| 407 | if (unlikely(PageHeadHuge(page))) | ||
| 408 | return page->index << compound_order(page); | ||
| 409 | else | ||
| 410 | return page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); | ||
| 411 | } | ||
| 412 | |||
| 413 | /* | ||
| 402 | * Return byte-offset into filesystem object for page. | 414 | * Return byte-offset into filesystem object for page. |
| 403 | */ | 415 | */ |
| 404 | static inline loff_t page_offset(struct page *page) | 416 | static inline loff_t page_offset(struct page *page) |
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index a5fc7d01aad6..dec01d6c3f80 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h | |||
| @@ -146,10 +146,10 @@ | |||
| 146 | * Declaration/definition used for per-CPU variables that must be read mostly. | 146 | * Declaration/definition used for per-CPU variables that must be read mostly. |
| 147 | */ | 147 | */ |
| 148 | #define DECLARE_PER_CPU_READ_MOSTLY(type, name) \ | 148 | #define DECLARE_PER_CPU_READ_MOSTLY(type, name) \ |
| 149 | DECLARE_PER_CPU_SECTION(type, name, "..readmostly") | 149 | DECLARE_PER_CPU_SECTION(type, name, "..read_mostly") |
| 150 | 150 | ||
| 151 | #define DEFINE_PER_CPU_READ_MOSTLY(type, name) \ | 151 | #define DEFINE_PER_CPU_READ_MOSTLY(type, name) \ |
| 152 | DEFINE_PER_CPU_SECTION(type, name, "..readmostly") | 152 | DEFINE_PER_CPU_SECTION(type, name, "..read_mostly") |
| 153 | 153 | ||
| 154 | /* | 154 | /* |
| 155 | * Intermodule exports for per-CPU variables. sparse forgets about | 155 | * Intermodule exports for per-CPU variables. sparse forgets about |
diff --git a/include/linux/platform_data/asoc-s3c.h b/include/linux/platform_data/asoc-s3c.h index 709c6f7e2f8c..a6591c693ebb 100644 --- a/include/linux/platform_data/asoc-s3c.h +++ b/include/linux/platform_data/asoc-s3c.h | |||
| @@ -15,15 +15,6 @@ | |||
| 15 | #define S3C64XX_AC97_GPE 1 | 15 | #define S3C64XX_AC97_GPE 1 |
| 16 | extern void s3c64xx_ac97_setup_gpio(int); | 16 | extern void s3c64xx_ac97_setup_gpio(int); |
| 17 | 17 | ||
| 18 | /* | ||
| 19 | * The machine init code calls s5p*_spdif_setup_gpio with | ||
| 20 | * one of these defines in order to select appropriate bank | ||
| 21 | * of GPIO for S/PDIF pins | ||
| 22 | */ | ||
| 23 | #define S5PC100_SPDIF_GPD 0 | ||
| 24 | #define S5PC100_SPDIF_GPG3 1 | ||
| 25 | extern void s5pc100_spdif_setup_gpio(int); | ||
| 26 | |||
| 27 | struct samsung_i2s { | 18 | struct samsung_i2s { |
| 28 | /* If the Primary DAI has 5.1 Channels */ | 19 | /* If the Primary DAI has 5.1 Channels */ |
| 29 | #define QUIRK_PRI_6CHAN (1 << 0) | 20 | #define QUIRK_PRI_6CHAN (1 << 0) |
diff --git a/include/linux/platform_data/dma-imx.h b/include/linux/platform_data/dma-imx.h index bcbc6c3c14c0..d05542aafa3e 100644 --- a/include/linux/platform_data/dma-imx.h +++ b/include/linux/platform_data/dma-imx.h | |||
| @@ -50,6 +50,7 @@ enum imx_dma_prio { | |||
| 50 | 50 | ||
| 51 | struct imx_dma_data { | 51 | struct imx_dma_data { |
| 52 | int dma_request; /* DMA request line */ | 52 | int dma_request; /* DMA request line */ |
| 53 | int dma_request2; /* secondary DMA request line */ | ||
| 53 | enum sdma_peripheral_type peripheral_type; | 54 | enum sdma_peripheral_type peripheral_type; |
| 54 | int priority; | 55 | int priority; |
| 55 | }; | 56 | }; |
diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h index 5a75d19aa661..6a94cc8b1ca0 100644 --- a/include/linux/rcupdate.h +++ b/include/linux/rcupdate.h | |||
| @@ -44,7 +44,6 @@ | |||
| 44 | #include <linux/debugobjects.h> | 44 | #include <linux/debugobjects.h> |
| 45 | #include <linux/bug.h> | 45 | #include <linux/bug.h> |
| 46 | #include <linux/compiler.h> | 46 | #include <linux/compiler.h> |
| 47 | #include <linux/percpu.h> | ||
| 48 | #include <asm/barrier.h> | 47 | #include <asm/barrier.h> |
| 49 | 48 | ||
| 50 | extern int rcu_expedited; /* for sysctl */ | 49 | extern int rcu_expedited; /* for sysctl */ |
| @@ -300,41 +299,6 @@ bool __rcu_is_watching(void); | |||
| 300 | #endif /* #if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) || defined(CONFIG_SMP) */ | 299 | #endif /* #if defined(CONFIG_DEBUG_LOCK_ALLOC) || defined(CONFIG_RCU_TRACE) || defined(CONFIG_SMP) */ |
| 301 | 300 | ||
| 302 | /* | 301 | /* |
| 303 | * Hooks for cond_resched() and friends to avoid RCU CPU stall warnings. | ||
| 304 | */ | ||
| 305 | |||
| 306 | #define RCU_COND_RESCHED_LIM 256 /* ms vs. 100s of ms. */ | ||
| 307 | DECLARE_PER_CPU(int, rcu_cond_resched_count); | ||
| 308 | void rcu_resched(void); | ||
| 309 | |||
| 310 | /* | ||
| 311 | * Is it time to report RCU quiescent states? | ||
| 312 | * | ||
| 313 | * Note unsynchronized access to rcu_cond_resched_count. Yes, we might | ||
| 314 | * increment some random CPU's count, and possibly also load the result from | ||
| 315 | * yet another CPU's count. We might even clobber some other CPU's attempt | ||
| 316 | * to zero its counter. This is all OK because the goal is not precision, | ||
| 317 | * but rather reasonable amortization of rcu_note_context_switch() overhead | ||
| 318 | * and extremely high probability of avoiding RCU CPU stall warnings. | ||
| 319 | * Note that this function has to be preempted in just the wrong place, | ||
| 320 | * many thousands of times in a row, for anything bad to happen. | ||
| 321 | */ | ||
| 322 | static inline bool rcu_should_resched(void) | ||
| 323 | { | ||
| 324 | return raw_cpu_inc_return(rcu_cond_resched_count) >= | ||
| 325 | RCU_COND_RESCHED_LIM; | ||
| 326 | } | ||
| 327 | |||
| 328 | /* | ||
| 329 | * Report quiscent states to RCU if it is time to do so. | ||
| 330 | */ | ||
| 331 | static inline void rcu_cond_resched(void) | ||
| 332 | { | ||
| 333 | if (unlikely(rcu_should_resched())) | ||
| 334 | rcu_resched(); | ||
| 335 | } | ||
| 336 | |||
| 337 | /* | ||
| 338 | * Infrastructure to implement the synchronize_() primitives in | 302 | * Infrastructure to implement the synchronize_() primitives in |
| 339 | * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. | 303 | * TREE_RCU and rcu_barrier_() primitives in TINY_RCU. |
| 340 | */ | 304 | */ |
| @@ -358,9 +322,19 @@ void wait_rcu_gp(call_rcu_func_t crf); | |||
| 358 | * initialization. | 322 | * initialization. |
| 359 | */ | 323 | */ |
| 360 | #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD | 324 | #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD |
| 325 | void init_rcu_head(struct rcu_head *head); | ||
| 326 | void destroy_rcu_head(struct rcu_head *head); | ||
| 361 | void init_rcu_head_on_stack(struct rcu_head *head); | 327 | void init_rcu_head_on_stack(struct rcu_head *head); |
| 362 | void destroy_rcu_head_on_stack(struct rcu_head *head); | 328 | void destroy_rcu_head_on_stack(struct rcu_head *head); |
| 363 | #else /* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ | 329 | #else /* !CONFIG_DEBUG_OBJECTS_RCU_HEAD */ |
| 330 | static inline void init_rcu_head(struct rcu_head *head) | ||
| 331 | { | ||
| 332 | } | ||
| 333 | |||
| 334 | static inline void destroy_rcu_head(struct rcu_head *head) | ||
| 335 | { | ||
| 336 | } | ||
| 337 | |||
| 364 | static inline void init_rcu_head_on_stack(struct rcu_head *head) | 338 | static inline void init_rcu_head_on_stack(struct rcu_head *head) |
| 365 | { | 339 | { |
| 366 | } | 340 | } |
diff --git a/include/linux/rwsem-spinlock.h b/include/linux/rwsem-spinlock.h index d5b13bc07a0b..561e8615528d 100644 --- a/include/linux/rwsem-spinlock.h +++ b/include/linux/rwsem-spinlock.h | |||
| @@ -15,13 +15,13 @@ | |||
| 15 | #ifdef __KERNEL__ | 15 | #ifdef __KERNEL__ |
| 16 | /* | 16 | /* |
| 17 | * the rw-semaphore definition | 17 | * the rw-semaphore definition |
| 18 | * - if activity is 0 then there are no active readers or writers | 18 | * - if count is 0 then there are no active readers or writers |
| 19 | * - if activity is +ve then that is the number of active readers | 19 | * - if count is +ve then that is the number of active readers |
| 20 | * - if activity is -1 then there is one active writer | 20 | * - if count is -1 then there is one active writer |
| 21 | * - if wait_list is not empty, then there are processes waiting for the semaphore | 21 | * - if wait_list is not empty, then there are processes waiting for the semaphore |
| 22 | */ | 22 | */ |
| 23 | struct rw_semaphore { | 23 | struct rw_semaphore { |
| 24 | __s32 activity; | 24 | __s32 count; |
| 25 | raw_spinlock_t wait_lock; | 25 | raw_spinlock_t wait_lock; |
| 26 | struct list_head wait_list; | 26 | struct list_head wait_list; |
| 27 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 27 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
diff --git a/include/linux/rwsem.h b/include/linux/rwsem.h index 8d79708146aa..035d3c57fc8a 100644 --- a/include/linux/rwsem.h +++ b/include/linux/rwsem.h | |||
| @@ -13,10 +13,11 @@ | |||
| 13 | #include <linux/kernel.h> | 13 | #include <linux/kernel.h> |
| 14 | #include <linux/list.h> | 14 | #include <linux/list.h> |
| 15 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
| 16 | |||
| 17 | #include <linux/atomic.h> | 16 | #include <linux/atomic.h> |
| 17 | #ifdef CONFIG_RWSEM_SPIN_ON_OWNER | ||
| 18 | #include <linux/osq_lock.h> | ||
| 19 | #endif | ||
| 18 | 20 | ||
| 19 | struct optimistic_spin_queue; | ||
| 20 | struct rw_semaphore; | 21 | struct rw_semaphore; |
| 21 | 22 | ||
| 22 | #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK | 23 | #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK |
| @@ -25,15 +26,15 @@ struct rw_semaphore; | |||
| 25 | /* All arch specific implementations share the same struct */ | 26 | /* All arch specific implementations share the same struct */ |
| 26 | struct rw_semaphore { | 27 | struct rw_semaphore { |
| 27 | long count; | 28 | long count; |
| 28 | raw_spinlock_t wait_lock; | ||
| 29 | struct list_head wait_list; | 29 | struct list_head wait_list; |
| 30 | #ifdef CONFIG_SMP | 30 | raw_spinlock_t wait_lock; |
| 31 | #ifdef CONFIG_RWSEM_SPIN_ON_OWNER | ||
| 32 | struct optimistic_spin_queue osq; /* spinner MCS lock */ | ||
| 31 | /* | 33 | /* |
| 32 | * Write owner. Used as a speculative check to see | 34 | * Write owner. Used as a speculative check to see |
| 33 | * if the owner is running on the cpu. | 35 | * if the owner is running on the cpu. |
| 34 | */ | 36 | */ |
| 35 | struct task_struct *owner; | 37 | struct task_struct *owner; |
| 36 | struct optimistic_spin_queue *osq; /* spinner MCS lock */ | ||
| 37 | #endif | 38 | #endif |
| 38 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | 39 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
| 39 | struct lockdep_map dep_map; | 40 | struct lockdep_map dep_map; |
| @@ -64,22 +65,19 @@ static inline int rwsem_is_locked(struct rw_semaphore *sem) | |||
| 64 | # define __RWSEM_DEP_MAP_INIT(lockname) | 65 | # define __RWSEM_DEP_MAP_INIT(lockname) |
| 65 | #endif | 66 | #endif |
| 66 | 67 | ||
| 67 | #if defined(CONFIG_SMP) && !defined(CONFIG_RWSEM_GENERIC_SPINLOCK) | 68 | #ifdef CONFIG_RWSEM_SPIN_ON_OWNER |
| 68 | #define __RWSEM_INITIALIZER(name) \ | 69 | #define __RWSEM_OPT_INIT(lockname) , .osq = OSQ_LOCK_UNLOCKED, .owner = NULL |
| 69 | { RWSEM_UNLOCKED_VALUE, \ | ||
| 70 | __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \ | ||
| 71 | LIST_HEAD_INIT((name).wait_list), \ | ||
| 72 | NULL, /* owner */ \ | ||
| 73 | NULL /* mcs lock */ \ | ||
| 74 | __RWSEM_DEP_MAP_INIT(name) } | ||
| 75 | #else | 70 | #else |
| 76 | #define __RWSEM_INITIALIZER(name) \ | 71 | #define __RWSEM_OPT_INIT(lockname) |
| 77 | { RWSEM_UNLOCKED_VALUE, \ | ||
| 78 | __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock), \ | ||
| 79 | LIST_HEAD_INIT((name).wait_list) \ | ||
| 80 | __RWSEM_DEP_MAP_INIT(name) } | ||
| 81 | #endif | 72 | #endif |
| 82 | 73 | ||
| 74 | #define __RWSEM_INITIALIZER(name) \ | ||
| 75 | { .count = RWSEM_UNLOCKED_VALUE, \ | ||
| 76 | .wait_list = LIST_HEAD_INIT((name).wait_list), \ | ||
| 77 | .wait_lock = __RAW_SPIN_LOCK_UNLOCKED(name.wait_lock) \ | ||
| 78 | __RWSEM_OPT_INIT(name) \ | ||
| 79 | __RWSEM_DEP_MAP_INIT(name) } | ||
| 80 | |||
| 83 | #define DECLARE_RWSEM(name) \ | 81 | #define DECLARE_RWSEM(name) \ |
| 84 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) | 82 | struct rw_semaphore name = __RWSEM_INITIALIZER(name) |
| 85 | 83 | ||
diff --git a/include/linux/sched.h b/include/linux/sched.h index 306f4f0c987a..0376b054a0d0 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -872,21 +872,21 @@ enum cpu_idle_type { | |||
| 872 | #define SD_NUMA 0x4000 /* cross-node balancing */ | 872 | #define SD_NUMA 0x4000 /* cross-node balancing */ |
| 873 | 873 | ||
| 874 | #ifdef CONFIG_SCHED_SMT | 874 | #ifdef CONFIG_SCHED_SMT |
| 875 | static inline const int cpu_smt_flags(void) | 875 | static inline int cpu_smt_flags(void) |
| 876 | { | 876 | { |
| 877 | return SD_SHARE_CPUCAPACITY | SD_SHARE_PKG_RESOURCES; | 877 | return SD_SHARE_CPUCAPACITY | SD_SHARE_PKG_RESOURCES; |
| 878 | } | 878 | } |
| 879 | #endif | 879 | #endif |
| 880 | 880 | ||
| 881 | #ifdef CONFIG_SCHED_MC | 881 | #ifdef CONFIG_SCHED_MC |
| 882 | static inline const int cpu_core_flags(void) | 882 | static inline int cpu_core_flags(void) |
| 883 | { | 883 | { |
| 884 | return SD_SHARE_PKG_RESOURCES; | 884 | return SD_SHARE_PKG_RESOURCES; |
| 885 | } | 885 | } |
| 886 | #endif | 886 | #endif |
| 887 | 887 | ||
| 888 | #ifdef CONFIG_NUMA | 888 | #ifdef CONFIG_NUMA |
| 889 | static inline const int cpu_numa_flags(void) | 889 | static inline int cpu_numa_flags(void) |
| 890 | { | 890 | { |
| 891 | return SD_NUMA; | 891 | return SD_NUMA; |
| 892 | } | 892 | } |
| @@ -999,7 +999,7 @@ void free_sched_domains(cpumask_var_t doms[], unsigned int ndoms); | |||
| 999 | bool cpus_share_cache(int this_cpu, int that_cpu); | 999 | bool cpus_share_cache(int this_cpu, int that_cpu); |
| 1000 | 1000 | ||
| 1001 | typedef const struct cpumask *(*sched_domain_mask_f)(int cpu); | 1001 | typedef const struct cpumask *(*sched_domain_mask_f)(int cpu); |
| 1002 | typedef const int (*sched_domain_flags_f)(void); | 1002 | typedef int (*sched_domain_flags_f)(void); |
| 1003 | 1003 | ||
| 1004 | #define SDTL_OVERLAP 0x01 | 1004 | #define SDTL_OVERLAP 0x01 |
| 1005 | 1005 | ||
diff --git a/include/net/ip.h b/include/net/ip.h index 0e795df05ec9..7596eb22e1ce 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
| @@ -309,16 +309,7 @@ static inline unsigned int ip_skb_dst_mtu(const struct sk_buff *skb) | |||
| 309 | } | 309 | } |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | #define IP_IDENTS_SZ 2048u | 312 | u32 ip_idents_reserve(u32 hash, int segs); |
| 313 | extern atomic_t *ip_idents; | ||
| 314 | |||
| 315 | static inline u32 ip_idents_reserve(u32 hash, int segs) | ||
| 316 | { | ||
| 317 | atomic_t *id_ptr = ip_idents + hash % IP_IDENTS_SZ; | ||
| 318 | |||
| 319 | return atomic_add_return(segs, id_ptr) - segs; | ||
| 320 | } | ||
| 321 | |||
| 322 | void __ip_select_ident(struct iphdr *iph, int segs); | 313 | void __ip_select_ident(struct iphdr *iph, int segs); |
| 323 | 314 | ||
| 324 | static inline void ip_select_ident_segs(struct sk_buff *skb, struct sock *sk, int segs) | 315 | static inline void ip_select_ident_segs(struct sk_buff *skb, struct sock *sk, int segs) |
diff --git a/include/net/neighbour.h b/include/net/neighbour.h index 7277caf3743d..47f425464f84 100644 --- a/include/net/neighbour.h +++ b/include/net/neighbour.h | |||
| @@ -203,7 +203,6 @@ struct neigh_table { | |||
| 203 | void (*proxy_redo)(struct sk_buff *skb); | 203 | void (*proxy_redo)(struct sk_buff *skb); |
| 204 | char *id; | 204 | char *id; |
| 205 | struct neigh_parms parms; | 205 | struct neigh_parms parms; |
| 206 | /* HACK. gc_* should follow parms without a gap! */ | ||
| 207 | int gc_interval; | 206 | int gc_interval; |
| 208 | int gc_thresh1; | 207 | int gc_thresh1; |
| 209 | int gc_thresh2; | 208 | int gc_thresh2; |
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h index 713b0b88bd5a..c4d86198d3d6 100644 --- a/include/net/netfilter/nf_tables.h +++ b/include/net/netfilter/nf_tables.h | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include <linux/netfilter/nfnetlink.h> | 6 | #include <linux/netfilter/nfnetlink.h> |
| 7 | #include <linux/netfilter/x_tables.h> | 7 | #include <linux/netfilter/x_tables.h> |
| 8 | #include <linux/netfilter/nf_tables.h> | 8 | #include <linux/netfilter/nf_tables.h> |
| 9 | #include <linux/u64_stats_sync.h> | ||
| 9 | #include <net/netlink.h> | 10 | #include <net/netlink.h> |
| 10 | 11 | ||
| 11 | #define NFT_JUMP_STACK_SIZE 16 | 12 | #define NFT_JUMP_STACK_SIZE 16 |
| @@ -528,8 +529,9 @@ enum nft_chain_type { | |||
| 528 | }; | 529 | }; |
| 529 | 530 | ||
| 530 | struct nft_stats { | 531 | struct nft_stats { |
| 531 | u64 bytes; | 532 | u64 bytes; |
| 532 | u64 pkts; | 533 | u64 pkts; |
| 534 | struct u64_stats_sync syncp; | ||
| 533 | }; | 535 | }; |
| 534 | 536 | ||
| 535 | #define NFT_HOOK_OPS_MAX 2 | 537 | #define NFT_HOOK_OPS_MAX 2 |
diff --git a/include/net/netns/ieee802154_6lowpan.h b/include/net/netns/ieee802154_6lowpan.h index 079030c853d8..e2070960bac0 100644 --- a/include/net/netns/ieee802154_6lowpan.h +++ b/include/net/netns/ieee802154_6lowpan.h | |||
| @@ -16,7 +16,7 @@ struct netns_sysctl_lowpan { | |||
| 16 | struct netns_ieee802154_lowpan { | 16 | struct netns_ieee802154_lowpan { |
| 17 | struct netns_sysctl_lowpan sysctl; | 17 | struct netns_sysctl_lowpan sysctl; |
| 18 | struct netns_frags frags; | 18 | struct netns_frags frags; |
| 19 | u16 max_dsize; | 19 | int max_dsize; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | #endif | 22 | #endif |
diff --git a/include/net/netns/nftables.h b/include/net/netns/nftables.h index 26a394cb91a8..eee608b12cc9 100644 --- a/include/net/netns/nftables.h +++ b/include/net/netns/nftables.h | |||
| @@ -13,8 +13,8 @@ struct netns_nftables { | |||
| 13 | struct nft_af_info *inet; | 13 | struct nft_af_info *inet; |
| 14 | struct nft_af_info *arp; | 14 | struct nft_af_info *arp; |
| 15 | struct nft_af_info *bridge; | 15 | struct nft_af_info *bridge; |
| 16 | unsigned int base_seq; | ||
| 16 | u8 gencursor; | 17 | u8 gencursor; |
| 17 | u8 genctr; | ||
| 18 | }; | 18 | }; |
| 19 | 19 | ||
| 20 | #endif | 20 | #endif |
diff --git a/include/net/sock.h b/include/net/sock.h index 173cae485de1..156350745700 100644 --- a/include/net/sock.h +++ b/include/net/sock.h | |||
| @@ -1768,9 +1768,11 @@ __sk_dst_set(struct sock *sk, struct dst_entry *dst) | |||
| 1768 | static inline void | 1768 | static inline void |
| 1769 | sk_dst_set(struct sock *sk, struct dst_entry *dst) | 1769 | sk_dst_set(struct sock *sk, struct dst_entry *dst) |
| 1770 | { | 1770 | { |
| 1771 | spin_lock(&sk->sk_dst_lock); | 1771 | struct dst_entry *old_dst; |
| 1772 | __sk_dst_set(sk, dst); | 1772 | |
| 1773 | spin_unlock(&sk->sk_dst_lock); | 1773 | sk_tx_queue_clear(sk); |
| 1774 | old_dst = xchg((__force struct dst_entry **)&sk->sk_dst_cache, dst); | ||
| 1775 | dst_release(old_dst); | ||
| 1774 | } | 1776 | } |
| 1775 | 1777 | ||
| 1776 | static inline void | 1778 | static inline void |
| @@ -1782,9 +1784,7 @@ __sk_dst_reset(struct sock *sk) | |||
| 1782 | static inline void | 1784 | static inline void |
| 1783 | sk_dst_reset(struct sock *sk) | 1785 | sk_dst_reset(struct sock *sk) |
| 1784 | { | 1786 | { |
| 1785 | spin_lock(&sk->sk_dst_lock); | 1787 | sk_dst_set(sk, NULL); |
| 1786 | __sk_dst_reset(sk); | ||
| 1787 | spin_unlock(&sk->sk_dst_lock); | ||
| 1788 | } | 1788 | } |
| 1789 | 1789 | ||
| 1790 | struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie); | 1790 | struct dst_entry *__sk_dst_check(struct sock *sk, u32 cookie); |
diff --git a/include/sound/control.h b/include/sound/control.h index 5358892b1b39..042613938a1d 100644 --- a/include/sound/control.h +++ b/include/sound/control.h | |||
| @@ -31,10 +31,15 @@ typedef int (snd_kcontrol_info_t) (struct snd_kcontrol * kcontrol, struct snd_ct | |||
| 31 | typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); | 31 | typedef int (snd_kcontrol_get_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); |
| 32 | typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); | 32 | typedef int (snd_kcontrol_put_t) (struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol); |
| 33 | typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol, | 33 | typedef int (snd_kcontrol_tlv_rw_t)(struct snd_kcontrol *kcontrol, |
| 34 | int op_flag, /* 0=read,1=write,-1=command */ | 34 | int op_flag, /* SNDRV_CTL_TLV_OP_XXX */ |
| 35 | unsigned int size, | 35 | unsigned int size, |
| 36 | unsigned int __user *tlv); | 36 | unsigned int __user *tlv); |
| 37 | 37 | ||
| 38 | enum { | ||
| 39 | SNDRV_CTL_TLV_OP_READ = 0, | ||
| 40 | SNDRV_CTL_TLV_OP_WRITE = 1, | ||
| 41 | SNDRV_CTL_TLV_OP_CMD = -1, | ||
| 42 | }; | ||
| 38 | 43 | ||
| 39 | struct snd_kcontrol_new { | 44 | struct snd_kcontrol_new { |
| 40 | snd_ctl_elem_iface_t iface; /* interface identifier */ | 45 | snd_ctl_elem_iface_t iface; /* interface identifier */ |
diff --git a/include/sound/rcar_snd.h b/include/sound/rcar_snd.h index f4a706f82cb7..d76412b84b48 100644 --- a/include/sound/rcar_snd.h +++ b/include/sound/rcar_snd.h | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | * B : SSI direction | 34 | * B : SSI direction |
| 35 | */ | 35 | */ |
| 36 | #define RSND_SSI_CLK_PIN_SHARE (1 << 31) | 36 | #define RSND_SSI_CLK_PIN_SHARE (1 << 31) |
| 37 | #define RSND_SSI_NO_BUSIF (1 << 30) /* SSI+DMA without BUSIF */ | ||
| 37 | 38 | ||
| 38 | #define RSND_SSI(_dma_id, _pio_irq, _flags) \ | 39 | #define RSND_SSI(_dma_id, _pio_irq, _flags) \ |
| 39 | { .dma_id = _dma_id, .pio_irq = _pio_irq, .flags = _flags } | 40 | { .dma_id = _dma_id, .pio_irq = _pio_irq, .flags = _flags } |
diff --git a/include/sound/rt286.h b/include/sound/rt286.h new file mode 100644 index 000000000000..eb773d1485f2 --- /dev/null +++ b/include/sound/rt286.h | |||
| @@ -0,0 +1,19 @@ | |||
| 1 | /* | ||
| 2 | * linux/sound/rt286.h -- Platform data for RT286 | ||
| 3 | * | ||
| 4 | * Copyright 2013 Realtek Microelectronics | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #ifndef __LINUX_SND_RT286_H | ||
| 12 | #define __LINUX_SND_RT286_H | ||
| 13 | |||
| 14 | struct rt286_platform_data { | ||
| 15 | bool cbj_en; /*combo jack enable*/ | ||
| 16 | bool gpio2_en; /*GPIO2 enable*/ | ||
| 17 | }; | ||
| 18 | |||
| 19 | #endif | ||
diff --git a/include/sound/rt5670.h b/include/sound/rt5670.h new file mode 100644 index 000000000000..bd311197a3b5 --- /dev/null +++ b/include/sound/rt5670.h | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | /* | ||
| 2 | * linux/sound/rt5670.h -- Platform data for RT5670 | ||
| 3 | * | ||
| 4 | * Copyright 2014 Realtek Microelectronics | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License version 2 as | ||
| 8 | * published by the Free Software Foundation. | ||
| 9 | */ | ||
| 10 | |||
| 11 | #ifndef __LINUX_SND_RT5670_H | ||
| 12 | #define __LINUX_SND_RT5670_H | ||
| 13 | |||
| 14 | struct rt5670_platform_data { | ||
| 15 | int jd_mode; | ||
| 16 | bool in2_diff; | ||
| 17 | |||
| 18 | bool dmic_en; | ||
| 19 | unsigned int dmic1_data_pin; | ||
| 20 | /* 0 = GPIO6; 1 = IN2P; 3 = GPIO7*/ | ||
| 21 | unsigned int dmic2_data_pin; | ||
| 22 | /* 0 = GPIO8; 1 = IN3N; */ | ||
| 23 | unsigned int dmic3_data_pin; | ||
| 24 | /* 0 = GPIO9; 1 = GPIO10; 2 = GPIO5*/ | ||
| 25 | }; | ||
| 26 | |||
| 27 | #endif | ||
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index 688f2ba8009f..e8b3080d196a 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h | |||
| @@ -257,7 +257,6 @@ struct snd_soc_dai { | |||
| 257 | 257 | ||
| 258 | struct snd_soc_dapm_widget *playback_widget; | 258 | struct snd_soc_dapm_widget *playback_widget; |
| 259 | struct snd_soc_dapm_widget *capture_widget; | 259 | struct snd_soc_dapm_widget *capture_widget; |
| 260 | struct snd_soc_dapm_context dapm; | ||
| 261 | 260 | ||
| 262 | /* DAI DMA data */ | 261 | /* DAI DMA data */ |
| 263 | void *playback_dma_data; | 262 | void *playback_dma_data; |
| @@ -273,6 +272,10 @@ struct snd_soc_dai { | |||
| 273 | struct snd_soc_codec *codec; | 272 | struct snd_soc_codec *codec; |
| 274 | struct snd_soc_component *component; | 273 | struct snd_soc_component *component; |
| 275 | 274 | ||
| 275 | /* CODEC TDM slot masks and params (for fixup) */ | ||
| 276 | unsigned int tx_mask; | ||
| 277 | unsigned int rx_mask; | ||
| 278 | |||
| 276 | struct snd_soc_card *card; | 279 | struct snd_soc_card *card; |
| 277 | 280 | ||
| 278 | struct list_head list; | 281 | struct list_head list; |
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 6b59471cdf44..aac04ff84eea 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
| @@ -431,7 +431,7 @@ int snd_soc_dapm_force_enable_pin_unlocked(struct snd_soc_dapm_context *dapm, | |||
| 431 | const char *pin); | 431 | const char *pin); |
| 432 | int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, | 432 | int snd_soc_dapm_ignore_suspend(struct snd_soc_dapm_context *dapm, |
| 433 | const char *pin); | 433 | const char *pin); |
| 434 | void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec); | 434 | void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card); |
| 435 | 435 | ||
| 436 | /* Mostly internal - should not normally be used */ | 436 | /* Mostly internal - should not normally be used */ |
| 437 | void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm); | 437 | void dapm_mark_io_dirty(struct snd_soc_dapm_context *dapm); |
| @@ -441,6 +441,8 @@ int snd_soc_dapm_dai_get_connected_widgets(struct snd_soc_dai *dai, int stream, | |||
| 441 | struct snd_soc_dapm_widget_list **list); | 441 | struct snd_soc_dapm_widget_list **list); |
| 442 | 442 | ||
| 443 | struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol); | 443 | struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol); |
| 444 | struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm( | ||
| 445 | struct snd_kcontrol *kcontrol); | ||
| 444 | 446 | ||
| 445 | /* dapm widget types */ | 447 | /* dapm widget types */ |
| 446 | enum snd_soc_dapm_type { | 448 | enum snd_soc_dapm_type { |
| @@ -524,7 +526,6 @@ struct snd_soc_dapm_widget { | |||
| 524 | const char *name; /* widget name */ | 526 | const char *name; /* widget name */ |
| 525 | const char *sname; /* stream name */ | 527 | const char *sname; /* stream name */ |
| 526 | struct snd_soc_codec *codec; | 528 | struct snd_soc_codec *codec; |
| 527 | struct snd_soc_platform *platform; | ||
| 528 | struct list_head list; | 529 | struct list_head list; |
| 529 | struct snd_soc_dapm_context *dapm; | 530 | struct snd_soc_dapm_context *dapm; |
| 530 | 531 | ||
| @@ -593,7 +594,6 @@ struct snd_soc_dapm_context { | |||
| 593 | struct device *dev; /* from parent - for debug */ | 594 | struct device *dev; /* from parent - for debug */ |
| 594 | struct snd_soc_component *component; /* parent component */ | 595 | struct snd_soc_component *component; /* parent component */ |
| 595 | struct snd_soc_codec *codec; /* parent codec */ | 596 | struct snd_soc_codec *codec; /* parent codec */ |
| 596 | struct snd_soc_platform *platform; /* parent platform */ | ||
| 597 | struct snd_soc_card *card; /* parent card */ | 597 | struct snd_soc_card *card; /* parent card */ |
| 598 | 598 | ||
| 599 | /* used during DAPM updates */ | 599 | /* used during DAPM updates */ |
| @@ -601,6 +601,8 @@ struct snd_soc_dapm_context { | |||
| 601 | struct list_head list; | 601 | struct list_head list; |
| 602 | 602 | ||
| 603 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); | 603 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); |
| 604 | int (*set_bias_level)(struct snd_soc_dapm_context *dapm, | ||
| 605 | enum snd_soc_bias_level level); | ||
| 604 | 606 | ||
| 605 | #ifdef CONFIG_DEBUG_FS | 607 | #ifdef CONFIG_DEBUG_FS |
| 606 | struct dentry *debugfs_dapm; | 608 | struct dentry *debugfs_dapm; |
diff --git a/include/sound/soc.h b/include/sound/soc.h index ed9e2d7e5fdc..be6ecae247b0 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -248,6 +248,8 @@ | |||
| 248 | .info = snd_soc_info_enum_double, \ | 248 | .info = snd_soc_info_enum_double, \ |
| 249 | .get = xhandler_get, .put = xhandler_put, \ | 249 | .get = xhandler_get, .put = xhandler_put, \ |
| 250 | .private_value = (unsigned long)&xenum } | 250 | .private_value = (unsigned long)&xenum } |
| 251 | #define SOC_VALUE_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) \ | ||
| 252 | SOC_ENUM_EXT(xname, xenum, xhandler_get, xhandler_put) | ||
| 251 | 253 | ||
| 252 | #define SND_SOC_BYTES(xname, xbase, xregs) \ | 254 | #define SND_SOC_BYTES(xname, xbase, xregs) \ |
| 253 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 255 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| @@ -270,7 +272,14 @@ | |||
| 270 | .get = xhandler_get, .put = xhandler_put, \ | 272 | .get = xhandler_get, .put = xhandler_put, \ |
| 271 | .private_value = (unsigned long)&(struct soc_bytes_ext) \ | 273 | .private_value = (unsigned long)&(struct soc_bytes_ext) \ |
| 272 | {.max = xcount} } | 274 | {.max = xcount} } |
| 273 | 275 | #define SND_SOC_BYTES_TLV(xname, xcount, xhandler_get, xhandler_put) \ | |
| 276 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | ||
| 277 | .access = SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE | \ | ||
| 278 | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, \ | ||
| 279 | .tlv.c = (snd_soc_bytes_tlv_callback), \ | ||
| 280 | .info = snd_soc_info_bytes_ext, \ | ||
| 281 | .private_value = (unsigned long)&(struct soc_bytes_ext) \ | ||
| 282 | {.max = xcount, .get = xhandler_get, .put = xhandler_put, } } | ||
| 274 | #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \ | 283 | #define SOC_SINGLE_XR_SX(xname, xregbase, xregcount, xnbits, \ |
| 275 | xmin, xmax, xinvert) \ | 284 | xmin, xmax, xinvert) \ |
| 276 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ | 285 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = (xname), \ |
| @@ -436,6 +445,10 @@ int snd_soc_set_runtime_hwparams(struct snd_pcm_substream *substream, | |||
| 436 | int snd_soc_platform_trigger(struct snd_pcm_substream *substream, | 445 | int snd_soc_platform_trigger(struct snd_pcm_substream *substream, |
| 437 | int cmd, struct snd_soc_platform *platform); | 446 | int cmd, struct snd_soc_platform *platform); |
| 438 | 447 | ||
| 448 | int soc_dai_hw_params(struct snd_pcm_substream *substream, | ||
| 449 | struct snd_pcm_hw_params *params, | ||
| 450 | struct snd_soc_dai *dai); | ||
| 451 | |||
| 439 | /* Jack reporting */ | 452 | /* Jack reporting */ |
| 440 | int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, | 453 | int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, |
| 441 | struct snd_soc_jack *jack); | 454 | struct snd_soc_jack *jack); |
| @@ -503,10 +516,12 @@ struct snd_kcontrol *snd_soc_cnew(const struct snd_kcontrol_new *_template, | |||
| 503 | const char *prefix); | 516 | const char *prefix); |
| 504 | struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, | 517 | struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, |
| 505 | const char *name); | 518 | const char *name); |
| 519 | int snd_soc_add_component_controls(struct snd_soc_component *component, | ||
| 520 | const struct snd_kcontrol_new *controls, unsigned int num_controls); | ||
| 506 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, | 521 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, |
| 507 | const struct snd_kcontrol_new *controls, int num_controls); | 522 | const struct snd_kcontrol_new *controls, unsigned int num_controls); |
| 508 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, | 523 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, |
| 509 | const struct snd_kcontrol_new *controls, int num_controls); | 524 | const struct snd_kcontrol_new *controls, unsigned int num_controls); |
| 510 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card, | 525 | int snd_soc_add_card_controls(struct snd_soc_card *soc_card, |
| 511 | const struct snd_kcontrol_new *controls, int num_controls); | 526 | const struct snd_kcontrol_new *controls, int num_controls); |
| 512 | int snd_soc_add_dai_controls(struct snd_soc_dai *dai, | 527 | int snd_soc_add_dai_controls(struct snd_soc_dai *dai, |
| @@ -552,6 +567,8 @@ int snd_soc_bytes_put(struct snd_kcontrol *kcontrol, | |||
| 552 | struct snd_ctl_elem_value *ucontrol); | 567 | struct snd_ctl_elem_value *ucontrol); |
| 553 | int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol, | 568 | int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol, |
| 554 | struct snd_ctl_elem_info *ucontrol); | 569 | struct snd_ctl_elem_info *ucontrol); |
| 570 | int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag, | ||
| 571 | unsigned int size, unsigned int __user *tlv); | ||
| 555 | int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol, | 572 | int snd_soc_info_xr_sx(struct snd_kcontrol *kcontrol, |
| 556 | struct snd_ctl_elem_info *uinfo); | 573 | struct snd_ctl_elem_info *uinfo); |
| 557 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, | 574 | int snd_soc_get_xr_sx(struct snd_kcontrol *kcontrol, |
| @@ -677,12 +694,17 @@ struct snd_soc_component_driver { | |||
| 677 | int (*of_xlate_dai_name)(struct snd_soc_component *component, | 694 | int (*of_xlate_dai_name)(struct snd_soc_component *component, |
| 678 | struct of_phandle_args *args, | 695 | struct of_phandle_args *args, |
| 679 | const char **dai_name); | 696 | const char **dai_name); |
| 697 | void (*seq_notifier)(struct snd_soc_component *, enum snd_soc_dapm_type, | ||
| 698 | int subseq); | ||
| 699 | int (*stream_event)(struct snd_soc_component *, int event); | ||
| 680 | }; | 700 | }; |
| 681 | 701 | ||
| 682 | struct snd_soc_component { | 702 | struct snd_soc_component { |
| 683 | const char *name; | 703 | const char *name; |
| 684 | int id; | 704 | int id; |
| 705 | const char *name_prefix; | ||
| 685 | struct device *dev; | 706 | struct device *dev; |
| 707 | struct snd_soc_card *card; | ||
| 686 | 708 | ||
| 687 | unsigned int active; | 709 | unsigned int active; |
| 688 | 710 | ||
| @@ -705,18 +727,18 @@ struct snd_soc_component { | |||
| 705 | int val_bytes; | 727 | int val_bytes; |
| 706 | 728 | ||
| 707 | struct mutex io_mutex; | 729 | struct mutex io_mutex; |
| 730 | |||
| 731 | /* Don't use these, use snd_soc_component_get_dapm() */ | ||
| 732 | struct snd_soc_dapm_context dapm; | ||
| 733 | struct snd_soc_dapm_context *dapm_ptr; | ||
| 708 | }; | 734 | }; |
| 709 | 735 | ||
| 710 | /* SoC Audio Codec device */ | 736 | /* SoC Audio Codec device */ |
| 711 | struct snd_soc_codec { | 737 | struct snd_soc_codec { |
| 712 | const char *name; | ||
| 713 | const char *name_prefix; | ||
| 714 | int id; | ||
| 715 | struct device *dev; | 738 | struct device *dev; |
| 716 | const struct snd_soc_codec_driver *driver; | 739 | const struct snd_soc_codec_driver *driver; |
| 717 | 740 | ||
| 718 | struct mutex mutex; | 741 | struct mutex mutex; |
| 719 | struct snd_soc_card *card; | ||
| 720 | struct list_head list; | 742 | struct list_head list; |
| 721 | struct list_head card_list; | 743 | struct list_head card_list; |
| 722 | 744 | ||
| @@ -790,9 +812,6 @@ struct snd_soc_codec_driver { | |||
| 790 | void (*seq_notifier)(struct snd_soc_dapm_context *, | 812 | void (*seq_notifier)(struct snd_soc_dapm_context *, |
| 791 | enum snd_soc_dapm_type, int); | 813 | enum snd_soc_dapm_type, int); |
| 792 | 814 | ||
| 793 | /* codec stream completion event */ | ||
| 794 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); | ||
| 795 | |||
| 796 | bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ | 815 | bool ignore_pmdown_time; /* Doesn't benefit from pmdown delay */ |
| 797 | 816 | ||
| 798 | /* probe ordering - for components with runtime dependencies */ | 817 | /* probe ordering - for components with runtime dependencies */ |
| @@ -834,9 +853,6 @@ struct snd_soc_platform_driver { | |||
| 834 | /* platform stream compress ops */ | 853 | /* platform stream compress ops */ |
| 835 | const struct snd_compr_ops *compr_ops; | 854 | const struct snd_compr_ops *compr_ops; |
| 836 | 855 | ||
| 837 | /* platform stream completion event */ | ||
| 838 | int (*stream_event)(struct snd_soc_dapm_context *dapm, int event); | ||
| 839 | |||
| 840 | /* probe ordering - for components with runtime dependencies */ | 856 | /* probe ordering - for components with runtime dependencies */ |
| 841 | int probe_order; | 857 | int probe_order; |
| 842 | int remove_order; | 858 | int remove_order; |
| @@ -847,23 +863,23 @@ struct snd_soc_platform_driver { | |||
| 847 | int (*bespoke_trigger)(struct snd_pcm_substream *, int); | 863 | int (*bespoke_trigger)(struct snd_pcm_substream *, int); |
| 848 | }; | 864 | }; |
| 849 | 865 | ||
| 850 | struct snd_soc_platform { | 866 | struct snd_soc_dai_link_component { |
| 851 | const char *name; | 867 | const char *name; |
| 852 | int id; | 868 | const struct device_node *of_node; |
| 869 | const char *dai_name; | ||
| 870 | }; | ||
| 871 | |||
| 872 | struct snd_soc_platform { | ||
| 853 | struct device *dev; | 873 | struct device *dev; |
| 854 | const struct snd_soc_platform_driver *driver; | 874 | const struct snd_soc_platform_driver *driver; |
| 855 | 875 | ||
| 856 | unsigned int suspended:1; /* platform is suspended */ | 876 | unsigned int suspended:1; /* platform is suspended */ |
| 857 | unsigned int probed:1; | 877 | unsigned int probed:1; |
| 858 | 878 | ||
| 859 | struct snd_soc_card *card; | ||
| 860 | struct list_head list; | 879 | struct list_head list; |
| 861 | struct list_head card_list; | ||
| 862 | 880 | ||
| 863 | struct snd_soc_component component; | 881 | struct snd_soc_component component; |
| 864 | 882 | ||
| 865 | struct snd_soc_dapm_context dapm; | ||
| 866 | |||
| 867 | #ifdef CONFIG_DEBUG_FS | 883 | #ifdef CONFIG_DEBUG_FS |
| 868 | struct dentry *debugfs_platform_root; | 884 | struct dentry *debugfs_platform_root; |
| 869 | #endif | 885 | #endif |
| @@ -896,6 +912,10 @@ struct snd_soc_dai_link { | |||
| 896 | const struct device_node *codec_of_node; | 912 | const struct device_node *codec_of_node; |
| 897 | /* You MUST specify the DAI name within the codec */ | 913 | /* You MUST specify the DAI name within the codec */ |
| 898 | const char *codec_dai_name; | 914 | const char *codec_dai_name; |
| 915 | |||
| 916 | struct snd_soc_dai_link_component *codecs; | ||
| 917 | unsigned int num_codecs; | ||
| 918 | |||
| 899 | /* | 919 | /* |
| 900 | * You MAY specify the link's platform/PCM/DMA driver, either by | 920 | * You MAY specify the link's platform/PCM/DMA driver, either by |
| 901 | * device name, or by DT/OF node, but not both. Some forms of link | 921 | * device name, or by DT/OF node, but not both. Some forms of link |
| @@ -1047,7 +1067,6 @@ struct snd_soc_card { | |||
| 1047 | 1067 | ||
| 1048 | /* lists of probed devices belonging to this card */ | 1068 | /* lists of probed devices belonging to this card */ |
| 1049 | struct list_head codec_dev_list; | 1069 | struct list_head codec_dev_list; |
| 1050 | struct list_head platform_dev_list; | ||
| 1051 | 1070 | ||
| 1052 | struct list_head widgets; | 1071 | struct list_head widgets; |
| 1053 | struct list_head paths; | 1072 | struct list_head paths; |
| @@ -1094,6 +1113,9 @@ struct snd_soc_pcm_runtime { | |||
| 1094 | struct snd_soc_dai *codec_dai; | 1113 | struct snd_soc_dai *codec_dai; |
| 1095 | struct snd_soc_dai *cpu_dai; | 1114 | struct snd_soc_dai *cpu_dai; |
| 1096 | 1115 | ||
| 1116 | struct snd_soc_dai **codec_dais; | ||
| 1117 | unsigned int num_codecs; | ||
| 1118 | |||
| 1097 | struct delayed_work delayed_work; | 1119 | struct delayed_work delayed_work; |
| 1098 | #ifdef CONFIG_DEBUG_FS | 1120 | #ifdef CONFIG_DEBUG_FS |
| 1099 | struct dentry *debugfs_dpcm_root; | 1121 | struct dentry *debugfs_dpcm_root; |
| @@ -1119,6 +1141,9 @@ struct soc_bytes { | |||
| 1119 | 1141 | ||
| 1120 | struct soc_bytes_ext { | 1142 | struct soc_bytes_ext { |
| 1121 | int max; | 1143 | int max; |
| 1144 | /* used for TLV byte control */ | ||
| 1145 | int (*get)(unsigned int __user *bytes, unsigned int size); | ||
| 1146 | int (*put)(const unsigned int __user *bytes, unsigned int size); | ||
| 1122 | }; | 1147 | }; |
| 1123 | 1148 | ||
| 1124 | /* multi register control */ | 1149 | /* multi register control */ |
| @@ -1165,6 +1190,21 @@ static inline struct snd_soc_platform *snd_soc_component_to_platform( | |||
| 1165 | } | 1190 | } |
| 1166 | 1191 | ||
| 1167 | /** | 1192 | /** |
| 1193 | * snd_soc_dapm_to_component() - Casts a DAPM context to the component it is | ||
| 1194 | * embedded in | ||
| 1195 | * @dapm: The DAPM context to cast to the component | ||
| 1196 | * | ||
| 1197 | * This function must only be used on DAPM contexts that are known to be part of | ||
| 1198 | * a component (e.g. in a component driver). Otherwise the behavior is | ||
| 1199 | * undefined. | ||
| 1200 | */ | ||
| 1201 | static inline struct snd_soc_component *snd_soc_dapm_to_component( | ||
| 1202 | struct snd_soc_dapm_context *dapm) | ||
| 1203 | { | ||
| 1204 | return container_of(dapm, struct snd_soc_component, dapm); | ||
| 1205 | } | ||
| 1206 | |||
| 1207 | /** | ||
| 1168 | * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in | 1208 | * snd_soc_dapm_to_codec() - Casts a DAPM context to the CODEC it is embedded in |
| 1169 | * @dapm: The DAPM context to cast to the CODEC | 1209 | * @dapm: The DAPM context to cast to the CODEC |
| 1170 | * | 1210 | * |
| @@ -1188,7 +1228,18 @@ static inline struct snd_soc_codec *snd_soc_dapm_to_codec( | |||
| 1188 | static inline struct snd_soc_platform *snd_soc_dapm_to_platform( | 1228 | static inline struct snd_soc_platform *snd_soc_dapm_to_platform( |
| 1189 | struct snd_soc_dapm_context *dapm) | 1229 | struct snd_soc_dapm_context *dapm) |
| 1190 | { | 1230 | { |
| 1191 | return container_of(dapm, struct snd_soc_platform, dapm); | 1231 | return snd_soc_component_to_platform(snd_soc_dapm_to_component(dapm)); |
| 1232 | } | ||
| 1233 | |||
| 1234 | /** | ||
| 1235 | * snd_soc_component_get_dapm() - Returns the DAPM context associated with a | ||
| 1236 | * component | ||
| 1237 | * @component: The component for which to get the DAPM context | ||
| 1238 | */ | ||
| 1239 | static inline struct snd_soc_dapm_context *snd_soc_component_get_dapm( | ||
| 1240 | struct snd_soc_component *component) | ||
| 1241 | { | ||
| 1242 | return component->dapm_ptr; | ||
| 1192 | } | 1243 | } |
| 1193 | 1244 | ||
| 1194 | /* codec IO */ | 1245 | /* codec IO */ |
| @@ -1261,7 +1312,6 @@ static inline void *snd_soc_pcm_get_drvdata(struct snd_soc_pcm_runtime *rtd) | |||
| 1261 | static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) | 1312 | static inline void snd_soc_initialize_card_lists(struct snd_soc_card *card) |
| 1262 | { | 1313 | { |
| 1263 | INIT_LIST_HEAD(&card->codec_dev_list); | 1314 | INIT_LIST_HEAD(&card->codec_dev_list); |
| 1264 | INIT_LIST_HEAD(&card->platform_dev_list); | ||
| 1265 | INIT_LIST_HEAD(&card->widgets); | 1315 | INIT_LIST_HEAD(&card->widgets); |
| 1266 | INIT_LIST_HEAD(&card->paths); | 1316 | INIT_LIST_HEAD(&card->paths); |
| 1267 | INIT_LIST_HEAD(&card->dapm_list); | 1317 | INIT_LIST_HEAD(&card->dapm_list); |
diff --git a/include/sound/tas2552-plat.h b/include/sound/tas2552-plat.h new file mode 100644 index 000000000000..65e7627ba38e --- /dev/null +++ b/include/sound/tas2552-plat.h | |||
| @@ -0,0 +1,25 @@ | |||
| 1 | /* | ||
| 2 | * TAS2552 driver platform header | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Texas Instruments Inc. | ||
| 5 | * | ||
| 6 | * Author: Dan Murphy <dmurphy@ti.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU General Public License | ||
| 10 | * version 2 as published by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef TAS2552_PLAT_H | ||
| 19 | #define TAS2552_PLAT_H | ||
| 20 | |||
| 21 | struct tas2552_platform_data { | ||
| 22 | int enable_gpio; | ||
| 23 | }; | ||
| 24 | |||
| 25 | #endif | ||
diff --git a/include/sound/wm8962.h b/include/sound/wm8962.h index 79e6d427b858..0af7c1674cbf 100644 --- a/include/sound/wm8962.h +++ b/include/sound/wm8962.h | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #define WM8962_GPIO_FN_MICSCD 22 | 37 | #define WM8962_GPIO_FN_MICSCD 22 |
| 38 | 38 | ||
| 39 | struct wm8962_pdata { | 39 | struct wm8962_pdata { |
| 40 | struct clk *mclk; | ||
| 40 | int gpio_base; | 41 | int gpio_base; |
| 41 | u32 gpio_init[WM8962_MAX_GPIO]; | 42 | u32 gpio_init[WM8962_MAX_GPIO]; |
| 42 | 43 | ||
diff --git a/include/trace/events/asoc.h b/include/trace/events/asoc.h index c75c795a377b..0194a641e4e2 100644 --- a/include/trace/events/asoc.h +++ b/include/trace/events/asoc.h | |||
| @@ -296,17 +296,17 @@ TRACE_EVENT(snd_soc_cache_sync, | |||
| 296 | TP_ARGS(codec, type, status), | 296 | TP_ARGS(codec, type, status), |
| 297 | 297 | ||
| 298 | TP_STRUCT__entry( | 298 | TP_STRUCT__entry( |
| 299 | __string( name, codec->name ) | 299 | __string( name, codec->component.name) |
| 300 | __string( status, status ) | 300 | __string( status, status ) |
| 301 | __string( type, type ) | 301 | __string( type, type ) |
| 302 | __field( int, id ) | 302 | __field( int, id ) |
| 303 | ), | 303 | ), |
| 304 | 304 | ||
| 305 | TP_fast_assign( | 305 | TP_fast_assign( |
| 306 | __assign_str(name, codec->name); | 306 | __assign_str(name, codec->component.name); |
| 307 | __assign_str(status, status); | 307 | __assign_str(status, status); |
| 308 | __assign_str(type, type); | 308 | __assign_str(type, type); |
| 309 | __entry->id = codec->id; | 309 | __entry->id = codec->component.id; |
| 310 | ), | 310 | ), |
| 311 | 311 | ||
| 312 | TP_printk("codec=%s.%d type=%s status=%s", __get_str(name), | 312 | TP_printk("codec=%s.%d type=%s status=%s", __get_str(name), |
diff --git a/include/uapi/linux/fuse.h b/include/uapi/linux/fuse.h index 40b5ca8a1b1f..25084a052a1e 100644 --- a/include/uapi/linux/fuse.h +++ b/include/uapi/linux/fuse.h | |||
| @@ -101,6 +101,7 @@ | |||
| 101 | * - add FATTR_CTIME | 101 | * - add FATTR_CTIME |
| 102 | * - add ctime and ctimensec to fuse_setattr_in | 102 | * - add ctime and ctimensec to fuse_setattr_in |
| 103 | * - add FUSE_RENAME2 request | 103 | * - add FUSE_RENAME2 request |
| 104 | * - add FUSE_NO_OPEN_SUPPORT flag | ||
| 104 | */ | 105 | */ |
| 105 | 106 | ||
| 106 | #ifndef _LINUX_FUSE_H | 107 | #ifndef _LINUX_FUSE_H |
| @@ -229,6 +230,7 @@ struct fuse_file_lock { | |||
| 229 | * FUSE_READDIRPLUS_AUTO: adaptive readdirplus | 230 | * FUSE_READDIRPLUS_AUTO: adaptive readdirplus |
| 230 | * FUSE_ASYNC_DIO: asynchronous direct I/O submission | 231 | * FUSE_ASYNC_DIO: asynchronous direct I/O submission |
| 231 | * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes | 232 | * FUSE_WRITEBACK_CACHE: use writeback cache for buffered writes |
| 233 | * FUSE_NO_OPEN_SUPPORT: kernel supports zero-message opens | ||
| 232 | */ | 234 | */ |
| 233 | #define FUSE_ASYNC_READ (1 << 0) | 235 | #define FUSE_ASYNC_READ (1 << 0) |
| 234 | #define FUSE_POSIX_LOCKS (1 << 1) | 236 | #define FUSE_POSIX_LOCKS (1 << 1) |
| @@ -247,6 +249,7 @@ struct fuse_file_lock { | |||
| 247 | #define FUSE_READDIRPLUS_AUTO (1 << 14) | 249 | #define FUSE_READDIRPLUS_AUTO (1 << 14) |
| 248 | #define FUSE_ASYNC_DIO (1 << 15) | 250 | #define FUSE_ASYNC_DIO (1 << 15) |
| 249 | #define FUSE_WRITEBACK_CACHE (1 << 16) | 251 | #define FUSE_WRITEBACK_CACHE (1 << 16) |
| 252 | #define FUSE_NO_OPEN_SUPPORT (1 << 17) | ||
| 250 | 253 | ||
| 251 | /** | 254 | /** |
| 252 | * CUSE INIT request/reply flags | 255 | * CUSE INIT request/reply flags |
diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h index a5af2a26d94f..5c1aba154b64 100644 --- a/include/xen/grant_table.h +++ b/include/xen/grant_table.h | |||
| @@ -170,6 +170,7 @@ gnttab_set_unmap_op(struct gnttab_unmap_grant_ref *unmap, phys_addr_t addr, | |||
| 170 | unmap->dev_bus_addr = 0; | 170 | unmap->dev_bus_addr = 0; |
| 171 | } | 171 | } |
| 172 | 172 | ||
| 173 | int arch_gnttab_init(unsigned long nr_shared, unsigned long nr_status); | ||
| 173 | int arch_gnttab_map_shared(xen_pfn_t *frames, unsigned long nr_gframes, | 174 | int arch_gnttab_map_shared(xen_pfn_t *frames, unsigned long nr_gframes, |
| 174 | unsigned long max_nr_gframes, | 175 | unsigned long max_nr_gframes, |
| 175 | void **__shared); | 176 | void **__shared); |
diff --git a/kernel/Kconfig.locks b/kernel/Kconfig.locks index 35536d9c0964..76768ee812b2 100644 --- a/kernel/Kconfig.locks +++ b/kernel/Kconfig.locks | |||
| @@ -220,9 +220,16 @@ config INLINE_WRITE_UNLOCK_IRQRESTORE | |||
| 220 | 220 | ||
| 221 | endif | 221 | endif |
| 222 | 222 | ||
| 223 | config ARCH_SUPPORTS_ATOMIC_RMW | ||
| 224 | bool | ||
| 225 | |||
| 223 | config MUTEX_SPIN_ON_OWNER | 226 | config MUTEX_SPIN_ON_OWNER |
| 224 | def_bool y | 227 | def_bool y |
| 225 | depends on SMP && !DEBUG_MUTEXES | 228 | depends on SMP && !DEBUG_MUTEXES && ARCH_SUPPORTS_ATOMIC_RMW |
| 229 | |||
| 230 | config RWSEM_SPIN_ON_OWNER | ||
| 231 | def_bool y | ||
| 232 | depends on SMP && RWSEM_XCHGADD_ALGORITHM && ARCH_SUPPORTS_ATOMIC_RMW | ||
| 226 | 233 | ||
| 227 | config ARCH_USE_QUEUE_RWLOCK | 234 | config ARCH_USE_QUEUE_RWLOCK |
| 228 | bool | 235 | bool |
diff --git a/kernel/cgroup.c b/kernel/cgroup.c index 7868fc3c0bc5..70776aec2562 100644 --- a/kernel/cgroup.c +++ b/kernel/cgroup.c | |||
| @@ -1648,10 +1648,13 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
| 1648 | int flags, const char *unused_dev_name, | 1648 | int flags, const char *unused_dev_name, |
| 1649 | void *data) | 1649 | void *data) |
| 1650 | { | 1650 | { |
| 1651 | struct super_block *pinned_sb = NULL; | ||
| 1652 | struct cgroup_subsys *ss; | ||
| 1651 | struct cgroup_root *root; | 1653 | struct cgroup_root *root; |
| 1652 | struct cgroup_sb_opts opts; | 1654 | struct cgroup_sb_opts opts; |
| 1653 | struct dentry *dentry; | 1655 | struct dentry *dentry; |
| 1654 | int ret; | 1656 | int ret; |
| 1657 | int i; | ||
| 1655 | bool new_sb; | 1658 | bool new_sb; |
| 1656 | 1659 | ||
| 1657 | /* | 1660 | /* |
| @@ -1677,6 +1680,27 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
| 1677 | goto out_unlock; | 1680 | goto out_unlock; |
| 1678 | } | 1681 | } |
| 1679 | 1682 | ||
| 1683 | /* | ||
| 1684 | * Destruction of cgroup root is asynchronous, so subsystems may | ||
| 1685 | * still be dying after the previous unmount. Let's drain the | ||
| 1686 | * dying subsystems. We just need to ensure that the ones | ||
| 1687 | * unmounted previously finish dying and don't care about new ones | ||
| 1688 | * starting. Testing ref liveliness is good enough. | ||
| 1689 | */ | ||
| 1690 | for_each_subsys(ss, i) { | ||
| 1691 | if (!(opts.subsys_mask & (1 << i)) || | ||
| 1692 | ss->root == &cgrp_dfl_root) | ||
| 1693 | continue; | ||
| 1694 | |||
| 1695 | if (!percpu_ref_tryget_live(&ss->root->cgrp.self.refcnt)) { | ||
| 1696 | mutex_unlock(&cgroup_mutex); | ||
| 1697 | msleep(10); | ||
| 1698 | ret = restart_syscall(); | ||
| 1699 | goto out_free; | ||
| 1700 | } | ||
| 1701 | cgroup_put(&ss->root->cgrp); | ||
| 1702 | } | ||
| 1703 | |||
| 1680 | for_each_root(root) { | 1704 | for_each_root(root) { |
| 1681 | bool name_match = false; | 1705 | bool name_match = false; |
| 1682 | 1706 | ||
| @@ -1717,15 +1741,23 @@ static struct dentry *cgroup_mount(struct file_system_type *fs_type, | |||
| 1717 | } | 1741 | } |
| 1718 | 1742 | ||
| 1719 | /* | 1743 | /* |
| 1720 | * A root's lifetime is governed by its root cgroup. | 1744 | * We want to reuse @root whose lifetime is governed by its |
| 1721 | * tryget_live failure indicate that the root is being | 1745 | * ->cgrp. Let's check whether @root is alive and keep it |
| 1722 | * destroyed. Wait for destruction to complete so that the | 1746 | * that way. As cgroup_kill_sb() can happen anytime, we |
| 1723 | * subsystems are free. We can use wait_queue for the wait | 1747 | * want to block it by pinning the sb so that @root doesn't |
| 1724 | * but this path is super cold. Let's just sleep for a bit | 1748 | * get killed before mount is complete. |
| 1725 | * and retry. | 1749 | * |
| 1750 | * With the sb pinned, tryget_live can reliably indicate | ||
| 1751 | * whether @root can be reused. If it's being killed, | ||
| 1752 | * drain it. We can use wait_queue for the wait but this | ||
| 1753 | * path is super cold. Let's just sleep a bit and retry. | ||
| 1726 | */ | 1754 | */ |
| 1727 | if (!percpu_ref_tryget_live(&root->cgrp.self.refcnt)) { | 1755 | pinned_sb = kernfs_pin_sb(root->kf_root, NULL); |
| 1756 | if (IS_ERR(pinned_sb) || | ||
| 1757 | !percpu_ref_tryget_live(&root->cgrp.self.refcnt)) { | ||
| 1728 | mutex_unlock(&cgroup_mutex); | 1758 | mutex_unlock(&cgroup_mutex); |
| 1759 | if (!IS_ERR_OR_NULL(pinned_sb)) | ||
| 1760 | deactivate_super(pinned_sb); | ||
| 1729 | msleep(10); | 1761 | msleep(10); |
| 1730 | ret = restart_syscall(); | 1762 | ret = restart_syscall(); |
| 1731 | goto out_free; | 1763 | goto out_free; |
| @@ -1770,6 +1802,16 @@ out_free: | |||
| 1770 | CGROUP_SUPER_MAGIC, &new_sb); | 1802 | CGROUP_SUPER_MAGIC, &new_sb); |
| 1771 | if (IS_ERR(dentry) || !new_sb) | 1803 | if (IS_ERR(dentry) || !new_sb) |
| 1772 | cgroup_put(&root->cgrp); | 1804 | cgroup_put(&root->cgrp); |
| 1805 | |||
| 1806 | /* | ||
| 1807 | * If @pinned_sb, we're reusing an existing root and holding an | ||
| 1808 | * extra ref on its sb. Mount is complete. Put the extra ref. | ||
| 1809 | */ | ||
| 1810 | if (pinned_sb) { | ||
| 1811 | WARN_ON(new_sb); | ||
| 1812 | deactivate_super(pinned_sb); | ||
| 1813 | } | ||
| 1814 | |||
| 1773 | return dentry; | 1815 | return dentry; |
| 1774 | } | 1816 | } |
| 1775 | 1817 | ||
| @@ -3328,7 +3370,7 @@ bool css_has_online_children(struct cgroup_subsys_state *css) | |||
| 3328 | 3370 | ||
| 3329 | rcu_read_lock(); | 3371 | rcu_read_lock(); |
| 3330 | css_for_each_child(child, css) { | 3372 | css_for_each_child(child, css) { |
| 3331 | if (css->flags & CSS_ONLINE) { | 3373 | if (child->flags & CSS_ONLINE) { |
| 3332 | ret = true; | 3374 | ret = true; |
| 3333 | break; | 3375 | break; |
| 3334 | } | 3376 | } |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index f6b33c696224..116a4164720a 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
| @@ -1181,7 +1181,13 @@ done: | |||
| 1181 | 1181 | ||
| 1182 | int current_cpuset_is_being_rebound(void) | 1182 | int current_cpuset_is_being_rebound(void) |
| 1183 | { | 1183 | { |
| 1184 | return task_cs(current) == cpuset_being_rebound; | 1184 | int ret; |
| 1185 | |||
| 1186 | rcu_read_lock(); | ||
| 1187 | ret = task_cs(current) == cpuset_being_rebound; | ||
| 1188 | rcu_read_unlock(); | ||
| 1189 | |||
| 1190 | return ret; | ||
| 1185 | } | 1191 | } |
| 1186 | 1192 | ||
| 1187 | static int update_relax_domain_level(struct cpuset *cs, s64 val) | 1193 | static int update_relax_domain_level(struct cpuset *cs, s64 val) |
| @@ -1617,7 +1623,17 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of, | |||
| 1617 | * resources, wait for the previously scheduled operations before | 1623 | * resources, wait for the previously scheduled operations before |
| 1618 | * proceeding, so that we don't end up keep removing tasks added | 1624 | * proceeding, so that we don't end up keep removing tasks added |
| 1619 | * after execution capability is restored. | 1625 | * after execution capability is restored. |
| 1626 | * | ||
| 1627 | * cpuset_hotplug_work calls back into cgroup core via | ||
| 1628 | * cgroup_transfer_tasks() and waiting for it from a cgroupfs | ||
| 1629 | * operation like this one can lead to a deadlock through kernfs | ||
| 1630 | * active_ref protection. Let's break the protection. Losing the | ||
| 1631 | * protection is okay as we check whether @cs is online after | ||
| 1632 | * grabbing cpuset_mutex anyway. This only happens on the legacy | ||
| 1633 | * hierarchies. | ||
| 1620 | */ | 1634 | */ |
| 1635 | css_get(&cs->css); | ||
| 1636 | kernfs_break_active_protection(of->kn); | ||
| 1621 | flush_work(&cpuset_hotplug_work); | 1637 | flush_work(&cpuset_hotplug_work); |
| 1622 | 1638 | ||
| 1623 | mutex_lock(&cpuset_mutex); | 1639 | mutex_lock(&cpuset_mutex); |
| @@ -1645,6 +1661,8 @@ static ssize_t cpuset_write_resmask(struct kernfs_open_file *of, | |||
| 1645 | free_trial_cpuset(trialcs); | 1661 | free_trial_cpuset(trialcs); |
| 1646 | out_unlock: | 1662 | out_unlock: |
| 1647 | mutex_unlock(&cpuset_mutex); | 1663 | mutex_unlock(&cpuset_mutex); |
| 1664 | kernfs_unbreak_active_protection(of->kn); | ||
| 1665 | css_put(&cs->css); | ||
| 1648 | return retval ?: nbytes; | 1666 | return retval ?: nbytes; |
| 1649 | } | 1667 | } |
| 1650 | 1668 | ||
diff --git a/kernel/events/core.c b/kernel/events/core.c index a33d9a2bcbd7..6b17ac1b0c2a 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c | |||
| @@ -2320,7 +2320,7 @@ static void perf_event_context_sched_out(struct task_struct *task, int ctxn, | |||
| 2320 | next_parent = rcu_dereference(next_ctx->parent_ctx); | 2320 | next_parent = rcu_dereference(next_ctx->parent_ctx); |
| 2321 | 2321 | ||
| 2322 | /* If neither context have a parent context; they cannot be clones. */ | 2322 | /* If neither context have a parent context; they cannot be clones. */ |
| 2323 | if (!parent && !next_parent) | 2323 | if (!parent || !next_parent) |
| 2324 | goto unlock; | 2324 | goto unlock; |
| 2325 | 2325 | ||
| 2326 | if (next_parent == ctx || next_ctx == parent || next_parent == parent) { | 2326 | if (next_parent == ctx || next_ctx == parent || next_parent == parent) { |
| @@ -7458,7 +7458,19 @@ __perf_event_exit_task(struct perf_event *child_event, | |||
| 7458 | struct perf_event_context *child_ctx, | 7458 | struct perf_event_context *child_ctx, |
| 7459 | struct task_struct *child) | 7459 | struct task_struct *child) |
| 7460 | { | 7460 | { |
| 7461 | perf_remove_from_context(child_event, true); | 7461 | /* |
| 7462 | * Do not destroy the 'original' grouping; because of the context | ||
| 7463 | * switch optimization the original events could've ended up in a | ||
| 7464 | * random child task. | ||
| 7465 | * | ||
| 7466 | * If we were to destroy the original group, all group related | ||
| 7467 | * operations would cease to function properly after this random | ||
| 7468 | * child dies. | ||
| 7469 | * | ||
| 7470 | * Do destroy all inherited groups, we don't care about those | ||
| 7471 | * and being thorough is better. | ||
| 7472 | */ | ||
| 7473 | perf_remove_from_context(child_event, !!child_event->parent); | ||
| 7462 | 7474 | ||
| 7463 | /* | 7475 | /* |
| 7464 | * It can happen that the parent exits first, and has events | 7476 | * It can happen that the parent exits first, and has events |
| @@ -7474,7 +7486,7 @@ __perf_event_exit_task(struct perf_event *child_event, | |||
| 7474 | static void perf_event_exit_task_context(struct task_struct *child, int ctxn) | 7486 | static void perf_event_exit_task_context(struct task_struct *child, int ctxn) |
| 7475 | { | 7487 | { |
| 7476 | struct perf_event *child_event, *next; | 7488 | struct perf_event *child_event, *next; |
| 7477 | struct perf_event_context *child_ctx; | 7489 | struct perf_event_context *child_ctx, *parent_ctx; |
| 7478 | unsigned long flags; | 7490 | unsigned long flags; |
| 7479 | 7491 | ||
| 7480 | if (likely(!child->perf_event_ctxp[ctxn])) { | 7492 | if (likely(!child->perf_event_ctxp[ctxn])) { |
| @@ -7499,6 +7511,15 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn) | |||
| 7499 | raw_spin_lock(&child_ctx->lock); | 7511 | raw_spin_lock(&child_ctx->lock); |
| 7500 | task_ctx_sched_out(child_ctx); | 7512 | task_ctx_sched_out(child_ctx); |
| 7501 | child->perf_event_ctxp[ctxn] = NULL; | 7513 | child->perf_event_ctxp[ctxn] = NULL; |
| 7514 | |||
| 7515 | /* | ||
| 7516 | * In order to avoid freeing: child_ctx->parent_ctx->task | ||
| 7517 | * under perf_event_context::lock, grab another reference. | ||
| 7518 | */ | ||
| 7519 | parent_ctx = child_ctx->parent_ctx; | ||
| 7520 | if (parent_ctx) | ||
| 7521 | get_ctx(parent_ctx); | ||
| 7522 | |||
| 7502 | /* | 7523 | /* |
| 7503 | * If this context is a clone; unclone it so it can't get | 7524 | * If this context is a clone; unclone it so it can't get |
| 7504 | * swapped to another process while we're removing all | 7525 | * swapped to another process while we're removing all |
| @@ -7509,6 +7530,13 @@ static void perf_event_exit_task_context(struct task_struct *child, int ctxn) | |||
| 7509 | raw_spin_unlock_irqrestore(&child_ctx->lock, flags); | 7530 | raw_spin_unlock_irqrestore(&child_ctx->lock, flags); |
| 7510 | 7531 | ||
| 7511 | /* | 7532 | /* |
| 7533 | * Now that we no longer hold perf_event_context::lock, drop | ||
| 7534 | * our extra child_ctx->parent_ctx reference. | ||
| 7535 | */ | ||
| 7536 | if (parent_ctx) | ||
| 7537 | put_ctx(parent_ctx); | ||
| 7538 | |||
| 7539 | /* | ||
| 7512 | * Report the task dead after unscheduling the events so that we | 7540 | * Report the task dead after unscheduling the events so that we |
| 7513 | * won't get any samples after PERF_RECORD_EXIT. We can however still | 7541 | * won't get any samples after PERF_RECORD_EXIT. We can however still |
| 7514 | * get a few PERF_RECORD_READ events. | 7542 | * get a few PERF_RECORD_READ events. |
diff --git a/kernel/kexec.c b/kernel/kexec.c index 369f41a94124..4b8f0c925884 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c | |||
| @@ -33,6 +33,7 @@ | |||
| 33 | #include <linux/swap.h> | 33 | #include <linux/swap.h> |
| 34 | #include <linux/syscore_ops.h> | 34 | #include <linux/syscore_ops.h> |
| 35 | #include <linux/compiler.h> | 35 | #include <linux/compiler.h> |
| 36 | #include <linux/hugetlb.h> | ||
| 36 | 37 | ||
| 37 | #include <asm/page.h> | 38 | #include <asm/page.h> |
| 38 | #include <asm/uaccess.h> | 39 | #include <asm/uaccess.h> |
| @@ -1619,6 +1620,9 @@ static int __init crash_save_vmcoreinfo_init(void) | |||
| 1619 | #endif | 1620 | #endif |
| 1620 | VMCOREINFO_NUMBER(PG_head_mask); | 1621 | VMCOREINFO_NUMBER(PG_head_mask); |
| 1621 | VMCOREINFO_NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE); | 1622 | VMCOREINFO_NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE); |
| 1623 | #ifdef CONFIG_HUGETLBFS | ||
| 1624 | VMCOREINFO_SYMBOL(free_huge_page); | ||
| 1625 | #endif | ||
| 1622 | 1626 | ||
| 1623 | arch_crash_save_vmcoreinfo(); | 1627 | arch_crash_save_vmcoreinfo(); |
| 1624 | update_vmcoreinfo_note(); | 1628 | update_vmcoreinfo_note(); |
diff --git a/kernel/kprobes.c b/kernel/kprobes.c index 3214289df5a7..734e9a7d280b 100644 --- a/kernel/kprobes.c +++ b/kernel/kprobes.c | |||
| @@ -2037,19 +2037,23 @@ static int __init populate_kprobe_blacklist(unsigned long *start, | |||
| 2037 | { | 2037 | { |
| 2038 | unsigned long *iter; | 2038 | unsigned long *iter; |
| 2039 | struct kprobe_blacklist_entry *ent; | 2039 | struct kprobe_blacklist_entry *ent; |
| 2040 | unsigned long offset = 0, size = 0; | 2040 | unsigned long entry, offset = 0, size = 0; |
| 2041 | 2041 | ||
| 2042 | for (iter = start; iter < end; iter++) { | 2042 | for (iter = start; iter < end; iter++) { |
| 2043 | if (!kallsyms_lookup_size_offset(*iter, &size, &offset)) { | 2043 | entry = arch_deref_entry_point((void *)*iter); |
| 2044 | pr_err("Failed to find blacklist %p\n", (void *)*iter); | 2044 | |
| 2045 | if (!kernel_text_address(entry) || | ||
| 2046 | !kallsyms_lookup_size_offset(entry, &size, &offset)) { | ||
| 2047 | pr_err("Failed to find blacklist at %p\n", | ||
| 2048 | (void *)entry); | ||
| 2045 | continue; | 2049 | continue; |
| 2046 | } | 2050 | } |
| 2047 | 2051 | ||
| 2048 | ent = kmalloc(sizeof(*ent), GFP_KERNEL); | 2052 | ent = kmalloc(sizeof(*ent), GFP_KERNEL); |
| 2049 | if (!ent) | 2053 | if (!ent) |
| 2050 | return -ENOMEM; | 2054 | return -ENOMEM; |
| 2051 | ent->start_addr = *iter; | 2055 | ent->start_addr = entry; |
| 2052 | ent->end_addr = *iter + size; | 2056 | ent->end_addr = entry + size; |
| 2053 | INIT_LIST_HEAD(&ent->list); | 2057 | INIT_LIST_HEAD(&ent->list); |
| 2054 | list_add_tail(&ent->list, &kprobe_blacklist); | 2058 | list_add_tail(&ent->list, &kprobe_blacklist); |
| 2055 | } | 2059 | } |
diff --git a/kernel/locking/mcs_spinlock.c b/kernel/locking/mcs_spinlock.c index 838dc9e00669..be9ee1559fca 100644 --- a/kernel/locking/mcs_spinlock.c +++ b/kernel/locking/mcs_spinlock.c | |||
| @@ -14,21 +14,47 @@ | |||
| 14 | * called from interrupt context and we have preemption disabled while | 14 | * called from interrupt context and we have preemption disabled while |
| 15 | * spinning. | 15 | * spinning. |
| 16 | */ | 16 | */ |
| 17 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct optimistic_spin_queue, osq_node); | 17 | static DEFINE_PER_CPU_SHARED_ALIGNED(struct optimistic_spin_node, osq_node); |
| 18 | |||
| 19 | /* | ||
| 20 | * We use the value 0 to represent "no CPU", thus the encoded value | ||
| 21 | * will be the CPU number incremented by 1. | ||
| 22 | */ | ||
| 23 | static inline int encode_cpu(int cpu_nr) | ||
| 24 | { | ||
| 25 | return cpu_nr + 1; | ||
| 26 | } | ||
| 27 | |||
| 28 | static inline struct optimistic_spin_node *decode_cpu(int encoded_cpu_val) | ||
| 29 | { | ||
| 30 | int cpu_nr = encoded_cpu_val - 1; | ||
| 31 | |||
| 32 | return per_cpu_ptr(&osq_node, cpu_nr); | ||
| 33 | } | ||
| 18 | 34 | ||
| 19 | /* | 35 | /* |
| 20 | * Get a stable @node->next pointer, either for unlock() or unqueue() purposes. | 36 | * Get a stable @node->next pointer, either for unlock() or unqueue() purposes. |
| 21 | * Can return NULL in case we were the last queued and we updated @lock instead. | 37 | * Can return NULL in case we were the last queued and we updated @lock instead. |
| 22 | */ | 38 | */ |
| 23 | static inline struct optimistic_spin_queue * | 39 | static inline struct optimistic_spin_node * |
| 24 | osq_wait_next(struct optimistic_spin_queue **lock, | 40 | osq_wait_next(struct optimistic_spin_queue *lock, |
| 25 | struct optimistic_spin_queue *node, | 41 | struct optimistic_spin_node *node, |
| 26 | struct optimistic_spin_queue *prev) | 42 | struct optimistic_spin_node *prev) |
| 27 | { | 43 | { |
| 28 | struct optimistic_spin_queue *next = NULL; | 44 | struct optimistic_spin_node *next = NULL; |
| 45 | int curr = encode_cpu(smp_processor_id()); | ||
| 46 | int old; | ||
| 47 | |||
| 48 | /* | ||
| 49 | * If there is a prev node in queue, then the 'old' value will be | ||
| 50 | * the prev node's CPU #, else it's set to OSQ_UNLOCKED_VAL since if | ||
| 51 | * we're currently last in queue, then the queue will then become empty. | ||
| 52 | */ | ||
| 53 | old = prev ? prev->cpu : OSQ_UNLOCKED_VAL; | ||
| 29 | 54 | ||
| 30 | for (;;) { | 55 | for (;;) { |
| 31 | if (*lock == node && cmpxchg(lock, node, prev) == node) { | 56 | if (atomic_read(&lock->tail) == curr && |
| 57 | atomic_cmpxchg(&lock->tail, curr, old) == curr) { | ||
| 32 | /* | 58 | /* |
| 33 | * We were the last queued, we moved @lock back. @prev | 59 | * We were the last queued, we moved @lock back. @prev |
| 34 | * will now observe @lock and will complete its | 60 | * will now observe @lock and will complete its |
| @@ -59,18 +85,23 @@ osq_wait_next(struct optimistic_spin_queue **lock, | |||
| 59 | return next; | 85 | return next; |
| 60 | } | 86 | } |
| 61 | 87 | ||
| 62 | bool osq_lock(struct optimistic_spin_queue **lock) | 88 | bool osq_lock(struct optimistic_spin_queue *lock) |
| 63 | { | 89 | { |
| 64 | struct optimistic_spin_queue *node = this_cpu_ptr(&osq_node); | 90 | struct optimistic_spin_node *node = this_cpu_ptr(&osq_node); |
| 65 | struct optimistic_spin_queue *prev, *next; | 91 | struct optimistic_spin_node *prev, *next; |
| 92 | int curr = encode_cpu(smp_processor_id()); | ||
| 93 | int old; | ||
| 66 | 94 | ||
| 67 | node->locked = 0; | 95 | node->locked = 0; |
| 68 | node->next = NULL; | 96 | node->next = NULL; |
| 97 | node->cpu = curr; | ||
| 69 | 98 | ||
| 70 | node->prev = prev = xchg(lock, node); | 99 | old = atomic_xchg(&lock->tail, curr); |
| 71 | if (likely(prev == NULL)) | 100 | if (old == OSQ_UNLOCKED_VAL) |
| 72 | return true; | 101 | return true; |
| 73 | 102 | ||
| 103 | prev = decode_cpu(old); | ||
| 104 | node->prev = prev; | ||
| 74 | ACCESS_ONCE(prev->next) = node; | 105 | ACCESS_ONCE(prev->next) = node; |
| 75 | 106 | ||
| 76 | /* | 107 | /* |
| @@ -149,20 +180,21 @@ unqueue: | |||
| 149 | return false; | 180 | return false; |
| 150 | } | 181 | } |
| 151 | 182 | ||
| 152 | void osq_unlock(struct optimistic_spin_queue **lock) | 183 | void osq_unlock(struct optimistic_spin_queue *lock) |
| 153 | { | 184 | { |
| 154 | struct optimistic_spin_queue *node = this_cpu_ptr(&osq_node); | 185 | struct optimistic_spin_node *node, *next; |
| 155 | struct optimistic_spin_queue *next; | 186 | int curr = encode_cpu(smp_processor_id()); |
| 156 | 187 | ||
| 157 | /* | 188 | /* |
| 158 | * Fast path for the uncontended case. | 189 | * Fast path for the uncontended case. |
| 159 | */ | 190 | */ |
| 160 | if (likely(cmpxchg(lock, node, NULL) == node)) | 191 | if (likely(atomic_cmpxchg(&lock->tail, curr, OSQ_UNLOCKED_VAL) == curr)) |
| 161 | return; | 192 | return; |
| 162 | 193 | ||
| 163 | /* | 194 | /* |
| 164 | * Second most likely case. | 195 | * Second most likely case. |
| 165 | */ | 196 | */ |
| 197 | node = this_cpu_ptr(&osq_node); | ||
| 166 | next = xchg(&node->next, NULL); | 198 | next = xchg(&node->next, NULL); |
| 167 | if (next) { | 199 | if (next) { |
| 168 | ACCESS_ONCE(next->locked) = 1; | 200 | ACCESS_ONCE(next->locked) = 1; |
diff --git a/kernel/locking/mcs_spinlock.h b/kernel/locking/mcs_spinlock.h index a2dbac4aca6b..74356dc0ce29 100644 --- a/kernel/locking/mcs_spinlock.h +++ b/kernel/locking/mcs_spinlock.h | |||
| @@ -118,12 +118,13 @@ void mcs_spin_unlock(struct mcs_spinlock **lock, struct mcs_spinlock *node) | |||
| 118 | * mutex_lock()/rwsem_down_{read,write}() etc. | 118 | * mutex_lock()/rwsem_down_{read,write}() etc. |
| 119 | */ | 119 | */ |
| 120 | 120 | ||
| 121 | struct optimistic_spin_queue { | 121 | struct optimistic_spin_node { |
| 122 | struct optimistic_spin_queue *next, *prev; | 122 | struct optimistic_spin_node *next, *prev; |
| 123 | int locked; /* 1 if lock acquired */ | 123 | int locked; /* 1 if lock acquired */ |
| 124 | int cpu; /* encoded CPU # value */ | ||
| 124 | }; | 125 | }; |
| 125 | 126 | ||
| 126 | extern bool osq_lock(struct optimistic_spin_queue **lock); | 127 | extern bool osq_lock(struct optimistic_spin_queue *lock); |
| 127 | extern void osq_unlock(struct optimistic_spin_queue **lock); | 128 | extern void osq_unlock(struct optimistic_spin_queue *lock); |
| 128 | 129 | ||
| 129 | #endif /* __LINUX_MCS_SPINLOCK_H */ | 130 | #endif /* __LINUX_MCS_SPINLOCK_H */ |
diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c index bc73d33c6760..acca2c1a3c5e 100644 --- a/kernel/locking/mutex.c +++ b/kernel/locking/mutex.c | |||
| @@ -60,7 +60,7 @@ __mutex_init(struct mutex *lock, const char *name, struct lock_class_key *key) | |||
| 60 | INIT_LIST_HEAD(&lock->wait_list); | 60 | INIT_LIST_HEAD(&lock->wait_list); |
| 61 | mutex_clear_owner(lock); | 61 | mutex_clear_owner(lock); |
| 62 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER | 62 | #ifdef CONFIG_MUTEX_SPIN_ON_OWNER |
| 63 | lock->osq = NULL; | 63 | osq_lock_init(&lock->osq); |
| 64 | #endif | 64 | #endif |
| 65 | 65 | ||
| 66 | debug_mutex_init(lock, name, key); | 66 | debug_mutex_init(lock, name, key); |
diff --git a/kernel/locking/rwsem-spinlock.c b/kernel/locking/rwsem-spinlock.c index 9be8a9144978..2c93571162cb 100644 --- a/kernel/locking/rwsem-spinlock.c +++ b/kernel/locking/rwsem-spinlock.c | |||
| @@ -26,7 +26,7 @@ int rwsem_is_locked(struct rw_semaphore *sem) | |||
| 26 | unsigned long flags; | 26 | unsigned long flags; |
| 27 | 27 | ||
| 28 | if (raw_spin_trylock_irqsave(&sem->wait_lock, flags)) { | 28 | if (raw_spin_trylock_irqsave(&sem->wait_lock, flags)) { |
| 29 | ret = (sem->activity != 0); | 29 | ret = (sem->count != 0); |
| 30 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | 30 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 31 | } | 31 | } |
| 32 | return ret; | 32 | return ret; |
| @@ -46,7 +46,7 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, | |||
| 46 | debug_check_no_locks_freed((void *)sem, sizeof(*sem)); | 46 | debug_check_no_locks_freed((void *)sem, sizeof(*sem)); |
| 47 | lockdep_init_map(&sem->dep_map, name, key, 0); | 47 | lockdep_init_map(&sem->dep_map, name, key, 0); |
| 48 | #endif | 48 | #endif |
| 49 | sem->activity = 0; | 49 | sem->count = 0; |
| 50 | raw_spin_lock_init(&sem->wait_lock); | 50 | raw_spin_lock_init(&sem->wait_lock); |
| 51 | INIT_LIST_HEAD(&sem->wait_list); | 51 | INIT_LIST_HEAD(&sem->wait_list); |
| 52 | } | 52 | } |
| @@ -95,7 +95,7 @@ __rwsem_do_wake(struct rw_semaphore *sem, int wakewrite) | |||
| 95 | waiter = list_entry(next, struct rwsem_waiter, list); | 95 | waiter = list_entry(next, struct rwsem_waiter, list); |
| 96 | } while (waiter->type != RWSEM_WAITING_FOR_WRITE); | 96 | } while (waiter->type != RWSEM_WAITING_FOR_WRITE); |
| 97 | 97 | ||
| 98 | sem->activity += woken; | 98 | sem->count += woken; |
| 99 | 99 | ||
| 100 | out: | 100 | out: |
| 101 | return sem; | 101 | return sem; |
| @@ -126,9 +126,9 @@ void __sched __down_read(struct rw_semaphore *sem) | |||
| 126 | 126 | ||
| 127 | raw_spin_lock_irqsave(&sem->wait_lock, flags); | 127 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 128 | 128 | ||
| 129 | if (sem->activity >= 0 && list_empty(&sem->wait_list)) { | 129 | if (sem->count >= 0 && list_empty(&sem->wait_list)) { |
| 130 | /* granted */ | 130 | /* granted */ |
| 131 | sem->activity++; | 131 | sem->count++; |
| 132 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | 132 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| 133 | goto out; | 133 | goto out; |
| 134 | } | 134 | } |
| @@ -170,9 +170,9 @@ int __down_read_trylock(struct rw_semaphore *sem) | |||
| 170 | 170 | ||
| 171 | raw_spin_lock_irqsave(&sem->wait_lock, flags); | 171 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 172 | 172 | ||
| 173 | if (sem->activity >= 0 && list_empty(&sem->wait_list)) { | 173 | if (sem->count >= 0 && list_empty(&sem->wait_list)) { |
| 174 | /* granted */ | 174 | /* granted */ |
| 175 | sem->activity++; | 175 | sem->count++; |
| 176 | ret = 1; | 176 | ret = 1; |
| 177 | } | 177 | } |
| 178 | 178 | ||
| @@ -206,7 +206,7 @@ void __sched __down_write_nested(struct rw_semaphore *sem, int subclass) | |||
| 206 | * itself into sleep and waiting for system woke it or someone | 206 | * itself into sleep and waiting for system woke it or someone |
| 207 | * else in the head of the wait list up. | 207 | * else in the head of the wait list up. |
| 208 | */ | 208 | */ |
| 209 | if (sem->activity == 0) | 209 | if (sem->count == 0) |
| 210 | break; | 210 | break; |
| 211 | set_task_state(tsk, TASK_UNINTERRUPTIBLE); | 211 | set_task_state(tsk, TASK_UNINTERRUPTIBLE); |
| 212 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | 212 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| @@ -214,7 +214,7 @@ void __sched __down_write_nested(struct rw_semaphore *sem, int subclass) | |||
| 214 | raw_spin_lock_irqsave(&sem->wait_lock, flags); | 214 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 215 | } | 215 | } |
| 216 | /* got the lock */ | 216 | /* got the lock */ |
| 217 | sem->activity = -1; | 217 | sem->count = -1; |
| 218 | list_del(&waiter.list); | 218 | list_del(&waiter.list); |
| 219 | 219 | ||
| 220 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | 220 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| @@ -235,9 +235,9 @@ int __down_write_trylock(struct rw_semaphore *sem) | |||
| 235 | 235 | ||
| 236 | raw_spin_lock_irqsave(&sem->wait_lock, flags); | 236 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 237 | 237 | ||
| 238 | if (sem->activity == 0) { | 238 | if (sem->count == 0) { |
| 239 | /* got the lock */ | 239 | /* got the lock */ |
| 240 | sem->activity = -1; | 240 | sem->count = -1; |
| 241 | ret = 1; | 241 | ret = 1; |
| 242 | } | 242 | } |
| 243 | 243 | ||
| @@ -255,7 +255,7 @@ void __up_read(struct rw_semaphore *sem) | |||
| 255 | 255 | ||
| 256 | raw_spin_lock_irqsave(&sem->wait_lock, flags); | 256 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 257 | 257 | ||
| 258 | if (--sem->activity == 0 && !list_empty(&sem->wait_list)) | 258 | if (--sem->count == 0 && !list_empty(&sem->wait_list)) |
| 259 | sem = __rwsem_wake_one_writer(sem); | 259 | sem = __rwsem_wake_one_writer(sem); |
| 260 | 260 | ||
| 261 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); | 261 | raw_spin_unlock_irqrestore(&sem->wait_lock, flags); |
| @@ -270,7 +270,7 @@ void __up_write(struct rw_semaphore *sem) | |||
| 270 | 270 | ||
| 271 | raw_spin_lock_irqsave(&sem->wait_lock, flags); | 271 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 272 | 272 | ||
| 273 | sem->activity = 0; | 273 | sem->count = 0; |
| 274 | if (!list_empty(&sem->wait_list)) | 274 | if (!list_empty(&sem->wait_list)) |
| 275 | sem = __rwsem_do_wake(sem, 1); | 275 | sem = __rwsem_do_wake(sem, 1); |
| 276 | 276 | ||
| @@ -287,7 +287,7 @@ void __downgrade_write(struct rw_semaphore *sem) | |||
| 287 | 287 | ||
| 288 | raw_spin_lock_irqsave(&sem->wait_lock, flags); | 288 | raw_spin_lock_irqsave(&sem->wait_lock, flags); |
| 289 | 289 | ||
| 290 | sem->activity = 1; | 290 | sem->count = 1; |
| 291 | if (!list_empty(&sem->wait_list)) | 291 | if (!list_empty(&sem->wait_list)) |
| 292 | sem = __rwsem_do_wake(sem, 0); | 292 | sem = __rwsem_do_wake(sem, 0); |
| 293 | 293 | ||
diff --git a/kernel/locking/rwsem-xadd.c b/kernel/locking/rwsem-xadd.c index dacc32142fcc..a2391ac135c8 100644 --- a/kernel/locking/rwsem-xadd.c +++ b/kernel/locking/rwsem-xadd.c | |||
| @@ -82,9 +82,9 @@ void __init_rwsem(struct rw_semaphore *sem, const char *name, | |||
| 82 | sem->count = RWSEM_UNLOCKED_VALUE; | 82 | sem->count = RWSEM_UNLOCKED_VALUE; |
| 83 | raw_spin_lock_init(&sem->wait_lock); | 83 | raw_spin_lock_init(&sem->wait_lock); |
| 84 | INIT_LIST_HEAD(&sem->wait_list); | 84 | INIT_LIST_HEAD(&sem->wait_list); |
| 85 | #ifdef CONFIG_SMP | 85 | #ifdef CONFIG_RWSEM_SPIN_ON_OWNER |
| 86 | sem->owner = NULL; | 86 | sem->owner = NULL; |
| 87 | sem->osq = NULL; | 87 | osq_lock_init(&sem->osq); |
| 88 | #endif | 88 | #endif |
| 89 | } | 89 | } |
| 90 | 90 | ||
| @@ -262,7 +262,7 @@ static inline bool rwsem_try_write_lock(long count, struct rw_semaphore *sem) | |||
| 262 | return false; | 262 | return false; |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | #ifdef CONFIG_SMP | 265 | #ifdef CONFIG_RWSEM_SPIN_ON_OWNER |
| 266 | /* | 266 | /* |
| 267 | * Try to acquire write lock before the writer has been put on wait queue. | 267 | * Try to acquire write lock before the writer has been put on wait queue. |
| 268 | */ | 268 | */ |
| @@ -285,10 +285,10 @@ static inline bool rwsem_try_write_lock_unqueued(struct rw_semaphore *sem) | |||
| 285 | static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem) | 285 | static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem) |
| 286 | { | 286 | { |
| 287 | struct task_struct *owner; | 287 | struct task_struct *owner; |
| 288 | bool on_cpu = true; | 288 | bool on_cpu = false; |
| 289 | 289 | ||
| 290 | if (need_resched()) | 290 | if (need_resched()) |
| 291 | return 0; | 291 | return false; |
| 292 | 292 | ||
| 293 | rcu_read_lock(); | 293 | rcu_read_lock(); |
| 294 | owner = ACCESS_ONCE(sem->owner); | 294 | owner = ACCESS_ONCE(sem->owner); |
| @@ -297,9 +297,9 @@ static inline bool rwsem_can_spin_on_owner(struct rw_semaphore *sem) | |||
| 297 | rcu_read_unlock(); | 297 | rcu_read_unlock(); |
| 298 | 298 | ||
| 299 | /* | 299 | /* |
| 300 | * If sem->owner is not set, the rwsem owner may have | 300 | * If sem->owner is not set, yet we have just recently entered the |
| 301 | * just acquired it and not set the owner yet or the rwsem | 301 | * slowpath, then there is a possibility reader(s) may have the lock. |
| 302 | * has been released. | 302 | * To be safe, avoid spinning in these situations. |
| 303 | */ | 303 | */ |
| 304 | return on_cpu; | 304 | return on_cpu; |
| 305 | } | 305 | } |
diff --git a/kernel/locking/rwsem.c b/kernel/locking/rwsem.c index 42f806de49d4..e2d3bc7f03b4 100644 --- a/kernel/locking/rwsem.c +++ b/kernel/locking/rwsem.c | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include <linux/atomic.h> | 13 | #include <linux/atomic.h> |
| 14 | 14 | ||
| 15 | #if defined(CONFIG_SMP) && defined(CONFIG_RWSEM_XCHGADD_ALGORITHM) | 15 | #ifdef CONFIG_RWSEM_SPIN_ON_OWNER |
| 16 | static inline void rwsem_set_owner(struct rw_semaphore *sem) | 16 | static inline void rwsem_set_owner(struct rw_semaphore *sem) |
| 17 | { | 17 | { |
| 18 | sem->owner = current; | 18 | sem->owner = current; |
diff --git a/kernel/power/process.c b/kernel/power/process.c index 0ca8d83e2369..4ee194eb524b 100644 --- a/kernel/power/process.c +++ b/kernel/power/process.c | |||
| @@ -186,6 +186,7 @@ void thaw_processes(void) | |||
| 186 | 186 | ||
| 187 | printk("Restarting tasks ... "); | 187 | printk("Restarting tasks ... "); |
| 188 | 188 | ||
| 189 | __usermodehelper_set_disable_depth(UMH_FREEZING); | ||
| 189 | thaw_workqueues(); | 190 | thaw_workqueues(); |
| 190 | 191 | ||
| 191 | read_lock(&tasklist_lock); | 192 | read_lock(&tasklist_lock); |
diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 4dd8822f732a..ed35a4790afe 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c | |||
| @@ -306,7 +306,7 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
| 306 | error = suspend_ops->begin(state); | 306 | error = suspend_ops->begin(state); |
| 307 | if (error) | 307 | if (error) |
| 308 | goto Close; | 308 | goto Close; |
| 309 | } else if (state == PM_SUSPEND_FREEZE && freeze_ops->begin) { | 309 | } else if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->begin) { |
| 310 | error = freeze_ops->begin(); | 310 | error = freeze_ops->begin(); |
| 311 | if (error) | 311 | if (error) |
| 312 | goto Close; | 312 | goto Close; |
| @@ -335,7 +335,7 @@ int suspend_devices_and_enter(suspend_state_t state) | |||
| 335 | Close: | 335 | Close: |
| 336 | if (need_suspend_ops(state) && suspend_ops->end) | 336 | if (need_suspend_ops(state) && suspend_ops->end) |
| 337 | suspend_ops->end(); | 337 | suspend_ops->end(); |
| 338 | else if (state == PM_SUSPEND_FREEZE && freeze_ops->end) | 338 | else if (state == PM_SUSPEND_FREEZE && freeze_ops && freeze_ops->end) |
| 339 | freeze_ops->end(); | 339 | freeze_ops->end(); |
| 340 | 340 | ||
| 341 | return error; | 341 | return error; |
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index 7fa34f86e5ba..948a7693748e 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c | |||
| @@ -18,7 +18,7 @@ | |||
| 18 | * Copyright (C) IBM Corporation, 2005, 2006 | 18 | * Copyright (C) IBM Corporation, 2005, 2006 |
| 19 | * | 19 | * |
| 20 | * Authors: Paul E. McKenney <paulmck@us.ibm.com> | 20 | * Authors: Paul E. McKenney <paulmck@us.ibm.com> |
| 21 | * Josh Triplett <josh@freedesktop.org> | 21 | * Josh Triplett <josh@joshtriplett.org> |
| 22 | * | 22 | * |
| 23 | * See also: Documentation/RCU/torture.txt | 23 | * See also: Documentation/RCU/torture.txt |
| 24 | */ | 24 | */ |
| @@ -51,7 +51,7 @@ | |||
| 51 | #include <linux/torture.h> | 51 | #include <linux/torture.h> |
| 52 | 52 | ||
| 53 | MODULE_LICENSE("GPL"); | 53 | MODULE_LICENSE("GPL"); |
| 54 | MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@freedesktop.org>"); | 54 | MODULE_AUTHOR("Paul E. McKenney <paulmck@us.ibm.com> and Josh Triplett <josh@joshtriplett.org>"); |
| 55 | 55 | ||
| 56 | 56 | ||
| 57 | torture_param(int, fqs_duration, 0, | 57 | torture_param(int, fqs_duration, 0, |
diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c index f1ba77363fbb..625d0b0cd75a 100644 --- a/kernel/rcu/tree.c +++ b/kernel/rcu/tree.c | |||
| @@ -206,6 +206,70 @@ void rcu_bh_qs(int cpu) | |||
| 206 | rdp->passed_quiesce = 1; | 206 | rdp->passed_quiesce = 1; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | static DEFINE_PER_CPU(int, rcu_sched_qs_mask); | ||
| 210 | |||
| 211 | static DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = { | ||
| 212 | .dynticks_nesting = DYNTICK_TASK_EXIT_IDLE, | ||
| 213 | .dynticks = ATOMIC_INIT(1), | ||
| 214 | #ifdef CONFIG_NO_HZ_FULL_SYSIDLE | ||
| 215 | .dynticks_idle_nesting = DYNTICK_TASK_NEST_VALUE, | ||
| 216 | .dynticks_idle = ATOMIC_INIT(1), | ||
| 217 | #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ | ||
| 218 | }; | ||
| 219 | |||
| 220 | /* | ||
| 221 | * Let the RCU core know that this CPU has gone through the scheduler, | ||
| 222 | * which is a quiescent state. This is called when the need for a | ||
| 223 | * quiescent state is urgent, so we burn an atomic operation and full | ||
| 224 | * memory barriers to let the RCU core know about it, regardless of what | ||
| 225 | * this CPU might (or might not) do in the near future. | ||
| 226 | * | ||
| 227 | * We inform the RCU core by emulating a zero-duration dyntick-idle | ||
| 228 | * period, which we in turn do by incrementing the ->dynticks counter | ||
| 229 | * by two. | ||
| 230 | */ | ||
| 231 | static void rcu_momentary_dyntick_idle(void) | ||
| 232 | { | ||
| 233 | unsigned long flags; | ||
| 234 | struct rcu_data *rdp; | ||
| 235 | struct rcu_dynticks *rdtp; | ||
| 236 | int resched_mask; | ||
| 237 | struct rcu_state *rsp; | ||
| 238 | |||
| 239 | local_irq_save(flags); | ||
| 240 | |||
| 241 | /* | ||
| 242 | * Yes, we can lose flag-setting operations. This is OK, because | ||
| 243 | * the flag will be set again after some delay. | ||
| 244 | */ | ||
| 245 | resched_mask = raw_cpu_read(rcu_sched_qs_mask); | ||
| 246 | raw_cpu_write(rcu_sched_qs_mask, 0); | ||
| 247 | |||
| 248 | /* Find the flavor that needs a quiescent state. */ | ||
| 249 | for_each_rcu_flavor(rsp) { | ||
| 250 | rdp = raw_cpu_ptr(rsp->rda); | ||
| 251 | if (!(resched_mask & rsp->flavor_mask)) | ||
| 252 | continue; | ||
| 253 | smp_mb(); /* rcu_sched_qs_mask before cond_resched_completed. */ | ||
| 254 | if (ACCESS_ONCE(rdp->mynode->completed) != | ||
| 255 | ACCESS_ONCE(rdp->cond_resched_completed)) | ||
| 256 | continue; | ||
| 257 | |||
| 258 | /* | ||
| 259 | * Pretend to be momentarily idle for the quiescent state. | ||
| 260 | * This allows the grace-period kthread to record the | ||
| 261 | * quiescent state, with no need for this CPU to do anything | ||
| 262 | * further. | ||
| 263 | */ | ||
| 264 | rdtp = this_cpu_ptr(&rcu_dynticks); | ||
| 265 | smp_mb__before_atomic(); /* Earlier stuff before QS. */ | ||
| 266 | atomic_add(2, &rdtp->dynticks); /* QS. */ | ||
| 267 | smp_mb__after_atomic(); /* Later stuff after QS. */ | ||
| 268 | break; | ||
| 269 | } | ||
| 270 | local_irq_restore(flags); | ||
| 271 | } | ||
| 272 | |||
| 209 | /* | 273 | /* |
| 210 | * Note a context switch. This is a quiescent state for RCU-sched, | 274 | * Note a context switch. This is a quiescent state for RCU-sched, |
| 211 | * and requires special handling for preemptible RCU. | 275 | * and requires special handling for preemptible RCU. |
| @@ -216,19 +280,12 @@ void rcu_note_context_switch(int cpu) | |||
| 216 | trace_rcu_utilization(TPS("Start context switch")); | 280 | trace_rcu_utilization(TPS("Start context switch")); |
| 217 | rcu_sched_qs(cpu); | 281 | rcu_sched_qs(cpu); |
| 218 | rcu_preempt_note_context_switch(cpu); | 282 | rcu_preempt_note_context_switch(cpu); |
| 283 | if (unlikely(raw_cpu_read(rcu_sched_qs_mask))) | ||
| 284 | rcu_momentary_dyntick_idle(); | ||
| 219 | trace_rcu_utilization(TPS("End context switch")); | 285 | trace_rcu_utilization(TPS("End context switch")); |
| 220 | } | 286 | } |
| 221 | EXPORT_SYMBOL_GPL(rcu_note_context_switch); | 287 | EXPORT_SYMBOL_GPL(rcu_note_context_switch); |
| 222 | 288 | ||
| 223 | static DEFINE_PER_CPU(struct rcu_dynticks, rcu_dynticks) = { | ||
| 224 | .dynticks_nesting = DYNTICK_TASK_EXIT_IDLE, | ||
| 225 | .dynticks = ATOMIC_INIT(1), | ||
| 226 | #ifdef CONFIG_NO_HZ_FULL_SYSIDLE | ||
| 227 | .dynticks_idle_nesting = DYNTICK_TASK_NEST_VALUE, | ||
| 228 | .dynticks_idle = ATOMIC_INIT(1), | ||
| 229 | #endif /* #ifdef CONFIG_NO_HZ_FULL_SYSIDLE */ | ||
| 230 | }; | ||
| 231 | |||
| 232 | static long blimit = 10; /* Maximum callbacks per rcu_do_batch. */ | 289 | static long blimit = 10; /* Maximum callbacks per rcu_do_batch. */ |
| 233 | static long qhimark = 10000; /* If this many pending, ignore blimit. */ | 290 | static long qhimark = 10000; /* If this many pending, ignore blimit. */ |
| 234 | static long qlowmark = 100; /* Once only this many pending, use blimit. */ | 291 | static long qlowmark = 100; /* Once only this many pending, use blimit. */ |
| @@ -243,6 +300,13 @@ static ulong jiffies_till_next_fqs = ULONG_MAX; | |||
| 243 | module_param(jiffies_till_first_fqs, ulong, 0644); | 300 | module_param(jiffies_till_first_fqs, ulong, 0644); |
| 244 | module_param(jiffies_till_next_fqs, ulong, 0644); | 301 | module_param(jiffies_till_next_fqs, ulong, 0644); |
| 245 | 302 | ||
| 303 | /* | ||
| 304 | * How long the grace period must be before we start recruiting | ||
| 305 | * quiescent-state help from rcu_note_context_switch(). | ||
| 306 | */ | ||
| 307 | static ulong jiffies_till_sched_qs = HZ / 20; | ||
| 308 | module_param(jiffies_till_sched_qs, ulong, 0644); | ||
| 309 | |||
| 246 | static bool rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp, | 310 | static bool rcu_start_gp_advanced(struct rcu_state *rsp, struct rcu_node *rnp, |
| 247 | struct rcu_data *rdp); | 311 | struct rcu_data *rdp); |
| 248 | static void force_qs_rnp(struct rcu_state *rsp, | 312 | static void force_qs_rnp(struct rcu_state *rsp, |
| @@ -853,6 +917,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp, | |||
| 853 | bool *isidle, unsigned long *maxj) | 917 | bool *isidle, unsigned long *maxj) |
| 854 | { | 918 | { |
| 855 | unsigned int curr; | 919 | unsigned int curr; |
| 920 | int *rcrmp; | ||
| 856 | unsigned int snap; | 921 | unsigned int snap; |
| 857 | 922 | ||
| 858 | curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks); | 923 | curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks); |
| @@ -893,27 +958,43 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp, | |||
| 893 | } | 958 | } |
| 894 | 959 | ||
| 895 | /* | 960 | /* |
| 896 | * There is a possibility that a CPU in adaptive-ticks state | 961 | * A CPU running for an extended time within the kernel can |
| 897 | * might run in the kernel with the scheduling-clock tick disabled | 962 | * delay RCU grace periods. When the CPU is in NO_HZ_FULL mode, |
| 898 | * for an extended time period. Invoke rcu_kick_nohz_cpu() to | 963 | * even context-switching back and forth between a pair of |
| 899 | * force the CPU to restart the scheduling-clock tick in this | 964 | * in-kernel CPU-bound tasks cannot advance grace periods. |
| 900 | * CPU is in this state. | 965 | * So if the grace period is old enough, make the CPU pay attention. |
| 901 | */ | 966 | * Note that the unsynchronized assignments to the per-CPU |
| 902 | rcu_kick_nohz_cpu(rdp->cpu); | 967 | * rcu_sched_qs_mask variable are safe. Yes, setting of |
| 903 | 968 | * bits can be lost, but they will be set again on the next | |
| 904 | /* | 969 | * force-quiescent-state pass. So lost bit sets do not result |
| 905 | * Alternatively, the CPU might be running in the kernel | 970 | * in incorrect behavior, merely in a grace period lasting |
| 906 | * for an extended period of time without a quiescent state. | 971 | * a few jiffies longer than it might otherwise. Because |
| 907 | * Attempt to force the CPU through the scheduler to gain the | 972 | * there are at most four threads involved, and because the |
| 908 | * needed quiescent state, but only if the grace period has gone | 973 | * updates are only once every few jiffies, the probability of |
| 909 | * on for an uncommonly long time. If there are many stuck CPUs, | 974 | * lossage (and thus of slight grace-period extension) is |
| 910 | * we will beat on the first one until it gets unstuck, then move | 975 | * quite low. |
| 911 | * to the next. Only do this for the primary flavor of RCU. | 976 | * |
| 977 | * Note that if the jiffies_till_sched_qs boot/sysfs parameter | ||
| 978 | * is set too high, we override with half of the RCU CPU stall | ||
| 979 | * warning delay. | ||
| 912 | */ | 980 | */ |
| 913 | if (rdp->rsp == rcu_state_p && | 981 | rcrmp = &per_cpu(rcu_sched_qs_mask, rdp->cpu); |
| 982 | if (ULONG_CMP_GE(jiffies, | ||
| 983 | rdp->rsp->gp_start + jiffies_till_sched_qs) || | ||
| 914 | ULONG_CMP_GE(jiffies, rdp->rsp->jiffies_resched)) { | 984 | ULONG_CMP_GE(jiffies, rdp->rsp->jiffies_resched)) { |
| 915 | rdp->rsp->jiffies_resched += 5; | 985 | if (!(ACCESS_ONCE(*rcrmp) & rdp->rsp->flavor_mask)) { |
| 916 | resched_cpu(rdp->cpu); | 986 | ACCESS_ONCE(rdp->cond_resched_completed) = |
| 987 | ACCESS_ONCE(rdp->mynode->completed); | ||
| 988 | smp_mb(); /* ->cond_resched_completed before *rcrmp. */ | ||
| 989 | ACCESS_ONCE(*rcrmp) = | ||
| 990 | ACCESS_ONCE(*rcrmp) + rdp->rsp->flavor_mask; | ||
| 991 | resched_cpu(rdp->cpu); /* Force CPU into scheduler. */ | ||
| 992 | rdp->rsp->jiffies_resched += 5; /* Enable beating. */ | ||
| 993 | } else if (ULONG_CMP_GE(jiffies, rdp->rsp->jiffies_resched)) { | ||
| 994 | /* Time to beat on that CPU again! */ | ||
| 995 | resched_cpu(rdp->cpu); /* Force CPU into scheduler. */ | ||
| 996 | rdp->rsp->jiffies_resched += 5; /* Re-enable beating. */ | ||
| 997 | } | ||
| 917 | } | 998 | } |
| 918 | 999 | ||
| 919 | return 0; | 1000 | return 0; |
| @@ -3491,6 +3572,7 @@ static void __init rcu_init_one(struct rcu_state *rsp, | |||
| 3491 | "rcu_node_fqs_1", | 3572 | "rcu_node_fqs_1", |
| 3492 | "rcu_node_fqs_2", | 3573 | "rcu_node_fqs_2", |
| 3493 | "rcu_node_fqs_3" }; /* Match MAX_RCU_LVLS */ | 3574 | "rcu_node_fqs_3" }; /* Match MAX_RCU_LVLS */ |
| 3575 | static u8 fl_mask = 0x1; | ||
| 3494 | int cpustride = 1; | 3576 | int cpustride = 1; |
| 3495 | int i; | 3577 | int i; |
| 3496 | int j; | 3578 | int j; |
| @@ -3509,6 +3591,8 @@ static void __init rcu_init_one(struct rcu_state *rsp, | |||
| 3509 | for (i = 1; i < rcu_num_lvls; i++) | 3591 | for (i = 1; i < rcu_num_lvls; i++) |
| 3510 | rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1]; | 3592 | rsp->level[i] = rsp->level[i - 1] + rsp->levelcnt[i - 1]; |
| 3511 | rcu_init_levelspread(rsp); | 3593 | rcu_init_levelspread(rsp); |
| 3594 | rsp->flavor_mask = fl_mask; | ||
| 3595 | fl_mask <<= 1; | ||
| 3512 | 3596 | ||
| 3513 | /* Initialize the elements themselves, starting from the leaves. */ | 3597 | /* Initialize the elements themselves, starting from the leaves. */ |
| 3514 | 3598 | ||
diff --git a/kernel/rcu/tree.h b/kernel/rcu/tree.h index bf2c1e669691..0f69a79c5b7d 100644 --- a/kernel/rcu/tree.h +++ b/kernel/rcu/tree.h | |||
| @@ -307,6 +307,9 @@ struct rcu_data { | |||
| 307 | /* 4) reasons this CPU needed to be kicked by force_quiescent_state */ | 307 | /* 4) reasons this CPU needed to be kicked by force_quiescent_state */ |
| 308 | unsigned long dynticks_fqs; /* Kicked due to dynticks idle. */ | 308 | unsigned long dynticks_fqs; /* Kicked due to dynticks idle. */ |
| 309 | unsigned long offline_fqs; /* Kicked due to being offline. */ | 309 | unsigned long offline_fqs; /* Kicked due to being offline. */ |
| 310 | unsigned long cond_resched_completed; | ||
| 311 | /* Grace period that needs help */ | ||
| 312 | /* from cond_resched(). */ | ||
| 310 | 313 | ||
| 311 | /* 5) __rcu_pending() statistics. */ | 314 | /* 5) __rcu_pending() statistics. */ |
| 312 | unsigned long n_rcu_pending; /* rcu_pending() calls since boot. */ | 315 | unsigned long n_rcu_pending; /* rcu_pending() calls since boot. */ |
| @@ -392,6 +395,7 @@ struct rcu_state { | |||
| 392 | struct rcu_node *level[RCU_NUM_LVLS]; /* Hierarchy levels. */ | 395 | struct rcu_node *level[RCU_NUM_LVLS]; /* Hierarchy levels. */ |
| 393 | u32 levelcnt[MAX_RCU_LVLS + 1]; /* # nodes in each level. */ | 396 | u32 levelcnt[MAX_RCU_LVLS + 1]; /* # nodes in each level. */ |
| 394 | u8 levelspread[RCU_NUM_LVLS]; /* kids/node in each level. */ | 397 | u8 levelspread[RCU_NUM_LVLS]; /* kids/node in each level. */ |
| 398 | u8 flavor_mask; /* bit in flavor mask. */ | ||
| 395 | struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */ | 399 | struct rcu_data __percpu *rda; /* pointer of percu rcu_data. */ |
| 396 | void (*call)(struct rcu_head *head, /* call_rcu() flavor. */ | 400 | void (*call)(struct rcu_head *head, /* call_rcu() flavor. */ |
| 397 | void (*func)(struct rcu_head *head)); | 401 | void (*func)(struct rcu_head *head)); |
| @@ -563,7 +567,7 @@ static bool rcu_nocb_need_deferred_wakeup(struct rcu_data *rdp); | |||
| 563 | static void do_nocb_deferred_wakeup(struct rcu_data *rdp); | 567 | static void do_nocb_deferred_wakeup(struct rcu_data *rdp); |
| 564 | static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp); | 568 | static void rcu_boot_init_nocb_percpu_data(struct rcu_data *rdp); |
| 565 | static void rcu_spawn_nocb_kthreads(struct rcu_state *rsp); | 569 | static void rcu_spawn_nocb_kthreads(struct rcu_state *rsp); |
| 566 | static void rcu_kick_nohz_cpu(int cpu); | 570 | static void __maybe_unused rcu_kick_nohz_cpu(int cpu); |
| 567 | static bool init_nocb_callback_list(struct rcu_data *rdp); | 571 | static bool init_nocb_callback_list(struct rcu_data *rdp); |
| 568 | static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq); | 572 | static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq); |
| 569 | static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq); | 573 | static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq); |
diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h index cbc2c45265e2..02ac0fb186b8 100644 --- a/kernel/rcu/tree_plugin.h +++ b/kernel/rcu/tree_plugin.h | |||
| @@ -2404,7 +2404,7 @@ static bool init_nocb_callback_list(struct rcu_data *rdp) | |||
| 2404 | * if an adaptive-ticks CPU is failing to respond to the current grace | 2404 | * if an adaptive-ticks CPU is failing to respond to the current grace |
| 2405 | * period and has not be idle from an RCU perspective, kick it. | 2405 | * period and has not be idle from an RCU perspective, kick it. |
| 2406 | */ | 2406 | */ |
| 2407 | static void rcu_kick_nohz_cpu(int cpu) | 2407 | static void __maybe_unused rcu_kick_nohz_cpu(int cpu) |
| 2408 | { | 2408 | { |
| 2409 | #ifdef CONFIG_NO_HZ_FULL | 2409 | #ifdef CONFIG_NO_HZ_FULL |
| 2410 | if (tick_nohz_full_cpu(cpu)) | 2410 | if (tick_nohz_full_cpu(cpu)) |
diff --git a/kernel/rcu/update.c b/kernel/rcu/update.c index a2aeb4df0f60..bc7883570530 100644 --- a/kernel/rcu/update.c +++ b/kernel/rcu/update.c | |||
| @@ -200,12 +200,12 @@ void wait_rcu_gp(call_rcu_func_t crf) | |||
| 200 | EXPORT_SYMBOL_GPL(wait_rcu_gp); | 200 | EXPORT_SYMBOL_GPL(wait_rcu_gp); |
| 201 | 201 | ||
| 202 | #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD | 202 | #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD |
| 203 | static inline void debug_init_rcu_head(struct rcu_head *head) | 203 | void init_rcu_head(struct rcu_head *head) |
| 204 | { | 204 | { |
| 205 | debug_object_init(head, &rcuhead_debug_descr); | 205 | debug_object_init(head, &rcuhead_debug_descr); |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | static inline void debug_rcu_head_free(struct rcu_head *head) | 208 | void destroy_rcu_head(struct rcu_head *head) |
| 209 | { | 209 | { |
| 210 | debug_object_free(head, &rcuhead_debug_descr); | 210 | debug_object_free(head, &rcuhead_debug_descr); |
| 211 | } | 211 | } |
| @@ -350,21 +350,3 @@ static int __init check_cpu_stall_init(void) | |||
| 350 | early_initcall(check_cpu_stall_init); | 350 | early_initcall(check_cpu_stall_init); |
| 351 | 351 | ||
| 352 | #endif /* #ifdef CONFIG_RCU_STALL_COMMON */ | 352 | #endif /* #ifdef CONFIG_RCU_STALL_COMMON */ |
| 353 | |||
| 354 | /* | ||
| 355 | * Hooks for cond_resched() and friends to avoid RCU CPU stall warnings. | ||
| 356 | */ | ||
| 357 | |||
| 358 | DEFINE_PER_CPU(int, rcu_cond_resched_count); | ||
| 359 | |||
| 360 | /* | ||
| 361 | * Report a set of RCU quiescent states, for use by cond_resched() | ||
| 362 | * and friends. Out of line due to being called infrequently. | ||
| 363 | */ | ||
| 364 | void rcu_resched(void) | ||
| 365 | { | ||
| 366 | preempt_disable(); | ||
| 367 | __this_cpu_write(rcu_cond_resched_count, 0); | ||
| 368 | rcu_note_context_switch(smp_processor_id()); | ||
| 369 | preempt_enable(); | ||
| 370 | } | ||
diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 3bdf01b494fe..bc1638b33449 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c | |||
| @@ -4147,7 +4147,6 @@ static void __cond_resched(void) | |||
| 4147 | 4147 | ||
| 4148 | int __sched _cond_resched(void) | 4148 | int __sched _cond_resched(void) |
| 4149 | { | 4149 | { |
| 4150 | rcu_cond_resched(); | ||
| 4151 | if (should_resched()) { | 4150 | if (should_resched()) { |
| 4152 | __cond_resched(); | 4151 | __cond_resched(); |
| 4153 | return 1; | 4152 | return 1; |
| @@ -4166,18 +4165,15 @@ EXPORT_SYMBOL(_cond_resched); | |||
| 4166 | */ | 4165 | */ |
| 4167 | int __cond_resched_lock(spinlock_t *lock) | 4166 | int __cond_resched_lock(spinlock_t *lock) |
| 4168 | { | 4167 | { |
| 4169 | bool need_rcu_resched = rcu_should_resched(); | ||
| 4170 | int resched = should_resched(); | 4168 | int resched = should_resched(); |
| 4171 | int ret = 0; | 4169 | int ret = 0; |
| 4172 | 4170 | ||
| 4173 | lockdep_assert_held(lock); | 4171 | lockdep_assert_held(lock); |
| 4174 | 4172 | ||
| 4175 | if (spin_needbreak(lock) || resched || need_rcu_resched) { | 4173 | if (spin_needbreak(lock) || resched) { |
| 4176 | spin_unlock(lock); | 4174 | spin_unlock(lock); |
| 4177 | if (resched) | 4175 | if (resched) |
| 4178 | __cond_resched(); | 4176 | __cond_resched(); |
| 4179 | else if (unlikely(need_rcu_resched)) | ||
| 4180 | rcu_resched(); | ||
| 4181 | else | 4177 | else |
| 4182 | cpu_relax(); | 4178 | cpu_relax(); |
| 4183 | ret = 1; | 4179 | ret = 1; |
| @@ -4191,7 +4187,6 @@ int __sched __cond_resched_softirq(void) | |||
| 4191 | { | 4187 | { |
| 4192 | BUG_ON(!in_softirq()); | 4188 | BUG_ON(!in_softirq()); |
| 4193 | 4189 | ||
| 4194 | rcu_cond_resched(); /* BH disabled OK, just recording QSes. */ | ||
| 4195 | if (should_resched()) { | 4190 | if (should_resched()) { |
| 4196 | local_bh_enable(); | 4191 | local_bh_enable(); |
| 4197 | __cond_resched(); | 4192 | __cond_resched(); |
diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c index 695f9773bb60..627b3c34b821 100644 --- a/kernel/sched/debug.c +++ b/kernel/sched/debug.c | |||
| @@ -608,7 +608,7 @@ void proc_sched_show_task(struct task_struct *p, struct seq_file *m) | |||
| 608 | 608 | ||
| 609 | avg_atom = p->se.sum_exec_runtime; | 609 | avg_atom = p->se.sum_exec_runtime; |
| 610 | if (nr_switches) | 610 | if (nr_switches) |
| 611 | do_div(avg_atom, nr_switches); | 611 | avg_atom = div64_ul(avg_atom, nr_switches); |
| 612 | else | 612 | else |
| 613 | avg_atom = -1LL; | 613 | avg_atom = -1LL; |
| 614 | 614 | ||
diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 88c9c65a430d..fe75444ae7ec 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c | |||
| @@ -585,9 +585,14 @@ static int alarm_timer_set(struct k_itimer *timr, int flags, | |||
| 585 | struct itimerspec *new_setting, | 585 | struct itimerspec *new_setting, |
| 586 | struct itimerspec *old_setting) | 586 | struct itimerspec *old_setting) |
| 587 | { | 587 | { |
| 588 | ktime_t exp; | ||
| 589 | |||
| 588 | if (!rtcdev) | 590 | if (!rtcdev) |
| 589 | return -ENOTSUPP; | 591 | return -ENOTSUPP; |
| 590 | 592 | ||
| 593 | if (flags & ~TIMER_ABSTIME) | ||
| 594 | return -EINVAL; | ||
| 595 | |||
| 591 | if (old_setting) | 596 | if (old_setting) |
| 592 | alarm_timer_get(timr, old_setting); | 597 | alarm_timer_get(timr, old_setting); |
| 593 | 598 | ||
| @@ -597,8 +602,16 @@ static int alarm_timer_set(struct k_itimer *timr, int flags, | |||
| 597 | 602 | ||
| 598 | /* start the timer */ | 603 | /* start the timer */ |
| 599 | timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval); | 604 | timr->it.alarm.interval = timespec_to_ktime(new_setting->it_interval); |
| 600 | alarm_start(&timr->it.alarm.alarmtimer, | 605 | exp = timespec_to_ktime(new_setting->it_value); |
| 601 | timespec_to_ktime(new_setting->it_value)); | 606 | /* Convert (if necessary) to absolute time */ |
| 607 | if (flags != TIMER_ABSTIME) { | ||
| 608 | ktime_t now; | ||
| 609 | |||
| 610 | now = alarm_bases[timr->it.alarm.alarmtimer.type].gettime(); | ||
| 611 | exp = ktime_add(now, exp); | ||
| 612 | } | ||
| 613 | |||
| 614 | alarm_start(&timr->it.alarm.alarmtimer, exp); | ||
| 602 | return 0; | 615 | return 0; |
| 603 | } | 616 | } |
| 604 | 617 | ||
| @@ -730,6 +743,9 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags, | |||
| 730 | if (!alarmtimer_get_rtcdev()) | 743 | if (!alarmtimer_get_rtcdev()) |
| 731 | return -ENOTSUPP; | 744 | return -ENOTSUPP; |
| 732 | 745 | ||
| 746 | if (flags & ~TIMER_ABSTIME) | ||
| 747 | return -EINVAL; | ||
| 748 | |||
| 733 | if (!capable(CAP_WAKE_ALARM)) | 749 | if (!capable(CAP_WAKE_ALARM)) |
| 734 | return -EPERM; | 750 | return -EPERM; |
| 735 | 751 | ||
diff --git a/kernel/time/clockevents.c b/kernel/time/clockevents.c index ad362c260ef4..9c94c19f1305 100644 --- a/kernel/time/clockevents.c +++ b/kernel/time/clockevents.c | |||
| @@ -146,7 +146,8 @@ static int clockevents_increase_min_delta(struct clock_event_device *dev) | |||
| 146 | { | 146 | { |
| 147 | /* Nothing to do if we already reached the limit */ | 147 | /* Nothing to do if we already reached the limit */ |
| 148 | if (dev->min_delta_ns >= MIN_DELTA_LIMIT) { | 148 | if (dev->min_delta_ns >= MIN_DELTA_LIMIT) { |
| 149 | printk(KERN_WARNING "CE: Reprogramming failure. Giving up\n"); | 149 | printk_deferred(KERN_WARNING |
| 150 | "CE: Reprogramming failure. Giving up\n"); | ||
| 150 | dev->next_event.tv64 = KTIME_MAX; | 151 | dev->next_event.tv64 = KTIME_MAX; |
| 151 | return -ETIME; | 152 | return -ETIME; |
| 152 | } | 153 | } |
| @@ -159,9 +160,10 @@ static int clockevents_increase_min_delta(struct clock_event_device *dev) | |||
| 159 | if (dev->min_delta_ns > MIN_DELTA_LIMIT) | 160 | if (dev->min_delta_ns > MIN_DELTA_LIMIT) |
| 160 | dev->min_delta_ns = MIN_DELTA_LIMIT; | 161 | dev->min_delta_ns = MIN_DELTA_LIMIT; |
| 161 | 162 | ||
| 162 | printk(KERN_WARNING "CE: %s increased min_delta_ns to %llu nsec\n", | 163 | printk_deferred(KERN_WARNING |
| 163 | dev->name ? dev->name : "?", | 164 | "CE: %s increased min_delta_ns to %llu nsec\n", |
| 164 | (unsigned long long) dev->min_delta_ns); | 165 | dev->name ? dev->name : "?", |
| 166 | (unsigned long long) dev->min_delta_ns); | ||
| 165 | return 0; | 167 | return 0; |
| 166 | } | 168 | } |
| 167 | 169 | ||
diff --git a/kernel/time/sched_clock.c b/kernel/time/sched_clock.c index 445106d2c729..01d2d15aa662 100644 --- a/kernel/time/sched_clock.c +++ b/kernel/time/sched_clock.c | |||
| @@ -191,7 +191,8 @@ void __init sched_clock_postinit(void) | |||
| 191 | 191 | ||
| 192 | static int sched_clock_suspend(void) | 192 | static int sched_clock_suspend(void) |
| 193 | { | 193 | { |
| 194 | sched_clock_poll(&sched_clock_timer); | 194 | update_sched_clock(); |
| 195 | hrtimer_cancel(&sched_clock_timer); | ||
| 195 | cd.suspended = true; | 196 | cd.suspended = true; |
| 196 | return 0; | 197 | return 0; |
| 197 | } | 198 | } |
| @@ -199,6 +200,7 @@ static int sched_clock_suspend(void) | |||
| 199 | static void sched_clock_resume(void) | 200 | static void sched_clock_resume(void) |
| 200 | { | 201 | { |
| 201 | cd.epoch_cyc = read_sched_clock(); | 202 | cd.epoch_cyc = read_sched_clock(); |
| 203 | hrtimer_start(&sched_clock_timer, cd.wrap_kt, HRTIMER_MODE_REL); | ||
| 202 | cd.suspended = false; | 204 | cd.suspended = false; |
| 203 | } | 205 | } |
| 204 | 206 | ||
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 5b372e3ed675..ac9d1dad630b 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -265,12 +265,12 @@ static void update_ftrace_function(void) | |||
| 265 | func = ftrace_ops_list_func; | 265 | func = ftrace_ops_list_func; |
| 266 | } | 266 | } |
| 267 | 267 | ||
| 268 | update_function_graph_func(); | ||
| 269 | |||
| 268 | /* If there's no change, then do nothing more here */ | 270 | /* If there's no change, then do nothing more here */ |
| 269 | if (ftrace_trace_function == func) | 271 | if (ftrace_trace_function == func) |
| 270 | return; | 272 | return; |
| 271 | 273 | ||
| 272 | update_function_graph_func(); | ||
| 273 | |||
| 274 | /* | 274 | /* |
| 275 | * If we are using the list function, it doesn't care | 275 | * If we are using the list function, it doesn't care |
| 276 | * about the function_trace_ops. | 276 | * about the function_trace_ops. |
diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c index 7c56c3d06943..ff7027199a9a 100644 --- a/kernel/trace/ring_buffer.c +++ b/kernel/trace/ring_buffer.c | |||
| @@ -616,10 +616,6 @@ int ring_buffer_poll_wait(struct ring_buffer *buffer, int cpu, | |||
| 616 | struct ring_buffer_per_cpu *cpu_buffer; | 616 | struct ring_buffer_per_cpu *cpu_buffer; |
| 617 | struct rb_irq_work *work; | 617 | struct rb_irq_work *work; |
| 618 | 618 | ||
| 619 | if ((cpu == RING_BUFFER_ALL_CPUS && !ring_buffer_empty(buffer)) || | ||
| 620 | (cpu != RING_BUFFER_ALL_CPUS && !ring_buffer_empty_cpu(buffer, cpu))) | ||
| 621 | return POLLIN | POLLRDNORM; | ||
| 622 | |||
| 623 | if (cpu == RING_BUFFER_ALL_CPUS) | 619 | if (cpu == RING_BUFFER_ALL_CPUS) |
| 624 | work = &buffer->irq_work; | 620 | work = &buffer->irq_work; |
| 625 | else { | 621 | else { |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index f243444a3772..291397e66669 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -466,6 +466,12 @@ int __trace_puts(unsigned long ip, const char *str, int size) | |||
| 466 | struct print_entry *entry; | 466 | struct print_entry *entry; |
| 467 | unsigned long irq_flags; | 467 | unsigned long irq_flags; |
| 468 | int alloc; | 468 | int alloc; |
| 469 | int pc; | ||
| 470 | |||
| 471 | if (!(trace_flags & TRACE_ITER_PRINTK)) | ||
| 472 | return 0; | ||
| 473 | |||
| 474 | pc = preempt_count(); | ||
| 469 | 475 | ||
| 470 | if (unlikely(tracing_selftest_running || tracing_disabled)) | 476 | if (unlikely(tracing_selftest_running || tracing_disabled)) |
| 471 | return 0; | 477 | return 0; |
| @@ -475,7 +481,7 @@ int __trace_puts(unsigned long ip, const char *str, int size) | |||
| 475 | local_save_flags(irq_flags); | 481 | local_save_flags(irq_flags); |
| 476 | buffer = global_trace.trace_buffer.buffer; | 482 | buffer = global_trace.trace_buffer.buffer; |
| 477 | event = trace_buffer_lock_reserve(buffer, TRACE_PRINT, alloc, | 483 | event = trace_buffer_lock_reserve(buffer, TRACE_PRINT, alloc, |
| 478 | irq_flags, preempt_count()); | 484 | irq_flags, pc); |
| 479 | if (!event) | 485 | if (!event) |
| 480 | return 0; | 486 | return 0; |
| 481 | 487 | ||
| @@ -492,6 +498,7 @@ int __trace_puts(unsigned long ip, const char *str, int size) | |||
| 492 | entry->buf[size] = '\0'; | 498 | entry->buf[size] = '\0'; |
| 493 | 499 | ||
| 494 | __buffer_unlock_commit(buffer, event); | 500 | __buffer_unlock_commit(buffer, event); |
| 501 | ftrace_trace_stack(buffer, irq_flags, 4, pc); | ||
| 495 | 502 | ||
| 496 | return size; | 503 | return size; |
| 497 | } | 504 | } |
| @@ -509,6 +516,12 @@ int __trace_bputs(unsigned long ip, const char *str) | |||
| 509 | struct bputs_entry *entry; | 516 | struct bputs_entry *entry; |
| 510 | unsigned long irq_flags; | 517 | unsigned long irq_flags; |
| 511 | int size = sizeof(struct bputs_entry); | 518 | int size = sizeof(struct bputs_entry); |
| 519 | int pc; | ||
| 520 | |||
| 521 | if (!(trace_flags & TRACE_ITER_PRINTK)) | ||
| 522 | return 0; | ||
| 523 | |||
| 524 | pc = preempt_count(); | ||
| 512 | 525 | ||
| 513 | if (unlikely(tracing_selftest_running || tracing_disabled)) | 526 | if (unlikely(tracing_selftest_running || tracing_disabled)) |
| 514 | return 0; | 527 | return 0; |
| @@ -516,7 +529,7 @@ int __trace_bputs(unsigned long ip, const char *str) | |||
| 516 | local_save_flags(irq_flags); | 529 | local_save_flags(irq_flags); |
| 517 | buffer = global_trace.trace_buffer.buffer; | 530 | buffer = global_trace.trace_buffer.buffer; |
| 518 | event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size, | 531 | event = trace_buffer_lock_reserve(buffer, TRACE_BPUTS, size, |
| 519 | irq_flags, preempt_count()); | 532 | irq_flags, pc); |
| 520 | if (!event) | 533 | if (!event) |
| 521 | return 0; | 534 | return 0; |
| 522 | 535 | ||
| @@ -525,6 +538,7 @@ int __trace_bputs(unsigned long ip, const char *str) | |||
| 525 | entry->str = str; | 538 | entry->str = str; |
| 526 | 539 | ||
| 527 | __buffer_unlock_commit(buffer, event); | 540 | __buffer_unlock_commit(buffer, event); |
| 541 | ftrace_trace_stack(buffer, irq_flags, 4, pc); | ||
| 528 | 542 | ||
| 529 | return 1; | 543 | return 1; |
| 530 | } | 544 | } |
| @@ -809,7 +823,7 @@ static struct { | |||
| 809 | { trace_clock_local, "local", 1 }, | 823 | { trace_clock_local, "local", 1 }, |
| 810 | { trace_clock_global, "global", 1 }, | 824 | { trace_clock_global, "global", 1 }, |
| 811 | { trace_clock_counter, "counter", 0 }, | 825 | { trace_clock_counter, "counter", 0 }, |
| 812 | { trace_clock_jiffies, "uptime", 1 }, | 826 | { trace_clock_jiffies, "uptime", 0 }, |
| 813 | { trace_clock, "perf", 1 }, | 827 | { trace_clock, "perf", 1 }, |
| 814 | ARCH_TRACE_CLOCKS | 828 | ARCH_TRACE_CLOCKS |
| 815 | }; | 829 | }; |
diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c index 26dc348332b7..57b67b1f24d1 100644 --- a/kernel/trace/trace_clock.c +++ b/kernel/trace/trace_clock.c | |||
| @@ -59,13 +59,14 @@ u64 notrace trace_clock(void) | |||
| 59 | 59 | ||
| 60 | /* | 60 | /* |
| 61 | * trace_jiffy_clock(): Simply use jiffies as a clock counter. | 61 | * trace_jiffy_clock(): Simply use jiffies as a clock counter. |
| 62 | * Note that this use of jiffies_64 is not completely safe on | ||
| 63 | * 32-bit systems. But the window is tiny, and the effect if | ||
| 64 | * we are affected is that we will have an obviously bogus | ||
| 65 | * timestamp on a trace event - i.e. not life threatening. | ||
| 62 | */ | 66 | */ |
| 63 | u64 notrace trace_clock_jiffies(void) | 67 | u64 notrace trace_clock_jiffies(void) |
| 64 | { | 68 | { |
| 65 | u64 jiffy = jiffies - INITIAL_JIFFIES; | 69 | return jiffies_64_to_clock_t(jiffies_64 - INITIAL_JIFFIES); |
| 66 | |||
| 67 | /* Return nsecs */ | ||
| 68 | return (u64)jiffies_to_usecs(jiffy) * 1000ULL; | ||
| 69 | } | 70 | } |
| 70 | 71 | ||
| 71 | /* | 72 | /* |
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c index f99e0b3bca8c..2de53628689f 100644 --- a/kernel/trace/trace_events.c +++ b/kernel/trace/trace_events.c | |||
| @@ -470,6 +470,7 @@ static void remove_event_file_dir(struct ftrace_event_file *file) | |||
| 470 | 470 | ||
| 471 | list_del(&file->list); | 471 | list_del(&file->list); |
| 472 | remove_subsystem(file->system); | 472 | remove_subsystem(file->system); |
| 473 | free_event_filter(file->filter); | ||
| 473 | kmem_cache_free(file_cachep, file); | 474 | kmem_cache_free(file_cachep, file); |
| 474 | } | 475 | } |
| 475 | 476 | ||
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 6203d2900877..35974ac69600 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -3284,6 +3284,7 @@ int workqueue_sysfs_register(struct workqueue_struct *wq) | |||
| 3284 | } | 3284 | } |
| 3285 | } | 3285 | } |
| 3286 | 3286 | ||
| 3287 | dev_set_uevent_suppress(&wq_dev->dev, false); | ||
| 3287 | kobject_uevent(&wq_dev->dev.kobj, KOBJ_ADD); | 3288 | kobject_uevent(&wq_dev->dev.kobj, KOBJ_ADD); |
| 3288 | return 0; | 3289 | return 0; |
| 3289 | } | 3290 | } |
| @@ -4879,7 +4880,7 @@ static void __init wq_numa_init(void) | |||
| 4879 | BUG_ON(!tbl); | 4880 | BUG_ON(!tbl); |
| 4880 | 4881 | ||
| 4881 | for_each_node(node) | 4882 | for_each_node(node) |
| 4882 | BUG_ON(!alloc_cpumask_var_node(&tbl[node], GFP_KERNEL, | 4883 | BUG_ON(!zalloc_cpumask_var_node(&tbl[node], GFP_KERNEL, |
| 4883 | node_online(node) ? node : NUMA_NO_NODE)); | 4884 | node_online(node) ? node : NUMA_NO_NODE)); |
| 4884 | 4885 | ||
| 4885 | for_each_possible_cpu(cpu) { | 4886 | for_each_possible_cpu(cpu) { |
diff --git a/lib/cpumask.c b/lib/cpumask.c index c101230658eb..b6513a9f2892 100644 --- a/lib/cpumask.c +++ b/lib/cpumask.c | |||
| @@ -191,7 +191,7 @@ int cpumask_set_cpu_local_first(int i, int numa_node, cpumask_t *dstp) | |||
| 191 | 191 | ||
| 192 | i %= num_online_cpus(); | 192 | i %= num_online_cpus(); |
| 193 | 193 | ||
| 194 | if (!cpumask_of_node(numa_node)) { | 194 | if (numa_node == -1 || !cpumask_of_node(numa_node)) { |
| 195 | /* Use all online cpu's for non numa aware system */ | 195 | /* Use all online cpu's for non numa aware system */ |
| 196 | cpumask_copy(mask, cpu_online_mask); | 196 | cpumask_copy(mask, cpu_online_mask); |
| 197 | } else { | 197 | } else { |
diff --git a/mm/filemap.c b/mm/filemap.c index dafb06f70a09..900edfaf6df5 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
| @@ -1031,18 +1031,21 @@ EXPORT_SYMBOL(find_lock_entry); | |||
| 1031 | * @mapping: the address_space to search | 1031 | * @mapping: the address_space to search |
| 1032 | * @offset: the page index | 1032 | * @offset: the page index |
| 1033 | * @fgp_flags: PCG flags | 1033 | * @fgp_flags: PCG flags |
| 1034 | * @gfp_mask: gfp mask to use if a page is to be allocated | 1034 | * @cache_gfp_mask: gfp mask to use for the page cache data page allocation |
| 1035 | * @radix_gfp_mask: gfp mask to use for radix tree node allocation | ||
| 1035 | * | 1036 | * |
| 1036 | * Looks up the page cache slot at @mapping & @offset. | 1037 | * Looks up the page cache slot at @mapping & @offset. |
| 1037 | * | 1038 | * |
| 1038 | * PCG flags modify how the page is returned | 1039 | * PCG flags modify how the page is returned. |
| 1039 | * | 1040 | * |
| 1040 | * FGP_ACCESSED: the page will be marked accessed | 1041 | * FGP_ACCESSED: the page will be marked accessed |
| 1041 | * FGP_LOCK: Page is return locked | 1042 | * FGP_LOCK: Page is return locked |
| 1042 | * FGP_CREAT: If page is not present then a new page is allocated using | 1043 | * FGP_CREAT: If page is not present then a new page is allocated using |
| 1043 | * @gfp_mask and added to the page cache and the VM's LRU | 1044 | * @cache_gfp_mask and added to the page cache and the VM's LRU |
| 1044 | * list. The page is returned locked and with an increased | 1045 | * list. If radix tree nodes are allocated during page cache |
| 1045 | * refcount. Otherwise, %NULL is returned. | 1046 | * insertion then @radix_gfp_mask is used. The page is returned |
| 1047 | * locked and with an increased refcount. Otherwise, %NULL is | ||
| 1048 | * returned. | ||
| 1046 | * | 1049 | * |
| 1047 | * If FGP_LOCK or FGP_CREAT are specified then the function may sleep even | 1050 | * If FGP_LOCK or FGP_CREAT are specified then the function may sleep even |
| 1048 | * if the GFP flags specified for FGP_CREAT are atomic. | 1051 | * if the GFP flags specified for FGP_CREAT are atomic. |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 2024bbd573d2..7a0a73d2fcff 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
| @@ -856,7 +856,7 @@ struct hstate *size_to_hstate(unsigned long size) | |||
| 856 | return NULL; | 856 | return NULL; |
| 857 | } | 857 | } |
| 858 | 858 | ||
| 859 | static void free_huge_page(struct page *page) | 859 | void free_huge_page(struct page *page) |
| 860 | { | 860 | { |
| 861 | /* | 861 | /* |
| 862 | * Can't pass hstate in here because it is called from the | 862 | * Can't pass hstate in here because it is called from the |
| @@ -2604,6 +2604,7 @@ int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src, | |||
| 2604 | } else { | 2604 | } else { |
| 2605 | if (cow) | 2605 | if (cow) |
| 2606 | huge_ptep_set_wrprotect(src, addr, src_pte); | 2606 | huge_ptep_set_wrprotect(src, addr, src_pte); |
| 2607 | entry = huge_ptep_get(src_pte); | ||
| 2607 | ptepage = pte_page(entry); | 2608 | ptepage = pte_page(entry); |
| 2608 | get_page(ptepage); | 2609 | get_page(ptepage); |
| 2609 | page_dup_rmap(ptepage); | 2610 | page_dup_rmap(ptepage); |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index a2c7bcb0e6eb..1f14a430c656 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
| @@ -5415,8 +5415,12 @@ static int mem_cgroup_oom_notify_cb(struct mem_cgroup *memcg) | |||
| 5415 | { | 5415 | { |
| 5416 | struct mem_cgroup_eventfd_list *ev; | 5416 | struct mem_cgroup_eventfd_list *ev; |
| 5417 | 5417 | ||
| 5418 | spin_lock(&memcg_oom_lock); | ||
| 5419 | |||
| 5418 | list_for_each_entry(ev, &memcg->oom_notify, list) | 5420 | list_for_each_entry(ev, &memcg->oom_notify, list) |
| 5419 | eventfd_signal(ev->eventfd, 1); | 5421 | eventfd_signal(ev->eventfd, 1); |
| 5422 | |||
| 5423 | spin_unlock(&memcg_oom_lock); | ||
| 5420 | return 0; | 5424 | return 0; |
| 5421 | } | 5425 | } |
| 5422 | 5426 | ||
diff --git a/mm/memory-failure.c b/mm/memory-failure.c index c6399e328931..a013bc94ebbe 100644 --- a/mm/memory-failure.c +++ b/mm/memory-failure.c | |||
| @@ -435,7 +435,7 @@ static void collect_procs_anon(struct page *page, struct list_head *to_kill, | |||
| 435 | if (av == NULL) /* Not actually mapped anymore */ | 435 | if (av == NULL) /* Not actually mapped anymore */ |
| 436 | return; | 436 | return; |
| 437 | 437 | ||
| 438 | pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); | 438 | pgoff = page_to_pgoff(page); |
| 439 | read_lock(&tasklist_lock); | 439 | read_lock(&tasklist_lock); |
| 440 | for_each_process (tsk) { | 440 | for_each_process (tsk) { |
| 441 | struct anon_vma_chain *vmac; | 441 | struct anon_vma_chain *vmac; |
| @@ -469,7 +469,7 @@ static void collect_procs_file(struct page *page, struct list_head *to_kill, | |||
| 469 | mutex_lock(&mapping->i_mmap_mutex); | 469 | mutex_lock(&mapping->i_mmap_mutex); |
| 470 | read_lock(&tasklist_lock); | 470 | read_lock(&tasklist_lock); |
| 471 | for_each_process(tsk) { | 471 | for_each_process(tsk) { |
| 472 | pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); | 472 | pgoff_t pgoff = page_to_pgoff(page); |
| 473 | struct task_struct *t = task_early_kill(tsk, force_early); | 473 | struct task_struct *t = task_early_kill(tsk, force_early); |
| 474 | 474 | ||
| 475 | if (!t) | 475 | if (!t) |
| @@ -895,7 +895,13 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, | |||
| 895 | struct page *hpage = *hpagep; | 895 | struct page *hpage = *hpagep; |
| 896 | struct page *ppage; | 896 | struct page *ppage; |
| 897 | 897 | ||
| 898 | if (PageReserved(p) || PageSlab(p) || !PageLRU(p)) | 898 | /* |
| 899 | * Here we are interested only in user-mapped pages, so skip any | ||
| 900 | * other types of pages. | ||
| 901 | */ | ||
| 902 | if (PageReserved(p) || PageSlab(p)) | ||
| 903 | return SWAP_SUCCESS; | ||
| 904 | if (!(PageLRU(hpage) || PageHuge(p))) | ||
| 899 | return SWAP_SUCCESS; | 905 | return SWAP_SUCCESS; |
| 900 | 906 | ||
| 901 | /* | 907 | /* |
| @@ -905,8 +911,10 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn, | |||
| 905 | if (!page_mapped(hpage)) | 911 | if (!page_mapped(hpage)) |
| 906 | return SWAP_SUCCESS; | 912 | return SWAP_SUCCESS; |
| 907 | 913 | ||
| 908 | if (PageKsm(p)) | 914 | if (PageKsm(p)) { |
| 915 | pr_err("MCE %#lx: can't handle KSM pages.\n", pfn); | ||
| 909 | return SWAP_FAIL; | 916 | return SWAP_FAIL; |
| 917 | } | ||
| 910 | 918 | ||
| 911 | if (PageSwapCache(p)) { | 919 | if (PageSwapCache(p)) { |
| 912 | printk(KERN_ERR | 920 | printk(KERN_ERR |
| @@ -1229,7 +1237,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags) | |||
| 1229 | */ | 1237 | */ |
| 1230 | if (hwpoison_user_mappings(p, pfn, trapno, flags, &hpage) | 1238 | if (hwpoison_user_mappings(p, pfn, trapno, flags, &hpage) |
| 1231 | != SWAP_SUCCESS) { | 1239 | != SWAP_SUCCESS) { |
| 1232 | printk(KERN_ERR "MCE %#lx: cannot unmap page, give up\n", pfn); | 1240 | action_result(pfn, "unmapping failed", IGNORED); |
| 1233 | res = -EBUSY; | 1241 | res = -EBUSY; |
| 1234 | goto out; | 1242 | goto out; |
| 1235 | } | 1243 | } |
diff --git a/mm/memory.c b/mm/memory.c index d67fd9fcf1f2..8b44f765b645 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -2758,23 +2758,18 @@ void do_set_pte(struct vm_area_struct *vma, unsigned long address, | |||
| 2758 | update_mmu_cache(vma, address, pte); | 2758 | update_mmu_cache(vma, address, pte); |
| 2759 | } | 2759 | } |
| 2760 | 2760 | ||
| 2761 | static unsigned long fault_around_bytes = 65536; | 2761 | static unsigned long fault_around_bytes = rounddown_pow_of_two(65536); |
| 2762 | 2762 | ||
| 2763 | /* | ||
| 2764 | * fault_around_pages() and fault_around_mask() round down fault_around_bytes | ||
| 2765 | * to nearest page order. It's what do_fault_around() expects to see. | ||
| 2766 | */ | ||
| 2767 | static inline unsigned long fault_around_pages(void) | 2763 | static inline unsigned long fault_around_pages(void) |
| 2768 | { | 2764 | { |
| 2769 | return rounddown_pow_of_two(fault_around_bytes) / PAGE_SIZE; | 2765 | return fault_around_bytes >> PAGE_SHIFT; |
| 2770 | } | 2766 | } |
| 2771 | 2767 | ||
| 2772 | static inline unsigned long fault_around_mask(void) | 2768 | static inline unsigned long fault_around_mask(void) |
| 2773 | { | 2769 | { |
| 2774 | return ~(rounddown_pow_of_two(fault_around_bytes) - 1) & PAGE_MASK; | 2770 | return ~(fault_around_bytes - 1) & PAGE_MASK; |
| 2775 | } | 2771 | } |
| 2776 | 2772 | ||
| 2777 | |||
| 2778 | #ifdef CONFIG_DEBUG_FS | 2773 | #ifdef CONFIG_DEBUG_FS |
| 2779 | static int fault_around_bytes_get(void *data, u64 *val) | 2774 | static int fault_around_bytes_get(void *data, u64 *val) |
| 2780 | { | 2775 | { |
| @@ -2782,11 +2777,19 @@ static int fault_around_bytes_get(void *data, u64 *val) | |||
| 2782 | return 0; | 2777 | return 0; |
| 2783 | } | 2778 | } |
| 2784 | 2779 | ||
| 2780 | /* | ||
| 2781 | * fault_around_pages() and fault_around_mask() expects fault_around_bytes | ||
| 2782 | * rounded down to nearest page order. It's what do_fault_around() expects to | ||
| 2783 | * see. | ||
| 2784 | */ | ||
| 2785 | static int fault_around_bytes_set(void *data, u64 val) | 2785 | static int fault_around_bytes_set(void *data, u64 val) |
| 2786 | { | 2786 | { |
| 2787 | if (val / PAGE_SIZE > PTRS_PER_PTE) | 2787 | if (val / PAGE_SIZE > PTRS_PER_PTE) |
| 2788 | return -EINVAL; | 2788 | return -EINVAL; |
| 2789 | fault_around_bytes = val; | 2789 | if (val > PAGE_SIZE) |
| 2790 | fault_around_bytes = rounddown_pow_of_two(val); | ||
| 2791 | else | ||
| 2792 | fault_around_bytes = PAGE_SIZE; /* rounddown_pow_of_two(0) is undefined */ | ||
| 2790 | return 0; | 2793 | return 0; |
| 2791 | } | 2794 | } |
| 2792 | DEFINE_SIMPLE_ATTRIBUTE(fault_around_bytes_fops, | 2795 | DEFINE_SIMPLE_ATTRIBUTE(fault_around_bytes_fops, |
| @@ -2882,7 +2885,8 @@ static int do_read_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 2882 | * if page by the offset is not ready to be mapped (cold cache or | 2885 | * if page by the offset is not ready to be mapped (cold cache or |
| 2883 | * something). | 2886 | * something). |
| 2884 | */ | 2887 | */ |
| 2885 | if (vma->vm_ops->map_pages && fault_around_pages() > 1) { | 2888 | if (vma->vm_ops->map_pages && !(flags & FAULT_FLAG_NONLINEAR) && |
| 2889 | fault_around_pages() > 1) { | ||
| 2886 | pte = pte_offset_map_lock(mm, pmd, address, &ptl); | 2890 | pte = pte_offset_map_lock(mm, pmd, address, &ptl); |
| 2887 | do_fault_around(vma, address, pte, pgoff, flags); | 2891 | do_fault_around(vma, address, pte, pgoff, flags); |
| 2888 | if (!pte_same(*pte, orig_pte)) | 2892 | if (!pte_same(*pte, orig_pte)) |
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index eb58de19f815..8f5330d74f47 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
| @@ -2139,7 +2139,6 @@ struct mempolicy *__mpol_dup(struct mempolicy *old) | |||
| 2139 | } else | 2139 | } else |
| 2140 | *new = *old; | 2140 | *new = *old; |
| 2141 | 2141 | ||
| 2142 | rcu_read_lock(); | ||
| 2143 | if (current_cpuset_is_being_rebound()) { | 2142 | if (current_cpuset_is_being_rebound()) { |
| 2144 | nodemask_t mems = cpuset_mems_allowed(current); | 2143 | nodemask_t mems = cpuset_mems_allowed(current); |
| 2145 | if (new->flags & MPOL_F_REBINDING) | 2144 | if (new->flags & MPOL_F_REBINDING) |
| @@ -2147,7 +2146,6 @@ struct mempolicy *__mpol_dup(struct mempolicy *old) | |||
| 2147 | else | 2146 | else |
| 2148 | mpol_rebind_policy(new, &mems, MPOL_REBIND_ONCE); | 2147 | mpol_rebind_policy(new, &mems, MPOL_REBIND_ONCE); |
| 2149 | } | 2148 | } |
| 2150 | rcu_read_unlock(); | ||
| 2151 | atomic_set(&new->refcnt, 1); | 2149 | atomic_set(&new->refcnt, 1); |
| 2152 | return new; | 2150 | return new; |
| 2153 | } | 2151 | } |
diff --git a/mm/migrate.c b/mm/migrate.c index 9e0beaa91845..be6dbf995c0c 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
| @@ -988,9 +988,10 @@ out: | |||
| 988 | * it. Otherwise, putback_lru_page() will drop the reference grabbed | 988 | * it. Otherwise, putback_lru_page() will drop the reference grabbed |
| 989 | * during isolation. | 989 | * during isolation. |
| 990 | */ | 990 | */ |
| 991 | if (rc != MIGRATEPAGE_SUCCESS && put_new_page) | 991 | if (rc != MIGRATEPAGE_SUCCESS && put_new_page) { |
| 992 | ClearPageSwapBacked(newpage); | ||
| 992 | put_new_page(newpage, private); | 993 | put_new_page(newpage, private); |
| 993 | else | 994 | } else |
| 994 | putback_lru_page(newpage); | 995 | putback_lru_page(newpage); |
| 995 | 996 | ||
| 996 | if (result) { | 997 | if (result) { |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index 518e2c3f4c75..e0c943014eb7 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
| @@ -1306,9 +1306,9 @@ static inline void bdi_dirty_limits(struct backing_dev_info *bdi, | |||
| 1306 | *bdi_thresh = bdi_dirty_limit(bdi, dirty_thresh); | 1306 | *bdi_thresh = bdi_dirty_limit(bdi, dirty_thresh); |
| 1307 | 1307 | ||
| 1308 | if (bdi_bg_thresh) | 1308 | if (bdi_bg_thresh) |
| 1309 | *bdi_bg_thresh = div_u64((u64)*bdi_thresh * | 1309 | *bdi_bg_thresh = dirty_thresh ? div_u64((u64)*bdi_thresh * |
| 1310 | background_thresh, | 1310 | background_thresh, |
| 1311 | dirty_thresh); | 1311 | dirty_thresh) : 0; |
| 1312 | 1312 | ||
| 1313 | /* | 1313 | /* |
| 1314 | * In order to avoid the stacked BDI deadlock we need | 1314 | * In order to avoid the stacked BDI deadlock we need |
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 0ea758b898fd..ef44ad736ca1 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
| @@ -2447,7 +2447,7 @@ static inline int | |||
| 2447 | gfp_to_alloc_flags(gfp_t gfp_mask) | 2447 | gfp_to_alloc_flags(gfp_t gfp_mask) |
| 2448 | { | 2448 | { |
| 2449 | int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET; | 2449 | int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET; |
| 2450 | const gfp_t wait = gfp_mask & __GFP_WAIT; | 2450 | const bool atomic = !(gfp_mask & (__GFP_WAIT | __GFP_NO_KSWAPD)); |
| 2451 | 2451 | ||
| 2452 | /* __GFP_HIGH is assumed to be the same as ALLOC_HIGH to save a branch. */ | 2452 | /* __GFP_HIGH is assumed to be the same as ALLOC_HIGH to save a branch. */ |
| 2453 | BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_HIGH); | 2453 | BUILD_BUG_ON(__GFP_HIGH != (__force gfp_t) ALLOC_HIGH); |
| @@ -2456,20 +2456,20 @@ gfp_to_alloc_flags(gfp_t gfp_mask) | |||
| 2456 | * The caller may dip into page reserves a bit more if the caller | 2456 | * The caller may dip into page reserves a bit more if the caller |
| 2457 | * cannot run direct reclaim, or if the caller has realtime scheduling | 2457 | * cannot run direct reclaim, or if the caller has realtime scheduling |
| 2458 | * policy or is asking for __GFP_HIGH memory. GFP_ATOMIC requests will | 2458 | * policy or is asking for __GFP_HIGH memory. GFP_ATOMIC requests will |
| 2459 | * set both ALLOC_HARDER (!wait) and ALLOC_HIGH (__GFP_HIGH). | 2459 | * set both ALLOC_HARDER (atomic == true) and ALLOC_HIGH (__GFP_HIGH). |
| 2460 | */ | 2460 | */ |
| 2461 | alloc_flags |= (__force int) (gfp_mask & __GFP_HIGH); | 2461 | alloc_flags |= (__force int) (gfp_mask & __GFP_HIGH); |
| 2462 | 2462 | ||
| 2463 | if (!wait) { | 2463 | if (atomic) { |
| 2464 | /* | 2464 | /* |
| 2465 | * Not worth trying to allocate harder for | 2465 | * Not worth trying to allocate harder for __GFP_NOMEMALLOC even |
| 2466 | * __GFP_NOMEMALLOC even if it can't schedule. | 2466 | * if it can't schedule. |
| 2467 | */ | 2467 | */ |
| 2468 | if (!(gfp_mask & __GFP_NOMEMALLOC)) | 2468 | if (!(gfp_mask & __GFP_NOMEMALLOC)) |
| 2469 | alloc_flags |= ALLOC_HARDER; | 2469 | alloc_flags |= ALLOC_HARDER; |
| 2470 | /* | 2470 | /* |
| 2471 | * Ignore cpuset if GFP_ATOMIC (!wait) rather than fail alloc. | 2471 | * Ignore cpuset mems for GFP_ATOMIC rather than fail, see the |
| 2472 | * See also cpuset_zone_allowed() comment in kernel/cpuset.c. | 2472 | * comment for __cpuset_node_allowed_softwall(). |
| 2473 | */ | 2473 | */ |
| 2474 | alloc_flags &= ~ALLOC_CPUSET; | 2474 | alloc_flags &= ~ALLOC_CPUSET; |
| 2475 | } else if (unlikely(rt_task(current)) && !in_interrupt()) | 2475 | } else if (unlikely(rt_task(current)) && !in_interrupt()) |
| @@ -6062,11 +6062,13 @@ static inline int pfn_to_bitidx(struct zone *zone, unsigned long pfn) | |||
| 6062 | } | 6062 | } |
| 6063 | 6063 | ||
| 6064 | /** | 6064 | /** |
| 6065 | * get_pageblock_flags_group - Return the requested group of flags for the pageblock_nr_pages block of pages | 6065 | * get_pfnblock_flags_mask - Return the requested group of flags for the pageblock_nr_pages block of pages |
| 6066 | * @page: The page within the block of interest | 6066 | * @page: The page within the block of interest |
| 6067 | * @start_bitidx: The first bit of interest to retrieve | 6067 | * @pfn: The target page frame number |
| 6068 | * @end_bitidx: The last bit of interest | 6068 | * @end_bitidx: The last bit of interest to retrieve |
| 6069 | * returns pageblock_bits flags | 6069 | * @mask: mask of bits that the caller is interested in |
| 6070 | * | ||
| 6071 | * Return: pageblock_bits flags | ||
| 6070 | */ | 6072 | */ |
| 6071 | unsigned long get_pfnblock_flags_mask(struct page *page, unsigned long pfn, | 6073 | unsigned long get_pfnblock_flags_mask(struct page *page, unsigned long pfn, |
| 6072 | unsigned long end_bitidx, | 6074 | unsigned long end_bitidx, |
| @@ -6091,9 +6093,10 @@ unsigned long get_pfnblock_flags_mask(struct page *page, unsigned long pfn, | |||
| 6091 | /** | 6093 | /** |
| 6092 | * set_pfnblock_flags_mask - Set the requested group of flags for a pageblock_nr_pages block of pages | 6094 | * set_pfnblock_flags_mask - Set the requested group of flags for a pageblock_nr_pages block of pages |
| 6093 | * @page: The page within the block of interest | 6095 | * @page: The page within the block of interest |
| 6094 | * @start_bitidx: The first bit of interest | ||
| 6095 | * @end_bitidx: The last bit of interest | ||
| 6096 | * @flags: The flags to set | 6096 | * @flags: The flags to set |
| 6097 | * @pfn: The target page frame number | ||
| 6098 | * @end_bitidx: The last bit of interest | ||
| 6099 | * @mask: mask of bits that the caller is interested in | ||
| 6097 | */ | 6100 | */ |
| 6098 | void set_pfnblock_flags_mask(struct page *page, unsigned long flags, | 6101 | void set_pfnblock_flags_mask(struct page *page, unsigned long flags, |
| 6099 | unsigned long pfn, | 6102 | unsigned long pfn, |
| @@ -517,11 +517,7 @@ void page_unlock_anon_vma_read(struct anon_vma *anon_vma) | |||
| 517 | static inline unsigned long | 517 | static inline unsigned long |
| 518 | __vma_address(struct page *page, struct vm_area_struct *vma) | 518 | __vma_address(struct page *page, struct vm_area_struct *vma) |
| 519 | { | 519 | { |
| 520 | pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); | 520 | pgoff_t pgoff = page_to_pgoff(page); |
| 521 | |||
| 522 | if (unlikely(is_vm_hugetlb_page(vma))) | ||
| 523 | pgoff = page->index << huge_page_order(page_hstate(page)); | ||
| 524 | |||
| 525 | return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); | 521 | return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT); |
| 526 | } | 522 | } |
| 527 | 523 | ||
| @@ -1639,7 +1635,7 @@ static struct anon_vma *rmap_walk_anon_lock(struct page *page, | |||
| 1639 | static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc) | 1635 | static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc) |
| 1640 | { | 1636 | { |
| 1641 | struct anon_vma *anon_vma; | 1637 | struct anon_vma *anon_vma; |
| 1642 | pgoff_t pgoff = page->index << (PAGE_CACHE_SHIFT - PAGE_SHIFT); | 1638 | pgoff_t pgoff = page_to_pgoff(page); |
| 1643 | struct anon_vma_chain *avc; | 1639 | struct anon_vma_chain *avc; |
| 1644 | int ret = SWAP_AGAIN; | 1640 | int ret = SWAP_AGAIN; |
| 1645 | 1641 | ||
| @@ -1680,7 +1676,7 @@ static int rmap_walk_anon(struct page *page, struct rmap_walk_control *rwc) | |||
| 1680 | static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc) | 1676 | static int rmap_walk_file(struct page *page, struct rmap_walk_control *rwc) |
| 1681 | { | 1677 | { |
| 1682 | struct address_space *mapping = page->mapping; | 1678 | struct address_space *mapping = page->mapping; |
| 1683 | pgoff_t pgoff = page->index << compound_order(page); | 1679 | pgoff_t pgoff = page_to_pgoff(page); |
| 1684 | struct vm_area_struct *vma; | 1680 | struct vm_area_struct *vma; |
| 1685 | int ret = SWAP_AGAIN; | 1681 | int ret = SWAP_AGAIN; |
| 1686 | 1682 | ||
diff --git a/mm/shmem.c b/mm/shmem.c index 1140f49b6ded..af68b15a8fc1 100644 --- a/mm/shmem.c +++ b/mm/shmem.c | |||
| @@ -85,7 +85,7 @@ static struct vfsmount *shm_mnt; | |||
| 85 | * a time): we would prefer not to enlarge the shmem inode just for that. | 85 | * a time): we would prefer not to enlarge the shmem inode just for that. |
| 86 | */ | 86 | */ |
| 87 | struct shmem_falloc { | 87 | struct shmem_falloc { |
| 88 | int mode; /* FALLOC_FL mode currently operating */ | 88 | wait_queue_head_t *waitq; /* faults into hole wait for punch to end */ |
| 89 | pgoff_t start; /* start of range currently being fallocated */ | 89 | pgoff_t start; /* start of range currently being fallocated */ |
| 90 | pgoff_t next; /* the next page offset to be fallocated */ | 90 | pgoff_t next; /* the next page offset to be fallocated */ |
| 91 | pgoff_t nr_falloced; /* how many new pages have been fallocated */ | 91 | pgoff_t nr_falloced; /* how many new pages have been fallocated */ |
| @@ -468,23 +468,20 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, | |||
| 468 | return; | 468 | return; |
| 469 | 469 | ||
| 470 | index = start; | 470 | index = start; |
| 471 | for ( ; ; ) { | 471 | while (index < end) { |
| 472 | cond_resched(); | 472 | cond_resched(); |
| 473 | 473 | ||
| 474 | pvec.nr = find_get_entries(mapping, index, | 474 | pvec.nr = find_get_entries(mapping, index, |
| 475 | min(end - index, (pgoff_t)PAGEVEC_SIZE), | 475 | min(end - index, (pgoff_t)PAGEVEC_SIZE), |
| 476 | pvec.pages, indices); | 476 | pvec.pages, indices); |
| 477 | if (!pvec.nr) { | 477 | if (!pvec.nr) { |
| 478 | if (index == start || unfalloc) | 478 | /* If all gone or hole-punch or unfalloc, we're done */ |
| 479 | if (index == start || end != -1) | ||
| 479 | break; | 480 | break; |
| 481 | /* But if truncating, restart to make sure all gone */ | ||
| 480 | index = start; | 482 | index = start; |
| 481 | continue; | 483 | continue; |
| 482 | } | 484 | } |
| 483 | if ((index == start || unfalloc) && indices[0] >= end) { | ||
| 484 | pagevec_remove_exceptionals(&pvec); | ||
| 485 | pagevec_release(&pvec); | ||
| 486 | break; | ||
| 487 | } | ||
| 488 | mem_cgroup_uncharge_start(); | 485 | mem_cgroup_uncharge_start(); |
| 489 | for (i = 0; i < pagevec_count(&pvec); i++) { | 486 | for (i = 0; i < pagevec_count(&pvec); i++) { |
| 490 | struct page *page = pvec.pages[i]; | 487 | struct page *page = pvec.pages[i]; |
| @@ -496,8 +493,12 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, | |||
| 496 | if (radix_tree_exceptional_entry(page)) { | 493 | if (radix_tree_exceptional_entry(page)) { |
| 497 | if (unfalloc) | 494 | if (unfalloc) |
| 498 | continue; | 495 | continue; |
| 499 | nr_swaps_freed += !shmem_free_swap(mapping, | 496 | if (shmem_free_swap(mapping, index, page)) { |
| 500 | index, page); | 497 | /* Swap was replaced by page: retry */ |
| 498 | index--; | ||
| 499 | break; | ||
| 500 | } | ||
| 501 | nr_swaps_freed++; | ||
| 501 | continue; | 502 | continue; |
| 502 | } | 503 | } |
| 503 | 504 | ||
| @@ -506,6 +507,11 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, | |||
| 506 | if (page->mapping == mapping) { | 507 | if (page->mapping == mapping) { |
| 507 | VM_BUG_ON_PAGE(PageWriteback(page), page); | 508 | VM_BUG_ON_PAGE(PageWriteback(page), page); |
| 508 | truncate_inode_page(mapping, page); | 509 | truncate_inode_page(mapping, page); |
| 510 | } else { | ||
| 511 | /* Page was replaced by swap: retry */ | ||
| 512 | unlock_page(page); | ||
| 513 | index--; | ||
| 514 | break; | ||
| 509 | } | 515 | } |
| 510 | } | 516 | } |
| 511 | unlock_page(page); | 517 | unlock_page(page); |
| @@ -760,7 +766,7 @@ static int shmem_writepage(struct page *page, struct writeback_control *wbc) | |||
| 760 | spin_lock(&inode->i_lock); | 766 | spin_lock(&inode->i_lock); |
| 761 | shmem_falloc = inode->i_private; | 767 | shmem_falloc = inode->i_private; |
| 762 | if (shmem_falloc && | 768 | if (shmem_falloc && |
| 763 | !shmem_falloc->mode && | 769 | !shmem_falloc->waitq && |
| 764 | index >= shmem_falloc->start && | 770 | index >= shmem_falloc->start && |
| 765 | index < shmem_falloc->next) | 771 | index < shmem_falloc->next) |
| 766 | shmem_falloc->nr_unswapped++; | 772 | shmem_falloc->nr_unswapped++; |
| @@ -1248,38 +1254,58 @@ static int shmem_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 1248 | * Trinity finds that probing a hole which tmpfs is punching can | 1254 | * Trinity finds that probing a hole which tmpfs is punching can |
| 1249 | * prevent the hole-punch from ever completing: which in turn | 1255 | * prevent the hole-punch from ever completing: which in turn |
| 1250 | * locks writers out with its hold on i_mutex. So refrain from | 1256 | * locks writers out with its hold on i_mutex. So refrain from |
| 1251 | * faulting pages into the hole while it's being punched, and | 1257 | * faulting pages into the hole while it's being punched. Although |
| 1252 | * wait on i_mutex to be released if vmf->flags permits. | 1258 | * shmem_undo_range() does remove the additions, it may be unable to |
| 1259 | * keep up, as each new page needs its own unmap_mapping_range() call, | ||
| 1260 | * and the i_mmap tree grows ever slower to scan if new vmas are added. | ||
| 1261 | * | ||
| 1262 | * It does not matter if we sometimes reach this check just before the | ||
| 1263 | * hole-punch begins, so that one fault then races with the punch: | ||
| 1264 | * we just need to make racing faults a rare case. | ||
| 1265 | * | ||
| 1266 | * The implementation below would be much simpler if we just used a | ||
| 1267 | * standard mutex or completion: but we cannot take i_mutex in fault, | ||
| 1268 | * and bloating every shmem inode for this unlikely case would be sad. | ||
| 1253 | */ | 1269 | */ |
| 1254 | if (unlikely(inode->i_private)) { | 1270 | if (unlikely(inode->i_private)) { |
| 1255 | struct shmem_falloc *shmem_falloc; | 1271 | struct shmem_falloc *shmem_falloc; |
| 1256 | 1272 | ||
| 1257 | spin_lock(&inode->i_lock); | 1273 | spin_lock(&inode->i_lock); |
| 1258 | shmem_falloc = inode->i_private; | 1274 | shmem_falloc = inode->i_private; |
| 1259 | if (!shmem_falloc || | 1275 | if (shmem_falloc && |
| 1260 | shmem_falloc->mode != FALLOC_FL_PUNCH_HOLE || | 1276 | shmem_falloc->waitq && |
| 1261 | vmf->pgoff < shmem_falloc->start || | 1277 | vmf->pgoff >= shmem_falloc->start && |
| 1262 | vmf->pgoff >= shmem_falloc->next) | 1278 | vmf->pgoff < shmem_falloc->next) { |
| 1263 | shmem_falloc = NULL; | 1279 | wait_queue_head_t *shmem_falloc_waitq; |
| 1264 | spin_unlock(&inode->i_lock); | 1280 | DEFINE_WAIT(shmem_fault_wait); |
| 1265 | /* | 1281 | |
| 1266 | * i_lock has protected us from taking shmem_falloc seriously | 1282 | ret = VM_FAULT_NOPAGE; |
| 1267 | * once return from shmem_fallocate() went back up that stack. | ||
| 1268 | * i_lock does not serialize with i_mutex at all, but it does | ||
| 1269 | * not matter if sometimes we wait unnecessarily, or sometimes | ||
| 1270 | * miss out on waiting: we just need to make those cases rare. | ||
| 1271 | */ | ||
| 1272 | if (shmem_falloc) { | ||
| 1273 | if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) && | 1283 | if ((vmf->flags & FAULT_FLAG_ALLOW_RETRY) && |
| 1274 | !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) { | 1284 | !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) { |
| 1285 | /* It's polite to up mmap_sem if we can */ | ||
| 1275 | up_read(&vma->vm_mm->mmap_sem); | 1286 | up_read(&vma->vm_mm->mmap_sem); |
| 1276 | mutex_lock(&inode->i_mutex); | 1287 | ret = VM_FAULT_RETRY; |
| 1277 | mutex_unlock(&inode->i_mutex); | ||
| 1278 | return VM_FAULT_RETRY; | ||
| 1279 | } | 1288 | } |
| 1280 | /* cond_resched? Leave that to GUP or return to user */ | 1289 | |
| 1281 | return VM_FAULT_NOPAGE; | 1290 | shmem_falloc_waitq = shmem_falloc->waitq; |
| 1291 | prepare_to_wait(shmem_falloc_waitq, &shmem_fault_wait, | ||
| 1292 | TASK_UNINTERRUPTIBLE); | ||
| 1293 | spin_unlock(&inode->i_lock); | ||
| 1294 | schedule(); | ||
| 1295 | |||
| 1296 | /* | ||
| 1297 | * shmem_falloc_waitq points into the shmem_fallocate() | ||
| 1298 | * stack of the hole-punching task: shmem_falloc_waitq | ||
| 1299 | * is usually invalid by the time we reach here, but | ||
| 1300 | * finish_wait() does not dereference it in that case; | ||
| 1301 | * though i_lock needed lest racing with wake_up_all(). | ||
| 1302 | */ | ||
| 1303 | spin_lock(&inode->i_lock); | ||
| 1304 | finish_wait(shmem_falloc_waitq, &shmem_fault_wait); | ||
| 1305 | spin_unlock(&inode->i_lock); | ||
| 1306 | return ret; | ||
| 1282 | } | 1307 | } |
| 1308 | spin_unlock(&inode->i_lock); | ||
| 1283 | } | 1309 | } |
| 1284 | 1310 | ||
| 1285 | error = shmem_getpage(inode, vmf->pgoff, &vmf->page, SGP_CACHE, &ret); | 1311 | error = shmem_getpage(inode, vmf->pgoff, &vmf->page, SGP_CACHE, &ret); |
| @@ -1774,13 +1800,13 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, | |||
| 1774 | 1800 | ||
| 1775 | mutex_lock(&inode->i_mutex); | 1801 | mutex_lock(&inode->i_mutex); |
| 1776 | 1802 | ||
| 1777 | shmem_falloc.mode = mode & ~FALLOC_FL_KEEP_SIZE; | ||
| 1778 | |||
| 1779 | if (mode & FALLOC_FL_PUNCH_HOLE) { | 1803 | if (mode & FALLOC_FL_PUNCH_HOLE) { |
| 1780 | struct address_space *mapping = file->f_mapping; | 1804 | struct address_space *mapping = file->f_mapping; |
| 1781 | loff_t unmap_start = round_up(offset, PAGE_SIZE); | 1805 | loff_t unmap_start = round_up(offset, PAGE_SIZE); |
| 1782 | loff_t unmap_end = round_down(offset + len, PAGE_SIZE) - 1; | 1806 | loff_t unmap_end = round_down(offset + len, PAGE_SIZE) - 1; |
| 1807 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK(shmem_falloc_waitq); | ||
| 1783 | 1808 | ||
| 1809 | shmem_falloc.waitq = &shmem_falloc_waitq; | ||
| 1784 | shmem_falloc.start = unmap_start >> PAGE_SHIFT; | 1810 | shmem_falloc.start = unmap_start >> PAGE_SHIFT; |
| 1785 | shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT; | 1811 | shmem_falloc.next = (unmap_end + 1) >> PAGE_SHIFT; |
| 1786 | spin_lock(&inode->i_lock); | 1812 | spin_lock(&inode->i_lock); |
| @@ -1792,8 +1818,13 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, | |||
| 1792 | 1 + unmap_end - unmap_start, 0); | 1818 | 1 + unmap_end - unmap_start, 0); |
| 1793 | shmem_truncate_range(inode, offset, offset + len - 1); | 1819 | shmem_truncate_range(inode, offset, offset + len - 1); |
| 1794 | /* No need to unmap again: hole-punching leaves COWed pages */ | 1820 | /* No need to unmap again: hole-punching leaves COWed pages */ |
| 1821 | |||
| 1822 | spin_lock(&inode->i_lock); | ||
| 1823 | inode->i_private = NULL; | ||
| 1824 | wake_up_all(&shmem_falloc_waitq); | ||
| 1825 | spin_unlock(&inode->i_lock); | ||
| 1795 | error = 0; | 1826 | error = 0; |
| 1796 | goto undone; | 1827 | goto out; |
| 1797 | } | 1828 | } |
| 1798 | 1829 | ||
| 1799 | /* We need to check rlimit even when FALLOC_FL_KEEP_SIZE */ | 1830 | /* We need to check rlimit even when FALLOC_FL_KEEP_SIZE */ |
| @@ -1809,6 +1840,7 @@ static long shmem_fallocate(struct file *file, int mode, loff_t offset, | |||
| 1809 | goto out; | 1840 | goto out; |
| 1810 | } | 1841 | } |
| 1811 | 1842 | ||
| 1843 | shmem_falloc.waitq = NULL; | ||
| 1812 | shmem_falloc.start = start; | 1844 | shmem_falloc.start = start; |
| 1813 | shmem_falloc.next = start; | 1845 | shmem_falloc.next = start; |
| 1814 | shmem_falloc.nr_falloced = 0; | 1846 | shmem_falloc.nr_falloced = 0; |
diff --git a/mm/slab_common.c b/mm/slab_common.c index 735e01a0db6f..d31c4bacc6a2 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
| @@ -55,7 +55,7 @@ static int kmem_cache_sanity_check(const char *name, size_t size) | |||
| 55 | continue; | 55 | continue; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | #if !defined(CONFIG_SLUB) || !defined(CONFIG_SLUB_DEBUG_ON) | 58 | #if !defined(CONFIG_SLUB) |
| 59 | if (!strcmp(s->name, name)) { | 59 | if (!strcmp(s->name, name)) { |
| 60 | pr_err("%s (%s): Cache name already exists.\n", | 60 | pr_err("%s (%s): Cache name already exists.\n", |
| 61 | __func__, name); | 61 | __func__, name); |
diff --git a/mm/truncate.c b/mm/truncate.c index 6a78c814bebf..eda247307164 100644 --- a/mm/truncate.c +++ b/mm/truncate.c | |||
| @@ -355,14 +355,16 @@ void truncate_inode_pages_range(struct address_space *mapping, | |||
| 355 | for ( ; ; ) { | 355 | for ( ; ; ) { |
| 356 | cond_resched(); | 356 | cond_resched(); |
| 357 | if (!pagevec_lookup_entries(&pvec, mapping, index, | 357 | if (!pagevec_lookup_entries(&pvec, mapping, index, |
| 358 | min(end - index, (pgoff_t)PAGEVEC_SIZE), | 358 | min(end - index, (pgoff_t)PAGEVEC_SIZE), indices)) { |
| 359 | indices)) { | 359 | /* If all gone from start onwards, we're done */ |
| 360 | if (index == start) | 360 | if (index == start) |
| 361 | break; | 361 | break; |
| 362 | /* Otherwise restart to make sure all gone */ | ||
| 362 | index = start; | 363 | index = start; |
| 363 | continue; | 364 | continue; |
| 364 | } | 365 | } |
| 365 | if (index == start && indices[0] >= end) { | 366 | if (index == start && indices[0] >= end) { |
| 367 | /* All gone out of hole to be punched, we're done */ | ||
| 366 | pagevec_remove_exceptionals(&pvec); | 368 | pagevec_remove_exceptionals(&pvec); |
| 367 | pagevec_release(&pvec); | 369 | pagevec_release(&pvec); |
| 368 | break; | 370 | break; |
| @@ -373,8 +375,11 @@ void truncate_inode_pages_range(struct address_space *mapping, | |||
| 373 | 375 | ||
| 374 | /* We rely upon deletion not changing page->index */ | 376 | /* We rely upon deletion not changing page->index */ |
| 375 | index = indices[i]; | 377 | index = indices[i]; |
| 376 | if (index >= end) | 378 | if (index >= end) { |
| 379 | /* Restart punch to make sure all gone */ | ||
| 380 | index = start - 1; | ||
| 377 | break; | 381 | break; |
| 382 | } | ||
| 378 | 383 | ||
| 379 | if (radix_tree_exceptional_entry(page)) { | 384 | if (radix_tree_exceptional_entry(page)) { |
| 380 | clear_exceptional_entry(mapping, index, page); | 385 | clear_exceptional_entry(mapping, index, page); |
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c index ad2ac3c00398..dd11f612e03e 100644 --- a/net/8021q/vlan_dev.c +++ b/net/8021q/vlan_dev.c | |||
| @@ -627,8 +627,6 @@ static void vlan_dev_uninit(struct net_device *dev) | |||
| 627 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); | 627 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); |
| 628 | int i; | 628 | int i; |
| 629 | 629 | ||
| 630 | free_percpu(vlan->vlan_pcpu_stats); | ||
| 631 | vlan->vlan_pcpu_stats = NULL; | ||
| 632 | for (i = 0; i < ARRAY_SIZE(vlan->egress_priority_map); i++) { | 630 | for (i = 0; i < ARRAY_SIZE(vlan->egress_priority_map); i++) { |
| 633 | while ((pm = vlan->egress_priority_map[i]) != NULL) { | 631 | while ((pm = vlan->egress_priority_map[i]) != NULL) { |
| 634 | vlan->egress_priority_map[i] = pm->next; | 632 | vlan->egress_priority_map[i] = pm->next; |
| @@ -785,6 +783,15 @@ static const struct net_device_ops vlan_netdev_ops = { | |||
| 785 | .ndo_get_lock_subclass = vlan_dev_get_lock_subclass, | 783 | .ndo_get_lock_subclass = vlan_dev_get_lock_subclass, |
| 786 | }; | 784 | }; |
| 787 | 785 | ||
| 786 | static void vlan_dev_free(struct net_device *dev) | ||
| 787 | { | ||
| 788 | struct vlan_dev_priv *vlan = vlan_dev_priv(dev); | ||
| 789 | |||
| 790 | free_percpu(vlan->vlan_pcpu_stats); | ||
| 791 | vlan->vlan_pcpu_stats = NULL; | ||
| 792 | free_netdev(dev); | ||
| 793 | } | ||
| 794 | |||
| 788 | void vlan_setup(struct net_device *dev) | 795 | void vlan_setup(struct net_device *dev) |
| 789 | { | 796 | { |
| 790 | ether_setup(dev); | 797 | ether_setup(dev); |
| @@ -794,7 +801,7 @@ void vlan_setup(struct net_device *dev) | |||
| 794 | dev->tx_queue_len = 0; | 801 | dev->tx_queue_len = 0; |
| 795 | 802 | ||
| 796 | dev->netdev_ops = &vlan_netdev_ops; | 803 | dev->netdev_ops = &vlan_netdev_ops; |
| 797 | dev->destructor = free_netdev; | 804 | dev->destructor = vlan_dev_free; |
| 798 | dev->ethtool_ops = &vlan_ethtool_ops; | 805 | dev->ethtool_ops = &vlan_ethtool_ops; |
| 799 | 806 | ||
| 800 | memset(dev->broadcast, 0, ETH_ALEN); | 807 | memset(dev->broadcast, 0, ETH_ALEN); |
diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c index 01a1082e02b3..bfcf6be1d665 100644 --- a/net/appletalk/ddp.c +++ b/net/appletalk/ddp.c | |||
| @@ -1489,8 +1489,6 @@ static int atalk_rcv(struct sk_buff *skb, struct net_device *dev, | |||
| 1489 | goto drop; | 1489 | goto drop; |
| 1490 | 1490 | ||
| 1491 | /* Queue packet (standard) */ | 1491 | /* Queue packet (standard) */ |
| 1492 | skb->sk = sock; | ||
| 1493 | |||
| 1494 | if (sock_queue_rcv_skb(sock, skb) < 0) | 1492 | if (sock_queue_rcv_skb(sock, skb) < 0) |
| 1495 | goto drop; | 1493 | goto drop; |
| 1496 | 1494 | ||
| @@ -1644,7 +1642,6 @@ static int atalk_sendmsg(struct kiocb *iocb, struct socket *sock, struct msghdr | |||
| 1644 | if (!skb) | 1642 | if (!skb) |
| 1645 | goto out; | 1643 | goto out; |
| 1646 | 1644 | ||
| 1647 | skb->sk = sk; | ||
| 1648 | skb_reserve(skb, ddp_dl->header_length); | 1645 | skb_reserve(skb, ddp_dl->header_length); |
| 1649 | skb_reserve(skb, dev->hard_header_len); | 1646 | skb_reserve(skb, dev->hard_header_len); |
| 1650 | skb->dev = dev; | 1647 | skb->dev = dev; |
diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index 6f0d9ec37950..a957c8140721 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c | |||
| @@ -800,11 +800,6 @@ static int batadv_check_claim_group(struct batadv_priv *bat_priv, | |||
| 800 | bla_dst = (struct batadv_bla_claim_dst *)hw_dst; | 800 | bla_dst = (struct batadv_bla_claim_dst *)hw_dst; |
| 801 | bla_dst_own = &bat_priv->bla.claim_dest; | 801 | bla_dst_own = &bat_priv->bla.claim_dest; |
| 802 | 802 | ||
| 803 | /* check if it is a claim packet in general */ | ||
| 804 | if (memcmp(bla_dst->magic, bla_dst_own->magic, | ||
| 805 | sizeof(bla_dst->magic)) != 0) | ||
| 806 | return 0; | ||
| 807 | |||
| 808 | /* if announcement packet, use the source, | 803 | /* if announcement packet, use the source, |
| 809 | * otherwise assume it is in the hw_src | 804 | * otherwise assume it is in the hw_src |
| 810 | */ | 805 | */ |
| @@ -866,12 +861,13 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, | |||
| 866 | struct batadv_hard_iface *primary_if, | 861 | struct batadv_hard_iface *primary_if, |
| 867 | struct sk_buff *skb) | 862 | struct sk_buff *skb) |
| 868 | { | 863 | { |
| 869 | struct batadv_bla_claim_dst *bla_dst; | 864 | struct batadv_bla_claim_dst *bla_dst, *bla_dst_own; |
| 870 | uint8_t *hw_src, *hw_dst; | 865 | uint8_t *hw_src, *hw_dst; |
| 871 | struct vlan_ethhdr *vhdr; | 866 | struct vlan_hdr *vhdr, vhdr_buf; |
| 872 | struct ethhdr *ethhdr; | 867 | struct ethhdr *ethhdr; |
| 873 | struct arphdr *arphdr; | 868 | struct arphdr *arphdr; |
| 874 | unsigned short vid; | 869 | unsigned short vid; |
| 870 | int vlan_depth = 0; | ||
| 875 | __be16 proto; | 871 | __be16 proto; |
| 876 | int headlen; | 872 | int headlen; |
| 877 | int ret; | 873 | int ret; |
| @@ -882,9 +878,24 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, | |||
| 882 | proto = ethhdr->h_proto; | 878 | proto = ethhdr->h_proto; |
| 883 | headlen = ETH_HLEN; | 879 | headlen = ETH_HLEN; |
| 884 | if (vid & BATADV_VLAN_HAS_TAG) { | 880 | if (vid & BATADV_VLAN_HAS_TAG) { |
| 885 | vhdr = vlan_eth_hdr(skb); | 881 | /* Traverse the VLAN/Ethertypes. |
| 886 | proto = vhdr->h_vlan_encapsulated_proto; | 882 | * |
| 887 | headlen += VLAN_HLEN; | 883 | * At this point it is known that the first protocol is a VLAN |
| 884 | * header, so start checking at the encapsulated protocol. | ||
| 885 | * | ||
| 886 | * The depth of the VLAN headers is recorded to drop BLA claim | ||
| 887 | * frames encapsulated into multiple VLAN headers (QinQ). | ||
| 888 | */ | ||
| 889 | do { | ||
| 890 | vhdr = skb_header_pointer(skb, headlen, VLAN_HLEN, | ||
| 891 | &vhdr_buf); | ||
| 892 | if (!vhdr) | ||
| 893 | return 0; | ||
| 894 | |||
| 895 | proto = vhdr->h_vlan_encapsulated_proto; | ||
| 896 | headlen += VLAN_HLEN; | ||
| 897 | vlan_depth++; | ||
| 898 | } while (proto == htons(ETH_P_8021Q)); | ||
| 888 | } | 899 | } |
| 889 | 900 | ||
| 890 | if (proto != htons(ETH_P_ARP)) | 901 | if (proto != htons(ETH_P_ARP)) |
| @@ -914,6 +925,19 @@ static int batadv_bla_process_claim(struct batadv_priv *bat_priv, | |||
| 914 | hw_src = (uint8_t *)arphdr + sizeof(struct arphdr); | 925 | hw_src = (uint8_t *)arphdr + sizeof(struct arphdr); |
| 915 | hw_dst = hw_src + ETH_ALEN + 4; | 926 | hw_dst = hw_src + ETH_ALEN + 4; |
| 916 | bla_dst = (struct batadv_bla_claim_dst *)hw_dst; | 927 | bla_dst = (struct batadv_bla_claim_dst *)hw_dst; |
| 928 | bla_dst_own = &bat_priv->bla.claim_dest; | ||
| 929 | |||
| 930 | /* check if it is a claim frame in general */ | ||
| 931 | if (memcmp(bla_dst->magic, bla_dst_own->magic, | ||
| 932 | sizeof(bla_dst->magic)) != 0) | ||
| 933 | return 0; | ||
| 934 | |||
| 935 | /* check if there is a claim frame encapsulated deeper in (QinQ) and | ||
| 936 | * drop that, as this is not supported by BLA but should also not be | ||
| 937 | * sent via the mesh. | ||
| 938 | */ | ||
| 939 | if (vlan_depth > 1) | ||
| 940 | return 1; | ||
| 917 | 941 | ||
| 918 | /* check if it is a claim frame. */ | 942 | /* check if it is a claim frame. */ |
| 919 | ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst, | 943 | ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst, |
diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index e7ee65dc20bf..cbd677f48c00 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c | |||
| @@ -448,10 +448,15 @@ out: | |||
| 448 | * possibly free it | 448 | * possibly free it |
| 449 | * @softif_vlan: the vlan object to release | 449 | * @softif_vlan: the vlan object to release |
| 450 | */ | 450 | */ |
| 451 | void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *softif_vlan) | 451 | void batadv_softif_vlan_free_ref(struct batadv_softif_vlan *vlan) |
| 452 | { | 452 | { |
| 453 | if (atomic_dec_and_test(&softif_vlan->refcount)) | 453 | if (atomic_dec_and_test(&vlan->refcount)) { |
| 454 | kfree_rcu(softif_vlan, rcu); | 454 | spin_lock_bh(&vlan->bat_priv->softif_vlan_list_lock); |
| 455 | hlist_del_rcu(&vlan->list); | ||
| 456 | spin_unlock_bh(&vlan->bat_priv->softif_vlan_list_lock); | ||
| 457 | |||
| 458 | kfree_rcu(vlan, rcu); | ||
| 459 | } | ||
| 455 | } | 460 | } |
| 456 | 461 | ||
| 457 | /** | 462 | /** |
| @@ -505,6 +510,7 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) | |||
| 505 | if (!vlan) | 510 | if (!vlan) |
| 506 | return -ENOMEM; | 511 | return -ENOMEM; |
| 507 | 512 | ||
| 513 | vlan->bat_priv = bat_priv; | ||
| 508 | vlan->vid = vid; | 514 | vlan->vid = vid; |
| 509 | atomic_set(&vlan->refcount, 1); | 515 | atomic_set(&vlan->refcount, 1); |
| 510 | 516 | ||
| @@ -516,6 +522,10 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) | |||
| 516 | return err; | 522 | return err; |
| 517 | } | 523 | } |
| 518 | 524 | ||
| 525 | spin_lock_bh(&bat_priv->softif_vlan_list_lock); | ||
| 526 | hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); | ||
| 527 | spin_unlock_bh(&bat_priv->softif_vlan_list_lock); | ||
| 528 | |||
| 519 | /* add a new TT local entry. This one will be marked with the NOPURGE | 529 | /* add a new TT local entry. This one will be marked with the NOPURGE |
| 520 | * flag | 530 | * flag |
| 521 | */ | 531 | */ |
| @@ -523,10 +533,6 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) | |||
| 523 | bat_priv->soft_iface->dev_addr, vid, | 533 | bat_priv->soft_iface->dev_addr, vid, |
| 524 | BATADV_NULL_IFINDEX, BATADV_NO_MARK); | 534 | BATADV_NULL_IFINDEX, BATADV_NO_MARK); |
| 525 | 535 | ||
| 526 | spin_lock_bh(&bat_priv->softif_vlan_list_lock); | ||
| 527 | hlist_add_head_rcu(&vlan->list, &bat_priv->softif_vlan_list); | ||
| 528 | spin_unlock_bh(&bat_priv->softif_vlan_list_lock); | ||
| 529 | |||
| 530 | return 0; | 536 | return 0; |
| 531 | } | 537 | } |
| 532 | 538 | ||
| @@ -538,18 +544,13 @@ int batadv_softif_create_vlan(struct batadv_priv *bat_priv, unsigned short vid) | |||
| 538 | static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv, | 544 | static void batadv_softif_destroy_vlan(struct batadv_priv *bat_priv, |
| 539 | struct batadv_softif_vlan *vlan) | 545 | struct batadv_softif_vlan *vlan) |
| 540 | { | 546 | { |
| 541 | spin_lock_bh(&bat_priv->softif_vlan_list_lock); | ||
| 542 | hlist_del_rcu(&vlan->list); | ||
| 543 | spin_unlock_bh(&bat_priv->softif_vlan_list_lock); | ||
| 544 | |||
| 545 | batadv_sysfs_del_vlan(bat_priv, vlan); | ||
| 546 | |||
| 547 | /* explicitly remove the associated TT local entry because it is marked | 547 | /* explicitly remove the associated TT local entry because it is marked |
| 548 | * with the NOPURGE flag | 548 | * with the NOPURGE flag |
| 549 | */ | 549 | */ |
| 550 | batadv_tt_local_remove(bat_priv, bat_priv->soft_iface->dev_addr, | 550 | batadv_tt_local_remove(bat_priv, bat_priv->soft_iface->dev_addr, |
| 551 | vlan->vid, "vlan interface destroyed", false); | 551 | vlan->vid, "vlan interface destroyed", false); |
| 552 | 552 | ||
| 553 | batadv_sysfs_del_vlan(bat_priv, vlan); | ||
| 553 | batadv_softif_vlan_free_ref(vlan); | 554 | batadv_softif_vlan_free_ref(vlan); |
| 554 | } | 555 | } |
| 555 | 556 | ||
| @@ -567,6 +568,8 @@ static int batadv_interface_add_vid(struct net_device *dev, __be16 proto, | |||
| 567 | unsigned short vid) | 568 | unsigned short vid) |
| 568 | { | 569 | { |
| 569 | struct batadv_priv *bat_priv = netdev_priv(dev); | 570 | struct batadv_priv *bat_priv = netdev_priv(dev); |
| 571 | struct batadv_softif_vlan *vlan; | ||
| 572 | int ret; | ||
| 570 | 573 | ||
| 571 | /* only 802.1Q vlans are supported. | 574 | /* only 802.1Q vlans are supported. |
| 572 | * batman-adv does not know how to handle other types | 575 | * batman-adv does not know how to handle other types |
| @@ -576,7 +579,36 @@ static int batadv_interface_add_vid(struct net_device *dev, __be16 proto, | |||
| 576 | 579 | ||
| 577 | vid |= BATADV_VLAN_HAS_TAG; | 580 | vid |= BATADV_VLAN_HAS_TAG; |
| 578 | 581 | ||
| 579 | return batadv_softif_create_vlan(bat_priv, vid); | 582 | /* if a new vlan is getting created and it already exists, it means that |
| 583 | * it was not deleted yet. batadv_softif_vlan_get() increases the | ||
| 584 | * refcount in order to revive the object. | ||
| 585 | * | ||
| 586 | * if it does not exist then create it. | ||
| 587 | */ | ||
| 588 | vlan = batadv_softif_vlan_get(bat_priv, vid); | ||
| 589 | if (!vlan) | ||
| 590 | return batadv_softif_create_vlan(bat_priv, vid); | ||
| 591 | |||
| 592 | /* recreate the sysfs object if it was already destroyed (and it should | ||
| 593 | * be since we received a kill_vid() for this vlan | ||
| 594 | */ | ||
| 595 | if (!vlan->kobj) { | ||
| 596 | ret = batadv_sysfs_add_vlan(bat_priv->soft_iface, vlan); | ||
| 597 | if (ret) { | ||
| 598 | batadv_softif_vlan_free_ref(vlan); | ||
| 599 | return ret; | ||
| 600 | } | ||
| 601 | } | ||
| 602 | |||
| 603 | /* add a new TT local entry. This one will be marked with the NOPURGE | ||
| 604 | * flag. This must be added again, even if the vlan object already | ||
| 605 | * exists, because the entry was deleted by kill_vid() | ||
| 606 | */ | ||
| 607 | batadv_tt_local_add(bat_priv->soft_iface, | ||
| 608 | bat_priv->soft_iface->dev_addr, vid, | ||
| 609 | BATADV_NULL_IFINDEX, BATADV_NO_MARK); | ||
| 610 | |||
| 611 | return 0; | ||
| 580 | } | 612 | } |
| 581 | 613 | ||
| 582 | /** | 614 | /** |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index d636bde72c9a..5f59e7f899a0 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
| @@ -511,6 +511,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
| 511 | struct batadv_priv *bat_priv = netdev_priv(soft_iface); | 511 | struct batadv_priv *bat_priv = netdev_priv(soft_iface); |
| 512 | struct batadv_tt_local_entry *tt_local; | 512 | struct batadv_tt_local_entry *tt_local; |
| 513 | struct batadv_tt_global_entry *tt_global = NULL; | 513 | struct batadv_tt_global_entry *tt_global = NULL; |
| 514 | struct batadv_softif_vlan *vlan; | ||
| 514 | struct net_device *in_dev = NULL; | 515 | struct net_device *in_dev = NULL; |
| 515 | struct hlist_head *head; | 516 | struct hlist_head *head; |
| 516 | struct batadv_tt_orig_list_entry *orig_entry; | 517 | struct batadv_tt_orig_list_entry *orig_entry; |
| @@ -572,6 +573,9 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
| 572 | if (!tt_local) | 573 | if (!tt_local) |
| 573 | goto out; | 574 | goto out; |
| 574 | 575 | ||
| 576 | /* increase the refcounter of the related vlan */ | ||
| 577 | vlan = batadv_softif_vlan_get(bat_priv, vid); | ||
| 578 | |||
| 575 | batadv_dbg(BATADV_DBG_TT, bat_priv, | 579 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
| 576 | "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n", | 580 | "Creating new local tt entry: %pM (vid: %d, ttvn: %d)\n", |
| 577 | addr, BATADV_PRINT_VID(vid), | 581 | addr, BATADV_PRINT_VID(vid), |
| @@ -604,6 +608,7 @@ bool batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
| 604 | if (unlikely(hash_added != 0)) { | 608 | if (unlikely(hash_added != 0)) { |
| 605 | /* remove the reference for the hash */ | 609 | /* remove the reference for the hash */ |
| 606 | batadv_tt_local_entry_free_ref(tt_local); | 610 | batadv_tt_local_entry_free_ref(tt_local); |
| 611 | batadv_softif_vlan_free_ref(vlan); | ||
| 607 | goto out; | 612 | goto out; |
| 608 | } | 613 | } |
| 609 | 614 | ||
| @@ -1009,6 +1014,7 @@ uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, | |||
| 1009 | { | 1014 | { |
| 1010 | struct batadv_tt_local_entry *tt_local_entry; | 1015 | struct batadv_tt_local_entry *tt_local_entry; |
| 1011 | uint16_t flags, curr_flags = BATADV_NO_FLAGS; | 1016 | uint16_t flags, curr_flags = BATADV_NO_FLAGS; |
| 1017 | struct batadv_softif_vlan *vlan; | ||
| 1012 | 1018 | ||
| 1013 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid); | 1019 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid); |
| 1014 | if (!tt_local_entry) | 1020 | if (!tt_local_entry) |
| @@ -1039,6 +1045,11 @@ uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, | |||
| 1039 | hlist_del_rcu(&tt_local_entry->common.hash_entry); | 1045 | hlist_del_rcu(&tt_local_entry->common.hash_entry); |
| 1040 | batadv_tt_local_entry_free_ref(tt_local_entry); | 1046 | batadv_tt_local_entry_free_ref(tt_local_entry); |
| 1041 | 1047 | ||
| 1048 | /* decrease the reference held for this vlan */ | ||
| 1049 | vlan = batadv_softif_vlan_get(bat_priv, vid); | ||
| 1050 | batadv_softif_vlan_free_ref(vlan); | ||
| 1051 | batadv_softif_vlan_free_ref(vlan); | ||
| 1052 | |||
| 1042 | out: | 1053 | out: |
| 1043 | if (tt_local_entry) | 1054 | if (tt_local_entry) |
| 1044 | batadv_tt_local_entry_free_ref(tt_local_entry); | 1055 | batadv_tt_local_entry_free_ref(tt_local_entry); |
| @@ -1111,6 +1122,7 @@ static void batadv_tt_local_table_free(struct batadv_priv *bat_priv) | |||
| 1111 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 1122 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
| 1112 | struct batadv_tt_common_entry *tt_common_entry; | 1123 | struct batadv_tt_common_entry *tt_common_entry; |
| 1113 | struct batadv_tt_local_entry *tt_local; | 1124 | struct batadv_tt_local_entry *tt_local; |
| 1125 | struct batadv_softif_vlan *vlan; | ||
| 1114 | struct hlist_node *node_tmp; | 1126 | struct hlist_node *node_tmp; |
| 1115 | struct hlist_head *head; | 1127 | struct hlist_head *head; |
| 1116 | uint32_t i; | 1128 | uint32_t i; |
| @@ -1131,6 +1143,13 @@ static void batadv_tt_local_table_free(struct batadv_priv *bat_priv) | |||
| 1131 | tt_local = container_of(tt_common_entry, | 1143 | tt_local = container_of(tt_common_entry, |
| 1132 | struct batadv_tt_local_entry, | 1144 | struct batadv_tt_local_entry, |
| 1133 | common); | 1145 | common); |
| 1146 | |||
| 1147 | /* decrease the reference held for this vlan */ | ||
| 1148 | vlan = batadv_softif_vlan_get(bat_priv, | ||
| 1149 | tt_common_entry->vid); | ||
| 1150 | batadv_softif_vlan_free_ref(vlan); | ||
| 1151 | batadv_softif_vlan_free_ref(vlan); | ||
| 1152 | |||
| 1134 | batadv_tt_local_entry_free_ref(tt_local); | 1153 | batadv_tt_local_entry_free_ref(tt_local); |
| 1135 | } | 1154 | } |
| 1136 | spin_unlock_bh(list_lock); | 1155 | spin_unlock_bh(list_lock); |
| @@ -3139,6 +3158,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) | |||
| 3139 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; | 3158 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; |
| 3140 | struct batadv_tt_common_entry *tt_common; | 3159 | struct batadv_tt_common_entry *tt_common; |
| 3141 | struct batadv_tt_local_entry *tt_local; | 3160 | struct batadv_tt_local_entry *tt_local; |
| 3161 | struct batadv_softif_vlan *vlan; | ||
| 3142 | struct hlist_node *node_tmp; | 3162 | struct hlist_node *node_tmp; |
| 3143 | struct hlist_head *head; | 3163 | struct hlist_head *head; |
| 3144 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 3164 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
| @@ -3167,6 +3187,12 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) | |||
| 3167 | tt_local = container_of(tt_common, | 3187 | tt_local = container_of(tt_common, |
| 3168 | struct batadv_tt_local_entry, | 3188 | struct batadv_tt_local_entry, |
| 3169 | common); | 3189 | common); |
| 3190 | |||
| 3191 | /* decrease the reference held for this vlan */ | ||
| 3192 | vlan = batadv_softif_vlan_get(bat_priv, tt_common->vid); | ||
| 3193 | batadv_softif_vlan_free_ref(vlan); | ||
| 3194 | batadv_softif_vlan_free_ref(vlan); | ||
| 3195 | |||
| 3170 | batadv_tt_local_entry_free_ref(tt_local); | 3196 | batadv_tt_local_entry_free_ref(tt_local); |
| 3171 | } | 3197 | } |
| 3172 | spin_unlock_bh(list_lock); | 3198 | spin_unlock_bh(list_lock); |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 34891a56773f..8854c05622a9 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
| @@ -687,6 +687,7 @@ struct batadv_priv_nc { | |||
| 687 | 687 | ||
| 688 | /** | 688 | /** |
| 689 | * struct batadv_softif_vlan - per VLAN attributes set | 689 | * struct batadv_softif_vlan - per VLAN attributes set |
| 690 | * @bat_priv: pointer to the mesh object | ||
| 690 | * @vid: VLAN identifier | 691 | * @vid: VLAN identifier |
| 691 | * @kobj: kobject for sysfs vlan subdirectory | 692 | * @kobj: kobject for sysfs vlan subdirectory |
| 692 | * @ap_isolation: AP isolation state | 693 | * @ap_isolation: AP isolation state |
| @@ -696,6 +697,7 @@ struct batadv_priv_nc { | |||
| 696 | * @rcu: struct used for freeing in a RCU-safe manner | 697 | * @rcu: struct used for freeing in a RCU-safe manner |
| 697 | */ | 698 | */ |
| 698 | struct batadv_softif_vlan { | 699 | struct batadv_softif_vlan { |
| 700 | struct batadv_priv *bat_priv; | ||
| 699 | unsigned short vid; | 701 | unsigned short vid; |
| 700 | struct kobject *kobj; | 702 | struct kobject *kobj; |
| 701 | atomic_t ap_isolation; /* boolean */ | 703 | atomic_t ap_isolation; /* boolean */ |
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c index ca01d1861854..a7a27bc2c0b1 100644 --- a/net/bluetooth/hci_conn.c +++ b/net/bluetooth/hci_conn.c | |||
| @@ -289,10 +289,20 @@ static void hci_conn_timeout(struct work_struct *work) | |||
| 289 | { | 289 | { |
| 290 | struct hci_conn *conn = container_of(work, struct hci_conn, | 290 | struct hci_conn *conn = container_of(work, struct hci_conn, |
| 291 | disc_work.work); | 291 | disc_work.work); |
| 292 | int refcnt = atomic_read(&conn->refcnt); | ||
| 292 | 293 | ||
| 293 | BT_DBG("hcon %p state %s", conn, state_to_string(conn->state)); | 294 | BT_DBG("hcon %p state %s", conn, state_to_string(conn->state)); |
| 294 | 295 | ||
| 295 | if (atomic_read(&conn->refcnt)) | 296 | WARN_ON(refcnt < 0); |
| 297 | |||
| 298 | /* FIXME: It was observed that in pairing failed scenario, refcnt | ||
| 299 | * drops below 0. Probably this is because l2cap_conn_del calls | ||
| 300 | * l2cap_chan_del for each channel, and inside l2cap_chan_del conn is | ||
| 301 | * dropped. After that loop hci_chan_del is called which also drops | ||
| 302 | * conn. For now make sure that ACL is alive if refcnt is higher then 0, | ||
| 303 | * otherwise drop it. | ||
| 304 | */ | ||
| 305 | if (refcnt > 0) | ||
| 296 | return; | 306 | return; |
| 297 | 307 | ||
| 298 | switch (conn->state) { | 308 | switch (conn->state) { |
diff --git a/net/bluetooth/smp.c b/net/bluetooth/smp.c index f2829a7932e2..e33a982161c1 100644 --- a/net/bluetooth/smp.c +++ b/net/bluetooth/smp.c | |||
| @@ -385,6 +385,16 @@ static const u8 gen_method[5][5] = { | |||
| 385 | { CFM_PASSKEY, CFM_PASSKEY, REQ_PASSKEY, JUST_WORKS, OVERLAP }, | 385 | { CFM_PASSKEY, CFM_PASSKEY, REQ_PASSKEY, JUST_WORKS, OVERLAP }, |
| 386 | }; | 386 | }; |
| 387 | 387 | ||
| 388 | static u8 get_auth_method(struct smp_chan *smp, u8 local_io, u8 remote_io) | ||
| 389 | { | ||
| 390 | /* If either side has unknown io_caps, use JUST WORKS */ | ||
| 391 | if (local_io > SMP_IO_KEYBOARD_DISPLAY || | ||
| 392 | remote_io > SMP_IO_KEYBOARD_DISPLAY) | ||
| 393 | return JUST_WORKS; | ||
| 394 | |||
| 395 | return gen_method[remote_io][local_io]; | ||
| 396 | } | ||
| 397 | |||
| 388 | static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, | 398 | static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, |
| 389 | u8 local_io, u8 remote_io) | 399 | u8 local_io, u8 remote_io) |
| 390 | { | 400 | { |
| @@ -401,14 +411,11 @@ static int tk_request(struct l2cap_conn *conn, u8 remote_oob, u8 auth, | |||
| 401 | BT_DBG("tk_request: auth:%d lcl:%d rem:%d", auth, local_io, remote_io); | 411 | BT_DBG("tk_request: auth:%d lcl:%d rem:%d", auth, local_io, remote_io); |
| 402 | 412 | ||
| 403 | /* If neither side wants MITM, use JUST WORKS */ | 413 | /* If neither side wants MITM, use JUST WORKS */ |
| 404 | /* If either side has unknown io_caps, use JUST WORKS */ | ||
| 405 | /* Otherwise, look up method from the table */ | 414 | /* Otherwise, look up method from the table */ |
| 406 | if (!(auth & SMP_AUTH_MITM) || | 415 | if (!(auth & SMP_AUTH_MITM)) |
| 407 | local_io > SMP_IO_KEYBOARD_DISPLAY || | ||
| 408 | remote_io > SMP_IO_KEYBOARD_DISPLAY) | ||
| 409 | method = JUST_WORKS; | 416 | method = JUST_WORKS; |
| 410 | else | 417 | else |
| 411 | method = gen_method[remote_io][local_io]; | 418 | method = get_auth_method(smp, local_io, remote_io); |
| 412 | 419 | ||
| 413 | /* If not bonding, don't ask user to confirm a Zero TK */ | 420 | /* If not bonding, don't ask user to confirm a Zero TK */ |
| 414 | if (!(auth & SMP_AUTH_BONDING) && method == JUST_CFM) | 421 | if (!(auth & SMP_AUTH_BONDING) && method == JUST_CFM) |
| @@ -669,7 +676,7 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
| 669 | { | 676 | { |
| 670 | struct smp_cmd_pairing rsp, *req = (void *) skb->data; | 677 | struct smp_cmd_pairing rsp, *req = (void *) skb->data; |
| 671 | struct smp_chan *smp; | 678 | struct smp_chan *smp; |
| 672 | u8 key_size, auth; | 679 | u8 key_size, auth, sec_level; |
| 673 | int ret; | 680 | int ret; |
| 674 | 681 | ||
| 675 | BT_DBG("conn %p", conn); | 682 | BT_DBG("conn %p", conn); |
| @@ -695,7 +702,19 @@ static u8 smp_cmd_pairing_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
| 695 | /* We didn't start the pairing, so match remote */ | 702 | /* We didn't start the pairing, so match remote */ |
| 696 | auth = req->auth_req; | 703 | auth = req->auth_req; |
| 697 | 704 | ||
| 698 | conn->hcon->pending_sec_level = authreq_to_seclevel(auth); | 705 | sec_level = authreq_to_seclevel(auth); |
| 706 | if (sec_level > conn->hcon->pending_sec_level) | ||
| 707 | conn->hcon->pending_sec_level = sec_level; | ||
| 708 | |||
| 709 | /* If we need MITM check that it can be acheived */ | ||
| 710 | if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { | ||
| 711 | u8 method; | ||
| 712 | |||
| 713 | method = get_auth_method(smp, conn->hcon->io_capability, | ||
| 714 | req->io_capability); | ||
| 715 | if (method == JUST_WORKS || method == JUST_CFM) | ||
| 716 | return SMP_AUTH_REQUIREMENTS; | ||
| 717 | } | ||
| 699 | 718 | ||
| 700 | build_pairing_cmd(conn, req, &rsp, auth); | 719 | build_pairing_cmd(conn, req, &rsp, auth); |
| 701 | 720 | ||
| @@ -743,6 +762,16 @@ static u8 smp_cmd_pairing_rsp(struct l2cap_conn *conn, struct sk_buff *skb) | |||
| 743 | if (check_enc_key_size(conn, key_size)) | 762 | if (check_enc_key_size(conn, key_size)) |
| 744 | return SMP_ENC_KEY_SIZE; | 763 | return SMP_ENC_KEY_SIZE; |
| 745 | 764 | ||
| 765 | /* If we need MITM check that it can be acheived */ | ||
| 766 | if (conn->hcon->pending_sec_level >= BT_SECURITY_HIGH) { | ||
| 767 | u8 method; | ||
| 768 | |||
| 769 | method = get_auth_method(smp, req->io_capability, | ||
| 770 | rsp->io_capability); | ||
| 771 | if (method == JUST_WORKS || method == JUST_CFM) | ||
| 772 | return SMP_AUTH_REQUIREMENTS; | ||
| 773 | } | ||
| 774 | |||
| 746 | get_random_bytes(smp->prnd, sizeof(smp->prnd)); | 775 | get_random_bytes(smp->prnd, sizeof(smp->prnd)); |
| 747 | 776 | ||
| 748 | smp->prsp[0] = SMP_CMD_PAIRING_RSP; | 777 | smp->prsp[0] = SMP_CMD_PAIRING_RSP; |
| @@ -838,6 +867,7 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
| 838 | struct smp_cmd_pairing cp; | 867 | struct smp_cmd_pairing cp; |
| 839 | struct hci_conn *hcon = conn->hcon; | 868 | struct hci_conn *hcon = conn->hcon; |
| 840 | struct smp_chan *smp; | 869 | struct smp_chan *smp; |
| 870 | u8 sec_level; | ||
| 841 | 871 | ||
| 842 | BT_DBG("conn %p", conn); | 872 | BT_DBG("conn %p", conn); |
| 843 | 873 | ||
| @@ -847,7 +877,9 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb) | |||
| 847 | if (!(conn->hcon->link_mode & HCI_LM_MASTER)) | 877 | if (!(conn->hcon->link_mode & HCI_LM_MASTER)) |
| 848 | return SMP_CMD_NOTSUPP; | 878 | return SMP_CMD_NOTSUPP; |
| 849 | 879 | ||
| 850 | hcon->pending_sec_level = authreq_to_seclevel(rp->auth_req); | 880 | sec_level = authreq_to_seclevel(rp->auth_req); |
| 881 | if (sec_level > hcon->pending_sec_level) | ||
| 882 | hcon->pending_sec_level = sec_level; | ||
| 851 | 883 | ||
| 852 | if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) | 884 | if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) |
| 853 | return 0; | 885 | return 0; |
| @@ -901,9 +933,12 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) | |||
| 901 | if (smp_sufficient_security(hcon, sec_level)) | 933 | if (smp_sufficient_security(hcon, sec_level)) |
| 902 | return 1; | 934 | return 1; |
| 903 | 935 | ||
| 936 | if (sec_level > hcon->pending_sec_level) | ||
| 937 | hcon->pending_sec_level = sec_level; | ||
| 938 | |||
| 904 | if (hcon->link_mode & HCI_LM_MASTER) | 939 | if (hcon->link_mode & HCI_LM_MASTER) |
| 905 | if (smp_ltk_encrypt(conn, sec_level)) | 940 | if (smp_ltk_encrypt(conn, hcon->pending_sec_level)) |
| 906 | goto done; | 941 | return 0; |
| 907 | 942 | ||
| 908 | if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) | 943 | if (test_and_set_bit(HCI_CONN_LE_SMP_PEND, &hcon->flags)) |
| 909 | return 0; | 944 | return 0; |
| @@ -918,7 +953,7 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) | |||
| 918 | * requires it. | 953 | * requires it. |
| 919 | */ | 954 | */ |
| 920 | if (hcon->io_capability != HCI_IO_NO_INPUT_OUTPUT || | 955 | if (hcon->io_capability != HCI_IO_NO_INPUT_OUTPUT || |
| 921 | sec_level > BT_SECURITY_MEDIUM) | 956 | hcon->pending_sec_level > BT_SECURITY_MEDIUM) |
| 922 | authreq |= SMP_AUTH_MITM; | 957 | authreq |= SMP_AUTH_MITM; |
| 923 | 958 | ||
| 924 | if (hcon->link_mode & HCI_LM_MASTER) { | 959 | if (hcon->link_mode & HCI_LM_MASTER) { |
| @@ -937,9 +972,6 @@ int smp_conn_security(struct hci_conn *hcon, __u8 sec_level) | |||
| 937 | 972 | ||
| 938 | set_bit(SMP_FLAG_INITIATOR, &smp->flags); | 973 | set_bit(SMP_FLAG_INITIATOR, &smp->flags); |
| 939 | 974 | ||
| 940 | done: | ||
| 941 | hcon->pending_sec_level = sec_level; | ||
| 942 | |||
| 943 | return 0; | 975 | return 0; |
| 944 | } | 976 | } |
| 945 | 977 | ||
diff --git a/net/compat.c b/net/compat.c index 9a76eaf63184..bc8aeefddf3f 100644 --- a/net/compat.c +++ b/net/compat.c | |||
| @@ -85,7 +85,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov, | |||
| 85 | { | 85 | { |
| 86 | int tot_len; | 86 | int tot_len; |
| 87 | 87 | ||
| 88 | if (kern_msg->msg_namelen) { | 88 | if (kern_msg->msg_name && kern_msg->msg_namelen) { |
| 89 | if (mode == VERIFY_READ) { | 89 | if (mode == VERIFY_READ) { |
| 90 | int err = move_addr_to_kernel(kern_msg->msg_name, | 90 | int err = move_addr_to_kernel(kern_msg->msg_name, |
| 91 | kern_msg->msg_namelen, | 91 | kern_msg->msg_namelen, |
| @@ -93,10 +93,11 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov, | |||
| 93 | if (err < 0) | 93 | if (err < 0) |
| 94 | return err; | 94 | return err; |
| 95 | } | 95 | } |
| 96 | if (kern_msg->msg_name) | 96 | kern_msg->msg_name = kern_address; |
| 97 | kern_msg->msg_name = kern_address; | 97 | } else { |
| 98 | } else | ||
| 99 | kern_msg->msg_name = NULL; | 98 | kern_msg->msg_name = NULL; |
| 99 | kern_msg->msg_namelen = 0; | ||
| 100 | } | ||
| 100 | 101 | ||
| 101 | tot_len = iov_from_user_compat_to_kern(kern_iov, | 102 | tot_len = iov_from_user_compat_to_kern(kern_iov, |
| 102 | (struct compat_iovec __user *)kern_msg->msg_iov, | 103 | (struct compat_iovec __user *)kern_msg->msg_iov, |
diff --git a/net/core/dev.c b/net/core/dev.c index 30eedf677913..367a586d0c8a 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -148,6 +148,9 @@ struct list_head ptype_all __read_mostly; /* Taps */ | |||
| 148 | static struct list_head offload_base __read_mostly; | 148 | static struct list_head offload_base __read_mostly; |
| 149 | 149 | ||
| 150 | static int netif_rx_internal(struct sk_buff *skb); | 150 | static int netif_rx_internal(struct sk_buff *skb); |
| 151 | static int call_netdevice_notifiers_info(unsigned long val, | ||
| 152 | struct net_device *dev, | ||
| 153 | struct netdev_notifier_info *info); | ||
| 151 | 154 | ||
| 152 | /* | 155 | /* |
| 153 | * The @dev_base_head list is protected by @dev_base_lock and the rtnl | 156 | * The @dev_base_head list is protected by @dev_base_lock and the rtnl |
| @@ -1207,7 +1210,11 @@ EXPORT_SYMBOL(netdev_features_change); | |||
| 1207 | void netdev_state_change(struct net_device *dev) | 1210 | void netdev_state_change(struct net_device *dev) |
| 1208 | { | 1211 | { |
| 1209 | if (dev->flags & IFF_UP) { | 1212 | if (dev->flags & IFF_UP) { |
| 1210 | call_netdevice_notifiers(NETDEV_CHANGE, dev); | 1213 | struct netdev_notifier_change_info change_info; |
| 1214 | |||
| 1215 | change_info.flags_changed = 0; | ||
| 1216 | call_netdevice_notifiers_info(NETDEV_CHANGE, dev, | ||
| 1217 | &change_info.info); | ||
| 1211 | rtmsg_ifinfo(RTM_NEWLINK, dev, 0, GFP_KERNEL); | 1218 | rtmsg_ifinfo(RTM_NEWLINK, dev, 0, GFP_KERNEL); |
| 1212 | } | 1219 | } |
| 1213 | } | 1220 | } |
| @@ -4089,6 +4096,8 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) | |||
| 4089 | skb->vlan_tci = 0; | 4096 | skb->vlan_tci = 0; |
| 4090 | skb->dev = napi->dev; | 4097 | skb->dev = napi->dev; |
| 4091 | skb->skb_iif = 0; | 4098 | skb->skb_iif = 0; |
| 4099 | skb->encapsulation = 0; | ||
| 4100 | skb_shinfo(skb)->gso_type = 0; | ||
| 4092 | skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); | 4101 | skb->truesize = SKB_TRUESIZE(skb_end_offset(skb)); |
| 4093 | 4102 | ||
| 4094 | napi->skb = skb; | 4103 | napi->skb = skb; |
| @@ -4227,9 +4236,8 @@ static int process_backlog(struct napi_struct *napi, int quota) | |||
| 4227 | #endif | 4236 | #endif |
| 4228 | napi->weight = weight_p; | 4237 | napi->weight = weight_p; |
| 4229 | local_irq_disable(); | 4238 | local_irq_disable(); |
| 4230 | while (work < quota) { | 4239 | while (1) { |
| 4231 | struct sk_buff *skb; | 4240 | struct sk_buff *skb; |
| 4232 | unsigned int qlen; | ||
| 4233 | 4241 | ||
| 4234 | while ((skb = __skb_dequeue(&sd->process_queue))) { | 4242 | while ((skb = __skb_dequeue(&sd->process_queue))) { |
| 4235 | local_irq_enable(); | 4243 | local_irq_enable(); |
| @@ -4243,24 +4251,24 @@ static int process_backlog(struct napi_struct *napi, int quota) | |||
| 4243 | } | 4251 | } |
| 4244 | 4252 | ||
| 4245 | rps_lock(sd); | 4253 | rps_lock(sd); |
| 4246 | qlen = skb_queue_len(&sd->input_pkt_queue); | 4254 | if (skb_queue_empty(&sd->input_pkt_queue)) { |
| 4247 | if (qlen) | ||
| 4248 | skb_queue_splice_tail_init(&sd->input_pkt_queue, | ||
| 4249 | &sd->process_queue); | ||
| 4250 | |||
| 4251 | if (qlen < quota - work) { | ||
| 4252 | /* | 4255 | /* |
| 4253 | * Inline a custom version of __napi_complete(). | 4256 | * Inline a custom version of __napi_complete(). |
| 4254 | * only current cpu owns and manipulates this napi, | 4257 | * only current cpu owns and manipulates this napi, |
| 4255 | * and NAPI_STATE_SCHED is the only possible flag set on backlog. | 4258 | * and NAPI_STATE_SCHED is the only possible flag set |
| 4256 | * we can use a plain write instead of clear_bit(), | 4259 | * on backlog. |
| 4260 | * We can use a plain write instead of clear_bit(), | ||
| 4257 | * and we dont need an smp_mb() memory barrier. | 4261 | * and we dont need an smp_mb() memory barrier. |
| 4258 | */ | 4262 | */ |
| 4259 | list_del(&napi->poll_list); | 4263 | list_del(&napi->poll_list); |
| 4260 | napi->state = 0; | 4264 | napi->state = 0; |
| 4265 | rps_unlock(sd); | ||
| 4261 | 4266 | ||
| 4262 | quota = work + qlen; | 4267 | break; |
| 4263 | } | 4268 | } |
| 4269 | |||
| 4270 | skb_queue_splice_tail_init(&sd->input_pkt_queue, | ||
| 4271 | &sd->process_queue); | ||
| 4264 | rps_unlock(sd); | 4272 | rps_unlock(sd); |
| 4265 | } | 4273 | } |
| 4266 | local_irq_enable(); | 4274 | local_irq_enable(); |
diff --git a/net/core/iovec.c b/net/core/iovec.c index 827dd6beb49c..e1ec45ab1e63 100644 --- a/net/core/iovec.c +++ b/net/core/iovec.c | |||
| @@ -39,7 +39,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a | |||
| 39 | { | 39 | { |
| 40 | int size, ct, err; | 40 | int size, ct, err; |
| 41 | 41 | ||
| 42 | if (m->msg_namelen) { | 42 | if (m->msg_name && m->msg_namelen) { |
| 43 | if (mode == VERIFY_READ) { | 43 | if (mode == VERIFY_READ) { |
| 44 | void __user *namep; | 44 | void __user *namep; |
| 45 | namep = (void __user __force *) m->msg_name; | 45 | namep = (void __user __force *) m->msg_name; |
| @@ -48,10 +48,10 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a | |||
| 48 | if (err < 0) | 48 | if (err < 0) |
| 49 | return err; | 49 | return err; |
| 50 | } | 50 | } |
| 51 | if (m->msg_name) | 51 | m->msg_name = address; |
| 52 | m->msg_name = address; | ||
| 53 | } else { | 52 | } else { |
| 54 | m->msg_name = NULL; | 53 | m->msg_name = NULL; |
| 54 | m->msg_namelen = 0; | ||
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | size = m->msg_iovlen * sizeof(struct iovec); | 57 | size = m->msg_iovlen * sizeof(struct iovec); |
diff --git a/net/core/neighbour.c b/net/core/neighbour.c index 32d872eec7f5..ef31fef25e5a 100644 --- a/net/core/neighbour.c +++ b/net/core/neighbour.c | |||
| @@ -2249,7 +2249,7 @@ static int pneigh_fill_info(struct sk_buff *skb, struct pneigh_entry *pn, | |||
| 2249 | ndm->ndm_pad1 = 0; | 2249 | ndm->ndm_pad1 = 0; |
| 2250 | ndm->ndm_pad2 = 0; | 2250 | ndm->ndm_pad2 = 0; |
| 2251 | ndm->ndm_flags = pn->flags | NTF_PROXY; | 2251 | ndm->ndm_flags = pn->flags | NTF_PROXY; |
| 2252 | ndm->ndm_type = NDA_DST; | 2252 | ndm->ndm_type = RTN_UNICAST; |
| 2253 | ndm->ndm_ifindex = pn->dev->ifindex; | 2253 | ndm->ndm_ifindex = pn->dev->ifindex; |
| 2254 | ndm->ndm_state = NUD_NONE; | 2254 | ndm->ndm_state = NUD_NONE; |
| 2255 | 2255 | ||
| @@ -3059,11 +3059,12 @@ int neigh_sysctl_register(struct net_device *dev, struct neigh_parms *p, | |||
| 3059 | memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0, | 3059 | memset(&t->neigh_vars[NEIGH_VAR_GC_INTERVAL], 0, |
| 3060 | sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL])); | 3060 | sizeof(t->neigh_vars[NEIGH_VAR_GC_INTERVAL])); |
| 3061 | } else { | 3061 | } else { |
| 3062 | struct neigh_table *tbl = p->tbl; | ||
| 3062 | dev_name_source = "default"; | 3063 | dev_name_source = "default"; |
| 3063 | t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = (int *)(p + 1); | 3064 | t->neigh_vars[NEIGH_VAR_GC_INTERVAL].data = &tbl->gc_interval; |
| 3064 | t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = (int *)(p + 1) + 1; | 3065 | t->neigh_vars[NEIGH_VAR_GC_THRESH1].data = &tbl->gc_thresh1; |
| 3065 | t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = (int *)(p + 1) + 2; | 3066 | t->neigh_vars[NEIGH_VAR_GC_THRESH2].data = &tbl->gc_thresh2; |
| 3066 | t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = (int *)(p + 1) + 3; | 3067 | t->neigh_vars[NEIGH_VAR_GC_THRESH3].data = &tbl->gc_thresh3; |
| 3067 | } | 3068 | } |
| 3068 | 3069 | ||
| 3069 | if (handler) { | 3070 | if (handler) { |
diff --git a/net/dns_resolver/dns_query.c b/net/dns_resolver/dns_query.c index 9acec61f5433..dd8696a3dbec 100644 --- a/net/dns_resolver/dns_query.c +++ b/net/dns_resolver/dns_query.c | |||
| @@ -150,7 +150,7 @@ int dns_query(const char *type, const char *name, size_t namelen, | |||
| 150 | goto put; | 150 | goto put; |
| 151 | 151 | ||
| 152 | memcpy(*_result, upayload->data, len); | 152 | memcpy(*_result, upayload->data, len); |
| 153 | *_result[len] = '\0'; | 153 | (*_result)[len] = '\0'; |
| 154 | 154 | ||
| 155 | if (_expiry) | 155 | if (_expiry) |
| 156 | *_expiry = rkey->expiry; | 156 | *_expiry = rkey->expiry; |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index d5e6836cf772..d156b3c5f363 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
| @@ -1429,6 +1429,9 @@ static int inet_gro_complete(struct sk_buff *skb, int nhoff) | |||
| 1429 | int proto = iph->protocol; | 1429 | int proto = iph->protocol; |
| 1430 | int err = -ENOSYS; | 1430 | int err = -ENOSYS; |
| 1431 | 1431 | ||
| 1432 | if (skb->encapsulation) | ||
| 1433 | skb_set_inner_network_header(skb, nhoff); | ||
| 1434 | |||
| 1432 | csum_replace2(&iph->check, iph->tot_len, newlen); | 1435 | csum_replace2(&iph->check, iph->tot_len, newlen); |
| 1433 | iph->tot_len = newlen; | 1436 | iph->tot_len = newlen; |
| 1434 | 1437 | ||
diff --git a/net/ipv4/gre_demux.c b/net/ipv4/gre_demux.c index 4e9619bca732..0485bf7f8f03 100644 --- a/net/ipv4/gre_demux.c +++ b/net/ipv4/gre_demux.c | |||
| @@ -68,6 +68,7 @@ void gre_build_header(struct sk_buff *skb, const struct tnl_ptk_info *tpi, | |||
| 68 | 68 | ||
| 69 | skb_push(skb, hdr_len); | 69 | skb_push(skb, hdr_len); |
| 70 | 70 | ||
| 71 | skb_reset_transport_header(skb); | ||
| 71 | greh = (struct gre_base_hdr *)skb->data; | 72 | greh = (struct gre_base_hdr *)skb->data; |
| 72 | greh->flags = tnl_flags_to_gre_flags(tpi->flags); | 73 | greh->flags = tnl_flags_to_gre_flags(tpi->flags); |
| 73 | greh->protocol = tpi->proto; | 74 | greh->protocol = tpi->proto; |
diff --git a/net/ipv4/gre_offload.c b/net/ipv4/gre_offload.c index eb92deb12666..f0bdd47bbbcb 100644 --- a/net/ipv4/gre_offload.c +++ b/net/ipv4/gre_offload.c | |||
| @@ -263,6 +263,9 @@ static int gre_gro_complete(struct sk_buff *skb, int nhoff) | |||
| 263 | int err = -ENOENT; | 263 | int err = -ENOENT; |
| 264 | __be16 type; | 264 | __be16 type; |
| 265 | 265 | ||
| 266 | skb->encapsulation = 1; | ||
| 267 | skb_shinfo(skb)->gso_type = SKB_GSO_GRE; | ||
| 268 | |||
| 266 | type = greh->protocol; | 269 | type = greh->protocol; |
| 267 | if (greh->flags & GRE_KEY) | 270 | if (greh->flags & GRE_KEY) |
| 268 | grehlen += GRE_HEADER_SECTION; | 271 | grehlen += GRE_HEADER_SECTION; |
diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c index 79c3d947a481..42b7bcf8045b 100644 --- a/net/ipv4/icmp.c +++ b/net/ipv4/icmp.c | |||
| @@ -739,8 +739,6 @@ static void icmp_unreach(struct sk_buff *skb) | |||
| 739 | /* fall through */ | 739 | /* fall through */ |
| 740 | case 0: | 740 | case 0: |
| 741 | info = ntohs(icmph->un.frag.mtu); | 741 | info = ntohs(icmph->un.frag.mtu); |
| 742 | if (!info) | ||
| 743 | goto out; | ||
| 744 | } | 742 | } |
| 745 | break; | 743 | break; |
| 746 | case ICMP_SR_FAILED: | 744 | case ICMP_SR_FAILED: |
diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c index 6748d420f714..db710b059bab 100644 --- a/net/ipv4/igmp.c +++ b/net/ipv4/igmp.c | |||
| @@ -1944,6 +1944,10 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr) | |||
| 1944 | 1944 | ||
| 1945 | rtnl_lock(); | 1945 | rtnl_lock(); |
| 1946 | in_dev = ip_mc_find_dev(net, imr); | 1946 | in_dev = ip_mc_find_dev(net, imr); |
| 1947 | if (!in_dev) { | ||
| 1948 | ret = -ENODEV; | ||
| 1949 | goto out; | ||
| 1950 | } | ||
| 1947 | ifindex = imr->imr_ifindex; | 1951 | ifindex = imr->imr_ifindex; |
| 1948 | for (imlp = &inet->mc_list; | 1952 | for (imlp = &inet->mc_list; |
| 1949 | (iml = rtnl_dereference(*imlp)) != NULL; | 1953 | (iml = rtnl_dereference(*imlp)) != NULL; |
| @@ -1961,16 +1965,14 @@ int ip_mc_leave_group(struct sock *sk, struct ip_mreqn *imr) | |||
| 1961 | 1965 | ||
| 1962 | *imlp = iml->next_rcu; | 1966 | *imlp = iml->next_rcu; |
| 1963 | 1967 | ||
| 1964 | if (in_dev) | 1968 | ip_mc_dec_group(in_dev, group); |
| 1965 | ip_mc_dec_group(in_dev, group); | ||
| 1966 | rtnl_unlock(); | 1969 | rtnl_unlock(); |
| 1967 | /* decrease mem now to avoid the memleak warning */ | 1970 | /* decrease mem now to avoid the memleak warning */ |
| 1968 | atomic_sub(sizeof(*iml), &sk->sk_omem_alloc); | 1971 | atomic_sub(sizeof(*iml), &sk->sk_omem_alloc); |
| 1969 | kfree_rcu(iml, rcu); | 1972 | kfree_rcu(iml, rcu); |
| 1970 | return 0; | 1973 | return 0; |
| 1971 | } | 1974 | } |
| 1972 | if (!in_dev) | 1975 | out: |
| 1973 | ret = -ENODEV; | ||
| 1974 | rtnl_unlock(); | 1976 | rtnl_unlock(); |
| 1975 | return ret; | 1977 | return ret; |
| 1976 | } | 1978 | } |
diff --git a/net/ipv4/ip_options.c b/net/ipv4/ip_options.c index 5e7aecea05cd..ad382499bace 100644 --- a/net/ipv4/ip_options.c +++ b/net/ipv4/ip_options.c | |||
| @@ -288,6 +288,10 @@ int ip_options_compile(struct net *net, | |||
| 288 | optptr++; | 288 | optptr++; |
| 289 | continue; | 289 | continue; |
| 290 | } | 290 | } |
| 291 | if (unlikely(l < 2)) { | ||
| 292 | pp_ptr = optptr; | ||
| 293 | goto error; | ||
| 294 | } | ||
| 291 | optlen = optptr[1]; | 295 | optlen = optptr[1]; |
| 292 | if (optlen < 2 || optlen > l) { | 296 | if (optlen < 2 || optlen > l) { |
| 293 | pp_ptr = optptr; | 297 | pp_ptr = optptr; |
diff --git a/net/ipv4/ip_tunnel.c b/net/ipv4/ip_tunnel.c index 54b6731dab55..6f9de61dce5f 100644 --- a/net/ipv4/ip_tunnel.c +++ b/net/ipv4/ip_tunnel.c | |||
| @@ -169,6 +169,7 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, | |||
| 169 | 169 | ||
| 170 | hlist_for_each_entry_rcu(t, head, hash_node) { | 170 | hlist_for_each_entry_rcu(t, head, hash_node) { |
| 171 | if (remote != t->parms.iph.daddr || | 171 | if (remote != t->parms.iph.daddr || |
| 172 | t->parms.iph.saddr != 0 || | ||
| 172 | !(t->dev->flags & IFF_UP)) | 173 | !(t->dev->flags & IFF_UP)) |
| 173 | continue; | 174 | continue; |
| 174 | 175 | ||
| @@ -185,10 +186,11 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, | |||
| 185 | head = &itn->tunnels[hash]; | 186 | head = &itn->tunnels[hash]; |
| 186 | 187 | ||
| 187 | hlist_for_each_entry_rcu(t, head, hash_node) { | 188 | hlist_for_each_entry_rcu(t, head, hash_node) { |
| 188 | if ((local != t->parms.iph.saddr && | 189 | if ((local != t->parms.iph.saddr || t->parms.iph.daddr != 0) && |
| 189 | (local != t->parms.iph.daddr || | 190 | (local != t->parms.iph.daddr || !ipv4_is_multicast(local))) |
| 190 | !ipv4_is_multicast(local))) || | 191 | continue; |
| 191 | !(t->dev->flags & IFF_UP)) | 192 | |
| 193 | if (!(t->dev->flags & IFF_UP)) | ||
| 192 | continue; | 194 | continue; |
| 193 | 195 | ||
| 194 | if (!ip_tunnel_key_match(&t->parms, flags, key)) | 196 | if (!ip_tunnel_key_match(&t->parms, flags, key)) |
| @@ -205,6 +207,8 @@ struct ip_tunnel *ip_tunnel_lookup(struct ip_tunnel_net *itn, | |||
| 205 | 207 | ||
| 206 | hlist_for_each_entry_rcu(t, head, hash_node) { | 208 | hlist_for_each_entry_rcu(t, head, hash_node) { |
| 207 | if (t->parms.i_key != key || | 209 | if (t->parms.i_key != key || |
| 210 | t->parms.iph.saddr != 0 || | ||
| 211 | t->parms.iph.daddr != 0 || | ||
| 208 | !(t->dev->flags & IFF_UP)) | 212 | !(t->dev->flags & IFF_UP)) |
| 209 | continue; | 213 | continue; |
| 210 | 214 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index 082239ffe34a..190199851c9a 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -457,8 +457,31 @@ static struct neighbour *ipv4_neigh_lookup(const struct dst_entry *dst, | |||
| 457 | return neigh_create(&arp_tbl, pkey, dev); | 457 | return neigh_create(&arp_tbl, pkey, dev); |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | atomic_t *ip_idents __read_mostly; | 460 | #define IP_IDENTS_SZ 2048u |
| 461 | EXPORT_SYMBOL(ip_idents); | 461 | struct ip_ident_bucket { |
| 462 | atomic_t id; | ||
| 463 | u32 stamp32; | ||
| 464 | }; | ||
| 465 | |||
| 466 | static struct ip_ident_bucket *ip_idents __read_mostly; | ||
| 467 | |||
| 468 | /* In order to protect privacy, we add a perturbation to identifiers | ||
| 469 | * if one generator is seldom used. This makes hard for an attacker | ||
| 470 | * to infer how many packets were sent between two points in time. | ||
| 471 | */ | ||
| 472 | u32 ip_idents_reserve(u32 hash, int segs) | ||
| 473 | { | ||
| 474 | struct ip_ident_bucket *bucket = ip_idents + hash % IP_IDENTS_SZ; | ||
| 475 | u32 old = ACCESS_ONCE(bucket->stamp32); | ||
| 476 | u32 now = (u32)jiffies; | ||
| 477 | u32 delta = 0; | ||
| 478 | |||
| 479 | if (old != now && cmpxchg(&bucket->stamp32, old, now) == old) | ||
| 480 | delta = prandom_u32_max(now - old); | ||
| 481 | |||
| 482 | return atomic_add_return(segs + delta, &bucket->id) - segs; | ||
| 483 | } | ||
| 484 | EXPORT_SYMBOL(ip_idents_reserve); | ||
| 462 | 485 | ||
| 463 | void __ip_select_ident(struct iphdr *iph, int segs) | 486 | void __ip_select_ident(struct iphdr *iph, int segs) |
| 464 | { | 487 | { |
| @@ -467,7 +490,10 @@ void __ip_select_ident(struct iphdr *iph, int segs) | |||
| 467 | 490 | ||
| 468 | net_get_random_once(&ip_idents_hashrnd, sizeof(ip_idents_hashrnd)); | 491 | net_get_random_once(&ip_idents_hashrnd, sizeof(ip_idents_hashrnd)); |
| 469 | 492 | ||
| 470 | hash = jhash_1word((__force u32)iph->daddr, ip_idents_hashrnd); | 493 | hash = jhash_3words((__force u32)iph->daddr, |
| 494 | (__force u32)iph->saddr, | ||
| 495 | iph->protocol, | ||
| 496 | ip_idents_hashrnd); | ||
| 471 | id = ip_idents_reserve(hash, segs); | 497 | id = ip_idents_reserve(hash, segs); |
| 472 | iph->id = htons(id); | 498 | iph->id = htons(id); |
| 473 | } | 499 | } |
| @@ -1010,7 +1036,7 @@ void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu) | |||
| 1010 | const struct iphdr *iph = (const struct iphdr *) skb->data; | 1036 | const struct iphdr *iph = (const struct iphdr *) skb->data; |
| 1011 | struct flowi4 fl4; | 1037 | struct flowi4 fl4; |
| 1012 | struct rtable *rt; | 1038 | struct rtable *rt; |
| 1013 | struct dst_entry *dst; | 1039 | struct dst_entry *odst = NULL; |
| 1014 | bool new = false; | 1040 | bool new = false; |
| 1015 | 1041 | ||
| 1016 | bh_lock_sock(sk); | 1042 | bh_lock_sock(sk); |
| @@ -1018,16 +1044,17 @@ void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu) | |||
| 1018 | if (!ip_sk_accept_pmtu(sk)) | 1044 | if (!ip_sk_accept_pmtu(sk)) |
| 1019 | goto out; | 1045 | goto out; |
| 1020 | 1046 | ||
| 1021 | rt = (struct rtable *) __sk_dst_get(sk); | 1047 | odst = sk_dst_get(sk); |
| 1022 | 1048 | ||
| 1023 | if (sock_owned_by_user(sk) || !rt) { | 1049 | if (sock_owned_by_user(sk) || !odst) { |
| 1024 | __ipv4_sk_update_pmtu(skb, sk, mtu); | 1050 | __ipv4_sk_update_pmtu(skb, sk, mtu); |
| 1025 | goto out; | 1051 | goto out; |
| 1026 | } | 1052 | } |
| 1027 | 1053 | ||
| 1028 | __build_flow_key(&fl4, sk, iph, 0, 0, 0, 0, 0); | 1054 | __build_flow_key(&fl4, sk, iph, 0, 0, 0, 0, 0); |
| 1029 | 1055 | ||
| 1030 | if (!__sk_dst_check(sk, 0)) { | 1056 | rt = (struct rtable *)odst; |
| 1057 | if (odst->obsolete && odst->ops->check(odst, 0) == NULL) { | ||
| 1031 | rt = ip_route_output_flow(sock_net(sk), &fl4, sk); | 1058 | rt = ip_route_output_flow(sock_net(sk), &fl4, sk); |
| 1032 | if (IS_ERR(rt)) | 1059 | if (IS_ERR(rt)) |
| 1033 | goto out; | 1060 | goto out; |
| @@ -1037,8 +1064,7 @@ void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu) | |||
| 1037 | 1064 | ||
| 1038 | __ip_rt_update_pmtu((struct rtable *) rt->dst.path, &fl4, mtu); | 1065 | __ip_rt_update_pmtu((struct rtable *) rt->dst.path, &fl4, mtu); |
| 1039 | 1066 | ||
| 1040 | dst = dst_check(&rt->dst, 0); | 1067 | if (!dst_check(&rt->dst, 0)) { |
| 1041 | if (!dst) { | ||
| 1042 | if (new) | 1068 | if (new) |
| 1043 | dst_release(&rt->dst); | 1069 | dst_release(&rt->dst); |
| 1044 | 1070 | ||
| @@ -1050,10 +1076,11 @@ void ipv4_sk_update_pmtu(struct sk_buff *skb, struct sock *sk, u32 mtu) | |||
| 1050 | } | 1076 | } |
| 1051 | 1077 | ||
| 1052 | if (new) | 1078 | if (new) |
| 1053 | __sk_dst_set(sk, &rt->dst); | 1079 | sk_dst_set(sk, &rt->dst); |
| 1054 | 1080 | ||
| 1055 | out: | 1081 | out: |
| 1056 | bh_unlock_sock(sk); | 1082 | bh_unlock_sock(sk); |
| 1083 | dst_release(odst); | ||
| 1057 | } | 1084 | } |
| 1058 | EXPORT_SYMBOL_GPL(ipv4_sk_update_pmtu); | 1085 | EXPORT_SYMBOL_GPL(ipv4_sk_update_pmtu); |
| 1059 | 1086 | ||
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c index eb1dde37e678..9d2118e5fbc7 100644 --- a/net/ipv4/tcp.c +++ b/net/ipv4/tcp.c | |||
| @@ -1108,7 +1108,7 @@ int tcp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg, | |||
| 1108 | if (unlikely(tp->repair)) { | 1108 | if (unlikely(tp->repair)) { |
| 1109 | if (tp->repair_queue == TCP_RECV_QUEUE) { | 1109 | if (tp->repair_queue == TCP_RECV_QUEUE) { |
| 1110 | copied = tcp_send_rcvq(sk, msg, size); | 1110 | copied = tcp_send_rcvq(sk, msg, size); |
| 1111 | goto out; | 1111 | goto out_nopush; |
| 1112 | } | 1112 | } |
| 1113 | 1113 | ||
| 1114 | err = -EINVAL; | 1114 | err = -EINVAL; |
| @@ -1282,6 +1282,7 @@ wait_for_memory: | |||
| 1282 | out: | 1282 | out: |
| 1283 | if (copied) | 1283 | if (copied) |
| 1284 | tcp_push(sk, flags, mss_now, tp->nonagle, size_goal); | 1284 | tcp_push(sk, flags, mss_now, tp->nonagle, size_goal); |
| 1285 | out_nopush: | ||
| 1285 | release_sock(sk); | 1286 | release_sock(sk); |
| 1286 | return copied + copied_syn; | 1287 | return copied + copied_syn; |
| 1287 | 1288 | ||
diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index b5c23756965a..40639c288dc2 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c | |||
| @@ -1106,7 +1106,7 @@ static bool tcp_check_dsack(struct sock *sk, const struct sk_buff *ack_skb, | |||
| 1106 | } | 1106 | } |
| 1107 | 1107 | ||
| 1108 | /* D-SACK for already forgotten data... Do dumb counting. */ | 1108 | /* D-SACK for already forgotten data... Do dumb counting. */ |
| 1109 | if (dup_sack && tp->undo_marker && tp->undo_retrans && | 1109 | if (dup_sack && tp->undo_marker && tp->undo_retrans > 0 && |
| 1110 | !after(end_seq_0, prior_snd_una) && | 1110 | !after(end_seq_0, prior_snd_una) && |
| 1111 | after(end_seq_0, tp->undo_marker)) | 1111 | after(end_seq_0, tp->undo_marker)) |
| 1112 | tp->undo_retrans--; | 1112 | tp->undo_retrans--; |
| @@ -1187,7 +1187,7 @@ static u8 tcp_sacktag_one(struct sock *sk, | |||
| 1187 | 1187 | ||
| 1188 | /* Account D-SACK for retransmitted packet. */ | 1188 | /* Account D-SACK for retransmitted packet. */ |
| 1189 | if (dup_sack && (sacked & TCPCB_RETRANS)) { | 1189 | if (dup_sack && (sacked & TCPCB_RETRANS)) { |
| 1190 | if (tp->undo_marker && tp->undo_retrans && | 1190 | if (tp->undo_marker && tp->undo_retrans > 0 && |
| 1191 | after(end_seq, tp->undo_marker)) | 1191 | after(end_seq, tp->undo_marker)) |
| 1192 | tp->undo_retrans--; | 1192 | tp->undo_retrans--; |
| 1193 | if (sacked & TCPCB_SACKED_ACKED) | 1193 | if (sacked & TCPCB_SACKED_ACKED) |
| @@ -1893,7 +1893,7 @@ static void tcp_clear_retrans_partial(struct tcp_sock *tp) | |||
| 1893 | tp->lost_out = 0; | 1893 | tp->lost_out = 0; |
| 1894 | 1894 | ||
| 1895 | tp->undo_marker = 0; | 1895 | tp->undo_marker = 0; |
| 1896 | tp->undo_retrans = 0; | 1896 | tp->undo_retrans = -1; |
| 1897 | } | 1897 | } |
| 1898 | 1898 | ||
| 1899 | void tcp_clear_retrans(struct tcp_sock *tp) | 1899 | void tcp_clear_retrans(struct tcp_sock *tp) |
| @@ -2665,7 +2665,7 @@ static void tcp_enter_recovery(struct sock *sk, bool ece_ack) | |||
| 2665 | 2665 | ||
| 2666 | tp->prior_ssthresh = 0; | 2666 | tp->prior_ssthresh = 0; |
| 2667 | tp->undo_marker = tp->snd_una; | 2667 | tp->undo_marker = tp->snd_una; |
| 2668 | tp->undo_retrans = tp->retrans_out; | 2668 | tp->undo_retrans = tp->retrans_out ? : -1; |
| 2669 | 2669 | ||
| 2670 | if (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) { | 2670 | if (inet_csk(sk)->icsk_ca_state < TCP_CA_CWR) { |
| 2671 | if (!ece_ack) | 2671 | if (!ece_ack) |
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index 4e86c59ec7f7..55046ecd083e 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c | |||
| @@ -309,7 +309,7 @@ static int tcp4_gro_complete(struct sk_buff *skb, int thoff) | |||
| 309 | 309 | ||
| 310 | th->check = ~tcp_v4_check(skb->len - thoff, iph->saddr, | 310 | th->check = ~tcp_v4_check(skb->len - thoff, iph->saddr, |
| 311 | iph->daddr, 0); | 311 | iph->daddr, 0); |
| 312 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4; | 312 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4; |
| 313 | 313 | ||
| 314 | return tcp_gro_complete(skb); | 314 | return tcp_gro_complete(skb); |
| 315 | } | 315 | } |
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c index d92bce0ea24e..179b51e6bda3 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c | |||
| @@ -2525,8 +2525,6 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | |||
| 2525 | if (!tp->retrans_stamp) | 2525 | if (!tp->retrans_stamp) |
| 2526 | tp->retrans_stamp = TCP_SKB_CB(skb)->when; | 2526 | tp->retrans_stamp = TCP_SKB_CB(skb)->when; |
| 2527 | 2527 | ||
| 2528 | tp->undo_retrans += tcp_skb_pcount(skb); | ||
| 2529 | |||
| 2530 | /* snd_nxt is stored to detect loss of retransmitted segment, | 2528 | /* snd_nxt is stored to detect loss of retransmitted segment, |
| 2531 | * see tcp_input.c tcp_sacktag_write_queue(). | 2529 | * see tcp_input.c tcp_sacktag_write_queue(). |
| 2532 | */ | 2530 | */ |
| @@ -2534,6 +2532,10 @@ int tcp_retransmit_skb(struct sock *sk, struct sk_buff *skb) | |||
| 2534 | } else if (err != -EBUSY) { | 2532 | } else if (err != -EBUSY) { |
| 2535 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL); | 2533 | NET_INC_STATS_BH(sock_net(sk), LINUX_MIB_TCPRETRANSFAIL); |
| 2536 | } | 2534 | } |
| 2535 | |||
| 2536 | if (tp->undo_retrans < 0) | ||
| 2537 | tp->undo_retrans = 0; | ||
| 2538 | tp->undo_retrans += tcp_skb_pcount(skb); | ||
| 2537 | return err; | 2539 | return err; |
| 2538 | } | 2540 | } |
| 2539 | 2541 | ||
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index d92f94b7e402..7d5a8661df76 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
| @@ -1588,8 +1588,11 @@ int udp_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 1588 | goto csum_error; | 1588 | goto csum_error; |
| 1589 | 1589 | ||
| 1590 | 1590 | ||
| 1591 | if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) | 1591 | if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) { |
| 1592 | UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS, | ||
| 1593 | is_udplite); | ||
| 1592 | goto drop; | 1594 | goto drop; |
| 1595 | } | ||
| 1593 | 1596 | ||
| 1594 | rc = 0; | 1597 | rc = 0; |
| 1595 | 1598 | ||
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index cb9df0eb4023..45702b8cd141 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
| @@ -545,6 +545,8 @@ static void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt) | |||
| 545 | net_get_random_once(&ip6_idents_hashrnd, sizeof(ip6_idents_hashrnd)); | 545 | net_get_random_once(&ip6_idents_hashrnd, sizeof(ip6_idents_hashrnd)); |
| 546 | 546 | ||
| 547 | hash = __ipv6_addr_jhash(&rt->rt6i_dst.addr, ip6_idents_hashrnd); | 547 | hash = __ipv6_addr_jhash(&rt->rt6i_dst.addr, ip6_idents_hashrnd); |
| 548 | hash = __ipv6_addr_jhash(&rt->rt6i_src.addr, hash); | ||
| 549 | |||
| 548 | id = ip_idents_reserve(hash, 1); | 550 | id = ip_idents_reserve(hash, 1); |
| 549 | fhdr->identification = htonl(id); | 551 | fhdr->identification = htonl(id); |
| 550 | } | 552 | } |
diff --git a/net/ipv6/mcast.c b/net/ipv6/mcast.c index 08b367c6b9cf..617f0958e164 100644 --- a/net/ipv6/mcast.c +++ b/net/ipv6/mcast.c | |||
| @@ -1301,8 +1301,17 @@ int igmp6_event_query(struct sk_buff *skb) | |||
| 1301 | len = ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr); | 1301 | len = ntohs(ipv6_hdr(skb)->payload_len) + sizeof(struct ipv6hdr); |
| 1302 | len -= skb_network_header_len(skb); | 1302 | len -= skb_network_header_len(skb); |
| 1303 | 1303 | ||
| 1304 | /* Drop queries with not link local source */ | 1304 | /* RFC3810 6.2 |
| 1305 | if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL)) | 1305 | * Upon reception of an MLD message that contains a Query, the node |
| 1306 | * checks if the source address of the message is a valid link-local | ||
| 1307 | * address, if the Hop Limit is set to 1, and if the Router Alert | ||
| 1308 | * option is present in the Hop-By-Hop Options header of the IPv6 | ||
| 1309 | * packet. If any of these checks fails, the packet is dropped. | ||
| 1310 | */ | ||
| 1311 | if (!(ipv6_addr_type(&ipv6_hdr(skb)->saddr) & IPV6_ADDR_LINKLOCAL) || | ||
| 1312 | ipv6_hdr(skb)->hop_limit != 1 || | ||
| 1313 | !(IP6CB(skb)->flags & IP6SKB_ROUTERALERT) || | ||
| 1314 | IP6CB(skb)->ra != htons(IPV6_OPT_ROUTERALERT_MLD)) | ||
| 1306 | return -EINVAL; | 1315 | return -EINVAL; |
| 1307 | 1316 | ||
| 1308 | idev = __in6_dev_get(skb->dev); | 1317 | idev = __in6_dev_get(skb->dev); |
diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c index 8517d3cd1aed..01b0ff9a0c2c 100644 --- a/net/ipv6/tcpv6_offload.c +++ b/net/ipv6/tcpv6_offload.c | |||
| @@ -73,7 +73,7 @@ static int tcp6_gro_complete(struct sk_buff *skb, int thoff) | |||
| 73 | 73 | ||
| 74 | th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr, | 74 | th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr, |
| 75 | &iph->daddr, 0); | 75 | &iph->daddr, 0); |
| 76 | skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6; | 76 | skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6; |
| 77 | 77 | ||
| 78 | return tcp_gro_complete(skb); | 78 | return tcp_gro_complete(skb); |
| 79 | } | 79 | } |
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c index 95c834799288..7092ff78fd84 100644 --- a/net/ipv6/udp.c +++ b/net/ipv6/udp.c | |||
| @@ -674,8 +674,11 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 674 | goto csum_error; | 674 | goto csum_error; |
| 675 | } | 675 | } |
| 676 | 676 | ||
| 677 | if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) | 677 | if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) { |
| 678 | UDP6_INC_STATS_BH(sock_net(sk), | ||
| 679 | UDP_MIB_RCVBUFERRORS, is_udplite); | ||
| 678 | goto drop; | 680 | goto drop; |
| 681 | } | ||
| 679 | 682 | ||
| 680 | skb_dst_drop(skb); | 683 | skb_dst_drop(skb); |
| 681 | 684 | ||
| @@ -690,6 +693,7 @@ int udpv6_queue_rcv_skb(struct sock *sk, struct sk_buff *skb) | |||
| 690 | bh_unlock_sock(sk); | 693 | bh_unlock_sock(sk); |
| 691 | 694 | ||
| 692 | return rc; | 695 | return rc; |
| 696 | |||
| 693 | csum_error: | 697 | csum_error: |
| 694 | UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite); | 698 | UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite); |
| 695 | drop: | 699 | drop: |
diff --git a/net/l2tp/l2tp_ppp.c b/net/l2tp/l2tp_ppp.c index 950909f04ee6..13752d96275e 100644 --- a/net/l2tp/l2tp_ppp.c +++ b/net/l2tp/l2tp_ppp.c | |||
| @@ -1365,7 +1365,7 @@ static int pppol2tp_setsockopt(struct socket *sock, int level, int optname, | |||
| 1365 | int err; | 1365 | int err; |
| 1366 | 1366 | ||
| 1367 | if (level != SOL_PPPOL2TP) | 1367 | if (level != SOL_PPPOL2TP) |
| 1368 | return udp_prot.setsockopt(sk, level, optname, optval, optlen); | 1368 | return -EINVAL; |
| 1369 | 1369 | ||
| 1370 | if (optlen < sizeof(int)) | 1370 | if (optlen < sizeof(int)) |
| 1371 | return -EINVAL; | 1371 | return -EINVAL; |
| @@ -1491,7 +1491,7 @@ static int pppol2tp_getsockopt(struct socket *sock, int level, int optname, | |||
| 1491 | struct pppol2tp_session *ps; | 1491 | struct pppol2tp_session *ps; |
| 1492 | 1492 | ||
| 1493 | if (level != SOL_PPPOL2TP) | 1493 | if (level != SOL_PPPOL2TP) |
| 1494 | return udp_prot.getsockopt(sk, level, optname, optval, optlen); | 1494 | return -EINVAL; |
| 1495 | 1495 | ||
| 1496 | if (get_user(len, optlen)) | 1496 | if (get_user(len, optlen)) |
| 1497 | return -EFAULT; | 1497 | return -EFAULT; |
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index d7513a503be1..592f4b152ba8 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
| @@ -472,12 +472,15 @@ static void sta_set_sinfo(struct sta_info *sta, struct station_info *sinfo) | |||
| 472 | { | 472 | { |
| 473 | struct ieee80211_sub_if_data *sdata = sta->sdata; | 473 | struct ieee80211_sub_if_data *sdata = sta->sdata; |
| 474 | struct ieee80211_local *local = sdata->local; | 474 | struct ieee80211_local *local = sdata->local; |
| 475 | struct rate_control_ref *ref = local->rate_ctrl; | 475 | struct rate_control_ref *ref = NULL; |
| 476 | struct timespec uptime; | 476 | struct timespec uptime; |
| 477 | u64 packets = 0; | 477 | u64 packets = 0; |
| 478 | u32 thr = 0; | 478 | u32 thr = 0; |
| 479 | int i, ac; | 479 | int i, ac; |
| 480 | 480 | ||
| 481 | if (test_sta_flag(sta, WLAN_STA_RATE_CONTROL)) | ||
| 482 | ref = local->rate_ctrl; | ||
| 483 | |||
| 481 | sinfo->generation = sdata->local->sta_generation; | 484 | sinfo->generation = sdata->local->sta_generation; |
| 482 | 485 | ||
| 483 | sinfo->filled = STATION_INFO_INACTIVE_TIME | | 486 | sinfo->filled = STATION_INFO_INACTIVE_TIME | |
diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c index 5214686d9fd1..1a252c606ad0 100644 --- a/net/mac80211/tx.c +++ b/net/mac80211/tx.c | |||
| @@ -414,6 +414,9 @@ ieee80211_tx_h_multicast_ps_buf(struct ieee80211_tx_data *tx) | |||
| 414 | if (ieee80211_has_order(hdr->frame_control)) | 414 | if (ieee80211_has_order(hdr->frame_control)) |
| 415 | return TX_CONTINUE; | 415 | return TX_CONTINUE; |
| 416 | 416 | ||
| 417 | if (ieee80211_is_probe_req(hdr->frame_control)) | ||
| 418 | return TX_CONTINUE; | ||
| 419 | |||
| 417 | if (tx->local->hw.flags & IEEE80211_HW_QUEUE_CONTROL) | 420 | if (tx->local->hw.flags & IEEE80211_HW_QUEUE_CONTROL) |
| 418 | info->hw_queue = tx->sdata->vif.cab_queue; | 421 | info->hw_queue = tx->sdata->vif.cab_queue; |
| 419 | 422 | ||
| @@ -463,6 +466,7 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
| 463 | { | 466 | { |
| 464 | struct sta_info *sta = tx->sta; | 467 | struct sta_info *sta = tx->sta; |
| 465 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | 468 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); |
| 469 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | ||
| 466 | struct ieee80211_local *local = tx->local; | 470 | struct ieee80211_local *local = tx->local; |
| 467 | 471 | ||
| 468 | if (unlikely(!sta)) | 472 | if (unlikely(!sta)) |
| @@ -473,6 +477,12 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
| 473 | !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { | 477 | !(info->flags & IEEE80211_TX_CTL_NO_PS_BUFFER))) { |
| 474 | int ac = skb_get_queue_mapping(tx->skb); | 478 | int ac = skb_get_queue_mapping(tx->skb); |
| 475 | 479 | ||
| 480 | if (ieee80211_is_mgmt(hdr->frame_control) && | ||
| 481 | !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) { | ||
| 482 | info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; | ||
| 483 | return TX_CONTINUE; | ||
| 484 | } | ||
| 485 | |||
| 476 | ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", | 486 | ps_dbg(sta->sdata, "STA %pM aid %d: PS buffer for AC %d\n", |
| 477 | sta->sta.addr, sta->sta.aid, ac); | 487 | sta->sta.addr, sta->sta.aid, ac); |
| 478 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) | 488 | if (tx->local->total_ps_buffered >= TOTAL_MAX_TX_BUFFER) |
| @@ -531,19 +541,9 @@ ieee80211_tx_h_unicast_ps_buf(struct ieee80211_tx_data *tx) | |||
| 531 | static ieee80211_tx_result debug_noinline | 541 | static ieee80211_tx_result debug_noinline |
| 532 | ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx) | 542 | ieee80211_tx_h_ps_buf(struct ieee80211_tx_data *tx) |
| 533 | { | 543 | { |
| 534 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(tx->skb); | ||
| 535 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)tx->skb->data; | ||
| 536 | |||
| 537 | if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) | 544 | if (unlikely(tx->flags & IEEE80211_TX_PS_BUFFERED)) |
| 538 | return TX_CONTINUE; | 545 | return TX_CONTINUE; |
| 539 | 546 | ||
| 540 | if (ieee80211_is_mgmt(hdr->frame_control) && | ||
| 541 | !ieee80211_is_bufferable_mmpdu(hdr->frame_control)) { | ||
| 542 | if (tx->flags & IEEE80211_TX_UNICAST) | ||
| 543 | info->flags |= IEEE80211_TX_CTL_NO_PS_BUFFER; | ||
| 544 | return TX_CONTINUE; | ||
| 545 | } | ||
| 546 | |||
| 547 | if (tx->flags & IEEE80211_TX_UNICAST) | 547 | if (tx->flags & IEEE80211_TX_UNICAST) |
| 548 | return ieee80211_tx_h_unicast_ps_buf(tx); | 548 | return ieee80211_tx_h_unicast_ps_buf(tx); |
| 549 | else | 549 | else |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 6886601afe1c..a6cda52ed920 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
| @@ -1096,11 +1096,12 @@ void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, | |||
| 1096 | int err; | 1096 | int err; |
| 1097 | 1097 | ||
| 1098 | /* 24 + 6 = header + auth_algo + auth_transaction + status_code */ | 1098 | /* 24 + 6 = header + auth_algo + auth_transaction + status_code */ |
| 1099 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24 + 6 + extra_len); | 1099 | skb = dev_alloc_skb(local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN + |
| 1100 | 24 + 6 + extra_len + IEEE80211_WEP_ICV_LEN); | ||
| 1100 | if (!skb) | 1101 | if (!skb) |
| 1101 | return; | 1102 | return; |
| 1102 | 1103 | ||
| 1103 | skb_reserve(skb, local->hw.extra_tx_headroom); | 1104 | skb_reserve(skb, local->hw.extra_tx_headroom + IEEE80211_WEP_IV_LEN); |
| 1104 | 1105 | ||
| 1105 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24 + 6); | 1106 | mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24 + 6); |
| 1106 | memset(mgmt, 0, 24 + 6); | 1107 | memset(mgmt, 0, 24 + 6); |
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index a8eb0a89326a..610e19c0e13f 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c | |||
| @@ -797,7 +797,6 @@ static void ip_vs_conn_expire(unsigned long data) | |||
| 797 | ip_vs_control_del(cp); | 797 | ip_vs_control_del(cp); |
| 798 | 798 | ||
| 799 | if (cp->flags & IP_VS_CONN_F_NFCT) { | 799 | if (cp->flags & IP_VS_CONN_F_NFCT) { |
| 800 | ip_vs_conn_drop_conntrack(cp); | ||
| 801 | /* Do not access conntracks during subsys cleanup | 800 | /* Do not access conntracks during subsys cleanup |
| 802 | * because nf_conntrack_find_get can not be used after | 801 | * because nf_conntrack_find_get can not be used after |
| 803 | * conntrack cleanup for the net. | 802 | * conntrack cleanup for the net. |
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index ab4566cfcbe4..8746ff9a8357 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c | |||
| @@ -35,7 +35,7 @@ int nft_register_afinfo(struct net *net, struct nft_af_info *afi) | |||
| 35 | { | 35 | { |
| 36 | INIT_LIST_HEAD(&afi->tables); | 36 | INIT_LIST_HEAD(&afi->tables); |
| 37 | nfnl_lock(NFNL_SUBSYS_NFTABLES); | 37 | nfnl_lock(NFNL_SUBSYS_NFTABLES); |
| 38 | list_add_tail(&afi->list, &net->nft.af_info); | 38 | list_add_tail_rcu(&afi->list, &net->nft.af_info); |
| 39 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); | 39 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); |
| 40 | return 0; | 40 | return 0; |
| 41 | } | 41 | } |
| @@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(nft_register_afinfo); | |||
| 51 | void nft_unregister_afinfo(struct nft_af_info *afi) | 51 | void nft_unregister_afinfo(struct nft_af_info *afi) |
| 52 | { | 52 | { |
| 53 | nfnl_lock(NFNL_SUBSYS_NFTABLES); | 53 | nfnl_lock(NFNL_SUBSYS_NFTABLES); |
| 54 | list_del(&afi->list); | 54 | list_del_rcu(&afi->list); |
| 55 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); | 55 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); |
| 56 | } | 56 | } |
| 57 | EXPORT_SYMBOL_GPL(nft_unregister_afinfo); | 57 | EXPORT_SYMBOL_GPL(nft_unregister_afinfo); |
| @@ -277,11 +277,14 @@ static int nf_tables_dump_tables(struct sk_buff *skb, | |||
| 277 | struct net *net = sock_net(skb->sk); | 277 | struct net *net = sock_net(skb->sk); |
| 278 | int family = nfmsg->nfgen_family; | 278 | int family = nfmsg->nfgen_family; |
| 279 | 279 | ||
| 280 | list_for_each_entry(afi, &net->nft.af_info, list) { | 280 | rcu_read_lock(); |
| 281 | cb->seq = net->nft.base_seq; | ||
| 282 | |||
| 283 | list_for_each_entry_rcu(afi, &net->nft.af_info, list) { | ||
| 281 | if (family != NFPROTO_UNSPEC && family != afi->family) | 284 | if (family != NFPROTO_UNSPEC && family != afi->family) |
| 282 | continue; | 285 | continue; |
| 283 | 286 | ||
| 284 | list_for_each_entry(table, &afi->tables, list) { | 287 | list_for_each_entry_rcu(table, &afi->tables, list) { |
| 285 | if (idx < s_idx) | 288 | if (idx < s_idx) |
| 286 | goto cont; | 289 | goto cont; |
| 287 | if (idx > s_idx) | 290 | if (idx > s_idx) |
| @@ -294,11 +297,14 @@ static int nf_tables_dump_tables(struct sk_buff *skb, | |||
| 294 | NLM_F_MULTI, | 297 | NLM_F_MULTI, |
| 295 | afi->family, table) < 0) | 298 | afi->family, table) < 0) |
| 296 | goto done; | 299 | goto done; |
| 300 | |||
| 301 | nl_dump_check_consistent(cb, nlmsg_hdr(skb)); | ||
| 297 | cont: | 302 | cont: |
| 298 | idx++; | 303 | idx++; |
| 299 | } | 304 | } |
| 300 | } | 305 | } |
| 301 | done: | 306 | done: |
| 307 | rcu_read_unlock(); | ||
| 302 | cb->args[0] = idx; | 308 | cb->args[0] = idx; |
| 303 | return skb->len; | 309 | return skb->len; |
| 304 | } | 310 | } |
| @@ -407,6 +413,9 @@ static int nf_tables_updtable(struct nft_ctx *ctx) | |||
| 407 | if (flags & ~NFT_TABLE_F_DORMANT) | 413 | if (flags & ~NFT_TABLE_F_DORMANT) |
| 408 | return -EINVAL; | 414 | return -EINVAL; |
| 409 | 415 | ||
| 416 | if (flags == ctx->table->flags) | ||
| 417 | return 0; | ||
| 418 | |||
| 410 | trans = nft_trans_alloc(ctx, NFT_MSG_NEWTABLE, | 419 | trans = nft_trans_alloc(ctx, NFT_MSG_NEWTABLE, |
| 411 | sizeof(struct nft_trans_table)); | 420 | sizeof(struct nft_trans_table)); |
| 412 | if (trans == NULL) | 421 | if (trans == NULL) |
| @@ -514,7 +523,7 @@ static int nf_tables_newtable(struct sock *nlsk, struct sk_buff *skb, | |||
| 514 | module_put(afi->owner); | 523 | module_put(afi->owner); |
| 515 | return err; | 524 | return err; |
| 516 | } | 525 | } |
| 517 | list_add_tail(&table->list, &afi->tables); | 526 | list_add_tail_rcu(&table->list, &afi->tables); |
| 518 | return 0; | 527 | return 0; |
| 519 | } | 528 | } |
| 520 | 529 | ||
| @@ -546,7 +555,7 @@ static int nf_tables_deltable(struct sock *nlsk, struct sk_buff *skb, | |||
| 546 | if (err < 0) | 555 | if (err < 0) |
| 547 | return err; | 556 | return err; |
| 548 | 557 | ||
| 549 | list_del(&table->list); | 558 | list_del_rcu(&table->list); |
| 550 | return 0; | 559 | return 0; |
| 551 | } | 560 | } |
| 552 | 561 | ||
| @@ -635,13 +644,20 @@ static int nft_dump_stats(struct sk_buff *skb, struct nft_stats __percpu *stats) | |||
| 635 | { | 644 | { |
| 636 | struct nft_stats *cpu_stats, total; | 645 | struct nft_stats *cpu_stats, total; |
| 637 | struct nlattr *nest; | 646 | struct nlattr *nest; |
| 647 | unsigned int seq; | ||
| 648 | u64 pkts, bytes; | ||
| 638 | int cpu; | 649 | int cpu; |
| 639 | 650 | ||
| 640 | memset(&total, 0, sizeof(total)); | 651 | memset(&total, 0, sizeof(total)); |
| 641 | for_each_possible_cpu(cpu) { | 652 | for_each_possible_cpu(cpu) { |
| 642 | cpu_stats = per_cpu_ptr(stats, cpu); | 653 | cpu_stats = per_cpu_ptr(stats, cpu); |
| 643 | total.pkts += cpu_stats->pkts; | 654 | do { |
| 644 | total.bytes += cpu_stats->bytes; | 655 | seq = u64_stats_fetch_begin_irq(&cpu_stats->syncp); |
| 656 | pkts = cpu_stats->pkts; | ||
| 657 | bytes = cpu_stats->bytes; | ||
| 658 | } while (u64_stats_fetch_retry_irq(&cpu_stats->syncp, seq)); | ||
| 659 | total.pkts += pkts; | ||
| 660 | total.bytes += bytes; | ||
| 645 | } | 661 | } |
| 646 | nest = nla_nest_start(skb, NFTA_CHAIN_COUNTERS); | 662 | nest = nla_nest_start(skb, NFTA_CHAIN_COUNTERS); |
| 647 | if (nest == NULL) | 663 | if (nest == NULL) |
| @@ -761,12 +777,15 @@ static int nf_tables_dump_chains(struct sk_buff *skb, | |||
| 761 | struct net *net = sock_net(skb->sk); | 777 | struct net *net = sock_net(skb->sk); |
| 762 | int family = nfmsg->nfgen_family; | 778 | int family = nfmsg->nfgen_family; |
| 763 | 779 | ||
| 764 | list_for_each_entry(afi, &net->nft.af_info, list) { | 780 | rcu_read_lock(); |
| 781 | cb->seq = net->nft.base_seq; | ||
| 782 | |||
| 783 | list_for_each_entry_rcu(afi, &net->nft.af_info, list) { | ||
| 765 | if (family != NFPROTO_UNSPEC && family != afi->family) | 784 | if (family != NFPROTO_UNSPEC && family != afi->family) |
| 766 | continue; | 785 | continue; |
| 767 | 786 | ||
| 768 | list_for_each_entry(table, &afi->tables, list) { | 787 | list_for_each_entry_rcu(table, &afi->tables, list) { |
| 769 | list_for_each_entry(chain, &table->chains, list) { | 788 | list_for_each_entry_rcu(chain, &table->chains, list) { |
| 770 | if (idx < s_idx) | 789 | if (idx < s_idx) |
| 771 | goto cont; | 790 | goto cont; |
| 772 | if (idx > s_idx) | 791 | if (idx > s_idx) |
| @@ -778,17 +797,19 @@ static int nf_tables_dump_chains(struct sk_buff *skb, | |||
| 778 | NLM_F_MULTI, | 797 | NLM_F_MULTI, |
| 779 | afi->family, table, chain) < 0) | 798 | afi->family, table, chain) < 0) |
| 780 | goto done; | 799 | goto done; |
| 800 | |||
| 801 | nl_dump_check_consistent(cb, nlmsg_hdr(skb)); | ||
| 781 | cont: | 802 | cont: |
| 782 | idx++; | 803 | idx++; |
| 783 | } | 804 | } |
| 784 | } | 805 | } |
| 785 | } | 806 | } |
| 786 | done: | 807 | done: |
| 808 | rcu_read_unlock(); | ||
| 787 | cb->args[0] = idx; | 809 | cb->args[0] = idx; |
| 788 | return skb->len; | 810 | return skb->len; |
| 789 | } | 811 | } |
| 790 | 812 | ||
| 791 | |||
| 792 | static int nf_tables_getchain(struct sock *nlsk, struct sk_buff *skb, | 813 | static int nf_tables_getchain(struct sock *nlsk, struct sk_buff *skb, |
| 793 | const struct nlmsghdr *nlh, | 814 | const struct nlmsghdr *nlh, |
| 794 | const struct nlattr * const nla[]) | 815 | const struct nlattr * const nla[]) |
| @@ -861,7 +882,7 @@ static struct nft_stats __percpu *nft_stats_alloc(const struct nlattr *attr) | |||
| 861 | if (!tb[NFTA_COUNTER_BYTES] || !tb[NFTA_COUNTER_PACKETS]) | 882 | if (!tb[NFTA_COUNTER_BYTES] || !tb[NFTA_COUNTER_PACKETS]) |
| 862 | return ERR_PTR(-EINVAL); | 883 | return ERR_PTR(-EINVAL); |
| 863 | 884 | ||
| 864 | newstats = alloc_percpu(struct nft_stats); | 885 | newstats = netdev_alloc_pcpu_stats(struct nft_stats); |
| 865 | if (newstats == NULL) | 886 | if (newstats == NULL) |
| 866 | return ERR_PTR(-ENOMEM); | 887 | return ERR_PTR(-ENOMEM); |
| 867 | 888 | ||
| @@ -1077,7 +1098,7 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, | |||
| 1077 | } | 1098 | } |
| 1078 | basechain->stats = stats; | 1099 | basechain->stats = stats; |
| 1079 | } else { | 1100 | } else { |
| 1080 | stats = alloc_percpu(struct nft_stats); | 1101 | stats = netdev_alloc_pcpu_stats(struct nft_stats); |
| 1081 | if (IS_ERR(stats)) { | 1102 | if (IS_ERR(stats)) { |
| 1082 | module_put(type->owner); | 1103 | module_put(type->owner); |
| 1083 | kfree(basechain); | 1104 | kfree(basechain); |
| @@ -1130,7 +1151,7 @@ static int nf_tables_newchain(struct sock *nlsk, struct sk_buff *skb, | |||
| 1130 | goto err2; | 1151 | goto err2; |
| 1131 | 1152 | ||
| 1132 | table->use++; | 1153 | table->use++; |
| 1133 | list_add_tail(&chain->list, &table->chains); | 1154 | list_add_tail_rcu(&chain->list, &table->chains); |
| 1134 | return 0; | 1155 | return 0; |
| 1135 | err2: | 1156 | err2: |
| 1136 | if (!(table->flags & NFT_TABLE_F_DORMANT) && | 1157 | if (!(table->flags & NFT_TABLE_F_DORMANT) && |
| @@ -1180,7 +1201,7 @@ static int nf_tables_delchain(struct sock *nlsk, struct sk_buff *skb, | |||
| 1180 | return err; | 1201 | return err; |
| 1181 | 1202 | ||
| 1182 | table->use--; | 1203 | table->use--; |
| 1183 | list_del(&chain->list); | 1204 | list_del_rcu(&chain->list); |
| 1184 | return 0; | 1205 | return 0; |
| 1185 | } | 1206 | } |
| 1186 | 1207 | ||
| @@ -1199,9 +1220,9 @@ int nft_register_expr(struct nft_expr_type *type) | |||
| 1199 | { | 1220 | { |
| 1200 | nfnl_lock(NFNL_SUBSYS_NFTABLES); | 1221 | nfnl_lock(NFNL_SUBSYS_NFTABLES); |
| 1201 | if (type->family == NFPROTO_UNSPEC) | 1222 | if (type->family == NFPROTO_UNSPEC) |
| 1202 | list_add_tail(&type->list, &nf_tables_expressions); | 1223 | list_add_tail_rcu(&type->list, &nf_tables_expressions); |
| 1203 | else | 1224 | else |
| 1204 | list_add(&type->list, &nf_tables_expressions); | 1225 | list_add_rcu(&type->list, &nf_tables_expressions); |
| 1205 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); | 1226 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); |
| 1206 | return 0; | 1227 | return 0; |
| 1207 | } | 1228 | } |
| @@ -1216,7 +1237,7 @@ EXPORT_SYMBOL_GPL(nft_register_expr); | |||
| 1216 | void nft_unregister_expr(struct nft_expr_type *type) | 1237 | void nft_unregister_expr(struct nft_expr_type *type) |
| 1217 | { | 1238 | { |
| 1218 | nfnl_lock(NFNL_SUBSYS_NFTABLES); | 1239 | nfnl_lock(NFNL_SUBSYS_NFTABLES); |
| 1219 | list_del(&type->list); | 1240 | list_del_rcu(&type->list); |
| 1220 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); | 1241 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); |
| 1221 | } | 1242 | } |
| 1222 | EXPORT_SYMBOL_GPL(nft_unregister_expr); | 1243 | EXPORT_SYMBOL_GPL(nft_unregister_expr); |
| @@ -1549,16 +1570,17 @@ static int nf_tables_dump_rules(struct sk_buff *skb, | |||
| 1549 | unsigned int idx = 0, s_idx = cb->args[0]; | 1570 | unsigned int idx = 0, s_idx = cb->args[0]; |
| 1550 | struct net *net = sock_net(skb->sk); | 1571 | struct net *net = sock_net(skb->sk); |
| 1551 | int family = nfmsg->nfgen_family; | 1572 | int family = nfmsg->nfgen_family; |
| 1552 | u8 genctr = ACCESS_ONCE(net->nft.genctr); | ||
| 1553 | u8 gencursor = ACCESS_ONCE(net->nft.gencursor); | ||
| 1554 | 1573 | ||
| 1555 | list_for_each_entry(afi, &net->nft.af_info, list) { | 1574 | rcu_read_lock(); |
| 1575 | cb->seq = net->nft.base_seq; | ||
| 1576 | |||
| 1577 | list_for_each_entry_rcu(afi, &net->nft.af_info, list) { | ||
| 1556 | if (family != NFPROTO_UNSPEC && family != afi->family) | 1578 | if (family != NFPROTO_UNSPEC && family != afi->family) |
| 1557 | continue; | 1579 | continue; |
| 1558 | 1580 | ||
| 1559 | list_for_each_entry(table, &afi->tables, list) { | 1581 | list_for_each_entry_rcu(table, &afi->tables, list) { |
| 1560 | list_for_each_entry(chain, &table->chains, list) { | 1582 | list_for_each_entry_rcu(chain, &table->chains, list) { |
| 1561 | list_for_each_entry(rule, &chain->rules, list) { | 1583 | list_for_each_entry_rcu(rule, &chain->rules, list) { |
| 1562 | if (!nft_rule_is_active(net, rule)) | 1584 | if (!nft_rule_is_active(net, rule)) |
| 1563 | goto cont; | 1585 | goto cont; |
| 1564 | if (idx < s_idx) | 1586 | if (idx < s_idx) |
| @@ -1572,6 +1594,8 @@ static int nf_tables_dump_rules(struct sk_buff *skb, | |||
| 1572 | NLM_F_MULTI | NLM_F_APPEND, | 1594 | NLM_F_MULTI | NLM_F_APPEND, |
| 1573 | afi->family, table, chain, rule) < 0) | 1595 | afi->family, table, chain, rule) < 0) |
| 1574 | goto done; | 1596 | goto done; |
| 1597 | |||
| 1598 | nl_dump_check_consistent(cb, nlmsg_hdr(skb)); | ||
| 1575 | cont: | 1599 | cont: |
| 1576 | idx++; | 1600 | idx++; |
| 1577 | } | 1601 | } |
| @@ -1579,9 +1603,7 @@ cont: | |||
| 1579 | } | 1603 | } |
| 1580 | } | 1604 | } |
| 1581 | done: | 1605 | done: |
| 1582 | /* Invalidate this dump, a transition to the new generation happened */ | 1606 | rcu_read_unlock(); |
| 1583 | if (gencursor != net->nft.gencursor || genctr != net->nft.genctr) | ||
| 1584 | return -EBUSY; | ||
| 1585 | 1607 | ||
| 1586 | cb->args[0] = idx; | 1608 | cb->args[0] = idx; |
| 1587 | return skb->len; | 1609 | return skb->len; |
| @@ -1932,7 +1954,7 @@ static LIST_HEAD(nf_tables_set_ops); | |||
| 1932 | int nft_register_set(struct nft_set_ops *ops) | 1954 | int nft_register_set(struct nft_set_ops *ops) |
| 1933 | { | 1955 | { |
| 1934 | nfnl_lock(NFNL_SUBSYS_NFTABLES); | 1956 | nfnl_lock(NFNL_SUBSYS_NFTABLES); |
| 1935 | list_add_tail(&ops->list, &nf_tables_set_ops); | 1957 | list_add_tail_rcu(&ops->list, &nf_tables_set_ops); |
| 1936 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); | 1958 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); |
| 1937 | return 0; | 1959 | return 0; |
| 1938 | } | 1960 | } |
| @@ -1941,7 +1963,7 @@ EXPORT_SYMBOL_GPL(nft_register_set); | |||
| 1941 | void nft_unregister_set(struct nft_set_ops *ops) | 1963 | void nft_unregister_set(struct nft_set_ops *ops) |
| 1942 | { | 1964 | { |
| 1943 | nfnl_lock(NFNL_SUBSYS_NFTABLES); | 1965 | nfnl_lock(NFNL_SUBSYS_NFTABLES); |
| 1944 | list_del(&ops->list); | 1966 | list_del_rcu(&ops->list); |
| 1945 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); | 1967 | nfnl_unlock(NFNL_SUBSYS_NFTABLES); |
| 1946 | } | 1968 | } |
| 1947 | EXPORT_SYMBOL_GPL(nft_unregister_set); | 1969 | EXPORT_SYMBOL_GPL(nft_unregister_set); |
| @@ -2234,7 +2256,10 @@ static int nf_tables_dump_sets_table(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2234 | if (cb->args[1]) | 2256 | if (cb->args[1]) |
| 2235 | return skb->len; | 2257 | return skb->len; |
| 2236 | 2258 | ||
| 2237 | list_for_each_entry(set, &ctx->table->sets, list) { | 2259 | rcu_read_lock(); |
| 2260 | cb->seq = ctx->net->nft.base_seq; | ||
| 2261 | |||
| 2262 | list_for_each_entry_rcu(set, &ctx->table->sets, list) { | ||
| 2238 | if (idx < s_idx) | 2263 | if (idx < s_idx) |
| 2239 | goto cont; | 2264 | goto cont; |
| 2240 | if (nf_tables_fill_set(skb, ctx, set, NFT_MSG_NEWSET, | 2265 | if (nf_tables_fill_set(skb, ctx, set, NFT_MSG_NEWSET, |
| @@ -2242,11 +2267,13 @@ static int nf_tables_dump_sets_table(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2242 | cb->args[0] = idx; | 2267 | cb->args[0] = idx; |
| 2243 | goto done; | 2268 | goto done; |
| 2244 | } | 2269 | } |
| 2270 | nl_dump_check_consistent(cb, nlmsg_hdr(skb)); | ||
| 2245 | cont: | 2271 | cont: |
| 2246 | idx++; | 2272 | idx++; |
| 2247 | } | 2273 | } |
| 2248 | cb->args[1] = 1; | 2274 | cb->args[1] = 1; |
| 2249 | done: | 2275 | done: |
| 2276 | rcu_read_unlock(); | ||
| 2250 | return skb->len; | 2277 | return skb->len; |
| 2251 | } | 2278 | } |
| 2252 | 2279 | ||
| @@ -2260,7 +2287,10 @@ static int nf_tables_dump_sets_family(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2260 | if (cb->args[1]) | 2287 | if (cb->args[1]) |
| 2261 | return skb->len; | 2288 | return skb->len; |
| 2262 | 2289 | ||
| 2263 | list_for_each_entry(table, &ctx->afi->tables, list) { | 2290 | rcu_read_lock(); |
| 2291 | cb->seq = ctx->net->nft.base_seq; | ||
| 2292 | |||
| 2293 | list_for_each_entry_rcu(table, &ctx->afi->tables, list) { | ||
| 2264 | if (cur_table) { | 2294 | if (cur_table) { |
| 2265 | if (cur_table != table) | 2295 | if (cur_table != table) |
| 2266 | continue; | 2296 | continue; |
| @@ -2269,7 +2299,7 @@ static int nf_tables_dump_sets_family(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2269 | } | 2299 | } |
| 2270 | ctx->table = table; | 2300 | ctx->table = table; |
| 2271 | idx = 0; | 2301 | idx = 0; |
| 2272 | list_for_each_entry(set, &ctx->table->sets, list) { | 2302 | list_for_each_entry_rcu(set, &ctx->table->sets, list) { |
| 2273 | if (idx < s_idx) | 2303 | if (idx < s_idx) |
| 2274 | goto cont; | 2304 | goto cont; |
| 2275 | if (nf_tables_fill_set(skb, ctx, set, NFT_MSG_NEWSET, | 2305 | if (nf_tables_fill_set(skb, ctx, set, NFT_MSG_NEWSET, |
| @@ -2278,12 +2308,14 @@ static int nf_tables_dump_sets_family(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2278 | cb->args[2] = (unsigned long) table; | 2308 | cb->args[2] = (unsigned long) table; |
| 2279 | goto done; | 2309 | goto done; |
| 2280 | } | 2310 | } |
| 2311 | nl_dump_check_consistent(cb, nlmsg_hdr(skb)); | ||
| 2281 | cont: | 2312 | cont: |
| 2282 | idx++; | 2313 | idx++; |
| 2283 | } | 2314 | } |
| 2284 | } | 2315 | } |
| 2285 | cb->args[1] = 1; | 2316 | cb->args[1] = 1; |
| 2286 | done: | 2317 | done: |
| 2318 | rcu_read_unlock(); | ||
| 2287 | return skb->len; | 2319 | return skb->len; |
| 2288 | } | 2320 | } |
| 2289 | 2321 | ||
| @@ -2300,7 +2332,10 @@ static int nf_tables_dump_sets_all(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2300 | if (cb->args[1]) | 2332 | if (cb->args[1]) |
| 2301 | return skb->len; | 2333 | return skb->len; |
| 2302 | 2334 | ||
| 2303 | list_for_each_entry(afi, &net->nft.af_info, list) { | 2335 | rcu_read_lock(); |
| 2336 | cb->seq = net->nft.base_seq; | ||
| 2337 | |||
| 2338 | list_for_each_entry_rcu(afi, &net->nft.af_info, list) { | ||
| 2304 | if (cur_family) { | 2339 | if (cur_family) { |
| 2305 | if (afi->family != cur_family) | 2340 | if (afi->family != cur_family) |
| 2306 | continue; | 2341 | continue; |
| @@ -2308,7 +2343,7 @@ static int nf_tables_dump_sets_all(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2308 | cur_family = 0; | 2343 | cur_family = 0; |
| 2309 | } | 2344 | } |
| 2310 | 2345 | ||
| 2311 | list_for_each_entry(table, &afi->tables, list) { | 2346 | list_for_each_entry_rcu(table, &afi->tables, list) { |
| 2312 | if (cur_table) { | 2347 | if (cur_table) { |
| 2313 | if (cur_table != table) | 2348 | if (cur_table != table) |
| 2314 | continue; | 2349 | continue; |
| @@ -2319,7 +2354,7 @@ static int nf_tables_dump_sets_all(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2319 | ctx->table = table; | 2354 | ctx->table = table; |
| 2320 | ctx->afi = afi; | 2355 | ctx->afi = afi; |
| 2321 | idx = 0; | 2356 | idx = 0; |
| 2322 | list_for_each_entry(set, &ctx->table->sets, list) { | 2357 | list_for_each_entry_rcu(set, &ctx->table->sets, list) { |
| 2323 | if (idx < s_idx) | 2358 | if (idx < s_idx) |
| 2324 | goto cont; | 2359 | goto cont; |
| 2325 | if (nf_tables_fill_set(skb, ctx, set, | 2360 | if (nf_tables_fill_set(skb, ctx, set, |
| @@ -2330,6 +2365,7 @@ static int nf_tables_dump_sets_all(struct nft_ctx *ctx, struct sk_buff *skb, | |||
| 2330 | cb->args[3] = afi->family; | 2365 | cb->args[3] = afi->family; |
| 2331 | goto done; | 2366 | goto done; |
| 2332 | } | 2367 | } |
| 2368 | nl_dump_check_consistent(cb, nlmsg_hdr(skb)); | ||
| 2333 | cont: | 2369 | cont: |
| 2334 | idx++; | 2370 | idx++; |
| 2335 | } | 2371 | } |
| @@ -2339,6 +2375,7 @@ cont: | |||
| 2339 | } | 2375 | } |
| 2340 | cb->args[1] = 1; | 2376 | cb->args[1] = 1; |
| 2341 | done: | 2377 | done: |
| 2378 | rcu_read_unlock(); | ||
| 2342 | return skb->len; | 2379 | return skb->len; |
| 2343 | } | 2380 | } |
| 2344 | 2381 | ||
| @@ -2597,7 +2634,7 @@ static int nf_tables_newset(struct sock *nlsk, struct sk_buff *skb, | |||
| 2597 | if (err < 0) | 2634 | if (err < 0) |
| 2598 | goto err2; | 2635 | goto err2; |
| 2599 | 2636 | ||
| 2600 | list_add_tail(&set->list, &table->sets); | 2637 | list_add_tail_rcu(&set->list, &table->sets); |
| 2601 | table->use++; | 2638 | table->use++; |
| 2602 | return 0; | 2639 | return 0; |
| 2603 | 2640 | ||
| @@ -2617,7 +2654,7 @@ static void nft_set_destroy(struct nft_set *set) | |||
| 2617 | 2654 | ||
| 2618 | static void nf_tables_set_destroy(const struct nft_ctx *ctx, struct nft_set *set) | 2655 | static void nf_tables_set_destroy(const struct nft_ctx *ctx, struct nft_set *set) |
| 2619 | { | 2656 | { |
| 2620 | list_del(&set->list); | 2657 | list_del_rcu(&set->list); |
| 2621 | nf_tables_set_notify(ctx, set, NFT_MSG_DELSET, GFP_ATOMIC); | 2658 | nf_tables_set_notify(ctx, set, NFT_MSG_DELSET, GFP_ATOMIC); |
| 2622 | nft_set_destroy(set); | 2659 | nft_set_destroy(set); |
| 2623 | } | 2660 | } |
| @@ -2652,7 +2689,7 @@ static int nf_tables_delset(struct sock *nlsk, struct sk_buff *skb, | |||
| 2652 | if (err < 0) | 2689 | if (err < 0) |
| 2653 | return err; | 2690 | return err; |
| 2654 | 2691 | ||
| 2655 | list_del(&set->list); | 2692 | list_del_rcu(&set->list); |
| 2656 | ctx.table->use--; | 2693 | ctx.table->use--; |
| 2657 | return 0; | 2694 | return 0; |
| 2658 | } | 2695 | } |
| @@ -2704,14 +2741,14 @@ int nf_tables_bind_set(const struct nft_ctx *ctx, struct nft_set *set, | |||
| 2704 | } | 2741 | } |
| 2705 | bind: | 2742 | bind: |
| 2706 | binding->chain = ctx->chain; | 2743 | binding->chain = ctx->chain; |
| 2707 | list_add_tail(&binding->list, &set->bindings); | 2744 | list_add_tail_rcu(&binding->list, &set->bindings); |
| 2708 | return 0; | 2745 | return 0; |
| 2709 | } | 2746 | } |
| 2710 | 2747 | ||
| 2711 | void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set, | 2748 | void nf_tables_unbind_set(const struct nft_ctx *ctx, struct nft_set *set, |
| 2712 | struct nft_set_binding *binding) | 2749 | struct nft_set_binding *binding) |
| 2713 | { | 2750 | { |
| 2714 | list_del(&binding->list); | 2751 | list_del_rcu(&binding->list); |
| 2715 | 2752 | ||
| 2716 | if (list_empty(&set->bindings) && set->flags & NFT_SET_ANONYMOUS && | 2753 | if (list_empty(&set->bindings) && set->flags & NFT_SET_ANONYMOUS && |
| 2717 | !(set->flags & NFT_SET_INACTIVE)) | 2754 | !(set->flags & NFT_SET_INACTIVE)) |
| @@ -3346,7 +3383,7 @@ static int nf_tables_commit(struct sk_buff *skb) | |||
| 3346 | struct nft_set *set; | 3383 | struct nft_set *set; |
| 3347 | 3384 | ||
| 3348 | /* Bump generation counter, invalidate any dump in progress */ | 3385 | /* Bump generation counter, invalidate any dump in progress */ |
| 3349 | net->nft.genctr++; | 3386 | while (++net->nft.base_seq == 0); |
| 3350 | 3387 | ||
| 3351 | /* A new generation has just started */ | 3388 | /* A new generation has just started */ |
| 3352 | net->nft.gencursor = gencursor_next(net); | 3389 | net->nft.gencursor = gencursor_next(net); |
| @@ -3491,12 +3528,12 @@ static int nf_tables_abort(struct sk_buff *skb) | |||
| 3491 | } | 3528 | } |
| 3492 | nft_trans_destroy(trans); | 3529 | nft_trans_destroy(trans); |
| 3493 | } else { | 3530 | } else { |
| 3494 | list_del(&trans->ctx.table->list); | 3531 | list_del_rcu(&trans->ctx.table->list); |
| 3495 | } | 3532 | } |
| 3496 | break; | 3533 | break; |
| 3497 | case NFT_MSG_DELTABLE: | 3534 | case NFT_MSG_DELTABLE: |
| 3498 | list_add_tail(&trans->ctx.table->list, | 3535 | list_add_tail_rcu(&trans->ctx.table->list, |
| 3499 | &trans->ctx.afi->tables); | 3536 | &trans->ctx.afi->tables); |
| 3500 | nft_trans_destroy(trans); | 3537 | nft_trans_destroy(trans); |
| 3501 | break; | 3538 | break; |
| 3502 | case NFT_MSG_NEWCHAIN: | 3539 | case NFT_MSG_NEWCHAIN: |
| @@ -3507,7 +3544,7 @@ static int nf_tables_abort(struct sk_buff *skb) | |||
| 3507 | nft_trans_destroy(trans); | 3544 | nft_trans_destroy(trans); |
| 3508 | } else { | 3545 | } else { |
| 3509 | trans->ctx.table->use--; | 3546 | trans->ctx.table->use--; |
| 3510 | list_del(&trans->ctx.chain->list); | 3547 | list_del_rcu(&trans->ctx.chain->list); |
| 3511 | if (!(trans->ctx.table->flags & NFT_TABLE_F_DORMANT) && | 3548 | if (!(trans->ctx.table->flags & NFT_TABLE_F_DORMANT) && |
| 3512 | trans->ctx.chain->flags & NFT_BASE_CHAIN) { | 3549 | trans->ctx.chain->flags & NFT_BASE_CHAIN) { |
| 3513 | nf_unregister_hooks(nft_base_chain(trans->ctx.chain)->ops, | 3550 | nf_unregister_hooks(nft_base_chain(trans->ctx.chain)->ops, |
| @@ -3517,8 +3554,8 @@ static int nf_tables_abort(struct sk_buff *skb) | |||
| 3517 | break; | 3554 | break; |
| 3518 | case NFT_MSG_DELCHAIN: | 3555 | case NFT_MSG_DELCHAIN: |
| 3519 | trans->ctx.table->use++; | 3556 | trans->ctx.table->use++; |
| 3520 | list_add_tail(&trans->ctx.chain->list, | 3557 | list_add_tail_rcu(&trans->ctx.chain->list, |
| 3521 | &trans->ctx.table->chains); | 3558 | &trans->ctx.table->chains); |
| 3522 | nft_trans_destroy(trans); | 3559 | nft_trans_destroy(trans); |
| 3523 | break; | 3560 | break; |
| 3524 | case NFT_MSG_NEWRULE: | 3561 | case NFT_MSG_NEWRULE: |
| @@ -3532,12 +3569,12 @@ static int nf_tables_abort(struct sk_buff *skb) | |||
| 3532 | break; | 3569 | break; |
| 3533 | case NFT_MSG_NEWSET: | 3570 | case NFT_MSG_NEWSET: |
| 3534 | trans->ctx.table->use--; | 3571 | trans->ctx.table->use--; |
| 3535 | list_del(&nft_trans_set(trans)->list); | 3572 | list_del_rcu(&nft_trans_set(trans)->list); |
| 3536 | break; | 3573 | break; |
| 3537 | case NFT_MSG_DELSET: | 3574 | case NFT_MSG_DELSET: |
| 3538 | trans->ctx.table->use++; | 3575 | trans->ctx.table->use++; |
| 3539 | list_add_tail(&nft_trans_set(trans)->list, | 3576 | list_add_tail_rcu(&nft_trans_set(trans)->list, |
| 3540 | &trans->ctx.table->sets); | 3577 | &trans->ctx.table->sets); |
| 3541 | nft_trans_destroy(trans); | 3578 | nft_trans_destroy(trans); |
| 3542 | break; | 3579 | break; |
| 3543 | case NFT_MSG_NEWSETELEM: | 3580 | case NFT_MSG_NEWSETELEM: |
| @@ -3951,6 +3988,7 @@ static int nf_tables_init_net(struct net *net) | |||
| 3951 | { | 3988 | { |
| 3952 | INIT_LIST_HEAD(&net->nft.af_info); | 3989 | INIT_LIST_HEAD(&net->nft.af_info); |
| 3953 | INIT_LIST_HEAD(&net->nft.commit_list); | 3990 | INIT_LIST_HEAD(&net->nft.commit_list); |
| 3991 | net->nft.base_seq = 1; | ||
| 3954 | return 0; | 3992 | return 0; |
| 3955 | } | 3993 | } |
| 3956 | 3994 | ||
diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c index 345acfb1720b..3b90eb2b2c55 100644 --- a/net/netfilter/nf_tables_core.c +++ b/net/netfilter/nf_tables_core.c | |||
| @@ -109,7 +109,7 @@ nft_do_chain(struct nft_pktinfo *pkt, const struct nf_hook_ops *ops) | |||
| 109 | struct nft_data data[NFT_REG_MAX + 1]; | 109 | struct nft_data data[NFT_REG_MAX + 1]; |
| 110 | unsigned int stackptr = 0; | 110 | unsigned int stackptr = 0; |
| 111 | struct nft_jumpstack jumpstack[NFT_JUMP_STACK_SIZE]; | 111 | struct nft_jumpstack jumpstack[NFT_JUMP_STACK_SIZE]; |
| 112 | struct nft_stats __percpu *stats; | 112 | struct nft_stats *stats; |
| 113 | int rulenum; | 113 | int rulenum; |
| 114 | /* | 114 | /* |
| 115 | * Cache cursor to avoid problems in case that the cursor is updated | 115 | * Cache cursor to avoid problems in case that the cursor is updated |
| @@ -205,9 +205,11 @@ next_rule: | |||
| 205 | nft_trace_packet(pkt, basechain, -1, NFT_TRACE_POLICY); | 205 | nft_trace_packet(pkt, basechain, -1, NFT_TRACE_POLICY); |
| 206 | 206 | ||
| 207 | rcu_read_lock_bh(); | 207 | rcu_read_lock_bh(); |
| 208 | stats = rcu_dereference(nft_base_chain(basechain)->stats); | 208 | stats = this_cpu_ptr(rcu_dereference(nft_base_chain(basechain)->stats)); |
| 209 | __this_cpu_inc(stats->pkts); | 209 | u64_stats_update_begin(&stats->syncp); |
| 210 | __this_cpu_add(stats->bytes, pkt->skb->len); | 210 | stats->pkts++; |
| 211 | stats->bytes += pkt->skb->len; | ||
| 212 | u64_stats_update_end(&stats->syncp); | ||
| 211 | rcu_read_unlock_bh(); | 213 | rcu_read_unlock_bh(); |
| 212 | 214 | ||
| 213 | return nft_base_chain(basechain)->policy; | 215 | return nft_base_chain(basechain)->policy; |
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index 15c731f03fa6..e6fac7e3db52 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c | |||
| @@ -636,7 +636,7 @@ static unsigned int netlink_poll(struct file *file, struct socket *sock, | |||
| 636 | while (nlk->cb_running && netlink_dump_space(nlk)) { | 636 | while (nlk->cb_running && netlink_dump_space(nlk)) { |
| 637 | err = netlink_dump(sk); | 637 | err = netlink_dump(sk); |
| 638 | if (err < 0) { | 638 | if (err < 0) { |
| 639 | sk->sk_err = err; | 639 | sk->sk_err = -err; |
| 640 | sk->sk_error_report(sk); | 640 | sk->sk_error_report(sk); |
| 641 | break; | 641 | break; |
| 642 | } | 642 | } |
| @@ -2483,7 +2483,7 @@ static int netlink_recvmsg(struct kiocb *kiocb, struct socket *sock, | |||
| 2483 | atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) { | 2483 | atomic_read(&sk->sk_rmem_alloc) <= sk->sk_rcvbuf / 2) { |
| 2484 | ret = netlink_dump(sk); | 2484 | ret = netlink_dump(sk); |
| 2485 | if (ret) { | 2485 | if (ret) { |
| 2486 | sk->sk_err = ret; | 2486 | sk->sk_err = -ret; |
| 2487 | sk->sk_error_report(sk); | 2487 | sk->sk_error_report(sk); |
| 2488 | } | 2488 | } |
| 2489 | } | 2489 | } |
diff --git a/net/openvswitch/actions.c b/net/openvswitch/actions.c index c36856a457ca..e70d8b18e962 100644 --- a/net/openvswitch/actions.c +++ b/net/openvswitch/actions.c | |||
| @@ -551,6 +551,8 @@ static int do_execute_actions(struct datapath *dp, struct sk_buff *skb, | |||
| 551 | 551 | ||
| 552 | case OVS_ACTION_ATTR_SAMPLE: | 552 | case OVS_ACTION_ATTR_SAMPLE: |
| 553 | err = sample(dp, skb, a); | 553 | err = sample(dp, skb, a); |
| 554 | if (unlikely(err)) /* skb already freed. */ | ||
| 555 | return err; | ||
| 554 | break; | 556 | break; |
| 555 | } | 557 | } |
| 556 | 558 | ||
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index 0d407bca81e3..9db4bf6740d1 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2007-2013 Nicira, Inc. | 2 | * Copyright (c) 2007-2014 Nicira, Inc. |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or | 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of version 2 of the GNU General Public | 5 | * modify it under the terms of version 2 of the GNU General Public |
| @@ -276,7 +276,7 @@ void ovs_dp_process_received_packet(struct vport *p, struct sk_buff *skb) | |||
| 276 | OVS_CB(skb)->flow = flow; | 276 | OVS_CB(skb)->flow = flow; |
| 277 | OVS_CB(skb)->pkt_key = &key; | 277 | OVS_CB(skb)->pkt_key = &key; |
| 278 | 278 | ||
| 279 | ovs_flow_stats_update(OVS_CB(skb)->flow, skb); | 279 | ovs_flow_stats_update(OVS_CB(skb)->flow, key.tp.flags, skb); |
| 280 | ovs_execute_actions(dp, skb); | 280 | ovs_execute_actions(dp, skb); |
| 281 | stats_counter = &stats->n_hit; | 281 | stats_counter = &stats->n_hit; |
| 282 | 282 | ||
| @@ -889,8 +889,11 @@ static int ovs_flow_cmd_new(struct sk_buff *skb, struct genl_info *info) | |||
| 889 | } | 889 | } |
| 890 | /* The unmasked key has to be the same for flow updates. */ | 890 | /* The unmasked key has to be the same for flow updates. */ |
| 891 | if (unlikely(!ovs_flow_cmp_unmasked_key(flow, &match))) { | 891 | if (unlikely(!ovs_flow_cmp_unmasked_key(flow, &match))) { |
| 892 | error = -EEXIST; | 892 | flow = ovs_flow_tbl_lookup_exact(&dp->table, &match); |
| 893 | goto err_unlock_ovs; | 893 | if (!flow) { |
| 894 | error = -ENOENT; | ||
| 895 | goto err_unlock_ovs; | ||
| 896 | } | ||
| 894 | } | 897 | } |
| 895 | /* Update actions. */ | 898 | /* Update actions. */ |
| 896 | old_acts = ovsl_dereference(flow->sf_acts); | 899 | old_acts = ovsl_dereference(flow->sf_acts); |
| @@ -981,16 +984,12 @@ static int ovs_flow_cmd_set(struct sk_buff *skb, struct genl_info *info) | |||
| 981 | goto err_unlock_ovs; | 984 | goto err_unlock_ovs; |
| 982 | } | 985 | } |
| 983 | /* Check that the flow exists. */ | 986 | /* Check that the flow exists. */ |
| 984 | flow = ovs_flow_tbl_lookup(&dp->table, &key); | 987 | flow = ovs_flow_tbl_lookup_exact(&dp->table, &match); |
| 985 | if (unlikely(!flow)) { | 988 | if (unlikely(!flow)) { |
| 986 | error = -ENOENT; | 989 | error = -ENOENT; |
| 987 | goto err_unlock_ovs; | 990 | goto err_unlock_ovs; |
| 988 | } | 991 | } |
| 989 | /* The unmasked key has to be the same for flow updates. */ | 992 | |
| 990 | if (unlikely(!ovs_flow_cmp_unmasked_key(flow, &match))) { | ||
| 991 | error = -EEXIST; | ||
| 992 | goto err_unlock_ovs; | ||
| 993 | } | ||
| 994 | /* Update actions, if present. */ | 993 | /* Update actions, if present. */ |
| 995 | if (likely(acts)) { | 994 | if (likely(acts)) { |
| 996 | old_acts = ovsl_dereference(flow->sf_acts); | 995 | old_acts = ovsl_dereference(flow->sf_acts); |
| @@ -1063,8 +1062,8 @@ static int ovs_flow_cmd_get(struct sk_buff *skb, struct genl_info *info) | |||
| 1063 | goto unlock; | 1062 | goto unlock; |
| 1064 | } | 1063 | } |
| 1065 | 1064 | ||
| 1066 | flow = ovs_flow_tbl_lookup(&dp->table, &key); | 1065 | flow = ovs_flow_tbl_lookup_exact(&dp->table, &match); |
| 1067 | if (!flow || !ovs_flow_cmp_unmasked_key(flow, &match)) { | 1066 | if (!flow) { |
| 1068 | err = -ENOENT; | 1067 | err = -ENOENT; |
| 1069 | goto unlock; | 1068 | goto unlock; |
| 1070 | } | 1069 | } |
| @@ -1113,8 +1112,8 @@ static int ovs_flow_cmd_del(struct sk_buff *skb, struct genl_info *info) | |||
| 1113 | goto unlock; | 1112 | goto unlock; |
| 1114 | } | 1113 | } |
| 1115 | 1114 | ||
| 1116 | flow = ovs_flow_tbl_lookup(&dp->table, &key); | 1115 | flow = ovs_flow_tbl_lookup_exact(&dp->table, &match); |
| 1117 | if (unlikely(!flow || !ovs_flow_cmp_unmasked_key(flow, &match))) { | 1116 | if (unlikely(!flow)) { |
| 1118 | err = -ENOENT; | 1117 | err = -ENOENT; |
| 1119 | goto unlock; | 1118 | goto unlock; |
| 1120 | } | 1119 | } |
diff --git a/net/openvswitch/flow.c b/net/openvswitch/flow.c index 334751cb1528..d07ab538fc9d 100644 --- a/net/openvswitch/flow.c +++ b/net/openvswitch/flow.c | |||
| @@ -61,10 +61,10 @@ u64 ovs_flow_used_time(unsigned long flow_jiffies) | |||
| 61 | 61 | ||
| 62 | #define TCP_FLAGS_BE16(tp) (*(__be16 *)&tcp_flag_word(tp) & htons(0x0FFF)) | 62 | #define TCP_FLAGS_BE16(tp) (*(__be16 *)&tcp_flag_word(tp) & htons(0x0FFF)) |
| 63 | 63 | ||
| 64 | void ovs_flow_stats_update(struct sw_flow *flow, struct sk_buff *skb) | 64 | void ovs_flow_stats_update(struct sw_flow *flow, __be16 tcp_flags, |
| 65 | struct sk_buff *skb) | ||
| 65 | { | 66 | { |
| 66 | struct flow_stats *stats; | 67 | struct flow_stats *stats; |
| 67 | __be16 tcp_flags = flow->key.tp.flags; | ||
| 68 | int node = numa_node_id(); | 68 | int node = numa_node_id(); |
| 69 | 69 | ||
| 70 | stats = rcu_dereference(flow->stats[node]); | 70 | stats = rcu_dereference(flow->stats[node]); |
diff --git a/net/openvswitch/flow.h b/net/openvswitch/flow.h index ac395d2cd821..5e5aaed3a85b 100644 --- a/net/openvswitch/flow.h +++ b/net/openvswitch/flow.h | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2007-2013 Nicira, Inc. | 2 | * Copyright (c) 2007-2014 Nicira, Inc. |
| 3 | * | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or | 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of version 2 of the GNU General Public | 5 | * modify it under the terms of version 2 of the GNU General Public |
| @@ -180,7 +180,8 @@ struct arp_eth_header { | |||
| 180 | unsigned char ar_tip[4]; /* target IP address */ | 180 | unsigned char ar_tip[4]; /* target IP address */ |
| 181 | } __packed; | 181 | } __packed; |
| 182 | 182 | ||
| 183 | void ovs_flow_stats_update(struct sw_flow *, struct sk_buff *); | 183 | void ovs_flow_stats_update(struct sw_flow *, __be16 tcp_flags, |
| 184 | struct sk_buff *); | ||
| 184 | void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *, | 185 | void ovs_flow_stats_get(const struct sw_flow *, struct ovs_flow_stats *, |
| 185 | unsigned long *used, __be16 *tcp_flags); | 186 | unsigned long *used, __be16 *tcp_flags); |
| 186 | void ovs_flow_stats_clear(struct sw_flow *); | 187 | void ovs_flow_stats_clear(struct sw_flow *); |
diff --git a/net/openvswitch/flow_table.c b/net/openvswitch/flow_table.c index 574c3abc9b30..cf2d853646f0 100644 --- a/net/openvswitch/flow_table.c +++ b/net/openvswitch/flow_table.c | |||
| @@ -456,6 +456,22 @@ struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *tbl, | |||
| 456 | return ovs_flow_tbl_lookup_stats(tbl, key, &n_mask_hit); | 456 | return ovs_flow_tbl_lookup_stats(tbl, key, &n_mask_hit); |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, | ||
| 460 | struct sw_flow_match *match) | ||
| 461 | { | ||
| 462 | struct table_instance *ti = rcu_dereference_ovsl(tbl->ti); | ||
| 463 | struct sw_flow_mask *mask; | ||
| 464 | struct sw_flow *flow; | ||
| 465 | |||
| 466 | /* Always called under ovs-mutex. */ | ||
| 467 | list_for_each_entry(mask, &tbl->mask_list, list) { | ||
| 468 | flow = masked_flow_lookup(ti, match->key, mask); | ||
| 469 | if (flow && ovs_flow_cmp_unmasked_key(flow, match)) /* Found */ | ||
| 470 | return flow; | ||
| 471 | } | ||
| 472 | return NULL; | ||
| 473 | } | ||
| 474 | |||
| 459 | int ovs_flow_tbl_num_masks(const struct flow_table *table) | 475 | int ovs_flow_tbl_num_masks(const struct flow_table *table) |
| 460 | { | 476 | { |
| 461 | struct sw_flow_mask *mask; | 477 | struct sw_flow_mask *mask; |
diff --git a/net/openvswitch/flow_table.h b/net/openvswitch/flow_table.h index ca8a5820f615..5918bff7f3f6 100644 --- a/net/openvswitch/flow_table.h +++ b/net/openvswitch/flow_table.h | |||
| @@ -76,7 +76,8 @@ struct sw_flow *ovs_flow_tbl_lookup_stats(struct flow_table *, | |||
| 76 | u32 *n_mask_hit); | 76 | u32 *n_mask_hit); |
| 77 | struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, | 77 | struct sw_flow *ovs_flow_tbl_lookup(struct flow_table *, |
| 78 | const struct sw_flow_key *); | 78 | const struct sw_flow_key *); |
| 79 | 79 | struct sw_flow *ovs_flow_tbl_lookup_exact(struct flow_table *tbl, | |
| 80 | struct sw_flow_match *match); | ||
| 80 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, | 81 | bool ovs_flow_cmp_unmasked_key(const struct sw_flow *flow, |
| 81 | struct sw_flow_match *match); | 82 | struct sw_flow_match *match); |
| 82 | 83 | ||
diff --git a/net/openvswitch/vport-gre.c b/net/openvswitch/vport-gre.c index 35ec4fed09e2..f49148a07da2 100644 --- a/net/openvswitch/vport-gre.c +++ b/net/openvswitch/vport-gre.c | |||
| @@ -110,6 +110,22 @@ static int gre_rcv(struct sk_buff *skb, | |||
| 110 | return PACKET_RCVD; | 110 | return PACKET_RCVD; |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | /* Called with rcu_read_lock and BH disabled. */ | ||
| 114 | static int gre_err(struct sk_buff *skb, u32 info, | ||
| 115 | const struct tnl_ptk_info *tpi) | ||
| 116 | { | ||
| 117 | struct ovs_net *ovs_net; | ||
| 118 | struct vport *vport; | ||
| 119 | |||
| 120 | ovs_net = net_generic(dev_net(skb->dev), ovs_net_id); | ||
| 121 | vport = rcu_dereference(ovs_net->vport_net.gre_vport); | ||
| 122 | |||
| 123 | if (unlikely(!vport)) | ||
| 124 | return PACKET_REJECT; | ||
| 125 | else | ||
| 126 | return PACKET_RCVD; | ||
| 127 | } | ||
| 128 | |||
| 113 | static int gre_tnl_send(struct vport *vport, struct sk_buff *skb) | 129 | static int gre_tnl_send(struct vport *vport, struct sk_buff *skb) |
| 114 | { | 130 | { |
| 115 | struct net *net = ovs_dp_get_net(vport->dp); | 131 | struct net *net = ovs_dp_get_net(vport->dp); |
| @@ -186,6 +202,7 @@ error: | |||
| 186 | 202 | ||
| 187 | static struct gre_cisco_protocol gre_protocol = { | 203 | static struct gre_cisco_protocol gre_protocol = { |
| 188 | .handler = gre_rcv, | 204 | .handler = gre_rcv, |
| 205 | .err_handler = gre_err, | ||
| 189 | .priority = 1, | 206 | .priority = 1, |
| 190 | }; | 207 | }; |
| 191 | 208 | ||
diff --git a/net/sched/cls_u32.c b/net/sched/cls_u32.c index c39b583ace32..70c0be8d0121 100644 --- a/net/sched/cls_u32.c +++ b/net/sched/cls_u32.c | |||
| @@ -38,6 +38,7 @@ | |||
| 38 | #include <linux/errno.h> | 38 | #include <linux/errno.h> |
| 39 | #include <linux/rtnetlink.h> | 39 | #include <linux/rtnetlink.h> |
| 40 | #include <linux/skbuff.h> | 40 | #include <linux/skbuff.h> |
| 41 | #include <linux/bitmap.h> | ||
| 41 | #include <net/netlink.h> | 42 | #include <net/netlink.h> |
| 42 | #include <net/act_api.h> | 43 | #include <net/act_api.h> |
| 43 | #include <net/pkt_cls.h> | 44 | #include <net/pkt_cls.h> |
| @@ -460,17 +461,25 @@ static int u32_delete(struct tcf_proto *tp, unsigned long arg) | |||
| 460 | return 0; | 461 | return 0; |
| 461 | } | 462 | } |
| 462 | 463 | ||
| 464 | #define NR_U32_NODE (1<<12) | ||
| 463 | static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle) | 465 | static u32 gen_new_kid(struct tc_u_hnode *ht, u32 handle) |
| 464 | { | 466 | { |
| 465 | struct tc_u_knode *n; | 467 | struct tc_u_knode *n; |
| 466 | unsigned int i = 0x7FF; | 468 | unsigned long i; |
| 469 | unsigned long *bitmap = kzalloc(BITS_TO_LONGS(NR_U32_NODE) * sizeof(unsigned long), | ||
| 470 | GFP_KERNEL); | ||
| 471 | if (!bitmap) | ||
| 472 | return handle | 0xFFF; | ||
| 467 | 473 | ||
| 468 | for (n = ht->ht[TC_U32_HASH(handle)]; n; n = n->next) | 474 | for (n = ht->ht[TC_U32_HASH(handle)]; n; n = n->next) |
| 469 | if (i < TC_U32_NODE(n->handle)) | 475 | set_bit(TC_U32_NODE(n->handle), bitmap); |
| 470 | i = TC_U32_NODE(n->handle); | ||
| 471 | i++; | ||
| 472 | 476 | ||
| 473 | return handle | (i > 0xFFF ? 0xFFF : i); | 477 | i = find_next_zero_bit(bitmap, NR_U32_NODE, 0x800); |
| 478 | if (i >= NR_U32_NODE) | ||
| 479 | i = find_next_zero_bit(bitmap, NR_U32_NODE, 1); | ||
| 480 | |||
| 481 | kfree(bitmap); | ||
| 482 | return handle | (i >= NR_U32_NODE ? 0xFFF : i); | ||
| 474 | } | 483 | } |
| 475 | 484 | ||
| 476 | static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { | 485 | static const struct nla_policy u32_policy[TCA_U32_MAX + 1] = { |
diff --git a/net/sctp/associola.c b/net/sctp/associola.c index 9de23a222d3f..06a9ee6b2d3a 100644 --- a/net/sctp/associola.c +++ b/net/sctp/associola.c | |||
| @@ -1097,6 +1097,7 @@ void sctp_assoc_update(struct sctp_association *asoc, | |||
| 1097 | asoc->c = new->c; | 1097 | asoc->c = new->c; |
| 1098 | asoc->peer.rwnd = new->peer.rwnd; | 1098 | asoc->peer.rwnd = new->peer.rwnd; |
| 1099 | asoc->peer.sack_needed = new->peer.sack_needed; | 1099 | asoc->peer.sack_needed = new->peer.sack_needed; |
| 1100 | asoc->peer.auth_capable = new->peer.auth_capable; | ||
| 1100 | asoc->peer.i = new->peer.i; | 1101 | asoc->peer.i = new->peer.i; |
| 1101 | sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, | 1102 | sctp_tsnmap_init(&asoc->peer.tsn_map, SCTP_TSN_MAP_INITIAL, |
| 1102 | asoc->peer.i.initial_tsn, GFP_ATOMIC); | 1103 | asoc->peer.i.initial_tsn, GFP_ATOMIC); |
diff --git a/net/sctp/ulpevent.c b/net/sctp/ulpevent.c index 85c64658bd0b..b6842fdb53d4 100644 --- a/net/sctp/ulpevent.c +++ b/net/sctp/ulpevent.c | |||
| @@ -366,9 +366,10 @@ fail: | |||
| 366 | * specification [SCTP] and any extensions for a list of possible | 366 | * specification [SCTP] and any extensions for a list of possible |
| 367 | * error formats. | 367 | * error formats. |
| 368 | */ | 368 | */ |
| 369 | struct sctp_ulpevent *sctp_ulpevent_make_remote_error( | 369 | struct sctp_ulpevent * |
| 370 | const struct sctp_association *asoc, struct sctp_chunk *chunk, | 370 | sctp_ulpevent_make_remote_error(const struct sctp_association *asoc, |
| 371 | __u16 flags, gfp_t gfp) | 371 | struct sctp_chunk *chunk, __u16 flags, |
| 372 | gfp_t gfp) | ||
| 372 | { | 373 | { |
| 373 | struct sctp_ulpevent *event; | 374 | struct sctp_ulpevent *event; |
| 374 | struct sctp_remote_error *sre; | 375 | struct sctp_remote_error *sre; |
| @@ -387,8 +388,7 @@ struct sctp_ulpevent *sctp_ulpevent_make_remote_error( | |||
| 387 | /* Copy the skb to a new skb with room for us to prepend | 388 | /* Copy the skb to a new skb with room for us to prepend |
| 388 | * notification with. | 389 | * notification with. |
| 389 | */ | 390 | */ |
| 390 | skb = skb_copy_expand(chunk->skb, sizeof(struct sctp_remote_error), | 391 | skb = skb_copy_expand(chunk->skb, sizeof(*sre), 0, gfp); |
| 391 | 0, gfp); | ||
| 392 | 392 | ||
| 393 | /* Pull off the rest of the cause TLV from the chunk. */ | 393 | /* Pull off the rest of the cause TLV from the chunk. */ |
| 394 | skb_pull(chunk->skb, elen); | 394 | skb_pull(chunk->skb, elen); |
| @@ -399,62 +399,21 @@ struct sctp_ulpevent *sctp_ulpevent_make_remote_error( | |||
| 399 | event = sctp_skb2event(skb); | 399 | event = sctp_skb2event(skb); |
| 400 | sctp_ulpevent_init(event, MSG_NOTIFICATION, skb->truesize); | 400 | sctp_ulpevent_init(event, MSG_NOTIFICATION, skb->truesize); |
| 401 | 401 | ||
| 402 | sre = (struct sctp_remote_error *) | 402 | sre = (struct sctp_remote_error *) skb_push(skb, sizeof(*sre)); |
| 403 | skb_push(skb, sizeof(struct sctp_remote_error)); | ||
| 404 | 403 | ||
| 405 | /* Trim the buffer to the right length. */ | 404 | /* Trim the buffer to the right length. */ |
| 406 | skb_trim(skb, sizeof(struct sctp_remote_error) + elen); | 405 | skb_trim(skb, sizeof(*sre) + elen); |
| 407 | 406 | ||
| 408 | /* Socket Extensions for SCTP | 407 | /* RFC6458, Section 6.1.3. SCTP_REMOTE_ERROR */ |
| 409 | * 5.3.1.3 SCTP_REMOTE_ERROR | 408 | memset(sre, 0, sizeof(*sre)); |
| 410 | * | ||
| 411 | * sre_type: | ||
| 412 | * It should be SCTP_REMOTE_ERROR. | ||
| 413 | */ | ||
| 414 | sre->sre_type = SCTP_REMOTE_ERROR; | 409 | sre->sre_type = SCTP_REMOTE_ERROR; |
| 415 | |||
| 416 | /* | ||
| 417 | * Socket Extensions for SCTP | ||
| 418 | * 5.3.1.3 SCTP_REMOTE_ERROR | ||
| 419 | * | ||
| 420 | * sre_flags: 16 bits (unsigned integer) | ||
| 421 | * Currently unused. | ||
| 422 | */ | ||
| 423 | sre->sre_flags = 0; | 410 | sre->sre_flags = 0; |
| 424 | |||
| 425 | /* Socket Extensions for SCTP | ||
| 426 | * 5.3.1.3 SCTP_REMOTE_ERROR | ||
| 427 | * | ||
| 428 | * sre_length: sizeof (__u32) | ||
| 429 | * | ||
| 430 | * This field is the total length of the notification data, | ||
| 431 | * including the notification header. | ||
| 432 | */ | ||
| 433 | sre->sre_length = skb->len; | 411 | sre->sre_length = skb->len; |
| 434 | |||
| 435 | /* Socket Extensions for SCTP | ||
| 436 | * 5.3.1.3 SCTP_REMOTE_ERROR | ||
| 437 | * | ||
| 438 | * sre_error: 16 bits (unsigned integer) | ||
| 439 | * This value represents one of the Operational Error causes defined in | ||
| 440 | * the SCTP specification, in network byte order. | ||
| 441 | */ | ||
| 442 | sre->sre_error = cause; | 412 | sre->sre_error = cause; |
| 443 | |||
| 444 | /* Socket Extensions for SCTP | ||
| 445 | * 5.3.1.3 SCTP_REMOTE_ERROR | ||
| 446 | * | ||
| 447 | * sre_assoc_id: sizeof (sctp_assoc_t) | ||
| 448 | * | ||
| 449 | * The association id field, holds the identifier for the association. | ||
| 450 | * All notifications for a given association have the same association | ||
| 451 | * identifier. For TCP style socket, this field is ignored. | ||
| 452 | */ | ||
| 453 | sctp_ulpevent_set_owner(event, asoc); | 413 | sctp_ulpevent_set_owner(event, asoc); |
| 454 | sre->sre_assoc_id = sctp_assoc2id(asoc); | 414 | sre->sre_assoc_id = sctp_assoc2id(asoc); |
| 455 | 415 | ||
| 456 | return event; | 416 | return event; |
| 457 | |||
| 458 | fail: | 417 | fail: |
| 459 | return NULL; | 418 | return NULL; |
| 460 | } | 419 | } |
| @@ -899,7 +858,9 @@ __u16 sctp_ulpevent_get_notification_type(const struct sctp_ulpevent *event) | |||
| 899 | return notification->sn_header.sn_type; | 858 | return notification->sn_header.sn_type; |
| 900 | } | 859 | } |
| 901 | 860 | ||
| 902 | /* Copy out the sndrcvinfo into a msghdr. */ | 861 | /* RFC6458, Section 5.3.2. SCTP Header Information Structure |
| 862 | * (SCTP_SNDRCV, DEPRECATED) | ||
| 863 | */ | ||
| 903 | void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, | 864 | void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, |
| 904 | struct msghdr *msghdr) | 865 | struct msghdr *msghdr) |
| 905 | { | 866 | { |
| @@ -908,74 +869,21 @@ void sctp_ulpevent_read_sndrcvinfo(const struct sctp_ulpevent *event, | |||
| 908 | if (sctp_ulpevent_is_notification(event)) | 869 | if (sctp_ulpevent_is_notification(event)) |
| 909 | return; | 870 | return; |
| 910 | 871 | ||
| 911 | /* Sockets API Extensions for SCTP | 872 | memset(&sinfo, 0, sizeof(sinfo)); |
| 912 | * Section 5.2.2 SCTP Header Information Structure (SCTP_SNDRCV) | ||
| 913 | * | ||
| 914 | * sinfo_stream: 16 bits (unsigned integer) | ||
| 915 | * | ||
| 916 | * For recvmsg() the SCTP stack places the message's stream number in | ||
| 917 | * this value. | ||
| 918 | */ | ||
| 919 | sinfo.sinfo_stream = event->stream; | 873 | sinfo.sinfo_stream = event->stream; |
| 920 | /* sinfo_ssn: 16 bits (unsigned integer) | ||
| 921 | * | ||
| 922 | * For recvmsg() this value contains the stream sequence number that | ||
| 923 | * the remote endpoint placed in the DATA chunk. For fragmented | ||
| 924 | * messages this is the same number for all deliveries of the message | ||
| 925 | * (if more than one recvmsg() is needed to read the message). | ||
| 926 | */ | ||
| 927 | sinfo.sinfo_ssn = event->ssn; | 874 | sinfo.sinfo_ssn = event->ssn; |
| 928 | /* sinfo_ppid: 32 bits (unsigned integer) | ||
| 929 | * | ||
| 930 | * In recvmsg() this value is | ||
| 931 | * the same information that was passed by the upper layer in the peer | ||
| 932 | * application. Please note that byte order issues are NOT accounted | ||
| 933 | * for and this information is passed opaquely by the SCTP stack from | ||
| 934 | * one end to the other. | ||
| 935 | */ | ||
| 936 | sinfo.sinfo_ppid = event->ppid; | 875 | sinfo.sinfo_ppid = event->ppid; |
| 937 | /* sinfo_flags: 16 bits (unsigned integer) | ||
| 938 | * | ||
| 939 | * This field may contain any of the following flags and is composed of | ||
| 940 | * a bitwise OR of these values. | ||
| 941 | * | ||
| 942 | * recvmsg() flags: | ||
| 943 | * | ||
| 944 | * SCTP_UNORDERED - This flag is present when the message was sent | ||
| 945 | * non-ordered. | ||
| 946 | */ | ||
| 947 | sinfo.sinfo_flags = event->flags; | 876 | sinfo.sinfo_flags = event->flags; |
| 948 | /* sinfo_tsn: 32 bit (unsigned integer) | ||
| 949 | * | ||
| 950 | * For the receiving side, this field holds a TSN that was | ||
| 951 | * assigned to one of the SCTP Data Chunks. | ||
| 952 | */ | ||
| 953 | sinfo.sinfo_tsn = event->tsn; | 877 | sinfo.sinfo_tsn = event->tsn; |
| 954 | /* sinfo_cumtsn: 32 bit (unsigned integer) | ||
| 955 | * | ||
| 956 | * This field will hold the current cumulative TSN as | ||
| 957 | * known by the underlying SCTP layer. Note this field is | ||
| 958 | * ignored when sending and only valid for a receive | ||
| 959 | * operation when sinfo_flags are set to SCTP_UNORDERED. | ||
| 960 | */ | ||
| 961 | sinfo.sinfo_cumtsn = event->cumtsn; | 878 | sinfo.sinfo_cumtsn = event->cumtsn; |
| 962 | /* sinfo_assoc_id: sizeof (sctp_assoc_t) | ||
| 963 | * | ||
| 964 | * The association handle field, sinfo_assoc_id, holds the identifier | ||
| 965 | * for the association announced in the COMMUNICATION_UP notification. | ||
| 966 | * All notifications for a given association have the same identifier. | ||
| 967 | * Ignored for one-to-one style sockets. | ||
| 968 | */ | ||
| 969 | sinfo.sinfo_assoc_id = sctp_assoc2id(event->asoc); | 879 | sinfo.sinfo_assoc_id = sctp_assoc2id(event->asoc); |
| 970 | 880 | /* Context value that is set via SCTP_CONTEXT socket option. */ | |
| 971 | /* context value that is set via SCTP_CONTEXT socket option. */ | ||
| 972 | sinfo.sinfo_context = event->asoc->default_rcv_context; | 881 | sinfo.sinfo_context = event->asoc->default_rcv_context; |
| 973 | |||
| 974 | /* These fields are not used while receiving. */ | 882 | /* These fields are not used while receiving. */ |
| 975 | sinfo.sinfo_timetolive = 0; | 883 | sinfo.sinfo_timetolive = 0; |
| 976 | 884 | ||
| 977 | put_cmsg(msghdr, IPPROTO_SCTP, SCTP_SNDRCV, | 885 | put_cmsg(msghdr, IPPROTO_SCTP, SCTP_SNDRCV, |
| 978 | sizeof(struct sctp_sndrcvinfo), (void *)&sinfo); | 886 | sizeof(sinfo), &sinfo); |
| 979 | } | 887 | } |
| 980 | 888 | ||
| 981 | /* Do accounting for bytes received and hold a reference to the association | 889 | /* Do accounting for bytes received and hold a reference to the association |
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c index 26631679a1fa..55c6c9d3e1ce 100644 --- a/net/tipc/bcast.c +++ b/net/tipc/bcast.c | |||
| @@ -559,6 +559,7 @@ receive: | |||
| 559 | 559 | ||
| 560 | buf = node->bclink.deferred_head; | 560 | buf = node->bclink.deferred_head; |
| 561 | node->bclink.deferred_head = buf->next; | 561 | node->bclink.deferred_head = buf->next; |
| 562 | buf->next = NULL; | ||
| 562 | node->bclink.deferred_size--; | 563 | node->bclink.deferred_size--; |
| 563 | goto receive; | 564 | goto receive; |
| 564 | } | 565 | } |
diff --git a/net/tipc/msg.c b/net/tipc/msg.c index 8be6e94a1ca9..0a37a472c29f 100644 --- a/net/tipc/msg.c +++ b/net/tipc/msg.c | |||
| @@ -101,9 +101,11 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect, | |||
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | /* tipc_buf_append(): Append a buffer to the fragment list of another buffer | 103 | /* tipc_buf_append(): Append a buffer to the fragment list of another buffer |
| 104 | * Let first buffer become head buffer | 104 | * @*headbuf: in: NULL for first frag, otherwise value returned from prev call |
| 105 | * Returns 1 and sets *buf to headbuf if chain is complete, otherwise 0 | 105 | * out: set when successful non-complete reassembly, otherwise NULL |
| 106 | * Leaves headbuf pointer at NULL if failure | 106 | * @*buf: in: the buffer to append. Always defined |
| 107 | * out: head buf after sucessful complete reassembly, otherwise NULL | ||
| 108 | * Returns 1 when reassembly complete, otherwise 0 | ||
| 107 | */ | 109 | */ |
| 108 | int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) | 110 | int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) |
| 109 | { | 111 | { |
| @@ -122,6 +124,7 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) | |||
| 122 | goto out_free; | 124 | goto out_free; |
| 123 | head = *headbuf = frag; | 125 | head = *headbuf = frag; |
| 124 | skb_frag_list_init(head); | 126 | skb_frag_list_init(head); |
| 127 | *buf = NULL; | ||
| 125 | return 0; | 128 | return 0; |
| 126 | } | 129 | } |
| 127 | if (!head) | 130 | if (!head) |
| @@ -150,5 +153,7 @@ int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf) | |||
| 150 | out_free: | 153 | out_free: |
| 151 | pr_warn_ratelimited("Unable to build fragment list\n"); | 154 | pr_warn_ratelimited("Unable to build fragment list\n"); |
| 152 | kfree_skb(*buf); | 155 | kfree_skb(*buf); |
| 156 | kfree_skb(*headbuf); | ||
| 157 | *buf = *headbuf = NULL; | ||
| 153 | return 0; | 158 | return 0; |
| 154 | } | 159 | } |
diff --git a/net/wireless/core.h b/net/wireless/core.h index e9afbf10e756..7e3a3cef7df9 100644 --- a/net/wireless/core.h +++ b/net/wireless/core.h | |||
| @@ -424,7 +424,7 @@ static inline unsigned int elapsed_jiffies_msecs(unsigned long start) | |||
| 424 | if (end >= start) | 424 | if (end >= start) |
| 425 | return jiffies_to_msecs(end - start); | 425 | return jiffies_to_msecs(end - start); |
| 426 | 426 | ||
| 427 | return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1); | 427 | return jiffies_to_msecs(end + (ULONG_MAX - start) + 1); |
| 428 | } | 428 | } |
| 429 | 429 | ||
| 430 | void | 430 | void |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index ba4f1723c83a..6668daf69326 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
| @@ -1497,18 +1497,17 @@ static int nl80211_send_wiphy(struct cfg80211_registered_device *rdev, | |||
| 1497 | } | 1497 | } |
| 1498 | CMD(start_p2p_device, START_P2P_DEVICE); | 1498 | CMD(start_p2p_device, START_P2P_DEVICE); |
| 1499 | CMD(set_mcast_rate, SET_MCAST_RATE); | 1499 | CMD(set_mcast_rate, SET_MCAST_RATE); |
| 1500 | #ifdef CONFIG_NL80211_TESTMODE | ||
| 1501 | CMD(testmode_cmd, TESTMODE); | ||
| 1502 | #endif | ||
| 1500 | if (state->split) { | 1503 | if (state->split) { |
| 1501 | CMD(crit_proto_start, CRIT_PROTOCOL_START); | 1504 | CMD(crit_proto_start, CRIT_PROTOCOL_START); |
| 1502 | CMD(crit_proto_stop, CRIT_PROTOCOL_STOP); | 1505 | CMD(crit_proto_stop, CRIT_PROTOCOL_STOP); |
| 1503 | if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH) | 1506 | if (rdev->wiphy.flags & WIPHY_FLAG_HAS_CHANNEL_SWITCH) |
| 1504 | CMD(channel_switch, CHANNEL_SWITCH); | 1507 | CMD(channel_switch, CHANNEL_SWITCH); |
| 1508 | CMD(set_qos_map, SET_QOS_MAP); | ||
| 1505 | } | 1509 | } |
| 1506 | CMD(set_qos_map, SET_QOS_MAP); | 1510 | /* add into the if now */ |
| 1507 | |||
| 1508 | #ifdef CONFIG_NL80211_TESTMODE | ||
| 1509 | CMD(testmode_cmd, TESTMODE); | ||
| 1510 | #endif | ||
| 1511 | |||
| 1512 | #undef CMD | 1511 | #undef CMD |
| 1513 | 1512 | ||
| 1514 | if (rdev->ops->connect || rdev->ops->auth) { | 1513 | if (rdev->ops->connect || rdev->ops->auth) { |
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 558b0e3a02d8..1afdf45db38f 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
| @@ -935,7 +935,7 @@ freq_reg_info_regd(struct wiphy *wiphy, u32 center_freq, | |||
| 935 | if (!band_rule_found) | 935 | if (!band_rule_found) |
| 936 | band_rule_found = freq_in_rule_band(fr, center_freq); | 936 | band_rule_found = freq_in_rule_band(fr, center_freq); |
| 937 | 937 | ||
| 938 | bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(5)); | 938 | bw_fits = reg_does_bw_fit(fr, center_freq, MHZ_TO_KHZ(20)); |
| 939 | 939 | ||
| 940 | if (band_rule_found && bw_fits) | 940 | if (band_rule_found && bw_fits) |
| 941 | return rr; | 941 | return rr; |
| @@ -1019,10 +1019,10 @@ static void chan_reg_rule_print_dbg(const struct ieee80211_regdomain *regd, | |||
| 1019 | } | 1019 | } |
| 1020 | #endif | 1020 | #endif |
| 1021 | 1021 | ||
| 1022 | /* Find an ieee80211_reg_rule such that a 5MHz channel with frequency | 1022 | /* |
| 1023 | * chan->center_freq fits there. | 1023 | * Note that right now we assume the desired channel bandwidth |
| 1024 | * If there is no such reg_rule, disable the channel, otherwise set the | 1024 | * is always 20 MHz for each individual channel (HT40 uses 20 MHz |
| 1025 | * flags corresponding to the bandwidths allowed in the particular reg_rule | 1025 | * per channel, the primary and the extension channel). |
| 1026 | */ | 1026 | */ |
| 1027 | static void handle_channel(struct wiphy *wiphy, | 1027 | static void handle_channel(struct wiphy *wiphy, |
| 1028 | enum nl80211_reg_initiator initiator, | 1028 | enum nl80211_reg_initiator initiator, |
| @@ -1083,12 +1083,8 @@ static void handle_channel(struct wiphy *wiphy, | |||
| 1083 | if (reg_rule->flags & NL80211_RRF_AUTO_BW) | 1083 | if (reg_rule->flags & NL80211_RRF_AUTO_BW) |
| 1084 | max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule); | 1084 | max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule); |
| 1085 | 1085 | ||
| 1086 | if (max_bandwidth_khz < MHZ_TO_KHZ(10)) | ||
| 1087 | bw_flags = IEEE80211_CHAN_NO_10MHZ; | ||
| 1088 | if (max_bandwidth_khz < MHZ_TO_KHZ(20)) | ||
| 1089 | bw_flags |= IEEE80211_CHAN_NO_20MHZ; | ||
| 1090 | if (max_bandwidth_khz < MHZ_TO_KHZ(40)) | 1086 | if (max_bandwidth_khz < MHZ_TO_KHZ(40)) |
| 1091 | bw_flags |= IEEE80211_CHAN_NO_HT40; | 1087 | bw_flags = IEEE80211_CHAN_NO_HT40; |
| 1092 | if (max_bandwidth_khz < MHZ_TO_KHZ(80)) | 1088 | if (max_bandwidth_khz < MHZ_TO_KHZ(80)) |
| 1093 | bw_flags |= IEEE80211_CHAN_NO_80MHZ; | 1089 | bw_flags |= IEEE80211_CHAN_NO_80MHZ; |
| 1094 | if (max_bandwidth_khz < MHZ_TO_KHZ(160)) | 1090 | if (max_bandwidth_khz < MHZ_TO_KHZ(160)) |
| @@ -1522,12 +1518,8 @@ static void handle_channel_custom(struct wiphy *wiphy, | |||
| 1522 | if (reg_rule->flags & NL80211_RRF_AUTO_BW) | 1518 | if (reg_rule->flags & NL80211_RRF_AUTO_BW) |
| 1523 | max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule); | 1519 | max_bandwidth_khz = reg_get_max_bandwidth(regd, reg_rule); |
| 1524 | 1520 | ||
| 1525 | if (max_bandwidth_khz < MHZ_TO_KHZ(10)) | ||
| 1526 | bw_flags = IEEE80211_CHAN_NO_10MHZ; | ||
| 1527 | if (max_bandwidth_khz < MHZ_TO_KHZ(20)) | ||
| 1528 | bw_flags |= IEEE80211_CHAN_NO_20MHZ; | ||
| 1529 | if (max_bandwidth_khz < MHZ_TO_KHZ(40)) | 1521 | if (max_bandwidth_khz < MHZ_TO_KHZ(40)) |
| 1530 | bw_flags |= IEEE80211_CHAN_NO_HT40; | 1522 | bw_flags = IEEE80211_CHAN_NO_HT40; |
| 1531 | if (max_bandwidth_khz < MHZ_TO_KHZ(80)) | 1523 | if (max_bandwidth_khz < MHZ_TO_KHZ(80)) |
| 1532 | bw_flags |= IEEE80211_CHAN_NO_80MHZ; | 1524 | bw_flags |= IEEE80211_CHAN_NO_80MHZ; |
| 1533 | if (max_bandwidth_khz < MHZ_TO_KHZ(160)) | 1525 | if (max_bandwidth_khz < MHZ_TO_KHZ(160)) |
diff --git a/net/wireless/trace.h b/net/wireless/trace.h index 560ed77084e9..7cc887f9da11 100644 --- a/net/wireless/trace.h +++ b/net/wireless/trace.h | |||
| @@ -2094,7 +2094,8 @@ TRACE_EVENT(cfg80211_michael_mic_failure, | |||
| 2094 | MAC_ASSIGN(addr, addr); | 2094 | MAC_ASSIGN(addr, addr); |
| 2095 | __entry->key_type = key_type; | 2095 | __entry->key_type = key_type; |
| 2096 | __entry->key_id = key_id; | 2096 | __entry->key_id = key_id; |
| 2097 | memcpy(__entry->tsc, tsc, 6); | 2097 | if (tsc) |
| 2098 | memcpy(__entry->tsc, tsc, 6); | ||
| 2098 | ), | 2099 | ), |
| 2099 | TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT ", key type: %d, key id: %d, tsc: %pm", | 2100 | TP_printk(NETDEV_PR_FMT ", " MAC_PR_FMT ", key type: %d, key id: %d, tsc: %pm", |
| 2100 | NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->key_type, | 2101 | NETDEV_PR_ARG, MAC_PR_ARG(addr), __entry->key_type, |
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index a8ef5108e0d8..0525d78ba328 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
| @@ -2097,6 +2097,8 @@ struct dst_entry *xfrm_lookup(struct net *net, struct dst_entry *dst_orig, | |||
| 2097 | goto no_transform; | 2097 | goto no_transform; |
| 2098 | } | 2098 | } |
| 2099 | 2099 | ||
| 2100 | dst_hold(&xdst->u.dst); | ||
| 2101 | xdst->u.dst.flags |= DST_NOCACHE; | ||
| 2100 | route = xdst->route; | 2102 | route = xdst->route; |
| 2101 | } | 2103 | } |
| 2102 | } | 2104 | } |
diff --git a/net/xfrm/xfrm_user.c b/net/xfrm/xfrm_user.c index 412d9dc3a873..d4db6ebb089d 100644 --- a/net/xfrm/xfrm_user.c +++ b/net/xfrm/xfrm_user.c | |||
| @@ -177,9 +177,7 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, | |||
| 177 | attrs[XFRMA_ALG_AEAD] || | 177 | attrs[XFRMA_ALG_AEAD] || |
| 178 | attrs[XFRMA_ALG_CRYPT] || | 178 | attrs[XFRMA_ALG_CRYPT] || |
| 179 | attrs[XFRMA_ALG_COMP] || | 179 | attrs[XFRMA_ALG_COMP] || |
| 180 | attrs[XFRMA_TFCPAD] || | 180 | attrs[XFRMA_TFCPAD]) |
| 181 | (ntohl(p->id.spi) >= 0x10000)) | ||
| 182 | |||
| 183 | goto out; | 181 | goto out; |
| 184 | break; | 182 | break; |
| 185 | 183 | ||
| @@ -207,7 +205,8 @@ static int verify_newsa_info(struct xfrm_usersa_info *p, | |||
| 207 | attrs[XFRMA_ALG_AUTH] || | 205 | attrs[XFRMA_ALG_AUTH] || |
| 208 | attrs[XFRMA_ALG_AUTH_TRUNC] || | 206 | attrs[XFRMA_ALG_AUTH_TRUNC] || |
| 209 | attrs[XFRMA_ALG_CRYPT] || | 207 | attrs[XFRMA_ALG_CRYPT] || |
| 210 | attrs[XFRMA_TFCPAD]) | 208 | attrs[XFRMA_TFCPAD] || |
| 209 | (ntohl(p->id.spi) >= 0x10000)) | ||
| 211 | goto out; | 210 | goto out; |
| 212 | break; | 211 | break; |
| 213 | 212 | ||
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index da058da413e7..16a07cfa4d34 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -2073,6 +2073,7 @@ sub check_return_section { | |||
| 2073 | sub dump_function($$) { | 2073 | sub dump_function($$) { |
| 2074 | my $prototype = shift; | 2074 | my $prototype = shift; |
| 2075 | my $file = shift; | 2075 | my $file = shift; |
| 2076 | my $noret = 0; | ||
| 2076 | 2077 | ||
| 2077 | $prototype =~ s/^static +//; | 2078 | $prototype =~ s/^static +//; |
| 2078 | $prototype =~ s/^extern +//; | 2079 | $prototype =~ s/^extern +//; |
| @@ -2086,7 +2087,7 @@ sub dump_function($$) { | |||
| 2086 | $prototype =~ s/__init_or_module +//; | 2087 | $prototype =~ s/__init_or_module +//; |
| 2087 | $prototype =~ s/__must_check +//; | 2088 | $prototype =~ s/__must_check +//; |
| 2088 | $prototype =~ s/__weak +//; | 2089 | $prototype =~ s/__weak +//; |
| 2089 | $prototype =~ s/^#\s*define\s+//; #ak added | 2090 | my $define = $prototype =~ s/^#\s*define\s+//; #ak added |
| 2090 | $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; | 2091 | $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; |
| 2091 | 2092 | ||
| 2092 | # Yes, this truly is vile. We are looking for: | 2093 | # Yes, this truly is vile. We are looking for: |
| @@ -2105,7 +2106,15 @@ sub dump_function($$) { | |||
| 2105 | # - atomic_set (macro) | 2106 | # - atomic_set (macro) |
| 2106 | # - pci_match_device, __copy_to_user (long return type) | 2107 | # - pci_match_device, __copy_to_user (long return type) |
| 2107 | 2108 | ||
| 2108 | if ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || | 2109 | if ($define && $prototype =~ m/^()([a-zA-Z0-9_~:]+)\s+/) { |
| 2110 | # This is an object-like macro, it has no return type and no parameter | ||
| 2111 | # list. | ||
| 2112 | # Function-like macros are not allowed to have spaces between | ||
| 2113 | # declaration_name and opening parenthesis (notice the \s+). | ||
| 2114 | $return_type = $1; | ||
| 2115 | $declaration_name = $2; | ||
| 2116 | $noret = 1; | ||
| 2117 | } elsif ($prototype =~ m/^()([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || | ||
| 2109 | $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || | 2118 | $prototype =~ m/^(\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 2110 | $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || | 2119 | $prototype =~ m/^(\w+\s*\*)\s*([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| 2111 | $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || | 2120 | $prototype =~ m/^(\w+\s+\w+)\s+([a-zA-Z0-9_~:]+)\s*\(([^\(]*)\)/ || |
| @@ -2140,7 +2149,7 @@ sub dump_function($$) { | |||
| 2140 | # of warnings goes sufficiently down, the check is only performed in | 2149 | # of warnings goes sufficiently down, the check is only performed in |
| 2141 | # verbose mode. | 2150 | # verbose mode. |
| 2142 | # TODO: always perform the check. | 2151 | # TODO: always perform the check. |
| 2143 | if ($verbose) { | 2152 | if ($verbose && !$noret) { |
| 2144 | check_return_section($file, $declaration_name, $return_type); | 2153 | check_return_section($file, $declaration_name, $return_type); |
| 2145 | } | 2154 | } |
| 2146 | 2155 | ||
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c index 66de90ed30ca..39c3969ac1c7 100644 --- a/sound/arm/pxa2xx-ac97-lib.c +++ b/sound/arm/pxa2xx-ac97-lib.c | |||
| @@ -152,9 +152,9 @@ static inline void pxa_ac97_cold_pxa27x(void) | |||
| 152 | gsr_bits = 0; | 152 | gsr_bits = 0; |
| 153 | 153 | ||
| 154 | /* PXA27x Developers Manual section 13.5.2.2.1 */ | 154 | /* PXA27x Developers Manual section 13.5.2.2.1 */ |
| 155 | clk_enable(ac97conf_clk); | 155 | clk_prepare_enable(ac97conf_clk); |
| 156 | udelay(5); | 156 | udelay(5); |
| 157 | clk_disable(ac97conf_clk); | 157 | clk_disable_unprepare(ac97conf_clk); |
| 158 | GCR = GCR_COLD_RST | GCR_WARM_RST; | 158 | GCR = GCR_COLD_RST | GCR_WARM_RST; |
| 159 | } | 159 | } |
| 160 | #endif | 160 | #endif |
| @@ -299,14 +299,14 @@ static irqreturn_t pxa2xx_ac97_irq(int irq, void *dev_id) | |||
| 299 | int pxa2xx_ac97_hw_suspend(void) | 299 | int pxa2xx_ac97_hw_suspend(void) |
| 300 | { | 300 | { |
| 301 | GCR |= GCR_ACLINK_OFF; | 301 | GCR |= GCR_ACLINK_OFF; |
| 302 | clk_disable(ac97_clk); | 302 | clk_disable_unprepare(ac97_clk); |
| 303 | return 0; | 303 | return 0; |
| 304 | } | 304 | } |
| 305 | EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_suspend); | 305 | EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_suspend); |
| 306 | 306 | ||
| 307 | int pxa2xx_ac97_hw_resume(void) | 307 | int pxa2xx_ac97_hw_resume(void) |
| 308 | { | 308 | { |
| 309 | clk_enable(ac97_clk); | 309 | clk_prepare_enable(ac97_clk); |
| 310 | return 0; | 310 | return 0; |
| 311 | } | 311 | } |
| 312 | EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_resume); | 312 | EXPORT_SYMBOL_GPL(pxa2xx_ac97_hw_resume); |
| @@ -368,7 +368,7 @@ int pxa2xx_ac97_hw_probe(struct platform_device *dev) | |||
| 368 | goto err_clk; | 368 | goto err_clk; |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | ret = clk_enable(ac97_clk); | 371 | ret = clk_prepare_enable(ac97_clk); |
| 372 | if (ret) | 372 | if (ret) |
| 373 | goto err_clk2; | 373 | goto err_clk2; |
| 374 | 374 | ||
| @@ -403,7 +403,7 @@ void pxa2xx_ac97_hw_remove(struct platform_device *dev) | |||
| 403 | clk_put(ac97conf_clk); | 403 | clk_put(ac97conf_clk); |
| 404 | ac97conf_clk = NULL; | 404 | ac97conf_clk = NULL; |
| 405 | } | 405 | } |
| 406 | clk_disable(ac97_clk); | 406 | clk_disable_unprepare(ac97_clk); |
| 407 | clk_put(ac97_clk); | 407 | clk_put(ac97_clk); |
| 408 | ac97_clk = NULL; | 408 | ac97_clk = NULL; |
| 409 | } | 409 | } |
diff --git a/sound/core/control.c b/sound/core/control.c index f0b0e14497a5..b9611344ff9e 100644 --- a/sound/core/control.c +++ b/sound/core/control.c | |||
| @@ -1406,11 +1406,11 @@ static long snd_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long arg | |||
| 1406 | case SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS: | 1406 | case SNDRV_CTL_IOCTL_SUBSCRIBE_EVENTS: |
| 1407 | return snd_ctl_subscribe_events(ctl, ip); | 1407 | return snd_ctl_subscribe_events(ctl, ip); |
| 1408 | case SNDRV_CTL_IOCTL_TLV_READ: | 1408 | case SNDRV_CTL_IOCTL_TLV_READ: |
| 1409 | return snd_ctl_tlv_ioctl(ctl, argp, 0); | 1409 | return snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_READ); |
| 1410 | case SNDRV_CTL_IOCTL_TLV_WRITE: | 1410 | case SNDRV_CTL_IOCTL_TLV_WRITE: |
| 1411 | return snd_ctl_tlv_ioctl(ctl, argp, 1); | 1411 | return snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_WRITE); |
| 1412 | case SNDRV_CTL_IOCTL_TLV_COMMAND: | 1412 | case SNDRV_CTL_IOCTL_TLV_COMMAND: |
| 1413 | return snd_ctl_tlv_ioctl(ctl, argp, -1); | 1413 | return snd_ctl_tlv_ioctl(ctl, argp, SNDRV_CTL_TLV_OP_CMD); |
| 1414 | case SNDRV_CTL_IOCTL_POWER: | 1414 | case SNDRV_CTL_IOCTL_POWER: |
| 1415 | return -ENOPROTOOPT; | 1415 | return -ENOPROTOOPT; |
| 1416 | case SNDRV_CTL_IOCTL_POWER_STATE: | 1416 | case SNDRV_CTL_IOCTL_POWER_STATE: |
diff --git a/sound/core/pcm_dmaengine.c b/sound/core/pcm_dmaengine.c index 76cbb9ec953a..6542c4083594 100644 --- a/sound/core/pcm_dmaengine.c +++ b/sound/core/pcm_dmaengine.c | |||
| @@ -65,13 +65,15 @@ int snd_hwparams_to_dma_slave_config(const struct snd_pcm_substream *substream, | |||
| 65 | enum dma_slave_buswidth buswidth; | 65 | enum dma_slave_buswidth buswidth; |
| 66 | int bits; | 66 | int bits; |
| 67 | 67 | ||
| 68 | bits = snd_pcm_format_physical_width(params_format(params)); | 68 | bits = params_physical_width(params); |
| 69 | if (bits < 8 || bits > 64) | 69 | if (bits < 8 || bits > 64) |
| 70 | return -EINVAL; | 70 | return -EINVAL; |
| 71 | else if (bits == 8) | 71 | else if (bits == 8) |
| 72 | buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; | 72 | buswidth = DMA_SLAVE_BUSWIDTH_1_BYTE; |
| 73 | else if (bits == 16) | 73 | else if (bits == 16) |
| 74 | buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; | 74 | buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; |
| 75 | else if (bits == 24) | ||
| 76 | buswidth = DMA_SLAVE_BUSWIDTH_3_BYTES; | ||
| 75 | else if (bits <= 32) | 77 | else if (bits <= 32) |
| 76 | buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; | 78 | buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 77 | else | 79 | else |
diff --git a/sound/soc/Kconfig b/sound/soc/Kconfig index 0060b31cc3f3..0e9623368ab0 100644 --- a/sound/soc/Kconfig +++ b/sound/soc/Kconfig | |||
| @@ -47,6 +47,7 @@ source "sound/soc/kirkwood/Kconfig" | |||
| 47 | source "sound/soc/intel/Kconfig" | 47 | source "sound/soc/intel/Kconfig" |
| 48 | source "sound/soc/mxs/Kconfig" | 48 | source "sound/soc/mxs/Kconfig" |
| 49 | source "sound/soc/pxa/Kconfig" | 49 | source "sound/soc/pxa/Kconfig" |
| 50 | source "sound/soc/rockchip/Kconfig" | ||
| 50 | source "sound/soc/samsung/Kconfig" | 51 | source "sound/soc/samsung/Kconfig" |
| 51 | source "sound/soc/s6000/Kconfig" | 52 | source "sound/soc/s6000/Kconfig" |
| 52 | source "sound/soc/sh/Kconfig" | 53 | source "sound/soc/sh/Kconfig" |
diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 5f1df02984f8..534714a1ca44 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile | |||
| @@ -24,6 +24,7 @@ obj-$(CONFIG_SND_SOC) += nuc900/ | |||
| 24 | obj-$(CONFIG_SND_SOC) += omap/ | 24 | obj-$(CONFIG_SND_SOC) += omap/ |
| 25 | obj-$(CONFIG_SND_SOC) += kirkwood/ | 25 | obj-$(CONFIG_SND_SOC) += kirkwood/ |
| 26 | obj-$(CONFIG_SND_SOC) += pxa/ | 26 | obj-$(CONFIG_SND_SOC) += pxa/ |
| 27 | obj-$(CONFIG_SND_SOC) += rockchip/ | ||
| 27 | obj-$(CONFIG_SND_SOC) += samsung/ | 28 | obj-$(CONFIG_SND_SOC) += samsung/ |
| 28 | obj-$(CONFIG_SND_SOC) += s6000/ | 29 | obj-$(CONFIG_SND_SOC) += s6000/ |
| 29 | obj-$(CONFIG_SND_SOC) += sh/ | 30 | obj-$(CONFIG_SND_SOC) += sh/ |
diff --git a/sound/soc/atmel/atmel_ssc_dai.c b/sound/soc/atmel/atmel_ssc_dai.c index de433cfd044c..f403f399808a 100644 --- a/sound/soc/atmel/atmel_ssc_dai.c +++ b/sound/soc/atmel/atmel_ssc_dai.c | |||
| @@ -347,6 +347,7 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | |||
| 347 | u32 tfmr, rfmr, tcmr, rcmr; | 347 | u32 tfmr, rfmr, tcmr, rcmr; |
| 348 | int start_event; | 348 | int start_event; |
| 349 | int ret; | 349 | int ret; |
| 350 | int fslen, fslen_ext; | ||
| 350 | 351 | ||
| 351 | /* | 352 | /* |
| 352 | * Currently, there is only one set of dma params for | 353 | * Currently, there is only one set of dma params for |
| @@ -388,18 +389,6 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | |||
| 388 | } | 389 | } |
| 389 | 390 | ||
| 390 | /* | 391 | /* |
| 391 | * The SSC only supports up to 16-bit samples in I2S format, due | ||
| 392 | * to the size of the Frame Mode Register FSLEN field. | ||
| 393 | */ | ||
| 394 | if ((ssc_p->daifmt & SND_SOC_DAIFMT_FORMAT_MASK) == SND_SOC_DAIFMT_I2S | ||
| 395 | && bits > 16) { | ||
| 396 | printk(KERN_WARNING | ||
| 397 | "atmel_ssc_dai: sample size %d " | ||
| 398 | "is too large for I2S\n", bits); | ||
| 399 | return -EINVAL; | ||
| 400 | } | ||
| 401 | |||
| 402 | /* | ||
| 403 | * Compute SSC register settings. | 392 | * Compute SSC register settings. |
| 404 | */ | 393 | */ |
| 405 | switch (ssc_p->daifmt | 394 | switch (ssc_p->daifmt |
| @@ -413,6 +402,17 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | |||
| 413 | * from the MCK divider, and the BCLK signal | 402 | * from the MCK divider, and the BCLK signal |
| 414 | * is output on the SSC TK line. | 403 | * is output on the SSC TK line. |
| 415 | */ | 404 | */ |
| 405 | |||
| 406 | if (bits > 16 && !ssc->pdata->has_fslen_ext) { | ||
| 407 | dev_err(dai->dev, | ||
| 408 | "sample size %d is too large for SSC device\n", | ||
| 409 | bits); | ||
| 410 | return -EINVAL; | ||
| 411 | } | ||
| 412 | |||
| 413 | fslen_ext = (bits - 1) / 16; | ||
| 414 | fslen = (bits - 1) % 16; | ||
| 415 | |||
| 416 | rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period) | 416 | rcmr = SSC_BF(RCMR_PERIOD, ssc_p->rcmr_period) |
| 417 | | SSC_BF(RCMR_STTDLY, START_DELAY) | 417 | | SSC_BF(RCMR_STTDLY, START_DELAY) |
| 418 | | SSC_BF(RCMR_START, SSC_START_FALLING_RF) | 418 | | SSC_BF(RCMR_START, SSC_START_FALLING_RF) |
| @@ -420,9 +420,10 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | |||
| 420 | | SSC_BF(RCMR_CKO, SSC_CKO_NONE) | 420 | | SSC_BF(RCMR_CKO, SSC_CKO_NONE) |
| 421 | | SSC_BF(RCMR_CKS, SSC_CKS_DIV); | 421 | | SSC_BF(RCMR_CKS, SSC_CKS_DIV); |
| 422 | 422 | ||
| 423 | rfmr = SSC_BF(RFMR_FSEDGE, SSC_FSEDGE_POSITIVE) | 423 | rfmr = SSC_BF(RFMR_FSLEN_EXT, fslen_ext) |
| 424 | | SSC_BF(RFMR_FSEDGE, SSC_FSEDGE_POSITIVE) | ||
| 424 | | SSC_BF(RFMR_FSOS, SSC_FSOS_NEGATIVE) | 425 | | SSC_BF(RFMR_FSOS, SSC_FSOS_NEGATIVE) |
| 425 | | SSC_BF(RFMR_FSLEN, (bits - 1)) | 426 | | SSC_BF(RFMR_FSLEN, fslen) |
| 426 | | SSC_BF(RFMR_DATNB, (channels - 1)) | 427 | | SSC_BF(RFMR_DATNB, (channels - 1)) |
| 427 | | SSC_BIT(RFMR_MSBF) | 428 | | SSC_BIT(RFMR_MSBF) |
| 428 | | SSC_BF(RFMR_LOOP, 0) | 429 | | SSC_BF(RFMR_LOOP, 0) |
| @@ -435,10 +436,11 @@ static int atmel_ssc_hw_params(struct snd_pcm_substream *substream, | |||
| 435 | | SSC_BF(TCMR_CKO, SSC_CKO_CONTINUOUS) | 436 | | SSC_BF(TCMR_CKO, SSC_CKO_CONTINUOUS) |
| 436 | | SSC_BF(TCMR_CKS, SSC_CKS_DIV); | 437 | | SSC_BF(TCMR_CKS, SSC_CKS_DIV); |
| 437 | 438 | ||
| 438 | tfmr = SSC_BF(TFMR_FSEDGE, SSC_FSEDGE_POSITIVE) | 439 | tfmr = SSC_BF(TFMR_FSLEN_EXT, fslen_ext) |
| 440 | | SSC_BF(TFMR_FSEDGE, SSC_FSEDGE_POSITIVE) | ||
| 439 | | SSC_BF(TFMR_FSDEN, 0) | 441 | | SSC_BF(TFMR_FSDEN, 0) |
| 440 | | SSC_BF(TFMR_FSOS, SSC_FSOS_NEGATIVE) | 442 | | SSC_BF(TFMR_FSOS, SSC_FSOS_NEGATIVE) |
| 441 | | SSC_BF(TFMR_FSLEN, (bits - 1)) | 443 | | SSC_BF(TFMR_FSLEN, fslen) |
| 442 | | SSC_BF(TFMR_DATNB, (channels - 1)) | 444 | | SSC_BF(TFMR_DATNB, (channels - 1)) |
| 443 | | SSC_BIT(TFMR_MSBF) | 445 | | SSC_BIT(TFMR_MSBF) |
| 444 | | SSC_BF(TFMR_DATDEF, 0) | 446 | | SSC_BF(TFMR_DATDEF, 0) |
diff --git a/sound/soc/atmel/atmel_wm8904.c b/sound/soc/atmel/atmel_wm8904.c index b4e36901a40b..4052268ce462 100644 --- a/sound/soc/atmel/atmel_wm8904.c +++ b/sound/soc/atmel/atmel_wm8904.c | |||
| @@ -18,10 +18,6 @@ | |||
| 18 | #include "../codecs/wm8904.h" | 18 | #include "../codecs/wm8904.h" |
| 19 | #include "atmel_ssc_dai.h" | 19 | #include "atmel_ssc_dai.h" |
| 20 | 20 | ||
| 21 | #define MCLK_RATE 32768 | ||
| 22 | |||
| 23 | static struct clk *mclk; | ||
| 24 | |||
| 25 | static const struct snd_soc_dapm_widget atmel_asoc_wm8904_dapm_widgets[] = { | 21 | static const struct snd_soc_dapm_widget atmel_asoc_wm8904_dapm_widgets[] = { |
| 26 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | 22 | SND_SOC_DAPM_HP("Headphone Jack", NULL), |
| 27 | SND_SOC_DAPM_MIC("Mic", NULL), | 23 | SND_SOC_DAPM_MIC("Mic", NULL), |
| @@ -61,26 +57,6 @@ static struct snd_soc_ops atmel_asoc_wm8904_ops = { | |||
| 61 | .hw_params = atmel_asoc_wm8904_hw_params, | 57 | .hw_params = atmel_asoc_wm8904_hw_params, |
| 62 | }; | 58 | }; |
| 63 | 59 | ||
| 64 | static int atmel_set_bias_level(struct snd_soc_card *card, | ||
| 65 | struct snd_soc_dapm_context *dapm, | ||
| 66 | enum snd_soc_bias_level level) | ||
| 67 | { | ||
| 68 | if (dapm->bias_level == SND_SOC_BIAS_STANDBY) { | ||
| 69 | switch (level) { | ||
| 70 | case SND_SOC_BIAS_PREPARE: | ||
| 71 | clk_prepare_enable(mclk); | ||
| 72 | break; | ||
| 73 | case SND_SOC_BIAS_OFF: | ||
| 74 | clk_disable_unprepare(mclk); | ||
| 75 | break; | ||
| 76 | default: | ||
| 77 | break; | ||
| 78 | } | ||
| 79 | } | ||
| 80 | |||
| 81 | return 0; | ||
| 82 | }; | ||
| 83 | |||
| 84 | static struct snd_soc_dai_link atmel_asoc_wm8904_dailink = { | 60 | static struct snd_soc_dai_link atmel_asoc_wm8904_dailink = { |
| 85 | .name = "WM8904", | 61 | .name = "WM8904", |
| 86 | .stream_name = "WM8904 PCM", | 62 | .stream_name = "WM8904 PCM", |
| @@ -94,7 +70,6 @@ static struct snd_soc_dai_link atmel_asoc_wm8904_dailink = { | |||
| 94 | static struct snd_soc_card atmel_asoc_wm8904_card = { | 70 | static struct snd_soc_card atmel_asoc_wm8904_card = { |
| 95 | .name = "atmel_asoc_wm8904", | 71 | .name = "atmel_asoc_wm8904", |
| 96 | .owner = THIS_MODULE, | 72 | .owner = THIS_MODULE, |
| 97 | .set_bias_level = atmel_set_bias_level, | ||
| 98 | .dai_link = &atmel_asoc_wm8904_dailink, | 73 | .dai_link = &atmel_asoc_wm8904_dailink, |
| 99 | .num_links = 1, | 74 | .num_links = 1, |
| 100 | .dapm_widgets = atmel_asoc_wm8904_dapm_widgets, | 75 | .dapm_widgets = atmel_asoc_wm8904_dapm_widgets, |
| @@ -153,7 +128,6 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev) | |||
| 153 | { | 128 | { |
| 154 | struct snd_soc_card *card = &atmel_asoc_wm8904_card; | 129 | struct snd_soc_card *card = &atmel_asoc_wm8904_card; |
| 155 | struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink; | 130 | struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink; |
| 156 | struct clk *clk_src; | ||
| 157 | int id, ret; | 131 | int id, ret; |
| 158 | 132 | ||
| 159 | card->dev = &pdev->dev; | 133 | card->dev = &pdev->dev; |
| @@ -170,30 +144,6 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev) | |||
| 170 | return ret; | 144 | return ret; |
| 171 | } | 145 | } |
| 172 | 146 | ||
| 173 | mclk = clk_get(NULL, "pck0"); | ||
| 174 | if (IS_ERR(mclk)) { | ||
| 175 | dev_err(&pdev->dev, "failed to get pck0\n"); | ||
| 176 | ret = PTR_ERR(mclk); | ||
| 177 | goto err_set_audio; | ||
| 178 | } | ||
| 179 | |||
| 180 | clk_src = clk_get(NULL, "clk32k"); | ||
| 181 | if (IS_ERR(clk_src)) { | ||
| 182 | dev_err(&pdev->dev, "failed to get clk32k\n"); | ||
| 183 | ret = PTR_ERR(clk_src); | ||
| 184 | goto err_set_audio; | ||
| 185 | } | ||
| 186 | |||
| 187 | ret = clk_set_parent(mclk, clk_src); | ||
| 188 | clk_put(clk_src); | ||
| 189 | if (ret != 0) { | ||
| 190 | dev_err(&pdev->dev, "failed to set MCLK parent\n"); | ||
| 191 | goto err_set_audio; | ||
| 192 | } | ||
| 193 | |||
| 194 | dev_info(&pdev->dev, "setting pck0 to %dHz\n", MCLK_RATE); | ||
| 195 | clk_set_rate(mclk, MCLK_RATE); | ||
| 196 | |||
| 197 | ret = snd_soc_register_card(card); | 147 | ret = snd_soc_register_card(card); |
| 198 | if (ret) { | 148 | if (ret) { |
| 199 | dev_err(&pdev->dev, "snd_soc_register_card failed\n"); | 149 | dev_err(&pdev->dev, "snd_soc_register_card failed\n"); |
diff --git a/sound/soc/blackfin/bf5xx-i2s-pcm.c b/sound/soc/blackfin/bf5xx-i2s-pcm.c index a3881c4381c9..bcf591373a7a 100644 --- a/sound/soc/blackfin/bf5xx-i2s-pcm.c +++ b/sound/soc/blackfin/bf5xx-i2s-pcm.c | |||
| @@ -290,19 +290,19 @@ static int bf5xx_pcm_silence(struct snd_pcm_substream *substream, | |||
| 290 | unsigned int sample_size = runtime->sample_bits / 8; | 290 | unsigned int sample_size = runtime->sample_bits / 8; |
| 291 | void *buf = runtime->dma_area; | 291 | void *buf = runtime->dma_area; |
| 292 | struct bf5xx_i2s_pcm_data *dma_data; | 292 | struct bf5xx_i2s_pcm_data *dma_data; |
| 293 | unsigned int offset, size; | 293 | unsigned int offset, samples; |
| 294 | 294 | ||
| 295 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | 295 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
| 296 | 296 | ||
| 297 | if (dma_data->tdm_mode) { | 297 | if (dma_data->tdm_mode) { |
| 298 | offset = pos * 8 * sample_size; | 298 | offset = pos * 8 * sample_size; |
| 299 | size = count * 8 * sample_size; | 299 | samples = count * 8; |
| 300 | } else { | 300 | } else { |
| 301 | offset = frames_to_bytes(runtime, pos); | 301 | offset = frames_to_bytes(runtime, pos); |
| 302 | size = frames_to_bytes(runtime, count); | 302 | samples = count * runtime->channels; |
| 303 | } | 303 | } |
| 304 | 304 | ||
| 305 | snd_pcm_format_set_silence(runtime->format, buf + offset, size); | 305 | snd_pcm_format_set_silence(runtime->format, buf + offset, samples); |
| 306 | 306 | ||
| 307 | return 0; | 307 | return 0; |
| 308 | } | 308 | } |
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index 3c4b10ff48c1..922006dd0583 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c | |||
| @@ -945,11 +945,11 @@ static int pm860x_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 945 | unsigned char inf = 0, mask = 0; | 945 | unsigned char inf = 0, mask = 0; |
| 946 | 946 | ||
| 947 | /* bit size */ | 947 | /* bit size */ |
| 948 | switch (params_format(params)) { | 948 | switch (params_width(params)) { |
| 949 | case SNDRV_PCM_FORMAT_S16_LE: | 949 | case 16: |
| 950 | inf &= ~PCM_INF2_18WL; | 950 | inf &= ~PCM_INF2_18WL; |
| 951 | break; | 951 | break; |
| 952 | case SNDRV_PCM_FORMAT_S18_3LE: | 952 | case 18: |
| 953 | inf |= PCM_INF2_18WL; | 953 | inf |= PCM_INF2_18WL; |
| 954 | break; | 954 | break; |
| 955 | default: | 955 | default: |
| @@ -1044,11 +1044,11 @@ static int pm860x_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 1044 | unsigned char inf; | 1044 | unsigned char inf; |
| 1045 | 1045 | ||
| 1046 | /* bit size */ | 1046 | /* bit size */ |
| 1047 | switch (params_format(params)) { | 1047 | switch (params_width(params)) { |
| 1048 | case SNDRV_PCM_FORMAT_S16_LE: | 1048 | case 16: |
| 1049 | inf = 0; | 1049 | inf = 0; |
| 1050 | break; | 1050 | break; |
| 1051 | case SNDRV_PCM_FORMAT_S18_3LE: | 1051 | case 18: |
| 1052 | inf = PCM_INF2_18WL; | 1052 | inf = PCM_INF2_18WL; |
| 1053 | break; | 1053 | break; |
| 1054 | default: | 1054 | default: |
diff --git a/sound/soc/codecs/Kconfig b/sound/soc/codecs/Kconfig index 0b9571c858f8..8838838e25ed 100644 --- a/sound/soc/codecs/Kconfig +++ b/sound/soc/codecs/Kconfig | |||
| @@ -47,6 +47,7 @@ config SND_SOC_ALL_CODECS | |||
| 47 | select SND_SOC_CS42L52 if I2C && INPUT | 47 | select SND_SOC_CS42L52 if I2C && INPUT |
| 48 | select SND_SOC_CS42L56 if I2C && INPUT | 48 | select SND_SOC_CS42L56 if I2C && INPUT |
| 49 | select SND_SOC_CS42L73 if I2C | 49 | select SND_SOC_CS42L73 if I2C |
| 50 | select SND_SOC_CS4265 if I2C | ||
| 50 | select SND_SOC_CS4270 if I2C | 51 | select SND_SOC_CS4270 if I2C |
| 51 | select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI | 52 | select SND_SOC_CS4271 if SND_SOC_I2C_AND_SPI |
| 52 | select SND_SOC_CS42XX8_I2C if I2C | 53 | select SND_SOC_CS42XX8_I2C if I2C |
| @@ -74,10 +75,12 @@ config SND_SOC_ALL_CODECS | |||
| 74 | select SND_SOC_PCM3008 | 75 | select SND_SOC_PCM3008 |
| 75 | select SND_SOC_PCM512x_I2C if I2C | 76 | select SND_SOC_PCM512x_I2C if I2C |
| 76 | select SND_SOC_PCM512x_SPI if SPI_MASTER | 77 | select SND_SOC_PCM512x_SPI if SPI_MASTER |
| 78 | select SND_SOC_RT286 if I2C | ||
| 77 | select SND_SOC_RT5631 if I2C | 79 | select SND_SOC_RT5631 if I2C |
| 78 | select SND_SOC_RT5640 if I2C | 80 | select SND_SOC_RT5640 if I2C |
| 79 | select SND_SOC_RT5645 if I2C | 81 | select SND_SOC_RT5645 if I2C |
| 80 | select SND_SOC_RT5651 if I2C | 82 | select SND_SOC_RT5651 if I2C |
| 83 | select SND_SOC_RT5670 if I2C | ||
| 81 | select SND_SOC_RT5677 if I2C | 84 | select SND_SOC_RT5677 if I2C |
| 82 | select SND_SOC_SGTL5000 if I2C | 85 | select SND_SOC_SGTL5000 if I2C |
| 83 | select SND_SOC_SI476X if MFD_SI476X_CORE | 86 | select SND_SOC_SI476X if MFD_SI476X_CORE |
| @@ -91,6 +94,7 @@ config SND_SOC_ALL_CODECS | |||
| 91 | select SND_SOC_STA350 if I2C | 94 | select SND_SOC_STA350 if I2C |
| 92 | select SND_SOC_STA529 if I2C | 95 | select SND_SOC_STA529 if I2C |
| 93 | select SND_SOC_STAC9766 if SND_SOC_AC97_BUS | 96 | select SND_SOC_STAC9766 if SND_SOC_AC97_BUS |
| 97 | select SND_SOC_TAS2552 if I2C | ||
| 94 | select SND_SOC_TAS5086 if I2C | 98 | select SND_SOC_TAS5086 if I2C |
| 95 | select SND_SOC_TLV320AIC23_I2C if I2C | 99 | select SND_SOC_TLV320AIC23_I2C if I2C |
| 96 | select SND_SOC_TLV320AIC23_SPI if SPI_MASTER | 100 | select SND_SOC_TLV320AIC23_SPI if SPI_MASTER |
| @@ -338,6 +342,11 @@ config SND_SOC_CS42L73 | |||
| 338 | tristate "Cirrus Logic CS42L73 CODEC" | 342 | tristate "Cirrus Logic CS42L73 CODEC" |
| 339 | depends on I2C | 343 | depends on I2C |
| 340 | 344 | ||
| 345 | config SND_SOC_CS4265 | ||
| 346 | tristate "Cirrus Logic CS4265 CODEC" | ||
| 347 | depends on I2C | ||
| 348 | select REGMAP_I2C | ||
| 349 | |||
| 341 | # Cirrus Logic CS4270 Codec | 350 | # Cirrus Logic CS4270 Codec |
| 342 | config SND_SOC_CS4270 | 351 | config SND_SOC_CS4270 |
| 343 | tristate "Cirrus Logic CS4270 CODEC" | 352 | tristate "Cirrus Logic CS4270 CODEC" |
| @@ -445,9 +454,16 @@ config SND_SOC_RL6231 | |||
| 445 | default y if SND_SOC_RT5640=y | 454 | default y if SND_SOC_RT5640=y |
| 446 | default y if SND_SOC_RT5645=y | 455 | default y if SND_SOC_RT5645=y |
| 447 | default y if SND_SOC_RT5651=y | 456 | default y if SND_SOC_RT5651=y |
| 457 | default y if SND_SOC_RT5670=y | ||
| 458 | default y if SND_SOC_RT5677=y | ||
| 448 | default m if SND_SOC_RT5640=m | 459 | default m if SND_SOC_RT5640=m |
| 449 | default m if SND_SOC_RT5645=m | 460 | default m if SND_SOC_RT5645=m |
| 450 | default m if SND_SOC_RT5651=m | 461 | default m if SND_SOC_RT5651=m |
| 462 | default m if SND_SOC_RT5670=m | ||
| 463 | default m if SND_SOC_RT5677=m | ||
| 464 | |||
| 465 | config SND_SOC_RT286 | ||
| 466 | tristate | ||
| 451 | 467 | ||
| 452 | config SND_SOC_RT5631 | 468 | config SND_SOC_RT5631 |
| 453 | tristate | 469 | tristate |
| @@ -461,6 +477,9 @@ config SND_SOC_RT5645 | |||
| 461 | config SND_SOC_RT5651 | 477 | config SND_SOC_RT5651 |
| 462 | tristate | 478 | tristate |
| 463 | 479 | ||
| 480 | config SND_SOC_RT5670 | ||
| 481 | tristate | ||
| 482 | |||
| 464 | config SND_SOC_RT5677 | 483 | config SND_SOC_RT5677 |
| 465 | tristate | 484 | tristate |
| 466 | 485 | ||
| @@ -521,6 +540,10 @@ config SND_SOC_STA529 | |||
| 521 | config SND_SOC_STAC9766 | 540 | config SND_SOC_STAC9766 |
| 522 | tristate | 541 | tristate |
| 523 | 542 | ||
| 543 | config SND_SOC_TAS2552 | ||
| 544 | tristate "Texas Instruments TAS2552 Mono Audio amplifier" | ||
| 545 | depends on I2C | ||
| 546 | |||
| 524 | config SND_SOC_TAS5086 | 547 | config SND_SOC_TAS5086 |
| 525 | tristate "Texas Instruments TAS5086 speaker amplifier" | 548 | tristate "Texas Instruments TAS5086 speaker amplifier" |
| 526 | depends on I2C | 549 | depends on I2C |
| @@ -541,7 +564,9 @@ config SND_SOC_TLV320AIC26 | |||
| 541 | depends on SPI | 564 | depends on SPI |
| 542 | 565 | ||
| 543 | config SND_SOC_TLV320AIC31XX | 566 | config SND_SOC_TLV320AIC31XX |
| 544 | tristate | 567 | tristate "Texas Instruments TLV320AIC31xx CODECs" |
| 568 | depends on I2C | ||
| 569 | select REGMAP_I2C | ||
| 545 | 570 | ||
| 546 | config SND_SOC_TLV320AIC32X4 | 571 | config SND_SOC_TLV320AIC32X4 |
| 547 | tristate | 572 | tristate |
diff --git a/sound/soc/codecs/Makefile b/sound/soc/codecs/Makefile index 1bd6e1cf6f82..20afe0f0c5be 100644 --- a/sound/soc/codecs/Makefile +++ b/sound/soc/codecs/Makefile | |||
| @@ -37,6 +37,7 @@ snd-soc-cs42l51-i2c-objs := cs42l51-i2c.o | |||
| 37 | snd-soc-cs42l52-objs := cs42l52.o | 37 | snd-soc-cs42l52-objs := cs42l52.o |
| 38 | snd-soc-cs42l56-objs := cs42l56.o | 38 | snd-soc-cs42l56-objs := cs42l56.o |
| 39 | snd-soc-cs42l73-objs := cs42l73.o | 39 | snd-soc-cs42l73-objs := cs42l73.o |
| 40 | snd-soc-cs4265-objs := cs4265.o | ||
| 40 | snd-soc-cs4270-objs := cs4270.o | 41 | snd-soc-cs4270-objs := cs4270.o |
| 41 | snd-soc-cs4271-objs := cs4271.o | 42 | snd-soc-cs4271-objs := cs4271.o |
| 42 | snd-soc-cs42xx8-objs := cs42xx8.o | 43 | snd-soc-cs42xx8-objs := cs42xx8.o |
| @@ -68,10 +69,12 @@ snd-soc-pcm512x-objs := pcm512x.o | |||
| 68 | snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o | 69 | snd-soc-pcm512x-i2c-objs := pcm512x-i2c.o |
| 69 | snd-soc-pcm512x-spi-objs := pcm512x-spi.o | 70 | snd-soc-pcm512x-spi-objs := pcm512x-spi.o |
| 70 | snd-soc-rl6231-objs := rl6231.o | 71 | snd-soc-rl6231-objs := rl6231.o |
| 72 | snd-soc-rt286-objs := rt286.o | ||
| 71 | snd-soc-rt5631-objs := rt5631.o | 73 | snd-soc-rt5631-objs := rt5631.o |
| 72 | snd-soc-rt5640-objs := rt5640.o | 74 | snd-soc-rt5640-objs := rt5640.o |
| 73 | snd-soc-rt5645-objs := rt5645.o | 75 | snd-soc-rt5645-objs := rt5645.o |
| 74 | snd-soc-rt5651-objs := rt5651.o | 76 | snd-soc-rt5651-objs := rt5651.o |
| 77 | snd-soc-rt5670-objs := rt5670.o | ||
| 75 | snd-soc-rt5677-objs := rt5677.o | 78 | snd-soc-rt5677-objs := rt5677.o |
| 76 | snd-soc-sgtl5000-objs := sgtl5000.o | 79 | snd-soc-sgtl5000-objs := sgtl5000.o |
| 77 | snd-soc-alc5623-objs := alc5623.o | 80 | snd-soc-alc5623-objs := alc5623.o |
| @@ -162,6 +165,7 @@ snd-soc-wm-hubs-objs := wm_hubs.o | |||
| 162 | # Amp | 165 | # Amp |
| 163 | snd-soc-max9877-objs := max9877.o | 166 | snd-soc-max9877-objs := max9877.o |
| 164 | snd-soc-tpa6130a2-objs := tpa6130a2.o | 167 | snd-soc-tpa6130a2-objs := tpa6130a2.o |
| 168 | snd-soc-tas2552-objs := tas2552.o | ||
| 165 | 169 | ||
| 166 | obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o | 170 | obj-$(CONFIG_SND_SOC_88PM860X) += snd-soc-88pm860x.o |
| 167 | obj-$(CONFIG_SND_SOC_AB8500_CODEC) += snd-soc-ab8500-codec.o | 171 | obj-$(CONFIG_SND_SOC_AB8500_CODEC) += snd-soc-ab8500-codec.o |
| @@ -204,6 +208,7 @@ obj-$(CONFIG_SND_SOC_CS42L51_I2C) += snd-soc-cs42l51-i2c.o | |||
| 204 | obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o | 208 | obj-$(CONFIG_SND_SOC_CS42L52) += snd-soc-cs42l52.o |
| 205 | obj-$(CONFIG_SND_SOC_CS42L56) += snd-soc-cs42l56.o | 209 | obj-$(CONFIG_SND_SOC_CS42L56) += snd-soc-cs42l56.o |
| 206 | obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o | 210 | obj-$(CONFIG_SND_SOC_CS42L73) += snd-soc-cs42l73.o |
| 211 | obj-$(CONFIG_SND_SOC_CS4265) += snd-soc-cs4265.o | ||
| 207 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o | 212 | obj-$(CONFIG_SND_SOC_CS4270) += snd-soc-cs4270.o |
| 208 | obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o | 213 | obj-$(CONFIG_SND_SOC_CS4271) += snd-soc-cs4271.o |
| 209 | obj-$(CONFIG_SND_SOC_CS42XX8) += snd-soc-cs42xx8.o | 214 | obj-$(CONFIG_SND_SOC_CS42XX8) += snd-soc-cs42xx8.o |
| @@ -235,10 +240,12 @@ obj-$(CONFIG_SND_SOC_PCM512x) += snd-soc-pcm512x.o | |||
| 235 | obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o | 240 | obj-$(CONFIG_SND_SOC_PCM512x_I2C) += snd-soc-pcm512x-i2c.o |
| 236 | obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o | 241 | obj-$(CONFIG_SND_SOC_PCM512x_SPI) += snd-soc-pcm512x-spi.o |
| 237 | obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o | 242 | obj-$(CONFIG_SND_SOC_RL6231) += snd-soc-rl6231.o |
| 243 | obj-$(CONFIG_SND_SOC_RT286) += snd-soc-rt286.o | ||
| 238 | obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o | 244 | obj-$(CONFIG_SND_SOC_RT5631) += snd-soc-rt5631.o |
| 239 | obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o | 245 | obj-$(CONFIG_SND_SOC_RT5640) += snd-soc-rt5640.o |
| 240 | obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o | 246 | obj-$(CONFIG_SND_SOC_RT5645) += snd-soc-rt5645.o |
| 241 | obj-$(CONFIG_SND_SOC_RT5651) += snd-soc-rt5651.o | 247 | obj-$(CONFIG_SND_SOC_RT5651) += snd-soc-rt5651.o |
| 248 | obj-$(CONFIG_SND_SOC_RT5670) += snd-soc-rt5670.o | ||
| 242 | obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o | 249 | obj-$(CONFIG_SND_SOC_RT5677) += snd-soc-rt5677.o |
| 243 | obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o | 250 | obj-$(CONFIG_SND_SOC_SGTL5000) += snd-soc-sgtl5000.o |
| 244 | obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o | 251 | obj-$(CONFIG_SND_SOC_SIGMADSP) += snd-soc-sigmadsp.o |
| @@ -255,6 +262,7 @@ obj-$(CONFIG_SND_SOC_STA32X) += snd-soc-sta32x.o | |||
| 255 | obj-$(CONFIG_SND_SOC_STA350) += snd-soc-sta350.o | 262 | obj-$(CONFIG_SND_SOC_STA350) += snd-soc-sta350.o |
| 256 | obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o | 263 | obj-$(CONFIG_SND_SOC_STA529) += snd-soc-sta529.o |
| 257 | obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o | 264 | obj-$(CONFIG_SND_SOC_STAC9766) += snd-soc-stac9766.o |
| 265 | obj-$(CONFIG_SND_SOC_TAS2552) += snd-soc-tas2552.o | ||
| 258 | obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o | 266 | obj-$(CONFIG_SND_SOC_TAS5086) += snd-soc-tas5086.o |
| 259 | obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o | 267 | obj-$(CONFIG_SND_SOC_TLV320AIC23) += snd-soc-tlv320aic23.o |
| 260 | obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o | 268 | obj-$(CONFIG_SND_SOC_TLV320AIC23_I2C) += snd-soc-tlv320aic23-i2c.o |
diff --git a/sound/soc/codecs/ac97.c b/sound/soc/codecs/ac97.c index 8d9ba4ba4bfe..e889e1b84192 100644 --- a/sound/soc/codecs/ac97.c +++ b/sound/soc/codecs/ac97.c | |||
| @@ -89,8 +89,8 @@ static int ac97_soc_probe(struct snd_soc_codec *codec) | |||
| 89 | int ret; | 89 | int ret; |
| 90 | 90 | ||
| 91 | /* add codec as bus device for standard ac97 */ | 91 | /* add codec as bus device for standard ac97 */ |
| 92 | ret = snd_ac97_bus(codec->card->snd_card, 0, soc_ac97_ops, NULL, | 92 | ret = snd_ac97_bus(codec->component.card->snd_card, 0, soc_ac97_ops, |
| 93 | &ac97_bus); | 93 | NULL, &ac97_bus); |
| 94 | if (ret < 0) | 94 | if (ret < 0) |
| 95 | return ret; | 95 | return ret; |
| 96 | 96 | ||
diff --git a/sound/soc/codecs/adau1701.c b/sound/soc/codecs/adau1701.c index d71c59cf7bdd..370b742117ef 100644 --- a/sound/soc/codecs/adau1701.c +++ b/sound/soc/codecs/adau1701.c | |||
| @@ -230,8 +230,10 @@ static int adau1701_reg_read(void *context, unsigned int reg, | |||
| 230 | 230 | ||
| 231 | *value = 0; | 231 | *value = 0; |
| 232 | 232 | ||
| 233 | for (i = 0; i < size; i++) | 233 | for (i = 0; i < size; i++) { |
| 234 | *value |= recv_buf[i] << (i * 8); | 234 | *value <<= 8; |
| 235 | *value |= recv_buf[i]; | ||
| 236 | } | ||
| 235 | 237 | ||
| 236 | return 0; | 238 | return 0; |
| 237 | } | 239 | } |
diff --git a/sound/soc/codecs/adau17x1.c b/sound/soc/codecs/adau17x1.c index 2961fae9670a..0b659704e60c 100644 --- a/sound/soc/codecs/adau17x1.c +++ b/sound/soc/codecs/adau17x1.c | |||
| @@ -359,14 +359,14 @@ static int adau17x1_hw_params(struct snd_pcm_substream *substream, | |||
| 359 | if (adau->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) | 359 | if (adau->dai_fmt != SND_SOC_DAIFMT_RIGHT_J) |
| 360 | return 0; | 360 | return 0; |
| 361 | 361 | ||
| 362 | switch (params_format(params)) { | 362 | switch (params_width(params)) { |
| 363 | case SNDRV_PCM_FORMAT_S16_LE: | 363 | case 16: |
| 364 | val = ADAU17X1_SERIAL_PORT1_DELAY16; | 364 | val = ADAU17X1_SERIAL_PORT1_DELAY16; |
| 365 | break; | 365 | break; |
| 366 | case SNDRV_PCM_FORMAT_S24_LE: | 366 | case 24: |
| 367 | val = ADAU17X1_SERIAL_PORT1_DELAY8; | 367 | val = ADAU17X1_SERIAL_PORT1_DELAY8; |
| 368 | break; | 368 | break; |
| 369 | case SNDRV_PCM_FORMAT_S32_LE: | 369 | case 32: |
| 370 | val = ADAU17X1_SERIAL_PORT1_DELAY0; | 370 | val = ADAU17X1_SERIAL_PORT1_DELAY0; |
| 371 | break; | 371 | break; |
| 372 | default: | 372 | default: |
diff --git a/sound/soc/codecs/adau1977.c b/sound/soc/codecs/adau1977.c index fd55da7cb9d4..70ab35744aba 100644 --- a/sound/soc/codecs/adau1977.c +++ b/sound/soc/codecs/adau1977.c | |||
| @@ -968,7 +968,7 @@ int adau1977_probe(struct device *dev, struct regmap *regmap, | |||
| 968 | if (adau1977->dvdd_reg) | 968 | if (adau1977->dvdd_reg) |
| 969 | power_off_mask = ~0; | 969 | power_off_mask = ~0; |
| 970 | else | 970 | else |
| 971 | power_off_mask = ~ADAU1977_BLOCK_POWER_SAI_LDO_EN; | 971 | power_off_mask = (unsigned int)~ADAU1977_BLOCK_POWER_SAI_LDO_EN; |
| 972 | 972 | ||
| 973 | ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_BLOCK_POWER_SAI, | 973 | ret = regmap_update_bits(adau1977->regmap, ADAU1977_REG_BLOCK_POWER_SAI, |
| 974 | power_off_mask, 0x00); | 974 | power_off_mask, 0x00); |
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 3ba4c0f11418..041712592e29 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c | |||
| @@ -547,7 +547,7 @@ static const struct ak4642_drvdata ak4648_drvdata = { | |||
| 547 | .extended_frequencies = 1, | 547 | .extended_frequencies = 1, |
| 548 | }; | 548 | }; |
| 549 | 549 | ||
| 550 | static struct of_device_id ak4642_of_match[]; | 550 | static const struct of_device_id ak4642_of_match[]; |
| 551 | static int ak4642_i2c_probe(struct i2c_client *i2c, | 551 | static int ak4642_i2c_probe(struct i2c_client *i2c, |
| 552 | const struct i2c_device_id *id) | 552 | const struct i2c_device_id *id) |
| 553 | { | 553 | { |
| @@ -593,7 +593,7 @@ static int ak4642_i2c_remove(struct i2c_client *client) | |||
| 593 | return 0; | 593 | return 0; |
| 594 | } | 594 | } |
| 595 | 595 | ||
| 596 | static struct of_device_id ak4642_of_match[] = { | 596 | static const struct of_device_id ak4642_of_match[] = { |
| 597 | { .compatible = "asahi-kasei,ak4642", .data = &ak4642_drvdata}, | 597 | { .compatible = "asahi-kasei,ak4642", .data = &ak4642_drvdata}, |
| 598 | { .compatible = "asahi-kasei,ak4643", .data = &ak4643_drvdata}, | 598 | { .compatible = "asahi-kasei,ak4643", .data = &ak4643_drvdata}, |
| 599 | { .compatible = "asahi-kasei,ak4648", .data = &ak4648_drvdata}, | 599 | { .compatible = "asahi-kasei,ak4648", .data = &ak4648_drvdata}, |
diff --git a/sound/soc/codecs/ak5386.c b/sound/soc/codecs/ak5386.c index 72e953b2cb41..8107a1cac876 100644 --- a/sound/soc/codecs/ak5386.c +++ b/sound/soc/codecs/ak5386.c | |||
| @@ -14,12 +14,18 @@ | |||
| 14 | #include <linux/of.h> | 14 | #include <linux/of.h> |
| 15 | #include <linux/of_gpio.h> | 15 | #include <linux/of_gpio.h> |
| 16 | #include <linux/of_device.h> | 16 | #include <linux/of_device.h> |
| 17 | #include <linux/regulator/consumer.h> | ||
| 17 | #include <sound/soc.h> | 18 | #include <sound/soc.h> |
| 18 | #include <sound/pcm.h> | 19 | #include <sound/pcm.h> |
| 19 | #include <sound/initval.h> | 20 | #include <sound/initval.h> |
| 20 | 21 | ||
| 22 | static const char * const supply_names[] = { | ||
| 23 | "va", "vd" | ||
| 24 | }; | ||
| 25 | |||
| 21 | struct ak5386_priv { | 26 | struct ak5386_priv { |
| 22 | int reset_gpio; | 27 | int reset_gpio; |
| 28 | struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; | ||
| 23 | }; | 29 | }; |
| 24 | 30 | ||
| 25 | static const struct snd_soc_dapm_widget ak5386_dapm_widgets[] = { | 31 | static const struct snd_soc_dapm_widget ak5386_dapm_widgets[] = { |
| @@ -32,7 +38,42 @@ static const struct snd_soc_dapm_route ak5386_dapm_routes[] = { | |||
| 32 | { "Capture", NULL, "AINR" }, | 38 | { "Capture", NULL, "AINR" }, |
| 33 | }; | 39 | }; |
| 34 | 40 | ||
| 41 | static int ak5386_soc_probe(struct snd_soc_codec *codec) | ||
| 42 | { | ||
| 43 | struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 44 | return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 45 | } | ||
| 46 | |||
| 47 | static int ak5386_soc_remove(struct snd_soc_codec *codec) | ||
| 48 | { | ||
| 49 | struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 50 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 51 | return 0; | ||
| 52 | } | ||
| 53 | |||
| 54 | #ifdef CONFIG_PM | ||
| 55 | static int ak5386_soc_suspend(struct snd_soc_codec *codec) | ||
| 56 | { | ||
| 57 | struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 58 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 59 | return 0; | ||
| 60 | } | ||
| 61 | |||
| 62 | static int ak5386_soc_resume(struct snd_soc_codec *codec) | ||
| 63 | { | ||
| 64 | struct ak5386_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 65 | return regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 66 | } | ||
| 67 | #else | ||
| 68 | #define ak5386_soc_suspend NULL | ||
| 69 | #define ak5386_soc_resume NULL | ||
| 70 | #endif /* CONFIG_PM */ | ||
| 71 | |||
| 35 | static struct snd_soc_codec_driver soc_codec_ak5386 = { | 72 | static struct snd_soc_codec_driver soc_codec_ak5386 = { |
| 73 | .probe = ak5386_soc_probe, | ||
| 74 | .remove = ak5386_soc_remove, | ||
| 75 | .suspend = ak5386_soc_suspend, | ||
| 76 | .resume = ak5386_soc_resume, | ||
| 36 | .dapm_widgets = ak5386_dapm_widgets, | 77 | .dapm_widgets = ak5386_dapm_widgets, |
| 37 | .num_dapm_widgets = ARRAY_SIZE(ak5386_dapm_widgets), | 78 | .num_dapm_widgets = ARRAY_SIZE(ak5386_dapm_widgets), |
| 38 | .dapm_routes = ak5386_dapm_routes, | 79 | .dapm_routes = ak5386_dapm_routes, |
| @@ -122,6 +163,7 @@ static int ak5386_probe(struct platform_device *pdev) | |||
| 122 | { | 163 | { |
| 123 | struct device *dev = &pdev->dev; | 164 | struct device *dev = &pdev->dev; |
| 124 | struct ak5386_priv *priv; | 165 | struct ak5386_priv *priv; |
| 166 | int ret, i; | ||
| 125 | 167 | ||
| 126 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); | 168 | priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); |
| 127 | if (!priv) | 169 | if (!priv) |
| @@ -130,6 +172,14 @@ static int ak5386_probe(struct platform_device *pdev) | |||
| 130 | priv->reset_gpio = -EINVAL; | 172 | priv->reset_gpio = -EINVAL; |
| 131 | dev_set_drvdata(dev, priv); | 173 | dev_set_drvdata(dev, priv); |
| 132 | 174 | ||
| 175 | for (i = 0; i < ARRAY_SIZE(supply_names); i++) | ||
| 176 | priv->supplies[i].supply = supply_names[i]; | ||
| 177 | |||
| 178 | ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(priv->supplies), | ||
| 179 | priv->supplies); | ||
| 180 | if (ret < 0) | ||
| 181 | return ret; | ||
| 182 | |||
| 133 | if (of_match_device(of_match_ptr(ak5386_dt_ids), dev)) | 183 | if (of_match_device(of_match_ptr(ak5386_dt_ids), dev)) |
| 134 | priv->reset_gpio = of_get_named_gpio(dev->of_node, | 184 | priv->reset_gpio = of_get_named_gpio(dev->of_node, |
| 135 | "reset-gpio", 0); | 185 | "reset-gpio", 0); |
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 29e198f57d4c..2f2e91ac690f 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c | |||
| @@ -243,6 +243,31 @@ int arizona_init_spk(struct snd_soc_codec *codec) | |||
| 243 | } | 243 | } |
| 244 | EXPORT_SYMBOL_GPL(arizona_init_spk); | 244 | EXPORT_SYMBOL_GPL(arizona_init_spk); |
| 245 | 245 | ||
| 246 | static const struct snd_soc_dapm_route arizona_mono_routes[] = { | ||
| 247 | { "OUT1R", NULL, "OUT1L" }, | ||
| 248 | { "OUT2R", NULL, "OUT2L" }, | ||
| 249 | { "OUT3R", NULL, "OUT3L" }, | ||
| 250 | { "OUT4R", NULL, "OUT4L" }, | ||
| 251 | { "OUT5R", NULL, "OUT5L" }, | ||
| 252 | { "OUT6R", NULL, "OUT6L" }, | ||
| 253 | }; | ||
| 254 | |||
| 255 | int arizona_init_mono(struct snd_soc_codec *codec) | ||
| 256 | { | ||
| 257 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 258 | struct arizona *arizona = priv->arizona; | ||
| 259 | int i; | ||
| 260 | |||
| 261 | for (i = 0; i < ARIZONA_MAX_OUTPUT; ++i) { | ||
| 262 | if (arizona->pdata.out_mono[i]) | ||
| 263 | snd_soc_dapm_add_routes(&codec->dapm, | ||
| 264 | &arizona_mono_routes[i], 1); | ||
| 265 | } | ||
| 266 | |||
| 267 | return 0; | ||
| 268 | } | ||
| 269 | EXPORT_SYMBOL_GPL(arizona_init_mono); | ||
| 270 | |||
| 246 | int arizona_init_gpio(struct snd_soc_codec *codec) | 271 | int arizona_init_gpio(struct snd_soc_codec *codec) |
| 247 | { | 272 | { |
| 248 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); | 273 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); |
| @@ -1127,6 +1152,31 @@ static int arizona_startup(struct snd_pcm_substream *substream, | |||
| 1127 | constraint); | 1152 | constraint); |
| 1128 | } | 1153 | } |
| 1129 | 1154 | ||
| 1155 | static void arizona_wm5102_set_dac_comp(struct snd_soc_codec *codec, | ||
| 1156 | unsigned int rate) | ||
| 1157 | { | ||
| 1158 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 1159 | struct arizona *arizona = priv->arizona; | ||
| 1160 | struct reg_default dac_comp[] = { | ||
| 1161 | { 0x80, 0x3 }, | ||
| 1162 | { ARIZONA_DAC_COMP_1, 0 }, | ||
| 1163 | { ARIZONA_DAC_COMP_2, 0 }, | ||
| 1164 | { 0x80, 0x0 }, | ||
| 1165 | }; | ||
| 1166 | |||
| 1167 | mutex_lock(&codec->mutex); | ||
| 1168 | |||
| 1169 | dac_comp[1].def = arizona->dac_comp_coeff; | ||
| 1170 | if (rate >= 176400) | ||
| 1171 | dac_comp[2].def = arizona->dac_comp_enabled; | ||
| 1172 | |||
| 1173 | mutex_unlock(&codec->mutex); | ||
| 1174 | |||
| 1175 | regmap_multi_reg_write(arizona->regmap, | ||
| 1176 | dac_comp, | ||
| 1177 | ARRAY_SIZE(dac_comp)); | ||
| 1178 | } | ||
| 1179 | |||
| 1130 | static int arizona_hw_params_rate(struct snd_pcm_substream *substream, | 1180 | static int arizona_hw_params_rate(struct snd_pcm_substream *substream, |
| 1131 | struct snd_pcm_hw_params *params, | 1181 | struct snd_pcm_hw_params *params, |
| 1132 | struct snd_soc_dai *dai) | 1182 | struct snd_soc_dai *dai) |
| @@ -1153,6 +1203,15 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream, | |||
| 1153 | 1203 | ||
| 1154 | switch (dai_priv->clk) { | 1204 | switch (dai_priv->clk) { |
| 1155 | case ARIZONA_CLK_SYSCLK: | 1205 | case ARIZONA_CLK_SYSCLK: |
| 1206 | switch (priv->arizona->type) { | ||
| 1207 | case WM5102: | ||
| 1208 | arizona_wm5102_set_dac_comp(codec, | ||
| 1209 | params_rate(params)); | ||
| 1210 | break; | ||
| 1211 | default: | ||
| 1212 | break; | ||
| 1213 | } | ||
| 1214 | |||
| 1156 | snd_soc_update_bits(codec, ARIZONA_SAMPLE_RATE_1, | 1215 | snd_soc_update_bits(codec, ARIZONA_SAMPLE_RATE_1, |
| 1157 | ARIZONA_SAMPLE_RATE_1_MASK, sr_val); | 1216 | ARIZONA_SAMPLE_RATE_1_MASK, sr_val); |
| 1158 | if (base) | 1217 | if (base) |
| @@ -1175,6 +1234,27 @@ static int arizona_hw_params_rate(struct snd_pcm_substream *substream, | |||
| 1175 | return 0; | 1234 | return 0; |
| 1176 | } | 1235 | } |
| 1177 | 1236 | ||
| 1237 | static bool arizona_aif_cfg_changed(struct snd_soc_codec *codec, | ||
| 1238 | int base, int bclk, int lrclk, int frame) | ||
| 1239 | { | ||
| 1240 | int val; | ||
| 1241 | |||
| 1242 | val = snd_soc_read(codec, base + ARIZONA_AIF_BCLK_CTRL); | ||
| 1243 | if (bclk != (val & ARIZONA_AIF1_BCLK_FREQ_MASK)) | ||
| 1244 | return true; | ||
| 1245 | |||
| 1246 | val = snd_soc_read(codec, base + ARIZONA_AIF_TX_BCLK_RATE); | ||
| 1247 | if (lrclk != (val & ARIZONA_AIF1TX_BCPF_MASK)) | ||
| 1248 | return true; | ||
| 1249 | |||
| 1250 | val = snd_soc_read(codec, base + ARIZONA_AIF_FRAME_CTRL_1); | ||
| 1251 | if (frame != (val & (ARIZONA_AIF1TX_WL_MASK | | ||
| 1252 | ARIZONA_AIF1TX_SLOT_LEN_MASK))) | ||
| 1253 | return true; | ||
| 1254 | |||
| 1255 | return false; | ||
| 1256 | } | ||
| 1257 | |||
| 1178 | static int arizona_hw_params(struct snd_pcm_substream *substream, | 1258 | static int arizona_hw_params(struct snd_pcm_substream *substream, |
| 1179 | struct snd_pcm_hw_params *params, | 1259 | struct snd_pcm_hw_params *params, |
| 1180 | struct snd_soc_dai *dai) | 1260 | struct snd_soc_dai *dai) |
| @@ -1185,26 +1265,40 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, | |||
| 1185 | int base = dai->driver->base; | 1265 | int base = dai->driver->base; |
| 1186 | const int *rates; | 1266 | const int *rates; |
| 1187 | int i, ret, val; | 1267 | int i, ret, val; |
| 1268 | int channels = params_channels(params); | ||
| 1188 | int chan_limit = arizona->pdata.max_channels_clocked[dai->id - 1]; | 1269 | int chan_limit = arizona->pdata.max_channels_clocked[dai->id - 1]; |
| 1270 | int tdm_width = arizona->tdm_width[dai->id - 1]; | ||
| 1271 | int tdm_slots = arizona->tdm_slots[dai->id - 1]; | ||
| 1189 | int bclk, lrclk, wl, frame, bclk_target; | 1272 | int bclk, lrclk, wl, frame, bclk_target; |
| 1273 | bool reconfig; | ||
| 1274 | unsigned int aif_tx_state, aif_rx_state; | ||
| 1190 | 1275 | ||
| 1191 | if (params_rate(params) % 8000) | 1276 | if (params_rate(params) % 8000) |
| 1192 | rates = &arizona_44k1_bclk_rates[0]; | 1277 | rates = &arizona_44k1_bclk_rates[0]; |
| 1193 | else | 1278 | else |
| 1194 | rates = &arizona_48k_bclk_rates[0]; | 1279 | rates = &arizona_48k_bclk_rates[0]; |
| 1195 | 1280 | ||
| 1196 | bclk_target = snd_soc_params_to_bclk(params); | 1281 | if (tdm_slots) { |
| 1197 | if (chan_limit && chan_limit < params_channels(params)) { | 1282 | arizona_aif_dbg(dai, "Configuring for %d %d bit TDM slots\n", |
| 1283 | tdm_slots, tdm_width); | ||
| 1284 | bclk_target = tdm_slots * tdm_width * params_rate(params); | ||
| 1285 | channels = tdm_slots; | ||
| 1286 | } else { | ||
| 1287 | bclk_target = snd_soc_params_to_bclk(params); | ||
| 1288 | } | ||
| 1289 | |||
| 1290 | if (chan_limit && chan_limit < channels) { | ||
| 1198 | arizona_aif_dbg(dai, "Limiting to %d channels\n", chan_limit); | 1291 | arizona_aif_dbg(dai, "Limiting to %d channels\n", chan_limit); |
| 1199 | bclk_target /= params_channels(params); | 1292 | bclk_target /= channels; |
| 1200 | bclk_target *= chan_limit; | 1293 | bclk_target *= chan_limit; |
| 1201 | } | 1294 | } |
| 1202 | 1295 | ||
| 1203 | /* Force stereo for I2S mode */ | 1296 | /* Force multiple of 2 channels for I2S mode */ |
| 1204 | val = snd_soc_read(codec, base + ARIZONA_AIF_FORMAT); | 1297 | val = snd_soc_read(codec, base + ARIZONA_AIF_FORMAT); |
| 1205 | if (params_channels(params) == 1 && (val & ARIZONA_AIF1_FMT_MASK)) { | 1298 | if ((channels & 1) && (val & ARIZONA_AIF1_FMT_MASK)) { |
| 1206 | arizona_aif_dbg(dai, "Forcing stereo mode\n"); | 1299 | arizona_aif_dbg(dai, "Forcing stereo mode\n"); |
| 1207 | bclk_target *= 2; | 1300 | bclk_target /= channels; |
| 1301 | bclk_target *= channels + 1; | ||
| 1208 | } | 1302 | } |
| 1209 | 1303 | ||
| 1210 | for (i = 0; i < ARRAY_SIZE(arizona_44k1_bclk_rates); i++) { | 1304 | for (i = 0; i < ARRAY_SIZE(arizona_44k1_bclk_rates); i++) { |
| @@ -1228,28 +1322,56 @@ static int arizona_hw_params(struct snd_pcm_substream *substream, | |||
| 1228 | wl = snd_pcm_format_width(params_format(params)); | 1322 | wl = snd_pcm_format_width(params_format(params)); |
| 1229 | frame = wl << ARIZONA_AIF1TX_WL_SHIFT | wl; | 1323 | frame = wl << ARIZONA_AIF1TX_WL_SHIFT | wl; |
| 1230 | 1324 | ||
| 1325 | reconfig = arizona_aif_cfg_changed(codec, base, bclk, lrclk, frame); | ||
| 1326 | |||
| 1327 | if (reconfig) { | ||
| 1328 | /* Save AIF TX/RX state */ | ||
| 1329 | aif_tx_state = snd_soc_read(codec, | ||
| 1330 | base + ARIZONA_AIF_TX_ENABLES); | ||
| 1331 | aif_rx_state = snd_soc_read(codec, | ||
| 1332 | base + ARIZONA_AIF_RX_ENABLES); | ||
| 1333 | /* Disable AIF TX/RX before reconfiguring it */ | ||
| 1334 | regmap_update_bits_async(arizona->regmap, | ||
| 1335 | base + ARIZONA_AIF_TX_ENABLES, 0xff, 0x0); | ||
| 1336 | regmap_update_bits(arizona->regmap, | ||
| 1337 | base + ARIZONA_AIF_RX_ENABLES, 0xff, 0x0); | ||
| 1338 | } | ||
| 1339 | |||
| 1231 | ret = arizona_hw_params_rate(substream, params, dai); | 1340 | ret = arizona_hw_params_rate(substream, params, dai); |
| 1232 | if (ret != 0) | 1341 | if (ret != 0) |
| 1233 | return ret; | 1342 | goto restore_aif; |
| 1234 | 1343 | ||
| 1235 | regmap_update_bits_async(arizona->regmap, | 1344 | if (reconfig) { |
| 1236 | base + ARIZONA_AIF_BCLK_CTRL, | 1345 | regmap_update_bits_async(arizona->regmap, |
| 1237 | ARIZONA_AIF1_BCLK_FREQ_MASK, bclk); | 1346 | base + ARIZONA_AIF_BCLK_CTRL, |
| 1238 | regmap_update_bits_async(arizona->regmap, | 1347 | ARIZONA_AIF1_BCLK_FREQ_MASK, bclk); |
| 1239 | base + ARIZONA_AIF_TX_BCLK_RATE, | 1348 | regmap_update_bits_async(arizona->regmap, |
| 1240 | ARIZONA_AIF1TX_BCPF_MASK, lrclk); | 1349 | base + ARIZONA_AIF_TX_BCLK_RATE, |
| 1241 | regmap_update_bits_async(arizona->regmap, | 1350 | ARIZONA_AIF1TX_BCPF_MASK, lrclk); |
| 1242 | base + ARIZONA_AIF_RX_BCLK_RATE, | 1351 | regmap_update_bits_async(arizona->regmap, |
| 1243 | ARIZONA_AIF1RX_BCPF_MASK, lrclk); | 1352 | base + ARIZONA_AIF_RX_BCLK_RATE, |
| 1244 | regmap_update_bits_async(arizona->regmap, | 1353 | ARIZONA_AIF1RX_BCPF_MASK, lrclk); |
| 1245 | base + ARIZONA_AIF_FRAME_CTRL_1, | 1354 | regmap_update_bits_async(arizona->regmap, |
| 1246 | ARIZONA_AIF1TX_WL_MASK | | 1355 | base + ARIZONA_AIF_FRAME_CTRL_1, |
| 1247 | ARIZONA_AIF1TX_SLOT_LEN_MASK, frame); | 1356 | ARIZONA_AIF1TX_WL_MASK | |
| 1248 | regmap_update_bits(arizona->regmap, base + ARIZONA_AIF_FRAME_CTRL_2, | 1357 | ARIZONA_AIF1TX_SLOT_LEN_MASK, frame); |
| 1249 | ARIZONA_AIF1RX_WL_MASK | | 1358 | regmap_update_bits(arizona->regmap, |
| 1250 | ARIZONA_AIF1RX_SLOT_LEN_MASK, frame); | 1359 | base + ARIZONA_AIF_FRAME_CTRL_2, |
| 1360 | ARIZONA_AIF1RX_WL_MASK | | ||
| 1361 | ARIZONA_AIF1RX_SLOT_LEN_MASK, frame); | ||
| 1362 | } | ||
| 1251 | 1363 | ||
| 1252 | return 0; | 1364 | restore_aif: |
| 1365 | if (reconfig) { | ||
| 1366 | /* Restore AIF TX/RX state */ | ||
| 1367 | regmap_update_bits_async(arizona->regmap, | ||
| 1368 | base + ARIZONA_AIF_TX_ENABLES, | ||
| 1369 | 0xff, aif_tx_state); | ||
| 1370 | regmap_update_bits(arizona->regmap, | ||
| 1371 | base + ARIZONA_AIF_RX_ENABLES, | ||
| 1372 | 0xff, aif_rx_state); | ||
| 1373 | } | ||
| 1374 | return ret; | ||
| 1253 | } | 1375 | } |
| 1254 | 1376 | ||
| 1255 | static const char *arizona_dai_clk_str(int clk_id) | 1377 | static const char *arizona_dai_clk_str(int clk_id) |
| @@ -1324,9 +1446,63 @@ static int arizona_set_tristate(struct snd_soc_dai *dai, int tristate) | |||
| 1324 | ARIZONA_AIF1_TRI, reg); | 1446 | ARIZONA_AIF1_TRI, reg); |
| 1325 | } | 1447 | } |
| 1326 | 1448 | ||
| 1449 | static void arizona_set_channels_to_mask(struct snd_soc_dai *dai, | ||
| 1450 | unsigned int base, | ||
| 1451 | int channels, unsigned int mask) | ||
| 1452 | { | ||
| 1453 | struct snd_soc_codec *codec = dai->codec; | ||
| 1454 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 1455 | struct arizona *arizona = priv->arizona; | ||
| 1456 | int slot, i; | ||
| 1457 | |||
| 1458 | for (i = 0; i < channels; ++i) { | ||
| 1459 | slot = ffs(mask) - 1; | ||
| 1460 | if (slot < 0) | ||
| 1461 | return; | ||
| 1462 | |||
| 1463 | regmap_write(arizona->regmap, base + i, slot); | ||
| 1464 | |||
| 1465 | mask &= ~(1 << slot); | ||
| 1466 | } | ||
| 1467 | |||
| 1468 | if (mask) | ||
| 1469 | arizona_aif_warn(dai, "Too many channels in TDM mask\n"); | ||
| 1470 | } | ||
| 1471 | |||
| 1472 | static int arizona_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | ||
| 1473 | unsigned int rx_mask, int slots, int slot_width) | ||
| 1474 | { | ||
| 1475 | struct snd_soc_codec *codec = dai->codec; | ||
| 1476 | struct arizona_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 1477 | struct arizona *arizona = priv->arizona; | ||
| 1478 | int base = dai->driver->base; | ||
| 1479 | int rx_max_chan = dai->driver->playback.channels_max; | ||
| 1480 | int tx_max_chan = dai->driver->capture.channels_max; | ||
| 1481 | |||
| 1482 | /* Only support TDM for the physical AIFs */ | ||
| 1483 | if (dai->id > ARIZONA_MAX_AIF) | ||
| 1484 | return -ENOTSUPP; | ||
| 1485 | |||
| 1486 | if (slots == 0) { | ||
| 1487 | tx_mask = (1 << tx_max_chan) - 1; | ||
| 1488 | rx_mask = (1 << rx_max_chan) - 1; | ||
| 1489 | } | ||
| 1490 | |||
| 1491 | arizona_set_channels_to_mask(dai, base + ARIZONA_AIF_FRAME_CTRL_3, | ||
| 1492 | tx_max_chan, tx_mask); | ||
| 1493 | arizona_set_channels_to_mask(dai, base + ARIZONA_AIF_FRAME_CTRL_11, | ||
| 1494 | rx_max_chan, rx_mask); | ||
| 1495 | |||
| 1496 | arizona->tdm_width[dai->id - 1] = slot_width; | ||
| 1497 | arizona->tdm_slots[dai->id - 1] = slots; | ||
| 1498 | |||
| 1499 | return 0; | ||
| 1500 | } | ||
| 1501 | |||
| 1327 | const struct snd_soc_dai_ops arizona_dai_ops = { | 1502 | const struct snd_soc_dai_ops arizona_dai_ops = { |
| 1328 | .startup = arizona_startup, | 1503 | .startup = arizona_startup, |
| 1329 | .set_fmt = arizona_set_fmt, | 1504 | .set_fmt = arizona_set_fmt, |
| 1505 | .set_tdm_slot = arizona_set_tdm_slot, | ||
| 1330 | .hw_params = arizona_hw_params, | 1506 | .hw_params = arizona_hw_params, |
| 1331 | .set_sysclk = arizona_dai_set_sysclk, | 1507 | .set_sysclk = arizona_dai_set_sysclk, |
| 1332 | .set_tristate = arizona_set_tristate, | 1508 | .set_tristate = arizona_set_tristate, |
| @@ -1400,6 +1576,12 @@ static int arizona_validate_fll(struct arizona_fll *fll, | |||
| 1400 | { | 1576 | { |
| 1401 | unsigned int Fvco_min; | 1577 | unsigned int Fvco_min; |
| 1402 | 1578 | ||
| 1579 | if (fll->fout && Fout != fll->fout) { | ||
| 1580 | arizona_fll_err(fll, | ||
| 1581 | "Can't change output on active FLL\n"); | ||
| 1582 | return -EINVAL; | ||
| 1583 | } | ||
| 1584 | |||
| 1403 | if (Fref / ARIZONA_FLL_MAX_REFDIV > ARIZONA_FLL_MAX_FREF) { | 1585 | if (Fref / ARIZONA_FLL_MAX_REFDIV > ARIZONA_FLL_MAX_FREF) { |
| 1404 | arizona_fll_err(fll, | 1586 | arizona_fll_err(fll, |
| 1405 | "Can't scale %dMHz in to <=13.5MHz\n", | 1587 | "Can't scale %dMHz in to <=13.5MHz\n", |
| @@ -1478,6 +1660,10 @@ static int arizona_calc_fratio(struct arizona_fll *fll, | |||
| 1478 | while (div <= ARIZONA_FLL_MAX_REFDIV) { | 1660 | while (div <= ARIZONA_FLL_MAX_REFDIV) { |
| 1479 | for (ratio = init_ratio; ratio <= ARIZONA_FLL_MAX_FRATIO; | 1661 | for (ratio = init_ratio; ratio <= ARIZONA_FLL_MAX_FRATIO; |
| 1480 | ratio++) { | 1662 | ratio++) { |
| 1663 | if ((ARIZONA_FLL_VCO_CORNER / 2) / | ||
| 1664 | (fll->vco_mult * ratio) < Fref) | ||
| 1665 | break; | ||
| 1666 | |||
| 1481 | if (target % (ratio * Fref)) { | 1667 | if (target % (ratio * Fref)) { |
| 1482 | cfg->refdiv = refdiv; | 1668 | cfg->refdiv = refdiv; |
| 1483 | cfg->fratio = ratio - 1; | 1669 | cfg->fratio = ratio - 1; |
| @@ -1485,11 +1671,7 @@ static int arizona_calc_fratio(struct arizona_fll *fll, | |||
| 1485 | } | 1671 | } |
| 1486 | } | 1672 | } |
| 1487 | 1673 | ||
| 1488 | for (ratio = init_ratio - 1; ratio >= 0; ratio--) { | 1674 | for (ratio = init_ratio - 1; ratio > 0; ratio--) { |
| 1489 | if (ARIZONA_FLL_VCO_CORNER / (fll->vco_mult * ratio) < | ||
| 1490 | Fref) | ||
| 1491 | break; | ||
| 1492 | |||
| 1493 | if (target % (ratio * Fref)) { | 1675 | if (target % (ratio * Fref)) { |
| 1494 | cfg->refdiv = refdiv; | 1676 | cfg->refdiv = refdiv; |
| 1495 | cfg->fratio = ratio - 1; | 1677 | cfg->fratio = ratio - 1; |
| @@ -1616,7 +1798,7 @@ static void arizona_apply_fll(struct arizona *arizona, unsigned int base, | |||
| 1616 | ARIZONA_FLL1_CTRL_UPD | cfg->n); | 1798 | ARIZONA_FLL1_CTRL_UPD | cfg->n); |
| 1617 | } | 1799 | } |
| 1618 | 1800 | ||
| 1619 | static bool arizona_is_enabled_fll(struct arizona_fll *fll) | 1801 | static int arizona_is_enabled_fll(struct arizona_fll *fll) |
| 1620 | { | 1802 | { |
| 1621 | struct arizona *arizona = fll->arizona; | 1803 | struct arizona *arizona = fll->arizona; |
| 1622 | unsigned int reg; | 1804 | unsigned int reg; |
| @@ -1632,13 +1814,26 @@ static bool arizona_is_enabled_fll(struct arizona_fll *fll) | |||
| 1632 | return reg & ARIZONA_FLL1_ENA; | 1814 | return reg & ARIZONA_FLL1_ENA; |
| 1633 | } | 1815 | } |
| 1634 | 1816 | ||
| 1635 | static void arizona_enable_fll(struct arizona_fll *fll) | 1817 | static int arizona_enable_fll(struct arizona_fll *fll) |
| 1636 | { | 1818 | { |
| 1637 | struct arizona *arizona = fll->arizona; | 1819 | struct arizona *arizona = fll->arizona; |
| 1638 | int ret; | 1820 | int ret; |
| 1639 | bool use_sync = false; | 1821 | bool use_sync = false; |
| 1822 | int already_enabled = arizona_is_enabled_fll(fll); | ||
| 1640 | struct arizona_fll_cfg cfg; | 1823 | struct arizona_fll_cfg cfg; |
| 1641 | 1824 | ||
| 1825 | if (already_enabled < 0) | ||
| 1826 | return already_enabled; | ||
| 1827 | |||
| 1828 | if (already_enabled) { | ||
| 1829 | /* Facilitate smooth refclk across the transition */ | ||
| 1830 | regmap_update_bits_async(fll->arizona->regmap, fll->base + 0x7, | ||
| 1831 | ARIZONA_FLL1_GAIN_MASK, 0); | ||
| 1832 | regmap_update_bits_async(fll->arizona->regmap, fll->base + 1, | ||
| 1833 | ARIZONA_FLL1_FREERUN, | ||
| 1834 | ARIZONA_FLL1_FREERUN); | ||
| 1835 | } | ||
| 1836 | |||
| 1642 | /* | 1837 | /* |
| 1643 | * If we have both REFCLK and SYNCCLK then enable both, | 1838 | * If we have both REFCLK and SYNCCLK then enable both, |
| 1644 | * otherwise apply the SYNCCLK settings to REFCLK. | 1839 | * otherwise apply the SYNCCLK settings to REFCLK. |
| @@ -1666,7 +1861,7 @@ static void arizona_enable_fll(struct arizona_fll *fll) | |||
| 1666 | ARIZONA_FLL1_SYNC_ENA, 0); | 1861 | ARIZONA_FLL1_SYNC_ENA, 0); |
| 1667 | } else { | 1862 | } else { |
| 1668 | arizona_fll_err(fll, "No clocks provided\n"); | 1863 | arizona_fll_err(fll, "No clocks provided\n"); |
| 1669 | return; | 1864 | return -EINVAL; |
| 1670 | } | 1865 | } |
| 1671 | 1866 | ||
| 1672 | /* | 1867 | /* |
| @@ -1681,25 +1876,29 @@ static void arizona_enable_fll(struct arizona_fll *fll) | |||
| 1681 | ARIZONA_FLL1_SYNC_BW, | 1876 | ARIZONA_FLL1_SYNC_BW, |
| 1682 | ARIZONA_FLL1_SYNC_BW); | 1877 | ARIZONA_FLL1_SYNC_BW); |
| 1683 | 1878 | ||
| 1684 | if (!arizona_is_enabled_fll(fll)) | 1879 | if (!already_enabled) |
| 1685 | pm_runtime_get(arizona->dev); | 1880 | pm_runtime_get(arizona->dev); |
| 1686 | 1881 | ||
| 1687 | /* Clear any pending completions */ | 1882 | /* Clear any pending completions */ |
| 1688 | try_wait_for_completion(&fll->ok); | 1883 | try_wait_for_completion(&fll->ok); |
| 1689 | 1884 | ||
| 1690 | regmap_update_bits_async(arizona->regmap, fll->base + 1, | 1885 | regmap_update_bits_async(arizona->regmap, fll->base + 1, |
| 1691 | ARIZONA_FLL1_FREERUN, 0); | ||
| 1692 | regmap_update_bits_async(arizona->regmap, fll->base + 1, | ||
| 1693 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); | 1886 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); |
| 1694 | if (use_sync) | 1887 | if (use_sync) |
| 1695 | regmap_update_bits_async(arizona->regmap, fll->base + 0x11, | 1888 | regmap_update_bits_async(arizona->regmap, fll->base + 0x11, |
| 1696 | ARIZONA_FLL1_SYNC_ENA, | 1889 | ARIZONA_FLL1_SYNC_ENA, |
| 1697 | ARIZONA_FLL1_SYNC_ENA); | 1890 | ARIZONA_FLL1_SYNC_ENA); |
| 1698 | 1891 | ||
| 1892 | if (already_enabled) | ||
| 1893 | regmap_update_bits_async(arizona->regmap, fll->base + 1, | ||
| 1894 | ARIZONA_FLL1_FREERUN, 0); | ||
| 1895 | |||
| 1699 | ret = wait_for_completion_timeout(&fll->ok, | 1896 | ret = wait_for_completion_timeout(&fll->ok, |
| 1700 | msecs_to_jiffies(250)); | 1897 | msecs_to_jiffies(250)); |
| 1701 | if (ret == 0) | 1898 | if (ret == 0) |
| 1702 | arizona_fll_warn(fll, "Timed out waiting for lock\n"); | 1899 | arizona_fll_warn(fll, "Timed out waiting for lock\n"); |
| 1900 | |||
| 1901 | return 0; | ||
| 1703 | } | 1902 | } |
| 1704 | 1903 | ||
| 1705 | static void arizona_disable_fll(struct arizona_fll *fll) | 1904 | static void arizona_disable_fll(struct arizona_fll *fll) |
| @@ -1713,6 +1912,8 @@ static void arizona_disable_fll(struct arizona_fll *fll) | |||
| 1713 | ARIZONA_FLL1_ENA, 0, &change); | 1912 | ARIZONA_FLL1_ENA, 0, &change); |
| 1714 | regmap_update_bits(arizona->regmap, fll->base + 0x11, | 1913 | regmap_update_bits(arizona->regmap, fll->base + 0x11, |
| 1715 | ARIZONA_FLL1_SYNC_ENA, 0); | 1914 | ARIZONA_FLL1_SYNC_ENA, 0); |
| 1915 | regmap_update_bits_async(arizona->regmap, fll->base + 1, | ||
| 1916 | ARIZONA_FLL1_FREERUN, 0); | ||
| 1716 | 1917 | ||
| 1717 | if (change) | 1918 | if (change) |
| 1718 | pm_runtime_put_autosuspend(arizona->dev); | 1919 | pm_runtime_put_autosuspend(arizona->dev); |
| @@ -1721,7 +1922,7 @@ static void arizona_disable_fll(struct arizona_fll *fll) | |||
| 1721 | int arizona_set_fll_refclk(struct arizona_fll *fll, int source, | 1922 | int arizona_set_fll_refclk(struct arizona_fll *fll, int source, |
| 1722 | unsigned int Fref, unsigned int Fout) | 1923 | unsigned int Fref, unsigned int Fout) |
| 1723 | { | 1924 | { |
| 1724 | int ret; | 1925 | int ret = 0; |
| 1725 | 1926 | ||
| 1726 | if (fll->ref_src == source && fll->ref_freq == Fref) | 1927 | if (fll->ref_src == source && fll->ref_freq == Fref) |
| 1727 | return 0; | 1928 | return 0; |
| @@ -1736,17 +1937,17 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source, | |||
| 1736 | fll->ref_freq = Fref; | 1937 | fll->ref_freq = Fref; |
| 1737 | 1938 | ||
| 1738 | if (fll->fout && Fref > 0) { | 1939 | if (fll->fout && Fref > 0) { |
| 1739 | arizona_enable_fll(fll); | 1940 | ret = arizona_enable_fll(fll); |
| 1740 | } | 1941 | } |
| 1741 | 1942 | ||
| 1742 | return 0; | 1943 | return ret; |
| 1743 | } | 1944 | } |
| 1744 | EXPORT_SYMBOL_GPL(arizona_set_fll_refclk); | 1945 | EXPORT_SYMBOL_GPL(arizona_set_fll_refclk); |
| 1745 | 1946 | ||
| 1746 | int arizona_set_fll(struct arizona_fll *fll, int source, | 1947 | int arizona_set_fll(struct arizona_fll *fll, int source, |
| 1747 | unsigned int Fref, unsigned int Fout) | 1948 | unsigned int Fref, unsigned int Fout) |
| 1748 | { | 1949 | { |
| 1749 | int ret; | 1950 | int ret = 0; |
| 1750 | 1951 | ||
| 1751 | if (fll->sync_src == source && | 1952 | if (fll->sync_src == source && |
| 1752 | fll->sync_freq == Fref && fll->fout == Fout) | 1953 | fll->sync_freq == Fref && fll->fout == Fout) |
| @@ -1768,13 +1969,12 @@ int arizona_set_fll(struct arizona_fll *fll, int source, | |||
| 1768 | fll->sync_freq = Fref; | 1969 | fll->sync_freq = Fref; |
| 1769 | fll->fout = Fout; | 1970 | fll->fout = Fout; |
| 1770 | 1971 | ||
| 1771 | if (Fout) { | 1972 | if (Fout) |
| 1772 | arizona_enable_fll(fll); | 1973 | ret = arizona_enable_fll(fll); |
| 1773 | } else { | 1974 | else |
| 1774 | arizona_disable_fll(fll); | 1975 | arizona_disable_fll(fll); |
| 1775 | } | ||
| 1776 | 1976 | ||
| 1777 | return 0; | 1977 | return ret; |
| 1778 | } | 1978 | } |
| 1779 | EXPORT_SYMBOL_GPL(arizona_set_fll); | 1979 | EXPORT_SYMBOL_GPL(arizona_set_fll); |
| 1780 | 1980 | ||
diff --git a/sound/soc/codecs/arizona.h b/sound/soc/codecs/arizona.h index 05ae17f5bca3..942cfb197b6d 100644 --- a/sound/soc/codecs/arizona.h +++ b/sound/soc/codecs/arizona.h | |||
| @@ -249,6 +249,7 @@ extern int arizona_set_fll(struct arizona_fll *fll, int source, | |||
| 249 | 249 | ||
| 250 | extern int arizona_init_spk(struct snd_soc_codec *codec); | 250 | extern int arizona_init_spk(struct snd_soc_codec *codec); |
| 251 | extern int arizona_init_gpio(struct snd_soc_codec *codec); | 251 | extern int arizona_init_gpio(struct snd_soc_codec *codec); |
| 252 | extern int arizona_init_mono(struct snd_soc_codec *codec); | ||
| 252 | 253 | ||
| 253 | extern int arizona_init_dai(struct arizona_priv *priv, int dai); | 254 | extern int arizona_init_dai(struct arizona_priv *priv, int dai); |
| 254 | 255 | ||
diff --git a/sound/soc/codecs/cs4265.c b/sound/soc/codecs/cs4265.c new file mode 100644 index 000000000000..a20b30ca52c0 --- /dev/null +++ b/sound/soc/codecs/cs4265.c | |||
| @@ -0,0 +1,682 @@ | |||
| 1 | /* | ||
| 2 | * cs4265.c -- CS4265 ALSA SoC audio driver | ||
| 3 | * | ||
| 4 | * Copyright 2014 Cirrus Logic, Inc. | ||
| 5 | * | ||
| 6 | * Author: Paul Handrigan <paul.handrigan@cirrus.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/moduleparam.h> | ||
| 16 | #include <linux/kernel.h> | ||
| 17 | #include <linux/gpio/consumer.h> | ||
| 18 | #include <linux/init.h> | ||
| 19 | #include <linux/delay.h> | ||
| 20 | #include <linux/i2c.h> | ||
| 21 | #include <linux/input.h> | ||
| 22 | #include <linux/regmap.h> | ||
| 23 | #include <linux/slab.h> | ||
| 24 | #include <linux/platform_device.h> | ||
| 25 | #include <sound/core.h> | ||
| 26 | #include <sound/pcm.h> | ||
| 27 | #include <sound/pcm_params.h> | ||
| 28 | #include <sound/soc.h> | ||
| 29 | #include <sound/soc-dapm.h> | ||
| 30 | #include <sound/initval.h> | ||
| 31 | #include <sound/tlv.h> | ||
| 32 | #include "cs4265.h" | ||
| 33 | |||
| 34 | struct cs4265_private { | ||
| 35 | struct device *dev; | ||
| 36 | struct regmap *regmap; | ||
| 37 | struct gpio_desc *reset_gpio; | ||
| 38 | u8 format; | ||
| 39 | u32 sysclk; | ||
| 40 | }; | ||
| 41 | |||
| 42 | static const struct reg_default cs4265_reg_defaults[] = { | ||
| 43 | { CS4265_PWRCTL, 0x0F }, | ||
| 44 | { CS4265_DAC_CTL, 0x08 }, | ||
| 45 | { CS4265_ADC_CTL, 0x00 }, | ||
| 46 | { CS4265_MCLK_FREQ, 0x00 }, | ||
| 47 | { CS4265_SIG_SEL, 0x40 }, | ||
| 48 | { CS4265_CHB_PGA_CTL, 0x00 }, | ||
| 49 | { CS4265_CHA_PGA_CTL, 0x00 }, | ||
| 50 | { CS4265_ADC_CTL2, 0x19 }, | ||
| 51 | { CS4265_DAC_CHA_VOL, 0x00 }, | ||
| 52 | { CS4265_DAC_CHB_VOL, 0x00 }, | ||
| 53 | { CS4265_DAC_CTL2, 0xC0 }, | ||
| 54 | { CS4265_SPDIF_CTL1, 0x00 }, | ||
| 55 | { CS4265_SPDIF_CTL2, 0x00 }, | ||
| 56 | { CS4265_INT_MASK, 0x00 }, | ||
| 57 | { CS4265_STATUS_MODE_MSB, 0x00 }, | ||
| 58 | { CS4265_STATUS_MODE_LSB, 0x00 }, | ||
| 59 | }; | ||
| 60 | |||
| 61 | static bool cs4265_readable_register(struct device *dev, unsigned int reg) | ||
| 62 | { | ||
| 63 | switch (reg) { | ||
| 64 | case CS4265_PWRCTL: | ||
| 65 | case CS4265_DAC_CTL: | ||
| 66 | case CS4265_ADC_CTL: | ||
| 67 | case CS4265_MCLK_FREQ: | ||
| 68 | case CS4265_SIG_SEL: | ||
| 69 | case CS4265_CHB_PGA_CTL: | ||
| 70 | case CS4265_CHA_PGA_CTL: | ||
| 71 | case CS4265_ADC_CTL2: | ||
| 72 | case CS4265_DAC_CHA_VOL: | ||
| 73 | case CS4265_DAC_CHB_VOL: | ||
| 74 | case CS4265_DAC_CTL2: | ||
| 75 | case CS4265_SPDIF_CTL1: | ||
| 76 | case CS4265_SPDIF_CTL2: | ||
| 77 | case CS4265_INT_MASK: | ||
| 78 | case CS4265_STATUS_MODE_MSB: | ||
| 79 | case CS4265_STATUS_MODE_LSB: | ||
| 80 | return true; | ||
| 81 | default: | ||
| 82 | return false; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | |||
| 86 | static bool cs4265_volatile_register(struct device *dev, unsigned int reg) | ||
| 87 | { | ||
| 88 | switch (reg) { | ||
| 89 | case CS4265_INT_STATUS: | ||
| 90 | return true; | ||
| 91 | default: | ||
| 92 | return false; | ||
| 93 | } | ||
| 94 | } | ||
| 95 | |||
| 96 | static DECLARE_TLV_DB_SCALE(pga_tlv, -1200, 50, 0); | ||
| 97 | |||
| 98 | static DECLARE_TLV_DB_SCALE(dac_tlv, -12750, 50, 0); | ||
| 99 | |||
| 100 | static const char * const digital_input_mux_text[] = { | ||
| 101 | "SDIN1", "SDIN2" | ||
| 102 | }; | ||
| 103 | |||
| 104 | static SOC_ENUM_SINGLE_DECL(digital_input_mux_enum, CS4265_SIG_SEL, 7, | ||
| 105 | digital_input_mux_text); | ||
| 106 | |||
| 107 | static const struct snd_kcontrol_new digital_input_mux = | ||
| 108 | SOC_DAPM_ENUM("Digital Input Mux", digital_input_mux_enum); | ||
| 109 | |||
| 110 | static const char * const mic_linein_text[] = { | ||
| 111 | "MIC", "LINEIN" | ||
| 112 | }; | ||
| 113 | |||
| 114 | static SOC_ENUM_SINGLE_DECL(mic_linein_enum, CS4265_ADC_CTL2, 0, | ||
| 115 | mic_linein_text); | ||
| 116 | |||
| 117 | static const char * const cam_mode_text[] = { | ||
| 118 | "One Byte", "Two Byte" | ||
| 119 | }; | ||
| 120 | |||
| 121 | static SOC_ENUM_SINGLE_DECL(cam_mode_enum, CS4265_SPDIF_CTL1, 5, | ||
| 122 | cam_mode_text); | ||
| 123 | |||
| 124 | static const char * const cam_mono_stereo_text[] = { | ||
| 125 | "Stereo", "Mono" | ||
| 126 | }; | ||
| 127 | |||
| 128 | static SOC_ENUM_SINGLE_DECL(spdif_mono_stereo_enum, CS4265_SPDIF_CTL2, 2, | ||
| 129 | cam_mono_stereo_text); | ||
| 130 | |||
| 131 | static const char * const mono_select_text[] = { | ||
| 132 | "Channel A", "Channel B" | ||
| 133 | }; | ||
| 134 | |||
| 135 | static SOC_ENUM_SINGLE_DECL(spdif_mono_select_enum, CS4265_SPDIF_CTL2, 0, | ||
| 136 | mono_select_text); | ||
| 137 | |||
| 138 | static const struct snd_kcontrol_new mic_linein_mux = | ||
| 139 | SOC_DAPM_ENUM("ADC Input Capture Mux", mic_linein_enum); | ||
| 140 | |||
| 141 | static const struct snd_kcontrol_new loopback_ctl = | ||
| 142 | SOC_DAPM_SINGLE("Switch", CS4265_SIG_SEL, 1, 1, 0); | ||
| 143 | |||
| 144 | static const struct snd_kcontrol_new spdif_switch = | ||
| 145 | SOC_DAPM_SINGLE("Switch", SND_SOC_NOPM, 0, 0, 0); | ||
| 146 | |||
| 147 | static const struct snd_kcontrol_new dac_switch = | ||
| 148 | SOC_DAPM_SINGLE("Switch", CS4265_PWRCTL, 1, 1, 0); | ||
| 149 | |||
| 150 | static const struct snd_kcontrol_new cs4265_snd_controls[] = { | ||
| 151 | |||
| 152 | SOC_DOUBLE_R_SX_TLV("PGA Volume", CS4265_CHA_PGA_CTL, | ||
| 153 | CS4265_CHB_PGA_CTL, 0, 0x28, 0x30, pga_tlv), | ||
| 154 | SOC_DOUBLE_R_TLV("DAC Volume", CS4265_DAC_CHA_VOL, | ||
| 155 | CS4265_DAC_CHB_VOL, 0, 0xFF, 1, dac_tlv), | ||
| 156 | SOC_SINGLE("De-emp 44.1kHz Switch", CS4265_DAC_CTL, 1, | ||
| 157 | 1, 0), | ||
| 158 | SOC_SINGLE("DAC INV Switch", CS4265_DAC_CTL2, 5, | ||
| 159 | 1, 0), | ||
| 160 | SOC_SINGLE("DAC Zero Cross Switch", CS4265_DAC_CTL2, 6, | ||
| 161 | 1, 0), | ||
| 162 | SOC_SINGLE("DAC Soft Ramp Switch", CS4265_DAC_CTL2, 7, | ||
| 163 | 1, 0), | ||
| 164 | SOC_SINGLE("ADC HPF Switch", CS4265_ADC_CTL, 1, | ||
| 165 | 1, 0), | ||
| 166 | SOC_SINGLE("ADC Zero Cross Switch", CS4265_ADC_CTL2, 3, | ||
| 167 | 1, 1), | ||
| 168 | SOC_SINGLE("ADC Soft Ramp Switch", CS4265_ADC_CTL2, 7, | ||
| 169 | 1, 0), | ||
| 170 | SOC_SINGLE("E to F Buffer Disable Switch", CS4265_SPDIF_CTL1, | ||
| 171 | 6, 1, 0), | ||
| 172 | SOC_ENUM("C Data Access", cam_mode_enum), | ||
| 173 | SOC_SINGLE("Validity Bit Control Switch", CS4265_SPDIF_CTL2, | ||
| 174 | 3, 1, 0), | ||
| 175 | SOC_ENUM("SPDIF Mono/Stereo", spdif_mono_stereo_enum), | ||
| 176 | SOC_SINGLE("MMTLR Data Switch", 0, | ||
| 177 | 1, 1, 0), | ||
| 178 | SOC_ENUM("Mono Channel Select", spdif_mono_select_enum), | ||
| 179 | SND_SOC_BYTES("C Data Buffer", CS4265_C_DATA_BUFF, 24), | ||
| 180 | }; | ||
| 181 | |||
| 182 | static const struct snd_soc_dapm_widget cs4265_dapm_widgets[] = { | ||
| 183 | |||
| 184 | SND_SOC_DAPM_INPUT("LINEINL"), | ||
| 185 | SND_SOC_DAPM_INPUT("LINEINR"), | ||
| 186 | SND_SOC_DAPM_INPUT("MICL"), | ||
| 187 | SND_SOC_DAPM_INPUT("MICR"), | ||
| 188 | |||
| 189 | SND_SOC_DAPM_AIF_OUT("DOUT", NULL, 0, | ||
| 190 | SND_SOC_NOPM, 0, 0), | ||
| 191 | SND_SOC_DAPM_AIF_OUT("SPDIFOUT", NULL, 0, | ||
| 192 | SND_SOC_NOPM, 0, 0), | ||
| 193 | |||
| 194 | SND_SOC_DAPM_MUX("ADC Mux", SND_SOC_NOPM, 0, 0, &mic_linein_mux), | ||
| 195 | |||
| 196 | SND_SOC_DAPM_ADC("ADC", NULL, CS4265_PWRCTL, 2, 1), | ||
| 197 | SND_SOC_DAPM_PGA("Pre-amp MIC", CS4265_PWRCTL, 3, | ||
| 198 | 1, NULL, 0), | ||
| 199 | |||
| 200 | SND_SOC_DAPM_MUX("Input Mux", SND_SOC_NOPM, | ||
| 201 | 0, 0, &digital_input_mux), | ||
| 202 | |||
| 203 | SND_SOC_DAPM_MIXER("SDIN1 Input Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 204 | SND_SOC_DAPM_MIXER("SDIN2 Input Mixer", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 205 | SND_SOC_DAPM_MIXER("SPDIF Transmitter", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 206 | |||
| 207 | SND_SOC_DAPM_SWITCH("Loopback", SND_SOC_NOPM, 0, 0, | ||
| 208 | &loopback_ctl), | ||
| 209 | SND_SOC_DAPM_SWITCH("SPDIF", SND_SOC_NOPM, 0, 0, | ||
| 210 | &spdif_switch), | ||
| 211 | SND_SOC_DAPM_SWITCH("DAC", CS4265_PWRCTL, 1, 1, | ||
| 212 | &dac_switch), | ||
| 213 | |||
| 214 | SND_SOC_DAPM_AIF_IN("DIN1", NULL, 0, | ||
| 215 | SND_SOC_NOPM, 0, 0), | ||
| 216 | SND_SOC_DAPM_AIF_IN("DIN2", NULL, 0, | ||
| 217 | SND_SOC_NOPM, 0, 0), | ||
| 218 | SND_SOC_DAPM_AIF_IN("TXIN", NULL, 0, | ||
| 219 | CS4265_SPDIF_CTL2, 5, 1), | ||
| 220 | |||
| 221 | SND_SOC_DAPM_OUTPUT("LINEOUTL"), | ||
| 222 | SND_SOC_DAPM_OUTPUT("LINEOUTR"), | ||
| 223 | |||
| 224 | }; | ||
| 225 | |||
| 226 | static const struct snd_soc_dapm_route cs4265_audio_map[] = { | ||
| 227 | |||
| 228 | {"DIN1", NULL, "DAI1 Playback"}, | ||
| 229 | {"DIN2", NULL, "DAI2 Playback"}, | ||
| 230 | {"SDIN1 Input Mixer", NULL, "DIN1"}, | ||
| 231 | {"SDIN2 Input Mixer", NULL, "DIN2"}, | ||
| 232 | {"Input Mux", "SDIN1", "SDIN1 Input Mixer"}, | ||
| 233 | {"Input Mux", "SDIN2", "SDIN2 Input Mixer"}, | ||
| 234 | {"DAC", "Switch", "Input Mux"}, | ||
| 235 | {"SPDIF", "Switch", "Input Mux"}, | ||
| 236 | {"LINEOUTL", NULL, "DAC"}, | ||
| 237 | {"LINEOUTR", NULL, "DAC"}, | ||
| 238 | {"SPDIFOUT", NULL, "SPDIF"}, | ||
| 239 | |||
| 240 | {"ADC Mux", "LINEIN", "LINEINL"}, | ||
| 241 | {"ADC Mux", "LINEIN", "LINEINR"}, | ||
| 242 | {"ADC Mux", "MIC", "MICL"}, | ||
| 243 | {"ADC Mux", "MIC", "MICR"}, | ||
| 244 | {"ADC", NULL, "ADC Mux"}, | ||
| 245 | {"DOUT", NULL, "ADC"}, | ||
| 246 | {"DAI1 Capture", NULL, "DOUT"}, | ||
| 247 | {"DAI2 Capture", NULL, "DOUT"}, | ||
| 248 | |||
| 249 | /* Loopback */ | ||
| 250 | {"Loopback", "Switch", "ADC"}, | ||
| 251 | {"DAC", NULL, "Loopback"}, | ||
| 252 | }; | ||
| 253 | |||
| 254 | struct cs4265_clk_para { | ||
| 255 | u32 mclk; | ||
| 256 | u32 rate; | ||
| 257 | u8 fm_mode; /* values 1, 2, or 4 */ | ||
| 258 | u8 mclkdiv; | ||
| 259 | }; | ||
| 260 | |||
| 261 | static const struct cs4265_clk_para clk_map_table[] = { | ||
| 262 | /*32k*/ | ||
| 263 | {8192000, 32000, 0, 0}, | ||
| 264 | {12288000, 32000, 0, 1}, | ||
| 265 | {16384000, 32000, 0, 2}, | ||
| 266 | {24576000, 32000, 0, 3}, | ||
| 267 | {32768000, 32000, 0, 4}, | ||
| 268 | |||
| 269 | /*44.1k*/ | ||
| 270 | {11289600, 44100, 0, 0}, | ||
| 271 | {16934400, 44100, 0, 1}, | ||
| 272 | {22579200, 44100, 0, 2}, | ||
| 273 | {33868000, 44100, 0, 3}, | ||
| 274 | {45158400, 44100, 0, 4}, | ||
| 275 | |||
| 276 | /*48k*/ | ||
| 277 | {12288000, 48000, 0, 0}, | ||
| 278 | {18432000, 48000, 0, 1}, | ||
| 279 | {24576000, 48000, 0, 2}, | ||
| 280 | {36864000, 48000, 0, 3}, | ||
| 281 | {49152000, 48000, 0, 4}, | ||
| 282 | |||
| 283 | /*64k*/ | ||
| 284 | {8192000, 64000, 1, 0}, | ||
| 285 | {1228800, 64000, 1, 1}, | ||
| 286 | {1693440, 64000, 1, 2}, | ||
| 287 | {2457600, 64000, 1, 3}, | ||
| 288 | {3276800, 64000, 1, 4}, | ||
| 289 | |||
| 290 | /* 88.2k */ | ||
| 291 | {11289600, 88200, 1, 0}, | ||
| 292 | {16934400, 88200, 1, 1}, | ||
| 293 | {22579200, 88200, 1, 2}, | ||
| 294 | {33868000, 88200, 1, 3}, | ||
| 295 | {45158400, 88200, 1, 4}, | ||
| 296 | |||
| 297 | /* 96k */ | ||
| 298 | {12288000, 96000, 1, 0}, | ||
| 299 | {18432000, 96000, 1, 1}, | ||
| 300 | {24576000, 96000, 1, 2}, | ||
| 301 | {36864000, 96000, 1, 3}, | ||
| 302 | {49152000, 96000, 1, 4}, | ||
| 303 | |||
| 304 | /* 128k */ | ||
| 305 | {8192000, 128000, 2, 0}, | ||
| 306 | {12288000, 128000, 2, 1}, | ||
| 307 | {16934400, 128000, 2, 2}, | ||
| 308 | {24576000, 128000, 2, 3}, | ||
| 309 | {32768000, 128000, 2, 4}, | ||
| 310 | |||
| 311 | /* 176.4k */ | ||
| 312 | {11289600, 176400, 2, 0}, | ||
| 313 | {16934400, 176400, 2, 1}, | ||
| 314 | {22579200, 176400, 2, 2}, | ||
| 315 | {33868000, 176400, 2, 3}, | ||
| 316 | {49152000, 176400, 2, 4}, | ||
| 317 | |||
| 318 | /* 192k */ | ||
| 319 | {12288000, 192000, 2, 0}, | ||
| 320 | {18432000, 192000, 2, 1}, | ||
| 321 | {24576000, 192000, 2, 2}, | ||
| 322 | {36864000, 192000, 2, 3}, | ||
| 323 | {49152000, 192000, 2, 4}, | ||
| 324 | }; | ||
| 325 | |||
| 326 | static int cs4265_get_clk_index(int mclk, int rate) | ||
| 327 | { | ||
| 328 | int i; | ||
| 329 | |||
| 330 | for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) { | ||
| 331 | if (clk_map_table[i].rate == rate && | ||
| 332 | clk_map_table[i].mclk == mclk) | ||
| 333 | return i; | ||
| 334 | } | ||
| 335 | return -EINVAL; | ||
| 336 | } | ||
| 337 | |||
| 338 | static int cs4265_set_sysclk(struct snd_soc_dai *codec_dai, int clk_id, | ||
| 339 | unsigned int freq, int dir) | ||
| 340 | { | ||
| 341 | struct snd_soc_codec *codec = codec_dai->codec; | ||
| 342 | struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); | ||
| 343 | int i; | ||
| 344 | |||
| 345 | if (clk_id != 0) { | ||
| 346 | dev_err(codec->dev, "Invalid clk_id %d\n", clk_id); | ||
| 347 | return -EINVAL; | ||
| 348 | } | ||
| 349 | for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) { | ||
| 350 | if (clk_map_table[i].mclk == freq) { | ||
| 351 | cs4265->sysclk = freq; | ||
| 352 | return 0; | ||
| 353 | } | ||
| 354 | } | ||
| 355 | cs4265->sysclk = 0; | ||
| 356 | dev_err(codec->dev, "Invalid freq parameter %d\n", freq); | ||
| 357 | return -EINVAL; | ||
| 358 | } | ||
| 359 | |||
| 360 | static int cs4265_set_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | ||
| 361 | { | ||
| 362 | struct snd_soc_codec *codec = codec_dai->codec; | ||
| 363 | struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); | ||
| 364 | u8 iface = 0; | ||
| 365 | |||
| 366 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
| 367 | case SND_SOC_DAIFMT_CBM_CFM: | ||
| 368 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 369 | CS4265_ADC_MASTER, | ||
| 370 | CS4265_ADC_MASTER); | ||
| 371 | break; | ||
| 372 | case SND_SOC_DAIFMT_CBS_CFS: | ||
| 373 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 374 | CS4265_ADC_MASTER, | ||
| 375 | 0); | ||
| 376 | break; | ||
| 377 | default: | ||
| 378 | return -EINVAL; | ||
| 379 | } | ||
| 380 | |||
| 381 | /* interface format */ | ||
| 382 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 383 | case SND_SOC_DAIFMT_I2S: | ||
| 384 | iface |= SND_SOC_DAIFMT_I2S; | ||
| 385 | break; | ||
| 386 | case SND_SOC_DAIFMT_RIGHT_J: | ||
| 387 | iface |= SND_SOC_DAIFMT_RIGHT_J; | ||
| 388 | break; | ||
| 389 | case SND_SOC_DAIFMT_LEFT_J: | ||
| 390 | iface |= SND_SOC_DAIFMT_LEFT_J; | ||
| 391 | break; | ||
| 392 | default: | ||
| 393 | return -EINVAL; | ||
| 394 | } | ||
| 395 | |||
| 396 | cs4265->format = iface; | ||
| 397 | return 0; | ||
| 398 | } | ||
| 399 | |||
| 400 | static int cs4265_digital_mute(struct snd_soc_dai *dai, int mute) | ||
| 401 | { | ||
| 402 | struct snd_soc_codec *codec = dai->codec; | ||
| 403 | |||
| 404 | if (mute) { | ||
| 405 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | ||
| 406 | CS4265_DAC_CTL_MUTE, | ||
| 407 | CS4265_DAC_CTL_MUTE); | ||
| 408 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | ||
| 409 | CS4265_SPDIF_CTL2_MUTE, | ||
| 410 | CS4265_SPDIF_CTL2_MUTE); | ||
| 411 | } else { | ||
| 412 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | ||
| 413 | CS4265_DAC_CTL_MUTE, | ||
| 414 | 0); | ||
| 415 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | ||
| 416 | CS4265_SPDIF_CTL2_MUTE, | ||
| 417 | 0); | ||
| 418 | } | ||
| 419 | return 0; | ||
| 420 | } | ||
| 421 | |||
| 422 | static int cs4265_pcm_hw_params(struct snd_pcm_substream *substream, | ||
| 423 | struct snd_pcm_hw_params *params, | ||
| 424 | struct snd_soc_dai *dai) | ||
| 425 | { | ||
| 426 | struct snd_soc_codec *codec = dai->codec; | ||
| 427 | struct cs4265_private *cs4265 = snd_soc_codec_get_drvdata(codec); | ||
| 428 | int index; | ||
| 429 | |||
| 430 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE && | ||
| 431 | ((cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) | ||
| 432 | == SND_SOC_DAIFMT_RIGHT_J)) | ||
| 433 | return -EINVAL; | ||
| 434 | |||
| 435 | index = cs4265_get_clk_index(cs4265->sysclk, params_rate(params)); | ||
| 436 | if (index >= 0) { | ||
| 437 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 438 | CS4265_ADC_FM, clk_map_table[index].fm_mode); | ||
| 439 | snd_soc_update_bits(codec, CS4265_MCLK_FREQ, | ||
| 440 | CS4265_MCLK_FREQ_MASK, | ||
| 441 | clk_map_table[index].mclkdiv); | ||
| 442 | |||
| 443 | } else { | ||
| 444 | dev_err(codec->dev, "can't get correct mclk\n"); | ||
| 445 | return -EINVAL; | ||
| 446 | } | ||
| 447 | |||
| 448 | switch (cs4265->format & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 449 | case SND_SOC_DAIFMT_I2S: | ||
| 450 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | ||
| 451 | CS4265_DAC_CTL_DIF, (1 << 4)); | ||
| 452 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 453 | CS4265_ADC_DIF, (1 << 4)); | ||
| 454 | snd_soc_update_bits(codec, CS4265_SPDIF_CTL2, | ||
| 455 | CS4265_SPDIF_CTL2_DIF, (1 << 6)); | ||
| 456 | break; | ||
| 457 | case SND_SOC_DAIFMT_RIGHT_J: | ||
| 458 | if (params_width(params) == 16) { | ||
| 459 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | ||
| 460 | CS4265_DAC_CTL_DIF, (1 << 5)); | ||
| 461 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 462 | CS4265_SPDIF_CTL2_DIF, (1 << 7)); | ||
| 463 | } else { | ||
| 464 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | ||
| 465 | CS4265_DAC_CTL_DIF, (3 << 5)); | ||
| 466 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 467 | CS4265_SPDIF_CTL2_DIF, (1 << 7)); | ||
| 468 | } | ||
| 469 | break; | ||
| 470 | case SND_SOC_DAIFMT_LEFT_J: | ||
| 471 | snd_soc_update_bits(codec, CS4265_DAC_CTL, | ||
| 472 | CS4265_DAC_CTL_DIF, 0); | ||
| 473 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 474 | CS4265_ADC_DIF, 0); | ||
| 475 | snd_soc_update_bits(codec, CS4265_ADC_CTL, | ||
| 476 | CS4265_SPDIF_CTL2_DIF, (1 << 6)); | ||
| 477 | |||
| 478 | break; | ||
| 479 | default: | ||
| 480 | return -EINVAL; | ||
| 481 | } | ||
| 482 | return 0; | ||
| 483 | } | ||
| 484 | |||
| 485 | static int cs4265_set_bias_level(struct snd_soc_codec *codec, | ||
| 486 | enum snd_soc_bias_level level) | ||
| 487 | { | ||
| 488 | switch (level) { | ||
| 489 | case SND_SOC_BIAS_ON: | ||
| 490 | break; | ||
| 491 | case SND_SOC_BIAS_PREPARE: | ||
| 492 | snd_soc_update_bits(codec, CS4265_PWRCTL, | ||
| 493 | CS4265_PWRCTL_PDN, 0); | ||
| 494 | break; | ||
| 495 | case SND_SOC_BIAS_STANDBY: | ||
| 496 | snd_soc_update_bits(codec, CS4265_PWRCTL, | ||
| 497 | CS4265_PWRCTL_PDN, | ||
| 498 | CS4265_PWRCTL_PDN); | ||
| 499 | break; | ||
| 500 | case SND_SOC_BIAS_OFF: | ||
| 501 | snd_soc_update_bits(codec, CS4265_PWRCTL, | ||
| 502 | CS4265_PWRCTL_PDN, | ||
| 503 | CS4265_PWRCTL_PDN); | ||
| 504 | break; | ||
| 505 | } | ||
| 506 | codec->dapm.bias_level = level; | ||
| 507 | return 0; | ||
| 508 | } | ||
| 509 | |||
| 510 | #define CS4265_RATES (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | \ | ||
| 511 | SNDRV_PCM_RATE_48000 | SNDRV_PCM_RATE_64000 | \ | ||
| 512 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \ | ||
| 513 | SNDRV_PCM_RATE_176400 | SNDRV_PCM_RATE_192000) | ||
| 514 | |||
| 515 | #define CS4265_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_U16_LE | \ | ||
| 516 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_U24_LE) | ||
| 517 | |||
| 518 | static const struct snd_soc_dai_ops cs4265_ops = { | ||
| 519 | .hw_params = cs4265_pcm_hw_params, | ||
| 520 | .digital_mute = cs4265_digital_mute, | ||
| 521 | .set_fmt = cs4265_set_fmt, | ||
| 522 | .set_sysclk = cs4265_set_sysclk, | ||
| 523 | }; | ||
| 524 | |||
| 525 | static struct snd_soc_dai_driver cs4265_dai[] = { | ||
| 526 | { | ||
| 527 | .name = "cs4265-dai1", | ||
| 528 | .playback = { | ||
| 529 | .stream_name = "DAI1 Playback", | ||
| 530 | .channels_min = 1, | ||
| 531 | .channels_max = 2, | ||
| 532 | .rates = CS4265_RATES, | ||
| 533 | .formats = CS4265_FORMATS, | ||
| 534 | }, | ||
| 535 | .capture = { | ||
| 536 | .stream_name = "DAI1 Capture", | ||
| 537 | .channels_min = 1, | ||
| 538 | .channels_max = 2, | ||
| 539 | .rates = CS4265_RATES, | ||
| 540 | .formats = CS4265_FORMATS, | ||
| 541 | }, | ||
| 542 | .ops = &cs4265_ops, | ||
| 543 | }, | ||
| 544 | { | ||
| 545 | .name = "cs4265-dai2", | ||
| 546 | .playback = { | ||
| 547 | .stream_name = "DAI2 Playback", | ||
| 548 | .channels_min = 1, | ||
| 549 | .channels_max = 2, | ||
| 550 | .rates = CS4265_RATES, | ||
| 551 | .formats = CS4265_FORMATS, | ||
| 552 | }, | ||
| 553 | .capture = { | ||
| 554 | .stream_name = "DAI2 Capture", | ||
| 555 | .channels_min = 1, | ||
| 556 | .channels_max = 2, | ||
| 557 | .rates = CS4265_RATES, | ||
| 558 | .formats = CS4265_FORMATS, | ||
| 559 | }, | ||
| 560 | .ops = &cs4265_ops, | ||
| 561 | }, | ||
| 562 | }; | ||
| 563 | |||
| 564 | static const struct snd_soc_codec_driver soc_codec_cs4265 = { | ||
| 565 | .set_bias_level = cs4265_set_bias_level, | ||
| 566 | |||
| 567 | .dapm_widgets = cs4265_dapm_widgets, | ||
| 568 | .num_dapm_widgets = ARRAY_SIZE(cs4265_dapm_widgets), | ||
| 569 | .dapm_routes = cs4265_audio_map, | ||
| 570 | .num_dapm_routes = ARRAY_SIZE(cs4265_audio_map), | ||
| 571 | |||
| 572 | .controls = cs4265_snd_controls, | ||
| 573 | .num_controls = ARRAY_SIZE(cs4265_snd_controls), | ||
| 574 | }; | ||
| 575 | |||
| 576 | static const struct regmap_config cs4265_regmap = { | ||
| 577 | .reg_bits = 8, | ||
| 578 | .val_bits = 8, | ||
| 579 | |||
| 580 | .max_register = CS4265_MAX_REGISTER, | ||
| 581 | .reg_defaults = cs4265_reg_defaults, | ||
| 582 | .num_reg_defaults = ARRAY_SIZE(cs4265_reg_defaults), | ||
| 583 | .readable_reg = cs4265_readable_register, | ||
| 584 | .volatile_reg = cs4265_volatile_register, | ||
| 585 | .cache_type = REGCACHE_RBTREE, | ||
| 586 | }; | ||
| 587 | |||
| 588 | static int cs4265_i2c_probe(struct i2c_client *i2c_client, | ||
| 589 | const struct i2c_device_id *id) | ||
| 590 | { | ||
| 591 | struct cs4265_private *cs4265; | ||
| 592 | int ret = 0; | ||
| 593 | unsigned int devid = 0; | ||
| 594 | unsigned int reg; | ||
| 595 | |||
| 596 | cs4265 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4265_private), | ||
| 597 | GFP_KERNEL); | ||
| 598 | if (cs4265 == NULL) | ||
| 599 | return -ENOMEM; | ||
| 600 | cs4265->dev = &i2c_client->dev; | ||
| 601 | |||
| 602 | cs4265->regmap = devm_regmap_init_i2c(i2c_client, &cs4265_regmap); | ||
| 603 | if (IS_ERR(cs4265->regmap)) { | ||
| 604 | ret = PTR_ERR(cs4265->regmap); | ||
| 605 | dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); | ||
| 606 | return ret; | ||
| 607 | } | ||
| 608 | |||
| 609 | cs4265->reset_gpio = devm_gpiod_get(&i2c_client->dev, | ||
| 610 | "reset-gpios"); | ||
| 611 | if (IS_ERR(cs4265->reset_gpio)) { | ||
| 612 | ret = PTR_ERR(cs4265->reset_gpio); | ||
| 613 | if (ret != -ENOENT && ret != -ENOSYS) | ||
| 614 | return ret; | ||
| 615 | |||
| 616 | cs4265->reset_gpio = NULL; | ||
| 617 | } else { | ||
| 618 | ret = gpiod_direction_output(cs4265->reset_gpio, 0); | ||
| 619 | if (ret) | ||
| 620 | return ret; | ||
| 621 | mdelay(1); | ||
| 622 | gpiod_set_value_cansleep(cs4265->reset_gpio, 1); | ||
| 623 | |||
| 624 | } | ||
| 625 | |||
| 626 | i2c_set_clientdata(i2c_client, cs4265); | ||
| 627 | |||
| 628 | ret = regmap_read(cs4265->regmap, CS4265_CHIP_ID, ®); | ||
| 629 | devid = reg & CS4265_CHIP_ID_MASK; | ||
| 630 | if (devid != CS4265_CHIP_ID_VAL) { | ||
| 631 | ret = -ENODEV; | ||
| 632 | dev_err(&i2c_client->dev, | ||
| 633 | "CS4265 Device ID (%X). Expected %X\n", | ||
| 634 | devid, CS4265_CHIP_ID); | ||
| 635 | return ret; | ||
| 636 | } | ||
| 637 | dev_info(&i2c_client->dev, | ||
| 638 | "CS4265 Version %x\n", | ||
| 639 | reg & CS4265_REV_ID_MASK); | ||
| 640 | |||
| 641 | regmap_write(cs4265->regmap, CS4265_PWRCTL, 0x0F); | ||
| 642 | |||
| 643 | ret = snd_soc_register_codec(&i2c_client->dev, | ||
| 644 | &soc_codec_cs4265, cs4265_dai, | ||
| 645 | ARRAY_SIZE(cs4265_dai)); | ||
| 646 | return ret; | ||
| 647 | } | ||
| 648 | |||
| 649 | static int cs4265_i2c_remove(struct i2c_client *client) | ||
| 650 | { | ||
| 651 | snd_soc_unregister_codec(&client->dev); | ||
| 652 | return 0; | ||
| 653 | } | ||
| 654 | |||
| 655 | static const struct of_device_id cs4265_of_match[] = { | ||
| 656 | { .compatible = "cirrus,cs4265", }, | ||
| 657 | { } | ||
| 658 | }; | ||
| 659 | MODULE_DEVICE_TABLE(of, cs4265_of_match); | ||
| 660 | |||
| 661 | static const struct i2c_device_id cs4265_id[] = { | ||
| 662 | { "cs4265", 0 }, | ||
| 663 | { } | ||
| 664 | }; | ||
| 665 | MODULE_DEVICE_TABLE(i2c, cs4265_id); | ||
| 666 | |||
| 667 | static struct i2c_driver cs4265_i2c_driver = { | ||
| 668 | .driver = { | ||
| 669 | .name = "cs4265", | ||
| 670 | .owner = THIS_MODULE, | ||
| 671 | .of_match_table = cs4265_of_match, | ||
| 672 | }, | ||
| 673 | .id_table = cs4265_id, | ||
| 674 | .probe = cs4265_i2c_probe, | ||
| 675 | .remove = cs4265_i2c_remove, | ||
| 676 | }; | ||
| 677 | |||
| 678 | module_i2c_driver(cs4265_i2c_driver); | ||
| 679 | |||
| 680 | MODULE_DESCRIPTION("ASoC CS4265 driver"); | ||
| 681 | MODULE_AUTHOR("Paul Handrigan, Cirrus Logic Inc, <paul.handrigan@cirrus.com>"); | ||
| 682 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/cs4265.h b/sound/soc/codecs/cs4265.h new file mode 100644 index 000000000000..0a80a8dcec67 --- /dev/null +++ b/sound/soc/codecs/cs4265.h | |||
| @@ -0,0 +1,64 @@ | |||
| 1 | /* | ||
| 2 | * cs4265.h -- CS4265 ALSA SoC audio driver | ||
| 3 | * | ||
| 4 | * Copyright 2014 Cirrus Logic, Inc. | ||
| 5 | * | ||
| 6 | * Author: Paul Handrigan <paul.handrigan@cirrus.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef __CS4265_H__ | ||
| 15 | #define __CS4265_H__ | ||
| 16 | |||
| 17 | #define CS4265_CHIP_ID 0x1 | ||
| 18 | #define CS4265_CHIP_ID_VAL 0xD0 | ||
| 19 | #define CS4265_CHIP_ID_MASK 0xF0 | ||
| 20 | #define CS4265_REV_ID_MASK 0x0F | ||
| 21 | |||
| 22 | #define CS4265_PWRCTL 0x02 | ||
| 23 | #define CS4265_PWRCTL_PDN 1 | ||
| 24 | |||
| 25 | #define CS4265_DAC_CTL 0x3 | ||
| 26 | #define CS4265_DAC_CTL_MUTE (1 << 2) | ||
| 27 | #define CS4265_DAC_CTL_DIF (3 << 4) | ||
| 28 | |||
| 29 | #define CS4265_ADC_CTL 0x4 | ||
| 30 | #define CS4265_ADC_MASTER 1 | ||
| 31 | #define CS4265_ADC_DIF (1 << 4) | ||
| 32 | #define CS4265_ADC_FM (3 << 6) | ||
| 33 | |||
| 34 | #define CS4265_MCLK_FREQ 0x5 | ||
| 35 | #define CS4265_MCLK_FREQ_MASK (7 << 4) | ||
| 36 | |||
| 37 | #define CS4265_SIG_SEL 0x6 | ||
| 38 | #define CS4265_SIG_SEL_LOOP (1 << 1) | ||
| 39 | |||
| 40 | #define CS4265_CHB_PGA_CTL 0x7 | ||
| 41 | #define CS4265_CHA_PGA_CTL 0x8 | ||
| 42 | |||
| 43 | #define CS4265_ADC_CTL2 0x9 | ||
| 44 | |||
| 45 | #define CS4265_DAC_CHA_VOL 0xA | ||
| 46 | #define CS4265_DAC_CHB_VOL 0xB | ||
| 47 | |||
| 48 | #define CS4265_DAC_CTL2 0xC | ||
| 49 | |||
| 50 | #define CS4265_INT_STATUS 0xD | ||
| 51 | #define CS4265_INT_MASK 0xE | ||
| 52 | #define CS4265_STATUS_MODE_MSB 0xF | ||
| 53 | #define CS4265_STATUS_MODE_LSB 0x10 | ||
| 54 | |||
| 55 | #define CS4265_SPDIF_CTL1 0x11 | ||
| 56 | |||
| 57 | #define CS4265_SPDIF_CTL2 0x12 | ||
| 58 | #define CS4265_SPDIF_CTL2_MUTE (1 << 4) | ||
| 59 | #define CS4265_SPDIF_CTL2_DIF (3 << 6) | ||
| 60 | |||
| 61 | #define CS4265_C_DATA_BUFF 0x13 | ||
| 62 | #define CS4265_MAX_REGISTER 0x2A | ||
| 63 | |||
| 64 | #endif | ||
diff --git a/sound/soc/codecs/cs4270.c b/sound/soc/codecs/cs4270.c index 9947a9583679..e6d4ff9fd992 100644 --- a/sound/soc/codecs/cs4270.c +++ b/sound/soc/codecs/cs4270.c | |||
| @@ -664,10 +664,8 @@ static int cs4270_i2c_probe(struct i2c_client *i2c_client, | |||
| 664 | 664 | ||
| 665 | cs4270 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4270_private), | 665 | cs4270 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs4270_private), |
| 666 | GFP_KERNEL); | 666 | GFP_KERNEL); |
| 667 | if (!cs4270) { | 667 | if (!cs4270) |
| 668 | dev_err(&i2c_client->dev, "could not allocate codec\n"); | ||
| 669 | return -ENOMEM; | 668 | return -ENOMEM; |
| 670 | } | ||
| 671 | 669 | ||
| 672 | /* get the power supply regulators */ | 670 | /* get the power supply regulators */ |
| 673 | for (i = 0; i < ARRAY_SIZE(supply_names); i++) | 671 | for (i = 0; i < ARRAY_SIZE(supply_names); i++) |
diff --git a/sound/soc/codecs/cs42l52.c b/sound/soc/codecs/cs42l52.c index 071fc77f2f06..969167d8b71e 100644 --- a/sound/soc/codecs/cs42l52.c +++ b/sound/soc/codecs/cs42l52.c | |||
| @@ -399,15 +399,15 @@ static const struct snd_kcontrol_new cs42l52_snd_controls[] = { | |||
| 399 | CS42L52_MASTERB_VOL, 0, 0x34, 0xE4, hl_tlv), | 399 | CS42L52_MASTERB_VOL, 0, 0x34, 0xE4, hl_tlv), |
| 400 | 400 | ||
| 401 | SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L52_HPA_VOL, | 401 | SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L52_HPA_VOL, |
| 402 | CS42L52_HPB_VOL, 0, 0x34, 0xCC, hpd_tlv), | 402 | CS42L52_HPB_VOL, 0, 0x34, 0xC0, hpd_tlv), |
| 403 | 403 | ||
| 404 | SOC_ENUM("Headphone Analog Gain", hp_gain_enum), | 404 | SOC_ENUM("Headphone Analog Gain", hp_gain_enum), |
| 405 | 405 | ||
| 406 | SOC_DOUBLE_R_SX_TLV("Speaker Volume", CS42L52_SPKA_VOL, | 406 | SOC_DOUBLE_R_SX_TLV("Speaker Volume", CS42L52_SPKA_VOL, |
| 407 | CS42L52_SPKB_VOL, 0, 0x1, 0xff, hl_tlv), | 407 | CS42L52_SPKB_VOL, 0, 0x40, 0xC0, hl_tlv), |
| 408 | 408 | ||
| 409 | SOC_DOUBLE_R_SX_TLV("Bypass Volume", CS42L52_PASSTHRUA_VOL, | 409 | SOC_DOUBLE_R_SX_TLV("Bypass Volume", CS42L52_PASSTHRUA_VOL, |
| 410 | CS42L52_PASSTHRUB_VOL, 6, 0x18, 0x90, pga_tlv), | 410 | CS42L52_PASSTHRUB_VOL, 0, 0x88, 0x90, pga_tlv), |
| 411 | 411 | ||
| 412 | SOC_DOUBLE("Bypass Mute", CS42L52_MISC_CTL, 4, 5, 1, 0), | 412 | SOC_DOUBLE("Bypass Mute", CS42L52_MISC_CTL, 4, 5, 1, 0), |
| 413 | 413 | ||
| @@ -417,10 +417,10 @@ static const struct snd_kcontrol_new cs42l52_snd_controls[] = { | |||
| 417 | SOC_ENUM("MIC Bias Level", mic_bias_level_enum), | 417 | SOC_ENUM("MIC Bias Level", mic_bias_level_enum), |
| 418 | 418 | ||
| 419 | SOC_DOUBLE_R_SX_TLV("ADC Volume", CS42L52_ADCA_VOL, | 419 | SOC_DOUBLE_R_SX_TLV("ADC Volume", CS42L52_ADCA_VOL, |
| 420 | CS42L52_ADCB_VOL, 7, 0x80, 0xA0, ipd_tlv), | 420 | CS42L52_ADCB_VOL, 0, 0xA0, 0x78, ipd_tlv), |
| 421 | SOC_DOUBLE_R_SX_TLV("ADC Mixer Volume", | 421 | SOC_DOUBLE_R_SX_TLV("ADC Mixer Volume", |
| 422 | CS42L52_ADCA_MIXER_VOL, CS42L52_ADCB_MIXER_VOL, | 422 | CS42L52_ADCA_MIXER_VOL, CS42L52_ADCB_MIXER_VOL, |
| 423 | 6, 0x7f, 0x19, ipd_tlv), | 423 | 0, 0x19, 0x7F, ipd_tlv), |
| 424 | 424 | ||
| 425 | SOC_DOUBLE("ADC Switch", CS42L52_ADC_MISC_CTL, 0, 1, 1, 0), | 425 | SOC_DOUBLE("ADC Switch", CS42L52_ADC_MISC_CTL, 0, 1, 1, 0), |
| 426 | 426 | ||
| @@ -428,11 +428,11 @@ static const struct snd_kcontrol_new cs42l52_snd_controls[] = { | |||
| 428 | CS42L52_ADCB_MIXER_VOL, 7, 1, 1), | 428 | CS42L52_ADCB_MIXER_VOL, 7, 1, 1), |
| 429 | 429 | ||
| 430 | SOC_DOUBLE_R_SX_TLV("PGA Volume", CS42L52_PGAA_CTL, | 430 | SOC_DOUBLE_R_SX_TLV("PGA Volume", CS42L52_PGAA_CTL, |
| 431 | CS42L52_PGAB_CTL, 0, 0x28, 0x30, pga_tlv), | 431 | CS42L52_PGAB_CTL, 0, 0x28, 0x24, pga_tlv), |
| 432 | 432 | ||
| 433 | SOC_DOUBLE_R_SX_TLV("PCM Mixer Volume", | 433 | SOC_DOUBLE_R_SX_TLV("PCM Mixer Volume", |
| 434 | CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL, | 434 | CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL, |
| 435 | 0, 0x7f, 0x19, mix_tlv), | 435 | 0, 0x19, 0x7f, mix_tlv), |
| 436 | SOC_DOUBLE_R("PCM Mixer Switch", | 436 | SOC_DOUBLE_R("PCM Mixer Switch", |
| 437 | CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL, 7, 1, 1), | 437 | CS42L52_PCMA_MIXER_VOL, CS42L52_PCMB_MIXER_VOL, 7, 1, 1), |
| 438 | 438 | ||
diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c index fdc4bd27b0df..c766a5a9ce80 100644 --- a/sound/soc/codecs/cs42l56.c +++ b/sound/soc/codecs/cs42l56.c | |||
| @@ -318,24 +318,32 @@ static const struct soc_enum adca_swap_enum = | |||
| 318 | ARRAY_SIZE(left_swap_text), | 318 | ARRAY_SIZE(left_swap_text), |
| 319 | left_swap_text, | 319 | left_swap_text, |
| 320 | swap_values); | 320 | swap_values); |
| 321 | static const struct snd_kcontrol_new adca_swap_mux = | ||
| 322 | SOC_DAPM_ENUM("Route", adca_swap_enum); | ||
| 321 | 323 | ||
| 322 | static const struct soc_enum pcma_swap_enum = | 324 | static const struct soc_enum pcma_swap_enum = |
| 323 | SOC_VALUE_ENUM_SINGLE(CS42L56_CHAN_MIX_SWAP, 4, 3, | 325 | SOC_VALUE_ENUM_SINGLE(CS42L56_CHAN_MIX_SWAP, 4, 3, |
| 324 | ARRAY_SIZE(left_swap_text), | 326 | ARRAY_SIZE(left_swap_text), |
| 325 | left_swap_text, | 327 | left_swap_text, |
| 326 | swap_values); | 328 | swap_values); |
| 329 | static const struct snd_kcontrol_new pcma_swap_mux = | ||
| 330 | SOC_DAPM_ENUM("Route", pcma_swap_enum); | ||
| 327 | 331 | ||
| 328 | static const struct soc_enum adcb_swap_enum = | 332 | static const struct soc_enum adcb_swap_enum = |
| 329 | SOC_VALUE_ENUM_SINGLE(CS42L56_CHAN_MIX_SWAP, 2, 3, | 333 | SOC_VALUE_ENUM_SINGLE(CS42L56_CHAN_MIX_SWAP, 2, 3, |
| 330 | ARRAY_SIZE(right_swap_text), | 334 | ARRAY_SIZE(right_swap_text), |
| 331 | right_swap_text, | 335 | right_swap_text, |
| 332 | swap_values); | 336 | swap_values); |
| 337 | static const struct snd_kcontrol_new adcb_swap_mux = | ||
| 338 | SOC_DAPM_ENUM("Route", adcb_swap_enum); | ||
| 333 | 339 | ||
| 334 | static const struct soc_enum pcmb_swap_enum = | 340 | static const struct soc_enum pcmb_swap_enum = |
| 335 | SOC_VALUE_ENUM_SINGLE(CS42L56_CHAN_MIX_SWAP, 6, 3, | 341 | SOC_VALUE_ENUM_SINGLE(CS42L56_CHAN_MIX_SWAP, 6, 3, |
| 336 | ARRAY_SIZE(right_swap_text), | 342 | ARRAY_SIZE(right_swap_text), |
| 337 | right_swap_text, | 343 | right_swap_text, |
| 338 | swap_values); | 344 | swap_values); |
| 345 | static const struct snd_kcontrol_new pcmb_swap_mux = | ||
| 346 | SOC_DAPM_ENUM("Route", pcmb_swap_enum); | ||
| 339 | 347 | ||
| 340 | static const struct snd_kcontrol_new hpa_switch = | 348 | static const struct snd_kcontrol_new hpa_switch = |
| 341 | SOC_DAPM_SINGLE("Switch", CS42L56_PWRCTL_2, 6, 1, 1); | 349 | SOC_DAPM_SINGLE("Switch", CS42L56_PWRCTL_2, 6, 1, 1); |
| @@ -421,15 +429,15 @@ static const struct soc_enum ng_delay_enum = | |||
| 421 | static const struct snd_kcontrol_new cs42l56_snd_controls[] = { | 429 | static const struct snd_kcontrol_new cs42l56_snd_controls[] = { |
| 422 | 430 | ||
| 423 | SOC_DOUBLE_R_SX_TLV("Master Volume", CS42L56_MASTER_A_VOLUME, | 431 | SOC_DOUBLE_R_SX_TLV("Master Volume", CS42L56_MASTER_A_VOLUME, |
| 424 | CS42L56_MASTER_B_VOLUME, 0, 0x34, 0xfd, adv_tlv), | 432 | CS42L56_MASTER_B_VOLUME, 0, 0x34, 0xE4, adv_tlv), |
| 425 | SOC_DOUBLE("Master Mute Switch", CS42L56_DSP_MUTE_CTL, 0, 1, 1, 1), | 433 | SOC_DOUBLE("Master Mute Switch", CS42L56_DSP_MUTE_CTL, 0, 1, 1, 1), |
| 426 | 434 | ||
| 427 | SOC_DOUBLE_R_SX_TLV("ADC Mixer Volume", CS42L56_ADCA_MIX_VOLUME, | 435 | SOC_DOUBLE_R_SX_TLV("ADC Mixer Volume", CS42L56_ADCA_MIX_VOLUME, |
| 428 | CS42L56_ADCB_MIX_VOLUME, 0, 0x88, 0xa9, hl_tlv), | 436 | CS42L56_ADCB_MIX_VOLUME, 0, 0x88, 0x90, hl_tlv), |
| 429 | SOC_DOUBLE("ADC Mixer Mute Switch", CS42L56_DSP_MUTE_CTL, 6, 7, 1, 1), | 437 | SOC_DOUBLE("ADC Mixer Mute Switch", CS42L56_DSP_MUTE_CTL, 6, 7, 1, 1), |
| 430 | 438 | ||
| 431 | SOC_DOUBLE_R_SX_TLV("PCM Mixer Volume", CS42L56_PCMA_MIX_VOLUME, | 439 | SOC_DOUBLE_R_SX_TLV("PCM Mixer Volume", CS42L56_PCMA_MIX_VOLUME, |
| 432 | CS42L56_PCMB_MIX_VOLUME, 0, 0x88, 0xa9, hl_tlv), | 440 | CS42L56_PCMB_MIX_VOLUME, 0, 0x88, 0x90, hl_tlv), |
| 433 | SOC_DOUBLE("PCM Mixer Mute Switch", CS42L56_DSP_MUTE_CTL, 4, 5, 1, 1), | 441 | SOC_DOUBLE("PCM Mixer Mute Switch", CS42L56_DSP_MUTE_CTL, 4, 5, 1, 1), |
| 434 | 442 | ||
| 435 | SOC_SINGLE_TLV("Analog Advisory Volume", | 443 | SOC_SINGLE_TLV("Analog Advisory Volume", |
| @@ -438,16 +446,16 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = { | |||
| 438 | CS42L56_DIGINPUT_ADV_VOLUME, 0, 0x00, 1, adv_tlv), | 446 | CS42L56_DIGINPUT_ADV_VOLUME, 0, 0x00, 1, adv_tlv), |
| 439 | 447 | ||
| 440 | SOC_DOUBLE_R_SX_TLV("PGA Volume", CS42L56_PGAA_MUX_VOLUME, | 448 | SOC_DOUBLE_R_SX_TLV("PGA Volume", CS42L56_PGAA_MUX_VOLUME, |
| 441 | CS42L56_PGAB_MUX_VOLUME, 0, 0x34, 0xfd, pga_tlv), | 449 | CS42L56_PGAB_MUX_VOLUME, 0, 0x34, 0x24, pga_tlv), |
| 442 | SOC_DOUBLE_R_TLV("ADC Volume", CS42L56_ADCA_ATTENUATOR, | 450 | SOC_DOUBLE_R_TLV("ADC Volume", CS42L56_ADCA_ATTENUATOR, |
| 443 | CS42L56_ADCB_ATTENUATOR, 0, 0x00, 1, adc_tlv), | 451 | CS42L56_ADCB_ATTENUATOR, 0, 0x00, 1, adc_tlv), |
| 444 | SOC_DOUBLE("ADC Mute Switch", CS42L56_MISC_ADC_CTL, 2, 3, 1, 1), | 452 | SOC_DOUBLE("ADC Mute Switch", CS42L56_MISC_ADC_CTL, 2, 3, 1, 1), |
| 445 | SOC_DOUBLE("ADC Boost Switch", CS42L56_GAIN_BIAS_CTL, 3, 2, 1, 1), | 453 | SOC_DOUBLE("ADC Boost Switch", CS42L56_GAIN_BIAS_CTL, 3, 2, 1, 1), |
| 446 | 454 | ||
| 447 | SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L56_HPA_VOLUME, | 455 | SOC_DOUBLE_R_SX_TLV("Headphone Volume", CS42L56_HPA_VOLUME, |
| 448 | CS42L56_HPA_VOLUME, 0, 0x44, 0x55, hl_tlv), | 456 | CS42L56_HPB_VOLUME, 0, 0x84, 0x48, hl_tlv), |
| 449 | SOC_DOUBLE_R_SX_TLV("LineOut Volume", CS42L56_LOA_VOLUME, | 457 | SOC_DOUBLE_R_SX_TLV("LineOut Volume", CS42L56_LOA_VOLUME, |
| 450 | CS42L56_LOA_VOLUME, 0, 0x44, 0x55, hl_tlv), | 458 | CS42L56_LOB_VOLUME, 0, 0x84, 0x48, hl_tlv), |
| 451 | 459 | ||
| 452 | SOC_SINGLE_TLV("Bass Shelving Volume", CS42L56_TONE_CTL, | 460 | SOC_SINGLE_TLV("Bass Shelving Volume", CS42L56_TONE_CTL, |
| 453 | 0, 0x00, 1, tone_tlv), | 461 | 0, 0x00, 1, tone_tlv), |
| @@ -467,11 +475,6 @@ static const struct snd_kcontrol_new cs42l56_snd_controls[] = { | |||
| 467 | SOC_SINGLE("ADCA Invert", CS42L56_MISC_ADC_CTL, 2, 1, 1), | 475 | SOC_SINGLE("ADCA Invert", CS42L56_MISC_ADC_CTL, 2, 1, 1), |
| 468 | SOC_SINGLE("ADCB Invert", CS42L56_MISC_ADC_CTL, 3, 1, 1), | 476 | SOC_SINGLE("ADCB Invert", CS42L56_MISC_ADC_CTL, 3, 1, 1), |
| 469 | 477 | ||
| 470 | SOC_ENUM("PCMA Swap", pcma_swap_enum), | ||
| 471 | SOC_ENUM("PCMB Swap", pcmb_swap_enum), | ||
| 472 | SOC_ENUM("ADCA Swap", adca_swap_enum), | ||
| 473 | SOC_ENUM("ADCB Swap", adcb_swap_enum), | ||
| 474 | |||
| 475 | SOC_DOUBLE("HPF Switch", CS42L56_HPF_CTL, 5, 7, 1, 1), | 478 | SOC_DOUBLE("HPF Switch", CS42L56_HPF_CTL, 5, 7, 1, 1), |
| 476 | SOC_DOUBLE("HPF Freeze Switch", CS42L56_HPF_CTL, 4, 6, 1, 1), | 479 | SOC_DOUBLE("HPF Freeze Switch", CS42L56_HPF_CTL, 4, 6, 1, 1), |
| 477 | SOC_ENUM("HPFA Corner Freq", hpfa_freq_enum), | 480 | SOC_ENUM("HPFA Corner Freq", hpfa_freq_enum), |
| @@ -570,6 +573,16 @@ static const struct snd_soc_dapm_widget cs42l56_dapm_widgets[] = { | |||
| 570 | SND_SOC_DAPM_ADC("ADCA", NULL, CS42L56_PWRCTL_1, 1, 1), | 573 | SND_SOC_DAPM_ADC("ADCA", NULL, CS42L56_PWRCTL_1, 1, 1), |
| 571 | SND_SOC_DAPM_ADC("ADCB", NULL, CS42L56_PWRCTL_1, 2, 1), | 574 | SND_SOC_DAPM_ADC("ADCB", NULL, CS42L56_PWRCTL_1, 2, 1), |
| 572 | 575 | ||
| 576 | SND_SOC_DAPM_MUX("ADCA Swap Mux", SND_SOC_NOPM, 0, 0, | ||
| 577 | &adca_swap_mux), | ||
| 578 | SND_SOC_DAPM_MUX("ADCB Swap Mux", SND_SOC_NOPM, 0, 0, | ||
| 579 | &adcb_swap_mux), | ||
| 580 | |||
| 581 | SND_SOC_DAPM_MUX("PCMA Swap Mux", SND_SOC_NOPM, 0, 0, | ||
| 582 | &pcma_swap_mux), | ||
| 583 | SND_SOC_DAPM_MUX("PCMB Swap Mux", SND_SOC_NOPM, 0, 0, | ||
| 584 | &pcmb_swap_mux), | ||
| 585 | |||
| 573 | SND_SOC_DAPM_DAC("DACA", NULL, SND_SOC_NOPM, 0, 0), | 586 | SND_SOC_DAPM_DAC("DACA", NULL, SND_SOC_NOPM, 0, 0), |
| 574 | SND_SOC_DAPM_DAC("DACB", NULL, SND_SOC_NOPM, 0, 0), | 587 | SND_SOC_DAPM_DAC("DACB", NULL, SND_SOC_NOPM, 0, 0), |
| 575 | 588 | ||
| @@ -607,8 +620,19 @@ static const struct snd_soc_dapm_route cs42l56_audio_map[] = { | |||
| 607 | {"Digital Output Mux", NULL, "ADCA"}, | 620 | {"Digital Output Mux", NULL, "ADCA"}, |
| 608 | {"Digital Output Mux", NULL, "ADCB"}, | 621 | {"Digital Output Mux", NULL, "ADCB"}, |
| 609 | 622 | ||
| 610 | {"ADCB", NULL, "ADCB Mux"}, | 623 | {"ADCB", NULL, "ADCB Swap Mux"}, |
| 611 | {"ADCA", NULL, "ADCA Mux"}, | 624 | {"ADCA", NULL, "ADCA Swap Mux"}, |
| 625 | |||
| 626 | {"ADCA Swap Mux", NULL, "ADCA"}, | ||
| 627 | {"ADCB Swap Mux", NULL, "ADCB"}, | ||
| 628 | |||
| 629 | {"DACA", "Left", "ADCA Swap Mux"}, | ||
| 630 | {"DACA", "LR 2", "ADCA Swap Mux"}, | ||
| 631 | {"DACA", "Right", "ADCA Swap Mux"}, | ||
| 632 | |||
| 633 | {"DACB", "Left", "ADCB Swap Mux"}, | ||
| 634 | {"DACB", "LR 2", "ADCB Swap Mux"}, | ||
| 635 | {"DACB", "Right", "ADCB Swap Mux"}, | ||
| 612 | 636 | ||
| 613 | {"ADCA Mux", NULL, "AIN3A"}, | 637 | {"ADCA Mux", NULL, "AIN3A"}, |
| 614 | {"ADCA Mux", NULL, "AIN2A"}, | 638 | {"ADCA Mux", NULL, "AIN2A"}, |
| @@ -633,30 +657,32 @@ static const struct snd_soc_dapm_route cs42l56_audio_map[] = { | |||
| 633 | {"PGAB Input Mux", NULL, "AIN2B"}, | 657 | {"PGAB Input Mux", NULL, "AIN2B"}, |
| 634 | {"PGAB Input Mux", NULL, "AIN3B"}, | 658 | {"PGAB Input Mux", NULL, "AIN3B"}, |
| 635 | 659 | ||
| 636 | {"LOB", NULL, "Lineout Right"}, | 660 | {"LOB", "Switch", "LINEOUTB Input Mux"}, |
| 637 | {"LOA", NULL, "Lineout Left"}, | 661 | {"LOA", "Switch", "LINEOUTA Input Mux"}, |
| 638 | |||
| 639 | {"Lineout Right", "Switch", "LINEOUTB Input Mux"}, | ||
| 640 | {"Lineout Left", "Switch", "LINEOUTA Input Mux"}, | ||
| 641 | 662 | ||
| 642 | {"LINEOUTA Input Mux", "PGAA", "PGAA"}, | 663 | {"LINEOUTA Input Mux", "PGAA", "PGAA"}, |
| 643 | {"LINEOUTB Input Mux", "PGAB", "PGAB"}, | 664 | {"LINEOUTB Input Mux", "PGAB", "PGAB"}, |
| 644 | {"LINEOUTA Input Mux", "DACA", "DACA"}, | 665 | {"LINEOUTA Input Mux", "DACA", "DACA"}, |
| 645 | {"LINEOUTB Input Mux", "DACB", "DACB"}, | 666 | {"LINEOUTB Input Mux", "DACB", "DACB"}, |
| 646 | 667 | ||
| 647 | {"HPA", NULL, "Headphone Left"}, | 668 | {"HPA", "Switch", "HPB Input Mux"}, |
| 648 | {"HPB", NULL, "Headphone Right"}, | 669 | {"HPB", "Switch", "HPA Input Mux"}, |
| 649 | |||
| 650 | {"Headphone Right", "Switch", "HPB Input Mux"}, | ||
| 651 | {"Headphone Left", "Switch", "HPA Input Mux"}, | ||
| 652 | 670 | ||
| 653 | {"HPA Input Mux", "PGAA", "PGAA"}, | 671 | {"HPA Input Mux", "PGAA", "PGAA"}, |
| 654 | {"HPB Input Mux", "PGAB", "PGAB"}, | 672 | {"HPB Input Mux", "PGAB", "PGAB"}, |
| 655 | {"HPA Input Mux", "DACA", "DACA"}, | 673 | {"HPA Input Mux", "DACA", "DACA"}, |
| 656 | {"HPB Input Mux", "DACB", "DACB"}, | 674 | {"HPB Input Mux", "DACB", "DACB"}, |
| 657 | 675 | ||
| 658 | {"DACB", NULL, "HiFi Playback"}, | 676 | {"DACA", NULL, "PCMA Swap Mux"}, |
| 659 | {"DACA", NULL, "HiFi Playback"}, | 677 | {"DACB", NULL, "PCMB Swap Mux"}, |
| 678 | |||
| 679 | {"PCMB Swap Mux", "Left", "HiFi Playback"}, | ||
| 680 | {"PCMB Swap Mux", "LR 2", "HiFi Playback"}, | ||
| 681 | {"PCMB Swap Mux", "Right", "HiFi Playback"}, | ||
| 682 | |||
| 683 | {"PCMA Swap Mux", "Left", "HiFi Playback"}, | ||
| 684 | {"PCMA Swap Mux", "LR 2", "HiFi Playback"}, | ||
| 685 | {"PCMA Swap Mux", "Right", "HiFi Playback"}, | ||
| 660 | 686 | ||
| 661 | }; | 687 | }; |
| 662 | 688 | ||
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index ae3717992d56..0e7b9eb2ba61 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.c | |||
| @@ -401,7 +401,7 @@ static const struct snd_kcontrol_new cs42l73_snd_controls[] = { | |||
| 401 | CS42L73_LOBAVOL, 0, 0x41, 0x4B, hpaloa_tlv), | 401 | CS42L73_LOBAVOL, 0, 0x41, 0x4B, hpaloa_tlv), |
| 402 | 402 | ||
| 403 | SOC_DOUBLE_R_SX_TLV("Input PGA Analog Volume", CS42L73_MICAPREPGAAVOL, | 403 | SOC_DOUBLE_R_SX_TLV("Input PGA Analog Volume", CS42L73_MICAPREPGAAVOL, |
| 404 | CS42L73_MICBPREPGABVOL, 5, 0x34, | 404 | CS42L73_MICBPREPGABVOL, 0, 0x34, |
| 405 | 0x24, micpga_tlv), | 405 | 0x24, micpga_tlv), |
| 406 | 406 | ||
| 407 | SOC_DOUBLE_R("MIC Preamp Switch", CS42L73_MICAPREPGAAVOL, | 407 | SOC_DOUBLE_R("MIC Preamp Switch", CS42L73_MICAPREPGAAVOL, |
| @@ -1408,10 +1408,8 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, | |||
| 1408 | 1408 | ||
| 1409 | cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), | 1409 | cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), |
| 1410 | GFP_KERNEL); | 1410 | GFP_KERNEL); |
| 1411 | if (!cs42l73) { | 1411 | if (!cs42l73) |
| 1412 | dev_err(&i2c_client->dev, "could not allocate codec\n"); | ||
| 1413 | return -ENOMEM; | 1412 | return -ENOMEM; |
| 1414 | } | ||
| 1415 | 1413 | ||
| 1416 | cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap); | 1414 | cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap); |
| 1417 | if (IS_ERR(cs42l73->regmap)) { | 1415 | if (IS_ERR(cs42l73->regmap)) { |
diff --git a/sound/soc/codecs/cs42xx8.c b/sound/soc/codecs/cs42xx8.c index a25bc6061a30..02b1520ae0bc 100644 --- a/sound/soc/codecs/cs42xx8.c +++ b/sound/soc/codecs/cs42xx8.c | |||
| @@ -219,6 +219,9 @@ static int cs42xx8_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
| 219 | case SND_SOC_DAIFMT_RIGHT_J: | 219 | case SND_SOC_DAIFMT_RIGHT_J: |
| 220 | val = CS42XX8_INTF_DAC_DIF_RIGHTJ | CS42XX8_INTF_ADC_DIF_RIGHTJ; | 220 | val = CS42XX8_INTF_DAC_DIF_RIGHTJ | CS42XX8_INTF_ADC_DIF_RIGHTJ; |
| 221 | break; | 221 | break; |
| 222 | case SND_SOC_DAIFMT_DSP_A: | ||
| 223 | val = CS42XX8_INTF_DAC_DIF_TDM | CS42XX8_INTF_ADC_DIF_TDM; | ||
| 224 | break; | ||
| 222 | default: | 225 | default: |
| 223 | dev_err(codec->dev, "unsupported dai format\n"); | 226 | dev_err(codec->dev, "unsupported dai format\n"); |
| 224 | return -EINVAL; | 227 | return -EINVAL; |
| @@ -422,7 +425,7 @@ const struct cs42xx8_driver_data cs42888_data = { | |||
| 422 | }; | 425 | }; |
| 423 | EXPORT_SYMBOL_GPL(cs42888_data); | 426 | EXPORT_SYMBOL_GPL(cs42888_data); |
| 424 | 427 | ||
| 425 | const struct of_device_id cs42xx8_of_match[] = { | 428 | static const struct of_device_id cs42xx8_of_match[] = { |
| 426 | { .compatible = "cirrus,cs42448", .data = &cs42448_data, }, | 429 | { .compatible = "cirrus,cs42448", .data = &cs42448_data, }, |
| 427 | { .compatible = "cirrus,cs42888", .data = &cs42888_data, }, | 430 | { .compatible = "cirrus,cs42888", .data = &cs42888_data, }, |
| 428 | { /* sentinel */ } | 431 | { /* sentinel */ } |
diff --git a/sound/soc/codecs/cs42xx8.h b/sound/soc/codecs/cs42xx8.h index da0b94aee419..b2c10e537ef6 100644 --- a/sound/soc/codecs/cs42xx8.h +++ b/sound/soc/codecs/cs42xx8.h | |||
| @@ -128,8 +128,8 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap); | |||
| 128 | #define CS42XX8_INTF_DAC_DIF_RIGHTJ (2 << CS42XX8_INTF_DAC_DIF_SHIFT) | 128 | #define CS42XX8_INTF_DAC_DIF_RIGHTJ (2 << CS42XX8_INTF_DAC_DIF_SHIFT) |
| 129 | #define CS42XX8_INTF_DAC_DIF_RIGHTJ_16 (3 << CS42XX8_INTF_DAC_DIF_SHIFT) | 129 | #define CS42XX8_INTF_DAC_DIF_RIGHTJ_16 (3 << CS42XX8_INTF_DAC_DIF_SHIFT) |
| 130 | #define CS42XX8_INTF_DAC_DIF_ONELINE_20 (4 << CS42XX8_INTF_DAC_DIF_SHIFT) | 130 | #define CS42XX8_INTF_DAC_DIF_ONELINE_20 (4 << CS42XX8_INTF_DAC_DIF_SHIFT) |
| 131 | #define CS42XX8_INTF_DAC_DIF_ONELINE_24 (6 << CS42XX8_INTF_DAC_DIF_SHIFT) | 131 | #define CS42XX8_INTF_DAC_DIF_ONELINE_24 (5 << CS42XX8_INTF_DAC_DIF_SHIFT) |
| 132 | #define CS42XX8_INTF_DAC_DIF_TDM (7 << CS42XX8_INTF_DAC_DIF_SHIFT) | 132 | #define CS42XX8_INTF_DAC_DIF_TDM (6 << CS42XX8_INTF_DAC_DIF_SHIFT) |
| 133 | #define CS42XX8_INTF_ADC_DIF_SHIFT 0 | 133 | #define CS42XX8_INTF_ADC_DIF_SHIFT 0 |
| 134 | #define CS42XX8_INTF_ADC_DIF_WIDTH 3 | 134 | #define CS42XX8_INTF_ADC_DIF_WIDTH 3 |
| 135 | #define CS42XX8_INTF_ADC_DIF_MASK (((1 << CS42XX8_INTF_ADC_DIF_WIDTH) - 1) << CS42XX8_INTF_ADC_DIF_SHIFT) | 135 | #define CS42XX8_INTF_ADC_DIF_MASK (((1 << CS42XX8_INTF_ADC_DIF_WIDTH) - 1) << CS42XX8_INTF_ADC_DIF_SHIFT) |
| @@ -138,8 +138,8 @@ int cs42xx8_probe(struct device *dev, struct regmap *regmap); | |||
| 138 | #define CS42XX8_INTF_ADC_DIF_RIGHTJ (2 << CS42XX8_INTF_ADC_DIF_SHIFT) | 138 | #define CS42XX8_INTF_ADC_DIF_RIGHTJ (2 << CS42XX8_INTF_ADC_DIF_SHIFT) |
| 139 | #define CS42XX8_INTF_ADC_DIF_RIGHTJ_16 (3 << CS42XX8_INTF_ADC_DIF_SHIFT) | 139 | #define CS42XX8_INTF_ADC_DIF_RIGHTJ_16 (3 << CS42XX8_INTF_ADC_DIF_SHIFT) |
| 140 | #define CS42XX8_INTF_ADC_DIF_ONELINE_20 (4 << CS42XX8_INTF_ADC_DIF_SHIFT) | 140 | #define CS42XX8_INTF_ADC_DIF_ONELINE_20 (4 << CS42XX8_INTF_ADC_DIF_SHIFT) |
| 141 | #define CS42XX8_INTF_ADC_DIF_ONELINE_24 (6 << CS42XX8_INTF_ADC_DIF_SHIFT) | 141 | #define CS42XX8_INTF_ADC_DIF_ONELINE_24 (5 << CS42XX8_INTF_ADC_DIF_SHIFT) |
| 142 | #define CS42XX8_INTF_ADC_DIF_TDM (7 << CS42XX8_INTF_ADC_DIF_SHIFT) | 142 | #define CS42XX8_INTF_ADC_DIF_TDM (6 << CS42XX8_INTF_ADC_DIF_SHIFT) |
| 143 | 143 | ||
| 144 | /* ADC Control & DAC De-Emphasis (Address 05h) */ | 144 | /* ADC Control & DAC De-Emphasis (Address 05h) */ |
| 145 | #define CS42XX8_ADCCTL_ADC_HPF_FREEZE_SHIFT 7 | 145 | #define CS42XX8_ADCCTL_ADC_HPF_FREEZE_SHIFT 7 |
diff --git a/sound/soc/codecs/cx20442.c b/sound/soc/codecs/cx20442.c index d5fd00a64748..8f95b0300f1a 100644 --- a/sound/soc/codecs/cx20442.c +++ b/sound/soc/codecs/cx20442.c | |||
| @@ -253,7 +253,7 @@ static void v253_close(struct tty_struct *tty) | |||
| 253 | /* Prevent the codec driver from further accessing the modem */ | 253 | /* Prevent the codec driver from further accessing the modem */ |
| 254 | codec->hw_write = NULL; | 254 | codec->hw_write = NULL; |
| 255 | cx20442->control_data = NULL; | 255 | cx20442->control_data = NULL; |
| 256 | codec->card->pop_time = 0; | 256 | codec->component.card->pop_time = 0; |
| 257 | } | 257 | } |
| 258 | 258 | ||
| 259 | /* Line discipline .hangup() */ | 259 | /* Line discipline .hangup() */ |
| @@ -281,7 +281,7 @@ static void v253_receive(struct tty_struct *tty, | |||
| 281 | /* Set up codec driver access to modem controls */ | 281 | /* Set up codec driver access to modem controls */ |
| 282 | cx20442->control_data = tty; | 282 | cx20442->control_data = tty; |
| 283 | codec->hw_write = (hw_write_t)tty->ops->write; | 283 | codec->hw_write = (hw_write_t)tty->ops->write; |
| 284 | codec->card->pop_time = 1; | 284 | codec->component.card->pop_time = 1; |
| 285 | } | 285 | } |
| 286 | } | 286 | } |
| 287 | 287 | ||
| @@ -372,7 +372,7 @@ static int cx20442_codec_probe(struct snd_soc_codec *codec) | |||
| 372 | 372 | ||
| 373 | snd_soc_codec_set_drvdata(codec, cx20442); | 373 | snd_soc_codec_set_drvdata(codec, cx20442); |
| 374 | codec->hw_write = NULL; | 374 | codec->hw_write = NULL; |
| 375 | codec->card->pop_time = 0; | 375 | codec->component.card->pop_time = 0; |
| 376 | 376 | ||
| 377 | return 0; | 377 | return 0; |
| 378 | } | 378 | } |
| @@ -383,8 +383,8 @@ static int cx20442_codec_remove(struct snd_soc_codec *codec) | |||
| 383 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); | 383 | struct cx20442_priv *cx20442 = snd_soc_codec_get_drvdata(codec); |
| 384 | 384 | ||
| 385 | if (cx20442->control_data) { | 385 | if (cx20442->control_data) { |
| 386 | struct tty_struct *tty = cx20442->control_data; | 386 | struct tty_struct *tty = cx20442->control_data; |
| 387 | tty_hangup(tty); | 387 | tty_hangup(tty); |
| 388 | } | 388 | } |
| 389 | 389 | ||
| 390 | if (!IS_ERR(cx20442->por)) { | 390 | if (!IS_ERR(cx20442->por)) { |
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 9134982807b5..2cd3e5427441 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c | |||
| @@ -1299,12 +1299,12 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream, | |||
| 1299 | 1299 | ||
| 1300 | rate = params_rate(params); | 1300 | rate = params_rate(params); |
| 1301 | 1301 | ||
| 1302 | switch (params_format(params)) { | 1302 | switch (params_width(params)) { |
| 1303 | case SNDRV_PCM_FORMAT_S16_LE: | 1303 | case 16: |
| 1304 | snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT, | 1304 | snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT, |
| 1305 | M98088_DAI_WS, 0); | 1305 | M98088_DAI_WS, 0); |
| 1306 | break; | 1306 | break; |
| 1307 | case SNDRV_PCM_FORMAT_S24_LE: | 1307 | case 24: |
| 1308 | snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT, | 1308 | snd_soc_update_bits(codec, M98088_REG_1C_DAI2_FORMAT, |
| 1309 | M98088_DAI_WS, M98088_DAI_WS); | 1309 | M98088_DAI_WS, M98088_DAI_WS); |
| 1310 | break; | 1310 | break; |
diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c index f5fccc7a8e89..4a063fa88526 100644 --- a/sound/soc/codecs/max98090.c +++ b/sound/soc/codecs/max98090.c | |||
| @@ -26,10 +26,6 @@ | |||
| 26 | #include <sound/max98090.h> | 26 | #include <sound/max98090.h> |
| 27 | #include "max98090.h" | 27 | #include "max98090.h" |
| 28 | 28 | ||
| 29 | #define DEBUG | ||
| 30 | #define EXTMIC_METHOD | ||
| 31 | #define EXTMIC_METHOD_TEST | ||
| 32 | |||
| 33 | /* Allows for sparsely populated register maps */ | 29 | /* Allows for sparsely populated register maps */ |
| 34 | static struct reg_default max98090_reg[] = { | 30 | static struct reg_default max98090_reg[] = { |
| 35 | { 0x00, 0x00 }, /* 00 Software Reset */ | 31 | { 0x00, 0x00 }, /* 00 Software Reset */ |
| @@ -820,7 +816,6 @@ static int max98090_micinput_event(struct snd_soc_dapm_widget *w, | |||
| 820 | else | 816 | else |
| 821 | val = (val & M98090_MIC_PA2EN_MASK) >> M98090_MIC_PA2EN_SHIFT; | 817 | val = (val & M98090_MIC_PA2EN_MASK) >> M98090_MIC_PA2EN_SHIFT; |
| 822 | 818 | ||
| 823 | |||
| 824 | if (val >= 1) { | 819 | if (val >= 1) { |
| 825 | if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) { | 820 | if (w->reg == M98090_REG_MIC1_INPUT_LEVEL) { |
| 826 | max98090->pa1en = val - 1; /* Update for volatile */ | 821 | max98090->pa1en = val - 1; /* Update for volatile */ |
| @@ -1140,7 +1135,6 @@ static const struct snd_kcontrol_new max98090_mixhprsel_mux = | |||
| 1140 | SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum); | 1135 | SOC_DAPM_ENUM("MIXHPRSEL Mux", mixhprsel_mux_enum); |
| 1141 | 1136 | ||
| 1142 | static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { | 1137 | static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { |
| 1143 | |||
| 1144 | SND_SOC_DAPM_INPUT("MIC1"), | 1138 | SND_SOC_DAPM_INPUT("MIC1"), |
| 1145 | SND_SOC_DAPM_INPUT("MIC2"), | 1139 | SND_SOC_DAPM_INPUT("MIC2"), |
| 1146 | SND_SOC_DAPM_INPUT("DMICL"), | 1140 | SND_SOC_DAPM_INPUT("DMICL"), |
| @@ -1304,7 +1298,6 @@ static const struct snd_soc_dapm_widget max98090_dapm_widgets[] = { | |||
| 1304 | }; | 1298 | }; |
| 1305 | 1299 | ||
| 1306 | static const struct snd_soc_dapm_widget max98091_dapm_widgets[] = { | 1300 | static const struct snd_soc_dapm_widget max98091_dapm_widgets[] = { |
| 1307 | |||
| 1308 | SND_SOC_DAPM_INPUT("DMIC3"), | 1301 | SND_SOC_DAPM_INPUT("DMIC3"), |
| 1309 | SND_SOC_DAPM_INPUT("DMIC4"), | 1302 | SND_SOC_DAPM_INPUT("DMIC4"), |
| 1310 | 1303 | ||
| @@ -1315,7 +1308,6 @@ static const struct snd_soc_dapm_widget max98091_dapm_widgets[] = { | |||
| 1315 | }; | 1308 | }; |
| 1316 | 1309 | ||
| 1317 | static const struct snd_soc_dapm_route max98090_dapm_routes[] = { | 1310 | static const struct snd_soc_dapm_route max98090_dapm_routes[] = { |
| 1318 | |||
| 1319 | {"MIC1 Input", NULL, "MIC1"}, | 1311 | {"MIC1 Input", NULL, "MIC1"}, |
| 1320 | {"MIC2 Input", NULL, "MIC2"}, | 1312 | {"MIC2 Input", NULL, "MIC2"}, |
| 1321 | 1313 | ||
| @@ -1493,17 +1485,14 @@ static const struct snd_soc_dapm_route max98090_dapm_routes[] = { | |||
| 1493 | {"SPKR", NULL, "SPK Right Out"}, | 1485 | {"SPKR", NULL, "SPK Right Out"}, |
| 1494 | {"RCVL", NULL, "RCV Left Out"}, | 1486 | {"RCVL", NULL, "RCV Left Out"}, |
| 1495 | {"RCVR", NULL, "RCV Right Out"}, | 1487 | {"RCVR", NULL, "RCV Right Out"}, |
| 1496 | |||
| 1497 | }; | 1488 | }; |
| 1498 | 1489 | ||
| 1499 | static const struct snd_soc_dapm_route max98091_dapm_routes[] = { | 1490 | static const struct snd_soc_dapm_route max98091_dapm_routes[] = { |
| 1500 | |||
| 1501 | /* DMIC inputs */ | 1491 | /* DMIC inputs */ |
| 1502 | {"DMIC3", NULL, "DMIC3_ENA"}, | 1492 | {"DMIC3", NULL, "DMIC3_ENA"}, |
| 1503 | {"DMIC4", NULL, "DMIC4_ENA"}, | 1493 | {"DMIC4", NULL, "DMIC4_ENA"}, |
| 1504 | {"DMIC3", NULL, "AHPF"}, | 1494 | {"DMIC3", NULL, "AHPF"}, |
| 1505 | {"DMIC4", NULL, "AHPF"}, | 1495 | {"DMIC4", NULL, "AHPF"}, |
| 1506 | |||
| 1507 | }; | 1496 | }; |
| 1508 | 1497 | ||
| 1509 | static int max98090_add_widgets(struct snd_soc_codec *codec) | 1498 | static int max98090_add_widgets(struct snd_soc_codec *codec) |
| @@ -1531,7 +1520,6 @@ static int max98090_add_widgets(struct snd_soc_codec *codec) | |||
| 1531 | 1520 | ||
| 1532 | snd_soc_dapm_add_routes(dapm, max98091_dapm_routes, | 1521 | snd_soc_dapm_add_routes(dapm, max98091_dapm_routes, |
| 1533 | ARRAY_SIZE(max98091_dapm_routes)); | 1522 | ARRAY_SIZE(max98091_dapm_routes)); |
| 1534 | |||
| 1535 | } | 1523 | } |
| 1536 | 1524 | ||
| 1537 | return 0; | 1525 | return 0; |
| @@ -2212,22 +2200,11 @@ static struct snd_soc_dai_driver max98090_dai[] = { | |||
| 2212 | } | 2200 | } |
| 2213 | }; | 2201 | }; |
| 2214 | 2202 | ||
| 2215 | static void max98090_handle_pdata(struct snd_soc_codec *codec) | ||
| 2216 | { | ||
| 2217 | struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); | ||
| 2218 | struct max98090_pdata *pdata = max98090->pdata; | ||
| 2219 | |||
| 2220 | if (!pdata) { | ||
| 2221 | dev_err(codec->dev, "No platform data\n"); | ||
| 2222 | return; | ||
| 2223 | } | ||
| 2224 | |||
| 2225 | } | ||
| 2226 | |||
| 2227 | static int max98090_probe(struct snd_soc_codec *codec) | 2203 | static int max98090_probe(struct snd_soc_codec *codec) |
| 2228 | { | 2204 | { |
| 2229 | struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); | 2205 | struct max98090_priv *max98090 = snd_soc_codec_get_drvdata(codec); |
| 2230 | struct max98090_cdata *cdata; | 2206 | struct max98090_cdata *cdata; |
| 2207 | enum max98090_type devtype; | ||
| 2231 | int ret = 0; | 2208 | int ret = 0; |
| 2232 | 2209 | ||
| 2233 | dev_dbg(codec->dev, "max98090_probe\n"); | 2210 | dev_dbg(codec->dev, "max98090_probe\n"); |
| @@ -2263,16 +2240,21 @@ static int max98090_probe(struct snd_soc_codec *codec) | |||
| 2263 | } | 2240 | } |
| 2264 | 2241 | ||
| 2265 | if ((ret >= M98090_REVA) && (ret <= M98090_REVA + 0x0f)) { | 2242 | if ((ret >= M98090_REVA) && (ret <= M98090_REVA + 0x0f)) { |
| 2266 | max98090->devtype = MAX98090; | 2243 | devtype = MAX98090; |
| 2267 | dev_info(codec->dev, "MAX98090 REVID=0x%02x\n", ret); | 2244 | dev_info(codec->dev, "MAX98090 REVID=0x%02x\n", ret); |
| 2268 | } else if ((ret >= M98091_REVA) && (ret <= M98091_REVA + 0x0f)) { | 2245 | } else if ((ret >= M98091_REVA) && (ret <= M98091_REVA + 0x0f)) { |
| 2269 | max98090->devtype = MAX98091; | 2246 | devtype = MAX98091; |
| 2270 | dev_info(codec->dev, "MAX98091 REVID=0x%02x\n", ret); | 2247 | dev_info(codec->dev, "MAX98091 REVID=0x%02x\n", ret); |
| 2271 | } else { | 2248 | } else { |
| 2272 | max98090->devtype = MAX98090; | 2249 | devtype = MAX98090; |
| 2273 | dev_err(codec->dev, "Unrecognized revision 0x%02x\n", ret); | 2250 | dev_err(codec->dev, "Unrecognized revision 0x%02x\n", ret); |
| 2274 | } | 2251 | } |
| 2275 | 2252 | ||
| 2253 | if (max98090->devtype != devtype) { | ||
| 2254 | dev_warn(codec->dev, "Mismatch in DT specified CODEC type.\n"); | ||
| 2255 | max98090->devtype = devtype; | ||
| 2256 | } | ||
| 2257 | |||
| 2276 | max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; | 2258 | max98090->jack_state = M98090_JACK_STATE_NO_HEADSET; |
| 2277 | 2259 | ||
| 2278 | INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); | 2260 | INIT_DELAYED_WORK(&max98090->jack_work, max98090_jack_work); |
| @@ -2284,7 +2266,7 @@ static int max98090_probe(struct snd_soc_codec *codec) | |||
| 2284 | /* Register for interrupts */ | 2266 | /* Register for interrupts */ |
| 2285 | dev_dbg(codec->dev, "irq = %d\n", max98090->irq); | 2267 | dev_dbg(codec->dev, "irq = %d\n", max98090->irq); |
| 2286 | 2268 | ||
| 2287 | ret = request_threaded_irq(max98090->irq, NULL, | 2269 | ret = devm_request_threaded_irq(codec->dev, max98090->irq, NULL, |
| 2288 | max98090_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, | 2270 | max98090_interrupt, IRQF_TRIGGER_FALLING | IRQF_ONESHOT, |
| 2289 | "max98090_interrupt", codec); | 2271 | "max98090_interrupt", codec); |
| 2290 | if (ret < 0) { | 2272 | if (ret < 0) { |
| @@ -2317,8 +2299,6 @@ static int max98090_probe(struct snd_soc_codec *codec) | |||
| 2317 | snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE, | 2299 | snd_soc_update_bits(codec, M98090_REG_MIC_BIAS_VOLTAGE, |
| 2318 | M98090_MBVSEL_MASK, M98090_MBVSEL_2V8); | 2300 | M98090_MBVSEL_MASK, M98090_MBVSEL_2V8); |
| 2319 | 2301 | ||
| 2320 | max98090_handle_pdata(codec); | ||
| 2321 | |||
| 2322 | max98090_add_widgets(codec); | 2302 | max98090_add_widgets(codec); |
| 2323 | 2303 | ||
| 2324 | err_access: | 2304 | err_access: |
| @@ -2428,7 +2408,7 @@ static int max98090_runtime_suspend(struct device *dev) | |||
| 2428 | } | 2408 | } |
| 2429 | #endif | 2409 | #endif |
| 2430 | 2410 | ||
| 2431 | #ifdef CONFIG_PM | 2411 | #ifdef CONFIG_PM_SLEEP |
| 2432 | static int max98090_resume(struct device *dev) | 2412 | static int max98090_resume(struct device *dev) |
| 2433 | { | 2413 | { |
| 2434 | struct max98090_priv *max98090 = dev_get_drvdata(dev); | 2414 | struct max98090_priv *max98090 = dev_get_drvdata(dev); |
| @@ -2460,12 +2440,14 @@ static const struct dev_pm_ops max98090_pm = { | |||
| 2460 | 2440 | ||
| 2461 | static const struct i2c_device_id max98090_i2c_id[] = { | 2441 | static const struct i2c_device_id max98090_i2c_id[] = { |
| 2462 | { "max98090", MAX98090 }, | 2442 | { "max98090", MAX98090 }, |
| 2443 | { "max98091", MAX98091 }, | ||
| 2463 | { } | 2444 | { } |
| 2464 | }; | 2445 | }; |
| 2465 | MODULE_DEVICE_TABLE(i2c, max98090_i2c_id); | 2446 | MODULE_DEVICE_TABLE(i2c, max98090_i2c_id); |
| 2466 | 2447 | ||
| 2467 | static const struct of_device_id max98090_of_match[] = { | 2448 | static const struct of_device_id max98090_of_match[] = { |
| 2468 | { .compatible = "maxim,max98090", }, | 2449 | { .compatible = "maxim,max98090", }, |
| 2450 | { .compatible = "maxim,max98091", }, | ||
| 2469 | { } | 2451 | { } |
| 2470 | }; | 2452 | }; |
| 2471 | MODULE_DEVICE_TABLE(of, max98090_of_match); | 2453 | MODULE_DEVICE_TABLE(of, max98090_of_match); |
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 89ec00424880..0ee6797d5083 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c | |||
| @@ -1280,12 +1280,12 @@ static int max98095_dai2_hw_params(struct snd_pcm_substream *substream, | |||
| 1280 | 1280 | ||
| 1281 | rate = params_rate(params); | 1281 | rate = params_rate(params); |
| 1282 | 1282 | ||
| 1283 | switch (params_format(params)) { | 1283 | switch (params_width(params)) { |
| 1284 | case SNDRV_PCM_FORMAT_S16_LE: | 1284 | case 16: |
| 1285 | snd_soc_update_bits(codec, M98095_034_DAI2_FORMAT, | 1285 | snd_soc_update_bits(codec, M98095_034_DAI2_FORMAT, |
| 1286 | M98095_DAI_WS, 0); | 1286 | M98095_DAI_WS, 0); |
| 1287 | break; | 1287 | break; |
| 1288 | case SNDRV_PCM_FORMAT_S24_LE: | 1288 | case 24: |
| 1289 | snd_soc_update_bits(codec, M98095_034_DAI2_FORMAT, | 1289 | snd_soc_update_bits(codec, M98095_034_DAI2_FORMAT, |
| 1290 | M98095_DAI_WS, M98095_DAI_WS); | 1290 | M98095_DAI_WS, M98095_DAI_WS); |
| 1291 | break; | 1291 | break; |
| @@ -1341,12 +1341,12 @@ static int max98095_dai3_hw_params(struct snd_pcm_substream *substream, | |||
| 1341 | 1341 | ||
| 1342 | rate = params_rate(params); | 1342 | rate = params_rate(params); |
| 1343 | 1343 | ||
| 1344 | switch (params_format(params)) { | 1344 | switch (params_width(params)) { |
| 1345 | case SNDRV_PCM_FORMAT_S16_LE: | 1345 | case 16: |
| 1346 | snd_soc_update_bits(codec, M98095_03E_DAI3_FORMAT, | 1346 | snd_soc_update_bits(codec, M98095_03E_DAI3_FORMAT, |
| 1347 | M98095_DAI_WS, 0); | 1347 | M98095_DAI_WS, 0); |
| 1348 | break; | 1348 | break; |
| 1349 | case SNDRV_PCM_FORMAT_S24_LE: | 1349 | case 24: |
| 1350 | snd_soc_update_bits(codec, M98095_03E_DAI3_FORMAT, | 1350 | snd_soc_update_bits(codec, M98095_03E_DAI3_FORMAT, |
| 1351 | M98095_DAI_WS, M98095_DAI_WS); | 1351 | M98095_DAI_WS, M98095_DAI_WS); |
| 1352 | break; | 1352 | break; |
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index 9965277b595a..388f90a597fa 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c | |||
| @@ -766,11 +766,11 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) | |||
| 766 | 766 | ||
| 767 | ret = of_property_read_u32(np, "adc-port", &priv->adc_ssi_port); | 767 | ret = of_property_read_u32(np, "adc-port", &priv->adc_ssi_port); |
| 768 | if (ret) | 768 | if (ret) |
| 769 | return ret; | 769 | goto out; |
| 770 | 770 | ||
| 771 | ret = of_property_read_u32(np, "dac-port", &priv->dac_ssi_port); | 771 | ret = of_property_read_u32(np, "dac-port", &priv->dac_ssi_port); |
| 772 | if (ret) | 772 | if (ret) |
| 773 | return ret; | 773 | goto out; |
| 774 | } | 774 | } |
| 775 | 775 | ||
| 776 | dev_set_drvdata(&pdev->dev, priv); | 776 | dev_set_drvdata(&pdev->dev, priv); |
| @@ -783,6 +783,8 @@ static int __init mc13783_codec_probe(struct platform_device *pdev) | |||
| 783 | ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, | 783 | ret = snd_soc_register_codec(&pdev->dev, &soc_codec_dev_mc13783, |
| 784 | mc13783_dai_async, ARRAY_SIZE(mc13783_dai_async)); | 784 | mc13783_dai_async, ARRAY_SIZE(mc13783_dai_async)); |
| 785 | 785 | ||
| 786 | out: | ||
| 787 | of_node_put(np); | ||
| 786 | return ret; | 788 | return ret; |
| 787 | } | 789 | } |
| 788 | 790 | ||
diff --git a/sound/soc/codecs/pcm1792a.c b/sound/soc/codecs/pcm1792a.c index 3a80ba4452df..57b0c94a710b 100644 --- a/sound/soc/codecs/pcm1792a.c +++ b/sound/soc/codecs/pcm1792a.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #define PCM1792A_DAC_VOL_LEFT 0x10 | 36 | #define PCM1792A_DAC_VOL_LEFT 0x10 |
| 37 | #define PCM1792A_DAC_VOL_RIGHT 0x11 | 37 | #define PCM1792A_DAC_VOL_RIGHT 0x11 |
| 38 | #define PCM1792A_FMT_CONTROL 0x12 | 38 | #define PCM1792A_FMT_CONTROL 0x12 |
| 39 | #define PCM1792A_MODE_CONTROL 0x13 | ||
| 39 | #define PCM1792A_SOFT_MUTE PCM1792A_FMT_CONTROL | 40 | #define PCM1792A_SOFT_MUTE PCM1792A_FMT_CONTROL |
| 40 | 41 | ||
| 41 | #define PCM1792A_FMT_MASK 0x70 | 42 | #define PCM1792A_FMT_MASK 0x70 |
| @@ -164,6 +165,8 @@ static const struct snd_kcontrol_new pcm1792a_controls[] = { | |||
| 164 | SOC_DOUBLE_R_RANGE_TLV("DAC Playback Volume", PCM1792A_DAC_VOL_LEFT, | 165 | SOC_DOUBLE_R_RANGE_TLV("DAC Playback Volume", PCM1792A_DAC_VOL_LEFT, |
| 165 | PCM1792A_DAC_VOL_RIGHT, 0, 0xf, 0xff, 0, | 166 | PCM1792A_DAC_VOL_RIGHT, 0, 0xf, 0xff, 0, |
| 166 | pcm1792a_dac_tlv), | 167 | pcm1792a_dac_tlv), |
| 168 | SOC_SINGLE("DAC Invert Output Switch", PCM1792A_MODE_CONTROL, 7, 1, 0), | ||
| 169 | SOC_SINGLE("DAC Rolloff Filter Switch", PCM1792A_MODE_CONTROL, 1, 1, 0), | ||
| 167 | }; | 170 | }; |
| 168 | 171 | ||
| 169 | static const struct snd_soc_dapm_widget pcm1792a_dapm_widgets[] = { | 172 | static const struct snd_soc_dapm_widget pcm1792a_dapm_widgets[] = { |
diff --git a/sound/soc/codecs/pcm1792a.h b/sound/soc/codecs/pcm1792a.h index 7a83d1fc102a..51d5470fee16 100644 --- a/sound/soc/codecs/pcm1792a.h +++ b/sound/soc/codecs/pcm1792a.h | |||
| @@ -18,7 +18,8 @@ | |||
| 18 | #define __PCM1792A_H__ | 18 | #define __PCM1792A_H__ |
| 19 | 19 | ||
| 20 | #define PCM1792A_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_8000_48000 | \ | 20 | #define PCM1792A_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_8000_48000 | \ |
| 21 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_192000) | 21 | SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | \ |
| 22 | SNDRV_PCM_RATE_192000) | ||
| 22 | 23 | ||
| 23 | #define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ | 24 | #define PCM1792A_FORMATS (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ |
| 24 | SNDRV_PCM_FMTBIT_S16_LE) | 25 | SNDRV_PCM_FMTBIT_S16_LE) |
diff --git a/sound/soc/codecs/rl6231.c b/sound/soc/codecs/rl6231.c index 7b82fbe0d14c..56650d6c2f53 100644 --- a/sound/soc/codecs/rl6231.c +++ b/sound/soc/codecs/rl6231.c | |||
| @@ -11,25 +11,6 @@ | |||
| 11 | */ | 11 | */ |
| 12 | 12 | ||
| 13 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 14 | #include <linux/moduleparam.h> | ||
| 15 | #include <linux/init.h> | ||
| 16 | #include <linux/delay.h> | ||
| 17 | #include <linux/pm.h> | ||
| 18 | #include <linux/gpio.h> | ||
| 19 | #include <linux/i2c.h> | ||
| 20 | #include <linux/regmap.h> | ||
| 21 | #include <linux/of.h> | ||
| 22 | #include <linux/of_gpio.h> | ||
| 23 | #include <linux/platform_device.h> | ||
| 24 | #include <linux/spi/spi.h> | ||
| 25 | #include <linux/acpi.h> | ||
| 26 | #include <sound/core.h> | ||
| 27 | #include <sound/pcm.h> | ||
| 28 | #include <sound/pcm_params.h> | ||
| 29 | #include <sound/soc.h> | ||
| 30 | #include <sound/soc-dapm.h> | ||
| 31 | #include <sound/initval.h> | ||
| 32 | #include <sound/tlv.h> | ||
| 33 | 14 | ||
| 34 | #include "rl6231.h" | 15 | #include "rl6231.h" |
| 35 | 16 | ||
diff --git a/sound/soc/codecs/rt286.c b/sound/soc/codecs/rt286.c new file mode 100644 index 000000000000..e4f6102efc1a --- /dev/null +++ b/sound/soc/codecs/rt286.c | |||
| @@ -0,0 +1,1222 @@ | |||
| 1 | /* | ||
| 2 | * rt286.c -- RT286 ALSA SoC audio codec driver | ||
| 3 | * | ||
| 4 | * Copyright 2013 Realtek Semiconductor Corp. | ||
| 5 | * Author: Bard Liao <bardliao@realtek.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/module.h> | ||
| 13 | #include <linux/moduleparam.h> | ||
| 14 | #include <linux/init.h> | ||
| 15 | #include <linux/delay.h> | ||
| 16 | #include <linux/pm.h> | ||
| 17 | #include <linux/i2c.h> | ||
| 18 | #include <linux/platform_device.h> | ||
| 19 | #include <linux/spi/spi.h> | ||
| 20 | #include <linux/acpi.h> | ||
| 21 | #include <sound/core.h> | ||
| 22 | #include <sound/pcm.h> | ||
| 23 | #include <sound/pcm_params.h> | ||
| 24 | #include <sound/soc.h> | ||
| 25 | #include <sound/soc-dapm.h> | ||
| 26 | #include <sound/initval.h> | ||
| 27 | #include <sound/tlv.h> | ||
| 28 | #include <sound/jack.h> | ||
| 29 | #include <linux/workqueue.h> | ||
| 30 | #include <sound/rt286.h> | ||
| 31 | #include <sound/hda_verbs.h> | ||
| 32 | |||
| 33 | #include "rt286.h" | ||
| 34 | |||
| 35 | #define RT286_VENDOR_ID 0x10ec0286 | ||
| 36 | |||
| 37 | struct rt286_priv { | ||
| 38 | struct regmap *regmap; | ||
| 39 | struct rt286_platform_data pdata; | ||
| 40 | struct i2c_client *i2c; | ||
| 41 | struct snd_soc_jack *jack; | ||
| 42 | struct delayed_work jack_detect_work; | ||
| 43 | int sys_clk; | ||
| 44 | struct reg_default *index_cache; | ||
| 45 | }; | ||
| 46 | |||
| 47 | static struct reg_default rt286_index_def[] = { | ||
| 48 | { 0x01, 0xaaaa }, | ||
| 49 | { 0x02, 0x8aaa }, | ||
| 50 | { 0x03, 0x0002 }, | ||
| 51 | { 0x04, 0xaf01 }, | ||
| 52 | { 0x08, 0x000d }, | ||
| 53 | { 0x09, 0xd810 }, | ||
| 54 | { 0x0a, 0x0060 }, | ||
| 55 | { 0x0b, 0x0000 }, | ||
| 56 | { 0x0d, 0x2800 }, | ||
| 57 | { 0x0f, 0x0000 }, | ||
| 58 | { 0x19, 0x0a17 }, | ||
| 59 | { 0x20, 0x0020 }, | ||
| 60 | { 0x33, 0x0208 }, | ||
| 61 | { 0x49, 0x0004 }, | ||
| 62 | { 0x4f, 0x50e9 }, | ||
| 63 | { 0x50, 0x2c00 }, | ||
| 64 | { 0x63, 0x2902 }, | ||
| 65 | { 0x67, 0x1111 }, | ||
| 66 | { 0x68, 0x1016 }, | ||
| 67 | { 0x69, 0x273f }, | ||
| 68 | }; | ||
| 69 | #define INDEX_CACHE_SIZE ARRAY_SIZE(rt286_index_def) | ||
| 70 | |||
| 71 | static const struct reg_default rt286_reg[] = { | ||
| 72 | { 0x00170500, 0x00000400 }, | ||
| 73 | { 0x00220000, 0x00000031 }, | ||
| 74 | { 0x00239000, 0x0000007f }, | ||
| 75 | { 0x0023a000, 0x0000007f }, | ||
| 76 | { 0x00270500, 0x00000400 }, | ||
| 77 | { 0x00370500, 0x00000400 }, | ||
| 78 | { 0x00870500, 0x00000400 }, | ||
| 79 | { 0x00920000, 0x00000031 }, | ||
| 80 | { 0x00935000, 0x000000c3 }, | ||
| 81 | { 0x00936000, 0x000000c3 }, | ||
| 82 | { 0x00970500, 0x00000400 }, | ||
| 83 | { 0x00b37000, 0x00000097 }, | ||
| 84 | { 0x00b37200, 0x00000097 }, | ||
| 85 | { 0x00b37300, 0x00000097 }, | ||
| 86 | { 0x00c37000, 0x00000000 }, | ||
| 87 | { 0x00c37100, 0x00000080 }, | ||
| 88 | { 0x01270500, 0x00000400 }, | ||
| 89 | { 0x01370500, 0x00000400 }, | ||
| 90 | { 0x01371f00, 0x411111f0 }, | ||
| 91 | { 0x01439000, 0x00000080 }, | ||
| 92 | { 0x0143a000, 0x00000080 }, | ||
| 93 | { 0x01470700, 0x00000000 }, | ||
| 94 | { 0x01470500, 0x00000400 }, | ||
| 95 | { 0x01470c00, 0x00000000 }, | ||
| 96 | { 0x01470100, 0x00000000 }, | ||
| 97 | { 0x01837000, 0x00000000 }, | ||
| 98 | { 0x01870500, 0x00000400 }, | ||
| 99 | { 0x02050000, 0x00000000 }, | ||
| 100 | { 0x02139000, 0x00000080 }, | ||
| 101 | { 0x0213a000, 0x00000080 }, | ||
| 102 | { 0x02170100, 0x00000000 }, | ||
| 103 | { 0x02170500, 0x00000400 }, | ||
| 104 | { 0x02170700, 0x00000000 }, | ||
| 105 | { 0x02270100, 0x00000000 }, | ||
| 106 | { 0x02370100, 0x00000000 }, | ||
| 107 | { 0x02040000, 0x00004002 }, | ||
| 108 | { 0x01870700, 0x00000020 }, | ||
| 109 | { 0x00830000, 0x000000c3 }, | ||
| 110 | { 0x00930000, 0x000000c3 }, | ||
| 111 | { 0x01270700, 0x00000000 }, | ||
| 112 | }; | ||
| 113 | |||
| 114 | static bool rt286_volatile_register(struct device *dev, unsigned int reg) | ||
| 115 | { | ||
| 116 | switch (reg) { | ||
| 117 | case 0 ... 0xff: | ||
| 118 | case RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID): | ||
| 119 | case RT286_GET_HP_SENSE: | ||
| 120 | case RT286_GET_MIC1_SENSE: | ||
| 121 | case RT286_PROC_COEF: | ||
| 122 | return true; | ||
| 123 | default: | ||
| 124 | return false; | ||
| 125 | } | ||
| 126 | |||
| 127 | |||
| 128 | } | ||
| 129 | |||
| 130 | static bool rt286_readable_register(struct device *dev, unsigned int reg) | ||
| 131 | { | ||
| 132 | switch (reg) { | ||
| 133 | case 0 ... 0xff: | ||
| 134 | case RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID): | ||
| 135 | case RT286_GET_HP_SENSE: | ||
| 136 | case RT286_GET_MIC1_SENSE: | ||
| 137 | case RT286_SET_AUDIO_POWER: | ||
| 138 | case RT286_SET_HPO_POWER: | ||
| 139 | case RT286_SET_SPK_POWER: | ||
| 140 | case RT286_SET_DMIC1_POWER: | ||
| 141 | case RT286_SPK_MUX: | ||
| 142 | case RT286_HPO_MUX: | ||
| 143 | case RT286_ADC0_MUX: | ||
| 144 | case RT286_ADC1_MUX: | ||
| 145 | case RT286_SET_MIC1: | ||
| 146 | case RT286_SET_PIN_HPO: | ||
| 147 | case RT286_SET_PIN_SPK: | ||
| 148 | case RT286_SET_PIN_DMIC1: | ||
| 149 | case RT286_SPK_EAPD: | ||
| 150 | case RT286_SET_AMP_GAIN_HPO: | ||
| 151 | case RT286_SET_DMIC2_DEFAULT: | ||
| 152 | case RT286_DACL_GAIN: | ||
| 153 | case RT286_DACR_GAIN: | ||
| 154 | case RT286_ADCL_GAIN: | ||
| 155 | case RT286_ADCR_GAIN: | ||
| 156 | case RT286_MIC_GAIN: | ||
| 157 | case RT286_SPOL_GAIN: | ||
| 158 | case RT286_SPOR_GAIN: | ||
| 159 | case RT286_HPOL_GAIN: | ||
| 160 | case RT286_HPOR_GAIN: | ||
| 161 | case RT286_F_DAC_SWITCH: | ||
| 162 | case RT286_F_RECMIX_SWITCH: | ||
| 163 | case RT286_REC_MIC_SWITCH: | ||
| 164 | case RT286_REC_I2S_SWITCH: | ||
| 165 | case RT286_REC_LINE_SWITCH: | ||
| 166 | case RT286_REC_BEEP_SWITCH: | ||
| 167 | case RT286_DAC_FORMAT: | ||
| 168 | case RT286_ADC_FORMAT: | ||
| 169 | case RT286_COEF_INDEX: | ||
| 170 | case RT286_PROC_COEF: | ||
| 171 | case RT286_SET_AMP_GAIN_ADC_IN1: | ||
| 172 | case RT286_SET_AMP_GAIN_ADC_IN2: | ||
| 173 | case RT286_SET_POWER(RT286_DAC_OUT1): | ||
| 174 | case RT286_SET_POWER(RT286_DAC_OUT2): | ||
| 175 | case RT286_SET_POWER(RT286_ADC_IN1): | ||
| 176 | case RT286_SET_POWER(RT286_ADC_IN2): | ||
| 177 | case RT286_SET_POWER(RT286_DMIC2): | ||
| 178 | case RT286_SET_POWER(RT286_MIC1): | ||
| 179 | return true; | ||
| 180 | default: | ||
| 181 | return false; | ||
| 182 | } | ||
| 183 | } | ||
| 184 | |||
| 185 | static int rt286_hw_write(void *context, unsigned int reg, unsigned int value) | ||
| 186 | { | ||
| 187 | struct i2c_client *client = context; | ||
| 188 | struct rt286_priv *rt286 = i2c_get_clientdata(client); | ||
| 189 | u8 data[4]; | ||
| 190 | int ret, i; | ||
| 191 | |||
| 192 | /*handle index registers*/ | ||
| 193 | if (reg <= 0xff) { | ||
| 194 | rt286_hw_write(client, RT286_COEF_INDEX, reg); | ||
| 195 | reg = RT286_PROC_COEF; | ||
| 196 | for (i = 0; i < INDEX_CACHE_SIZE; i++) { | ||
| 197 | if (reg == rt286->index_cache[i].reg) { | ||
| 198 | rt286->index_cache[i].def = value; | ||
| 199 | break; | ||
| 200 | } | ||
| 201 | |||
| 202 | } | ||
| 203 | } | ||
| 204 | |||
| 205 | data[0] = (reg >> 24) & 0xff; | ||
| 206 | data[1] = (reg >> 16) & 0xff; | ||
| 207 | /* | ||
| 208 | * 4 bit VID: reg should be 0 | ||
| 209 | * 12 bit VID: value should be 0 | ||
| 210 | * So we use an OR operator to handle it rather than use if condition. | ||
| 211 | */ | ||
| 212 | data[2] = ((reg >> 8) & 0xff) | ((value >> 8) & 0xff); | ||
| 213 | data[3] = value & 0xff; | ||
| 214 | |||
| 215 | ret = i2c_master_send(client, data, 4); | ||
| 216 | |||
| 217 | if (ret == 4) | ||
| 218 | return 0; | ||
| 219 | else | ||
| 220 | pr_err("ret=%d\n", ret); | ||
| 221 | if (ret < 0) | ||
| 222 | return ret; | ||
| 223 | else | ||
| 224 | return -EIO; | ||
| 225 | } | ||
| 226 | |||
| 227 | static int rt286_hw_read(void *context, unsigned int reg, unsigned int *value) | ||
| 228 | { | ||
| 229 | struct i2c_client *client = context; | ||
| 230 | struct i2c_msg xfer[2]; | ||
| 231 | int ret; | ||
| 232 | __be32 be_reg; | ||
| 233 | unsigned int index, vid, buf = 0x0; | ||
| 234 | |||
| 235 | /*handle index registers*/ | ||
| 236 | if (reg <= 0xff) { | ||
| 237 | rt286_hw_write(client, RT286_COEF_INDEX, reg); | ||
| 238 | reg = RT286_PROC_COEF; | ||
| 239 | } | ||
| 240 | |||
| 241 | reg = reg | 0x80000; | ||
| 242 | vid = (reg >> 8) & 0xfff; | ||
| 243 | |||
| 244 | if (AC_VERB_GET_AMP_GAIN_MUTE == (vid & 0xf00)) { | ||
| 245 | index = (reg >> 8) & 0xf; | ||
| 246 | reg = (reg & ~0xf0f) | index; | ||
| 247 | } | ||
| 248 | be_reg = cpu_to_be32(reg); | ||
| 249 | |||
| 250 | /* Write register */ | ||
| 251 | xfer[0].addr = client->addr; | ||
| 252 | xfer[0].flags = 0; | ||
| 253 | xfer[0].len = 4; | ||
| 254 | xfer[0].buf = (u8 *)&be_reg; | ||
| 255 | |||
| 256 | /* Read data */ | ||
| 257 | xfer[1].addr = client->addr; | ||
| 258 | xfer[1].flags = I2C_M_RD; | ||
| 259 | xfer[1].len = 4; | ||
| 260 | xfer[1].buf = (u8 *)&buf; | ||
| 261 | |||
| 262 | ret = i2c_transfer(client->adapter, xfer, 2); | ||
| 263 | if (ret < 0) | ||
| 264 | return ret; | ||
| 265 | else if (ret != 2) | ||
| 266 | return -EIO; | ||
| 267 | |||
| 268 | *value = be32_to_cpu(buf); | ||
| 269 | |||
| 270 | return 0; | ||
| 271 | } | ||
| 272 | |||
| 273 | static void rt286_index_sync(struct snd_soc_codec *codec) | ||
| 274 | { | ||
| 275 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 276 | int i; | ||
| 277 | |||
| 278 | for (i = 0; i < INDEX_CACHE_SIZE; i++) { | ||
| 279 | snd_soc_write(codec, rt286->index_cache[i].reg, | ||
| 280 | rt286->index_cache[i].def); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 284 | static int rt286_support_power_controls[] = { | ||
| 285 | RT286_DAC_OUT1, | ||
| 286 | RT286_DAC_OUT2, | ||
| 287 | RT286_ADC_IN1, | ||
| 288 | RT286_ADC_IN2, | ||
| 289 | RT286_MIC1, | ||
| 290 | RT286_DMIC1, | ||
| 291 | RT286_DMIC2, | ||
| 292 | RT286_SPK_OUT, | ||
| 293 | RT286_HP_OUT, | ||
| 294 | }; | ||
| 295 | #define RT286_POWER_REG_LEN ARRAY_SIZE(rt286_support_power_controls) | ||
| 296 | |||
| 297 | static int rt286_jack_detect(struct rt286_priv *rt286, bool *hp, bool *mic) | ||
| 298 | { | ||
| 299 | unsigned int val, buf; | ||
| 300 | int i; | ||
| 301 | |||
| 302 | *hp = false; | ||
| 303 | *mic = false; | ||
| 304 | |||
| 305 | if (rt286->pdata.cbj_en) { | ||
| 306 | regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); | ||
| 307 | *hp = buf & 0x80000000; | ||
| 308 | if (*hp) { | ||
| 309 | /* power on HV,VERF */ | ||
| 310 | regmap_update_bits(rt286->regmap, | ||
| 311 | RT286_POWER_CTRL1, 0x1001, 0x0); | ||
| 312 | /* power LDO1 */ | ||
| 313 | regmap_update_bits(rt286->regmap, | ||
| 314 | RT286_POWER_CTRL2, 0x4, 0x4); | ||
| 315 | regmap_write(rt286->regmap, RT286_SET_MIC1, 0x24); | ||
| 316 | regmap_read(rt286->regmap, RT286_CBJ_CTRL2, &val); | ||
| 317 | |||
| 318 | msleep(200); | ||
| 319 | i = 40; | ||
| 320 | while (((val & 0x0800) == 0) && (i > 0)) { | ||
| 321 | regmap_read(rt286->regmap, | ||
| 322 | RT286_CBJ_CTRL2, &val); | ||
| 323 | i--; | ||
| 324 | msleep(20); | ||
| 325 | } | ||
| 326 | |||
| 327 | if (0x0400 == (val & 0x0700)) { | ||
| 328 | *mic = false; | ||
| 329 | |||
| 330 | regmap_write(rt286->regmap, | ||
| 331 | RT286_SET_MIC1, 0x20); | ||
| 332 | /* power off HV,VERF */ | ||
| 333 | regmap_update_bits(rt286->regmap, | ||
| 334 | RT286_POWER_CTRL1, 0x1001, 0x1001); | ||
| 335 | regmap_update_bits(rt286->regmap, | ||
| 336 | RT286_A_BIAS_CTRL3, 0xc000, 0x0000); | ||
| 337 | regmap_update_bits(rt286->regmap, | ||
| 338 | RT286_CBJ_CTRL1, 0x0030, 0x0000); | ||
| 339 | regmap_update_bits(rt286->regmap, | ||
| 340 | RT286_A_BIAS_CTRL2, 0xc000, 0x0000); | ||
| 341 | } else if ((0x0200 == (val & 0x0700)) || | ||
| 342 | (0x0100 == (val & 0x0700))) { | ||
| 343 | *mic = true; | ||
| 344 | regmap_update_bits(rt286->regmap, | ||
| 345 | RT286_A_BIAS_CTRL3, 0xc000, 0x8000); | ||
| 346 | regmap_update_bits(rt286->regmap, | ||
| 347 | RT286_CBJ_CTRL1, 0x0030, 0x0020); | ||
| 348 | regmap_update_bits(rt286->regmap, | ||
| 349 | RT286_A_BIAS_CTRL2, 0xc000, 0x8000); | ||
| 350 | } else { | ||
| 351 | *mic = false; | ||
| 352 | } | ||
| 353 | |||
| 354 | regmap_update_bits(rt286->regmap, | ||
| 355 | RT286_MISC_CTRL1, | ||
| 356 | 0x0060, 0x0000); | ||
| 357 | } else { | ||
| 358 | regmap_update_bits(rt286->regmap, | ||
| 359 | RT286_MISC_CTRL1, | ||
| 360 | 0x0060, 0x0020); | ||
| 361 | regmap_update_bits(rt286->regmap, | ||
| 362 | RT286_A_BIAS_CTRL3, | ||
| 363 | 0xc000, 0x8000); | ||
| 364 | regmap_update_bits(rt286->regmap, | ||
| 365 | RT286_CBJ_CTRL1, | ||
| 366 | 0x0030, 0x0020); | ||
| 367 | regmap_update_bits(rt286->regmap, | ||
| 368 | RT286_A_BIAS_CTRL2, | ||
| 369 | 0xc000, 0x8000); | ||
| 370 | |||
| 371 | *mic = false; | ||
| 372 | } | ||
| 373 | } else { | ||
| 374 | regmap_read(rt286->regmap, RT286_GET_HP_SENSE, &buf); | ||
| 375 | *hp = buf & 0x80000000; | ||
| 376 | regmap_read(rt286->regmap, RT286_GET_MIC1_SENSE, &buf); | ||
| 377 | *mic = buf & 0x80000000; | ||
| 378 | } | ||
| 379 | |||
| 380 | return 0; | ||
| 381 | } | ||
| 382 | |||
| 383 | static void rt286_jack_detect_work(struct work_struct *work) | ||
| 384 | { | ||
| 385 | struct rt286_priv *rt286 = | ||
| 386 | container_of(work, struct rt286_priv, jack_detect_work.work); | ||
| 387 | int status = 0; | ||
| 388 | bool hp = false; | ||
| 389 | bool mic = false; | ||
| 390 | |||
| 391 | rt286_jack_detect(rt286, &hp, &mic); | ||
| 392 | |||
| 393 | if (hp == true) | ||
| 394 | status |= SND_JACK_HEADPHONE; | ||
| 395 | |||
| 396 | if (mic == true) | ||
| 397 | status |= SND_JACK_MICROPHONE; | ||
| 398 | |||
| 399 | snd_soc_jack_report(rt286->jack, status, | ||
| 400 | SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); | ||
| 401 | } | ||
| 402 | |||
| 403 | int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack) | ||
| 404 | { | ||
| 405 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 406 | |||
| 407 | rt286->jack = jack; | ||
| 408 | |||
| 409 | /* Send an initial empty report */ | ||
| 410 | snd_soc_jack_report(rt286->jack, 0, | ||
| 411 | SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); | ||
| 412 | |||
| 413 | return 0; | ||
| 414 | } | ||
| 415 | EXPORT_SYMBOL_GPL(rt286_mic_detect); | ||
| 416 | |||
| 417 | static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -6350, 50, 0); | ||
| 418 | static const DECLARE_TLV_DB_SCALE(mic_vol_tlv, 0, 1000, 0); | ||
| 419 | |||
| 420 | static const struct snd_kcontrol_new rt286_snd_controls[] = { | ||
| 421 | SOC_DOUBLE_R_TLV("DAC0 Playback Volume", RT286_DACL_GAIN, | ||
| 422 | RT286_DACR_GAIN, 0, 0x7f, 0, out_vol_tlv), | ||
| 423 | SOC_DOUBLE_R_TLV("ADC0 Capture Volume", RT286_ADCL_GAIN, | ||
| 424 | RT286_ADCR_GAIN, 0, 0x7f, 0, out_vol_tlv), | ||
| 425 | SOC_SINGLE_TLV("AMIC Volume", RT286_MIC_GAIN, | ||
| 426 | 0, 0x3, 0, mic_vol_tlv), | ||
| 427 | SOC_DOUBLE_R("Speaker Playback Switch", RT286_SPOL_GAIN, | ||
| 428 | RT286_SPOR_GAIN, RT286_MUTE_SFT, 1, 1), | ||
| 429 | }; | ||
| 430 | |||
| 431 | /* Digital Mixer */ | ||
| 432 | static const struct snd_kcontrol_new rt286_front_mix[] = { | ||
| 433 | SOC_DAPM_SINGLE("DAC Switch", RT286_F_DAC_SWITCH, | ||
| 434 | RT286_MUTE_SFT, 1, 1), | ||
| 435 | SOC_DAPM_SINGLE("RECMIX Switch", RT286_F_RECMIX_SWITCH, | ||
| 436 | RT286_MUTE_SFT, 1, 1), | ||
| 437 | }; | ||
| 438 | |||
| 439 | /* Analog Input Mixer */ | ||
| 440 | static const struct snd_kcontrol_new rt286_rec_mix[] = { | ||
| 441 | SOC_DAPM_SINGLE("Mic1 Switch", RT286_REC_MIC_SWITCH, | ||
| 442 | RT286_MUTE_SFT, 1, 1), | ||
| 443 | SOC_DAPM_SINGLE("I2S Switch", RT286_REC_I2S_SWITCH, | ||
| 444 | RT286_MUTE_SFT, 1, 1), | ||
| 445 | SOC_DAPM_SINGLE("Line1 Switch", RT286_REC_LINE_SWITCH, | ||
| 446 | RT286_MUTE_SFT, 1, 1), | ||
| 447 | SOC_DAPM_SINGLE("Beep Switch", RT286_REC_BEEP_SWITCH, | ||
| 448 | RT286_MUTE_SFT, 1, 1), | ||
| 449 | }; | ||
| 450 | |||
| 451 | static const struct snd_kcontrol_new spo_enable_control = | ||
| 452 | SOC_DAPM_SINGLE("Switch", RT286_SET_PIN_SPK, | ||
| 453 | RT286_SET_PIN_SFT, 1, 0); | ||
| 454 | |||
| 455 | static const struct snd_kcontrol_new hpol_enable_control = | ||
| 456 | SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT286_HPOL_GAIN, | ||
| 457 | RT286_MUTE_SFT, 1, 1); | ||
| 458 | |||
| 459 | static const struct snd_kcontrol_new hpor_enable_control = | ||
| 460 | SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT286_HPOR_GAIN, | ||
| 461 | RT286_MUTE_SFT, 1, 1); | ||
| 462 | |||
| 463 | /* ADC0 source */ | ||
| 464 | static const char * const rt286_adc_src[] = { | ||
| 465 | "Mic", "RECMIX", "Dmic" | ||
| 466 | }; | ||
| 467 | |||
| 468 | static const int rt286_adc_values[] = { | ||
| 469 | 0, 4, 5, | ||
| 470 | }; | ||
| 471 | |||
| 472 | static SOC_VALUE_ENUM_SINGLE_DECL( | ||
| 473 | rt286_adc0_enum, RT286_ADC0_MUX, RT286_ADC_SEL_SFT, | ||
| 474 | RT286_ADC_SEL_MASK, rt286_adc_src, rt286_adc_values); | ||
| 475 | |||
| 476 | static const struct snd_kcontrol_new rt286_adc0_mux = | ||
| 477 | SOC_DAPM_ENUM("ADC 0 source", rt286_adc0_enum); | ||
| 478 | |||
| 479 | static SOC_VALUE_ENUM_SINGLE_DECL( | ||
| 480 | rt286_adc1_enum, RT286_ADC1_MUX, RT286_ADC_SEL_SFT, | ||
| 481 | RT286_ADC_SEL_MASK, rt286_adc_src, rt286_adc_values); | ||
| 482 | |||
| 483 | static const struct snd_kcontrol_new rt286_adc1_mux = | ||
| 484 | SOC_DAPM_ENUM("ADC 1 source", rt286_adc1_enum); | ||
| 485 | |||
| 486 | static const char * const rt286_dac_src[] = { | ||
| 487 | "Front", "Surround" | ||
| 488 | }; | ||
| 489 | /* HP-OUT source */ | ||
| 490 | static SOC_ENUM_SINGLE_DECL(rt286_hpo_enum, RT286_HPO_MUX, | ||
| 491 | 0, rt286_dac_src); | ||
| 492 | |||
| 493 | static const struct snd_kcontrol_new rt286_hpo_mux = | ||
| 494 | SOC_DAPM_ENUM("HPO source", rt286_hpo_enum); | ||
| 495 | |||
| 496 | /* SPK-OUT source */ | ||
| 497 | static SOC_ENUM_SINGLE_DECL(rt286_spo_enum, RT286_SPK_MUX, | ||
| 498 | 0, rt286_dac_src); | ||
| 499 | |||
| 500 | static const struct snd_kcontrol_new rt286_spo_mux = | ||
| 501 | SOC_DAPM_ENUM("SPO source", rt286_spo_enum); | ||
| 502 | |||
| 503 | static int rt286_spk_event(struct snd_soc_dapm_widget *w, | ||
| 504 | struct snd_kcontrol *kcontrol, int event) | ||
| 505 | { | ||
| 506 | struct snd_soc_codec *codec = w->codec; | ||
| 507 | |||
| 508 | switch (event) { | ||
| 509 | case SND_SOC_DAPM_POST_PMU: | ||
| 510 | snd_soc_write(codec, | ||
| 511 | RT286_SPK_EAPD, RT286_SET_EAPD_HIGH); | ||
| 512 | break; | ||
| 513 | case SND_SOC_DAPM_PRE_PMD: | ||
| 514 | snd_soc_write(codec, | ||
| 515 | RT286_SPK_EAPD, RT286_SET_EAPD_LOW); | ||
| 516 | break; | ||
| 517 | |||
| 518 | default: | ||
| 519 | return 0; | ||
| 520 | } | ||
| 521 | |||
| 522 | return 0; | ||
| 523 | } | ||
| 524 | |||
| 525 | static int rt286_set_dmic1_event(struct snd_soc_dapm_widget *w, | ||
| 526 | struct snd_kcontrol *kcontrol, int event) | ||
| 527 | { | ||
| 528 | struct snd_soc_codec *codec = w->codec; | ||
| 529 | |||
| 530 | switch (event) { | ||
| 531 | case SND_SOC_DAPM_POST_PMU: | ||
| 532 | snd_soc_write(codec, RT286_SET_PIN_DMIC1, 0x20); | ||
| 533 | break; | ||
| 534 | case SND_SOC_DAPM_PRE_PMD: | ||
| 535 | snd_soc_write(codec, RT286_SET_PIN_DMIC1, 0); | ||
| 536 | break; | ||
| 537 | default: | ||
| 538 | return 0; | ||
| 539 | } | ||
| 540 | |||
| 541 | return 0; | ||
| 542 | } | ||
| 543 | |||
| 544 | static int rt286_adc_event(struct snd_soc_dapm_widget *w, | ||
| 545 | struct snd_kcontrol *kcontrol, int event) | ||
| 546 | { | ||
| 547 | struct snd_soc_codec *codec = w->codec; | ||
| 548 | unsigned int nid; | ||
| 549 | |||
| 550 | nid = (w->reg >> 20) & 0xff; | ||
| 551 | |||
| 552 | switch (event) { | ||
| 553 | case SND_SOC_DAPM_POST_PMU: | ||
| 554 | snd_soc_update_bits(codec, | ||
| 555 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), | ||
| 556 | 0x7080, 0x7000); | ||
| 557 | break; | ||
| 558 | case SND_SOC_DAPM_PRE_PMD: | ||
| 559 | snd_soc_update_bits(codec, | ||
| 560 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, nid, 0), | ||
| 561 | 0x7080, 0x7080); | ||
| 562 | break; | ||
| 563 | default: | ||
| 564 | return 0; | ||
| 565 | } | ||
| 566 | |||
| 567 | return 0; | ||
| 568 | } | ||
| 569 | |||
| 570 | static const struct snd_soc_dapm_widget rt286_dapm_widgets[] = { | ||
| 571 | /* Input Lines */ | ||
| 572 | SND_SOC_DAPM_INPUT("DMIC1 Pin"), | ||
| 573 | SND_SOC_DAPM_INPUT("DMIC2 Pin"), | ||
| 574 | SND_SOC_DAPM_INPUT("MIC1"), | ||
| 575 | SND_SOC_DAPM_INPUT("LINE1"), | ||
| 576 | SND_SOC_DAPM_INPUT("Beep"), | ||
| 577 | |||
| 578 | /* DMIC */ | ||
| 579 | SND_SOC_DAPM_PGA_E("DMIC1", RT286_SET_POWER(RT286_DMIC1), 0, 1, | ||
| 580 | NULL, 0, rt286_set_dmic1_event, | ||
| 581 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
| 582 | SND_SOC_DAPM_PGA("DMIC2", RT286_SET_POWER(RT286_DMIC2), 0, 1, | ||
| 583 | NULL, 0), | ||
| 584 | SND_SOC_DAPM_SUPPLY("DMIC Receiver", SND_SOC_NOPM, | ||
| 585 | 0, 0, NULL, 0), | ||
| 586 | |||
| 587 | /* REC Mixer */ | ||
| 588 | SND_SOC_DAPM_MIXER("RECMIX", SND_SOC_NOPM, 0, 0, | ||
| 589 | rt286_rec_mix, ARRAY_SIZE(rt286_rec_mix)), | ||
| 590 | |||
| 591 | /* ADCs */ | ||
| 592 | SND_SOC_DAPM_ADC("ADC 0", NULL, SND_SOC_NOPM, 0, 0), | ||
| 593 | SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0), | ||
| 594 | |||
| 595 | /* ADC Mux */ | ||
| 596 | SND_SOC_DAPM_MUX_E("ADC 0 Mux", RT286_SET_POWER(RT286_ADC_IN1), 0, 1, | ||
| 597 | &rt286_adc0_mux, rt286_adc_event, SND_SOC_DAPM_PRE_PMD | | ||
| 598 | SND_SOC_DAPM_POST_PMU), | ||
| 599 | SND_SOC_DAPM_MUX_E("ADC 1 Mux", RT286_SET_POWER(RT286_ADC_IN2), 0, 1, | ||
| 600 | &rt286_adc1_mux, rt286_adc_event, SND_SOC_DAPM_PRE_PMD | | ||
| 601 | SND_SOC_DAPM_POST_PMU), | ||
| 602 | |||
| 603 | /* Audio Interface */ | ||
| 604 | SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
| 605 | SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
| 606 | SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
| 607 | SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
| 608 | |||
| 609 | /* Output Side */ | ||
| 610 | /* DACs */ | ||
| 611 | SND_SOC_DAPM_DAC("DAC 0", NULL, SND_SOC_NOPM, 0, 0), | ||
| 612 | SND_SOC_DAPM_DAC("DAC 1", NULL, SND_SOC_NOPM, 0, 0), | ||
| 613 | |||
| 614 | /* Output Mux */ | ||
| 615 | SND_SOC_DAPM_MUX("SPK Mux", SND_SOC_NOPM, 0, 0, &rt286_spo_mux), | ||
| 616 | SND_SOC_DAPM_MUX("HPO Mux", SND_SOC_NOPM, 0, 0, &rt286_hpo_mux), | ||
| 617 | |||
| 618 | SND_SOC_DAPM_SUPPLY("HP Power", RT286_SET_PIN_HPO, | ||
| 619 | RT286_SET_PIN_SFT, 0, NULL, 0), | ||
| 620 | |||
| 621 | /* Output Mixer */ | ||
| 622 | SND_SOC_DAPM_MIXER("Front", RT286_SET_POWER(RT286_DAC_OUT1), 0, 1, | ||
| 623 | rt286_front_mix, ARRAY_SIZE(rt286_front_mix)), | ||
| 624 | SND_SOC_DAPM_PGA("Surround", RT286_SET_POWER(RT286_DAC_OUT2), 0, 1, | ||
| 625 | NULL, 0), | ||
| 626 | |||
| 627 | /* Output Pga */ | ||
| 628 | SND_SOC_DAPM_SWITCH_E("SPO", SND_SOC_NOPM, 0, 0, | ||
| 629 | &spo_enable_control, rt286_spk_event, | ||
| 630 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
| 631 | SND_SOC_DAPM_SWITCH("HPO L", SND_SOC_NOPM, 0, 0, | ||
| 632 | &hpol_enable_control), | ||
| 633 | SND_SOC_DAPM_SWITCH("HPO R", SND_SOC_NOPM, 0, 0, | ||
| 634 | &hpor_enable_control), | ||
| 635 | |||
| 636 | /* Output Lines */ | ||
| 637 | SND_SOC_DAPM_OUTPUT("SPOL"), | ||
| 638 | SND_SOC_DAPM_OUTPUT("SPOR"), | ||
| 639 | SND_SOC_DAPM_OUTPUT("HPO Pin"), | ||
| 640 | SND_SOC_DAPM_OUTPUT("SPDIF"), | ||
| 641 | }; | ||
| 642 | |||
| 643 | static const struct snd_soc_dapm_route rt286_dapm_routes[] = { | ||
| 644 | {"DMIC1", NULL, "DMIC1 Pin"}, | ||
| 645 | {"DMIC2", NULL, "DMIC2 Pin"}, | ||
| 646 | {"DMIC1", NULL, "DMIC Receiver"}, | ||
| 647 | {"DMIC2", NULL, "DMIC Receiver"}, | ||
| 648 | |||
| 649 | {"RECMIX", "Beep Switch", "Beep"}, | ||
| 650 | {"RECMIX", "Line1 Switch", "LINE1"}, | ||
| 651 | {"RECMIX", "Mic1 Switch", "MIC1"}, | ||
| 652 | |||
| 653 | {"ADC 0 Mux", "Dmic", "DMIC1"}, | ||
| 654 | {"ADC 0 Mux", "RECMIX", "RECMIX"}, | ||
| 655 | {"ADC 0 Mux", "Mic", "MIC1"}, | ||
| 656 | {"ADC 1 Mux", "Dmic", "DMIC2"}, | ||
| 657 | {"ADC 1 Mux", "RECMIX", "RECMIX"}, | ||
| 658 | {"ADC 1 Mux", "Mic", "MIC1"}, | ||
| 659 | |||
| 660 | {"ADC 0", NULL, "ADC 0 Mux"}, | ||
| 661 | {"ADC 1", NULL, "ADC 1 Mux"}, | ||
| 662 | |||
| 663 | {"AIF1TX", NULL, "ADC 0"}, | ||
| 664 | {"AIF2TX", NULL, "ADC 1"}, | ||
| 665 | |||
| 666 | {"DAC 0", NULL, "AIF1RX"}, | ||
| 667 | {"DAC 1", NULL, "AIF2RX"}, | ||
| 668 | |||
| 669 | {"Front", "DAC Switch", "DAC 0"}, | ||
| 670 | {"Front", "RECMIX Switch", "RECMIX"}, | ||
| 671 | |||
| 672 | {"Surround", NULL, "DAC 1"}, | ||
| 673 | |||
| 674 | {"SPK Mux", "Front", "Front"}, | ||
| 675 | {"SPK Mux", "Surround", "Surround"}, | ||
| 676 | |||
| 677 | {"HPO Mux", "Front", "Front"}, | ||
| 678 | {"HPO Mux", "Surround", "Surround"}, | ||
| 679 | |||
| 680 | {"SPO", "Switch", "SPK Mux"}, | ||
| 681 | {"HPO L", "Switch", "HPO Mux"}, | ||
| 682 | {"HPO R", "Switch", "HPO Mux"}, | ||
| 683 | {"HPO L", NULL, "HP Power"}, | ||
| 684 | {"HPO R", NULL, "HP Power"}, | ||
| 685 | |||
| 686 | {"SPOL", NULL, "SPO"}, | ||
| 687 | {"SPOR", NULL, "SPO"}, | ||
| 688 | {"HPO Pin", NULL, "HPO L"}, | ||
| 689 | {"HPO Pin", NULL, "HPO R"}, | ||
| 690 | }; | ||
| 691 | |||
| 692 | static int rt286_hw_params(struct snd_pcm_substream *substream, | ||
| 693 | struct snd_pcm_hw_params *params, | ||
| 694 | struct snd_soc_dai *dai) | ||
| 695 | { | ||
| 696 | struct snd_soc_codec *codec = dai->codec; | ||
| 697 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 698 | unsigned int val = 0; | ||
| 699 | int d_len_code; | ||
| 700 | |||
| 701 | switch (params_rate(params)) { | ||
| 702 | /* bit 14 0:48K 1:44.1K */ | ||
| 703 | case 44100: | ||
| 704 | val |= 0x4000; | ||
| 705 | break; | ||
| 706 | case 48000: | ||
| 707 | break; | ||
| 708 | default: | ||
| 709 | dev_err(codec->dev, "Unsupported sample rate %d\n", | ||
| 710 | params_rate(params)); | ||
| 711 | return -EINVAL; | ||
| 712 | } | ||
| 713 | switch (rt286->sys_clk) { | ||
| 714 | case 12288000: | ||
| 715 | case 24576000: | ||
| 716 | if (params_rate(params) != 48000) { | ||
| 717 | dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", | ||
| 718 | params_rate(params), rt286->sys_clk); | ||
| 719 | return -EINVAL; | ||
| 720 | } | ||
| 721 | break; | ||
| 722 | case 11289600: | ||
| 723 | case 22579200: | ||
| 724 | if (params_rate(params) != 44100) { | ||
| 725 | dev_err(codec->dev, "Sys_clk is not matched (%d %d)\n", | ||
| 726 | params_rate(params), rt286->sys_clk); | ||
| 727 | return -EINVAL; | ||
| 728 | } | ||
| 729 | break; | ||
| 730 | } | ||
| 731 | |||
| 732 | if (params_channels(params) <= 16) { | ||
| 733 | /* bit 3:0 Number of Channel */ | ||
| 734 | val |= (params_channels(params) - 1); | ||
| 735 | } else { | ||
| 736 | dev_err(codec->dev, "Unsupported channels %d\n", | ||
| 737 | params_channels(params)); | ||
| 738 | return -EINVAL; | ||
| 739 | } | ||
| 740 | |||
| 741 | d_len_code = 0; | ||
| 742 | switch (params_width(params)) { | ||
| 743 | /* bit 6:4 Bits per Sample */ | ||
| 744 | case 16: | ||
| 745 | d_len_code = 0; | ||
| 746 | val |= (0x1 << 4); | ||
| 747 | break; | ||
| 748 | case 32: | ||
| 749 | d_len_code = 2; | ||
| 750 | val |= (0x4 << 4); | ||
| 751 | break; | ||
| 752 | case 20: | ||
| 753 | d_len_code = 1; | ||
| 754 | val |= (0x2 << 4); | ||
| 755 | break; | ||
| 756 | case 24: | ||
| 757 | d_len_code = 2; | ||
| 758 | val |= (0x3 << 4); | ||
| 759 | break; | ||
| 760 | case 8: | ||
| 761 | d_len_code = 3; | ||
| 762 | break; | ||
| 763 | default: | ||
| 764 | return -EINVAL; | ||
| 765 | } | ||
| 766 | |||
| 767 | snd_soc_update_bits(codec, | ||
| 768 | RT286_I2S_CTRL1, 0x0018, d_len_code << 3); | ||
| 769 | dev_dbg(codec->dev, "format val = 0x%x\n", val); | ||
| 770 | |||
| 771 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 772 | snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x407f, val); | ||
| 773 | else | ||
| 774 | snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x407f, val); | ||
| 775 | |||
| 776 | return 0; | ||
| 777 | } | ||
| 778 | |||
| 779 | static int rt286_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | ||
| 780 | { | ||
| 781 | struct snd_soc_codec *codec = dai->codec; | ||
| 782 | |||
| 783 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
| 784 | case SND_SOC_DAIFMT_CBM_CFM: | ||
| 785 | snd_soc_update_bits(codec, | ||
| 786 | RT286_I2S_CTRL1, 0x800, 0x800); | ||
| 787 | break; | ||
| 788 | case SND_SOC_DAIFMT_CBS_CFS: | ||
| 789 | snd_soc_update_bits(codec, | ||
| 790 | RT286_I2S_CTRL1, 0x800, 0x0); | ||
| 791 | break; | ||
| 792 | default: | ||
| 793 | return -EINVAL; | ||
| 794 | } | ||
| 795 | |||
| 796 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 797 | case SND_SOC_DAIFMT_I2S: | ||
| 798 | snd_soc_update_bits(codec, | ||
| 799 | RT286_I2S_CTRL1, 0x300, 0x0); | ||
| 800 | break; | ||
| 801 | case SND_SOC_DAIFMT_LEFT_J: | ||
| 802 | snd_soc_update_bits(codec, | ||
| 803 | RT286_I2S_CTRL1, 0x300, 0x1 << 8); | ||
| 804 | break; | ||
| 805 | case SND_SOC_DAIFMT_DSP_A: | ||
| 806 | snd_soc_update_bits(codec, | ||
| 807 | RT286_I2S_CTRL1, 0x300, 0x2 << 8); | ||
| 808 | break; | ||
| 809 | case SND_SOC_DAIFMT_DSP_B: | ||
| 810 | snd_soc_update_bits(codec, | ||
| 811 | RT286_I2S_CTRL1, 0x300, 0x3 << 8); | ||
| 812 | break; | ||
| 813 | default: | ||
| 814 | return -EINVAL; | ||
| 815 | } | ||
| 816 | /* bit 15 Stream Type 0:PCM 1:Non-PCM */ | ||
| 817 | snd_soc_update_bits(codec, RT286_DAC_FORMAT, 0x8000, 0); | ||
| 818 | snd_soc_update_bits(codec, RT286_ADC_FORMAT, 0x8000, 0); | ||
| 819 | |||
| 820 | return 0; | ||
| 821 | } | ||
| 822 | |||
| 823 | static int rt286_set_dai_sysclk(struct snd_soc_dai *dai, | ||
| 824 | int clk_id, unsigned int freq, int dir) | ||
| 825 | { | ||
| 826 | struct snd_soc_codec *codec = dai->codec; | ||
| 827 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 828 | |||
| 829 | dev_dbg(codec->dev, "%s freq=%d\n", __func__, freq); | ||
| 830 | |||
| 831 | if (RT286_SCLK_S_MCLK == clk_id) { | ||
| 832 | snd_soc_update_bits(codec, | ||
| 833 | RT286_I2S_CTRL2, 0x0100, 0x0); | ||
| 834 | snd_soc_update_bits(codec, | ||
| 835 | RT286_PLL_CTRL1, 0x20, 0x20); | ||
| 836 | } else { | ||
| 837 | snd_soc_update_bits(codec, | ||
| 838 | RT286_I2S_CTRL2, 0x0100, 0x0100); | ||
| 839 | snd_soc_update_bits(codec, | ||
| 840 | RT286_PLL_CTRL, 0x4, 0x4); | ||
| 841 | snd_soc_update_bits(codec, | ||
| 842 | RT286_PLL_CTRL1, 0x20, 0x0); | ||
| 843 | } | ||
| 844 | |||
| 845 | switch (freq) { | ||
| 846 | case 19200000: | ||
| 847 | if (RT286_SCLK_S_MCLK == clk_id) { | ||
| 848 | dev_err(codec->dev, "Should not use MCLK\n"); | ||
| 849 | return -EINVAL; | ||
| 850 | } | ||
| 851 | snd_soc_update_bits(codec, | ||
| 852 | RT286_I2S_CTRL2, 0x40, 0x40); | ||
| 853 | break; | ||
| 854 | case 24000000: | ||
| 855 | if (RT286_SCLK_S_MCLK == clk_id) { | ||
| 856 | dev_err(codec->dev, "Should not use MCLK\n"); | ||
| 857 | return -EINVAL; | ||
| 858 | } | ||
| 859 | snd_soc_update_bits(codec, | ||
| 860 | RT286_I2S_CTRL2, 0x40, 0x0); | ||
| 861 | break; | ||
| 862 | case 12288000: | ||
| 863 | case 11289600: | ||
| 864 | snd_soc_update_bits(codec, | ||
| 865 | RT286_I2S_CTRL2, 0x8, 0x0); | ||
| 866 | snd_soc_update_bits(codec, | ||
| 867 | RT286_CLK_DIV, 0xfc1e, 0x0004); | ||
| 868 | break; | ||
| 869 | case 24576000: | ||
| 870 | case 22579200: | ||
| 871 | snd_soc_update_bits(codec, | ||
| 872 | RT286_I2S_CTRL2, 0x8, 0x8); | ||
| 873 | snd_soc_update_bits(codec, | ||
| 874 | RT286_CLK_DIV, 0xfc1e, 0x5406); | ||
| 875 | break; | ||
| 876 | default: | ||
| 877 | dev_err(codec->dev, "Unsupported system clock\n"); | ||
| 878 | return -EINVAL; | ||
| 879 | } | ||
| 880 | |||
| 881 | rt286->sys_clk = freq; | ||
| 882 | |||
| 883 | return 0; | ||
| 884 | } | ||
| 885 | |||
| 886 | static int rt286_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) | ||
| 887 | { | ||
| 888 | struct snd_soc_codec *codec = dai->codec; | ||
| 889 | |||
| 890 | dev_dbg(codec->dev, "%s ratio=%d\n", __func__, ratio); | ||
| 891 | if (50 == ratio) | ||
| 892 | snd_soc_update_bits(codec, | ||
| 893 | RT286_I2S_CTRL1, 0x1000, 0x1000); | ||
| 894 | else | ||
| 895 | snd_soc_update_bits(codec, | ||
| 896 | RT286_I2S_CTRL1, 0x1000, 0x0); | ||
| 897 | |||
| 898 | |||
| 899 | return 0; | ||
| 900 | } | ||
| 901 | |||
| 902 | static int rt286_set_bias_level(struct snd_soc_codec *codec, | ||
| 903 | enum snd_soc_bias_level level) | ||
| 904 | { | ||
| 905 | switch (level) { | ||
| 906 | case SND_SOC_BIAS_PREPARE: | ||
| 907 | if (SND_SOC_BIAS_STANDBY == codec->dapm.bias_level) { | ||
| 908 | snd_soc_write(codec, | ||
| 909 | RT286_SET_AUDIO_POWER, AC_PWRST_D0); | ||
| 910 | snd_soc_update_bits(codec, | ||
| 911 | RT286_DC_GAIN, 0x200, 0x200); | ||
| 912 | } | ||
| 913 | break; | ||
| 914 | |||
| 915 | case SND_SOC_BIAS_ON: | ||
| 916 | mdelay(10); | ||
| 917 | break; | ||
| 918 | |||
| 919 | case SND_SOC_BIAS_STANDBY: | ||
| 920 | snd_soc_write(codec, | ||
| 921 | RT286_SET_AUDIO_POWER, AC_PWRST_D3); | ||
| 922 | snd_soc_update_bits(codec, | ||
| 923 | RT286_DC_GAIN, 0x200, 0x0); | ||
| 924 | break; | ||
| 925 | |||
| 926 | default: | ||
| 927 | break; | ||
| 928 | } | ||
| 929 | codec->dapm.bias_level = level; | ||
| 930 | |||
| 931 | return 0; | ||
| 932 | } | ||
| 933 | |||
| 934 | static irqreturn_t rt286_irq(int irq, void *data) | ||
| 935 | { | ||
| 936 | struct rt286_priv *rt286 = data; | ||
| 937 | bool hp = false; | ||
| 938 | bool mic = false; | ||
| 939 | int status = 0; | ||
| 940 | |||
| 941 | rt286_jack_detect(rt286, &hp, &mic); | ||
| 942 | |||
| 943 | /* Clear IRQ */ | ||
| 944 | regmap_update_bits(rt286->regmap, RT286_IRQ_CTRL, 0x1, 0x1); | ||
| 945 | |||
| 946 | if (hp == true) | ||
| 947 | status |= SND_JACK_HEADPHONE; | ||
| 948 | |||
| 949 | if (mic == true) | ||
| 950 | status |= SND_JACK_MICROPHONE; | ||
| 951 | |||
| 952 | snd_soc_jack_report(rt286->jack, status, | ||
| 953 | SND_JACK_MICROPHONE | SND_JACK_HEADPHONE); | ||
| 954 | |||
| 955 | pm_wakeup_event(&rt286->i2c->dev, 300); | ||
| 956 | |||
| 957 | return IRQ_HANDLED; | ||
| 958 | } | ||
| 959 | |||
| 960 | static int rt286_probe(struct snd_soc_codec *codec) | ||
| 961 | { | ||
| 962 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 963 | |||
| 964 | codec->dapm.bias_level = SND_SOC_BIAS_OFF; | ||
| 965 | |||
| 966 | if (rt286->i2c->irq) { | ||
| 967 | regmap_update_bits(rt286->regmap, | ||
| 968 | RT286_IRQ_CTRL, 0x2, 0x2); | ||
| 969 | |||
| 970 | INIT_DELAYED_WORK(&rt286->jack_detect_work, | ||
| 971 | rt286_jack_detect_work); | ||
| 972 | schedule_delayed_work(&rt286->jack_detect_work, | ||
| 973 | msecs_to_jiffies(1250)); | ||
| 974 | } | ||
| 975 | |||
| 976 | return 0; | ||
| 977 | } | ||
| 978 | |||
| 979 | static int rt286_remove(struct snd_soc_codec *codec) | ||
| 980 | { | ||
| 981 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 982 | |||
| 983 | cancel_delayed_work_sync(&rt286->jack_detect_work); | ||
| 984 | |||
| 985 | return 0; | ||
| 986 | } | ||
| 987 | |||
| 988 | #ifdef CONFIG_PM | ||
| 989 | static int rt286_suspend(struct snd_soc_codec *codec) | ||
| 990 | { | ||
| 991 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 992 | |||
| 993 | regcache_cache_only(rt286->regmap, true); | ||
| 994 | regcache_mark_dirty(rt286->regmap); | ||
| 995 | |||
| 996 | return 0; | ||
| 997 | } | ||
| 998 | |||
| 999 | static int rt286_resume(struct snd_soc_codec *codec) | ||
| 1000 | { | ||
| 1001 | struct rt286_priv *rt286 = snd_soc_codec_get_drvdata(codec); | ||
| 1002 | |||
| 1003 | regcache_cache_only(rt286->regmap, false); | ||
| 1004 | rt286_index_sync(codec); | ||
| 1005 | regcache_sync(rt286->regmap); | ||
| 1006 | |||
| 1007 | return 0; | ||
| 1008 | } | ||
| 1009 | #else | ||
| 1010 | #define rt286_suspend NULL | ||
| 1011 | #define rt286_resume NULL | ||
| 1012 | #endif | ||
| 1013 | |||
| 1014 | #define RT286_STEREO_RATES (SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000) | ||
| 1015 | #define RT286_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ | ||
| 1016 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) | ||
| 1017 | |||
| 1018 | static const struct snd_soc_dai_ops rt286_aif_dai_ops = { | ||
| 1019 | .hw_params = rt286_hw_params, | ||
| 1020 | .set_fmt = rt286_set_dai_fmt, | ||
| 1021 | .set_sysclk = rt286_set_dai_sysclk, | ||
| 1022 | .set_bclk_ratio = rt286_set_bclk_ratio, | ||
| 1023 | }; | ||
| 1024 | |||
| 1025 | static struct snd_soc_dai_driver rt286_dai[] = { | ||
| 1026 | { | ||
| 1027 | .name = "rt286-aif1", | ||
| 1028 | .id = RT286_AIF1, | ||
| 1029 | .playback = { | ||
| 1030 | .stream_name = "AIF1 Playback", | ||
| 1031 | .channels_min = 1, | ||
| 1032 | .channels_max = 2, | ||
| 1033 | .rates = RT286_STEREO_RATES, | ||
| 1034 | .formats = RT286_FORMATS, | ||
| 1035 | }, | ||
| 1036 | .capture = { | ||
| 1037 | .stream_name = "AIF1 Capture", | ||
| 1038 | .channels_min = 1, | ||
| 1039 | .channels_max = 2, | ||
| 1040 | .rates = RT286_STEREO_RATES, | ||
| 1041 | .formats = RT286_FORMATS, | ||
| 1042 | }, | ||
| 1043 | .ops = &rt286_aif_dai_ops, | ||
| 1044 | .symmetric_rates = 1, | ||
| 1045 | }, | ||
| 1046 | { | ||
| 1047 | .name = "rt286-aif2", | ||
| 1048 | .id = RT286_AIF2, | ||
| 1049 | .playback = { | ||
| 1050 | .stream_name = "AIF2 Playback", | ||
| 1051 | .channels_min = 1, | ||
| 1052 | .channels_max = 2, | ||
| 1053 | .rates = RT286_STEREO_RATES, | ||
| 1054 | .formats = RT286_FORMATS, | ||
| 1055 | }, | ||
| 1056 | .capture = { | ||
| 1057 | .stream_name = "AIF2 Capture", | ||
| 1058 | .channels_min = 1, | ||
| 1059 | .channels_max = 2, | ||
| 1060 | .rates = RT286_STEREO_RATES, | ||
| 1061 | .formats = RT286_FORMATS, | ||
| 1062 | }, | ||
| 1063 | .ops = &rt286_aif_dai_ops, | ||
| 1064 | .symmetric_rates = 1, | ||
| 1065 | }, | ||
| 1066 | |||
| 1067 | }; | ||
| 1068 | |||
| 1069 | static struct snd_soc_codec_driver soc_codec_dev_rt286 = { | ||
| 1070 | .probe = rt286_probe, | ||
| 1071 | .remove = rt286_remove, | ||
| 1072 | .suspend = rt286_suspend, | ||
| 1073 | .resume = rt286_resume, | ||
| 1074 | .set_bias_level = rt286_set_bias_level, | ||
| 1075 | .idle_bias_off = true, | ||
| 1076 | .controls = rt286_snd_controls, | ||
| 1077 | .num_controls = ARRAY_SIZE(rt286_snd_controls), | ||
| 1078 | .dapm_widgets = rt286_dapm_widgets, | ||
| 1079 | .num_dapm_widgets = ARRAY_SIZE(rt286_dapm_widgets), | ||
| 1080 | .dapm_routes = rt286_dapm_routes, | ||
| 1081 | .num_dapm_routes = ARRAY_SIZE(rt286_dapm_routes), | ||
| 1082 | }; | ||
| 1083 | |||
| 1084 | static const struct regmap_config rt286_regmap = { | ||
| 1085 | .reg_bits = 32, | ||
| 1086 | .val_bits = 32, | ||
| 1087 | .max_register = 0x02370100, | ||
| 1088 | .volatile_reg = rt286_volatile_register, | ||
| 1089 | .readable_reg = rt286_readable_register, | ||
| 1090 | .reg_write = rt286_hw_write, | ||
| 1091 | .reg_read = rt286_hw_read, | ||
| 1092 | .cache_type = REGCACHE_RBTREE, | ||
| 1093 | .reg_defaults = rt286_reg, | ||
| 1094 | .num_reg_defaults = ARRAY_SIZE(rt286_reg), | ||
| 1095 | }; | ||
| 1096 | |||
| 1097 | static const struct i2c_device_id rt286_i2c_id[] = { | ||
| 1098 | {"rt286", 0}, | ||
| 1099 | {} | ||
| 1100 | }; | ||
| 1101 | MODULE_DEVICE_TABLE(i2c, rt286_i2c_id); | ||
| 1102 | |||
| 1103 | static const struct acpi_device_id rt286_acpi_match[] = { | ||
| 1104 | { "INT343A", 0 }, | ||
| 1105 | {}, | ||
| 1106 | }; | ||
| 1107 | MODULE_DEVICE_TABLE(acpi, rt286_acpi_match); | ||
| 1108 | |||
| 1109 | static int rt286_i2c_probe(struct i2c_client *i2c, | ||
| 1110 | const struct i2c_device_id *id) | ||
| 1111 | { | ||
| 1112 | struct rt286_platform_data *pdata = dev_get_platdata(&i2c->dev); | ||
| 1113 | struct rt286_priv *rt286; | ||
| 1114 | int i, ret; | ||
| 1115 | |||
| 1116 | rt286 = devm_kzalloc(&i2c->dev, sizeof(*rt286), | ||
| 1117 | GFP_KERNEL); | ||
| 1118 | if (NULL == rt286) | ||
| 1119 | return -ENOMEM; | ||
| 1120 | |||
| 1121 | rt286->regmap = devm_regmap_init(&i2c->dev, NULL, i2c, &rt286_regmap); | ||
| 1122 | if (IS_ERR(rt286->regmap)) { | ||
| 1123 | ret = PTR_ERR(rt286->regmap); | ||
| 1124 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | ||
| 1125 | ret); | ||
| 1126 | return ret; | ||
| 1127 | } | ||
| 1128 | |||
| 1129 | regmap_read(rt286->regmap, | ||
| 1130 | RT286_GET_PARAM(AC_NODE_ROOT, AC_PAR_VENDOR_ID), &ret); | ||
| 1131 | if (ret != RT286_VENDOR_ID) { | ||
| 1132 | dev_err(&i2c->dev, | ||
| 1133 | "Device with ID register %x is not rt286\n", ret); | ||
| 1134 | return -ENODEV; | ||
| 1135 | } | ||
| 1136 | |||
| 1137 | rt286->index_cache = rt286_index_def; | ||
| 1138 | rt286->i2c = i2c; | ||
| 1139 | i2c_set_clientdata(i2c, rt286); | ||
| 1140 | |||
| 1141 | if (pdata) | ||
| 1142 | rt286->pdata = *pdata; | ||
| 1143 | |||
| 1144 | regmap_write(rt286->regmap, RT286_SET_AUDIO_POWER, AC_PWRST_D3); | ||
| 1145 | |||
| 1146 | for (i = 0; i < RT286_POWER_REG_LEN; i++) | ||
| 1147 | regmap_write(rt286->regmap, | ||
| 1148 | RT286_SET_POWER(rt286_support_power_controls[i]), | ||
| 1149 | AC_PWRST_D1); | ||
| 1150 | |||
| 1151 | if (!rt286->pdata.cbj_en) { | ||
| 1152 | regmap_write(rt286->regmap, RT286_CBJ_CTRL2, 0x0000); | ||
| 1153 | regmap_write(rt286->regmap, RT286_MIC1_DET_CTRL, 0x0816); | ||
| 1154 | regmap_write(rt286->regmap, RT286_MISC_CTRL1, 0x0000); | ||
| 1155 | regmap_update_bits(rt286->regmap, | ||
| 1156 | RT286_CBJ_CTRL1, 0xf000, 0xb000); | ||
| 1157 | } else { | ||
| 1158 | regmap_update_bits(rt286->regmap, | ||
| 1159 | RT286_CBJ_CTRL1, 0xf000, 0x5000); | ||
| 1160 | } | ||
| 1161 | |||
| 1162 | mdelay(10); | ||
| 1163 | |||
| 1164 | if (!rt286->pdata.gpio2_en) | ||
| 1165 | regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0x4000); | ||
| 1166 | else | ||
| 1167 | regmap_write(rt286->regmap, RT286_SET_DMIC2_DEFAULT, 0); | ||
| 1168 | |||
| 1169 | mdelay(10); | ||
| 1170 | |||
| 1171 | /*Power down LDO2*/ | ||
| 1172 | regmap_update_bits(rt286->regmap, RT286_POWER_CTRL2, 0x8, 0x0); | ||
| 1173 | |||
| 1174 | /*Set depop parameter*/ | ||
| 1175 | regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL2, 0x403a, 0x401a); | ||
| 1176 | regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL3, 0xf777, 0x4737); | ||
| 1177 | regmap_update_bits(rt286->regmap, RT286_DEPOP_CTRL4, 0x00ff, 0x003f); | ||
| 1178 | |||
| 1179 | if (rt286->i2c->irq) { | ||
| 1180 | ret = request_threaded_irq(rt286->i2c->irq, NULL, rt286_irq, | ||
| 1181 | IRQF_TRIGGER_HIGH | IRQF_ONESHOT, "rt286", rt286); | ||
| 1182 | if (ret != 0) { | ||
| 1183 | dev_err(&i2c->dev, | ||
| 1184 | "Failed to reguest IRQ: %d\n", ret); | ||
| 1185 | return ret; | ||
| 1186 | } | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt286, | ||
| 1190 | rt286_dai, ARRAY_SIZE(rt286_dai)); | ||
| 1191 | |||
| 1192 | return ret; | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | static int rt286_i2c_remove(struct i2c_client *i2c) | ||
| 1196 | { | ||
| 1197 | struct rt286_priv *rt286 = i2c_get_clientdata(i2c); | ||
| 1198 | |||
| 1199 | if (i2c->irq) | ||
| 1200 | free_irq(i2c->irq, rt286); | ||
| 1201 | snd_soc_unregister_codec(&i2c->dev); | ||
| 1202 | |||
| 1203 | return 0; | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | |||
| 1207 | static struct i2c_driver rt286_i2c_driver = { | ||
| 1208 | .driver = { | ||
| 1209 | .name = "rt286", | ||
| 1210 | .owner = THIS_MODULE, | ||
| 1211 | .acpi_match_table = ACPI_PTR(rt286_acpi_match), | ||
| 1212 | }, | ||
| 1213 | .probe = rt286_i2c_probe, | ||
| 1214 | .remove = rt286_i2c_remove, | ||
| 1215 | .id_table = rt286_i2c_id, | ||
| 1216 | }; | ||
| 1217 | |||
| 1218 | module_i2c_driver(rt286_i2c_driver); | ||
| 1219 | |||
| 1220 | MODULE_DESCRIPTION("ASoC RT286 driver"); | ||
| 1221 | MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>"); | ||
| 1222 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/rt286.h b/sound/soc/codecs/rt286.h new file mode 100644 index 000000000000..b539b7320a79 --- /dev/null +++ b/sound/soc/codecs/rt286.h | |||
| @@ -0,0 +1,198 @@ | |||
| 1 | /* | ||
| 2 | * rt286.h -- RT286 ALSA SoC audio driver | ||
| 3 | * | ||
| 4 | * Copyright 2011 Realtek Microelectronics | ||
| 5 | * Author: Johnny Hsu <johnnyhsu@realtek.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef __RT286_H__ | ||
| 13 | #define __RT286_H__ | ||
| 14 | |||
| 15 | #define VERB_CMD(V, N, D) ((N << 20) | (V << 8) | D) | ||
| 16 | |||
| 17 | #define RT286_AUDIO_FUNCTION_GROUP 0x01 | ||
| 18 | #define RT286_DAC_OUT1 0x02 | ||
| 19 | #define RT286_DAC_OUT2 0x03 | ||
| 20 | #define RT286_ADC_IN1 0x09 | ||
| 21 | #define RT286_ADC_IN2 0x08 | ||
| 22 | #define RT286_MIXER_IN 0x0b | ||
| 23 | #define RT286_MIXER_OUT1 0x0c | ||
| 24 | #define RT286_MIXER_OUT2 0x0d | ||
| 25 | #define RT286_DMIC1 0x12 | ||
| 26 | #define RT286_DMIC2 0x13 | ||
| 27 | #define RT286_SPK_OUT 0x14 | ||
| 28 | #define RT286_MIC1 0x18 | ||
| 29 | #define RT286_LINE1 0x1a | ||
| 30 | #define RT286_BEEP 0x1d | ||
| 31 | #define RT286_SPDIF 0x1e | ||
| 32 | #define RT286_VENDOR_REGISTERS 0x20 | ||
| 33 | #define RT286_HP_OUT 0x21 | ||
| 34 | #define RT286_MIXER_IN1 0x22 | ||
| 35 | #define RT286_MIXER_IN2 0x23 | ||
| 36 | |||
| 37 | #define RT286_SET_PIN_SFT 6 | ||
| 38 | #define RT286_SET_PIN_ENABLE 0x40 | ||
| 39 | #define RT286_SET_PIN_DISABLE 0 | ||
| 40 | #define RT286_SET_EAPD_HIGH 0x2 | ||
| 41 | #define RT286_SET_EAPD_LOW 0 | ||
| 42 | |||
| 43 | #define RT286_MUTE_SFT 7 | ||
| 44 | |||
| 45 | /* Verb commands */ | ||
| 46 | #define RT286_GET_PARAM(NID, PARAM) VERB_CMD(AC_VERB_PARAMETERS, NID, PARAM) | ||
| 47 | #define RT286_SET_POWER(NID) VERB_CMD(AC_VERB_SET_POWER_STATE, NID, 0) | ||
| 48 | #define RT286_SET_AUDIO_POWER RT286_SET_POWER(RT286_AUDIO_FUNCTION_GROUP) | ||
| 49 | #define RT286_SET_HPO_POWER RT286_SET_POWER(RT286_HP_OUT) | ||
| 50 | #define RT286_SET_SPK_POWER RT286_SET_POWER(RT286_SPK_OUT) | ||
| 51 | #define RT286_SET_DMIC1_POWER RT286_SET_POWER(RT286_DMIC1) | ||
| 52 | #define RT286_SPK_MUX\ | ||
| 53 | VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_SPK_OUT, 0) | ||
| 54 | #define RT286_HPO_MUX\ | ||
| 55 | VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_HP_OUT, 0) | ||
| 56 | #define RT286_ADC0_MUX\ | ||
| 57 | VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_MIXER_IN1, 0) | ||
| 58 | #define RT286_ADC1_MUX\ | ||
| 59 | VERB_CMD(AC_VERB_SET_CONNECT_SEL, RT286_MIXER_IN2, 0) | ||
| 60 | #define RT286_SET_MIC1\ | ||
| 61 | VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_MIC1, 0) | ||
| 62 | #define RT286_SET_PIN_HPO\ | ||
| 63 | VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_HP_OUT, 0) | ||
| 64 | #define RT286_SET_PIN_SPK\ | ||
| 65 | VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_SPK_OUT, 0) | ||
| 66 | #define RT286_SET_PIN_DMIC1\ | ||
| 67 | VERB_CMD(AC_VERB_SET_PIN_WIDGET_CONTROL, RT286_DMIC1, 0) | ||
| 68 | #define RT286_SPK_EAPD\ | ||
| 69 | VERB_CMD(AC_VERB_SET_EAPD_BTLENABLE, RT286_SPK_OUT, 0) | ||
| 70 | #define RT286_SET_AMP_GAIN_HPO\ | ||
| 71 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_HP_OUT, 0) | ||
| 72 | #define RT286_SET_AMP_GAIN_ADC_IN1\ | ||
| 73 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN1, 0) | ||
| 74 | #define RT286_SET_AMP_GAIN_ADC_IN2\ | ||
| 75 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN2, 0) | ||
| 76 | #define RT286_GET_HP_SENSE\ | ||
| 77 | VERB_CMD(AC_VERB_GET_PIN_SENSE, RT286_HP_OUT, 0) | ||
| 78 | #define RT286_GET_MIC1_SENSE\ | ||
| 79 | VERB_CMD(AC_VERB_GET_PIN_SENSE, RT286_MIC1, 0) | ||
| 80 | #define RT286_SET_DMIC2_DEFAULT\ | ||
| 81 | VERB_CMD(AC_VERB_SET_CONFIG_DEFAULT_BYTES_3, RT286_DMIC2, 0) | ||
| 82 | #define RT286_DACL_GAIN\ | ||
| 83 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_DAC_OUT1, 0xa000) | ||
| 84 | #define RT286_DACR_GAIN\ | ||
| 85 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_DAC_OUT1, 0x9000) | ||
| 86 | #define RT286_ADCL_GAIN\ | ||
| 87 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN1, 0x6000) | ||
| 88 | #define RT286_ADCR_GAIN\ | ||
| 89 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_ADC_IN1, 0x5000) | ||
| 90 | #define RT286_MIC_GAIN\ | ||
| 91 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIC1, 0x7000) | ||
| 92 | #define RT286_SPOL_GAIN\ | ||
| 93 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_SPK_OUT, 0xa000) | ||
| 94 | #define RT286_SPOR_GAIN\ | ||
| 95 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_SPK_OUT, 0x9000) | ||
| 96 | #define RT286_HPOL_GAIN\ | ||
| 97 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_HP_OUT, 0xa000) | ||
| 98 | #define RT286_HPOR_GAIN\ | ||
| 99 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_HP_OUT, 0x9000) | ||
| 100 | #define RT286_F_DAC_SWITCH\ | ||
| 101 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_OUT1, 0x7000) | ||
| 102 | #define RT286_F_RECMIX_SWITCH\ | ||
| 103 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_OUT1, 0x7100) | ||
| 104 | #define RT286_REC_MIC_SWITCH\ | ||
| 105 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7000) | ||
| 106 | #define RT286_REC_I2S_SWITCH\ | ||
| 107 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7100) | ||
| 108 | #define RT286_REC_LINE_SWITCH\ | ||
| 109 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7200) | ||
| 110 | #define RT286_REC_BEEP_SWITCH\ | ||
| 111 | VERB_CMD(AC_VERB_SET_AMP_GAIN_MUTE, RT286_MIXER_IN, 0x7300) | ||
| 112 | #define RT286_DAC_FORMAT\ | ||
| 113 | VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT286_DAC_OUT1, 0) | ||
| 114 | #define RT286_ADC_FORMAT\ | ||
| 115 | VERB_CMD(AC_VERB_SET_STREAM_FORMAT, RT286_ADC_IN1, 0) | ||
| 116 | #define RT286_COEF_INDEX\ | ||
| 117 | VERB_CMD(AC_VERB_SET_COEF_INDEX, RT286_VENDOR_REGISTERS, 0) | ||
| 118 | #define RT286_PROC_COEF\ | ||
| 119 | VERB_CMD(AC_VERB_SET_PROC_COEF, RT286_VENDOR_REGISTERS, 0) | ||
| 120 | |||
| 121 | /* Index registers */ | ||
| 122 | #define RT286_A_BIAS_CTRL1 0x01 | ||
| 123 | #define RT286_A_BIAS_CTRL2 0x02 | ||
| 124 | #define RT286_POWER_CTRL1 0x03 | ||
| 125 | #define RT286_A_BIAS_CTRL3 0x04 | ||
| 126 | #define RT286_POWER_CTRL2 0x08 | ||
| 127 | #define RT286_I2S_CTRL1 0x09 | ||
| 128 | #define RT286_I2S_CTRL2 0x0a | ||
| 129 | #define RT286_CLK_DIV 0x0b | ||
| 130 | #define RT286_DC_GAIN 0x0d | ||
| 131 | #define RT286_POWER_CTRL3 0x0f | ||
| 132 | #define RT286_MIC1_DET_CTRL 0x19 | ||
| 133 | #define RT286_MISC_CTRL1 0x20 | ||
| 134 | #define RT286_IRQ_CTRL 0x33 | ||
| 135 | #define RT286_PLL_CTRL1 0x49 | ||
| 136 | #define RT286_CBJ_CTRL1 0x4f | ||
| 137 | #define RT286_CBJ_CTRL2 0x50 | ||
| 138 | #define RT286_PLL_CTRL 0x63 | ||
| 139 | #define RT286_DEPOP_CTRL1 0x66 | ||
| 140 | #define RT286_DEPOP_CTRL2 0x67 | ||
| 141 | #define RT286_DEPOP_CTRL3 0x68 | ||
| 142 | #define RT286_DEPOP_CTRL4 0x69 | ||
| 143 | |||
| 144 | /* SPDIF (0x06) */ | ||
| 145 | #define RT286_SPDIF_SEL_SFT 0 | ||
| 146 | #define RT286_SPDIF_SEL_PCM0 0 | ||
| 147 | #define RT286_SPDIF_SEL_PCM1 1 | ||
| 148 | #define RT286_SPDIF_SEL_SPOUT 2 | ||
| 149 | #define RT286_SPDIF_SEL_PP 3 | ||
| 150 | |||
| 151 | /* RECMIX (0x0b) */ | ||
| 152 | #define RT286_M_REC_BEEP_SFT 0 | ||
| 153 | #define RT286_M_REC_LINE1_SFT 1 | ||
| 154 | #define RT286_M_REC_MIC1_SFT 2 | ||
| 155 | #define RT286_M_REC_I2S_SFT 3 | ||
| 156 | |||
| 157 | /* Front (0x0c) */ | ||
| 158 | #define RT286_M_FRONT_DAC_SFT 0 | ||
| 159 | #define RT286_M_FRONT_REC_SFT 1 | ||
| 160 | |||
| 161 | /* SPK-OUT (0x14) */ | ||
| 162 | #define RT286_M_SPK_MUX_SFT 14 | ||
| 163 | #define RT286_SPK_SEL_MASK 0x1 | ||
| 164 | #define RT286_SPK_SEL_SFT 0 | ||
| 165 | #define RT286_SPK_SEL_F 0 | ||
| 166 | #define RT286_SPK_SEL_S 1 | ||
| 167 | |||
| 168 | /* HP-OUT (0x21) */ | ||
| 169 | #define RT286_M_HP_MUX_SFT 14 | ||
| 170 | #define RT286_HP_SEL_MASK 0x1 | ||
| 171 | #define RT286_HP_SEL_SFT 0 | ||
| 172 | #define RT286_HP_SEL_F 0 | ||
| 173 | #define RT286_HP_SEL_S 1 | ||
| 174 | |||
| 175 | /* ADC (0x22) (0x23) */ | ||
| 176 | #define RT286_ADC_SEL_MASK 0x7 | ||
| 177 | #define RT286_ADC_SEL_SFT 0 | ||
| 178 | #define RT286_ADC_SEL_SURR 0 | ||
| 179 | #define RT286_ADC_SEL_FRONT 1 | ||
| 180 | #define RT286_ADC_SEL_DMIC 2 | ||
| 181 | #define RT286_ADC_SEL_BEEP 4 | ||
| 182 | #define RT286_ADC_SEL_LINE1 5 | ||
| 183 | #define RT286_ADC_SEL_I2S 6 | ||
| 184 | #define RT286_ADC_SEL_MIC1 7 | ||
| 185 | |||
| 186 | #define RT286_SCLK_S_MCLK 0 | ||
| 187 | #define RT286_SCLK_S_PLL 1 | ||
| 188 | |||
| 189 | enum { | ||
| 190 | RT286_AIF1, | ||
| 191 | RT286_AIF2, | ||
| 192 | RT286_AIFS, | ||
| 193 | }; | ||
| 194 | |||
| 195 | int rt286_mic_detect(struct snd_soc_codec *codec, struct snd_soc_jack *jack); | ||
| 196 | |||
| 197 | #endif /* __RT286_H__ */ | ||
| 198 | |||
diff --git a/sound/soc/codecs/rt5631.c b/sound/soc/codecs/rt5631.c index 30e234708579..1ba27db660a6 100644 --- a/sound/soc/codecs/rt5631.c +++ b/sound/soc/codecs/rt5631.c | |||
| @@ -1370,16 +1370,16 @@ static int rt5631_hifi_pcm_params(struct snd_pcm_substream *substream, | |||
| 1370 | return coeff; | 1370 | return coeff; |
| 1371 | } | 1371 | } |
| 1372 | 1372 | ||
| 1373 | switch (params_format(params)) { | 1373 | switch (params_width(params)) { |
| 1374 | case SNDRV_PCM_FORMAT_S16_LE: | 1374 | case 16: |
| 1375 | break; | 1375 | break; |
| 1376 | case SNDRV_PCM_FORMAT_S20_3LE: | 1376 | case 20: |
| 1377 | iface |= RT5631_SDP_I2S_DL_20; | 1377 | iface |= RT5631_SDP_I2S_DL_20; |
| 1378 | break; | 1378 | break; |
| 1379 | case SNDRV_PCM_FORMAT_S24_LE: | 1379 | case 24: |
| 1380 | iface |= RT5631_SDP_I2S_DL_24; | 1380 | iface |= RT5631_SDP_I2S_DL_24; |
| 1381 | break; | 1381 | break; |
| 1382 | case SNDRV_PCM_FORMAT_S8: | 1382 | case 8: |
| 1383 | iface |= RT5631_SDP_I2S_DL_8; | 1383 | iface |= RT5631_SDP_I2S_DL_8; |
| 1384 | break; | 1384 | break; |
| 1385 | default: | 1385 | default: |
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index de80e89b5fd8..6bc6efdec550 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c | |||
| @@ -2215,14 +2215,8 @@ static int rt5640_i2c_probe(struct i2c_client *i2c, | |||
| 2215 | 2215 | ||
| 2216 | rt5640->hp_mute = 1; | 2216 | rt5640->hp_mute = 1; |
| 2217 | 2217 | ||
| 2218 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640, | 2218 | return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5640, |
| 2219 | rt5640_dai, ARRAY_SIZE(rt5640_dai)); | 2219 | rt5640_dai, ARRAY_SIZE(rt5640_dai)); |
| 2220 | if (ret < 0) | ||
| 2221 | goto err; | ||
| 2222 | |||
| 2223 | return 0; | ||
| 2224 | err: | ||
| 2225 | return ret; | ||
| 2226 | } | 2220 | } |
| 2227 | 2221 | ||
| 2228 | static int rt5640_i2c_remove(struct i2c_client *i2c) | 2222 | static int rt5640_i2c_remove(struct i2c_client *i2c) |
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 02147be2b302..a7762d0a623e 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c | |||
| @@ -2345,14 +2345,8 @@ static int rt5645_i2c_probe(struct i2c_client *i2c, | |||
| 2345 | 2345 | ||
| 2346 | } | 2346 | } |
| 2347 | 2347 | ||
| 2348 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5645, | 2348 | return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5645, |
| 2349 | rt5645_dai, ARRAY_SIZE(rt5645_dai)); | 2349 | rt5645_dai, ARRAY_SIZE(rt5645_dai)); |
| 2350 | if (ret < 0) | ||
| 2351 | goto err; | ||
| 2352 | |||
| 2353 | return 0; | ||
| 2354 | err: | ||
| 2355 | return ret; | ||
| 2356 | } | 2350 | } |
| 2357 | 2351 | ||
| 2358 | static int rt5645_i2c_remove(struct i2c_client *i2c) | 2352 | static int rt5645_i2c_remove(struct i2c_client *i2c) |
diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c index ea4b1c652a26..bb0a3ab5416c 100644 --- a/sound/soc/codecs/rt5651.c +++ b/sound/soc/codecs/rt5651.c | |||
| @@ -1366,16 +1366,16 @@ static int rt5651_hw_params(struct snd_pcm_substream *substream, | |||
| 1366 | dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", | 1366 | dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", |
| 1367 | bclk_ms, pre_div, dai->id); | 1367 | bclk_ms, pre_div, dai->id); |
| 1368 | 1368 | ||
| 1369 | switch (params_format(params)) { | 1369 | switch (params_width(params)) { |
| 1370 | case SNDRV_PCM_FORMAT_S16_LE: | 1370 | case 16: |
| 1371 | break; | 1371 | break; |
| 1372 | case SNDRV_PCM_FORMAT_S20_3LE: | 1372 | case 20: |
| 1373 | val_len |= RT5651_I2S_DL_20; | 1373 | val_len |= RT5651_I2S_DL_20; |
| 1374 | break; | 1374 | break; |
| 1375 | case SNDRV_PCM_FORMAT_S24_LE: | 1375 | case 24: |
| 1376 | val_len |= RT5651_I2S_DL_24; | 1376 | val_len |= RT5651_I2S_DL_24; |
| 1377 | break; | 1377 | break; |
| 1378 | case SNDRV_PCM_FORMAT_S8: | 1378 | case 8: |
| 1379 | val_len |= RT5651_I2S_DL_8; | 1379 | val_len |= RT5651_I2S_DL_8; |
| 1380 | break; | 1380 | break; |
| 1381 | default: | 1381 | default: |
diff --git a/sound/soc/codecs/rt5670-dsp.h b/sound/soc/codecs/rt5670-dsp.h new file mode 100644 index 000000000000..a34d0cdb8198 --- /dev/null +++ b/sound/soc/codecs/rt5670-dsp.h | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | /* | ||
| 2 | * rt5670-dsp.h -- RT5670 ALSA SoC DSP driver | ||
| 3 | * | ||
| 4 | * Copyright 2014 Realtek Microelectronics | ||
| 5 | * Author: Bard Liao <bardliao@realtek.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef __RT5670_DSP_H__ | ||
| 13 | #define __RT5670_DSP_H__ | ||
| 14 | |||
| 15 | #define RT5670_DSP_CTRL1 0xe0 | ||
| 16 | #define RT5670_DSP_CTRL2 0xe1 | ||
| 17 | #define RT5670_DSP_CTRL3 0xe2 | ||
| 18 | #define RT5670_DSP_CTRL4 0xe3 | ||
| 19 | #define RT5670_DSP_CTRL5 0xe4 | ||
| 20 | |||
| 21 | /* DSP Control 1 (0xe0) */ | ||
| 22 | #define RT5670_DSP_CMD_MASK (0xff << 8) | ||
| 23 | #define RT5670_DSP_CMD_PE (0x0d << 8) /* Patch Entry */ | ||
| 24 | #define RT5670_DSP_CMD_MW (0x3b << 8) /* Memory Write */ | ||
| 25 | #define RT5670_DSP_CMD_MR (0x37 << 8) /* Memory Read */ | ||
| 26 | #define RT5670_DSP_CMD_RR (0x60 << 8) /* Register Read */ | ||
| 27 | #define RT5670_DSP_CMD_RW (0x68 << 8) /* Register Write */ | ||
| 28 | #define RT5670_DSP_REG_DATHI (0x26 << 8) /* High Data Addr */ | ||
| 29 | #define RT5670_DSP_REG_DATLO (0x25 << 8) /* Low Data Addr */ | ||
| 30 | #define RT5670_DSP_CLK_MASK (0x3 << 6) | ||
| 31 | #define RT5670_DSP_CLK_SFT 6 | ||
| 32 | #define RT5670_DSP_CLK_768K (0x0 << 6) | ||
| 33 | #define RT5670_DSP_CLK_384K (0x1 << 6) | ||
| 34 | #define RT5670_DSP_CLK_192K (0x2 << 6) | ||
| 35 | #define RT5670_DSP_CLK_96K (0x3 << 6) | ||
| 36 | #define RT5670_DSP_BUSY_MASK (0x1 << 5) | ||
| 37 | #define RT5670_DSP_RW_MASK (0x1 << 4) | ||
| 38 | #define RT5670_DSP_DL_MASK (0x3 << 2) | ||
| 39 | #define RT5670_DSP_DL_0 (0x0 << 2) | ||
| 40 | #define RT5670_DSP_DL_1 (0x1 << 2) | ||
| 41 | #define RT5670_DSP_DL_2 (0x2 << 2) | ||
| 42 | #define RT5670_DSP_DL_3 (0x3 << 2) | ||
| 43 | #define RT5670_DSP_I2C_AL_16 (0x1 << 1) | ||
| 44 | #define RT5670_DSP_CMD_EN (0x1) | ||
| 45 | |||
| 46 | struct rt5670_dsp_param { | ||
| 47 | u16 cmd_fmt; | ||
| 48 | u16 addr; | ||
| 49 | u16 data; | ||
| 50 | u8 cmd; | ||
| 51 | }; | ||
| 52 | |||
| 53 | #endif /* __RT5670_DSP_H__ */ | ||
| 54 | |||
diff --git a/sound/soc/codecs/rt5670.c b/sound/soc/codecs/rt5670.c new file mode 100644 index 000000000000..ba9d9b4d4857 --- /dev/null +++ b/sound/soc/codecs/rt5670.c | |||
| @@ -0,0 +1,2657 @@ | |||
| 1 | /* | ||
| 2 | * rt5670.c -- RT5670 ALSA SoC audio codec driver | ||
| 3 | * | ||
| 4 | * Copyright 2014 Realtek Semiconductor Corp. | ||
| 5 | * Author: Bard Liao <bardliao@realtek.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/module.h> | ||
| 13 | #include <linux/moduleparam.h> | ||
| 14 | #include <linux/init.h> | ||
| 15 | #include <linux/delay.h> | ||
| 16 | #include <linux/pm.h> | ||
| 17 | #include <linux/i2c.h> | ||
| 18 | #include <linux/platform_device.h> | ||
| 19 | #include <linux/spi/spi.h> | ||
| 20 | #include <sound/core.h> | ||
| 21 | #include <sound/pcm.h> | ||
| 22 | #include <sound/pcm_params.h> | ||
| 23 | #include <sound/jack.h> | ||
| 24 | #include <sound/soc.h> | ||
| 25 | #include <sound/soc-dapm.h> | ||
| 26 | #include <sound/initval.h> | ||
| 27 | #include <sound/tlv.h> | ||
| 28 | #include <sound/rt5670.h> | ||
| 29 | |||
| 30 | #include "rl6231.h" | ||
| 31 | #include "rt5670.h" | ||
| 32 | #include "rt5670-dsp.h" | ||
| 33 | |||
| 34 | #define RT5670_DEVICE_ID 0x6271 | ||
| 35 | |||
| 36 | #define RT5670_PR_RANGE_BASE (0xff + 1) | ||
| 37 | #define RT5670_PR_SPACING 0x100 | ||
| 38 | |||
| 39 | #define RT5670_PR_BASE (RT5670_PR_RANGE_BASE + (0 * RT5670_PR_SPACING)) | ||
| 40 | |||
| 41 | static const struct regmap_range_cfg rt5670_ranges[] = { | ||
| 42 | { .name = "PR", .range_min = RT5670_PR_BASE, | ||
| 43 | .range_max = RT5670_PR_BASE + 0xf8, | ||
| 44 | .selector_reg = RT5670_PRIV_INDEX, | ||
| 45 | .selector_mask = 0xff, | ||
| 46 | .selector_shift = 0x0, | ||
| 47 | .window_start = RT5670_PRIV_DATA, | ||
| 48 | .window_len = 0x1, }, | ||
| 49 | }; | ||
| 50 | |||
| 51 | static struct reg_default init_list[] = { | ||
| 52 | { RT5670_PR_BASE + 0x14, 0x9a8a }, | ||
| 53 | { RT5670_PR_BASE + 0x38, 0x3ba1 }, | ||
| 54 | { RT5670_PR_BASE + 0x3d, 0x3640 }, | ||
| 55 | }; | ||
| 56 | #define RT5670_INIT_REG_LEN ARRAY_SIZE(init_list) | ||
| 57 | |||
| 58 | static const struct reg_default rt5670_reg[] = { | ||
| 59 | { 0x00, 0x0000 }, | ||
| 60 | { 0x02, 0x8888 }, | ||
| 61 | { 0x03, 0x8888 }, | ||
| 62 | { 0x0a, 0x0001 }, | ||
| 63 | { 0x0b, 0x0827 }, | ||
| 64 | { 0x0c, 0x0000 }, | ||
| 65 | { 0x0d, 0x0008 }, | ||
| 66 | { 0x0e, 0x0000 }, | ||
| 67 | { 0x0f, 0x0808 }, | ||
| 68 | { 0x19, 0xafaf }, | ||
| 69 | { 0x1a, 0xafaf }, | ||
| 70 | { 0x1b, 0x0011 }, | ||
| 71 | { 0x1c, 0x2f2f }, | ||
| 72 | { 0x1d, 0x2f2f }, | ||
| 73 | { 0x1e, 0x0000 }, | ||
| 74 | { 0x1f, 0x2f2f }, | ||
| 75 | { 0x20, 0x0000 }, | ||
| 76 | { 0x26, 0x7860 }, | ||
| 77 | { 0x27, 0x7860 }, | ||
| 78 | { 0x28, 0x7871 }, | ||
| 79 | { 0x29, 0x8080 }, | ||
| 80 | { 0x2a, 0x5656 }, | ||
| 81 | { 0x2b, 0x5454 }, | ||
| 82 | { 0x2c, 0xaaa0 }, | ||
| 83 | { 0x2d, 0x0000 }, | ||
| 84 | { 0x2e, 0x2f2f }, | ||
| 85 | { 0x2f, 0x1002 }, | ||
| 86 | { 0x30, 0x0000 }, | ||
| 87 | { 0x31, 0x5f00 }, | ||
| 88 | { 0x32, 0x0000 }, | ||
| 89 | { 0x33, 0x0000 }, | ||
| 90 | { 0x34, 0x0000 }, | ||
| 91 | { 0x35, 0x0000 }, | ||
| 92 | { 0x36, 0x0000 }, | ||
| 93 | { 0x37, 0x0000 }, | ||
| 94 | { 0x38, 0x0000 }, | ||
| 95 | { 0x3b, 0x0000 }, | ||
| 96 | { 0x3c, 0x007f }, | ||
| 97 | { 0x3d, 0x0000 }, | ||
| 98 | { 0x3e, 0x007f }, | ||
| 99 | { 0x45, 0xe00f }, | ||
| 100 | { 0x4c, 0x5380 }, | ||
| 101 | { 0x4f, 0x0073 }, | ||
| 102 | { 0x52, 0x00d3 }, | ||
| 103 | { 0x53, 0xf0f0 }, | ||
| 104 | { 0x61, 0x0000 }, | ||
| 105 | { 0x62, 0x0001 }, | ||
| 106 | { 0x63, 0x00c3 }, | ||
| 107 | { 0x64, 0x0000 }, | ||
| 108 | { 0x65, 0x0000 }, | ||
| 109 | { 0x66, 0x0000 }, | ||
| 110 | { 0x6f, 0x8000 }, | ||
| 111 | { 0x70, 0x8000 }, | ||
| 112 | { 0x71, 0x8000 }, | ||
| 113 | { 0x72, 0x8000 }, | ||
| 114 | { 0x73, 0x1110 }, | ||
| 115 | { 0x74, 0x0e00 }, | ||
| 116 | { 0x75, 0x1505 }, | ||
| 117 | { 0x76, 0x0015 }, | ||
| 118 | { 0x77, 0x0c00 }, | ||
| 119 | { 0x78, 0x4000 }, | ||
| 120 | { 0x79, 0x0123 }, | ||
| 121 | { 0x7f, 0x1100 }, | ||
| 122 | { 0x80, 0x0000 }, | ||
| 123 | { 0x81, 0x0000 }, | ||
| 124 | { 0x82, 0x0000 }, | ||
| 125 | { 0x83, 0x0000 }, | ||
| 126 | { 0x84, 0x0000 }, | ||
| 127 | { 0x85, 0x0000 }, | ||
| 128 | { 0x86, 0x0008 }, | ||
| 129 | { 0x87, 0x0000 }, | ||
| 130 | { 0x88, 0x0000 }, | ||
| 131 | { 0x89, 0x0000 }, | ||
| 132 | { 0x8a, 0x0000 }, | ||
| 133 | { 0x8b, 0x0000 }, | ||
| 134 | { 0x8c, 0x0007 }, | ||
| 135 | { 0x8d, 0x0000 }, | ||
| 136 | { 0x8e, 0x0004 }, | ||
| 137 | { 0x8f, 0x1100 }, | ||
| 138 | { 0x90, 0x0646 }, | ||
| 139 | { 0x91, 0x0c06 }, | ||
| 140 | { 0x93, 0x0000 }, | ||
| 141 | { 0x94, 0x0000 }, | ||
| 142 | { 0x95, 0x0000 }, | ||
| 143 | { 0x97, 0x0000 }, | ||
| 144 | { 0x98, 0x0000 }, | ||
| 145 | { 0x99, 0x0000 }, | ||
| 146 | { 0x9a, 0x2184 }, | ||
| 147 | { 0x9b, 0x010a }, | ||
| 148 | { 0x9c, 0x0aea }, | ||
| 149 | { 0x9d, 0x000c }, | ||
| 150 | { 0x9e, 0x0400 }, | ||
| 151 | { 0xae, 0x7000 }, | ||
| 152 | { 0xaf, 0x0000 }, | ||
| 153 | { 0xb0, 0x6000 }, | ||
| 154 | { 0xb1, 0x0000 }, | ||
| 155 | { 0xb2, 0x0000 }, | ||
| 156 | { 0xb3, 0x001f }, | ||
| 157 | { 0xb4, 0x2206 }, | ||
| 158 | { 0xb5, 0x1f00 }, | ||
| 159 | { 0xb6, 0x0000 }, | ||
| 160 | { 0xb7, 0x0000 }, | ||
| 161 | { 0xbb, 0x0000 }, | ||
| 162 | { 0xbc, 0x0000 }, | ||
| 163 | { 0xbd, 0x0000 }, | ||
| 164 | { 0xbe, 0x0000 }, | ||
| 165 | { 0xbf, 0x0000 }, | ||
| 166 | { 0xc0, 0x0000 }, | ||
| 167 | { 0xc1, 0x0000 }, | ||
| 168 | { 0xc2, 0x0000 }, | ||
| 169 | { 0xcd, 0x0000 }, | ||
| 170 | { 0xce, 0x0000 }, | ||
| 171 | { 0xcf, 0x1813 }, | ||
| 172 | { 0xd0, 0x0690 }, | ||
| 173 | { 0xd1, 0x1c17 }, | ||
| 174 | { 0xd3, 0xb320 }, | ||
| 175 | { 0xd4, 0x0000 }, | ||
| 176 | { 0xd6, 0x0400 }, | ||
| 177 | { 0xd9, 0x0809 }, | ||
| 178 | { 0xda, 0x0000 }, | ||
| 179 | { 0xdb, 0x0001 }, | ||
| 180 | { 0xdc, 0x0049 }, | ||
| 181 | { 0xdd, 0x0009 }, | ||
| 182 | { 0xe6, 0x8000 }, | ||
| 183 | { 0xe7, 0x0000 }, | ||
| 184 | { 0xec, 0xb300 }, | ||
| 185 | { 0xed, 0x0000 }, | ||
| 186 | { 0xee, 0xb300 }, | ||
| 187 | { 0xef, 0x0000 }, | ||
| 188 | { 0xf8, 0x0000 }, | ||
| 189 | { 0xf9, 0x0000 }, | ||
| 190 | { 0xfa, 0x8010 }, | ||
| 191 | { 0xfb, 0x0033 }, | ||
| 192 | { 0xfc, 0x0080 }, | ||
| 193 | }; | ||
| 194 | |||
| 195 | static bool rt5670_volatile_register(struct device *dev, unsigned int reg) | ||
| 196 | { | ||
| 197 | int i; | ||
| 198 | |||
| 199 | for (i = 0; i < ARRAY_SIZE(rt5670_ranges); i++) { | ||
| 200 | if ((reg >= rt5670_ranges[i].window_start && | ||
| 201 | reg <= rt5670_ranges[i].window_start + | ||
| 202 | rt5670_ranges[i].window_len) || | ||
| 203 | (reg >= rt5670_ranges[i].range_min && | ||
| 204 | reg <= rt5670_ranges[i].range_max)) { | ||
| 205 | return true; | ||
| 206 | } | ||
| 207 | } | ||
| 208 | |||
| 209 | switch (reg) { | ||
| 210 | case RT5670_RESET: | ||
| 211 | case RT5670_PDM_DATA_CTRL1: | ||
| 212 | case RT5670_PDM1_DATA_CTRL4: | ||
| 213 | case RT5670_PDM2_DATA_CTRL4: | ||
| 214 | case RT5670_PRIV_DATA: | ||
| 215 | case RT5670_ASRC_5: | ||
| 216 | case RT5670_CJ_CTRL1: | ||
| 217 | case RT5670_CJ_CTRL2: | ||
| 218 | case RT5670_CJ_CTRL3: | ||
| 219 | case RT5670_A_JD_CTRL1: | ||
| 220 | case RT5670_A_JD_CTRL2: | ||
| 221 | case RT5670_VAD_CTRL5: | ||
| 222 | case RT5670_ADC_EQ_CTRL1: | ||
| 223 | case RT5670_EQ_CTRL1: | ||
| 224 | case RT5670_ALC_CTRL_1: | ||
| 225 | case RT5670_IRQ_CTRL1: | ||
| 226 | case RT5670_IRQ_CTRL2: | ||
| 227 | case RT5670_INT_IRQ_ST: | ||
| 228 | case RT5670_IL_CMD: | ||
| 229 | case RT5670_DSP_CTRL1: | ||
| 230 | case RT5670_DSP_CTRL2: | ||
| 231 | case RT5670_DSP_CTRL3: | ||
| 232 | case RT5670_DSP_CTRL4: | ||
| 233 | case RT5670_DSP_CTRL5: | ||
| 234 | case RT5670_VENDOR_ID: | ||
| 235 | case RT5670_VENDOR_ID1: | ||
| 236 | case RT5670_VENDOR_ID2: | ||
| 237 | return true; | ||
| 238 | default: | ||
| 239 | return false; | ||
| 240 | } | ||
| 241 | } | ||
| 242 | |||
| 243 | static bool rt5670_readable_register(struct device *dev, unsigned int reg) | ||
| 244 | { | ||
| 245 | int i; | ||
| 246 | |||
| 247 | for (i = 0; i < ARRAY_SIZE(rt5670_ranges); i++) { | ||
| 248 | if ((reg >= rt5670_ranges[i].window_start && | ||
| 249 | reg <= rt5670_ranges[i].window_start + | ||
| 250 | rt5670_ranges[i].window_len) || | ||
| 251 | (reg >= rt5670_ranges[i].range_min && | ||
| 252 | reg <= rt5670_ranges[i].range_max)) { | ||
| 253 | return true; | ||
| 254 | } | ||
| 255 | } | ||
| 256 | |||
| 257 | switch (reg) { | ||
| 258 | case RT5670_RESET: | ||
| 259 | case RT5670_HP_VOL: | ||
| 260 | case RT5670_LOUT1: | ||
| 261 | case RT5670_CJ_CTRL1: | ||
| 262 | case RT5670_CJ_CTRL2: | ||
| 263 | case RT5670_CJ_CTRL3: | ||
| 264 | case RT5670_IN2: | ||
| 265 | case RT5670_INL1_INR1_VOL: | ||
| 266 | case RT5670_DAC1_DIG_VOL: | ||
| 267 | case RT5670_DAC2_DIG_VOL: | ||
| 268 | case RT5670_DAC_CTRL: | ||
| 269 | case RT5670_STO1_ADC_DIG_VOL: | ||
| 270 | case RT5670_MONO_ADC_DIG_VOL: | ||
| 271 | case RT5670_STO2_ADC_DIG_VOL: | ||
| 272 | case RT5670_ADC_BST_VOL1: | ||
| 273 | case RT5670_ADC_BST_VOL2: | ||
| 274 | case RT5670_STO2_ADC_MIXER: | ||
| 275 | case RT5670_STO1_ADC_MIXER: | ||
| 276 | case RT5670_MONO_ADC_MIXER: | ||
| 277 | case RT5670_AD_DA_MIXER: | ||
| 278 | case RT5670_STO_DAC_MIXER: | ||
| 279 | case RT5670_DD_MIXER: | ||
| 280 | case RT5670_DIG_MIXER: | ||
| 281 | case RT5670_DSP_PATH1: | ||
| 282 | case RT5670_DSP_PATH2: | ||
| 283 | case RT5670_DIG_INF1_DATA: | ||
| 284 | case RT5670_DIG_INF2_DATA: | ||
| 285 | case RT5670_PDM_OUT_CTRL: | ||
| 286 | case RT5670_PDM_DATA_CTRL1: | ||
| 287 | case RT5670_PDM1_DATA_CTRL2: | ||
| 288 | case RT5670_PDM1_DATA_CTRL3: | ||
| 289 | case RT5670_PDM1_DATA_CTRL4: | ||
| 290 | case RT5670_PDM2_DATA_CTRL2: | ||
| 291 | case RT5670_PDM2_DATA_CTRL3: | ||
| 292 | case RT5670_PDM2_DATA_CTRL4: | ||
| 293 | case RT5670_REC_L1_MIXER: | ||
| 294 | case RT5670_REC_L2_MIXER: | ||
| 295 | case RT5670_REC_R1_MIXER: | ||
| 296 | case RT5670_REC_R2_MIXER: | ||
| 297 | case RT5670_HPO_MIXER: | ||
| 298 | case RT5670_MONO_MIXER: | ||
| 299 | case RT5670_OUT_L1_MIXER: | ||
| 300 | case RT5670_OUT_R1_MIXER: | ||
| 301 | case RT5670_LOUT_MIXER: | ||
| 302 | case RT5670_PWR_DIG1: | ||
| 303 | case RT5670_PWR_DIG2: | ||
| 304 | case RT5670_PWR_ANLG1: | ||
| 305 | case RT5670_PWR_ANLG2: | ||
| 306 | case RT5670_PWR_MIXER: | ||
| 307 | case RT5670_PWR_VOL: | ||
| 308 | case RT5670_PRIV_INDEX: | ||
| 309 | case RT5670_PRIV_DATA: | ||
| 310 | case RT5670_I2S4_SDP: | ||
| 311 | case RT5670_I2S1_SDP: | ||
| 312 | case RT5670_I2S2_SDP: | ||
| 313 | case RT5670_I2S3_SDP: | ||
| 314 | case RT5670_ADDA_CLK1: | ||
| 315 | case RT5670_ADDA_CLK2: | ||
| 316 | case RT5670_DMIC_CTRL1: | ||
| 317 | case RT5670_DMIC_CTRL2: | ||
| 318 | case RT5670_TDM_CTRL_1: | ||
| 319 | case RT5670_TDM_CTRL_2: | ||
| 320 | case RT5670_TDM_CTRL_3: | ||
| 321 | case RT5670_DSP_CLK: | ||
| 322 | case RT5670_GLB_CLK: | ||
| 323 | case RT5670_PLL_CTRL1: | ||
| 324 | case RT5670_PLL_CTRL2: | ||
| 325 | case RT5670_ASRC_1: | ||
| 326 | case RT5670_ASRC_2: | ||
| 327 | case RT5670_ASRC_3: | ||
| 328 | case RT5670_ASRC_4: | ||
| 329 | case RT5670_ASRC_5: | ||
| 330 | case RT5670_ASRC_7: | ||
| 331 | case RT5670_ASRC_8: | ||
| 332 | case RT5670_ASRC_9: | ||
| 333 | case RT5670_ASRC_10: | ||
| 334 | case RT5670_ASRC_11: | ||
| 335 | case RT5670_ASRC_12: | ||
| 336 | case RT5670_ASRC_13: | ||
| 337 | case RT5670_ASRC_14: | ||
| 338 | case RT5670_DEPOP_M1: | ||
| 339 | case RT5670_DEPOP_M2: | ||
| 340 | case RT5670_DEPOP_M3: | ||
| 341 | case RT5670_CHARGE_PUMP: | ||
| 342 | case RT5670_MICBIAS: | ||
| 343 | case RT5670_A_JD_CTRL1: | ||
| 344 | case RT5670_A_JD_CTRL2: | ||
| 345 | case RT5670_VAD_CTRL1: | ||
| 346 | case RT5670_VAD_CTRL2: | ||
| 347 | case RT5670_VAD_CTRL3: | ||
| 348 | case RT5670_VAD_CTRL4: | ||
| 349 | case RT5670_VAD_CTRL5: | ||
| 350 | case RT5670_ADC_EQ_CTRL1: | ||
| 351 | case RT5670_ADC_EQ_CTRL2: | ||
| 352 | case RT5670_EQ_CTRL1: | ||
| 353 | case RT5670_EQ_CTRL2: | ||
| 354 | case RT5670_ALC_DRC_CTRL1: | ||
| 355 | case RT5670_ALC_DRC_CTRL2: | ||
| 356 | case RT5670_ALC_CTRL_1: | ||
| 357 | case RT5670_ALC_CTRL_2: | ||
| 358 | case RT5670_ALC_CTRL_3: | ||
| 359 | case RT5670_JD_CTRL: | ||
| 360 | case RT5670_IRQ_CTRL1: | ||
| 361 | case RT5670_IRQ_CTRL2: | ||
| 362 | case RT5670_INT_IRQ_ST: | ||
| 363 | case RT5670_GPIO_CTRL1: | ||
| 364 | case RT5670_GPIO_CTRL2: | ||
| 365 | case RT5670_GPIO_CTRL3: | ||
| 366 | case RT5670_SCRABBLE_FUN: | ||
| 367 | case RT5670_SCRABBLE_CTRL: | ||
| 368 | case RT5670_BASE_BACK: | ||
| 369 | case RT5670_MP3_PLUS1: | ||
| 370 | case RT5670_MP3_PLUS2: | ||
| 371 | case RT5670_ADJ_HPF1: | ||
| 372 | case RT5670_ADJ_HPF2: | ||
| 373 | case RT5670_HP_CALIB_AMP_DET: | ||
| 374 | case RT5670_SV_ZCD1: | ||
| 375 | case RT5670_SV_ZCD2: | ||
| 376 | case RT5670_IL_CMD: | ||
| 377 | case RT5670_IL_CMD2: | ||
| 378 | case RT5670_IL_CMD3: | ||
| 379 | case RT5670_DRC_HL_CTRL1: | ||
| 380 | case RT5670_DRC_HL_CTRL2: | ||
| 381 | case RT5670_ADC_MONO_HP_CTRL1: | ||
| 382 | case RT5670_ADC_MONO_HP_CTRL2: | ||
| 383 | case RT5670_ADC_STO2_HP_CTRL1: | ||
| 384 | case RT5670_ADC_STO2_HP_CTRL2: | ||
| 385 | case RT5670_JD_CTRL3: | ||
| 386 | case RT5670_JD_CTRL4: | ||
| 387 | case RT5670_DIG_MISC: | ||
| 388 | case RT5670_DSP_CTRL1: | ||
| 389 | case RT5670_DSP_CTRL2: | ||
| 390 | case RT5670_DSP_CTRL3: | ||
| 391 | case RT5670_DSP_CTRL4: | ||
| 392 | case RT5670_DSP_CTRL5: | ||
| 393 | case RT5670_GEN_CTRL2: | ||
| 394 | case RT5670_GEN_CTRL3: | ||
| 395 | case RT5670_VENDOR_ID: | ||
| 396 | case RT5670_VENDOR_ID1: | ||
| 397 | case RT5670_VENDOR_ID2: | ||
| 398 | return true; | ||
| 399 | default: | ||
| 400 | return false; | ||
| 401 | } | ||
| 402 | } | ||
| 403 | |||
| 404 | static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); | ||
| 405 | static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0); | ||
| 406 | static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); | ||
| 407 | static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0); | ||
| 408 | static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); | ||
| 409 | |||
| 410 | /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ | ||
| 411 | static unsigned int bst_tlv[] = { | ||
| 412 | TLV_DB_RANGE_HEAD(7), | ||
| 413 | 0, 0, TLV_DB_SCALE_ITEM(0, 0, 0), | ||
| 414 | 1, 1, TLV_DB_SCALE_ITEM(2000, 0, 0), | ||
| 415 | 2, 2, TLV_DB_SCALE_ITEM(2400, 0, 0), | ||
| 416 | 3, 5, TLV_DB_SCALE_ITEM(3000, 500, 0), | ||
| 417 | 6, 6, TLV_DB_SCALE_ITEM(4400, 0, 0), | ||
| 418 | 7, 7, TLV_DB_SCALE_ITEM(5000, 0, 0), | ||
| 419 | 8, 8, TLV_DB_SCALE_ITEM(5200, 0, 0), | ||
| 420 | }; | ||
| 421 | |||
| 422 | /* Interface data select */ | ||
| 423 | static const char * const rt5670_data_select[] = { | ||
| 424 | "Normal", "Swap", "left copy to right", "right copy to left" | ||
| 425 | }; | ||
| 426 | |||
| 427 | static SOC_ENUM_SINGLE_DECL(rt5670_if2_dac_enum, RT5670_DIG_INF1_DATA, | ||
| 428 | RT5670_IF2_DAC_SEL_SFT, rt5670_data_select); | ||
| 429 | |||
| 430 | static SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_enum, RT5670_DIG_INF1_DATA, | ||
| 431 | RT5670_IF2_ADC_SEL_SFT, rt5670_data_select); | ||
| 432 | |||
| 433 | static const struct snd_kcontrol_new rt5670_snd_controls[] = { | ||
| 434 | /* Headphone Output Volume */ | ||
| 435 | SOC_DOUBLE("HP Playback Switch", RT5670_HP_VOL, | ||
| 436 | RT5670_L_MUTE_SFT, RT5670_R_MUTE_SFT, 1, 1), | ||
| 437 | SOC_DOUBLE_TLV("HP Playback Volume", RT5670_HP_VOL, | ||
| 438 | RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, | ||
| 439 | 39, 0, out_vol_tlv), | ||
| 440 | /* OUTPUT Control */ | ||
| 441 | SOC_DOUBLE("OUT Channel Switch", RT5670_LOUT1, | ||
| 442 | RT5670_VOL_L_SFT, RT5670_VOL_R_SFT, 1, 1), | ||
| 443 | SOC_DOUBLE_TLV("OUT Playback Volume", RT5670_LOUT1, | ||
| 444 | RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, 39, 1, out_vol_tlv), | ||
| 445 | /* DAC Digital Volume */ | ||
| 446 | SOC_DOUBLE("DAC2 Playback Switch", RT5670_DAC_CTRL, | ||
| 447 | RT5670_M_DAC_L2_VOL_SFT, RT5670_M_DAC_R2_VOL_SFT, 1, 1), | ||
| 448 | SOC_DOUBLE_TLV("DAC1 Playback Volume", RT5670_DAC1_DIG_VOL, | ||
| 449 | RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, | ||
| 450 | 175, 0, dac_vol_tlv), | ||
| 451 | SOC_DOUBLE_TLV("Mono DAC Playback Volume", RT5670_DAC2_DIG_VOL, | ||
| 452 | RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, | ||
| 453 | 175, 0, dac_vol_tlv), | ||
| 454 | /* IN1/IN2 Control */ | ||
| 455 | SOC_SINGLE_TLV("IN1 Boost Volume", RT5670_CJ_CTRL1, | ||
| 456 | RT5670_BST_SFT1, 8, 0, bst_tlv), | ||
| 457 | SOC_SINGLE_TLV("IN2 Boost Volume", RT5670_IN2, | ||
| 458 | RT5670_BST_SFT1, 8, 0, bst_tlv), | ||
| 459 | /* INL/INR Volume Control */ | ||
| 460 | SOC_DOUBLE_TLV("IN Capture Volume", RT5670_INL1_INR1_VOL, | ||
| 461 | RT5670_INL_VOL_SFT, RT5670_INR_VOL_SFT, | ||
| 462 | 31, 1, in_vol_tlv), | ||
| 463 | /* ADC Digital Volume Control */ | ||
| 464 | SOC_DOUBLE("ADC Capture Switch", RT5670_STO1_ADC_DIG_VOL, | ||
| 465 | RT5670_L_MUTE_SFT, RT5670_R_MUTE_SFT, 1, 1), | ||
| 466 | SOC_DOUBLE_TLV("ADC Capture Volume", RT5670_STO1_ADC_DIG_VOL, | ||
| 467 | RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, | ||
| 468 | 127, 0, adc_vol_tlv), | ||
| 469 | |||
| 470 | SOC_DOUBLE_TLV("Mono ADC Capture Volume", RT5670_MONO_ADC_DIG_VOL, | ||
| 471 | RT5670_L_VOL_SFT, RT5670_R_VOL_SFT, | ||
| 472 | 127, 0, adc_vol_tlv), | ||
| 473 | |||
| 474 | /* ADC Boost Volume Control */ | ||
| 475 | SOC_DOUBLE_TLV("STO1 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1, | ||
| 476 | RT5670_STO1_ADC_L_BST_SFT, RT5670_STO1_ADC_R_BST_SFT, | ||
| 477 | 3, 0, adc_bst_tlv), | ||
| 478 | |||
| 479 | SOC_DOUBLE_TLV("STO2 ADC Boost Gain Volume", RT5670_ADC_BST_VOL1, | ||
| 480 | RT5670_STO2_ADC_L_BST_SFT, RT5670_STO2_ADC_R_BST_SFT, | ||
| 481 | 3, 0, adc_bst_tlv), | ||
| 482 | |||
| 483 | SOC_ENUM("ADC IF2 Data Switch", rt5670_if2_adc_enum), | ||
| 484 | SOC_ENUM("DAC IF2 Data Switch", rt5670_if2_dac_enum), | ||
| 485 | }; | ||
| 486 | |||
| 487 | /** | ||
| 488 | * set_dmic_clk - Set parameter of dmic. | ||
| 489 | * | ||
| 490 | * @w: DAPM widget. | ||
| 491 | * @kcontrol: The kcontrol of this widget. | ||
| 492 | * @event: Event id. | ||
| 493 | * | ||
| 494 | * Choose dmic clock between 1MHz and 3MHz. | ||
| 495 | * It is better for clock to approximate 3MHz. | ||
| 496 | */ | ||
| 497 | static int set_dmic_clk(struct snd_soc_dapm_widget *w, | ||
| 498 | struct snd_kcontrol *kcontrol, int event) | ||
| 499 | { | ||
| 500 | struct snd_soc_codec *codec = w->codec; | ||
| 501 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 502 | int idx = -EINVAL; | ||
| 503 | |||
| 504 | idx = rl6231_calc_dmic_clk(rt5670->sysclk); | ||
| 505 | |||
| 506 | if (idx < 0) | ||
| 507 | dev_err(codec->dev, "Failed to set DMIC clock\n"); | ||
| 508 | else | ||
| 509 | snd_soc_update_bits(codec, RT5670_DMIC_CTRL1, | ||
| 510 | RT5670_DMIC_CLK_MASK, idx << RT5670_DMIC_CLK_SFT); | ||
| 511 | return idx; | ||
| 512 | } | ||
| 513 | |||
| 514 | static int is_sys_clk_from_pll(struct snd_soc_dapm_widget *source, | ||
| 515 | struct snd_soc_dapm_widget *sink) | ||
| 516 | { | ||
| 517 | unsigned int val; | ||
| 518 | |||
| 519 | val = snd_soc_read(source->codec, RT5670_GLB_CLK); | ||
| 520 | val &= RT5670_SCLK_SRC_MASK; | ||
| 521 | if (val == RT5670_SCLK_SRC_PLL1) | ||
| 522 | return 1; | ||
| 523 | else | ||
| 524 | return 0; | ||
| 525 | } | ||
| 526 | |||
| 527 | static int is_using_asrc(struct snd_soc_dapm_widget *source, | ||
| 528 | struct snd_soc_dapm_widget *sink) | ||
| 529 | { | ||
| 530 | unsigned int reg, shift, val; | ||
| 531 | |||
| 532 | switch (source->shift) { | ||
| 533 | case 0: | ||
| 534 | reg = RT5670_ASRC_3; | ||
| 535 | shift = 0; | ||
| 536 | break; | ||
| 537 | case 1: | ||
| 538 | reg = RT5670_ASRC_3; | ||
| 539 | shift = 4; | ||
| 540 | break; | ||
| 541 | case 2: | ||
| 542 | reg = RT5670_ASRC_5; | ||
| 543 | shift = 12; | ||
| 544 | break; | ||
| 545 | case 3: | ||
| 546 | reg = RT5670_ASRC_2; | ||
| 547 | shift = 0; | ||
| 548 | break; | ||
| 549 | case 8: | ||
| 550 | reg = RT5670_ASRC_2; | ||
| 551 | shift = 4; | ||
| 552 | break; | ||
| 553 | case 9: | ||
| 554 | reg = RT5670_ASRC_2; | ||
| 555 | shift = 8; | ||
| 556 | break; | ||
| 557 | case 10: | ||
| 558 | reg = RT5670_ASRC_2; | ||
| 559 | shift = 12; | ||
| 560 | break; | ||
| 561 | default: | ||
| 562 | return 0; | ||
| 563 | } | ||
| 564 | |||
| 565 | val = (snd_soc_read(source->codec, reg) >> shift) & 0xf; | ||
| 566 | switch (val) { | ||
| 567 | case 1: | ||
| 568 | case 2: | ||
| 569 | case 3: | ||
| 570 | case 4: | ||
| 571 | return 1; | ||
| 572 | default: | ||
| 573 | return 0; | ||
| 574 | } | ||
| 575 | |||
| 576 | } | ||
| 577 | |||
| 578 | /* Digital Mixer */ | ||
| 579 | static const struct snd_kcontrol_new rt5670_sto1_adc_l_mix[] = { | ||
| 580 | SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER, | ||
| 581 | RT5670_M_ADC_L1_SFT, 1, 1), | ||
| 582 | SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO1_ADC_MIXER, | ||
| 583 | RT5670_M_ADC_L2_SFT, 1, 1), | ||
| 584 | }; | ||
| 585 | |||
| 586 | static const struct snd_kcontrol_new rt5670_sto1_adc_r_mix[] = { | ||
| 587 | SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO1_ADC_MIXER, | ||
| 588 | RT5670_M_ADC_R1_SFT, 1, 1), | ||
| 589 | SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO1_ADC_MIXER, | ||
| 590 | RT5670_M_ADC_R2_SFT, 1, 1), | ||
| 591 | }; | ||
| 592 | |||
| 593 | static const struct snd_kcontrol_new rt5670_sto2_adc_l_mix[] = { | ||
| 594 | SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO2_ADC_MIXER, | ||
| 595 | RT5670_M_ADC_L1_SFT, 1, 1), | ||
| 596 | SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO2_ADC_MIXER, | ||
| 597 | RT5670_M_ADC_L2_SFT, 1, 1), | ||
| 598 | }; | ||
| 599 | |||
| 600 | static const struct snd_kcontrol_new rt5670_sto2_adc_r_mix[] = { | ||
| 601 | SOC_DAPM_SINGLE("ADC1 Switch", RT5670_STO2_ADC_MIXER, | ||
| 602 | RT5670_M_ADC_R1_SFT, 1, 1), | ||
| 603 | SOC_DAPM_SINGLE("ADC2 Switch", RT5670_STO2_ADC_MIXER, | ||
| 604 | RT5670_M_ADC_R2_SFT, 1, 1), | ||
| 605 | }; | ||
| 606 | |||
| 607 | static const struct snd_kcontrol_new rt5670_mono_adc_l_mix[] = { | ||
| 608 | SOC_DAPM_SINGLE("ADC1 Switch", RT5670_MONO_ADC_MIXER, | ||
| 609 | RT5670_M_MONO_ADC_L1_SFT, 1, 1), | ||
| 610 | SOC_DAPM_SINGLE("ADC2 Switch", RT5670_MONO_ADC_MIXER, | ||
| 611 | RT5670_M_MONO_ADC_L2_SFT, 1, 1), | ||
| 612 | }; | ||
| 613 | |||
| 614 | static const struct snd_kcontrol_new rt5670_mono_adc_r_mix[] = { | ||
| 615 | SOC_DAPM_SINGLE("ADC1 Switch", RT5670_MONO_ADC_MIXER, | ||
| 616 | RT5670_M_MONO_ADC_R1_SFT, 1, 1), | ||
| 617 | SOC_DAPM_SINGLE("ADC2 Switch", RT5670_MONO_ADC_MIXER, | ||
| 618 | RT5670_M_MONO_ADC_R2_SFT, 1, 1), | ||
| 619 | }; | ||
| 620 | |||
| 621 | static const struct snd_kcontrol_new rt5670_dac_l_mix[] = { | ||
| 622 | SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER, | ||
| 623 | RT5670_M_ADCMIX_L_SFT, 1, 1), | ||
| 624 | SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER, | ||
| 625 | RT5670_M_DAC1_L_SFT, 1, 1), | ||
| 626 | }; | ||
| 627 | |||
| 628 | static const struct snd_kcontrol_new rt5670_dac_r_mix[] = { | ||
| 629 | SOC_DAPM_SINGLE("Stereo ADC Switch", RT5670_AD_DA_MIXER, | ||
| 630 | RT5670_M_ADCMIX_R_SFT, 1, 1), | ||
| 631 | SOC_DAPM_SINGLE("DAC1 Switch", RT5670_AD_DA_MIXER, | ||
| 632 | RT5670_M_DAC1_R_SFT, 1, 1), | ||
| 633 | }; | ||
| 634 | |||
| 635 | static const struct snd_kcontrol_new rt5670_sto_dac_l_mix[] = { | ||
| 636 | SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_STO_DAC_MIXER, | ||
| 637 | RT5670_M_DAC_L1_SFT, 1, 1), | ||
| 638 | SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_STO_DAC_MIXER, | ||
| 639 | RT5670_M_DAC_L2_SFT, 1, 1), | ||
| 640 | SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_STO_DAC_MIXER, | ||
| 641 | RT5670_M_DAC_R1_STO_L_SFT, 1, 1), | ||
| 642 | }; | ||
| 643 | |||
| 644 | static const struct snd_kcontrol_new rt5670_sto_dac_r_mix[] = { | ||
| 645 | SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_STO_DAC_MIXER, | ||
| 646 | RT5670_M_DAC_R1_SFT, 1, 1), | ||
| 647 | SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_STO_DAC_MIXER, | ||
| 648 | RT5670_M_DAC_R2_SFT, 1, 1), | ||
| 649 | SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_STO_DAC_MIXER, | ||
| 650 | RT5670_M_DAC_L1_STO_R_SFT, 1, 1), | ||
| 651 | }; | ||
| 652 | |||
| 653 | static const struct snd_kcontrol_new rt5670_mono_dac_l_mix[] = { | ||
| 654 | SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_DD_MIXER, | ||
| 655 | RT5670_M_DAC_L1_MONO_L_SFT, 1, 1), | ||
| 656 | SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DD_MIXER, | ||
| 657 | RT5670_M_DAC_L2_MONO_L_SFT, 1, 1), | ||
| 658 | SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DD_MIXER, | ||
| 659 | RT5670_M_DAC_R2_MONO_L_SFT, 1, 1), | ||
| 660 | }; | ||
| 661 | |||
| 662 | static const struct snd_kcontrol_new rt5670_mono_dac_r_mix[] = { | ||
| 663 | SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_DD_MIXER, | ||
| 664 | RT5670_M_DAC_R1_MONO_R_SFT, 1, 1), | ||
| 665 | SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DD_MIXER, | ||
| 666 | RT5670_M_DAC_R2_MONO_R_SFT, 1, 1), | ||
| 667 | SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DD_MIXER, | ||
| 668 | RT5670_M_DAC_L2_MONO_R_SFT, 1, 1), | ||
| 669 | }; | ||
| 670 | |||
| 671 | static const struct snd_kcontrol_new rt5670_dig_l_mix[] = { | ||
| 672 | SOC_DAPM_SINGLE("Sto DAC Mix L Switch", RT5670_DIG_MIXER, | ||
| 673 | RT5670_M_STO_L_DAC_L_SFT, 1, 1), | ||
| 674 | SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DIG_MIXER, | ||
| 675 | RT5670_M_DAC_L2_DAC_L_SFT, 1, 1), | ||
| 676 | SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DIG_MIXER, | ||
| 677 | RT5670_M_DAC_R2_DAC_L_SFT, 1, 1), | ||
| 678 | }; | ||
| 679 | |||
| 680 | static const struct snd_kcontrol_new rt5670_dig_r_mix[] = { | ||
| 681 | SOC_DAPM_SINGLE("Sto DAC Mix R Switch", RT5670_DIG_MIXER, | ||
| 682 | RT5670_M_STO_R_DAC_R_SFT, 1, 1), | ||
| 683 | SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_DIG_MIXER, | ||
| 684 | RT5670_M_DAC_R2_DAC_R_SFT, 1, 1), | ||
| 685 | SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_DIG_MIXER, | ||
| 686 | RT5670_M_DAC_L2_DAC_R_SFT, 1, 1), | ||
| 687 | }; | ||
| 688 | |||
| 689 | /* Analog Input Mixer */ | ||
| 690 | static const struct snd_kcontrol_new rt5670_rec_l_mix[] = { | ||
| 691 | SOC_DAPM_SINGLE("INL Switch", RT5670_REC_L2_MIXER, | ||
| 692 | RT5670_M_IN_L_RM_L_SFT, 1, 1), | ||
| 693 | SOC_DAPM_SINGLE("BST2 Switch", RT5670_REC_L2_MIXER, | ||
| 694 | RT5670_M_BST2_RM_L_SFT, 1, 1), | ||
| 695 | SOC_DAPM_SINGLE("BST1 Switch", RT5670_REC_L2_MIXER, | ||
| 696 | RT5670_M_BST1_RM_L_SFT, 1, 1), | ||
| 697 | }; | ||
| 698 | |||
| 699 | static const struct snd_kcontrol_new rt5670_rec_r_mix[] = { | ||
| 700 | SOC_DAPM_SINGLE("INR Switch", RT5670_REC_R2_MIXER, | ||
| 701 | RT5670_M_IN_R_RM_R_SFT, 1, 1), | ||
| 702 | SOC_DAPM_SINGLE("BST2 Switch", RT5670_REC_R2_MIXER, | ||
| 703 | RT5670_M_BST2_RM_R_SFT, 1, 1), | ||
| 704 | SOC_DAPM_SINGLE("BST1 Switch", RT5670_REC_R2_MIXER, | ||
| 705 | RT5670_M_BST1_RM_R_SFT, 1, 1), | ||
| 706 | }; | ||
| 707 | |||
| 708 | static const struct snd_kcontrol_new rt5670_out_l_mix[] = { | ||
| 709 | SOC_DAPM_SINGLE("BST1 Switch", RT5670_OUT_L1_MIXER, | ||
| 710 | RT5670_M_BST1_OM_L_SFT, 1, 1), | ||
| 711 | SOC_DAPM_SINGLE("INL Switch", RT5670_OUT_L1_MIXER, | ||
| 712 | RT5670_M_IN_L_OM_L_SFT, 1, 1), | ||
| 713 | SOC_DAPM_SINGLE("DAC L2 Switch", RT5670_OUT_L1_MIXER, | ||
| 714 | RT5670_M_DAC_L2_OM_L_SFT, 1, 1), | ||
| 715 | SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_OUT_L1_MIXER, | ||
| 716 | RT5670_M_DAC_L1_OM_L_SFT, 1, 1), | ||
| 717 | }; | ||
| 718 | |||
| 719 | static const struct snd_kcontrol_new rt5670_out_r_mix[] = { | ||
| 720 | SOC_DAPM_SINGLE("BST2 Switch", RT5670_OUT_R1_MIXER, | ||
| 721 | RT5670_M_BST2_OM_R_SFT, 1, 1), | ||
| 722 | SOC_DAPM_SINGLE("INR Switch", RT5670_OUT_R1_MIXER, | ||
| 723 | RT5670_M_IN_R_OM_R_SFT, 1, 1), | ||
| 724 | SOC_DAPM_SINGLE("DAC R2 Switch", RT5670_OUT_R1_MIXER, | ||
| 725 | RT5670_M_DAC_R2_OM_R_SFT, 1, 1), | ||
| 726 | SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_OUT_R1_MIXER, | ||
| 727 | RT5670_M_DAC_R1_OM_R_SFT, 1, 1), | ||
| 728 | }; | ||
| 729 | |||
| 730 | static const struct snd_kcontrol_new rt5670_hpo_mix[] = { | ||
| 731 | SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER, | ||
| 732 | RT5670_M_DAC1_HM_SFT, 1, 1), | ||
| 733 | SOC_DAPM_SINGLE("HPVOL Switch", RT5670_HPO_MIXER, | ||
| 734 | RT5670_M_HPVOL_HM_SFT, 1, 1), | ||
| 735 | }; | ||
| 736 | |||
| 737 | static const struct snd_kcontrol_new rt5670_hpvoll_mix[] = { | ||
| 738 | SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER, | ||
| 739 | RT5670_M_DACL1_HML_SFT, 1, 1), | ||
| 740 | SOC_DAPM_SINGLE("INL Switch", RT5670_HPO_MIXER, | ||
| 741 | RT5670_M_INL1_HML_SFT, 1, 1), | ||
| 742 | }; | ||
| 743 | |||
| 744 | static const struct snd_kcontrol_new rt5670_hpvolr_mix[] = { | ||
| 745 | SOC_DAPM_SINGLE("DAC1 Switch", RT5670_HPO_MIXER, | ||
| 746 | RT5670_M_DACR1_HMR_SFT, 1, 1), | ||
| 747 | SOC_DAPM_SINGLE("INR Switch", RT5670_HPO_MIXER, | ||
| 748 | RT5670_M_INR1_HMR_SFT, 1, 1), | ||
| 749 | }; | ||
| 750 | |||
| 751 | static const struct snd_kcontrol_new rt5670_lout_mix[] = { | ||
| 752 | SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_LOUT_MIXER, | ||
| 753 | RT5670_M_DAC_L1_LM_SFT, 1, 1), | ||
| 754 | SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_LOUT_MIXER, | ||
| 755 | RT5670_M_DAC_R1_LM_SFT, 1, 1), | ||
| 756 | SOC_DAPM_SINGLE("OUTMIX L Switch", RT5670_LOUT_MIXER, | ||
| 757 | RT5670_M_OV_L_LM_SFT, 1, 1), | ||
| 758 | SOC_DAPM_SINGLE("OUTMIX R Switch", RT5670_LOUT_MIXER, | ||
| 759 | RT5670_M_OV_R_LM_SFT, 1, 1), | ||
| 760 | }; | ||
| 761 | |||
| 762 | static const struct snd_kcontrol_new rt5670_hpl_mix[] = { | ||
| 763 | SOC_DAPM_SINGLE("DAC L1 Switch", RT5670_HPO_MIXER, | ||
| 764 | RT5670_M_DACL1_HML_SFT, 1, 1), | ||
| 765 | SOC_DAPM_SINGLE("INL1 Switch", RT5670_HPO_MIXER, | ||
| 766 | RT5670_M_INL1_HML_SFT, 1, 1), | ||
| 767 | }; | ||
| 768 | |||
| 769 | static const struct snd_kcontrol_new rt5670_hpr_mix[] = { | ||
| 770 | SOC_DAPM_SINGLE("DAC R1 Switch", RT5670_HPO_MIXER, | ||
| 771 | RT5670_M_DACR1_HMR_SFT, 1, 1), | ||
| 772 | SOC_DAPM_SINGLE("INR1 Switch", RT5670_HPO_MIXER, | ||
| 773 | RT5670_M_INR1_HMR_SFT, 1, 1), | ||
| 774 | }; | ||
| 775 | |||
| 776 | static const struct snd_kcontrol_new lout_l_enable_control = | ||
| 777 | SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5670_LOUT1, | ||
| 778 | RT5670_L_MUTE_SFT, 1, 1); | ||
| 779 | |||
| 780 | static const struct snd_kcontrol_new lout_r_enable_control = | ||
| 781 | SOC_DAPM_SINGLE_AUTODISABLE("Switch", RT5670_LOUT1, | ||
| 782 | RT5670_R_MUTE_SFT, 1, 1); | ||
| 783 | |||
| 784 | /* DAC1 L/R source */ /* MX-29 [9:8] [11:10] */ | ||
| 785 | static const char * const rt5670_dac1_src[] = { | ||
| 786 | "IF1 DAC", "IF2 DAC" | ||
| 787 | }; | ||
| 788 | |||
| 789 | static SOC_ENUM_SINGLE_DECL(rt5670_dac1l_enum, RT5670_AD_DA_MIXER, | ||
| 790 | RT5670_DAC1_L_SEL_SFT, rt5670_dac1_src); | ||
| 791 | |||
| 792 | static const struct snd_kcontrol_new rt5670_dac1l_mux = | ||
| 793 | SOC_DAPM_ENUM("DAC1 L source", rt5670_dac1l_enum); | ||
| 794 | |||
| 795 | static SOC_ENUM_SINGLE_DECL(rt5670_dac1r_enum, RT5670_AD_DA_MIXER, | ||
| 796 | RT5670_DAC1_R_SEL_SFT, rt5670_dac1_src); | ||
| 797 | |||
| 798 | static const struct snd_kcontrol_new rt5670_dac1r_mux = | ||
| 799 | SOC_DAPM_ENUM("DAC1 R source", rt5670_dac1r_enum); | ||
| 800 | |||
| 801 | /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */ | ||
| 802 | /* TODO Use SOC_VALUE_ENUM_SINGLE_DECL */ | ||
| 803 | static const char * const rt5670_dac12_src[] = { | ||
| 804 | "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", | ||
| 805 | "Bass", "VAD_ADC", "IF4 DAC" | ||
| 806 | }; | ||
| 807 | |||
| 808 | static SOC_ENUM_SINGLE_DECL(rt5670_dac2l_enum, RT5670_DAC_CTRL, | ||
| 809 | RT5670_DAC2_L_SEL_SFT, rt5670_dac12_src); | ||
| 810 | |||
| 811 | static const struct snd_kcontrol_new rt5670_dac_l2_mux = | ||
| 812 | SOC_DAPM_ENUM("DAC2 L source", rt5670_dac2l_enum); | ||
| 813 | |||
| 814 | static const char * const rt5670_dacr2_src[] = { | ||
| 815 | "IF1 DAC", "IF2 DAC", "IF3 DAC", "TxDC DAC", "TxDP ADC", "IF4 DAC" | ||
| 816 | }; | ||
| 817 | |||
| 818 | static SOC_ENUM_SINGLE_DECL(rt5670_dac2r_enum, RT5670_DAC_CTRL, | ||
| 819 | RT5670_DAC2_R_SEL_SFT, rt5670_dacr2_src); | ||
| 820 | |||
| 821 | static const struct snd_kcontrol_new rt5670_dac_r2_mux = | ||
| 822 | SOC_DAPM_ENUM("DAC2 R source", rt5670_dac2r_enum); | ||
| 823 | |||
| 824 | /*RxDP source*/ /* MX-2D [15:13] */ | ||
| 825 | static const char * const rt5670_rxdp_src[] = { | ||
| 826 | "IF2 DAC", "IF1 DAC", "STO1 ADC Mixer", "STO2 ADC Mixer", | ||
| 827 | "Mono ADC Mixer L", "Mono ADC Mixer R", "DAC1" | ||
| 828 | }; | ||
| 829 | |||
| 830 | static SOC_ENUM_SINGLE_DECL(rt5670_rxdp_enum, RT5670_DSP_PATH1, | ||
| 831 | RT5670_RXDP_SEL_SFT, rt5670_rxdp_src); | ||
| 832 | |||
| 833 | static const struct snd_kcontrol_new rt5670_rxdp_mux = | ||
| 834 | SOC_DAPM_ENUM("DAC2 L source", rt5670_rxdp_enum); | ||
| 835 | |||
| 836 | /* MX-2D [1] [0] */ | ||
| 837 | static const char * const rt5670_dsp_bypass_src[] = { | ||
| 838 | "DSP", "Bypass" | ||
| 839 | }; | ||
| 840 | |||
| 841 | static SOC_ENUM_SINGLE_DECL(rt5670_dsp_ul_enum, RT5670_DSP_PATH1, | ||
| 842 | RT5670_DSP_UL_SFT, rt5670_dsp_bypass_src); | ||
| 843 | |||
| 844 | static const struct snd_kcontrol_new rt5670_dsp_ul_mux = | ||
| 845 | SOC_DAPM_ENUM("DSP UL source", rt5670_dsp_ul_enum); | ||
| 846 | |||
| 847 | static SOC_ENUM_SINGLE_DECL(rt5670_dsp_dl_enum, RT5670_DSP_PATH1, | ||
| 848 | RT5670_DSP_DL_SFT, rt5670_dsp_bypass_src); | ||
| 849 | |||
| 850 | static const struct snd_kcontrol_new rt5670_dsp_dl_mux = | ||
| 851 | SOC_DAPM_ENUM("DSP DL source", rt5670_dsp_dl_enum); | ||
| 852 | |||
| 853 | /* Stereo2 ADC source */ | ||
| 854 | /* MX-26 [15] */ | ||
| 855 | static const char * const rt5670_stereo2_adc_lr_src[] = { | ||
| 856 | "L", "LR" | ||
| 857 | }; | ||
| 858 | |||
| 859 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc_lr_enum, RT5670_STO2_ADC_MIXER, | ||
| 860 | RT5670_STO2_ADC_SRC_SFT, rt5670_stereo2_adc_lr_src); | ||
| 861 | |||
| 862 | static const struct snd_kcontrol_new rt5670_sto2_adc_lr_mux = | ||
| 863 | SOC_DAPM_ENUM("Stereo2 ADC LR source", rt5670_stereo2_adc_lr_enum); | ||
| 864 | |||
| 865 | /* Stereo1 ADC source */ | ||
| 866 | /* MX-27 MX-26 [12] */ | ||
| 867 | static const char * const rt5670_stereo_adc1_src[] = { | ||
| 868 | "DAC MIX", "ADC" | ||
| 869 | }; | ||
| 870 | |||
| 871 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc1_enum, RT5670_STO1_ADC_MIXER, | ||
| 872 | RT5670_ADC_1_SRC_SFT, rt5670_stereo_adc1_src); | ||
| 873 | |||
| 874 | static const struct snd_kcontrol_new rt5670_sto_adc_l1_mux = | ||
| 875 | SOC_DAPM_ENUM("Stereo1 ADC L1 source", rt5670_stereo1_adc1_enum); | ||
| 876 | |||
| 877 | static const struct snd_kcontrol_new rt5670_sto_adc_r1_mux = | ||
| 878 | SOC_DAPM_ENUM("Stereo1 ADC R1 source", rt5670_stereo1_adc1_enum); | ||
| 879 | |||
| 880 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc1_enum, RT5670_STO2_ADC_MIXER, | ||
| 881 | RT5670_ADC_1_SRC_SFT, rt5670_stereo_adc1_src); | ||
| 882 | |||
| 883 | static const struct snd_kcontrol_new rt5670_sto2_adc_l1_mux = | ||
| 884 | SOC_DAPM_ENUM("Stereo2 ADC L1 source", rt5670_stereo2_adc1_enum); | ||
| 885 | |||
| 886 | static const struct snd_kcontrol_new rt5670_sto2_adc_r1_mux = | ||
| 887 | SOC_DAPM_ENUM("Stereo2 ADC R1 source", rt5670_stereo2_adc1_enum); | ||
| 888 | |||
| 889 | /* MX-27 MX-26 [11] */ | ||
| 890 | static const char * const rt5670_stereo_adc2_src[] = { | ||
| 891 | "DAC MIX", "DMIC" | ||
| 892 | }; | ||
| 893 | |||
| 894 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc2_enum, RT5670_STO1_ADC_MIXER, | ||
| 895 | RT5670_ADC_2_SRC_SFT, rt5670_stereo_adc2_src); | ||
| 896 | |||
| 897 | static const struct snd_kcontrol_new rt5670_sto_adc_l2_mux = | ||
| 898 | SOC_DAPM_ENUM("Stereo1 ADC L2 source", rt5670_stereo1_adc2_enum); | ||
| 899 | |||
| 900 | static const struct snd_kcontrol_new rt5670_sto_adc_r2_mux = | ||
| 901 | SOC_DAPM_ENUM("Stereo1 ADC R2 source", rt5670_stereo1_adc2_enum); | ||
| 902 | |||
| 903 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc2_enum, RT5670_STO2_ADC_MIXER, | ||
| 904 | RT5670_ADC_2_SRC_SFT, rt5670_stereo_adc2_src); | ||
| 905 | |||
| 906 | static const struct snd_kcontrol_new rt5670_sto2_adc_l2_mux = | ||
| 907 | SOC_DAPM_ENUM("Stereo2 ADC L2 source", rt5670_stereo2_adc2_enum); | ||
| 908 | |||
| 909 | static const struct snd_kcontrol_new rt5670_sto2_adc_r2_mux = | ||
| 910 | SOC_DAPM_ENUM("Stereo2 ADC R2 source", rt5670_stereo2_adc2_enum); | ||
| 911 | |||
| 912 | /* MX-27 MX26 [10] */ | ||
| 913 | static const char * const rt5670_stereo_adc_src[] = { | ||
| 914 | "ADC1L ADC2R", "ADC3" | ||
| 915 | }; | ||
| 916 | |||
| 917 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_adc_enum, RT5670_STO1_ADC_MIXER, | ||
| 918 | RT5670_ADC_SRC_SFT, rt5670_stereo_adc_src); | ||
| 919 | |||
| 920 | static const struct snd_kcontrol_new rt5670_sto_adc_mux = | ||
| 921 | SOC_DAPM_ENUM("Stereo1 ADC source", rt5670_stereo1_adc_enum); | ||
| 922 | |||
| 923 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_adc_enum, RT5670_STO2_ADC_MIXER, | ||
| 924 | RT5670_ADC_SRC_SFT, rt5670_stereo_adc_src); | ||
| 925 | |||
| 926 | static const struct snd_kcontrol_new rt5670_sto2_adc_mux = | ||
| 927 | SOC_DAPM_ENUM("Stereo2 ADC source", rt5670_stereo2_adc_enum); | ||
| 928 | |||
| 929 | /* MX-27 MX-26 [9:8] */ | ||
| 930 | static const char * const rt5670_stereo_dmic_src[] = { | ||
| 931 | "DMIC1", "DMIC2", "DMIC3" | ||
| 932 | }; | ||
| 933 | |||
| 934 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo1_dmic_enum, RT5670_STO1_ADC_MIXER, | ||
| 935 | RT5670_DMIC_SRC_SFT, rt5670_stereo_dmic_src); | ||
| 936 | |||
| 937 | static const struct snd_kcontrol_new rt5670_sto1_dmic_mux = | ||
| 938 | SOC_DAPM_ENUM("Stereo1 DMIC source", rt5670_stereo1_dmic_enum); | ||
| 939 | |||
| 940 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo2_dmic_enum, RT5670_STO2_ADC_MIXER, | ||
| 941 | RT5670_DMIC_SRC_SFT, rt5670_stereo_dmic_src); | ||
| 942 | |||
| 943 | static const struct snd_kcontrol_new rt5670_sto2_dmic_mux = | ||
| 944 | SOC_DAPM_ENUM("Stereo2 DMIC source", rt5670_stereo2_dmic_enum); | ||
| 945 | |||
| 946 | /* MX-27 [0] */ | ||
| 947 | static const char * const rt5670_stereo_dmic3_src[] = { | ||
| 948 | "DMIC3", "PDM ADC" | ||
| 949 | }; | ||
| 950 | |||
| 951 | static SOC_ENUM_SINGLE_DECL(rt5670_stereo_dmic3_enum, RT5670_STO1_ADC_MIXER, | ||
| 952 | RT5670_DMIC3_SRC_SFT, rt5670_stereo_dmic3_src); | ||
| 953 | |||
| 954 | static const struct snd_kcontrol_new rt5670_sto_dmic3_mux = | ||
| 955 | SOC_DAPM_ENUM("Stereo DMIC3 source", rt5670_stereo_dmic3_enum); | ||
| 956 | |||
| 957 | /* Mono ADC source */ | ||
| 958 | /* MX-28 [12] */ | ||
| 959 | static const char * const rt5670_mono_adc_l1_src[] = { | ||
| 960 | "Mono DAC MIXL", "ADC1" | ||
| 961 | }; | ||
| 962 | |||
| 963 | static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_l1_enum, RT5670_MONO_ADC_MIXER, | ||
| 964 | RT5670_MONO_ADC_L1_SRC_SFT, rt5670_mono_adc_l1_src); | ||
| 965 | |||
| 966 | static const struct snd_kcontrol_new rt5670_mono_adc_l1_mux = | ||
| 967 | SOC_DAPM_ENUM("Mono ADC1 left source", rt5670_mono_adc_l1_enum); | ||
| 968 | /* MX-28 [11] */ | ||
| 969 | static const char * const rt5670_mono_adc_l2_src[] = { | ||
| 970 | "Mono DAC MIXL", "DMIC" | ||
| 971 | }; | ||
| 972 | |||
| 973 | static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_l2_enum, RT5670_MONO_ADC_MIXER, | ||
| 974 | RT5670_MONO_ADC_L2_SRC_SFT, rt5670_mono_adc_l2_src); | ||
| 975 | |||
| 976 | static const struct snd_kcontrol_new rt5670_mono_adc_l2_mux = | ||
| 977 | SOC_DAPM_ENUM("Mono ADC2 left source", rt5670_mono_adc_l2_enum); | ||
| 978 | |||
| 979 | /* MX-28 [9:8] */ | ||
| 980 | static const char * const rt5670_mono_dmic_src[] = { | ||
| 981 | "DMIC1", "DMIC2", "DMIC3" | ||
| 982 | }; | ||
| 983 | |||
| 984 | static SOC_ENUM_SINGLE_DECL(rt5670_mono_dmic_l_enum, RT5670_MONO_ADC_MIXER, | ||
| 985 | RT5670_MONO_DMIC_L_SRC_SFT, rt5670_mono_dmic_src); | ||
| 986 | |||
| 987 | static const struct snd_kcontrol_new rt5670_mono_dmic_l_mux = | ||
| 988 | SOC_DAPM_ENUM("Mono DMIC left source", rt5670_mono_dmic_l_enum); | ||
| 989 | /* MX-28 [1:0] */ | ||
| 990 | static SOC_ENUM_SINGLE_DECL(rt5670_mono_dmic_r_enum, RT5670_MONO_ADC_MIXER, | ||
| 991 | RT5670_MONO_DMIC_R_SRC_SFT, rt5670_mono_dmic_src); | ||
| 992 | |||
| 993 | static const struct snd_kcontrol_new rt5670_mono_dmic_r_mux = | ||
| 994 | SOC_DAPM_ENUM("Mono DMIC Right source", rt5670_mono_dmic_r_enum); | ||
| 995 | /* MX-28 [4] */ | ||
| 996 | static const char * const rt5670_mono_adc_r1_src[] = { | ||
| 997 | "Mono DAC MIXR", "ADC2" | ||
| 998 | }; | ||
| 999 | |||
| 1000 | static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_r1_enum, RT5670_MONO_ADC_MIXER, | ||
| 1001 | RT5670_MONO_ADC_R1_SRC_SFT, rt5670_mono_adc_r1_src); | ||
| 1002 | |||
| 1003 | static const struct snd_kcontrol_new rt5670_mono_adc_r1_mux = | ||
| 1004 | SOC_DAPM_ENUM("Mono ADC1 right source", rt5670_mono_adc_r1_enum); | ||
| 1005 | /* MX-28 [3] */ | ||
| 1006 | static const char * const rt5670_mono_adc_r2_src[] = { | ||
| 1007 | "Mono DAC MIXR", "DMIC" | ||
| 1008 | }; | ||
| 1009 | |||
| 1010 | static SOC_ENUM_SINGLE_DECL(rt5670_mono_adc_r2_enum, RT5670_MONO_ADC_MIXER, | ||
| 1011 | RT5670_MONO_ADC_R2_SRC_SFT, rt5670_mono_adc_r2_src); | ||
| 1012 | |||
| 1013 | static const struct snd_kcontrol_new rt5670_mono_adc_r2_mux = | ||
| 1014 | SOC_DAPM_ENUM("Mono ADC2 right source", rt5670_mono_adc_r2_enum); | ||
| 1015 | |||
| 1016 | /* MX-2D [3:2] */ | ||
| 1017 | static const char * const rt5670_txdp_slot_src[] = { | ||
| 1018 | "Slot 0-1", "Slot 2-3", "Slot 4-5", "Slot 6-7" | ||
| 1019 | }; | ||
| 1020 | |||
| 1021 | static SOC_ENUM_SINGLE_DECL(rt5670_txdp_slot_enum, RT5670_DSP_PATH1, | ||
| 1022 | RT5670_TXDP_SLOT_SEL_SFT, rt5670_txdp_slot_src); | ||
| 1023 | |||
| 1024 | static const struct snd_kcontrol_new rt5670_txdp_slot_mux = | ||
| 1025 | SOC_DAPM_ENUM("TxDP Slot source", rt5670_txdp_slot_enum); | ||
| 1026 | |||
| 1027 | /* MX-2F [15] */ | ||
| 1028 | static const char * const rt5670_if1_adc2_in_src[] = { | ||
| 1029 | "IF_ADC2", "VAD_ADC" | ||
| 1030 | }; | ||
| 1031 | |||
| 1032 | static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc2_in_enum, RT5670_DIG_INF1_DATA, | ||
| 1033 | RT5670_IF1_ADC2_IN_SFT, rt5670_if1_adc2_in_src); | ||
| 1034 | |||
| 1035 | static const struct snd_kcontrol_new rt5670_if1_adc2_in_mux = | ||
| 1036 | SOC_DAPM_ENUM("IF1 ADC2 IN source", rt5670_if1_adc2_in_enum); | ||
| 1037 | |||
| 1038 | /* MX-2F [14:12] */ | ||
| 1039 | static const char * const rt5670_if2_adc_in_src[] = { | ||
| 1040 | "IF_ADC1", "IF_ADC2", "IF_ADC3", "TxDC_DAC", "TxDP_ADC", "VAD_ADC" | ||
| 1041 | }; | ||
| 1042 | |||
| 1043 | static SOC_ENUM_SINGLE_DECL(rt5670_if2_adc_in_enum, RT5670_DIG_INF1_DATA, | ||
| 1044 | RT5670_IF2_ADC_IN_SFT, rt5670_if2_adc_in_src); | ||
| 1045 | |||
| 1046 | static const struct snd_kcontrol_new rt5670_if2_adc_in_mux = | ||
| 1047 | SOC_DAPM_ENUM("IF2 ADC IN source", rt5670_if2_adc_in_enum); | ||
| 1048 | |||
| 1049 | /* MX-30 [5:4] */ | ||
| 1050 | static const char * const rt5670_if4_adc_in_src[] = { | ||
| 1051 | "IF_ADC1", "IF_ADC2", "IF_ADC3" | ||
| 1052 | }; | ||
| 1053 | |||
| 1054 | static SOC_ENUM_SINGLE_DECL(rt5670_if4_adc_in_enum, RT5670_DIG_INF2_DATA, | ||
| 1055 | RT5670_IF4_ADC_IN_SFT, rt5670_if4_adc_in_src); | ||
| 1056 | |||
| 1057 | static const struct snd_kcontrol_new rt5670_if4_adc_in_mux = | ||
| 1058 | SOC_DAPM_ENUM("IF4 ADC IN source", rt5670_if4_adc_in_enum); | ||
| 1059 | |||
| 1060 | /* MX-31 [15] [13] [11] [9] */ | ||
| 1061 | static const char * const rt5670_pdm_src[] = { | ||
| 1062 | "Mono DAC", "Stereo DAC" | ||
| 1063 | }; | ||
| 1064 | |||
| 1065 | static SOC_ENUM_SINGLE_DECL(rt5670_pdm1_l_enum, RT5670_PDM_OUT_CTRL, | ||
| 1066 | RT5670_PDM1_L_SFT, rt5670_pdm_src); | ||
| 1067 | |||
| 1068 | static const struct snd_kcontrol_new rt5670_pdm1_l_mux = | ||
| 1069 | SOC_DAPM_ENUM("PDM1 L source", rt5670_pdm1_l_enum); | ||
| 1070 | |||
| 1071 | static SOC_ENUM_SINGLE_DECL(rt5670_pdm1_r_enum, RT5670_PDM_OUT_CTRL, | ||
| 1072 | RT5670_PDM1_R_SFT, rt5670_pdm_src); | ||
| 1073 | |||
| 1074 | static const struct snd_kcontrol_new rt5670_pdm1_r_mux = | ||
| 1075 | SOC_DAPM_ENUM("PDM1 R source", rt5670_pdm1_r_enum); | ||
| 1076 | |||
| 1077 | static SOC_ENUM_SINGLE_DECL(rt5670_pdm2_l_enum, RT5670_PDM_OUT_CTRL, | ||
| 1078 | RT5670_PDM2_L_SFT, rt5670_pdm_src); | ||
| 1079 | |||
| 1080 | static const struct snd_kcontrol_new rt5670_pdm2_l_mux = | ||
| 1081 | SOC_DAPM_ENUM("PDM2 L source", rt5670_pdm2_l_enum); | ||
| 1082 | |||
| 1083 | static SOC_ENUM_SINGLE_DECL(rt5670_pdm2_r_enum, RT5670_PDM_OUT_CTRL, | ||
| 1084 | RT5670_PDM2_R_SFT, rt5670_pdm_src); | ||
| 1085 | |||
| 1086 | static const struct snd_kcontrol_new rt5670_pdm2_r_mux = | ||
| 1087 | SOC_DAPM_ENUM("PDM2 R source", rt5670_pdm2_r_enum); | ||
| 1088 | |||
| 1089 | /* MX-FA [12] */ | ||
| 1090 | static const char * const rt5670_if1_adc1_in1_src[] = { | ||
| 1091 | "IF_ADC1", "IF1_ADC3" | ||
| 1092 | }; | ||
| 1093 | |||
| 1094 | static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc1_in1_enum, RT5670_DIG_MISC, | ||
| 1095 | RT5670_IF1_ADC1_IN1_SFT, rt5670_if1_adc1_in1_src); | ||
| 1096 | |||
| 1097 | static const struct snd_kcontrol_new rt5670_if1_adc1_in1_mux = | ||
| 1098 | SOC_DAPM_ENUM("IF1 ADC1 IN1 source", rt5670_if1_adc1_in1_enum); | ||
| 1099 | |||
| 1100 | /* MX-FA [11] */ | ||
| 1101 | static const char * const rt5670_if1_adc1_in2_src[] = { | ||
| 1102 | "IF1_ADC1_IN1", "IF1_ADC4" | ||
| 1103 | }; | ||
| 1104 | |||
| 1105 | static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc1_in2_enum, RT5670_DIG_MISC, | ||
| 1106 | RT5670_IF1_ADC1_IN2_SFT, rt5670_if1_adc1_in2_src); | ||
| 1107 | |||
| 1108 | static const struct snd_kcontrol_new rt5670_if1_adc1_in2_mux = | ||
| 1109 | SOC_DAPM_ENUM("IF1 ADC1 IN2 source", rt5670_if1_adc1_in2_enum); | ||
| 1110 | |||
| 1111 | /* MX-FA [10] */ | ||
| 1112 | static const char * const rt5670_if1_adc2_in1_src[] = { | ||
| 1113 | "IF1_ADC2_IN", "IF1_ADC4" | ||
| 1114 | }; | ||
| 1115 | |||
| 1116 | static SOC_ENUM_SINGLE_DECL(rt5670_if1_adc2_in1_enum, RT5670_DIG_MISC, | ||
| 1117 | RT5670_IF1_ADC2_IN1_SFT, rt5670_if1_adc2_in1_src); | ||
| 1118 | |||
| 1119 | static const struct snd_kcontrol_new rt5670_if1_adc2_in1_mux = | ||
| 1120 | SOC_DAPM_ENUM("IF1 ADC2 IN1 source", rt5670_if1_adc2_in1_enum); | ||
| 1121 | |||
| 1122 | /* MX-9D [9:8] */ | ||
| 1123 | static const char * const rt5670_vad_adc_src[] = { | ||
| 1124 | "Sto1 ADC L", "Mono ADC L", "Mono ADC R", "Sto2 ADC L" | ||
| 1125 | }; | ||
| 1126 | |||
| 1127 | static SOC_ENUM_SINGLE_DECL(rt5670_vad_adc_enum, RT5670_VAD_CTRL4, | ||
| 1128 | RT5670_VAD_SEL_SFT, rt5670_vad_adc_src); | ||
| 1129 | |||
| 1130 | static const struct snd_kcontrol_new rt5670_vad_adc_mux = | ||
| 1131 | SOC_DAPM_ENUM("VAD ADC source", rt5670_vad_adc_enum); | ||
| 1132 | |||
| 1133 | static int rt5670_hp_power_event(struct snd_soc_dapm_widget *w, | ||
| 1134 | struct snd_kcontrol *kcontrol, int event) | ||
| 1135 | { | ||
| 1136 | struct snd_soc_codec *codec = w->codec; | ||
| 1137 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 1138 | |||
| 1139 | switch (event) { | ||
| 1140 | case SND_SOC_DAPM_POST_PMU: | ||
| 1141 | regmap_update_bits(rt5670->regmap, RT5670_CHARGE_PUMP, | ||
| 1142 | RT5670_PM_HP_MASK, RT5670_PM_HP_HV); | ||
| 1143 | regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, | ||
| 1144 | 0x0400, 0x0400); | ||
| 1145 | /* headphone amp power on */ | ||
| 1146 | regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, | ||
| 1147 | RT5670_PWR_HA | RT5670_PWR_FV1 | | ||
| 1148 | RT5670_PWR_FV2, RT5670_PWR_HA | | ||
| 1149 | RT5670_PWR_FV1 | RT5670_PWR_FV2); | ||
| 1150 | /* depop parameters */ | ||
| 1151 | regmap_write(rt5670->regmap, RT5670_DEPOP_M2, 0x3100); | ||
| 1152 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8009); | ||
| 1153 | regmap_write(rt5670->regmap, RT5670_PR_BASE + | ||
| 1154 | RT5670_HP_DCC_INT1, 0x9f00); | ||
| 1155 | mdelay(20); | ||
| 1156 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); | ||
| 1157 | break; | ||
| 1158 | case SND_SOC_DAPM_PRE_PMD: | ||
| 1159 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x0004); | ||
| 1160 | msleep(30); | ||
| 1161 | break; | ||
| 1162 | default: | ||
| 1163 | return 0; | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | return 0; | ||
| 1167 | } | ||
| 1168 | |||
| 1169 | static int rt5670_hp_event(struct snd_soc_dapm_widget *w, | ||
| 1170 | struct snd_kcontrol *kcontrol, int event) | ||
| 1171 | { | ||
| 1172 | struct snd_soc_codec *codec = w->codec; | ||
| 1173 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 1174 | |||
| 1175 | switch (event) { | ||
| 1176 | case SND_SOC_DAPM_POST_PMU: | ||
| 1177 | /* headphone unmute sequence */ | ||
| 1178 | regmap_write(rt5670->regmap, RT5670_PR_BASE + | ||
| 1179 | RT5670_MAMP_INT_REG2, 0xb400); | ||
| 1180 | regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); | ||
| 1181 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x805d); | ||
| 1182 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); | ||
| 1183 | regmap_update_bits(rt5670->regmap, RT5670_GEN_CTRL2, | ||
| 1184 | 0x0300, 0x0300); | ||
| 1185 | regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, | ||
| 1186 | RT5670_L_MUTE | RT5670_R_MUTE, 0); | ||
| 1187 | msleep(80); | ||
| 1188 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); | ||
| 1189 | break; | ||
| 1190 | |||
| 1191 | case SND_SOC_DAPM_PRE_PMD: | ||
| 1192 | /* headphone mute sequence */ | ||
| 1193 | regmap_write(rt5670->regmap, RT5670_PR_BASE + | ||
| 1194 | RT5670_MAMP_INT_REG2, 0xb400); | ||
| 1195 | regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0772); | ||
| 1196 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x803d); | ||
| 1197 | mdelay(10); | ||
| 1198 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x831d); | ||
| 1199 | mdelay(10); | ||
| 1200 | regmap_update_bits(rt5670->regmap, RT5670_HP_VOL, | ||
| 1201 | RT5670_L_MUTE | RT5670_R_MUTE, | ||
| 1202 | RT5670_L_MUTE | RT5670_R_MUTE); | ||
| 1203 | msleep(20); | ||
| 1204 | regmap_update_bits(rt5670->regmap, | ||
| 1205 | RT5670_GEN_CTRL2, 0x0300, 0x0); | ||
| 1206 | regmap_write(rt5670->regmap, RT5670_DEPOP_M1, 0x8019); | ||
| 1207 | regmap_write(rt5670->regmap, RT5670_DEPOP_M3, 0x0707); | ||
| 1208 | regmap_write(rt5670->regmap, RT5670_PR_BASE + | ||
| 1209 | RT5670_MAMP_INT_REG2, 0xfc00); | ||
| 1210 | break; | ||
| 1211 | |||
| 1212 | default: | ||
| 1213 | return 0; | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | return 0; | ||
| 1217 | } | ||
| 1218 | |||
| 1219 | static int rt5670_bst1_event(struct snd_soc_dapm_widget *w, | ||
| 1220 | struct snd_kcontrol *kcontrol, int event) | ||
| 1221 | { | ||
| 1222 | struct snd_soc_codec *codec = w->codec; | ||
| 1223 | |||
| 1224 | switch (event) { | ||
| 1225 | case SND_SOC_DAPM_POST_PMU: | ||
| 1226 | snd_soc_update_bits(codec, RT5670_PWR_ANLG2, | ||
| 1227 | RT5670_PWR_BST1_P, RT5670_PWR_BST1_P); | ||
| 1228 | break; | ||
| 1229 | |||
| 1230 | case SND_SOC_DAPM_PRE_PMD: | ||
| 1231 | snd_soc_update_bits(codec, RT5670_PWR_ANLG2, | ||
| 1232 | RT5670_PWR_BST1_P, 0); | ||
| 1233 | break; | ||
| 1234 | |||
| 1235 | default: | ||
| 1236 | return 0; | ||
| 1237 | } | ||
| 1238 | |||
| 1239 | return 0; | ||
| 1240 | } | ||
| 1241 | |||
| 1242 | static int rt5670_bst2_event(struct snd_soc_dapm_widget *w, | ||
| 1243 | struct snd_kcontrol *kcontrol, int event) | ||
| 1244 | { | ||
| 1245 | struct snd_soc_codec *codec = w->codec; | ||
| 1246 | |||
| 1247 | switch (event) { | ||
| 1248 | case SND_SOC_DAPM_POST_PMU: | ||
| 1249 | snd_soc_update_bits(codec, RT5670_PWR_ANLG2, | ||
| 1250 | RT5670_PWR_BST2_P, RT5670_PWR_BST2_P); | ||
| 1251 | break; | ||
| 1252 | |||
| 1253 | case SND_SOC_DAPM_PRE_PMD: | ||
| 1254 | snd_soc_update_bits(codec, RT5670_PWR_ANLG2, | ||
| 1255 | RT5670_PWR_BST2_P, 0); | ||
| 1256 | break; | ||
| 1257 | |||
| 1258 | default: | ||
| 1259 | return 0; | ||
| 1260 | } | ||
| 1261 | |||
| 1262 | return 0; | ||
| 1263 | } | ||
| 1264 | |||
| 1265 | static const struct snd_soc_dapm_widget rt5670_dapm_widgets[] = { | ||
| 1266 | SND_SOC_DAPM_SUPPLY("PLL1", RT5670_PWR_ANLG2, | ||
| 1267 | RT5670_PWR_PLL_BIT, 0, NULL, 0), | ||
| 1268 | SND_SOC_DAPM_SUPPLY("I2S DSP", RT5670_PWR_DIG2, | ||
| 1269 | RT5670_PWR_I2S_DSP_BIT, 0, NULL, 0), | ||
| 1270 | SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5670_PWR_VOL, | ||
| 1271 | RT5670_PWR_MIC_DET_BIT, 0, NULL, 0), | ||
| 1272 | |||
| 1273 | /* ASRC */ | ||
| 1274 | SND_SOC_DAPM_SUPPLY_S("I2S1 ASRC", 1, RT5670_ASRC_1, | ||
| 1275 | 11, 0, NULL, 0), | ||
| 1276 | SND_SOC_DAPM_SUPPLY_S("I2S2 ASRC", 1, RT5670_ASRC_1, | ||
| 1277 | 12, 0, NULL, 0), | ||
| 1278 | SND_SOC_DAPM_SUPPLY_S("DAC STO ASRC", 1, RT5670_ASRC_1, | ||
| 1279 | 10, 0, NULL, 0), | ||
| 1280 | SND_SOC_DAPM_SUPPLY_S("DAC MONO L ASRC", 1, RT5670_ASRC_1, | ||
| 1281 | 9, 0, NULL, 0), | ||
| 1282 | SND_SOC_DAPM_SUPPLY_S("DAC MONO R ASRC", 1, RT5670_ASRC_1, | ||
| 1283 | 8, 0, NULL, 0), | ||
| 1284 | SND_SOC_DAPM_SUPPLY_S("ADC STO1 ASRC", 1, RT5670_ASRC_1, | ||
| 1285 | 3, 0, NULL, 0), | ||
| 1286 | SND_SOC_DAPM_SUPPLY_S("ADC STO2 ASRC", 1, RT5670_ASRC_1, | ||
| 1287 | 2, 0, NULL, 0), | ||
| 1288 | SND_SOC_DAPM_SUPPLY_S("ADC MONO L ASRC", 1, RT5670_ASRC_1, | ||
| 1289 | 1, 0, NULL, 0), | ||
| 1290 | SND_SOC_DAPM_SUPPLY_S("ADC MONO R ASRC", 1, RT5670_ASRC_1, | ||
| 1291 | 0, 0, NULL, 0), | ||
| 1292 | |||
| 1293 | /* Input Side */ | ||
| 1294 | /* micbias */ | ||
| 1295 | SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5670_PWR_ANLG2, | ||
| 1296 | RT5670_PWR_MB1_BIT, 0, NULL, 0), | ||
| 1297 | |||
| 1298 | /* Input Lines */ | ||
| 1299 | SND_SOC_DAPM_INPUT("DMIC L1"), | ||
| 1300 | SND_SOC_DAPM_INPUT("DMIC R1"), | ||
| 1301 | SND_SOC_DAPM_INPUT("DMIC L2"), | ||
| 1302 | SND_SOC_DAPM_INPUT("DMIC R2"), | ||
| 1303 | SND_SOC_DAPM_INPUT("DMIC L3"), | ||
| 1304 | SND_SOC_DAPM_INPUT("DMIC R3"), | ||
| 1305 | |||
| 1306 | SND_SOC_DAPM_INPUT("IN1P"), | ||
| 1307 | SND_SOC_DAPM_INPUT("IN1N"), | ||
| 1308 | SND_SOC_DAPM_INPUT("IN2P"), | ||
| 1309 | SND_SOC_DAPM_INPUT("IN2N"), | ||
| 1310 | |||
| 1311 | SND_SOC_DAPM_PGA("DMIC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1312 | SND_SOC_DAPM_PGA("DMIC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1313 | SND_SOC_DAPM_PGA("DMIC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1314 | |||
| 1315 | SND_SOC_DAPM_SUPPLY("DMIC CLK", SND_SOC_NOPM, 0, 0, | ||
| 1316 | set_dmic_clk, SND_SOC_DAPM_PRE_PMU), | ||
| 1317 | SND_SOC_DAPM_SUPPLY("DMIC1 Power", RT5670_DMIC_CTRL1, | ||
| 1318 | RT5670_DMIC_1_EN_SFT, 0, NULL, 0), | ||
| 1319 | SND_SOC_DAPM_SUPPLY("DMIC2 Power", RT5670_DMIC_CTRL1, | ||
| 1320 | RT5670_DMIC_2_EN_SFT, 0, NULL, 0), | ||
| 1321 | SND_SOC_DAPM_SUPPLY("DMIC3 Power", RT5670_DMIC_CTRL1, | ||
| 1322 | RT5670_DMIC_3_EN_SFT, 0, NULL, 0), | ||
| 1323 | /* Boost */ | ||
| 1324 | SND_SOC_DAPM_PGA_E("BST1", RT5670_PWR_ANLG2, RT5670_PWR_BST1_BIT, | ||
| 1325 | 0, NULL, 0, rt5670_bst1_event, | ||
| 1326 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
| 1327 | SND_SOC_DAPM_PGA_E("BST2", RT5670_PWR_ANLG2, RT5670_PWR_BST2_BIT, | ||
| 1328 | 0, NULL, 0, rt5670_bst2_event, | ||
| 1329 | SND_SOC_DAPM_PRE_PMD | SND_SOC_DAPM_POST_PMU), | ||
| 1330 | /* Input Volume */ | ||
| 1331 | SND_SOC_DAPM_PGA("INL VOL", RT5670_PWR_VOL, | ||
| 1332 | RT5670_PWR_IN_L_BIT, 0, NULL, 0), | ||
| 1333 | SND_SOC_DAPM_PGA("INR VOL", RT5670_PWR_VOL, | ||
| 1334 | RT5670_PWR_IN_R_BIT, 0, NULL, 0), | ||
| 1335 | |||
| 1336 | /* REC Mixer */ | ||
| 1337 | SND_SOC_DAPM_MIXER("RECMIXL", RT5670_PWR_MIXER, RT5670_PWR_RM_L_BIT, 0, | ||
| 1338 | rt5670_rec_l_mix, ARRAY_SIZE(rt5670_rec_l_mix)), | ||
| 1339 | SND_SOC_DAPM_MIXER("RECMIXR", RT5670_PWR_MIXER, RT5670_PWR_RM_R_BIT, 0, | ||
| 1340 | rt5670_rec_r_mix, ARRAY_SIZE(rt5670_rec_r_mix)), | ||
| 1341 | /* ADCs */ | ||
| 1342 | SND_SOC_DAPM_ADC("ADC 1", NULL, SND_SOC_NOPM, 0, 0), | ||
| 1343 | SND_SOC_DAPM_ADC("ADC 2", NULL, SND_SOC_NOPM, 0, 0), | ||
| 1344 | |||
| 1345 | SND_SOC_DAPM_PGA("ADC 1_2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1346 | |||
| 1347 | SND_SOC_DAPM_SUPPLY("ADC 1 power", RT5670_PWR_DIG1, | ||
| 1348 | RT5670_PWR_ADC_L_BIT, 0, NULL, 0), | ||
| 1349 | SND_SOC_DAPM_SUPPLY("ADC 2 power", RT5670_PWR_DIG1, | ||
| 1350 | RT5670_PWR_ADC_R_BIT, 0, NULL, 0), | ||
| 1351 | SND_SOC_DAPM_SUPPLY("ADC clock", RT5670_PR_BASE + | ||
| 1352 | RT5670_CHOP_DAC_ADC, 12, 0, NULL, 0), | ||
| 1353 | /* ADC Mux */ | ||
| 1354 | SND_SOC_DAPM_MUX("Stereo1 DMIC Mux", SND_SOC_NOPM, 0, 0, | ||
| 1355 | &rt5670_sto1_dmic_mux), | ||
| 1356 | SND_SOC_DAPM_MUX("Stereo1 ADC L2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1357 | &rt5670_sto_adc_l2_mux), | ||
| 1358 | SND_SOC_DAPM_MUX("Stereo1 ADC R2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1359 | &rt5670_sto_adc_r2_mux), | ||
| 1360 | SND_SOC_DAPM_MUX("Stereo1 ADC L1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1361 | &rt5670_sto_adc_l1_mux), | ||
| 1362 | SND_SOC_DAPM_MUX("Stereo1 ADC R1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1363 | &rt5670_sto_adc_r1_mux), | ||
| 1364 | SND_SOC_DAPM_MUX("Stereo2 DMIC Mux", SND_SOC_NOPM, 0, 0, | ||
| 1365 | &rt5670_sto2_dmic_mux), | ||
| 1366 | SND_SOC_DAPM_MUX("Stereo2 ADC L2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1367 | &rt5670_sto2_adc_l2_mux), | ||
| 1368 | SND_SOC_DAPM_MUX("Stereo2 ADC R2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1369 | &rt5670_sto2_adc_r2_mux), | ||
| 1370 | SND_SOC_DAPM_MUX("Stereo2 ADC L1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1371 | &rt5670_sto2_adc_l1_mux), | ||
| 1372 | SND_SOC_DAPM_MUX("Stereo2 ADC R1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1373 | &rt5670_sto2_adc_r1_mux), | ||
| 1374 | SND_SOC_DAPM_MUX("Stereo2 ADC LR Mux", SND_SOC_NOPM, 0, 0, | ||
| 1375 | &rt5670_sto2_adc_lr_mux), | ||
| 1376 | SND_SOC_DAPM_MUX("Mono DMIC L Mux", SND_SOC_NOPM, 0, 0, | ||
| 1377 | &rt5670_mono_dmic_l_mux), | ||
| 1378 | SND_SOC_DAPM_MUX("Mono DMIC R Mux", SND_SOC_NOPM, 0, 0, | ||
| 1379 | &rt5670_mono_dmic_r_mux), | ||
| 1380 | SND_SOC_DAPM_MUX("Mono ADC L2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1381 | &rt5670_mono_adc_l2_mux), | ||
| 1382 | SND_SOC_DAPM_MUX("Mono ADC L1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1383 | &rt5670_mono_adc_l1_mux), | ||
| 1384 | SND_SOC_DAPM_MUX("Mono ADC R1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1385 | &rt5670_mono_adc_r1_mux), | ||
| 1386 | SND_SOC_DAPM_MUX("Mono ADC R2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1387 | &rt5670_mono_adc_r2_mux), | ||
| 1388 | /* ADC Mixer */ | ||
| 1389 | SND_SOC_DAPM_SUPPLY("ADC Stereo1 Filter", RT5670_PWR_DIG2, | ||
| 1390 | RT5670_PWR_ADC_S1F_BIT, 0, NULL, 0), | ||
| 1391 | SND_SOC_DAPM_SUPPLY("ADC Stereo2 Filter", RT5670_PWR_DIG2, | ||
| 1392 | RT5670_PWR_ADC_S2F_BIT, 0, NULL, 0), | ||
| 1393 | SND_SOC_DAPM_MIXER("Sto1 ADC MIXL", RT5670_STO1_ADC_DIG_VOL, | ||
| 1394 | RT5670_L_MUTE_SFT, 1, rt5670_sto1_adc_l_mix, | ||
| 1395 | ARRAY_SIZE(rt5670_sto1_adc_l_mix)), | ||
| 1396 | SND_SOC_DAPM_MIXER("Sto1 ADC MIXR", RT5670_STO1_ADC_DIG_VOL, | ||
| 1397 | RT5670_R_MUTE_SFT, 1, rt5670_sto1_adc_r_mix, | ||
| 1398 | ARRAY_SIZE(rt5670_sto1_adc_r_mix)), | ||
| 1399 | SND_SOC_DAPM_MIXER("Sto2 ADC MIXL", SND_SOC_NOPM, 0, 0, | ||
| 1400 | rt5670_sto2_adc_l_mix, | ||
| 1401 | ARRAY_SIZE(rt5670_sto2_adc_l_mix)), | ||
| 1402 | SND_SOC_DAPM_MIXER("Sto2 ADC MIXR", SND_SOC_NOPM, 0, 0, | ||
| 1403 | rt5670_sto2_adc_r_mix, | ||
| 1404 | ARRAY_SIZE(rt5670_sto2_adc_r_mix)), | ||
| 1405 | SND_SOC_DAPM_SUPPLY("ADC Mono Left Filter", RT5670_PWR_DIG2, | ||
| 1406 | RT5670_PWR_ADC_MF_L_BIT, 0, NULL, 0), | ||
| 1407 | SND_SOC_DAPM_MIXER("Mono ADC MIXL", RT5670_MONO_ADC_DIG_VOL, | ||
| 1408 | RT5670_L_MUTE_SFT, 1, rt5670_mono_adc_l_mix, | ||
| 1409 | ARRAY_SIZE(rt5670_mono_adc_l_mix)), | ||
| 1410 | SND_SOC_DAPM_SUPPLY("ADC Mono Right Filter", RT5670_PWR_DIG2, | ||
| 1411 | RT5670_PWR_ADC_MF_R_BIT, 0, NULL, 0), | ||
| 1412 | SND_SOC_DAPM_MIXER("Mono ADC MIXR", RT5670_MONO_ADC_DIG_VOL, | ||
| 1413 | RT5670_R_MUTE_SFT, 1, rt5670_mono_adc_r_mix, | ||
| 1414 | ARRAY_SIZE(rt5670_mono_adc_r_mix)), | ||
| 1415 | |||
| 1416 | /* ADC PGA */ | ||
| 1417 | SND_SOC_DAPM_PGA("Stereo1 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1418 | SND_SOC_DAPM_PGA("Stereo1 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1419 | SND_SOC_DAPM_PGA("Stereo2 ADC MIXL", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1420 | SND_SOC_DAPM_PGA("Stereo2 ADC MIXR", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1421 | SND_SOC_DAPM_PGA("Sto2 ADC LR MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1422 | SND_SOC_DAPM_PGA("Stereo1 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1423 | SND_SOC_DAPM_PGA("Stereo2 ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1424 | SND_SOC_DAPM_PGA("Mono ADC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1425 | SND_SOC_DAPM_PGA("VAD_ADC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1426 | SND_SOC_DAPM_PGA("IF_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1427 | SND_SOC_DAPM_PGA("IF_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1428 | SND_SOC_DAPM_PGA("IF_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1429 | SND_SOC_DAPM_PGA("IF1_ADC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1430 | SND_SOC_DAPM_PGA("IF1_ADC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1431 | SND_SOC_DAPM_PGA("IF1_ADC3", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1432 | SND_SOC_DAPM_PGA("IF1_ADC4", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1433 | |||
| 1434 | /* DSP */ | ||
| 1435 | SND_SOC_DAPM_PGA("TxDP_ADC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1436 | SND_SOC_DAPM_PGA("TxDP_ADC_L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1437 | SND_SOC_DAPM_PGA("TxDP_ADC_R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1438 | SND_SOC_DAPM_PGA("TxDC_DAC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1439 | |||
| 1440 | SND_SOC_DAPM_MUX("TDM Data Mux", SND_SOC_NOPM, 0, 0, | ||
| 1441 | &rt5670_txdp_slot_mux), | ||
| 1442 | |||
| 1443 | SND_SOC_DAPM_MUX("DSP UL Mux", SND_SOC_NOPM, 0, 0, | ||
| 1444 | &rt5670_dsp_ul_mux), | ||
| 1445 | SND_SOC_DAPM_MUX("DSP DL Mux", SND_SOC_NOPM, 0, 0, | ||
| 1446 | &rt5670_dsp_dl_mux), | ||
| 1447 | |||
| 1448 | SND_SOC_DAPM_MUX("RxDP Mux", SND_SOC_NOPM, 0, 0, | ||
| 1449 | &rt5670_rxdp_mux), | ||
| 1450 | |||
| 1451 | /* IF2 Mux */ | ||
| 1452 | SND_SOC_DAPM_MUX("IF2 ADC Mux", SND_SOC_NOPM, 0, 0, | ||
| 1453 | &rt5670_if2_adc_in_mux), | ||
| 1454 | |||
| 1455 | /* Digital Interface */ | ||
| 1456 | SND_SOC_DAPM_SUPPLY("I2S1", RT5670_PWR_DIG1, | ||
| 1457 | RT5670_PWR_I2S1_BIT, 0, NULL, 0), | ||
| 1458 | SND_SOC_DAPM_PGA("IF1 DAC1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1459 | SND_SOC_DAPM_PGA("IF1 DAC2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1460 | SND_SOC_DAPM_PGA("IF1 DAC1 L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1461 | SND_SOC_DAPM_PGA("IF1 DAC1 R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1462 | SND_SOC_DAPM_PGA("IF1 DAC2 L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1463 | SND_SOC_DAPM_PGA("IF1 DAC2 R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1464 | SND_SOC_DAPM_PGA("IF1 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1465 | SND_SOC_DAPM_PGA("IF1 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1466 | SND_SOC_DAPM_PGA("IF1 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1467 | SND_SOC_DAPM_SUPPLY("I2S2", RT5670_PWR_DIG1, | ||
| 1468 | RT5670_PWR_I2S2_BIT, 0, NULL, 0), | ||
| 1469 | SND_SOC_DAPM_PGA("IF2 DAC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1470 | SND_SOC_DAPM_PGA("IF2 DAC L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1471 | SND_SOC_DAPM_PGA("IF2 DAC R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1472 | SND_SOC_DAPM_PGA("IF2 ADC", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1473 | SND_SOC_DAPM_PGA("IF2 ADC L", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1474 | SND_SOC_DAPM_PGA("IF2 ADC R", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1475 | |||
| 1476 | /* Digital Interface Select */ | ||
| 1477 | SND_SOC_DAPM_MUX("IF1 ADC1 IN1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1478 | &rt5670_if1_adc1_in1_mux), | ||
| 1479 | SND_SOC_DAPM_MUX("IF1 ADC1 IN2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1480 | &rt5670_if1_adc1_in2_mux), | ||
| 1481 | SND_SOC_DAPM_MUX("IF1 ADC2 IN Mux", SND_SOC_NOPM, 0, 0, | ||
| 1482 | &rt5670_if1_adc2_in_mux), | ||
| 1483 | SND_SOC_DAPM_MUX("IF1 ADC2 IN1 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1484 | &rt5670_if1_adc2_in1_mux), | ||
| 1485 | SND_SOC_DAPM_MUX("VAD ADC Mux", SND_SOC_NOPM, 0, 0, | ||
| 1486 | &rt5670_vad_adc_mux), | ||
| 1487 | |||
| 1488 | /* Audio Interface */ | ||
| 1489 | SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
| 1490 | SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
| 1491 | SND_SOC_DAPM_AIF_IN("AIF2RX", "AIF2 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
| 1492 | SND_SOC_DAPM_AIF_OUT("AIF2TX", "AIF2 Capture", 0, | ||
| 1493 | RT5670_GPIO_CTRL1, RT5670_I2S2_PIN_SFT, 1), | ||
| 1494 | |||
| 1495 | /* Audio DSP */ | ||
| 1496 | SND_SOC_DAPM_PGA("Audio DSP", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1497 | |||
| 1498 | /* Output Side */ | ||
| 1499 | /* DAC mixer before sound effect */ | ||
| 1500 | SND_SOC_DAPM_MIXER("DAC1 MIXL", SND_SOC_NOPM, 0, 0, | ||
| 1501 | rt5670_dac_l_mix, ARRAY_SIZE(rt5670_dac_l_mix)), | ||
| 1502 | SND_SOC_DAPM_MIXER("DAC1 MIXR", SND_SOC_NOPM, 0, 0, | ||
| 1503 | rt5670_dac_r_mix, ARRAY_SIZE(rt5670_dac_r_mix)), | ||
| 1504 | SND_SOC_DAPM_PGA("DAC MIX", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1505 | |||
| 1506 | /* DAC2 channel Mux */ | ||
| 1507 | SND_SOC_DAPM_MUX("DAC L2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1508 | &rt5670_dac_l2_mux), | ||
| 1509 | SND_SOC_DAPM_MUX("DAC R2 Mux", SND_SOC_NOPM, 0, 0, | ||
| 1510 | &rt5670_dac_r2_mux), | ||
| 1511 | SND_SOC_DAPM_PGA("DAC L2 Volume", RT5670_PWR_DIG1, | ||
| 1512 | RT5670_PWR_DAC_L2_BIT, 0, NULL, 0), | ||
| 1513 | SND_SOC_DAPM_PGA("DAC R2 Volume", RT5670_PWR_DIG1, | ||
| 1514 | RT5670_PWR_DAC_R2_BIT, 0, NULL, 0), | ||
| 1515 | |||
| 1516 | SND_SOC_DAPM_MUX("DAC1 L Mux", SND_SOC_NOPM, 0, 0, &rt5670_dac1l_mux), | ||
| 1517 | SND_SOC_DAPM_MUX("DAC1 R Mux", SND_SOC_NOPM, 0, 0, &rt5670_dac1r_mux), | ||
| 1518 | |||
| 1519 | /* DAC Mixer */ | ||
| 1520 | SND_SOC_DAPM_SUPPLY("DAC Stereo1 Filter", RT5670_PWR_DIG2, | ||
| 1521 | RT5670_PWR_DAC_S1F_BIT, 0, NULL, 0), | ||
| 1522 | SND_SOC_DAPM_SUPPLY("DAC Mono Left Filter", RT5670_PWR_DIG2, | ||
| 1523 | RT5670_PWR_DAC_MF_L_BIT, 0, NULL, 0), | ||
| 1524 | SND_SOC_DAPM_SUPPLY("DAC Mono Right Filter", RT5670_PWR_DIG2, | ||
| 1525 | RT5670_PWR_DAC_MF_R_BIT, 0, NULL, 0), | ||
| 1526 | SND_SOC_DAPM_MIXER("Stereo DAC MIXL", SND_SOC_NOPM, 0, 0, | ||
| 1527 | rt5670_sto_dac_l_mix, | ||
| 1528 | ARRAY_SIZE(rt5670_sto_dac_l_mix)), | ||
| 1529 | SND_SOC_DAPM_MIXER("Stereo DAC MIXR", SND_SOC_NOPM, 0, 0, | ||
| 1530 | rt5670_sto_dac_r_mix, | ||
| 1531 | ARRAY_SIZE(rt5670_sto_dac_r_mix)), | ||
| 1532 | SND_SOC_DAPM_MIXER("Mono DAC MIXL", SND_SOC_NOPM, 0, 0, | ||
| 1533 | rt5670_mono_dac_l_mix, | ||
| 1534 | ARRAY_SIZE(rt5670_mono_dac_l_mix)), | ||
| 1535 | SND_SOC_DAPM_MIXER("Mono DAC MIXR", SND_SOC_NOPM, 0, 0, | ||
| 1536 | rt5670_mono_dac_r_mix, | ||
| 1537 | ARRAY_SIZE(rt5670_mono_dac_r_mix)), | ||
| 1538 | SND_SOC_DAPM_MIXER("DAC MIXL", SND_SOC_NOPM, 0, 0, | ||
| 1539 | rt5670_dig_l_mix, | ||
| 1540 | ARRAY_SIZE(rt5670_dig_l_mix)), | ||
| 1541 | SND_SOC_DAPM_MIXER("DAC MIXR", SND_SOC_NOPM, 0, 0, | ||
| 1542 | rt5670_dig_r_mix, | ||
| 1543 | ARRAY_SIZE(rt5670_dig_r_mix)), | ||
| 1544 | |||
| 1545 | /* DACs */ | ||
| 1546 | SND_SOC_DAPM_SUPPLY("DAC L1 Power", RT5670_PWR_DIG1, | ||
| 1547 | RT5670_PWR_DAC_L1_BIT, 0, NULL, 0), | ||
| 1548 | SND_SOC_DAPM_SUPPLY("DAC R1 Power", RT5670_PWR_DIG1, | ||
| 1549 | RT5670_PWR_DAC_R1_BIT, 0, NULL, 0), | ||
| 1550 | SND_SOC_DAPM_DAC("DAC L1", NULL, SND_SOC_NOPM, 0, 0), | ||
| 1551 | SND_SOC_DAPM_DAC("DAC R1", NULL, SND_SOC_NOPM, 0, 0), | ||
| 1552 | SND_SOC_DAPM_DAC("DAC L2", NULL, RT5670_PWR_DIG1, | ||
| 1553 | RT5670_PWR_DAC_L2_BIT, 0), | ||
| 1554 | |||
| 1555 | SND_SOC_DAPM_DAC("DAC R2", NULL, RT5670_PWR_DIG1, | ||
| 1556 | RT5670_PWR_DAC_R2_BIT, 0), | ||
| 1557 | /* OUT Mixer */ | ||
| 1558 | |||
| 1559 | SND_SOC_DAPM_MIXER("OUT MIXL", RT5670_PWR_MIXER, RT5670_PWR_OM_L_BIT, | ||
| 1560 | 0, rt5670_out_l_mix, ARRAY_SIZE(rt5670_out_l_mix)), | ||
| 1561 | SND_SOC_DAPM_MIXER("OUT MIXR", RT5670_PWR_MIXER, RT5670_PWR_OM_R_BIT, | ||
| 1562 | 0, rt5670_out_r_mix, ARRAY_SIZE(rt5670_out_r_mix)), | ||
| 1563 | /* Ouput Volume */ | ||
| 1564 | SND_SOC_DAPM_MIXER("HPOVOL MIXL", RT5670_PWR_VOL, | ||
| 1565 | RT5670_PWR_HV_L_BIT, 0, | ||
| 1566 | rt5670_hpvoll_mix, ARRAY_SIZE(rt5670_hpvoll_mix)), | ||
| 1567 | SND_SOC_DAPM_MIXER("HPOVOL MIXR", RT5670_PWR_VOL, | ||
| 1568 | RT5670_PWR_HV_R_BIT, 0, | ||
| 1569 | rt5670_hpvolr_mix, ARRAY_SIZE(rt5670_hpvolr_mix)), | ||
| 1570 | SND_SOC_DAPM_PGA("DAC 1", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1571 | SND_SOC_DAPM_PGA("DAC 2", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1572 | SND_SOC_DAPM_PGA("HPOVOL", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1573 | |||
| 1574 | /* HPO/LOUT/Mono Mixer */ | ||
| 1575 | SND_SOC_DAPM_MIXER("HPO MIX", SND_SOC_NOPM, 0, 0, | ||
| 1576 | rt5670_hpo_mix, ARRAY_SIZE(rt5670_hpo_mix)), | ||
| 1577 | SND_SOC_DAPM_MIXER("LOUT MIX", RT5670_PWR_ANLG1, RT5670_PWR_LM_BIT, | ||
| 1578 | 0, rt5670_lout_mix, ARRAY_SIZE(rt5670_lout_mix)), | ||
| 1579 | SND_SOC_DAPM_SUPPLY_S("Improve HP Amp Drv", 1, SND_SOC_NOPM, 0, 0, | ||
| 1580 | rt5670_hp_power_event, SND_SOC_DAPM_POST_PMU | | ||
| 1581 | SND_SOC_DAPM_PRE_PMD), | ||
| 1582 | SND_SOC_DAPM_SUPPLY("HP L Amp", RT5670_PWR_ANLG1, | ||
| 1583 | RT5670_PWR_HP_L_BIT, 0, NULL, 0), | ||
| 1584 | SND_SOC_DAPM_SUPPLY("HP R Amp", RT5670_PWR_ANLG1, | ||
| 1585 | RT5670_PWR_HP_R_BIT, 0, NULL, 0), | ||
| 1586 | SND_SOC_DAPM_PGA_S("HP Amp", 1, SND_SOC_NOPM, 0, 0, | ||
| 1587 | rt5670_hp_event, SND_SOC_DAPM_PRE_PMD | | ||
| 1588 | SND_SOC_DAPM_POST_PMU), | ||
| 1589 | SND_SOC_DAPM_SWITCH("LOUT L Playback", SND_SOC_NOPM, 0, 0, | ||
| 1590 | &lout_l_enable_control), | ||
| 1591 | SND_SOC_DAPM_SWITCH("LOUT R Playback", SND_SOC_NOPM, 0, 0, | ||
| 1592 | &lout_r_enable_control), | ||
| 1593 | SND_SOC_DAPM_PGA("LOUT Amp", SND_SOC_NOPM, 0, 0, NULL, 0), | ||
| 1594 | |||
| 1595 | /* PDM */ | ||
| 1596 | SND_SOC_DAPM_SUPPLY("PDM1 Power", RT5670_PWR_DIG2, | ||
| 1597 | RT5670_PWR_PDM1_BIT, 0, NULL, 0), | ||
| 1598 | SND_SOC_DAPM_SUPPLY("PDM2 Power", RT5670_PWR_DIG2, | ||
| 1599 | RT5670_PWR_PDM2_BIT, 0, NULL, 0), | ||
| 1600 | |||
| 1601 | SND_SOC_DAPM_MUX("PDM1 L Mux", RT5670_PDM_OUT_CTRL, | ||
| 1602 | RT5670_M_PDM1_L_SFT, 1, &rt5670_pdm1_l_mux), | ||
| 1603 | SND_SOC_DAPM_MUX("PDM1 R Mux", RT5670_PDM_OUT_CTRL, | ||
| 1604 | RT5670_M_PDM1_R_SFT, 1, &rt5670_pdm1_r_mux), | ||
| 1605 | SND_SOC_DAPM_MUX("PDM2 L Mux", RT5670_PDM_OUT_CTRL, | ||
| 1606 | RT5670_M_PDM2_L_SFT, 1, &rt5670_pdm2_l_mux), | ||
| 1607 | SND_SOC_DAPM_MUX("PDM2 R Mux", RT5670_PDM_OUT_CTRL, | ||
| 1608 | RT5670_M_PDM2_R_SFT, 1, &rt5670_pdm2_r_mux), | ||
| 1609 | |||
| 1610 | /* Output Lines */ | ||
| 1611 | SND_SOC_DAPM_OUTPUT("HPOL"), | ||
| 1612 | SND_SOC_DAPM_OUTPUT("HPOR"), | ||
| 1613 | SND_SOC_DAPM_OUTPUT("LOUTL"), | ||
| 1614 | SND_SOC_DAPM_OUTPUT("LOUTR"), | ||
| 1615 | SND_SOC_DAPM_OUTPUT("PDM1L"), | ||
| 1616 | SND_SOC_DAPM_OUTPUT("PDM1R"), | ||
| 1617 | SND_SOC_DAPM_OUTPUT("PDM2L"), | ||
| 1618 | SND_SOC_DAPM_OUTPUT("PDM2R"), | ||
| 1619 | }; | ||
| 1620 | |||
| 1621 | static const struct snd_soc_dapm_route rt5670_dapm_routes[] = { | ||
| 1622 | { "ADC Stereo1 Filter", NULL, "ADC STO1 ASRC", is_using_asrc }, | ||
| 1623 | { "ADC Stereo2 Filter", NULL, "ADC STO2 ASRC", is_using_asrc }, | ||
| 1624 | { "ADC Mono Left Filter", NULL, "ADC MONO L ASRC", is_using_asrc }, | ||
| 1625 | { "ADC Mono Right Filter", NULL, "ADC MONO R ASRC", is_using_asrc }, | ||
| 1626 | { "DAC Mono Left Filter", NULL, "DAC MONO L ASRC", is_using_asrc }, | ||
| 1627 | { "DAC Mono Right Filter", NULL, "DAC MONO R ASRC", is_using_asrc }, | ||
| 1628 | { "DAC Stereo1 Filter", NULL, "DAC STO ASRC", is_using_asrc }, | ||
| 1629 | |||
| 1630 | { "I2S1", NULL, "I2S1 ASRC" }, | ||
| 1631 | { "I2S2", NULL, "I2S2 ASRC" }, | ||
| 1632 | |||
| 1633 | { "DMIC1", NULL, "DMIC L1" }, | ||
| 1634 | { "DMIC1", NULL, "DMIC R1" }, | ||
| 1635 | { "DMIC2", NULL, "DMIC L2" }, | ||
| 1636 | { "DMIC2", NULL, "DMIC R2" }, | ||
| 1637 | { "DMIC3", NULL, "DMIC L3" }, | ||
| 1638 | { "DMIC3", NULL, "DMIC R3" }, | ||
| 1639 | |||
| 1640 | { "BST1", NULL, "IN1P" }, | ||
| 1641 | { "BST1", NULL, "IN1N" }, | ||
| 1642 | { "BST1", NULL, "Mic Det Power" }, | ||
| 1643 | { "BST2", NULL, "IN2P" }, | ||
| 1644 | { "BST2", NULL, "IN2N" }, | ||
| 1645 | |||
| 1646 | { "INL VOL", NULL, "IN2P" }, | ||
| 1647 | { "INR VOL", NULL, "IN2N" }, | ||
| 1648 | |||
| 1649 | { "RECMIXL", "INL Switch", "INL VOL" }, | ||
| 1650 | { "RECMIXL", "BST2 Switch", "BST2" }, | ||
| 1651 | { "RECMIXL", "BST1 Switch", "BST1" }, | ||
| 1652 | |||
| 1653 | { "RECMIXR", "INR Switch", "INR VOL" }, | ||
| 1654 | { "RECMIXR", "BST2 Switch", "BST2" }, | ||
| 1655 | { "RECMIXR", "BST1 Switch", "BST1" }, | ||
| 1656 | |||
| 1657 | { "ADC 1", NULL, "RECMIXL" }, | ||
| 1658 | { "ADC 1", NULL, "ADC 1 power" }, | ||
| 1659 | { "ADC 1", NULL, "ADC clock" }, | ||
| 1660 | { "ADC 2", NULL, "RECMIXR" }, | ||
| 1661 | { "ADC 2", NULL, "ADC 2 power" }, | ||
| 1662 | { "ADC 2", NULL, "ADC clock" }, | ||
| 1663 | |||
| 1664 | { "DMIC L1", NULL, "DMIC CLK" }, | ||
| 1665 | { "DMIC L1", NULL, "DMIC1 Power" }, | ||
| 1666 | { "DMIC R1", NULL, "DMIC CLK" }, | ||
| 1667 | { "DMIC R1", NULL, "DMIC1 Power" }, | ||
| 1668 | { "DMIC L2", NULL, "DMIC CLK" }, | ||
| 1669 | { "DMIC L2", NULL, "DMIC2 Power" }, | ||
| 1670 | { "DMIC R2", NULL, "DMIC CLK" }, | ||
| 1671 | { "DMIC R2", NULL, "DMIC2 Power" }, | ||
| 1672 | { "DMIC L3", NULL, "DMIC CLK" }, | ||
| 1673 | { "DMIC L3", NULL, "DMIC3 Power" }, | ||
| 1674 | { "DMIC R3", NULL, "DMIC CLK" }, | ||
| 1675 | { "DMIC R3", NULL, "DMIC3 Power" }, | ||
| 1676 | |||
| 1677 | { "Stereo1 DMIC Mux", "DMIC1", "DMIC1" }, | ||
| 1678 | { "Stereo1 DMIC Mux", "DMIC2", "DMIC2" }, | ||
| 1679 | { "Stereo1 DMIC Mux", "DMIC3", "DMIC3" }, | ||
| 1680 | |||
| 1681 | { "Stereo2 DMIC Mux", "DMIC1", "DMIC1" }, | ||
| 1682 | { "Stereo2 DMIC Mux", "DMIC2", "DMIC2" }, | ||
| 1683 | { "Stereo2 DMIC Mux", "DMIC3", "DMIC3" }, | ||
| 1684 | |||
| 1685 | { "Mono DMIC L Mux", "DMIC1", "DMIC L1" }, | ||
| 1686 | { "Mono DMIC L Mux", "DMIC2", "DMIC L2" }, | ||
| 1687 | { "Mono DMIC L Mux", "DMIC3", "DMIC L3" }, | ||
| 1688 | |||
| 1689 | { "Mono DMIC R Mux", "DMIC1", "DMIC R1" }, | ||
| 1690 | { "Mono DMIC R Mux", "DMIC2", "DMIC R2" }, | ||
| 1691 | { "Mono DMIC R Mux", "DMIC3", "DMIC R3" }, | ||
| 1692 | |||
| 1693 | { "ADC 1_2", NULL, "ADC 1" }, | ||
| 1694 | { "ADC 1_2", NULL, "ADC 2" }, | ||
| 1695 | |||
| 1696 | { "Stereo1 ADC L2 Mux", "DMIC", "Stereo1 DMIC Mux" }, | ||
| 1697 | { "Stereo1 ADC L2 Mux", "DAC MIX", "DAC MIXL" }, | ||
| 1698 | { "Stereo1 ADC L1 Mux", "ADC", "ADC 1_2" }, | ||
| 1699 | { "Stereo1 ADC L1 Mux", "DAC MIX", "DAC MIXL" }, | ||
| 1700 | |||
| 1701 | { "Stereo1 ADC R1 Mux", "ADC", "ADC 1_2" }, | ||
| 1702 | { "Stereo1 ADC R1 Mux", "DAC MIX", "DAC MIXR" }, | ||
| 1703 | { "Stereo1 ADC R2 Mux", "DMIC", "Stereo1 DMIC Mux" }, | ||
| 1704 | { "Stereo1 ADC R2 Mux", "DAC MIX", "DAC MIXR" }, | ||
| 1705 | |||
| 1706 | { "Mono ADC L2 Mux", "DMIC", "Mono DMIC L Mux" }, | ||
| 1707 | { "Mono ADC L2 Mux", "Mono DAC MIXL", "Mono DAC MIXL" }, | ||
| 1708 | { "Mono ADC L1 Mux", "Mono DAC MIXL", "Mono DAC MIXL" }, | ||
| 1709 | { "Mono ADC L1 Mux", "ADC1", "ADC 1" }, | ||
| 1710 | |||
| 1711 | { "Mono ADC R1 Mux", "Mono DAC MIXR", "Mono DAC MIXR" }, | ||
| 1712 | { "Mono ADC R1 Mux", "ADC2", "ADC 2" }, | ||
| 1713 | { "Mono ADC R2 Mux", "DMIC", "Mono DMIC R Mux" }, | ||
| 1714 | { "Mono ADC R2 Mux", "Mono DAC MIXR", "Mono DAC MIXR" }, | ||
| 1715 | |||
| 1716 | { "Sto1 ADC MIXL", "ADC1 Switch", "Stereo1 ADC L1 Mux" }, | ||
| 1717 | { "Sto1 ADC MIXL", "ADC2 Switch", "Stereo1 ADC L2 Mux" }, | ||
| 1718 | { "Sto1 ADC MIXR", "ADC1 Switch", "Stereo1 ADC R1 Mux" }, | ||
| 1719 | { "Sto1 ADC MIXR", "ADC2 Switch", "Stereo1 ADC R2 Mux" }, | ||
| 1720 | |||
| 1721 | { "Stereo1 ADC MIXL", NULL, "Sto1 ADC MIXL" }, | ||
| 1722 | { "Stereo1 ADC MIXL", NULL, "ADC Stereo1 Filter" }, | ||
| 1723 | { "ADC Stereo1 Filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1724 | |||
| 1725 | { "Stereo1 ADC MIXR", NULL, "Sto1 ADC MIXR" }, | ||
| 1726 | { "Stereo1 ADC MIXR", NULL, "ADC Stereo1 Filter" }, | ||
| 1727 | { "ADC Stereo1 Filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1728 | |||
| 1729 | { "Mono ADC MIXL", "ADC1 Switch", "Mono ADC L1 Mux" }, | ||
| 1730 | { "Mono ADC MIXL", "ADC2 Switch", "Mono ADC L2 Mux" }, | ||
| 1731 | { "Mono ADC MIXL", NULL, "ADC Mono Left Filter" }, | ||
| 1732 | { "ADC Mono Left Filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1733 | |||
| 1734 | { "Mono ADC MIXR", "ADC1 Switch", "Mono ADC R1 Mux" }, | ||
| 1735 | { "Mono ADC MIXR", "ADC2 Switch", "Mono ADC R2 Mux" }, | ||
| 1736 | { "Mono ADC MIXR", NULL, "ADC Mono Right Filter" }, | ||
| 1737 | { "ADC Mono Right Filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1738 | |||
| 1739 | { "Stereo2 ADC L2 Mux", "DMIC", "Stereo2 DMIC Mux" }, | ||
| 1740 | { "Stereo2 ADC L2 Mux", "DAC MIX", "DAC MIXL" }, | ||
| 1741 | { "Stereo2 ADC L1 Mux", "ADC", "ADC 1_2" }, | ||
| 1742 | { "Stereo2 ADC L1 Mux", "DAC MIX", "DAC MIXL" }, | ||
| 1743 | |||
| 1744 | { "Stereo2 ADC R1 Mux", "ADC", "ADC 1_2" }, | ||
| 1745 | { "Stereo2 ADC R1 Mux", "DAC MIX", "DAC MIXR" }, | ||
| 1746 | { "Stereo2 ADC R2 Mux", "DMIC", "Stereo2 DMIC Mux" }, | ||
| 1747 | { "Stereo2 ADC R2 Mux", "DAC MIX", "DAC MIXR" }, | ||
| 1748 | |||
| 1749 | { "Sto2 ADC MIXL", "ADC1 Switch", "Stereo2 ADC L1 Mux" }, | ||
| 1750 | { "Sto2 ADC MIXL", "ADC2 Switch", "Stereo2 ADC L2 Mux" }, | ||
| 1751 | { "Sto2 ADC MIXR", "ADC1 Switch", "Stereo2 ADC R1 Mux" }, | ||
| 1752 | { "Sto2 ADC MIXR", "ADC2 Switch", "Stereo2 ADC R2 Mux" }, | ||
| 1753 | |||
| 1754 | { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXL" }, | ||
| 1755 | { "Sto2 ADC LR MIX", NULL, "Sto2 ADC MIXR" }, | ||
| 1756 | |||
| 1757 | { "Stereo2 ADC LR Mux", "L", "Sto2 ADC MIXL" }, | ||
| 1758 | { "Stereo2 ADC LR Mux", "LR", "Sto2 ADC LR MIX" }, | ||
| 1759 | |||
| 1760 | { "Stereo2 ADC MIXL", NULL, "Stereo2 ADC LR Mux" }, | ||
| 1761 | { "Stereo2 ADC MIXL", NULL, "ADC Stereo2 Filter" }, | ||
| 1762 | { "ADC Stereo2 Filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1763 | |||
| 1764 | { "Stereo2 ADC MIXR", NULL, "Sto2 ADC MIXR" }, | ||
| 1765 | { "Stereo2 ADC MIXR", NULL, "ADC Stereo2 Filter" }, | ||
| 1766 | { "ADC Stereo2 Filter", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1767 | |||
| 1768 | { "VAD ADC Mux", "Sto1 ADC L", "Stereo1 ADC MIXL" }, | ||
| 1769 | { "VAD ADC Mux", "Mono ADC L", "Mono ADC MIXL" }, | ||
| 1770 | { "VAD ADC Mux", "Mono ADC R", "Mono ADC MIXR" }, | ||
| 1771 | { "VAD ADC Mux", "Sto2 ADC L", "Sto2 ADC MIXL" }, | ||
| 1772 | |||
| 1773 | { "VAD_ADC", NULL, "VAD ADC Mux" }, | ||
| 1774 | |||
| 1775 | { "IF_ADC1", NULL, "Stereo1 ADC MIXL" }, | ||
| 1776 | { "IF_ADC1", NULL, "Stereo1 ADC MIXR" }, | ||
| 1777 | { "IF_ADC2", NULL, "Mono ADC MIXL" }, | ||
| 1778 | { "IF_ADC2", NULL, "Mono ADC MIXR" }, | ||
| 1779 | { "IF_ADC3", NULL, "Stereo2 ADC MIXL" }, | ||
| 1780 | { "IF_ADC3", NULL, "Stereo2 ADC MIXR" }, | ||
| 1781 | |||
| 1782 | { "IF1 ADC1 IN1 Mux", "IF_ADC1", "IF_ADC1" }, | ||
| 1783 | { "IF1 ADC1 IN1 Mux", "IF1_ADC3", "IF1_ADC3" }, | ||
| 1784 | |||
| 1785 | { "IF1 ADC1 IN2 Mux", "IF1_ADC1_IN1", "IF1 ADC1 IN1 Mux" }, | ||
| 1786 | { "IF1 ADC1 IN2 Mux", "IF1_ADC4", "IF1_ADC4" }, | ||
| 1787 | |||
| 1788 | { "IF1 ADC2 IN Mux", "IF_ADC2", "IF_ADC2" }, | ||
| 1789 | { "IF1 ADC2 IN Mux", "VAD_ADC", "VAD_ADC" }, | ||
| 1790 | |||
| 1791 | { "IF1 ADC2 IN1 Mux", "IF1_ADC2_IN", "IF1 ADC2 IN Mux" }, | ||
| 1792 | { "IF1 ADC2 IN1 Mux", "IF1_ADC4", "IF1_ADC4" }, | ||
| 1793 | |||
| 1794 | { "IF1_ADC1" , NULL, "IF1 ADC1 IN2 Mux" }, | ||
| 1795 | { "IF1_ADC2" , NULL, "IF1 ADC2 IN1 Mux" }, | ||
| 1796 | |||
| 1797 | { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXL" }, | ||
| 1798 | { "Stereo1 ADC MIX", NULL, "Stereo1 ADC MIXR" }, | ||
| 1799 | { "Stereo2 ADC MIX", NULL, "Sto2 ADC MIXL" }, | ||
| 1800 | { "Stereo2 ADC MIX", NULL, "Sto2 ADC MIXR" }, | ||
| 1801 | { "Mono ADC MIX", NULL, "Mono ADC MIXL" }, | ||
| 1802 | { "Mono ADC MIX", NULL, "Mono ADC MIXR" }, | ||
| 1803 | |||
| 1804 | { "RxDP Mux", "IF2 DAC", "IF2 DAC" }, | ||
| 1805 | { "RxDP Mux", "IF1 DAC", "IF1 DAC2" }, | ||
| 1806 | { "RxDP Mux", "STO1 ADC Mixer", "Stereo1 ADC MIX" }, | ||
| 1807 | { "RxDP Mux", "STO2 ADC Mixer", "Stereo2 ADC MIX" }, | ||
| 1808 | { "RxDP Mux", "Mono ADC Mixer L", "Mono ADC MIXL" }, | ||
| 1809 | { "RxDP Mux", "Mono ADC Mixer R", "Mono ADC MIXR" }, | ||
| 1810 | { "RxDP Mux", "DAC1", "DAC MIX" }, | ||
| 1811 | |||
| 1812 | { "TDM Data Mux", "Slot 0-1", "Stereo1 ADC MIX" }, | ||
| 1813 | { "TDM Data Mux", "Slot 2-3", "Mono ADC MIX" }, | ||
| 1814 | { "TDM Data Mux", "Slot 4-5", "Stereo2 ADC MIX" }, | ||
| 1815 | { "TDM Data Mux", "Slot 6-7", "IF2 DAC" }, | ||
| 1816 | |||
| 1817 | { "DSP UL Mux", "Bypass", "TDM Data Mux" }, | ||
| 1818 | { "DSP UL Mux", NULL, "I2S DSP" }, | ||
| 1819 | { "DSP DL Mux", "Bypass", "RxDP Mux" }, | ||
| 1820 | { "DSP DL Mux", NULL, "I2S DSP" }, | ||
| 1821 | |||
| 1822 | { "TxDP_ADC_L", NULL, "DSP UL Mux" }, | ||
| 1823 | { "TxDP_ADC_R", NULL, "DSP UL Mux" }, | ||
| 1824 | { "TxDC_DAC", NULL, "DSP DL Mux" }, | ||
| 1825 | |||
| 1826 | { "TxDP_ADC", NULL, "TxDP_ADC_L" }, | ||
| 1827 | { "TxDP_ADC", NULL, "TxDP_ADC_R" }, | ||
| 1828 | |||
| 1829 | { "IF1 ADC", NULL, "I2S1" }, | ||
| 1830 | { "IF1 ADC", NULL, "IF1_ADC1" }, | ||
| 1831 | { "IF1 ADC", NULL, "IF1_ADC2" }, | ||
| 1832 | { "IF1 ADC", NULL, "IF_ADC3" }, | ||
| 1833 | { "IF1 ADC", NULL, "TxDP_ADC" }, | ||
| 1834 | |||
| 1835 | { "IF2 ADC Mux", "IF_ADC1", "IF_ADC1" }, | ||
| 1836 | { "IF2 ADC Mux", "IF_ADC2", "IF_ADC2" }, | ||
| 1837 | { "IF2 ADC Mux", "IF_ADC3", "IF_ADC3" }, | ||
| 1838 | { "IF2 ADC Mux", "TxDC_DAC", "TxDC_DAC" }, | ||
| 1839 | { "IF2 ADC Mux", "TxDP_ADC", "TxDP_ADC" }, | ||
| 1840 | { "IF2 ADC Mux", "VAD_ADC", "VAD_ADC" }, | ||
| 1841 | |||
| 1842 | { "IF2 ADC L", NULL, "IF2 ADC Mux" }, | ||
| 1843 | { "IF2 ADC R", NULL, "IF2 ADC Mux" }, | ||
| 1844 | |||
| 1845 | { "IF2 ADC", NULL, "I2S2" }, | ||
| 1846 | { "IF2 ADC", NULL, "IF2 ADC L" }, | ||
| 1847 | { "IF2 ADC", NULL, "IF2 ADC R" }, | ||
| 1848 | |||
| 1849 | { "AIF1TX", NULL, "IF1 ADC" }, | ||
| 1850 | { "AIF2TX", NULL, "IF2 ADC" }, | ||
| 1851 | |||
| 1852 | { "IF1 DAC1", NULL, "AIF1RX" }, | ||
| 1853 | { "IF1 DAC2", NULL, "AIF1RX" }, | ||
| 1854 | { "IF2 DAC", NULL, "AIF2RX" }, | ||
| 1855 | |||
| 1856 | { "IF1 DAC1", NULL, "I2S1" }, | ||
| 1857 | { "IF1 DAC2", NULL, "I2S1" }, | ||
| 1858 | { "IF2 DAC", NULL, "I2S2" }, | ||
| 1859 | |||
| 1860 | { "IF1 DAC2 L", NULL, "IF1 DAC2" }, | ||
| 1861 | { "IF1 DAC2 R", NULL, "IF1 DAC2" }, | ||
| 1862 | { "IF1 DAC1 L", NULL, "IF1 DAC1" }, | ||
| 1863 | { "IF1 DAC1 R", NULL, "IF1 DAC1" }, | ||
| 1864 | { "IF2 DAC L", NULL, "IF2 DAC" }, | ||
| 1865 | { "IF2 DAC R", NULL, "IF2 DAC" }, | ||
| 1866 | |||
| 1867 | { "DAC1 L Mux", "IF1 DAC", "IF1 DAC1 L" }, | ||
| 1868 | { "DAC1 L Mux", "IF2 DAC", "IF2 DAC L" }, | ||
| 1869 | |||
| 1870 | { "DAC1 R Mux", "IF1 DAC", "IF1 DAC1 R" }, | ||
| 1871 | { "DAC1 R Mux", "IF2 DAC", "IF2 DAC R" }, | ||
| 1872 | |||
| 1873 | { "DAC1 MIXL", "Stereo ADC Switch", "Stereo1 ADC MIXL" }, | ||
| 1874 | { "DAC1 MIXL", "DAC1 Switch", "DAC1 L Mux" }, | ||
| 1875 | { "DAC1 MIXL", NULL, "DAC Stereo1 Filter" }, | ||
| 1876 | { "DAC1 MIXR", "Stereo ADC Switch", "Stereo1 ADC MIXR" }, | ||
| 1877 | { "DAC1 MIXR", "DAC1 Switch", "DAC1 R Mux" }, | ||
| 1878 | { "DAC1 MIXR", NULL, "DAC Stereo1 Filter" }, | ||
| 1879 | |||
| 1880 | { "DAC MIX", NULL, "DAC1 MIXL" }, | ||
| 1881 | { "DAC MIX", NULL, "DAC1 MIXR" }, | ||
| 1882 | |||
| 1883 | { "Audio DSP", NULL, "DAC1 MIXL" }, | ||
| 1884 | { "Audio DSP", NULL, "DAC1 MIXR" }, | ||
| 1885 | |||
| 1886 | { "DAC L2 Mux", "IF1 DAC", "IF1 DAC2 L" }, | ||
| 1887 | { "DAC L2 Mux", "IF2 DAC", "IF2 DAC L" }, | ||
| 1888 | { "DAC L2 Mux", "TxDC DAC", "TxDC_DAC" }, | ||
| 1889 | { "DAC L2 Mux", "VAD_ADC", "VAD_ADC" }, | ||
| 1890 | { "DAC L2 Volume", NULL, "DAC L2 Mux" }, | ||
| 1891 | { "DAC L2 Volume", NULL, "DAC Mono Left Filter" }, | ||
| 1892 | |||
| 1893 | { "DAC R2 Mux", "IF1 DAC", "IF1 DAC2 R" }, | ||
| 1894 | { "DAC R2 Mux", "IF2 DAC", "IF2 DAC R" }, | ||
| 1895 | { "DAC R2 Mux", "TxDC DAC", "TxDC_DAC" }, | ||
| 1896 | { "DAC R2 Mux", "TxDP ADC", "TxDP_ADC" }, | ||
| 1897 | { "DAC R2 Volume", NULL, "DAC R2 Mux" }, | ||
| 1898 | { "DAC R2 Volume", NULL, "DAC Mono Right Filter" }, | ||
| 1899 | |||
| 1900 | { "Stereo DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" }, | ||
| 1901 | { "Stereo DAC MIXL", "DAC R1 Switch", "DAC1 MIXR" }, | ||
| 1902 | { "Stereo DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" }, | ||
| 1903 | { "Stereo DAC MIXL", NULL, "DAC Stereo1 Filter" }, | ||
| 1904 | { "Stereo DAC MIXL", NULL, "DAC L1 Power" }, | ||
| 1905 | { "Stereo DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" }, | ||
| 1906 | { "Stereo DAC MIXR", "DAC L1 Switch", "DAC1 MIXL" }, | ||
| 1907 | { "Stereo DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" }, | ||
| 1908 | { "Stereo DAC MIXR", NULL, "DAC Stereo1 Filter" }, | ||
| 1909 | { "Stereo DAC MIXR", NULL, "DAC R1 Power" }, | ||
| 1910 | |||
| 1911 | { "Mono DAC MIXL", "DAC L1 Switch", "DAC1 MIXL" }, | ||
| 1912 | { "Mono DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" }, | ||
| 1913 | { "Mono DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" }, | ||
| 1914 | { "Mono DAC MIXL", NULL, "DAC Mono Left Filter" }, | ||
| 1915 | { "Mono DAC MIXR", "DAC R1 Switch", "DAC1 MIXR" }, | ||
| 1916 | { "Mono DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" }, | ||
| 1917 | { "Mono DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" }, | ||
| 1918 | { "Mono DAC MIXR", NULL, "DAC Mono Right Filter" }, | ||
| 1919 | |||
| 1920 | { "DAC MIXL", "Sto DAC Mix L Switch", "Stereo DAC MIXL" }, | ||
| 1921 | { "DAC MIXL", "DAC L2 Switch", "DAC L2 Volume" }, | ||
| 1922 | { "DAC MIXL", "DAC R2 Switch", "DAC R2 Volume" }, | ||
| 1923 | { "DAC MIXR", "Sto DAC Mix R Switch", "Stereo DAC MIXR" }, | ||
| 1924 | { "DAC MIXR", "DAC R2 Switch", "DAC R2 Volume" }, | ||
| 1925 | { "DAC MIXR", "DAC L2 Switch", "DAC L2 Volume" }, | ||
| 1926 | |||
| 1927 | { "DAC L1", NULL, "DAC L1 Power" }, | ||
| 1928 | { "DAC L1", NULL, "Stereo DAC MIXL" }, | ||
| 1929 | { "DAC L1", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1930 | { "DAC R1", NULL, "DAC R1 Power" }, | ||
| 1931 | { "DAC R1", NULL, "Stereo DAC MIXR" }, | ||
| 1932 | { "DAC R1", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1933 | { "DAC L2", NULL, "Mono DAC MIXL" }, | ||
| 1934 | { "DAC L2", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1935 | { "DAC R2", NULL, "Mono DAC MIXR" }, | ||
| 1936 | { "DAC R2", NULL, "PLL1", is_sys_clk_from_pll }, | ||
| 1937 | |||
| 1938 | { "OUT MIXL", "BST1 Switch", "BST1" }, | ||
| 1939 | { "OUT MIXL", "INL Switch", "INL VOL" }, | ||
| 1940 | { "OUT MIXL", "DAC L2 Switch", "DAC L2" }, | ||
| 1941 | { "OUT MIXL", "DAC L1 Switch", "DAC L1" }, | ||
| 1942 | |||
| 1943 | { "OUT MIXR", "BST2 Switch", "BST2" }, | ||
| 1944 | { "OUT MIXR", "INR Switch", "INR VOL" }, | ||
| 1945 | { "OUT MIXR", "DAC R2 Switch", "DAC R2" }, | ||
| 1946 | { "OUT MIXR", "DAC R1 Switch", "DAC R1" }, | ||
| 1947 | |||
| 1948 | { "HPOVOL MIXL", "DAC1 Switch", "DAC L1" }, | ||
| 1949 | { "HPOVOL MIXL", "INL Switch", "INL VOL" }, | ||
| 1950 | { "HPOVOL MIXR", "DAC1 Switch", "DAC R1" }, | ||
| 1951 | { "HPOVOL MIXR", "INR Switch", "INR VOL" }, | ||
| 1952 | |||
| 1953 | { "DAC 2", NULL, "DAC L2" }, | ||
| 1954 | { "DAC 2", NULL, "DAC R2" }, | ||
| 1955 | { "DAC 1", NULL, "DAC L1" }, | ||
| 1956 | { "DAC 1", NULL, "DAC R1" }, | ||
| 1957 | { "HPOVOL", NULL, "HPOVOL MIXL" }, | ||
| 1958 | { "HPOVOL", NULL, "HPOVOL MIXR" }, | ||
| 1959 | { "HPO MIX", "DAC1 Switch", "DAC 1" }, | ||
| 1960 | { "HPO MIX", "HPVOL Switch", "HPOVOL" }, | ||
| 1961 | |||
| 1962 | { "LOUT MIX", "DAC L1 Switch", "DAC L1" }, | ||
| 1963 | { "LOUT MIX", "DAC R1 Switch", "DAC R1" }, | ||
| 1964 | { "LOUT MIX", "OUTMIX L Switch", "OUT MIXL" }, | ||
| 1965 | { "LOUT MIX", "OUTMIX R Switch", "OUT MIXR" }, | ||
| 1966 | |||
| 1967 | { "PDM1 L Mux", "Stereo DAC", "Stereo DAC MIXL" }, | ||
| 1968 | { "PDM1 L Mux", "Mono DAC", "Mono DAC MIXL" }, | ||
| 1969 | { "PDM1 L Mux", NULL, "PDM1 Power" }, | ||
| 1970 | { "PDM1 R Mux", "Stereo DAC", "Stereo DAC MIXR" }, | ||
| 1971 | { "PDM1 R Mux", "Mono DAC", "Mono DAC MIXR" }, | ||
| 1972 | { "PDM1 R Mux", NULL, "PDM1 Power" }, | ||
| 1973 | { "PDM2 L Mux", "Stereo DAC", "Stereo DAC MIXL" }, | ||
| 1974 | { "PDM2 L Mux", "Mono DAC", "Mono DAC MIXL" }, | ||
| 1975 | { "PDM2 L Mux", NULL, "PDM2 Power" }, | ||
| 1976 | { "PDM2 R Mux", "Stereo DAC", "Stereo DAC MIXR" }, | ||
| 1977 | { "PDM2 R Mux", "Mono DAC", "Mono DAC MIXR" }, | ||
| 1978 | { "PDM2 R Mux", NULL, "PDM2 Power" }, | ||
| 1979 | |||
| 1980 | { "HP Amp", NULL, "HPO MIX" }, | ||
| 1981 | { "HP Amp", NULL, "Mic Det Power" }, | ||
| 1982 | { "HPOL", NULL, "HP Amp" }, | ||
| 1983 | { "HPOL", NULL, "HP L Amp" }, | ||
| 1984 | { "HPOL", NULL, "Improve HP Amp Drv" }, | ||
| 1985 | { "HPOR", NULL, "HP Amp" }, | ||
| 1986 | { "HPOR", NULL, "HP R Amp" }, | ||
| 1987 | { "HPOR", NULL, "Improve HP Amp Drv" }, | ||
| 1988 | |||
| 1989 | { "LOUT Amp", NULL, "LOUT MIX" }, | ||
| 1990 | { "LOUT L Playback", "Switch", "LOUT Amp" }, | ||
| 1991 | { "LOUT R Playback", "Switch", "LOUT Amp" }, | ||
| 1992 | { "LOUTL", NULL, "LOUT L Playback" }, | ||
| 1993 | { "LOUTR", NULL, "LOUT R Playback" }, | ||
| 1994 | { "LOUTL", NULL, "Improve HP Amp Drv" }, | ||
| 1995 | { "LOUTR", NULL, "Improve HP Amp Drv" }, | ||
| 1996 | |||
| 1997 | { "PDM1L", NULL, "PDM1 L Mux" }, | ||
| 1998 | { "PDM1R", NULL, "PDM1 R Mux" }, | ||
| 1999 | { "PDM2L", NULL, "PDM2 L Mux" }, | ||
| 2000 | { "PDM2R", NULL, "PDM2 R Mux" }, | ||
| 2001 | }; | ||
| 2002 | |||
| 2003 | static int rt5670_hw_params(struct snd_pcm_substream *substream, | ||
| 2004 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | ||
| 2005 | { | ||
| 2006 | struct snd_soc_codec *codec = dai->codec; | ||
| 2007 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2008 | unsigned int val_len = 0, val_clk, mask_clk; | ||
| 2009 | int pre_div, bclk_ms, frame_size; | ||
| 2010 | |||
| 2011 | rt5670->lrck[dai->id] = params_rate(params); | ||
| 2012 | pre_div = rl6231_get_clk_info(rt5670->sysclk, rt5670->lrck[dai->id]); | ||
| 2013 | if (pre_div < 0) { | ||
| 2014 | dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", | ||
| 2015 | rt5670->lrck[dai->id], dai->id); | ||
| 2016 | return -EINVAL; | ||
| 2017 | } | ||
| 2018 | frame_size = snd_soc_params_to_frame_size(params); | ||
| 2019 | if (frame_size < 0) { | ||
| 2020 | dev_err(codec->dev, "Unsupported frame size: %d\n", frame_size); | ||
| 2021 | return -EINVAL; | ||
| 2022 | } | ||
| 2023 | bclk_ms = frame_size > 32; | ||
| 2024 | rt5670->bclk[dai->id] = rt5670->lrck[dai->id] * (32 << bclk_ms); | ||
| 2025 | |||
| 2026 | dev_dbg(dai->dev, "bclk is %dHz and lrck is %dHz\n", | ||
| 2027 | rt5670->bclk[dai->id], rt5670->lrck[dai->id]); | ||
| 2028 | dev_dbg(dai->dev, "bclk_ms is %d and pre_div is %d for iis %d\n", | ||
| 2029 | bclk_ms, pre_div, dai->id); | ||
| 2030 | |||
| 2031 | switch (params_width(params)) { | ||
| 2032 | case 16: | ||
| 2033 | break; | ||
| 2034 | case 20: | ||
| 2035 | val_len |= RT5670_I2S_DL_20; | ||
| 2036 | break; | ||
| 2037 | case 24: | ||
| 2038 | val_len |= RT5670_I2S_DL_24; | ||
| 2039 | break; | ||
| 2040 | case 8: | ||
| 2041 | val_len |= RT5670_I2S_DL_8; | ||
| 2042 | break; | ||
| 2043 | default: | ||
| 2044 | return -EINVAL; | ||
| 2045 | } | ||
| 2046 | |||
| 2047 | switch (dai->id) { | ||
| 2048 | case RT5670_AIF1: | ||
| 2049 | mask_clk = RT5670_I2S_BCLK_MS1_MASK | RT5670_I2S_PD1_MASK; | ||
| 2050 | val_clk = bclk_ms << RT5670_I2S_BCLK_MS1_SFT | | ||
| 2051 | pre_div << RT5670_I2S_PD1_SFT; | ||
| 2052 | snd_soc_update_bits(codec, RT5670_I2S1_SDP, | ||
| 2053 | RT5670_I2S_DL_MASK, val_len); | ||
| 2054 | snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); | ||
| 2055 | break; | ||
| 2056 | case RT5670_AIF2: | ||
| 2057 | mask_clk = RT5670_I2S_BCLK_MS2_MASK | RT5670_I2S_PD2_MASK; | ||
| 2058 | val_clk = bclk_ms << RT5670_I2S_BCLK_MS2_SFT | | ||
| 2059 | pre_div << RT5670_I2S_PD2_SFT; | ||
| 2060 | snd_soc_update_bits(codec, RT5670_I2S2_SDP, | ||
| 2061 | RT5670_I2S_DL_MASK, val_len); | ||
| 2062 | snd_soc_update_bits(codec, RT5670_ADDA_CLK1, mask_clk, val_clk); | ||
| 2063 | break; | ||
| 2064 | default: | ||
| 2065 | dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); | ||
| 2066 | return -EINVAL; | ||
| 2067 | } | ||
| 2068 | |||
| 2069 | return 0; | ||
| 2070 | } | ||
| 2071 | |||
| 2072 | static int rt5670_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | ||
| 2073 | { | ||
| 2074 | struct snd_soc_codec *codec = dai->codec; | ||
| 2075 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2076 | unsigned int reg_val = 0; | ||
| 2077 | |||
| 2078 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
| 2079 | case SND_SOC_DAIFMT_CBM_CFM: | ||
| 2080 | rt5670->master[dai->id] = 1; | ||
| 2081 | break; | ||
| 2082 | case SND_SOC_DAIFMT_CBS_CFS: | ||
| 2083 | reg_val |= RT5670_I2S_MS_S; | ||
| 2084 | rt5670->master[dai->id] = 0; | ||
| 2085 | break; | ||
| 2086 | default: | ||
| 2087 | return -EINVAL; | ||
| 2088 | } | ||
| 2089 | |||
| 2090 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
| 2091 | case SND_SOC_DAIFMT_NB_NF: | ||
| 2092 | break; | ||
| 2093 | case SND_SOC_DAIFMT_IB_NF: | ||
| 2094 | reg_val |= RT5670_I2S_BP_INV; | ||
| 2095 | break; | ||
| 2096 | default: | ||
| 2097 | return -EINVAL; | ||
| 2098 | } | ||
| 2099 | |||
| 2100 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 2101 | case SND_SOC_DAIFMT_I2S: | ||
| 2102 | break; | ||
| 2103 | case SND_SOC_DAIFMT_LEFT_J: | ||
| 2104 | reg_val |= RT5670_I2S_DF_LEFT; | ||
| 2105 | break; | ||
| 2106 | case SND_SOC_DAIFMT_DSP_A: | ||
| 2107 | reg_val |= RT5670_I2S_DF_PCM_A; | ||
| 2108 | break; | ||
| 2109 | case SND_SOC_DAIFMT_DSP_B: | ||
| 2110 | reg_val |= RT5670_I2S_DF_PCM_B; | ||
| 2111 | break; | ||
| 2112 | default: | ||
| 2113 | return -EINVAL; | ||
| 2114 | } | ||
| 2115 | |||
| 2116 | switch (dai->id) { | ||
| 2117 | case RT5670_AIF1: | ||
| 2118 | snd_soc_update_bits(codec, RT5670_I2S1_SDP, | ||
| 2119 | RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | | ||
| 2120 | RT5670_I2S_DF_MASK, reg_val); | ||
| 2121 | break; | ||
| 2122 | case RT5670_AIF2: | ||
| 2123 | snd_soc_update_bits(codec, RT5670_I2S2_SDP, | ||
| 2124 | RT5670_I2S_MS_MASK | RT5670_I2S_BP_MASK | | ||
| 2125 | RT5670_I2S_DF_MASK, reg_val); | ||
| 2126 | break; | ||
| 2127 | default: | ||
| 2128 | dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); | ||
| 2129 | return -EINVAL; | ||
| 2130 | } | ||
| 2131 | return 0; | ||
| 2132 | } | ||
| 2133 | |||
| 2134 | static int rt5670_set_dai_sysclk(struct snd_soc_dai *dai, | ||
| 2135 | int clk_id, unsigned int freq, int dir) | ||
| 2136 | { | ||
| 2137 | struct snd_soc_codec *codec = dai->codec; | ||
| 2138 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2139 | unsigned int reg_val = 0; | ||
| 2140 | |||
| 2141 | if (freq == rt5670->sysclk && clk_id == rt5670->sysclk_src) | ||
| 2142 | return 0; | ||
| 2143 | |||
| 2144 | switch (clk_id) { | ||
| 2145 | case RT5670_SCLK_S_MCLK: | ||
| 2146 | reg_val |= RT5670_SCLK_SRC_MCLK; | ||
| 2147 | break; | ||
| 2148 | case RT5670_SCLK_S_PLL1: | ||
| 2149 | reg_val |= RT5670_SCLK_SRC_PLL1; | ||
| 2150 | break; | ||
| 2151 | case RT5670_SCLK_S_RCCLK: | ||
| 2152 | reg_val |= RT5670_SCLK_SRC_RCCLK; | ||
| 2153 | break; | ||
| 2154 | default: | ||
| 2155 | dev_err(codec->dev, "Invalid clock id (%d)\n", clk_id); | ||
| 2156 | return -EINVAL; | ||
| 2157 | } | ||
| 2158 | snd_soc_update_bits(codec, RT5670_GLB_CLK, | ||
| 2159 | RT5670_SCLK_SRC_MASK, reg_val); | ||
| 2160 | rt5670->sysclk = freq; | ||
| 2161 | rt5670->sysclk_src = clk_id; | ||
| 2162 | |||
| 2163 | dev_dbg(dai->dev, "Sysclk is %dHz and clock id is %d\n", freq, clk_id); | ||
| 2164 | |||
| 2165 | return 0; | ||
| 2166 | } | ||
| 2167 | |||
| 2168 | static int rt5670_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | ||
| 2169 | unsigned int freq_in, unsigned int freq_out) | ||
| 2170 | { | ||
| 2171 | struct snd_soc_codec *codec = dai->codec; | ||
| 2172 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2173 | struct rl6231_pll_code pll_code; | ||
| 2174 | int ret; | ||
| 2175 | |||
| 2176 | if (source == rt5670->pll_src && freq_in == rt5670->pll_in && | ||
| 2177 | freq_out == rt5670->pll_out) | ||
| 2178 | return 0; | ||
| 2179 | |||
| 2180 | if (!freq_in || !freq_out) { | ||
| 2181 | dev_dbg(codec->dev, "PLL disabled\n"); | ||
| 2182 | |||
| 2183 | rt5670->pll_in = 0; | ||
| 2184 | rt5670->pll_out = 0; | ||
| 2185 | snd_soc_update_bits(codec, RT5670_GLB_CLK, | ||
| 2186 | RT5670_SCLK_SRC_MASK, RT5670_SCLK_SRC_MCLK); | ||
| 2187 | return 0; | ||
| 2188 | } | ||
| 2189 | |||
| 2190 | switch (source) { | ||
| 2191 | case RT5670_PLL1_S_MCLK: | ||
| 2192 | snd_soc_update_bits(codec, RT5670_GLB_CLK, | ||
| 2193 | RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_MCLK); | ||
| 2194 | break; | ||
| 2195 | case RT5670_PLL1_S_BCLK1: | ||
| 2196 | case RT5670_PLL1_S_BCLK2: | ||
| 2197 | case RT5670_PLL1_S_BCLK3: | ||
| 2198 | case RT5670_PLL1_S_BCLK4: | ||
| 2199 | switch (dai->id) { | ||
| 2200 | case RT5670_AIF1: | ||
| 2201 | snd_soc_update_bits(codec, RT5670_GLB_CLK, | ||
| 2202 | RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK1); | ||
| 2203 | break; | ||
| 2204 | case RT5670_AIF2: | ||
| 2205 | snd_soc_update_bits(codec, RT5670_GLB_CLK, | ||
| 2206 | RT5670_PLL1_SRC_MASK, RT5670_PLL1_SRC_BCLK2); | ||
| 2207 | break; | ||
| 2208 | default: | ||
| 2209 | dev_err(codec->dev, "Invalid dai->id: %d\n", dai->id); | ||
| 2210 | return -EINVAL; | ||
| 2211 | } | ||
| 2212 | break; | ||
| 2213 | default: | ||
| 2214 | dev_err(codec->dev, "Unknown PLL source %d\n", source); | ||
| 2215 | return -EINVAL; | ||
| 2216 | } | ||
| 2217 | |||
| 2218 | ret = rl6231_pll_calc(freq_in, freq_out, &pll_code); | ||
| 2219 | if (ret < 0) { | ||
| 2220 | dev_err(codec->dev, "Unsupport input clock %d\n", freq_in); | ||
| 2221 | return ret; | ||
| 2222 | } | ||
| 2223 | |||
| 2224 | dev_dbg(codec->dev, "bypass=%d m=%d n=%d k=%d\n", | ||
| 2225 | pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), | ||
| 2226 | pll_code.n_code, pll_code.k_code); | ||
| 2227 | |||
| 2228 | snd_soc_write(codec, RT5670_PLL_CTRL1, | ||
| 2229 | pll_code.n_code << RT5670_PLL_N_SFT | pll_code.k_code); | ||
| 2230 | snd_soc_write(codec, RT5670_PLL_CTRL2, | ||
| 2231 | (pll_code.m_bp ? 0 : pll_code.m_code) << RT5670_PLL_M_SFT | | ||
| 2232 | pll_code.m_bp << RT5670_PLL_M_BP_SFT); | ||
| 2233 | |||
| 2234 | rt5670->pll_in = freq_in; | ||
| 2235 | rt5670->pll_out = freq_out; | ||
| 2236 | rt5670->pll_src = source; | ||
| 2237 | |||
| 2238 | return 0; | ||
| 2239 | } | ||
| 2240 | |||
| 2241 | static int rt5670_set_tdm_slot(struct snd_soc_dai *dai, unsigned int tx_mask, | ||
| 2242 | unsigned int rx_mask, int slots, int slot_width) | ||
| 2243 | { | ||
| 2244 | struct snd_soc_codec *codec = dai->codec; | ||
| 2245 | unsigned int val = 0; | ||
| 2246 | |||
| 2247 | if (rx_mask || tx_mask) | ||
| 2248 | val |= (1 << 14); | ||
| 2249 | |||
| 2250 | switch (slots) { | ||
| 2251 | case 4: | ||
| 2252 | val |= (1 << 12); | ||
| 2253 | break; | ||
| 2254 | case 6: | ||
| 2255 | val |= (2 << 12); | ||
| 2256 | break; | ||
| 2257 | case 8: | ||
| 2258 | val |= (3 << 12); | ||
| 2259 | break; | ||
| 2260 | case 2: | ||
| 2261 | break; | ||
| 2262 | default: | ||
| 2263 | return -EINVAL; | ||
| 2264 | } | ||
| 2265 | |||
| 2266 | switch (slot_width) { | ||
| 2267 | case 20: | ||
| 2268 | val |= (1 << 10); | ||
| 2269 | break; | ||
| 2270 | case 24: | ||
| 2271 | val |= (2 << 10); | ||
| 2272 | break; | ||
| 2273 | case 32: | ||
| 2274 | val |= (3 << 10); | ||
| 2275 | break; | ||
| 2276 | case 16: | ||
| 2277 | break; | ||
| 2278 | default: | ||
| 2279 | return -EINVAL; | ||
| 2280 | } | ||
| 2281 | |||
| 2282 | snd_soc_update_bits(codec, RT5670_TDM_CTRL_1, 0x7c00, val); | ||
| 2283 | |||
| 2284 | return 0; | ||
| 2285 | } | ||
| 2286 | |||
| 2287 | static int rt5670_set_bias_level(struct snd_soc_codec *codec, | ||
| 2288 | enum snd_soc_bias_level level) | ||
| 2289 | { | ||
| 2290 | switch (level) { | ||
| 2291 | case SND_SOC_BIAS_PREPARE: | ||
| 2292 | if (SND_SOC_BIAS_STANDBY == codec->dapm.bias_level) { | ||
| 2293 | snd_soc_update_bits(codec, RT5670_PWR_ANLG1, | ||
| 2294 | RT5670_PWR_VREF1 | RT5670_PWR_MB | | ||
| 2295 | RT5670_PWR_BG | RT5670_PWR_VREF2, | ||
| 2296 | RT5670_PWR_VREF1 | RT5670_PWR_MB | | ||
| 2297 | RT5670_PWR_BG | RT5670_PWR_VREF2); | ||
| 2298 | mdelay(10); | ||
| 2299 | snd_soc_update_bits(codec, RT5670_PWR_ANLG1, | ||
| 2300 | RT5670_PWR_FV1 | RT5670_PWR_FV2, | ||
| 2301 | RT5670_PWR_FV1 | RT5670_PWR_FV2); | ||
| 2302 | snd_soc_update_bits(codec, RT5670_CHARGE_PUMP, | ||
| 2303 | RT5670_OSW_L_MASK | RT5670_OSW_R_MASK, | ||
| 2304 | RT5670_OSW_L_DIS | RT5670_OSW_R_DIS); | ||
| 2305 | snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x1); | ||
| 2306 | snd_soc_update_bits(codec, RT5670_PWR_ANLG1, | ||
| 2307 | RT5670_LDO_SEL_MASK, 0x3); | ||
| 2308 | } | ||
| 2309 | break; | ||
| 2310 | case SND_SOC_BIAS_STANDBY: | ||
| 2311 | snd_soc_write(codec, RT5670_PWR_DIG1, 0x0000); | ||
| 2312 | snd_soc_write(codec, RT5670_PWR_DIG2, 0x0001); | ||
| 2313 | snd_soc_write(codec, RT5670_PWR_VOL, 0x0000); | ||
| 2314 | snd_soc_write(codec, RT5670_PWR_MIXER, 0x0001); | ||
| 2315 | snd_soc_write(codec, RT5670_PWR_ANLG1, 0x2800); | ||
| 2316 | snd_soc_write(codec, RT5670_PWR_ANLG2, 0x0004); | ||
| 2317 | snd_soc_update_bits(codec, RT5670_DIG_MISC, 0x1, 0x0); | ||
| 2318 | snd_soc_update_bits(codec, RT5670_PWR_ANLG1, | ||
| 2319 | RT5670_LDO_SEL_MASK, 0x1); | ||
| 2320 | break; | ||
| 2321 | |||
| 2322 | default: | ||
| 2323 | break; | ||
| 2324 | } | ||
| 2325 | codec->dapm.bias_level = level; | ||
| 2326 | |||
| 2327 | return 0; | ||
| 2328 | } | ||
| 2329 | |||
| 2330 | static int rt5670_probe(struct snd_soc_codec *codec) | ||
| 2331 | { | ||
| 2332 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2333 | |||
| 2334 | rt5670->codec = codec; | ||
| 2335 | |||
| 2336 | return 0; | ||
| 2337 | } | ||
| 2338 | |||
| 2339 | static int rt5670_remove(struct snd_soc_codec *codec) | ||
| 2340 | { | ||
| 2341 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2342 | |||
| 2343 | regmap_write(rt5670->regmap, RT5670_RESET, 0); | ||
| 2344 | return 0; | ||
| 2345 | } | ||
| 2346 | |||
| 2347 | #ifdef CONFIG_PM | ||
| 2348 | static int rt5670_suspend(struct snd_soc_codec *codec) | ||
| 2349 | { | ||
| 2350 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2351 | |||
| 2352 | regcache_cache_only(rt5670->regmap, true); | ||
| 2353 | regcache_mark_dirty(rt5670->regmap); | ||
| 2354 | return 0; | ||
| 2355 | } | ||
| 2356 | |||
| 2357 | static int rt5670_resume(struct snd_soc_codec *codec) | ||
| 2358 | { | ||
| 2359 | struct rt5670_priv *rt5670 = snd_soc_codec_get_drvdata(codec); | ||
| 2360 | |||
| 2361 | regcache_cache_only(rt5670->regmap, false); | ||
| 2362 | regcache_sync(rt5670->regmap); | ||
| 2363 | |||
| 2364 | return 0; | ||
| 2365 | } | ||
| 2366 | #else | ||
| 2367 | #define rt5670_suspend NULL | ||
| 2368 | #define rt5670_resume NULL | ||
| 2369 | #endif | ||
| 2370 | |||
| 2371 | #define RT5670_STEREO_RATES SNDRV_PCM_RATE_8000_96000 | ||
| 2372 | #define RT5670_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ | ||
| 2373 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S8) | ||
| 2374 | |||
| 2375 | static struct snd_soc_dai_ops rt5670_aif_dai_ops = { | ||
| 2376 | .hw_params = rt5670_hw_params, | ||
| 2377 | .set_fmt = rt5670_set_dai_fmt, | ||
| 2378 | .set_sysclk = rt5670_set_dai_sysclk, | ||
| 2379 | .set_tdm_slot = rt5670_set_tdm_slot, | ||
| 2380 | .set_pll = rt5670_set_dai_pll, | ||
| 2381 | }; | ||
| 2382 | |||
| 2383 | static struct snd_soc_dai_driver rt5670_dai[] = { | ||
| 2384 | { | ||
| 2385 | .name = "rt5670-aif1", | ||
| 2386 | .id = RT5670_AIF1, | ||
| 2387 | .playback = { | ||
| 2388 | .stream_name = "AIF1 Playback", | ||
| 2389 | .channels_min = 1, | ||
| 2390 | .channels_max = 2, | ||
| 2391 | .rates = RT5670_STEREO_RATES, | ||
| 2392 | .formats = RT5670_FORMATS, | ||
| 2393 | }, | ||
| 2394 | .capture = { | ||
| 2395 | .stream_name = "AIF1 Capture", | ||
| 2396 | .channels_min = 1, | ||
| 2397 | .channels_max = 2, | ||
| 2398 | .rates = RT5670_STEREO_RATES, | ||
| 2399 | .formats = RT5670_FORMATS, | ||
| 2400 | }, | ||
| 2401 | .ops = &rt5670_aif_dai_ops, | ||
| 2402 | }, | ||
| 2403 | { | ||
| 2404 | .name = "rt5670-aif2", | ||
| 2405 | .id = RT5670_AIF2, | ||
| 2406 | .playback = { | ||
| 2407 | .stream_name = "AIF2 Playback", | ||
| 2408 | .channels_min = 1, | ||
| 2409 | .channels_max = 2, | ||
| 2410 | .rates = RT5670_STEREO_RATES, | ||
| 2411 | .formats = RT5670_FORMATS, | ||
| 2412 | }, | ||
| 2413 | .capture = { | ||
| 2414 | .stream_name = "AIF2 Capture", | ||
| 2415 | .channels_min = 1, | ||
| 2416 | .channels_max = 2, | ||
| 2417 | .rates = RT5670_STEREO_RATES, | ||
| 2418 | .formats = RT5670_FORMATS, | ||
| 2419 | }, | ||
| 2420 | .ops = &rt5670_aif_dai_ops, | ||
| 2421 | }, | ||
| 2422 | }; | ||
| 2423 | |||
| 2424 | static struct snd_soc_codec_driver soc_codec_dev_rt5670 = { | ||
| 2425 | .probe = rt5670_probe, | ||
| 2426 | .remove = rt5670_remove, | ||
| 2427 | .suspend = rt5670_suspend, | ||
| 2428 | .resume = rt5670_resume, | ||
| 2429 | .set_bias_level = rt5670_set_bias_level, | ||
| 2430 | .idle_bias_off = true, | ||
| 2431 | .controls = rt5670_snd_controls, | ||
| 2432 | .num_controls = ARRAY_SIZE(rt5670_snd_controls), | ||
| 2433 | .dapm_widgets = rt5670_dapm_widgets, | ||
| 2434 | .num_dapm_widgets = ARRAY_SIZE(rt5670_dapm_widgets), | ||
| 2435 | .dapm_routes = rt5670_dapm_routes, | ||
| 2436 | .num_dapm_routes = ARRAY_SIZE(rt5670_dapm_routes), | ||
| 2437 | }; | ||
| 2438 | |||
| 2439 | static const struct regmap_config rt5670_regmap = { | ||
| 2440 | .reg_bits = 8, | ||
| 2441 | .val_bits = 16, | ||
| 2442 | .max_register = RT5670_VENDOR_ID2 + 1 + (ARRAY_SIZE(rt5670_ranges) * | ||
| 2443 | RT5670_PR_SPACING), | ||
| 2444 | .volatile_reg = rt5670_volatile_register, | ||
| 2445 | .readable_reg = rt5670_readable_register, | ||
| 2446 | .cache_type = REGCACHE_RBTREE, | ||
| 2447 | .reg_defaults = rt5670_reg, | ||
| 2448 | .num_reg_defaults = ARRAY_SIZE(rt5670_reg), | ||
| 2449 | .ranges = rt5670_ranges, | ||
| 2450 | .num_ranges = ARRAY_SIZE(rt5670_ranges), | ||
| 2451 | }; | ||
| 2452 | |||
| 2453 | static const struct i2c_device_id rt5670_i2c_id[] = { | ||
| 2454 | { "rt5670", 0 }, | ||
| 2455 | { } | ||
| 2456 | }; | ||
| 2457 | MODULE_DEVICE_TABLE(i2c, rt5670_i2c_id); | ||
| 2458 | |||
| 2459 | static int rt5670_i2c_probe(struct i2c_client *i2c, | ||
| 2460 | const struct i2c_device_id *id) | ||
| 2461 | { | ||
| 2462 | struct rt5670_platform_data *pdata = dev_get_platdata(&i2c->dev); | ||
| 2463 | struct rt5670_priv *rt5670; | ||
| 2464 | int ret; | ||
| 2465 | unsigned int val; | ||
| 2466 | |||
| 2467 | rt5670 = devm_kzalloc(&i2c->dev, | ||
| 2468 | sizeof(struct rt5670_priv), | ||
| 2469 | GFP_KERNEL); | ||
| 2470 | if (NULL == rt5670) | ||
| 2471 | return -ENOMEM; | ||
| 2472 | |||
| 2473 | i2c_set_clientdata(i2c, rt5670); | ||
| 2474 | |||
| 2475 | if (pdata) | ||
| 2476 | rt5670->pdata = *pdata; | ||
| 2477 | |||
| 2478 | rt5670->regmap = devm_regmap_init_i2c(i2c, &rt5670_regmap); | ||
| 2479 | if (IS_ERR(rt5670->regmap)) { | ||
| 2480 | ret = PTR_ERR(rt5670->regmap); | ||
| 2481 | dev_err(&i2c->dev, "Failed to allocate register map: %d\n", | ||
| 2482 | ret); | ||
| 2483 | return ret; | ||
| 2484 | } | ||
| 2485 | |||
| 2486 | regmap_read(rt5670->regmap, RT5670_VENDOR_ID2, &val); | ||
| 2487 | if (val != RT5670_DEVICE_ID) { | ||
| 2488 | dev_err(&i2c->dev, | ||
| 2489 | "Device with ID register %x is not rt5670/72\n", val); | ||
| 2490 | return -ENODEV; | ||
| 2491 | } | ||
| 2492 | |||
| 2493 | regmap_write(rt5670->regmap, RT5670_RESET, 0); | ||
| 2494 | regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, | ||
| 2495 | RT5670_PWR_HP_L | RT5670_PWR_HP_R | | ||
| 2496 | RT5670_PWR_VREF2, RT5670_PWR_VREF2); | ||
| 2497 | msleep(100); | ||
| 2498 | |||
| 2499 | regmap_write(rt5670->regmap, RT5670_RESET, 0); | ||
| 2500 | |||
| 2501 | ret = regmap_register_patch(rt5670->regmap, init_list, | ||
| 2502 | ARRAY_SIZE(init_list)); | ||
| 2503 | if (ret != 0) | ||
| 2504 | dev_warn(&i2c->dev, "Failed to apply regmap patch: %d\n", ret); | ||
| 2505 | |||
| 2506 | if (rt5670->pdata.in2_diff) | ||
| 2507 | regmap_update_bits(rt5670->regmap, RT5670_IN2, | ||
| 2508 | RT5670_IN_DF2, RT5670_IN_DF2); | ||
| 2509 | |||
| 2510 | if (i2c->irq) { | ||
| 2511 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, | ||
| 2512 | RT5670_GP1_PIN_MASK, RT5670_GP1_PIN_IRQ); | ||
| 2513 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL2, | ||
| 2514 | RT5670_GP1_PF_MASK, RT5670_GP1_PF_OUT); | ||
| 2515 | |||
| 2516 | } | ||
| 2517 | |||
| 2518 | if (rt5670->pdata.jd_mode) { | ||
| 2519 | regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG1, | ||
| 2520 | RT5670_PWR_MB, RT5670_PWR_MB); | ||
| 2521 | regmap_update_bits(rt5670->regmap, RT5670_PWR_ANLG2, | ||
| 2522 | RT5670_PWR_JD1, RT5670_PWR_JD1); | ||
| 2523 | regmap_update_bits(rt5670->regmap, RT5670_IRQ_CTRL1, | ||
| 2524 | RT5670_JD1_1_EN_MASK, RT5670_JD1_1_EN); | ||
| 2525 | regmap_update_bits(rt5670->regmap, RT5670_JD_CTRL3, | ||
| 2526 | RT5670_JD_TRI_CBJ_SEL_MASK | | ||
| 2527 | RT5670_JD_TRI_HPO_SEL_MASK, | ||
| 2528 | RT5670_JD_CBJ_JD1_1 | RT5670_JD_HPO_JD1_1); | ||
| 2529 | switch (rt5670->pdata.jd_mode) { | ||
| 2530 | case 1: | ||
| 2531 | regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, | ||
| 2532 | RT5670_JD1_MODE_MASK, | ||
| 2533 | RT5670_JD1_MODE_0); | ||
| 2534 | break; | ||
| 2535 | case 2: | ||
| 2536 | regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, | ||
| 2537 | RT5670_JD1_MODE_MASK, | ||
| 2538 | RT5670_JD1_MODE_1); | ||
| 2539 | break; | ||
| 2540 | case 3: | ||
| 2541 | regmap_update_bits(rt5670->regmap, RT5670_A_JD_CTRL1, | ||
| 2542 | RT5670_JD1_MODE_MASK, | ||
| 2543 | RT5670_JD1_MODE_2); | ||
| 2544 | break; | ||
| 2545 | default: | ||
| 2546 | break; | ||
| 2547 | } | ||
| 2548 | } | ||
| 2549 | |||
| 2550 | if (rt5670->pdata.dmic_en) { | ||
| 2551 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, | ||
| 2552 | RT5670_GP2_PIN_MASK, | ||
| 2553 | RT5670_GP2_PIN_DMIC1_SCL); | ||
| 2554 | |||
| 2555 | switch (rt5670->pdata.dmic1_data_pin) { | ||
| 2556 | case RT5670_DMIC_DATA_IN2P: | ||
| 2557 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, | ||
| 2558 | RT5670_DMIC_1_DP_MASK, | ||
| 2559 | RT5670_DMIC_1_DP_IN2P); | ||
| 2560 | break; | ||
| 2561 | |||
| 2562 | case RT5670_DMIC_DATA_GPIO6: | ||
| 2563 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, | ||
| 2564 | RT5670_DMIC_1_DP_MASK, | ||
| 2565 | RT5670_DMIC_1_DP_GPIO6); | ||
| 2566 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, | ||
| 2567 | RT5670_GP6_PIN_MASK, | ||
| 2568 | RT5670_GP6_PIN_DMIC1_SDA); | ||
| 2569 | break; | ||
| 2570 | |||
| 2571 | case RT5670_DMIC_DATA_GPIO7: | ||
| 2572 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, | ||
| 2573 | RT5670_DMIC_1_DP_MASK, | ||
| 2574 | RT5670_DMIC_1_DP_GPIO7); | ||
| 2575 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, | ||
| 2576 | RT5670_GP7_PIN_MASK, | ||
| 2577 | RT5670_GP7_PIN_DMIC1_SDA); | ||
| 2578 | break; | ||
| 2579 | |||
| 2580 | default: | ||
| 2581 | break; | ||
| 2582 | } | ||
| 2583 | |||
| 2584 | switch (rt5670->pdata.dmic2_data_pin) { | ||
| 2585 | case RT5670_DMIC_DATA_IN3N: | ||
| 2586 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, | ||
| 2587 | RT5670_DMIC_2_DP_MASK, | ||
| 2588 | RT5670_DMIC_2_DP_IN3N); | ||
| 2589 | break; | ||
| 2590 | |||
| 2591 | case RT5670_DMIC_DATA_GPIO8: | ||
| 2592 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL1, | ||
| 2593 | RT5670_DMIC_2_DP_MASK, | ||
| 2594 | RT5670_DMIC_2_DP_GPIO8); | ||
| 2595 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, | ||
| 2596 | RT5670_GP8_PIN_MASK, | ||
| 2597 | RT5670_GP8_PIN_DMIC2_SDA); | ||
| 2598 | break; | ||
| 2599 | |||
| 2600 | default: | ||
| 2601 | break; | ||
| 2602 | } | ||
| 2603 | |||
| 2604 | switch (rt5670->pdata.dmic3_data_pin) { | ||
| 2605 | case RT5670_DMIC_DATA_GPIO5: | ||
| 2606 | regmap_update_bits(rt5670->regmap, RT5670_DMIC_CTRL2, | ||
| 2607 | RT5670_DMIC_3_DP_MASK, | ||
| 2608 | RT5670_DMIC_3_DP_GPIO5); | ||
| 2609 | regmap_update_bits(rt5670->regmap, RT5670_GPIO_CTRL1, | ||
| 2610 | RT5670_GP5_PIN_MASK, | ||
| 2611 | RT5670_GP5_PIN_DMIC3_SDA); | ||
| 2612 | break; | ||
| 2613 | |||
| 2614 | case RT5670_DMIC_DATA_GPIO9: | ||
| 2615 | case RT5670_DMIC_DATA_GPIO10: | ||
| 2616 | dev_err(&i2c->dev, | ||
| 2617 | "Always use GPIO5 as DMIC3 data pin\n"); | ||
| 2618 | break; | ||
| 2619 | |||
| 2620 | default: | ||
| 2621 | break; | ||
| 2622 | } | ||
| 2623 | |||
| 2624 | } | ||
| 2625 | |||
| 2626 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5670, | ||
| 2627 | rt5670_dai, ARRAY_SIZE(rt5670_dai)); | ||
| 2628 | if (ret < 0) | ||
| 2629 | goto err; | ||
| 2630 | |||
| 2631 | return 0; | ||
| 2632 | err: | ||
| 2633 | return ret; | ||
| 2634 | } | ||
| 2635 | |||
| 2636 | static int rt5670_i2c_remove(struct i2c_client *i2c) | ||
| 2637 | { | ||
| 2638 | snd_soc_unregister_codec(&i2c->dev); | ||
| 2639 | |||
| 2640 | return 0; | ||
| 2641 | } | ||
| 2642 | |||
| 2643 | static struct i2c_driver rt5670_i2c_driver = { | ||
| 2644 | .driver = { | ||
| 2645 | .name = "rt5670", | ||
| 2646 | .owner = THIS_MODULE, | ||
| 2647 | }, | ||
| 2648 | .probe = rt5670_i2c_probe, | ||
| 2649 | .remove = rt5670_i2c_remove, | ||
| 2650 | .id_table = rt5670_i2c_id, | ||
| 2651 | }; | ||
| 2652 | |||
| 2653 | module_i2c_driver(rt5670_i2c_driver); | ||
| 2654 | |||
| 2655 | MODULE_DESCRIPTION("ASoC RT5670 driver"); | ||
| 2656 | MODULE_AUTHOR("Bard Liao <bardliao@realtek.com>"); | ||
| 2657 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/codecs/rt5670.h b/sound/soc/codecs/rt5670.h new file mode 100644 index 000000000000..a0b5c855b492 --- /dev/null +++ b/sound/soc/codecs/rt5670.h | |||
| @@ -0,0 +1,2000 @@ | |||
| 1 | /* | ||
| 2 | * rt5670.h -- RT5670 ALSA SoC audio driver | ||
| 3 | * | ||
| 4 | * Copyright 2014 Realtek Microelectronics | ||
| 5 | * Author: Bard Liao <bardliao@realtek.com> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify | ||
| 8 | * it under the terms of the GNU General Public License version 2 as | ||
| 9 | * published by the Free Software Foundation. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #ifndef __RT5670_H__ | ||
| 13 | #define __RT5670_H__ | ||
| 14 | |||
| 15 | #include <sound/rt5670.h> | ||
| 16 | |||
| 17 | /* Info */ | ||
| 18 | #define RT5670_RESET 0x00 | ||
| 19 | #define RT5670_VENDOR_ID 0xfd | ||
| 20 | #define RT5670_VENDOR_ID1 0xfe | ||
| 21 | #define RT5670_VENDOR_ID2 0xff | ||
| 22 | /* I/O - Output */ | ||
| 23 | #define RT5670_HP_VOL 0x02 | ||
| 24 | #define RT5670_LOUT1 0x03 | ||
| 25 | /* I/O - Input */ | ||
| 26 | #define RT5670_CJ_CTRL1 0x0a | ||
| 27 | #define RT5670_CJ_CTRL2 0x0b | ||
| 28 | #define RT5670_CJ_CTRL3 0x0c | ||
| 29 | #define RT5670_IN2 0x0e | ||
| 30 | #define RT5670_INL1_INR1_VOL 0x0f | ||
| 31 | /* I/O - ADC/DAC/DMIC */ | ||
| 32 | #define RT5670_DAC1_DIG_VOL 0x19 | ||
| 33 | #define RT5670_DAC2_DIG_VOL 0x1a | ||
| 34 | #define RT5670_DAC_CTRL 0x1b | ||
| 35 | #define RT5670_STO1_ADC_DIG_VOL 0x1c | ||
| 36 | #define RT5670_MONO_ADC_DIG_VOL 0x1d | ||
| 37 | #define RT5670_ADC_BST_VOL1 0x1e | ||
| 38 | #define RT5670_STO2_ADC_DIG_VOL 0x1f | ||
| 39 | /* Mixer - D-D */ | ||
| 40 | #define RT5670_ADC_BST_VOL2 0x20 | ||
| 41 | #define RT5670_STO2_ADC_MIXER 0x26 | ||
| 42 | #define RT5670_STO1_ADC_MIXER 0x27 | ||
| 43 | #define RT5670_MONO_ADC_MIXER 0x28 | ||
| 44 | #define RT5670_AD_DA_MIXER 0x29 | ||
| 45 | #define RT5670_STO_DAC_MIXER 0x2a | ||
| 46 | #define RT5670_DD_MIXER 0x2b | ||
| 47 | #define RT5670_DIG_MIXER 0x2c | ||
| 48 | #define RT5670_DSP_PATH1 0x2d | ||
| 49 | #define RT5670_DSP_PATH2 0x2e | ||
| 50 | #define RT5670_DIG_INF1_DATA 0x2f | ||
| 51 | #define RT5670_DIG_INF2_DATA 0x30 | ||
| 52 | /* Mixer - PDM */ | ||
| 53 | #define RT5670_PDM_OUT_CTRL 0x31 | ||
| 54 | #define RT5670_PDM_DATA_CTRL1 0x32 | ||
| 55 | #define RT5670_PDM1_DATA_CTRL2 0x33 | ||
| 56 | #define RT5670_PDM1_DATA_CTRL3 0x34 | ||
| 57 | #define RT5670_PDM1_DATA_CTRL4 0x35 | ||
| 58 | #define RT5670_PDM2_DATA_CTRL2 0x36 | ||
| 59 | #define RT5670_PDM2_DATA_CTRL3 0x37 | ||
| 60 | #define RT5670_PDM2_DATA_CTRL4 0x38 | ||
| 61 | /* Mixer - ADC */ | ||
| 62 | #define RT5670_REC_L1_MIXER 0x3b | ||
| 63 | #define RT5670_REC_L2_MIXER 0x3c | ||
| 64 | #define RT5670_REC_R1_MIXER 0x3d | ||
| 65 | #define RT5670_REC_R2_MIXER 0x3e | ||
| 66 | /* Mixer - DAC */ | ||
| 67 | #define RT5670_HPO_MIXER 0x45 | ||
| 68 | #define RT5670_MONO_MIXER 0x4c | ||
| 69 | #define RT5670_OUT_L1_MIXER 0x4f | ||
| 70 | #define RT5670_OUT_R1_MIXER 0x52 | ||
| 71 | #define RT5670_LOUT_MIXER 0x53 | ||
| 72 | /* Power */ | ||
| 73 | #define RT5670_PWR_DIG1 0x61 | ||
| 74 | #define RT5670_PWR_DIG2 0x62 | ||
| 75 | #define RT5670_PWR_ANLG1 0x63 | ||
| 76 | #define RT5670_PWR_ANLG2 0x64 | ||
| 77 | #define RT5670_PWR_MIXER 0x65 | ||
| 78 | #define RT5670_PWR_VOL 0x66 | ||
| 79 | /* Private Register Control */ | ||
| 80 | #define RT5670_PRIV_INDEX 0x6a | ||
| 81 | #define RT5670_PRIV_DATA 0x6c | ||
| 82 | /* Format - ADC/DAC */ | ||
| 83 | #define RT5670_I2S4_SDP 0x6f | ||
| 84 | #define RT5670_I2S1_SDP 0x70 | ||
| 85 | #define RT5670_I2S2_SDP 0x71 | ||
| 86 | #define RT5670_I2S3_SDP 0x72 | ||
| 87 | #define RT5670_ADDA_CLK1 0x73 | ||
| 88 | #define RT5670_ADDA_CLK2 0x74 | ||
| 89 | #define RT5670_DMIC_CTRL1 0x75 | ||
| 90 | #define RT5670_DMIC_CTRL2 0x76 | ||
| 91 | /* Format - TDM Control */ | ||
| 92 | #define RT5670_TDM_CTRL_1 0x77 | ||
| 93 | #define RT5670_TDM_CTRL_2 0x78 | ||
| 94 | #define RT5670_TDM_CTRL_3 0x79 | ||
| 95 | |||
| 96 | /* Function - Analog */ | ||
| 97 | #define RT5670_DSP_CLK 0x7f | ||
| 98 | #define RT5670_GLB_CLK 0x80 | ||
| 99 | #define RT5670_PLL_CTRL1 0x81 | ||
| 100 | #define RT5670_PLL_CTRL2 0x82 | ||
| 101 | #define RT5670_ASRC_1 0x83 | ||
| 102 | #define RT5670_ASRC_2 0x84 | ||
| 103 | #define RT5670_ASRC_3 0x85 | ||
| 104 | #define RT5670_ASRC_4 0x86 | ||
| 105 | #define RT5670_ASRC_5 0x87 | ||
| 106 | #define RT5670_ASRC_7 0x89 | ||
| 107 | #define RT5670_ASRC_8 0x8a | ||
| 108 | #define RT5670_ASRC_9 0x8b | ||
| 109 | #define RT5670_ASRC_10 0x8c | ||
| 110 | #define RT5670_ASRC_11 0x8d | ||
| 111 | #define RT5670_DEPOP_M1 0x8e | ||
| 112 | #define RT5670_DEPOP_M2 0x8f | ||
| 113 | #define RT5670_DEPOP_M3 0x90 | ||
| 114 | #define RT5670_CHARGE_PUMP 0x91 | ||
| 115 | #define RT5670_MICBIAS 0x93 | ||
| 116 | #define RT5670_A_JD_CTRL1 0x94 | ||
| 117 | #define RT5670_A_JD_CTRL2 0x95 | ||
| 118 | #define RT5670_ASRC_12 0x97 | ||
| 119 | #define RT5670_ASRC_13 0x98 | ||
| 120 | #define RT5670_ASRC_14 0x99 | ||
| 121 | #define RT5670_VAD_CTRL1 0x9a | ||
| 122 | #define RT5670_VAD_CTRL2 0x9b | ||
| 123 | #define RT5670_VAD_CTRL3 0x9c | ||
| 124 | #define RT5670_VAD_CTRL4 0x9d | ||
| 125 | #define RT5670_VAD_CTRL5 0x9e | ||
| 126 | /* Function - Digital */ | ||
| 127 | #define RT5670_ADC_EQ_CTRL1 0xae | ||
| 128 | #define RT5670_ADC_EQ_CTRL2 0xaf | ||
| 129 | #define RT5670_EQ_CTRL1 0xb0 | ||
| 130 | #define RT5670_EQ_CTRL2 0xb1 | ||
| 131 | #define RT5670_ALC_DRC_CTRL1 0xb2 | ||
| 132 | #define RT5670_ALC_DRC_CTRL2 0xb3 | ||
| 133 | #define RT5670_ALC_CTRL_1 0xb4 | ||
| 134 | #define RT5670_ALC_CTRL_2 0xb5 | ||
| 135 | #define RT5670_ALC_CTRL_3 0xb6 | ||
| 136 | #define RT5670_ALC_CTRL_4 0xb7 | ||
| 137 | #define RT5670_JD_CTRL 0xbb | ||
| 138 | #define RT5670_IRQ_CTRL1 0xbd | ||
| 139 | #define RT5670_IRQ_CTRL2 0xbe | ||
| 140 | #define RT5670_INT_IRQ_ST 0xbf | ||
| 141 | #define RT5670_GPIO_CTRL1 0xc0 | ||
| 142 | #define RT5670_GPIO_CTRL2 0xc1 | ||
| 143 | #define RT5670_GPIO_CTRL3 0xc2 | ||
| 144 | #define RT5670_SCRABBLE_FUN 0xcd | ||
| 145 | #define RT5670_SCRABBLE_CTRL 0xce | ||
| 146 | #define RT5670_BASE_BACK 0xcf | ||
| 147 | #define RT5670_MP3_PLUS1 0xd0 | ||
| 148 | #define RT5670_MP3_PLUS2 0xd1 | ||
| 149 | #define RT5670_ADJ_HPF1 0xd3 | ||
| 150 | #define RT5670_ADJ_HPF2 0xd4 | ||
| 151 | #define RT5670_HP_CALIB_AMP_DET 0xd6 | ||
| 152 | #define RT5670_SV_ZCD1 0xd9 | ||
| 153 | #define RT5670_SV_ZCD2 0xda | ||
| 154 | #define RT5670_IL_CMD 0xdb | ||
| 155 | #define RT5670_IL_CMD2 0xdc | ||
| 156 | #define RT5670_IL_CMD3 0xdd | ||
| 157 | #define RT5670_DRC_HL_CTRL1 0xe6 | ||
| 158 | #define RT5670_DRC_HL_CTRL2 0xe7 | ||
| 159 | #define RT5670_ADC_MONO_HP_CTRL1 0xec | ||
| 160 | #define RT5670_ADC_MONO_HP_CTRL2 0xed | ||
| 161 | #define RT5670_ADC_STO2_HP_CTRL1 0xee | ||
| 162 | #define RT5670_ADC_STO2_HP_CTRL2 0xef | ||
| 163 | #define RT5670_JD_CTRL3 0xf8 | ||
| 164 | #define RT5670_JD_CTRL4 0xf9 | ||
| 165 | /* General Control */ | ||
| 166 | #define RT5670_DIG_MISC 0xfa | ||
| 167 | #define RT5670_GEN_CTRL2 0xfb | ||
| 168 | #define RT5670_GEN_CTRL3 0xfc | ||
| 169 | |||
| 170 | |||
| 171 | /* Index of Codec Private Register definition */ | ||
| 172 | #define RT5670_DIG_VOL 0x00 | ||
| 173 | #define RT5670_PR_ALC_CTRL_1 0x01 | ||
| 174 | #define RT5670_PR_ALC_CTRL_2 0x02 | ||
| 175 | #define RT5670_PR_ALC_CTRL_3 0x03 | ||
| 176 | #define RT5670_PR_ALC_CTRL_4 0x04 | ||
| 177 | #define RT5670_PR_ALC_CTRL_5 0x05 | ||
| 178 | #define RT5670_PR_ALC_CTRL_6 0x06 | ||
| 179 | #define RT5670_BIAS_CUR1 0x12 | ||
| 180 | #define RT5670_BIAS_CUR3 0x14 | ||
| 181 | #define RT5670_CLSD_INT_REG1 0x1c | ||
| 182 | #define RT5670_MAMP_INT_REG2 0x37 | ||
| 183 | #define RT5670_CHOP_DAC_ADC 0x3d | ||
| 184 | #define RT5670_MIXER_INT_REG 0x3f | ||
| 185 | #define RT5670_3D_SPK 0x63 | ||
| 186 | #define RT5670_WND_1 0x6c | ||
| 187 | #define RT5670_WND_2 0x6d | ||
| 188 | #define RT5670_WND_3 0x6e | ||
| 189 | #define RT5670_WND_4 0x6f | ||
| 190 | #define RT5670_WND_5 0x70 | ||
| 191 | #define RT5670_WND_8 0x73 | ||
| 192 | #define RT5670_DIP_SPK_INF 0x75 | ||
| 193 | #define RT5670_HP_DCC_INT1 0x77 | ||
| 194 | #define RT5670_EQ_BW_LOP 0xa0 | ||
| 195 | #define RT5670_EQ_GN_LOP 0xa1 | ||
| 196 | #define RT5670_EQ_FC_BP1 0xa2 | ||
| 197 | #define RT5670_EQ_BW_BP1 0xa3 | ||
| 198 | #define RT5670_EQ_GN_BP1 0xa4 | ||
| 199 | #define RT5670_EQ_FC_BP2 0xa5 | ||
| 200 | #define RT5670_EQ_BW_BP2 0xa6 | ||
| 201 | #define RT5670_EQ_GN_BP2 0xa7 | ||
| 202 | #define RT5670_EQ_FC_BP3 0xa8 | ||
| 203 | #define RT5670_EQ_BW_BP3 0xa9 | ||
| 204 | #define RT5670_EQ_GN_BP3 0xaa | ||
| 205 | #define RT5670_EQ_FC_BP4 0xab | ||
| 206 | #define RT5670_EQ_BW_BP4 0xac | ||
| 207 | #define RT5670_EQ_GN_BP4 0xad | ||
| 208 | #define RT5670_EQ_FC_HIP1 0xae | ||
| 209 | #define RT5670_EQ_GN_HIP1 0xaf | ||
| 210 | #define RT5670_EQ_FC_HIP2 0xb0 | ||
| 211 | #define RT5670_EQ_BW_HIP2 0xb1 | ||
| 212 | #define RT5670_EQ_GN_HIP2 0xb2 | ||
| 213 | #define RT5670_EQ_PRE_VOL 0xb3 | ||
| 214 | #define RT5670_EQ_PST_VOL 0xb4 | ||
| 215 | |||
| 216 | |||
| 217 | /* global definition */ | ||
| 218 | #define RT5670_L_MUTE (0x1 << 15) | ||
| 219 | #define RT5670_L_MUTE_SFT 15 | ||
| 220 | #define RT5670_VOL_L_MUTE (0x1 << 14) | ||
| 221 | #define RT5670_VOL_L_SFT 14 | ||
| 222 | #define RT5670_R_MUTE (0x1 << 7) | ||
| 223 | #define RT5670_R_MUTE_SFT 7 | ||
| 224 | #define RT5670_VOL_R_MUTE (0x1 << 6) | ||
| 225 | #define RT5670_VOL_R_SFT 6 | ||
| 226 | #define RT5670_L_VOL_MASK (0x3f << 8) | ||
| 227 | #define RT5670_L_VOL_SFT 8 | ||
| 228 | #define RT5670_R_VOL_MASK (0x3f) | ||
| 229 | #define RT5670_R_VOL_SFT 0 | ||
| 230 | |||
| 231 | /* Combo Jack Control 1 (0x0a) */ | ||
| 232 | #define RT5670_CBJ_BST1_MASK (0xf << 12) | ||
| 233 | #define RT5670_CBJ_BST1_SFT (12) | ||
| 234 | #define RT5670_CBJ_JD_HP_EN (0x1 << 9) | ||
| 235 | #define RT5670_CBJ_JD_MIC_EN (0x1 << 8) | ||
| 236 | #define RT5670_CBJ_BST1_EN (0x1 << 2) | ||
| 237 | |||
| 238 | /* Combo Jack Control 1 (0x0b) */ | ||
| 239 | #define RT5670_CBJ_MN_JD (0x1 << 12) | ||
| 240 | #define RT5670_CAPLESS_EN (0x1 << 11) | ||
| 241 | #define RT5670_CBJ_DET_MODE (0x1 << 7) | ||
| 242 | |||
| 243 | /* IN2 Control (0x0e) */ | ||
| 244 | #define RT5670_BST_MASK1 (0xf<<12) | ||
| 245 | #define RT5670_BST_SFT1 12 | ||
| 246 | #define RT5670_BST_MASK2 (0xf<<8) | ||
| 247 | #define RT5670_BST_SFT2 8 | ||
| 248 | #define RT5670_IN_DF1 (0x1 << 7) | ||
| 249 | #define RT5670_IN_SFT1 7 | ||
| 250 | #define RT5670_IN_DF2 (0x1 << 6) | ||
| 251 | #define RT5670_IN_SFT2 6 | ||
| 252 | |||
| 253 | /* INL and INR Volume Control (0x0f) */ | ||
| 254 | #define RT5670_INL_SEL_MASK (0x1 << 15) | ||
| 255 | #define RT5670_INL_SEL_SFT 15 | ||
| 256 | #define RT5670_INL_SEL_IN4P (0x0 << 15) | ||
| 257 | #define RT5670_INL_SEL_MONOP (0x1 << 15) | ||
| 258 | #define RT5670_INL_VOL_MASK (0x1f << 8) | ||
| 259 | #define RT5670_INL_VOL_SFT 8 | ||
| 260 | #define RT5670_INR_SEL_MASK (0x1 << 7) | ||
| 261 | #define RT5670_INR_SEL_SFT 7 | ||
| 262 | #define RT5670_INR_SEL_IN4N (0x0 << 7) | ||
| 263 | #define RT5670_INR_SEL_MONON (0x1 << 7) | ||
| 264 | #define RT5670_INR_VOL_MASK (0x1f) | ||
| 265 | #define RT5670_INR_VOL_SFT 0 | ||
| 266 | |||
| 267 | /* Sidetone Control (0x18) */ | ||
| 268 | #define RT5670_ST_SEL_MASK (0x7 << 9) | ||
| 269 | #define RT5670_ST_SEL_SFT 9 | ||
| 270 | #define RT5670_M_ST_DACR2 (0x1 << 8) | ||
| 271 | #define RT5670_M_ST_DACR2_SFT 8 | ||
| 272 | #define RT5670_M_ST_DACL2 (0x1 << 7) | ||
| 273 | #define RT5670_M_ST_DACL2_SFT 7 | ||
| 274 | #define RT5670_ST_EN (0x1 << 6) | ||
| 275 | #define RT5670_ST_EN_SFT 6 | ||
| 276 | |||
| 277 | /* DAC1 Digital Volume (0x19) */ | ||
| 278 | #define RT5670_DAC_L1_VOL_MASK (0xff << 8) | ||
| 279 | #define RT5670_DAC_L1_VOL_SFT 8 | ||
| 280 | #define RT5670_DAC_R1_VOL_MASK (0xff) | ||
| 281 | #define RT5670_DAC_R1_VOL_SFT 0 | ||
| 282 | |||
| 283 | /* DAC2 Digital Volume (0x1a) */ | ||
| 284 | #define RT5670_DAC_L2_VOL_MASK (0xff << 8) | ||
| 285 | #define RT5670_DAC_L2_VOL_SFT 8 | ||
| 286 | #define RT5670_DAC_R2_VOL_MASK (0xff) | ||
| 287 | #define RT5670_DAC_R2_VOL_SFT 0 | ||
| 288 | |||
| 289 | /* DAC2 Control (0x1b) */ | ||
| 290 | #define RT5670_M_DAC_L2_VOL (0x1 << 13) | ||
| 291 | #define RT5670_M_DAC_L2_VOL_SFT 13 | ||
| 292 | #define RT5670_M_DAC_R2_VOL (0x1 << 12) | ||
| 293 | #define RT5670_M_DAC_R2_VOL_SFT 12 | ||
| 294 | #define RT5670_DAC2_L_SEL_MASK (0x7 << 4) | ||
| 295 | #define RT5670_DAC2_L_SEL_SFT 4 | ||
| 296 | #define RT5670_DAC2_R_SEL_MASK (0x7 << 0) | ||
| 297 | #define RT5670_DAC2_R_SEL_SFT 0 | ||
| 298 | |||
| 299 | /* ADC Digital Volume Control (0x1c) */ | ||
| 300 | #define RT5670_ADC_L_VOL_MASK (0x7f << 8) | ||
| 301 | #define RT5670_ADC_L_VOL_SFT 8 | ||
| 302 | #define RT5670_ADC_R_VOL_MASK (0x7f) | ||
| 303 | #define RT5670_ADC_R_VOL_SFT 0 | ||
| 304 | |||
| 305 | /* Mono ADC Digital Volume Control (0x1d) */ | ||
| 306 | #define RT5670_MONO_ADC_L_VOL_MASK (0x7f << 8) | ||
| 307 | #define RT5670_MONO_ADC_L_VOL_SFT 8 | ||
| 308 | #define RT5670_MONO_ADC_R_VOL_MASK (0x7f) | ||
| 309 | #define RT5670_MONO_ADC_R_VOL_SFT 0 | ||
| 310 | |||
| 311 | /* ADC Boost Volume Control (0x1e) */ | ||
| 312 | #define RT5670_STO1_ADC_L_BST_MASK (0x3 << 14) | ||
| 313 | #define RT5670_STO1_ADC_L_BST_SFT 14 | ||
| 314 | #define RT5670_STO1_ADC_R_BST_MASK (0x3 << 12) | ||
| 315 | #define RT5670_STO1_ADC_R_BST_SFT 12 | ||
| 316 | #define RT5670_STO1_ADC_COMP_MASK (0x3 << 10) | ||
| 317 | #define RT5670_STO1_ADC_COMP_SFT 10 | ||
| 318 | #define RT5670_STO2_ADC_L_BST_MASK (0x3 << 8) | ||
| 319 | #define RT5670_STO2_ADC_L_BST_SFT 8 | ||
| 320 | #define RT5670_STO2_ADC_R_BST_MASK (0x3 << 6) | ||
| 321 | #define RT5670_STO2_ADC_R_BST_SFT 6 | ||
| 322 | #define RT5670_STO2_ADC_COMP_MASK (0x3 << 4) | ||
| 323 | #define RT5670_STO2_ADC_COMP_SFT 4 | ||
| 324 | |||
| 325 | /* Stereo2 ADC Mixer Control (0x26) */ | ||
| 326 | #define RT5670_STO2_ADC_SRC_MASK (0x1 << 15) | ||
| 327 | #define RT5670_STO2_ADC_SRC_SFT 15 | ||
| 328 | |||
| 329 | /* Stereo ADC Mixer Control (0x26 0x27) */ | ||
| 330 | #define RT5670_M_ADC_L1 (0x1 << 14) | ||
| 331 | #define RT5670_M_ADC_L1_SFT 14 | ||
| 332 | #define RT5670_M_ADC_L2 (0x1 << 13) | ||
| 333 | #define RT5670_M_ADC_L2_SFT 13 | ||
| 334 | #define RT5670_ADC_1_SRC_MASK (0x1 << 12) | ||
| 335 | #define RT5670_ADC_1_SRC_SFT 12 | ||
| 336 | #define RT5670_ADC_1_SRC_ADC (0x1 << 12) | ||
| 337 | #define RT5670_ADC_1_SRC_DACMIX (0x0 << 12) | ||
| 338 | #define RT5670_ADC_2_SRC_MASK (0x1 << 11) | ||
| 339 | #define RT5670_ADC_2_SRC_SFT 11 | ||
| 340 | #define RT5670_ADC_SRC_MASK (0x1 << 10) | ||
| 341 | #define RT5670_ADC_SRC_SFT 10 | ||
| 342 | #define RT5670_DMIC_SRC_MASK (0x3 << 8) | ||
| 343 | #define RT5670_DMIC_SRC_SFT 8 | ||
| 344 | #define RT5670_M_ADC_R1 (0x1 << 6) | ||
| 345 | #define RT5670_M_ADC_R1_SFT 6 | ||
| 346 | #define RT5670_M_ADC_R2 (0x1 << 5) | ||
| 347 | #define RT5670_M_ADC_R2_SFT 5 | ||
| 348 | #define RT5670_DMIC3_SRC_MASK (0x1 << 1) | ||
| 349 | #define RT5670_DMIC3_SRC_SFT 0 | ||
| 350 | |||
| 351 | /* Mono ADC Mixer Control (0x28) */ | ||
| 352 | #define RT5670_M_MONO_ADC_L1 (0x1 << 14) | ||
| 353 | #define RT5670_M_MONO_ADC_L1_SFT 14 | ||
| 354 | #define RT5670_M_MONO_ADC_L2 (0x1 << 13) | ||
| 355 | #define RT5670_M_MONO_ADC_L2_SFT 13 | ||
| 356 | #define RT5670_MONO_ADC_L1_SRC_MASK (0x1 << 12) | ||
| 357 | #define RT5670_MONO_ADC_L1_SRC_SFT 12 | ||
| 358 | #define RT5670_MONO_ADC_L1_SRC_DACMIXL (0x0 << 12) | ||
| 359 | #define RT5670_MONO_ADC_L1_SRC_ADCL (0x1 << 12) | ||
| 360 | #define RT5670_MONO_ADC_L2_SRC_MASK (0x1 << 11) | ||
| 361 | #define RT5670_MONO_ADC_L2_SRC_SFT 11 | ||
| 362 | #define RT5670_MONO_ADC_L_SRC_MASK (0x1 << 10) | ||
| 363 | #define RT5670_MONO_ADC_L_SRC_SFT 10 | ||
| 364 | #define RT5670_MONO_DMIC_L_SRC_MASK (0x3 << 8) | ||
| 365 | #define RT5670_MONO_DMIC_L_SRC_SFT 8 | ||
| 366 | #define RT5670_M_MONO_ADC_R1 (0x1 << 6) | ||
| 367 | #define RT5670_M_MONO_ADC_R1_SFT 6 | ||
| 368 | #define RT5670_M_MONO_ADC_R2 (0x1 << 5) | ||
| 369 | #define RT5670_M_MONO_ADC_R2_SFT 5 | ||
| 370 | #define RT5670_MONO_ADC_R1_SRC_MASK (0x1 << 4) | ||
| 371 | #define RT5670_MONO_ADC_R1_SRC_SFT 4 | ||
| 372 | #define RT5670_MONO_ADC_R1_SRC_ADCR (0x1 << 4) | ||
| 373 | #define RT5670_MONO_ADC_R1_SRC_DACMIXR (0x0 << 4) | ||
| 374 | #define RT5670_MONO_ADC_R2_SRC_MASK (0x1 << 3) | ||
| 375 | #define RT5670_MONO_ADC_R2_SRC_SFT 3 | ||
| 376 | #define RT5670_MONO_DMIC_R_SRC_MASK (0x3) | ||
| 377 | #define RT5670_MONO_DMIC_R_SRC_SFT 0 | ||
| 378 | |||
| 379 | /* ADC Mixer to DAC Mixer Control (0x29) */ | ||
| 380 | #define RT5670_M_ADCMIX_L (0x1 << 15) | ||
| 381 | #define RT5670_M_ADCMIX_L_SFT 15 | ||
| 382 | #define RT5670_M_DAC1_L (0x1 << 14) | ||
| 383 | #define RT5670_M_DAC1_L_SFT 14 | ||
| 384 | #define RT5670_DAC1_R_SEL_MASK (0x3 << 10) | ||
| 385 | #define RT5670_DAC1_R_SEL_SFT 10 | ||
| 386 | #define RT5670_DAC1_R_SEL_IF1 (0x0 << 10) | ||
| 387 | #define RT5670_DAC1_R_SEL_IF2 (0x1 << 10) | ||
| 388 | #define RT5670_DAC1_R_SEL_IF3 (0x2 << 10) | ||
| 389 | #define RT5670_DAC1_R_SEL_IF4 (0x3 << 10) | ||
| 390 | #define RT5670_DAC1_L_SEL_MASK (0x3 << 8) | ||
| 391 | #define RT5670_DAC1_L_SEL_SFT 8 | ||
| 392 | #define RT5670_DAC1_L_SEL_IF1 (0x0 << 8) | ||
| 393 | #define RT5670_DAC1_L_SEL_IF2 (0x1 << 8) | ||
| 394 | #define RT5670_DAC1_L_SEL_IF3 (0x2 << 8) | ||
| 395 | #define RT5670_DAC1_L_SEL_IF4 (0x3 << 8) | ||
| 396 | #define RT5670_M_ADCMIX_R (0x1 << 7) | ||
| 397 | #define RT5670_M_ADCMIX_R_SFT 7 | ||
| 398 | #define RT5670_M_DAC1_R (0x1 << 6) | ||
| 399 | #define RT5670_M_DAC1_R_SFT 6 | ||
| 400 | |||
| 401 | /* Stereo DAC Mixer Control (0x2a) */ | ||
| 402 | #define RT5670_M_DAC_L1 (0x1 << 14) | ||
| 403 | #define RT5670_M_DAC_L1_SFT 14 | ||
| 404 | #define RT5670_DAC_L1_STO_L_VOL_MASK (0x1 << 13) | ||
| 405 | #define RT5670_DAC_L1_STO_L_VOL_SFT 13 | ||
| 406 | #define RT5670_M_DAC_L2 (0x1 << 12) | ||
| 407 | #define RT5670_M_DAC_L2_SFT 12 | ||
| 408 | #define RT5670_DAC_L2_STO_L_VOL_MASK (0x1 << 11) | ||
| 409 | #define RT5670_DAC_L2_STO_L_VOL_SFT 11 | ||
| 410 | #define RT5670_M_DAC_R1_STO_L (0x1 << 9) | ||
| 411 | #define RT5670_M_DAC_R1_STO_L_SFT 9 | ||
| 412 | #define RT5670_DAC_R1_STO_L_VOL_MASK (0x1 << 8) | ||
| 413 | #define RT5670_DAC_R1_STO_L_VOL_SFT 8 | ||
| 414 | #define RT5670_M_DAC_R1 (0x1 << 6) | ||
| 415 | #define RT5670_M_DAC_R1_SFT 6 | ||
| 416 | #define RT5670_DAC_R1_STO_R_VOL_MASK (0x1 << 5) | ||
| 417 | #define RT5670_DAC_R1_STO_R_VOL_SFT 5 | ||
| 418 | #define RT5670_M_DAC_R2 (0x1 << 4) | ||
| 419 | #define RT5670_M_DAC_R2_SFT 4 | ||
| 420 | #define RT5670_DAC_R2_STO_R_VOL_MASK (0x1 << 3) | ||
| 421 | #define RT5670_DAC_R2_STO_R_VOL_SFT 3 | ||
| 422 | #define RT5670_M_DAC_L1_STO_R (0x1 << 1) | ||
| 423 | #define RT5670_M_DAC_L1_STO_R_SFT 1 | ||
| 424 | #define RT5670_DAC_L1_STO_R_VOL_MASK (0x1) | ||
| 425 | #define RT5670_DAC_L1_STO_R_VOL_SFT 0 | ||
| 426 | |||
| 427 | /* Mono DAC Mixer Control (0x2b) */ | ||
| 428 | #define RT5670_M_DAC_L1_MONO_L (0x1 << 14) | ||
| 429 | #define RT5670_M_DAC_L1_MONO_L_SFT 14 | ||
| 430 | #define RT5670_DAC_L1_MONO_L_VOL_MASK (0x1 << 13) | ||
| 431 | #define RT5670_DAC_L1_MONO_L_VOL_SFT 13 | ||
| 432 | #define RT5670_M_DAC_L2_MONO_L (0x1 << 12) | ||
| 433 | #define RT5670_M_DAC_L2_MONO_L_SFT 12 | ||
| 434 | #define RT5670_DAC_L2_MONO_L_VOL_MASK (0x1 << 11) | ||
| 435 | #define RT5670_DAC_L2_MONO_L_VOL_SFT 11 | ||
| 436 | #define RT5670_M_DAC_R2_MONO_L (0x1 << 10) | ||
| 437 | #define RT5670_M_DAC_R2_MONO_L_SFT 10 | ||
| 438 | #define RT5670_DAC_R2_MONO_L_VOL_MASK (0x1 << 9) | ||
| 439 | #define RT5670_DAC_R2_MONO_L_VOL_SFT 9 | ||
| 440 | #define RT5670_M_DAC_R1_MONO_R (0x1 << 6) | ||
| 441 | #define RT5670_M_DAC_R1_MONO_R_SFT 6 | ||
| 442 | #define RT5670_DAC_R1_MONO_R_VOL_MASK (0x1 << 5) | ||
| 443 | #define RT5670_DAC_R1_MONO_R_VOL_SFT 5 | ||
| 444 | #define RT5670_M_DAC_R2_MONO_R (0x1 << 4) | ||
| 445 | #define RT5670_M_DAC_R2_MONO_R_SFT 4 | ||
| 446 | #define RT5670_DAC_R2_MONO_R_VOL_MASK (0x1 << 3) | ||
| 447 | #define RT5670_DAC_R2_MONO_R_VOL_SFT 3 | ||
| 448 | #define RT5670_M_DAC_L2_MONO_R (0x1 << 2) | ||
| 449 | #define RT5670_M_DAC_L2_MONO_R_SFT 2 | ||
| 450 | #define RT5670_DAC_L2_MONO_R_VOL_MASK (0x1 << 1) | ||
| 451 | #define RT5670_DAC_L2_MONO_R_VOL_SFT 1 | ||
| 452 | |||
| 453 | /* Digital Mixer Control (0x2c) */ | ||
| 454 | #define RT5670_M_STO_L_DAC_L (0x1 << 15) | ||
| 455 | #define RT5670_M_STO_L_DAC_L_SFT 15 | ||
| 456 | #define RT5670_STO_L_DAC_L_VOL_MASK (0x1 << 14) | ||
| 457 | #define RT5670_STO_L_DAC_L_VOL_SFT 14 | ||
| 458 | #define RT5670_M_DAC_L2_DAC_L (0x1 << 13) | ||
| 459 | #define RT5670_M_DAC_L2_DAC_L_SFT 13 | ||
| 460 | #define RT5670_DAC_L2_DAC_L_VOL_MASK (0x1 << 12) | ||
| 461 | #define RT5670_DAC_L2_DAC_L_VOL_SFT 12 | ||
| 462 | #define RT5670_M_STO_R_DAC_R (0x1 << 11) | ||
| 463 | #define RT5670_M_STO_R_DAC_R_SFT 11 | ||
| 464 | #define RT5670_STO_R_DAC_R_VOL_MASK (0x1 << 10) | ||
| 465 | #define RT5670_STO_R_DAC_R_VOL_SFT 10 | ||
| 466 | #define RT5670_M_DAC_R2_DAC_R (0x1 << 9) | ||
| 467 | #define RT5670_M_DAC_R2_DAC_R_SFT 9 | ||
| 468 | #define RT5670_DAC_R2_DAC_R_VOL_MASK (0x1 << 8) | ||
| 469 | #define RT5670_DAC_R2_DAC_R_VOL_SFT 8 | ||
| 470 | #define RT5670_M_DAC_R2_DAC_L (0x1 << 7) | ||
| 471 | #define RT5670_M_DAC_R2_DAC_L_SFT 7 | ||
| 472 | #define RT5670_DAC_R2_DAC_L_VOL_MASK (0x1 << 6) | ||
| 473 | #define RT5670_DAC_R2_DAC_L_VOL_SFT 6 | ||
| 474 | #define RT5670_M_DAC_L2_DAC_R (0x1 << 5) | ||
| 475 | #define RT5670_M_DAC_L2_DAC_R_SFT 5 | ||
| 476 | #define RT5670_DAC_L2_DAC_R_VOL_MASK (0x1 << 4) | ||
| 477 | #define RT5670_DAC_L2_DAC_R_VOL_SFT 4 | ||
| 478 | |||
| 479 | /* DSP Path Control 1 (0x2d) */ | ||
| 480 | #define RT5670_RXDP_SEL_MASK (0x7 << 13) | ||
| 481 | #define RT5670_RXDP_SEL_SFT 13 | ||
| 482 | #define RT5670_RXDP_SRC_MASK (0x3 << 11) | ||
| 483 | #define RT5670_RXDP_SRC_SFT 11 | ||
| 484 | #define RT5670_RXDP_SRC_NOR (0x0 << 11) | ||
| 485 | #define RT5670_RXDP_SRC_DIV2 (0x1 << 11) | ||
| 486 | #define RT5670_RXDP_SRC_DIV3 (0x2 << 11) | ||
| 487 | #define RT5670_TXDP_SRC_MASK (0x3 << 4) | ||
| 488 | #define RT5670_TXDP_SRC_SFT 4 | ||
| 489 | #define RT5670_TXDP_SRC_NOR (0x0 << 4) | ||
| 490 | #define RT5670_TXDP_SRC_DIV2 (0x1 << 4) | ||
| 491 | #define RT5670_TXDP_SRC_DIV3 (0x2 << 4) | ||
| 492 | #define RT5670_TXDP_SLOT_SEL_MASK (0x3 << 2) | ||
| 493 | #define RT5670_TXDP_SLOT_SEL_SFT 2 | ||
| 494 | #define RT5670_DSP_UL_SEL (0x1 << 1) | ||
| 495 | #define RT5670_DSP_UL_SFT 1 | ||
| 496 | #define RT5670_DSP_DL_SEL 0x1 | ||
| 497 | #define RT5670_DSP_DL_SFT 0 | ||
| 498 | |||
| 499 | /* DSP Path Control 2 (0x2e) */ | ||
| 500 | #define RT5670_TXDP_L_VOL_MASK (0x7f << 8) | ||
| 501 | #define RT5670_TXDP_L_VOL_SFT 8 | ||
| 502 | #define RT5670_TXDP_R_VOL_MASK (0x7f) | ||
| 503 | #define RT5670_TXDP_R_VOL_SFT 0 | ||
| 504 | |||
| 505 | /* Digital Interface Data Control (0x2f) */ | ||
| 506 | #define RT5670_IF1_ADC2_IN_SEL (0x1 << 15) | ||
| 507 | #define RT5670_IF1_ADC2_IN_SFT 15 | ||
| 508 | #define RT5670_IF2_ADC_IN_MASK (0x7 << 12) | ||
| 509 | #define RT5670_IF2_ADC_IN_SFT 12 | ||
| 510 | #define RT5670_IF2_DAC_SEL_MASK (0x3 << 10) | ||
| 511 | #define RT5670_IF2_DAC_SEL_SFT 10 | ||
| 512 | #define RT5670_IF2_ADC_SEL_MASK (0x3 << 8) | ||
| 513 | #define RT5670_IF2_ADC_SEL_SFT 8 | ||
| 514 | |||
| 515 | /* Digital Interface Data Control (0x30) */ | ||
| 516 | #define RT5670_IF4_ADC_IN_MASK (0x3 << 4) | ||
| 517 | #define RT5670_IF4_ADC_IN_SFT 4 | ||
| 518 | |||
| 519 | /* PDM Output Control (0x31) */ | ||
| 520 | #define RT5670_PDM1_L_MASK (0x1 << 15) | ||
| 521 | #define RT5670_PDM1_L_SFT 15 | ||
| 522 | #define RT5670_M_PDM1_L (0x1 << 14) | ||
| 523 | #define RT5670_M_PDM1_L_SFT 14 | ||
| 524 | #define RT5670_PDM1_R_MASK (0x1 << 13) | ||
| 525 | #define RT5670_PDM1_R_SFT 13 | ||
| 526 | #define RT5670_M_PDM1_R (0x1 << 12) | ||
| 527 | #define RT5670_M_PDM1_R_SFT 12 | ||
| 528 | #define RT5670_PDM2_L_MASK (0x1 << 11) | ||
| 529 | #define RT5670_PDM2_L_SFT 11 | ||
| 530 | #define RT5670_M_PDM2_L (0x1 << 10) | ||
| 531 | #define RT5670_M_PDM2_L_SFT 10 | ||
| 532 | #define RT5670_PDM2_R_MASK (0x1 << 9) | ||
| 533 | #define RT5670_PDM2_R_SFT 9 | ||
| 534 | #define RT5670_M_PDM2_R (0x1 << 8) | ||
| 535 | #define RT5670_M_PDM2_R_SFT 8 | ||
| 536 | #define RT5670_PDM2_BUSY (0x1 << 7) | ||
| 537 | #define RT5670_PDM1_BUSY (0x1 << 6) | ||
| 538 | #define RT5670_PDM_PATTERN (0x1 << 5) | ||
| 539 | #define RT5670_PDM_GAIN (0x1 << 4) | ||
| 540 | #define RT5670_PDM_DIV_MASK (0x3) | ||
| 541 | |||
| 542 | /* REC Left Mixer Control 1 (0x3b) */ | ||
| 543 | #define RT5670_G_HP_L_RM_L_MASK (0x7 << 13) | ||
| 544 | #define RT5670_G_HP_L_RM_L_SFT 13 | ||
| 545 | #define RT5670_G_IN_L_RM_L_MASK (0x7 << 10) | ||
| 546 | #define RT5670_G_IN_L_RM_L_SFT 10 | ||
| 547 | #define RT5670_G_BST4_RM_L_MASK (0x7 << 7) | ||
| 548 | #define RT5670_G_BST4_RM_L_SFT 7 | ||
| 549 | #define RT5670_G_BST3_RM_L_MASK (0x7 << 4) | ||
| 550 | #define RT5670_G_BST3_RM_L_SFT 4 | ||
| 551 | #define RT5670_G_BST2_RM_L_MASK (0x7 << 1) | ||
| 552 | #define RT5670_G_BST2_RM_L_SFT 1 | ||
| 553 | |||
| 554 | /* REC Left Mixer Control 2 (0x3c) */ | ||
| 555 | #define RT5670_G_BST1_RM_L_MASK (0x7 << 13) | ||
| 556 | #define RT5670_G_BST1_RM_L_SFT 13 | ||
| 557 | #define RT5670_M_IN_L_RM_L (0x1 << 5) | ||
| 558 | #define RT5670_M_IN_L_RM_L_SFT 5 | ||
| 559 | #define RT5670_M_BST2_RM_L (0x1 << 3) | ||
| 560 | #define RT5670_M_BST2_RM_L_SFT 3 | ||
| 561 | #define RT5670_M_BST1_RM_L (0x1 << 1) | ||
| 562 | #define RT5670_M_BST1_RM_L_SFT 1 | ||
| 563 | |||
| 564 | /* REC Right Mixer Control 1 (0x3d) */ | ||
| 565 | #define RT5670_G_HP_R_RM_R_MASK (0x7 << 13) | ||
| 566 | #define RT5670_G_HP_R_RM_R_SFT 13 | ||
| 567 | #define RT5670_G_IN_R_RM_R_MASK (0x7 << 10) | ||
| 568 | #define RT5670_G_IN_R_RM_R_SFT 10 | ||
| 569 | #define RT5670_G_BST4_RM_R_MASK (0x7 << 7) | ||
| 570 | #define RT5670_G_BST4_RM_R_SFT 7 | ||
| 571 | #define RT5670_G_BST3_RM_R_MASK (0x7 << 4) | ||
| 572 | #define RT5670_G_BST3_RM_R_SFT 4 | ||
| 573 | #define RT5670_G_BST2_RM_R_MASK (0x7 << 1) | ||
| 574 | #define RT5670_G_BST2_RM_R_SFT 1 | ||
| 575 | |||
| 576 | /* REC Right Mixer Control 2 (0x3e) */ | ||
| 577 | #define RT5670_G_BST1_RM_R_MASK (0x7 << 13) | ||
| 578 | #define RT5670_G_BST1_RM_R_SFT 13 | ||
| 579 | #define RT5670_M_IN_R_RM_R (0x1 << 5) | ||
| 580 | #define RT5670_M_IN_R_RM_R_SFT 5 | ||
| 581 | #define RT5670_M_BST2_RM_R (0x1 << 3) | ||
| 582 | #define RT5670_M_BST2_RM_R_SFT 3 | ||
| 583 | #define RT5670_M_BST1_RM_R (0x1 << 1) | ||
| 584 | #define RT5670_M_BST1_RM_R_SFT 1 | ||
| 585 | |||
| 586 | /* HPMIX Control (0x45) */ | ||
| 587 | #define RT5670_M_DAC2_HM (0x1 << 15) | ||
| 588 | #define RT5670_M_DAC2_HM_SFT 15 | ||
| 589 | #define RT5670_M_HPVOL_HM (0x1 << 14) | ||
| 590 | #define RT5670_M_HPVOL_HM_SFT 14 | ||
| 591 | #define RT5670_M_DAC1_HM (0x1 << 13) | ||
| 592 | #define RT5670_M_DAC1_HM_SFT 13 | ||
| 593 | #define RT5670_G_HPOMIX_MASK (0x1 << 12) | ||
| 594 | #define RT5670_G_HPOMIX_SFT 12 | ||
| 595 | #define RT5670_M_INR1_HMR (0x1 << 3) | ||
| 596 | #define RT5670_M_INR1_HMR_SFT 3 | ||
| 597 | #define RT5670_M_DACR1_HMR (0x1 << 2) | ||
| 598 | #define RT5670_M_DACR1_HMR_SFT 2 | ||
| 599 | #define RT5670_M_INL1_HML (0x1 << 1) | ||
| 600 | #define RT5670_M_INL1_HML_SFT 1 | ||
| 601 | #define RT5670_M_DACL1_HML (0x1) | ||
| 602 | #define RT5670_M_DACL1_HML_SFT 0 | ||
| 603 | |||
| 604 | /* Mono Output Mixer Control (0x4c) */ | ||
| 605 | #define RT5670_M_DAC_R2_MA (0x1 << 15) | ||
| 606 | #define RT5670_M_DAC_R2_MA_SFT 15 | ||
| 607 | #define RT5670_M_DAC_L2_MA (0x1 << 14) | ||
| 608 | #define RT5670_M_DAC_L2_MA_SFT 14 | ||
| 609 | #define RT5670_M_OV_R_MM (0x1 << 13) | ||
| 610 | #define RT5670_M_OV_R_MM_SFT 13 | ||
| 611 | #define RT5670_M_OV_L_MM (0x1 << 12) | ||
| 612 | #define RT5670_M_OV_L_MM_SFT 12 | ||
| 613 | #define RT5670_G_MONOMIX_MASK (0x1 << 10) | ||
| 614 | #define RT5670_G_MONOMIX_SFT 10 | ||
| 615 | #define RT5670_M_DAC_R2_MM (0x1 << 9) | ||
| 616 | #define RT5670_M_DAC_R2_MM_SFT 9 | ||
| 617 | #define RT5670_M_DAC_L2_MM (0x1 << 8) | ||
| 618 | #define RT5670_M_DAC_L2_MM_SFT 8 | ||
| 619 | #define RT5670_M_BST4_MM (0x1 << 7) | ||
| 620 | #define RT5670_M_BST4_MM_SFT 7 | ||
| 621 | |||
| 622 | /* Output Left Mixer Control 1 (0x4d) */ | ||
| 623 | #define RT5670_G_BST3_OM_L_MASK (0x7 << 13) | ||
| 624 | #define RT5670_G_BST3_OM_L_SFT 13 | ||
| 625 | #define RT5670_G_BST2_OM_L_MASK (0x7 << 10) | ||
| 626 | #define RT5670_G_BST2_OM_L_SFT 10 | ||
| 627 | #define RT5670_G_BST1_OM_L_MASK (0x7 << 7) | ||
| 628 | #define RT5670_G_BST1_OM_L_SFT 7 | ||
| 629 | #define RT5670_G_IN_L_OM_L_MASK (0x7 << 4) | ||
| 630 | #define RT5670_G_IN_L_OM_L_SFT 4 | ||
| 631 | #define RT5670_G_RM_L_OM_L_MASK (0x7 << 1) | ||
| 632 | #define RT5670_G_RM_L_OM_L_SFT 1 | ||
| 633 | |||
| 634 | /* Output Left Mixer Control 2 (0x4e) */ | ||
| 635 | #define RT5670_G_DAC_R2_OM_L_MASK (0x7 << 13) | ||
| 636 | #define RT5670_G_DAC_R2_OM_L_SFT 13 | ||
| 637 | #define RT5670_G_DAC_L2_OM_L_MASK (0x7 << 10) | ||
| 638 | #define RT5670_G_DAC_L2_OM_L_SFT 10 | ||
| 639 | #define RT5670_G_DAC_L1_OM_L_MASK (0x7 << 7) | ||
| 640 | #define RT5670_G_DAC_L1_OM_L_SFT 7 | ||
| 641 | |||
| 642 | /* Output Left Mixer Control 3 (0x4f) */ | ||
| 643 | #define RT5670_M_BST1_OM_L (0x1 << 5) | ||
| 644 | #define RT5670_M_BST1_OM_L_SFT 5 | ||
| 645 | #define RT5670_M_IN_L_OM_L (0x1 << 4) | ||
| 646 | #define RT5670_M_IN_L_OM_L_SFT 4 | ||
| 647 | #define RT5670_M_DAC_L2_OM_L (0x1 << 1) | ||
| 648 | #define RT5670_M_DAC_L2_OM_L_SFT 1 | ||
| 649 | #define RT5670_M_DAC_L1_OM_L (0x1) | ||
| 650 | #define RT5670_M_DAC_L1_OM_L_SFT 0 | ||
| 651 | |||
| 652 | /* Output Right Mixer Control 1 (0x50) */ | ||
| 653 | #define RT5670_G_BST4_OM_R_MASK (0x7 << 13) | ||
| 654 | #define RT5670_G_BST4_OM_R_SFT 13 | ||
| 655 | #define RT5670_G_BST2_OM_R_MASK (0x7 << 10) | ||
| 656 | #define RT5670_G_BST2_OM_R_SFT 10 | ||
| 657 | #define RT5670_G_BST1_OM_R_MASK (0x7 << 7) | ||
| 658 | #define RT5670_G_BST1_OM_R_SFT 7 | ||
| 659 | #define RT5670_G_IN_R_OM_R_MASK (0x7 << 4) | ||
| 660 | #define RT5670_G_IN_R_OM_R_SFT 4 | ||
| 661 | #define RT5670_G_RM_R_OM_R_MASK (0x7 << 1) | ||
| 662 | #define RT5670_G_RM_R_OM_R_SFT 1 | ||
| 663 | |||
| 664 | /* Output Right Mixer Control 2 (0x51) */ | ||
| 665 | #define RT5670_G_DAC_L2_OM_R_MASK (0x7 << 13) | ||
| 666 | #define RT5670_G_DAC_L2_OM_R_SFT 13 | ||
| 667 | #define RT5670_G_DAC_R2_OM_R_MASK (0x7 << 10) | ||
| 668 | #define RT5670_G_DAC_R2_OM_R_SFT 10 | ||
| 669 | #define RT5670_G_DAC_R1_OM_R_MASK (0x7 << 7) | ||
| 670 | #define RT5670_G_DAC_R1_OM_R_SFT 7 | ||
| 671 | |||
| 672 | /* Output Right Mixer Control 3 (0x52) */ | ||
| 673 | #define RT5670_M_BST2_OM_R (0x1 << 6) | ||
| 674 | #define RT5670_M_BST2_OM_R_SFT 6 | ||
| 675 | #define RT5670_M_IN_R_OM_R (0x1 << 4) | ||
| 676 | #define RT5670_M_IN_R_OM_R_SFT 4 | ||
| 677 | #define RT5670_M_DAC_R2_OM_R (0x1 << 1) | ||
| 678 | #define RT5670_M_DAC_R2_OM_R_SFT 1 | ||
| 679 | #define RT5670_M_DAC_R1_OM_R (0x1) | ||
| 680 | #define RT5670_M_DAC_R1_OM_R_SFT 0 | ||
| 681 | |||
| 682 | /* LOUT Mixer Control (0x53) */ | ||
| 683 | #define RT5670_M_DAC_L1_LM (0x1 << 15) | ||
| 684 | #define RT5670_M_DAC_L1_LM_SFT 15 | ||
| 685 | #define RT5670_M_DAC_R1_LM (0x1 << 14) | ||
| 686 | #define RT5670_M_DAC_R1_LM_SFT 14 | ||
| 687 | #define RT5670_M_OV_L_LM (0x1 << 13) | ||
| 688 | #define RT5670_M_OV_L_LM_SFT 13 | ||
| 689 | #define RT5670_M_OV_R_LM (0x1 << 12) | ||
| 690 | #define RT5670_M_OV_R_LM_SFT 12 | ||
| 691 | #define RT5670_G_LOUTMIX_MASK (0x1 << 11) | ||
| 692 | #define RT5670_G_LOUTMIX_SFT 11 | ||
| 693 | |||
| 694 | /* Power Management for Digital 1 (0x61) */ | ||
| 695 | #define RT5670_PWR_I2S1 (0x1 << 15) | ||
| 696 | #define RT5670_PWR_I2S1_BIT 15 | ||
| 697 | #define RT5670_PWR_I2S2 (0x1 << 14) | ||
| 698 | #define RT5670_PWR_I2S2_BIT 14 | ||
| 699 | #define RT5670_PWR_DAC_L1 (0x1 << 12) | ||
| 700 | #define RT5670_PWR_DAC_L1_BIT 12 | ||
| 701 | #define RT5670_PWR_DAC_R1 (0x1 << 11) | ||
| 702 | #define RT5670_PWR_DAC_R1_BIT 11 | ||
| 703 | #define RT5670_PWR_DAC_L2 (0x1 << 7) | ||
| 704 | #define RT5670_PWR_DAC_L2_BIT 7 | ||
| 705 | #define RT5670_PWR_DAC_R2 (0x1 << 6) | ||
| 706 | #define RT5670_PWR_DAC_R2_BIT 6 | ||
| 707 | #define RT5670_PWR_ADC_L (0x1 << 2) | ||
| 708 | #define RT5670_PWR_ADC_L_BIT 2 | ||
| 709 | #define RT5670_PWR_ADC_R (0x1 << 1) | ||
| 710 | #define RT5670_PWR_ADC_R_BIT 1 | ||
| 711 | #define RT5670_PWR_CLS_D (0x1) | ||
| 712 | #define RT5670_PWR_CLS_D_BIT 0 | ||
| 713 | |||
| 714 | /* Power Management for Digital 2 (0x62) */ | ||
| 715 | #define RT5670_PWR_ADC_S1F (0x1 << 15) | ||
| 716 | #define RT5670_PWR_ADC_S1F_BIT 15 | ||
| 717 | #define RT5670_PWR_ADC_MF_L (0x1 << 14) | ||
| 718 | #define RT5670_PWR_ADC_MF_L_BIT 14 | ||
| 719 | #define RT5670_PWR_ADC_MF_R (0x1 << 13) | ||
| 720 | #define RT5670_PWR_ADC_MF_R_BIT 13 | ||
| 721 | #define RT5670_PWR_I2S_DSP (0x1 << 12) | ||
| 722 | #define RT5670_PWR_I2S_DSP_BIT 12 | ||
| 723 | #define RT5670_PWR_DAC_S1F (0x1 << 11) | ||
| 724 | #define RT5670_PWR_DAC_S1F_BIT 11 | ||
| 725 | #define RT5670_PWR_DAC_MF_L (0x1 << 10) | ||
| 726 | #define RT5670_PWR_DAC_MF_L_BIT 10 | ||
| 727 | #define RT5670_PWR_DAC_MF_R (0x1 << 9) | ||
| 728 | #define RT5670_PWR_DAC_MF_R_BIT 9 | ||
| 729 | #define RT5670_PWR_ADC_S2F (0x1 << 8) | ||
| 730 | #define RT5670_PWR_ADC_S2F_BIT 8 | ||
| 731 | #define RT5670_PWR_PDM1 (0x1 << 7) | ||
| 732 | #define RT5670_PWR_PDM1_BIT 7 | ||
| 733 | #define RT5670_PWR_PDM2 (0x1 << 6) | ||
| 734 | #define RT5670_PWR_PDM2_BIT 6 | ||
| 735 | |||
| 736 | /* Power Management for Analog 1 (0x63) */ | ||
| 737 | #define RT5670_PWR_VREF1 (0x1 << 15) | ||
| 738 | #define RT5670_PWR_VREF1_BIT 15 | ||
| 739 | #define RT5670_PWR_FV1 (0x1 << 14) | ||
| 740 | #define RT5670_PWR_FV1_BIT 14 | ||
| 741 | #define RT5670_PWR_MB (0x1 << 13) | ||
| 742 | #define RT5670_PWR_MB_BIT 13 | ||
| 743 | #define RT5670_PWR_LM (0x1 << 12) | ||
| 744 | #define RT5670_PWR_LM_BIT 12 | ||
| 745 | #define RT5670_PWR_BG (0x1 << 11) | ||
| 746 | #define RT5670_PWR_BG_BIT 11 | ||
| 747 | #define RT5670_PWR_HP_L (0x1 << 7) | ||
| 748 | #define RT5670_PWR_HP_L_BIT 7 | ||
| 749 | #define RT5670_PWR_HP_R (0x1 << 6) | ||
| 750 | #define RT5670_PWR_HP_R_BIT 6 | ||
| 751 | #define RT5670_PWR_HA (0x1 << 5) | ||
| 752 | #define RT5670_PWR_HA_BIT 5 | ||
| 753 | #define RT5670_PWR_VREF2 (0x1 << 4) | ||
| 754 | #define RT5670_PWR_VREF2_BIT 4 | ||
| 755 | #define RT5670_PWR_FV2 (0x1 << 3) | ||
| 756 | #define RT5670_PWR_FV2_BIT 3 | ||
| 757 | #define RT5670_LDO_SEL_MASK (0x3) | ||
| 758 | #define RT5670_LDO_SEL_SFT 0 | ||
| 759 | |||
| 760 | /* Power Management for Analog 2 (0x64) */ | ||
| 761 | #define RT5670_PWR_BST1 (0x1 << 15) | ||
| 762 | #define RT5670_PWR_BST1_BIT 15 | ||
| 763 | #define RT5670_PWR_BST2 (0x1 << 13) | ||
| 764 | #define RT5670_PWR_BST2_BIT 13 | ||
| 765 | #define RT5670_PWR_MB1 (0x1 << 11) | ||
| 766 | #define RT5670_PWR_MB1_BIT 11 | ||
| 767 | #define RT5670_PWR_MB2 (0x1 << 10) | ||
| 768 | #define RT5670_PWR_MB2_BIT 10 | ||
| 769 | #define RT5670_PWR_PLL (0x1 << 9) | ||
| 770 | #define RT5670_PWR_PLL_BIT 9 | ||
| 771 | #define RT5670_PWR_BST1_P (0x1 << 6) | ||
| 772 | #define RT5670_PWR_BST1_P_BIT 6 | ||
| 773 | #define RT5670_PWR_BST2_P (0x1 << 4) | ||
| 774 | #define RT5670_PWR_BST2_P_BIT 4 | ||
| 775 | #define RT5670_PWR_JD1 (0x1 << 2) | ||
| 776 | #define RT5670_PWR_JD1_BIT 2 | ||
| 777 | #define RT5670_PWR_JD (0x1 << 1) | ||
| 778 | #define RT5670_PWR_JD_BIT 1 | ||
| 779 | |||
| 780 | /* Power Management for Mixer (0x65) */ | ||
| 781 | #define RT5670_PWR_OM_L (0x1 << 15) | ||
| 782 | #define RT5670_PWR_OM_L_BIT 15 | ||
| 783 | #define RT5670_PWR_OM_R (0x1 << 14) | ||
| 784 | #define RT5670_PWR_OM_R_BIT 14 | ||
| 785 | #define RT5670_PWR_RM_L (0x1 << 11) | ||
| 786 | #define RT5670_PWR_RM_L_BIT 11 | ||
| 787 | #define RT5670_PWR_RM_R (0x1 << 10) | ||
| 788 | #define RT5670_PWR_RM_R_BIT 10 | ||
| 789 | |||
| 790 | /* Power Management for Volume (0x66) */ | ||
| 791 | #define RT5670_PWR_HV_L (0x1 << 11) | ||
| 792 | #define RT5670_PWR_HV_L_BIT 11 | ||
| 793 | #define RT5670_PWR_HV_R (0x1 << 10) | ||
| 794 | #define RT5670_PWR_HV_R_BIT 10 | ||
| 795 | #define RT5670_PWR_IN_L (0x1 << 9) | ||
| 796 | #define RT5670_PWR_IN_L_BIT 9 | ||
| 797 | #define RT5670_PWR_IN_R (0x1 << 8) | ||
| 798 | #define RT5670_PWR_IN_R_BIT 8 | ||
| 799 | #define RT5670_PWR_MIC_DET (0x1 << 5) | ||
| 800 | #define RT5670_PWR_MIC_DET_BIT 5 | ||
| 801 | |||
| 802 | /* I2S1/2/3 Audio Serial Data Port Control (0x70 0x71 0x72) */ | ||
| 803 | #define RT5670_I2S_MS_MASK (0x1 << 15) | ||
| 804 | #define RT5670_I2S_MS_SFT 15 | ||
| 805 | #define RT5670_I2S_MS_M (0x0 << 15) | ||
| 806 | #define RT5670_I2S_MS_S (0x1 << 15) | ||
| 807 | #define RT5670_I2S_IF_MASK (0x7 << 12) | ||
| 808 | #define RT5670_I2S_IF_SFT 12 | ||
| 809 | #define RT5670_I2S_O_CP_MASK (0x3 << 10) | ||
| 810 | #define RT5670_I2S_O_CP_SFT 10 | ||
| 811 | #define RT5670_I2S_O_CP_OFF (0x0 << 10) | ||
| 812 | #define RT5670_I2S_O_CP_U_LAW (0x1 << 10) | ||
| 813 | #define RT5670_I2S_O_CP_A_LAW (0x2 << 10) | ||
| 814 | #define RT5670_I2S_I_CP_MASK (0x3 << 8) | ||
| 815 | #define RT5670_I2S_I_CP_SFT 8 | ||
| 816 | #define RT5670_I2S_I_CP_OFF (0x0 << 8) | ||
| 817 | #define RT5670_I2S_I_CP_U_LAW (0x1 << 8) | ||
| 818 | #define RT5670_I2S_I_CP_A_LAW (0x2 << 8) | ||
| 819 | #define RT5670_I2S_BP_MASK (0x1 << 7) | ||
| 820 | #define RT5670_I2S_BP_SFT 7 | ||
| 821 | #define RT5670_I2S_BP_NOR (0x0 << 7) | ||
| 822 | #define RT5670_I2S_BP_INV (0x1 << 7) | ||
| 823 | #define RT5670_I2S_DL_MASK (0x3 << 2) | ||
| 824 | #define RT5670_I2S_DL_SFT 2 | ||
| 825 | #define RT5670_I2S_DL_16 (0x0 << 2) | ||
| 826 | #define RT5670_I2S_DL_20 (0x1 << 2) | ||
| 827 | #define RT5670_I2S_DL_24 (0x2 << 2) | ||
| 828 | #define RT5670_I2S_DL_8 (0x3 << 2) | ||
| 829 | #define RT5670_I2S_DF_MASK (0x3) | ||
| 830 | #define RT5670_I2S_DF_SFT 0 | ||
| 831 | #define RT5670_I2S_DF_I2S (0x0) | ||
| 832 | #define RT5670_I2S_DF_LEFT (0x1) | ||
| 833 | #define RT5670_I2S_DF_PCM_A (0x2) | ||
| 834 | #define RT5670_I2S_DF_PCM_B (0x3) | ||
| 835 | |||
| 836 | /* I2S2 Audio Serial Data Port Control (0x71) */ | ||
| 837 | #define RT5670_I2S2_SDI_MASK (0x1 << 6) | ||
| 838 | #define RT5670_I2S2_SDI_SFT 6 | ||
| 839 | #define RT5670_I2S2_SDI_I2S1 (0x0 << 6) | ||
| 840 | #define RT5670_I2S2_SDI_I2S2 (0x1 << 6) | ||
| 841 | |||
| 842 | /* ADC/DAC Clock Control 1 (0x73) */ | ||
| 843 | #define RT5670_I2S_BCLK_MS1_MASK (0x1 << 15) | ||
| 844 | #define RT5670_I2S_BCLK_MS1_SFT 15 | ||
| 845 | #define RT5670_I2S_BCLK_MS1_32 (0x0 << 15) | ||
| 846 | #define RT5670_I2S_BCLK_MS1_64 (0x1 << 15) | ||
| 847 | #define RT5670_I2S_PD1_MASK (0x7 << 12) | ||
| 848 | #define RT5670_I2S_PD1_SFT 12 | ||
| 849 | #define RT5670_I2S_PD1_1 (0x0 << 12) | ||
| 850 | #define RT5670_I2S_PD1_2 (0x1 << 12) | ||
| 851 | #define RT5670_I2S_PD1_3 (0x2 << 12) | ||
| 852 | #define RT5670_I2S_PD1_4 (0x3 << 12) | ||
| 853 | #define RT5670_I2S_PD1_6 (0x4 << 12) | ||
| 854 | #define RT5670_I2S_PD1_8 (0x5 << 12) | ||
| 855 | #define RT5670_I2S_PD1_12 (0x6 << 12) | ||
| 856 | #define RT5670_I2S_PD1_16 (0x7 << 12) | ||
| 857 | #define RT5670_I2S_BCLK_MS2_MASK (0x1 << 11) | ||
| 858 | #define RT5670_I2S_BCLK_MS2_SFT 11 | ||
| 859 | #define RT5670_I2S_BCLK_MS2_32 (0x0 << 11) | ||
| 860 | #define RT5670_I2S_BCLK_MS2_64 (0x1 << 11) | ||
| 861 | #define RT5670_I2S_PD2_MASK (0x7 << 8) | ||
| 862 | #define RT5670_I2S_PD2_SFT 8 | ||
| 863 | #define RT5670_I2S_PD2_1 (0x0 << 8) | ||
| 864 | #define RT5670_I2S_PD2_2 (0x1 << 8) | ||
| 865 | #define RT5670_I2S_PD2_3 (0x2 << 8) | ||
| 866 | #define RT5670_I2S_PD2_4 (0x3 << 8) | ||
| 867 | #define RT5670_I2S_PD2_6 (0x4 << 8) | ||
| 868 | #define RT5670_I2S_PD2_8 (0x5 << 8) | ||
| 869 | #define RT5670_I2S_PD2_12 (0x6 << 8) | ||
| 870 | #define RT5670_I2S_PD2_16 (0x7 << 8) | ||
| 871 | #define RT5670_I2S_BCLK_MS3_MASK (0x1 << 7) | ||
| 872 | #define RT5670_I2S_BCLK_MS3_SFT 7 | ||
| 873 | #define RT5670_I2S_BCLK_MS3_32 (0x0 << 7) | ||
| 874 | #define RT5670_I2S_BCLK_MS3_64 (0x1 << 7) | ||
| 875 | #define RT5670_I2S_PD3_MASK (0x7 << 4) | ||
| 876 | #define RT5670_I2S_PD3_SFT 4 | ||
| 877 | #define RT5670_I2S_PD3_1 (0x0 << 4) | ||
| 878 | #define RT5670_I2S_PD3_2 (0x1 << 4) | ||
| 879 | #define RT5670_I2S_PD3_3 (0x2 << 4) | ||
| 880 | #define RT5670_I2S_PD3_4 (0x3 << 4) | ||
| 881 | #define RT5670_I2S_PD3_6 (0x4 << 4) | ||
| 882 | #define RT5670_I2S_PD3_8 (0x5 << 4) | ||
| 883 | #define RT5670_I2S_PD3_12 (0x6 << 4) | ||
| 884 | #define RT5670_I2S_PD3_16 (0x7 << 4) | ||
| 885 | #define RT5670_DAC_OSR_MASK (0x3 << 2) | ||
| 886 | #define RT5670_DAC_OSR_SFT 2 | ||
| 887 | #define RT5670_DAC_OSR_128 (0x0 << 2) | ||
| 888 | #define RT5670_DAC_OSR_64 (0x1 << 2) | ||
| 889 | #define RT5670_DAC_OSR_32 (0x2 << 2) | ||
| 890 | #define RT5670_DAC_OSR_16 (0x3 << 2) | ||
| 891 | #define RT5670_ADC_OSR_MASK (0x3) | ||
| 892 | #define RT5670_ADC_OSR_SFT 0 | ||
| 893 | #define RT5670_ADC_OSR_128 (0x0) | ||
| 894 | #define RT5670_ADC_OSR_64 (0x1) | ||
| 895 | #define RT5670_ADC_OSR_32 (0x2) | ||
| 896 | #define RT5670_ADC_OSR_16 (0x3) | ||
| 897 | |||
| 898 | /* ADC/DAC Clock Control 2 (0x74) */ | ||
| 899 | #define RT5670_DAC_L_OSR_MASK (0x3 << 14) | ||
| 900 | #define RT5670_DAC_L_OSR_SFT 14 | ||
| 901 | #define RT5670_DAC_L_OSR_128 (0x0 << 14) | ||
| 902 | #define RT5670_DAC_L_OSR_64 (0x1 << 14) | ||
| 903 | #define RT5670_DAC_L_OSR_32 (0x2 << 14) | ||
| 904 | #define RT5670_DAC_L_OSR_16 (0x3 << 14) | ||
| 905 | #define RT5670_ADC_R_OSR_MASK (0x3 << 12) | ||
| 906 | #define RT5670_ADC_R_OSR_SFT 12 | ||
| 907 | #define RT5670_ADC_R_OSR_128 (0x0 << 12) | ||
| 908 | #define RT5670_ADC_R_OSR_64 (0x1 << 12) | ||
| 909 | #define RT5670_ADC_R_OSR_32 (0x2 << 12) | ||
| 910 | #define RT5670_ADC_R_OSR_16 (0x3 << 12) | ||
| 911 | #define RT5670_DAHPF_EN (0x1 << 11) | ||
| 912 | #define RT5670_DAHPF_EN_SFT 11 | ||
| 913 | #define RT5670_ADHPF_EN (0x1 << 10) | ||
| 914 | #define RT5670_ADHPF_EN_SFT 10 | ||
| 915 | |||
| 916 | /* Digital Microphone Control (0x75) */ | ||
| 917 | #define RT5670_DMIC_1_EN_MASK (0x1 << 15) | ||
| 918 | #define RT5670_DMIC_1_EN_SFT 15 | ||
| 919 | #define RT5670_DMIC_1_DIS (0x0 << 15) | ||
| 920 | #define RT5670_DMIC_1_EN (0x1 << 15) | ||
| 921 | #define RT5670_DMIC_2_EN_MASK (0x1 << 14) | ||
| 922 | #define RT5670_DMIC_2_EN_SFT 14 | ||
| 923 | #define RT5670_DMIC_2_DIS (0x0 << 14) | ||
| 924 | #define RT5670_DMIC_2_EN (0x1 << 14) | ||
| 925 | #define RT5670_DMIC_1L_LH_MASK (0x1 << 13) | ||
| 926 | #define RT5670_DMIC_1L_LH_SFT 13 | ||
| 927 | #define RT5670_DMIC_1L_LH_FALLING (0x0 << 13) | ||
| 928 | #define RT5670_DMIC_1L_LH_RISING (0x1 << 13) | ||
| 929 | #define RT5670_DMIC_1R_LH_MASK (0x1 << 12) | ||
| 930 | #define RT5670_DMIC_1R_LH_SFT 12 | ||
| 931 | #define RT5670_DMIC_1R_LH_FALLING (0x0 << 12) | ||
| 932 | #define RT5670_DMIC_1R_LH_RISING (0x1 << 12) | ||
| 933 | #define RT5670_DMIC_2_DP_MASK (0x1 << 10) | ||
| 934 | #define RT5670_DMIC_2_DP_SFT 10 | ||
| 935 | #define RT5670_DMIC_2_DP_GPIO8 (0x0 << 10) | ||
| 936 | #define RT5670_DMIC_2_DP_IN3N (0x1 << 10) | ||
| 937 | #define RT5670_DMIC_2L_LH_MASK (0x1 << 9) | ||
| 938 | #define RT5670_DMIC_2L_LH_SFT 9 | ||
| 939 | #define RT5670_DMIC_2L_LH_FALLING (0x0 << 9) | ||
| 940 | #define RT5670_DMIC_2L_LH_RISING (0x1 << 9) | ||
| 941 | #define RT5670_DMIC_2R_LH_MASK (0x1 << 8) | ||
| 942 | #define RT5670_DMIC_2R_LH_SFT 8 | ||
| 943 | #define RT5670_DMIC_2R_LH_FALLING (0x0 << 8) | ||
| 944 | #define RT5670_DMIC_2R_LH_RISING (0x1 << 8) | ||
| 945 | #define RT5670_DMIC_CLK_MASK (0x7 << 5) | ||
| 946 | #define RT5670_DMIC_CLK_SFT 5 | ||
| 947 | #define RT5670_DMIC_3_EN_MASK (0x1 << 4) | ||
| 948 | #define RT5670_DMIC_3_EN_SFT 4 | ||
| 949 | #define RT5670_DMIC_3_DIS (0x0 << 4) | ||
| 950 | #define RT5670_DMIC_3_EN (0x1 << 4) | ||
| 951 | #define RT5670_DMIC_1_DP_MASK (0x3 << 0) | ||
| 952 | #define RT5670_DMIC_1_DP_SFT 0 | ||
| 953 | #define RT5670_DMIC_1_DP_GPIO6 (0x0 << 0) | ||
| 954 | #define RT5670_DMIC_1_DP_IN2P (0x1 << 0) | ||
| 955 | #define RT5670_DMIC_1_DP_GPIO7 (0x2 << 0) | ||
| 956 | |||
| 957 | /* Digital Microphone Control2 (0x76) */ | ||
| 958 | #define RT5670_DMIC_3_DP_MASK (0x3 << 6) | ||
| 959 | #define RT5670_DMIC_3_DP_SFT 6 | ||
| 960 | #define RT5670_DMIC_3_DP_GPIO9 (0x0 << 6) | ||
| 961 | #define RT5670_DMIC_3_DP_GPIO10 (0x1 << 6) | ||
| 962 | #define RT5670_DMIC_3_DP_GPIO5 (0x2 << 6) | ||
| 963 | |||
| 964 | /* Global Clock Control (0x80) */ | ||
| 965 | #define RT5670_SCLK_SRC_MASK (0x3 << 14) | ||
| 966 | #define RT5670_SCLK_SRC_SFT 14 | ||
| 967 | #define RT5670_SCLK_SRC_MCLK (0x0 << 14) | ||
| 968 | #define RT5670_SCLK_SRC_PLL1 (0x1 << 14) | ||
| 969 | #define RT5670_SCLK_SRC_RCCLK (0x2 << 14) /* 15MHz */ | ||
| 970 | #define RT5670_PLL1_SRC_MASK (0x3 << 12) | ||
| 971 | #define RT5670_PLL1_SRC_SFT 12 | ||
| 972 | #define RT5670_PLL1_SRC_MCLK (0x0 << 12) | ||
| 973 | #define RT5670_PLL1_SRC_BCLK1 (0x1 << 12) | ||
| 974 | #define RT5670_PLL1_SRC_BCLK2 (0x2 << 12) | ||
| 975 | #define RT5670_PLL1_SRC_BCLK3 (0x3 << 12) | ||
| 976 | #define RT5670_PLL1_PD_MASK (0x1 << 3) | ||
| 977 | #define RT5670_PLL1_PD_SFT 3 | ||
| 978 | #define RT5670_PLL1_PD_1 (0x0 << 3) | ||
| 979 | #define RT5670_PLL1_PD_2 (0x1 << 3) | ||
| 980 | |||
| 981 | #define RT5670_PLL_INP_MAX 40000000 | ||
| 982 | #define RT5670_PLL_INP_MIN 256000 | ||
| 983 | /* PLL M/N/K Code Control 1 (0x81) */ | ||
| 984 | #define RT5670_PLL_N_MAX 0x1ff | ||
| 985 | #define RT5670_PLL_N_MASK (RT5670_PLL_N_MAX << 7) | ||
| 986 | #define RT5670_PLL_N_SFT 7 | ||
| 987 | #define RT5670_PLL_K_MAX 0x1f | ||
| 988 | #define RT5670_PLL_K_MASK (RT5670_PLL_K_MAX) | ||
| 989 | #define RT5670_PLL_K_SFT 0 | ||
| 990 | |||
| 991 | /* PLL M/N/K Code Control 2 (0x82) */ | ||
| 992 | #define RT5670_PLL_M_MAX 0xf | ||
| 993 | #define RT5670_PLL_M_MASK (RT5670_PLL_M_MAX << 12) | ||
| 994 | #define RT5670_PLL_M_SFT 12 | ||
| 995 | #define RT5670_PLL_M_BP (0x1 << 11) | ||
| 996 | #define RT5670_PLL_M_BP_SFT 11 | ||
| 997 | |||
| 998 | /* ASRC Control 1 (0x83) */ | ||
| 999 | #define RT5670_STO_T_MASK (0x1 << 15) | ||
| 1000 | #define RT5670_STO_T_SFT 15 | ||
| 1001 | #define RT5670_STO_T_SCLK (0x0 << 15) | ||
| 1002 | #define RT5670_STO_T_LRCK1 (0x1 << 15) | ||
| 1003 | #define RT5670_M1_T_MASK (0x1 << 14) | ||
| 1004 | #define RT5670_M1_T_SFT 14 | ||
| 1005 | #define RT5670_M1_T_I2S2 (0x0 << 14) | ||
| 1006 | #define RT5670_M1_T_I2S2_D3 (0x1 << 14) | ||
| 1007 | #define RT5670_I2S2_F_MASK (0x1 << 12) | ||
| 1008 | #define RT5670_I2S2_F_SFT 12 | ||
| 1009 | #define RT5670_I2S2_F_I2S2_D2 (0x0 << 12) | ||
| 1010 | #define RT5670_I2S2_F_I2S1_TCLK (0x1 << 12) | ||
| 1011 | #define RT5670_DMIC_1_M_MASK (0x1 << 9) | ||
| 1012 | #define RT5670_DMIC_1_M_SFT 9 | ||
| 1013 | #define RT5670_DMIC_1_M_NOR (0x0 << 9) | ||
| 1014 | #define RT5670_DMIC_1_M_ASYN (0x1 << 9) | ||
| 1015 | #define RT5670_DMIC_2_M_MASK (0x1 << 8) | ||
| 1016 | #define RT5670_DMIC_2_M_SFT 8 | ||
| 1017 | #define RT5670_DMIC_2_M_NOR (0x0 << 8) | ||
| 1018 | #define RT5670_DMIC_2_M_ASYN (0x1 << 8) | ||
| 1019 | |||
| 1020 | /* ASRC Control 2 (0x84) */ | ||
| 1021 | #define RT5670_MDA_L_M_MASK (0x1 << 15) | ||
| 1022 | #define RT5670_MDA_L_M_SFT 15 | ||
| 1023 | #define RT5670_MDA_L_M_NOR (0x0 << 15) | ||
| 1024 | #define RT5670_MDA_L_M_ASYN (0x1 << 15) | ||
| 1025 | #define RT5670_MDA_R_M_MASK (0x1 << 14) | ||
| 1026 | #define RT5670_MDA_R_M_SFT 14 | ||
| 1027 | #define RT5670_MDA_R_M_NOR (0x0 << 14) | ||
| 1028 | #define RT5670_MDA_R_M_ASYN (0x1 << 14) | ||
| 1029 | #define RT5670_MAD_L_M_MASK (0x1 << 13) | ||
| 1030 | #define RT5670_MAD_L_M_SFT 13 | ||
| 1031 | #define RT5670_MAD_L_M_NOR (0x0 << 13) | ||
| 1032 | #define RT5670_MAD_L_M_ASYN (0x1 << 13) | ||
| 1033 | #define RT5670_MAD_R_M_MASK (0x1 << 12) | ||
| 1034 | #define RT5670_MAD_R_M_SFT 12 | ||
| 1035 | #define RT5670_MAD_R_M_NOR (0x0 << 12) | ||
| 1036 | #define RT5670_MAD_R_M_ASYN (0x1 << 12) | ||
| 1037 | #define RT5670_ADC_M_MASK (0x1 << 11) | ||
| 1038 | #define RT5670_ADC_M_SFT 11 | ||
| 1039 | #define RT5670_ADC_M_NOR (0x0 << 11) | ||
| 1040 | #define RT5670_ADC_M_ASYN (0x1 << 11) | ||
| 1041 | #define RT5670_STO_DAC_M_MASK (0x1 << 5) | ||
| 1042 | #define RT5670_STO_DAC_M_SFT 5 | ||
| 1043 | #define RT5670_STO_DAC_M_NOR (0x0 << 5) | ||
| 1044 | #define RT5670_STO_DAC_M_ASYN (0x1 << 5) | ||
| 1045 | #define RT5670_I2S1_R_D_MASK (0x1 << 4) | ||
| 1046 | #define RT5670_I2S1_R_D_SFT 4 | ||
| 1047 | #define RT5670_I2S1_R_D_DIS (0x0 << 4) | ||
| 1048 | #define RT5670_I2S1_R_D_EN (0x1 << 4) | ||
| 1049 | #define RT5670_I2S2_R_D_MASK (0x1 << 3) | ||
| 1050 | #define RT5670_I2S2_R_D_SFT 3 | ||
| 1051 | #define RT5670_I2S2_R_D_DIS (0x0 << 3) | ||
| 1052 | #define RT5670_I2S2_R_D_EN (0x1 << 3) | ||
| 1053 | #define RT5670_PRE_SCLK_MASK (0x3) | ||
| 1054 | #define RT5670_PRE_SCLK_SFT 0 | ||
| 1055 | #define RT5670_PRE_SCLK_512 (0x0) | ||
| 1056 | #define RT5670_PRE_SCLK_1024 (0x1) | ||
| 1057 | #define RT5670_PRE_SCLK_2048 (0x2) | ||
| 1058 | |||
| 1059 | /* ASRC Control 3 (0x85) */ | ||
| 1060 | #define RT5670_I2S1_RATE_MASK (0xf << 12) | ||
| 1061 | #define RT5670_I2S1_RATE_SFT 12 | ||
| 1062 | #define RT5670_I2S2_RATE_MASK (0xf << 8) | ||
| 1063 | #define RT5670_I2S2_RATE_SFT 8 | ||
| 1064 | |||
| 1065 | /* ASRC Control 4 (0x89) */ | ||
| 1066 | #define RT5670_I2S1_PD_MASK (0x7 << 12) | ||
| 1067 | #define RT5670_I2S1_PD_SFT 12 | ||
| 1068 | #define RT5670_I2S2_PD_MASK (0x7 << 8) | ||
| 1069 | #define RT5670_I2S2_PD_SFT 8 | ||
| 1070 | |||
| 1071 | /* HPOUT Over Current Detection (0x8b) */ | ||
| 1072 | #define RT5670_HP_OVCD_MASK (0x1 << 10) | ||
| 1073 | #define RT5670_HP_OVCD_SFT 10 | ||
| 1074 | #define RT5670_HP_OVCD_DIS (0x0 << 10) | ||
| 1075 | #define RT5670_HP_OVCD_EN (0x1 << 10) | ||
| 1076 | #define RT5670_HP_OC_TH_MASK (0x3 << 8) | ||
| 1077 | #define RT5670_HP_OC_TH_SFT 8 | ||
| 1078 | #define RT5670_HP_OC_TH_90 (0x0 << 8) | ||
| 1079 | #define RT5670_HP_OC_TH_105 (0x1 << 8) | ||
| 1080 | #define RT5670_HP_OC_TH_120 (0x2 << 8) | ||
| 1081 | #define RT5670_HP_OC_TH_135 (0x3 << 8) | ||
| 1082 | |||
| 1083 | /* Class D Over Current Control (0x8c) */ | ||
| 1084 | #define RT5670_CLSD_OC_MASK (0x1 << 9) | ||
| 1085 | #define RT5670_CLSD_OC_SFT 9 | ||
| 1086 | #define RT5670_CLSD_OC_PU (0x0 << 9) | ||
| 1087 | #define RT5670_CLSD_OC_PD (0x1 << 9) | ||
| 1088 | #define RT5670_AUTO_PD_MASK (0x1 << 8) | ||
| 1089 | #define RT5670_AUTO_PD_SFT 8 | ||
| 1090 | #define RT5670_AUTO_PD_DIS (0x0 << 8) | ||
| 1091 | #define RT5670_AUTO_PD_EN (0x1 << 8) | ||
| 1092 | #define RT5670_CLSD_OC_TH_MASK (0x3f) | ||
| 1093 | #define RT5670_CLSD_OC_TH_SFT 0 | ||
| 1094 | |||
| 1095 | /* Class D Output Control (0x8d) */ | ||
| 1096 | #define RT5670_CLSD_RATIO_MASK (0xf << 12) | ||
| 1097 | #define RT5670_CLSD_RATIO_SFT 12 | ||
| 1098 | #define RT5670_CLSD_OM_MASK (0x1 << 11) | ||
| 1099 | #define RT5670_CLSD_OM_SFT 11 | ||
| 1100 | #define RT5670_CLSD_OM_MONO (0x0 << 11) | ||
| 1101 | #define RT5670_CLSD_OM_STO (0x1 << 11) | ||
| 1102 | #define RT5670_CLSD_SCH_MASK (0x1 << 10) | ||
| 1103 | #define RT5670_CLSD_SCH_SFT 10 | ||
| 1104 | #define RT5670_CLSD_SCH_L (0x0 << 10) | ||
| 1105 | #define RT5670_CLSD_SCH_S (0x1 << 10) | ||
| 1106 | |||
| 1107 | /* Depop Mode Control 1 (0x8e) */ | ||
| 1108 | #define RT5670_SMT_TRIG_MASK (0x1 << 15) | ||
| 1109 | #define RT5670_SMT_TRIG_SFT 15 | ||
| 1110 | #define RT5670_SMT_TRIG_DIS (0x0 << 15) | ||
| 1111 | #define RT5670_SMT_TRIG_EN (0x1 << 15) | ||
| 1112 | #define RT5670_HP_L_SMT_MASK (0x1 << 9) | ||
| 1113 | #define RT5670_HP_L_SMT_SFT 9 | ||
| 1114 | #define RT5670_HP_L_SMT_DIS (0x0 << 9) | ||
| 1115 | #define RT5670_HP_L_SMT_EN (0x1 << 9) | ||
| 1116 | #define RT5670_HP_R_SMT_MASK (0x1 << 8) | ||
| 1117 | #define RT5670_HP_R_SMT_SFT 8 | ||
| 1118 | #define RT5670_HP_R_SMT_DIS (0x0 << 8) | ||
| 1119 | #define RT5670_HP_R_SMT_EN (0x1 << 8) | ||
| 1120 | #define RT5670_HP_CD_PD_MASK (0x1 << 7) | ||
| 1121 | #define RT5670_HP_CD_PD_SFT 7 | ||
| 1122 | #define RT5670_HP_CD_PD_DIS (0x0 << 7) | ||
| 1123 | #define RT5670_HP_CD_PD_EN (0x1 << 7) | ||
| 1124 | #define RT5670_RSTN_MASK (0x1 << 6) | ||
| 1125 | #define RT5670_RSTN_SFT 6 | ||
| 1126 | #define RT5670_RSTN_DIS (0x0 << 6) | ||
| 1127 | #define RT5670_RSTN_EN (0x1 << 6) | ||
| 1128 | #define RT5670_RSTP_MASK (0x1 << 5) | ||
| 1129 | #define RT5670_RSTP_SFT 5 | ||
| 1130 | #define RT5670_RSTP_DIS (0x0 << 5) | ||
| 1131 | #define RT5670_RSTP_EN (0x1 << 5) | ||
| 1132 | #define RT5670_HP_CO_MASK (0x1 << 4) | ||
| 1133 | #define RT5670_HP_CO_SFT 4 | ||
| 1134 | #define RT5670_HP_CO_DIS (0x0 << 4) | ||
| 1135 | #define RT5670_HP_CO_EN (0x1 << 4) | ||
| 1136 | #define RT5670_HP_CP_MASK (0x1 << 3) | ||
| 1137 | #define RT5670_HP_CP_SFT 3 | ||
| 1138 | #define RT5670_HP_CP_PD (0x0 << 3) | ||
| 1139 | #define RT5670_HP_CP_PU (0x1 << 3) | ||
| 1140 | #define RT5670_HP_SG_MASK (0x1 << 2) | ||
| 1141 | #define RT5670_HP_SG_SFT 2 | ||
| 1142 | #define RT5670_HP_SG_DIS (0x0 << 2) | ||
| 1143 | #define RT5670_HP_SG_EN (0x1 << 2) | ||
| 1144 | #define RT5670_HP_DP_MASK (0x1 << 1) | ||
| 1145 | #define RT5670_HP_DP_SFT 1 | ||
| 1146 | #define RT5670_HP_DP_PD (0x0 << 1) | ||
| 1147 | #define RT5670_HP_DP_PU (0x1 << 1) | ||
| 1148 | #define RT5670_HP_CB_MASK (0x1) | ||
| 1149 | #define RT5670_HP_CB_SFT 0 | ||
| 1150 | #define RT5670_HP_CB_PD (0x0) | ||
| 1151 | #define RT5670_HP_CB_PU (0x1) | ||
| 1152 | |||
| 1153 | /* Depop Mode Control 2 (0x8f) */ | ||
| 1154 | #define RT5670_DEPOP_MASK (0x1 << 13) | ||
| 1155 | #define RT5670_DEPOP_SFT 13 | ||
| 1156 | #define RT5670_DEPOP_AUTO (0x0 << 13) | ||
| 1157 | #define RT5670_DEPOP_MAN (0x1 << 13) | ||
| 1158 | #define RT5670_RAMP_MASK (0x1 << 12) | ||
| 1159 | #define RT5670_RAMP_SFT 12 | ||
| 1160 | #define RT5670_RAMP_DIS (0x0 << 12) | ||
| 1161 | #define RT5670_RAMP_EN (0x1 << 12) | ||
| 1162 | #define RT5670_BPS_MASK (0x1 << 11) | ||
| 1163 | #define RT5670_BPS_SFT 11 | ||
| 1164 | #define RT5670_BPS_DIS (0x0 << 11) | ||
| 1165 | #define RT5670_BPS_EN (0x1 << 11) | ||
| 1166 | #define RT5670_FAST_UPDN_MASK (0x1 << 10) | ||
| 1167 | #define RT5670_FAST_UPDN_SFT 10 | ||
| 1168 | #define RT5670_FAST_UPDN_DIS (0x0 << 10) | ||
| 1169 | #define RT5670_FAST_UPDN_EN (0x1 << 10) | ||
| 1170 | #define RT5670_MRES_MASK (0x3 << 8) | ||
| 1171 | #define RT5670_MRES_SFT 8 | ||
| 1172 | #define RT5670_MRES_15MO (0x0 << 8) | ||
| 1173 | #define RT5670_MRES_25MO (0x1 << 8) | ||
| 1174 | #define RT5670_MRES_35MO (0x2 << 8) | ||
| 1175 | #define RT5670_MRES_45MO (0x3 << 8) | ||
| 1176 | #define RT5670_VLO_MASK (0x1 << 7) | ||
| 1177 | #define RT5670_VLO_SFT 7 | ||
| 1178 | #define RT5670_VLO_3V (0x0 << 7) | ||
| 1179 | #define RT5670_VLO_32V (0x1 << 7) | ||
| 1180 | #define RT5670_DIG_DP_MASK (0x1 << 6) | ||
| 1181 | #define RT5670_DIG_DP_SFT 6 | ||
| 1182 | #define RT5670_DIG_DP_DIS (0x0 << 6) | ||
| 1183 | #define RT5670_DIG_DP_EN (0x1 << 6) | ||
| 1184 | #define RT5670_DP_TH_MASK (0x3 << 4) | ||
| 1185 | #define RT5670_DP_TH_SFT 4 | ||
| 1186 | |||
| 1187 | /* Depop Mode Control 3 (0x90) */ | ||
| 1188 | #define RT5670_CP_SYS_MASK (0x7 << 12) | ||
| 1189 | #define RT5670_CP_SYS_SFT 12 | ||
| 1190 | #define RT5670_CP_FQ1_MASK (0x7 << 8) | ||
| 1191 | #define RT5670_CP_FQ1_SFT 8 | ||
| 1192 | #define RT5670_CP_FQ2_MASK (0x7 << 4) | ||
| 1193 | #define RT5670_CP_FQ2_SFT 4 | ||
| 1194 | #define RT5670_CP_FQ3_MASK (0x7) | ||
| 1195 | #define RT5670_CP_FQ3_SFT 0 | ||
| 1196 | #define RT5670_CP_FQ_1_5_KHZ 0 | ||
| 1197 | #define RT5670_CP_FQ_3_KHZ 1 | ||
| 1198 | #define RT5670_CP_FQ_6_KHZ 2 | ||
| 1199 | #define RT5670_CP_FQ_12_KHZ 3 | ||
| 1200 | #define RT5670_CP_FQ_24_KHZ 4 | ||
| 1201 | #define RT5670_CP_FQ_48_KHZ 5 | ||
| 1202 | #define RT5670_CP_FQ_96_KHZ 6 | ||
| 1203 | #define RT5670_CP_FQ_192_KHZ 7 | ||
| 1204 | |||
| 1205 | /* HPOUT charge pump (0x91) */ | ||
| 1206 | #define RT5670_OSW_L_MASK (0x1 << 11) | ||
| 1207 | #define RT5670_OSW_L_SFT 11 | ||
| 1208 | #define RT5670_OSW_L_DIS (0x0 << 11) | ||
| 1209 | #define RT5670_OSW_L_EN (0x1 << 11) | ||
| 1210 | #define RT5670_OSW_R_MASK (0x1 << 10) | ||
| 1211 | #define RT5670_OSW_R_SFT 10 | ||
| 1212 | #define RT5670_OSW_R_DIS (0x0 << 10) | ||
| 1213 | #define RT5670_OSW_R_EN (0x1 << 10) | ||
| 1214 | #define RT5670_PM_HP_MASK (0x3 << 8) | ||
| 1215 | #define RT5670_PM_HP_SFT 8 | ||
| 1216 | #define RT5670_PM_HP_LV (0x0 << 8) | ||
| 1217 | #define RT5670_PM_HP_MV (0x1 << 8) | ||
| 1218 | #define RT5670_PM_HP_HV (0x2 << 8) | ||
| 1219 | #define RT5670_IB_HP_MASK (0x3 << 6) | ||
| 1220 | #define RT5670_IB_HP_SFT 6 | ||
| 1221 | #define RT5670_IB_HP_125IL (0x0 << 6) | ||
| 1222 | #define RT5670_IB_HP_25IL (0x1 << 6) | ||
| 1223 | #define RT5670_IB_HP_5IL (0x2 << 6) | ||
| 1224 | #define RT5670_IB_HP_1IL (0x3 << 6) | ||
| 1225 | |||
| 1226 | /* PV detection and SPK gain control (0x92) */ | ||
| 1227 | #define RT5670_PVDD_DET_MASK (0x1 << 15) | ||
| 1228 | #define RT5670_PVDD_DET_SFT 15 | ||
| 1229 | #define RT5670_PVDD_DET_DIS (0x0 << 15) | ||
| 1230 | #define RT5670_PVDD_DET_EN (0x1 << 15) | ||
| 1231 | #define RT5670_SPK_AG_MASK (0x1 << 14) | ||
| 1232 | #define RT5670_SPK_AG_SFT 14 | ||
| 1233 | #define RT5670_SPK_AG_DIS (0x0 << 14) | ||
| 1234 | #define RT5670_SPK_AG_EN (0x1 << 14) | ||
| 1235 | |||
| 1236 | /* Micbias Control (0x93) */ | ||
| 1237 | #define RT5670_MIC1_BS_MASK (0x1 << 15) | ||
| 1238 | #define RT5670_MIC1_BS_SFT 15 | ||
| 1239 | #define RT5670_MIC1_BS_9AV (0x0 << 15) | ||
| 1240 | #define RT5670_MIC1_BS_75AV (0x1 << 15) | ||
| 1241 | #define RT5670_MIC2_BS_MASK (0x1 << 14) | ||
| 1242 | #define RT5670_MIC2_BS_SFT 14 | ||
| 1243 | #define RT5670_MIC2_BS_9AV (0x0 << 14) | ||
| 1244 | #define RT5670_MIC2_BS_75AV (0x1 << 14) | ||
| 1245 | #define RT5670_MIC1_CLK_MASK (0x1 << 13) | ||
| 1246 | #define RT5670_MIC1_CLK_SFT 13 | ||
| 1247 | #define RT5670_MIC1_CLK_DIS (0x0 << 13) | ||
| 1248 | #define RT5670_MIC1_CLK_EN (0x1 << 13) | ||
| 1249 | #define RT5670_MIC2_CLK_MASK (0x1 << 12) | ||
| 1250 | #define RT5670_MIC2_CLK_SFT 12 | ||
| 1251 | #define RT5670_MIC2_CLK_DIS (0x0 << 12) | ||
| 1252 | #define RT5670_MIC2_CLK_EN (0x1 << 12) | ||
| 1253 | #define RT5670_MIC1_OVCD_MASK (0x1 << 11) | ||
| 1254 | #define RT5670_MIC1_OVCD_SFT 11 | ||
| 1255 | #define RT5670_MIC1_OVCD_DIS (0x0 << 11) | ||
| 1256 | #define RT5670_MIC1_OVCD_EN (0x1 << 11) | ||
| 1257 | #define RT5670_MIC1_OVTH_MASK (0x3 << 9) | ||
| 1258 | #define RT5670_MIC1_OVTH_SFT 9 | ||
| 1259 | #define RT5670_MIC1_OVTH_600UA (0x0 << 9) | ||
| 1260 | #define RT5670_MIC1_OVTH_1500UA (0x1 << 9) | ||
| 1261 | #define RT5670_MIC1_OVTH_2000UA (0x2 << 9) | ||
| 1262 | #define RT5670_MIC2_OVCD_MASK (0x1 << 8) | ||
| 1263 | #define RT5670_MIC2_OVCD_SFT 8 | ||
| 1264 | #define RT5670_MIC2_OVCD_DIS (0x0 << 8) | ||
| 1265 | #define RT5670_MIC2_OVCD_EN (0x1 << 8) | ||
| 1266 | #define RT5670_MIC2_OVTH_MASK (0x3 << 6) | ||
| 1267 | #define RT5670_MIC2_OVTH_SFT 6 | ||
| 1268 | #define RT5670_MIC2_OVTH_600UA (0x0 << 6) | ||
| 1269 | #define RT5670_MIC2_OVTH_1500UA (0x1 << 6) | ||
| 1270 | #define RT5670_MIC2_OVTH_2000UA (0x2 << 6) | ||
| 1271 | #define RT5670_PWR_MB_MASK (0x1 << 5) | ||
| 1272 | #define RT5670_PWR_MB_SFT 5 | ||
| 1273 | #define RT5670_PWR_MB_PD (0x0 << 5) | ||
| 1274 | #define RT5670_PWR_MB_PU (0x1 << 5) | ||
| 1275 | #define RT5670_PWR_CLK25M_MASK (0x1 << 4) | ||
| 1276 | #define RT5670_PWR_CLK25M_SFT 4 | ||
| 1277 | #define RT5670_PWR_CLK25M_PD (0x0 << 4) | ||
| 1278 | #define RT5670_PWR_CLK25M_PU (0x1 << 4) | ||
| 1279 | |||
| 1280 | /* Analog JD Control 1 (0x94) */ | ||
| 1281 | #define RT5670_JD1_MODE_MASK (0x3 << 0) | ||
| 1282 | #define RT5670_JD1_MODE_0 (0x0 << 0) | ||
| 1283 | #define RT5670_JD1_MODE_1 (0x1 << 0) | ||
| 1284 | #define RT5670_JD1_MODE_2 (0x2 << 0) | ||
| 1285 | |||
| 1286 | /* VAD Control 4 (0x9d) */ | ||
| 1287 | #define RT5670_VAD_SEL_MASK (0x3 << 8) | ||
| 1288 | #define RT5670_VAD_SEL_SFT 8 | ||
| 1289 | |||
| 1290 | /* EQ Control 1 (0xb0) */ | ||
| 1291 | #define RT5670_EQ_SRC_MASK (0x1 << 15) | ||
| 1292 | #define RT5670_EQ_SRC_SFT 15 | ||
| 1293 | #define RT5670_EQ_SRC_DAC (0x0 << 15) | ||
| 1294 | #define RT5670_EQ_SRC_ADC (0x1 << 15) | ||
| 1295 | #define RT5670_EQ_UPD (0x1 << 14) | ||
| 1296 | #define RT5670_EQ_UPD_BIT 14 | ||
| 1297 | #define RT5670_EQ_CD_MASK (0x1 << 13) | ||
| 1298 | #define RT5670_EQ_CD_SFT 13 | ||
| 1299 | #define RT5670_EQ_CD_DIS (0x0 << 13) | ||
| 1300 | #define RT5670_EQ_CD_EN (0x1 << 13) | ||
| 1301 | #define RT5670_EQ_DITH_MASK (0x3 << 8) | ||
| 1302 | #define RT5670_EQ_DITH_SFT 8 | ||
| 1303 | #define RT5670_EQ_DITH_NOR (0x0 << 8) | ||
| 1304 | #define RT5670_EQ_DITH_LSB (0x1 << 8) | ||
| 1305 | #define RT5670_EQ_DITH_LSB_1 (0x2 << 8) | ||
| 1306 | #define RT5670_EQ_DITH_LSB_2 (0x3 << 8) | ||
| 1307 | |||
| 1308 | /* EQ Control 2 (0xb1) */ | ||
| 1309 | #define RT5670_EQ_HPF1_M_MASK (0x1 << 8) | ||
| 1310 | #define RT5670_EQ_HPF1_M_SFT 8 | ||
| 1311 | #define RT5670_EQ_HPF1_M_HI (0x0 << 8) | ||
| 1312 | #define RT5670_EQ_HPF1_M_1ST (0x1 << 8) | ||
| 1313 | #define RT5670_EQ_LPF1_M_MASK (0x1 << 7) | ||
| 1314 | #define RT5670_EQ_LPF1_M_SFT 7 | ||
| 1315 | #define RT5670_EQ_LPF1_M_LO (0x0 << 7) | ||
| 1316 | #define RT5670_EQ_LPF1_M_1ST (0x1 << 7) | ||
| 1317 | #define RT5670_EQ_HPF2_MASK (0x1 << 6) | ||
| 1318 | #define RT5670_EQ_HPF2_SFT 6 | ||
| 1319 | #define RT5670_EQ_HPF2_DIS (0x0 << 6) | ||
| 1320 | #define RT5670_EQ_HPF2_EN (0x1 << 6) | ||
| 1321 | #define RT5670_EQ_HPF1_MASK (0x1 << 5) | ||
| 1322 | #define RT5670_EQ_HPF1_SFT 5 | ||
| 1323 | #define RT5670_EQ_HPF1_DIS (0x0 << 5) | ||
| 1324 | #define RT5670_EQ_HPF1_EN (0x1 << 5) | ||
| 1325 | #define RT5670_EQ_BPF4_MASK (0x1 << 4) | ||
| 1326 | #define RT5670_EQ_BPF4_SFT 4 | ||
| 1327 | #define RT5670_EQ_BPF4_DIS (0x0 << 4) | ||
| 1328 | #define RT5670_EQ_BPF4_EN (0x1 << 4) | ||
| 1329 | #define RT5670_EQ_BPF3_MASK (0x1 << 3) | ||
| 1330 | #define RT5670_EQ_BPF3_SFT 3 | ||
| 1331 | #define RT5670_EQ_BPF3_DIS (0x0 << 3) | ||
| 1332 | #define RT5670_EQ_BPF3_EN (0x1 << 3) | ||
| 1333 | #define RT5670_EQ_BPF2_MASK (0x1 << 2) | ||
| 1334 | #define RT5670_EQ_BPF2_SFT 2 | ||
| 1335 | #define RT5670_EQ_BPF2_DIS (0x0 << 2) | ||
| 1336 | #define RT5670_EQ_BPF2_EN (0x1 << 2) | ||
| 1337 | #define RT5670_EQ_BPF1_MASK (0x1 << 1) | ||
| 1338 | #define RT5670_EQ_BPF1_SFT 1 | ||
| 1339 | #define RT5670_EQ_BPF1_DIS (0x0 << 1) | ||
| 1340 | #define RT5670_EQ_BPF1_EN (0x1 << 1) | ||
| 1341 | #define RT5670_EQ_LPF_MASK (0x1) | ||
| 1342 | #define RT5670_EQ_LPF_SFT 0 | ||
| 1343 | #define RT5670_EQ_LPF_DIS (0x0) | ||
| 1344 | #define RT5670_EQ_LPF_EN (0x1) | ||
| 1345 | #define RT5670_EQ_CTRL_MASK (0x7f) | ||
| 1346 | |||
| 1347 | /* Memory Test (0xb2) */ | ||
| 1348 | #define RT5670_MT_MASK (0x1 << 15) | ||
| 1349 | #define RT5670_MT_SFT 15 | ||
| 1350 | #define RT5670_MT_DIS (0x0 << 15) | ||
| 1351 | #define RT5670_MT_EN (0x1 << 15) | ||
| 1352 | |||
| 1353 | /* DRC/AGC Control 1 (0xb4) */ | ||
| 1354 | #define RT5670_DRC_AGC_P_MASK (0x1 << 15) | ||
| 1355 | #define RT5670_DRC_AGC_P_SFT 15 | ||
| 1356 | #define RT5670_DRC_AGC_P_DAC (0x0 << 15) | ||
| 1357 | #define RT5670_DRC_AGC_P_ADC (0x1 << 15) | ||
| 1358 | #define RT5670_DRC_AGC_MASK (0x1 << 14) | ||
| 1359 | #define RT5670_DRC_AGC_SFT 14 | ||
| 1360 | #define RT5670_DRC_AGC_DIS (0x0 << 14) | ||
| 1361 | #define RT5670_DRC_AGC_EN (0x1 << 14) | ||
| 1362 | #define RT5670_DRC_AGC_UPD (0x1 << 13) | ||
| 1363 | #define RT5670_DRC_AGC_UPD_BIT 13 | ||
| 1364 | #define RT5670_DRC_AGC_AR_MASK (0x1f << 8) | ||
| 1365 | #define RT5670_DRC_AGC_AR_SFT 8 | ||
| 1366 | #define RT5670_DRC_AGC_R_MASK (0x7 << 5) | ||
| 1367 | #define RT5670_DRC_AGC_R_SFT 5 | ||
| 1368 | #define RT5670_DRC_AGC_R_48K (0x1 << 5) | ||
| 1369 | #define RT5670_DRC_AGC_R_96K (0x2 << 5) | ||
| 1370 | #define RT5670_DRC_AGC_R_192K (0x3 << 5) | ||
| 1371 | #define RT5670_DRC_AGC_R_441K (0x5 << 5) | ||
| 1372 | #define RT5670_DRC_AGC_R_882K (0x6 << 5) | ||
| 1373 | #define RT5670_DRC_AGC_R_1764K (0x7 << 5) | ||
| 1374 | #define RT5670_DRC_AGC_RC_MASK (0x1f) | ||
| 1375 | #define RT5670_DRC_AGC_RC_SFT 0 | ||
| 1376 | |||
| 1377 | /* DRC/AGC Control 2 (0xb5) */ | ||
| 1378 | #define RT5670_DRC_AGC_POB_MASK (0x3f << 8) | ||
| 1379 | #define RT5670_DRC_AGC_POB_SFT 8 | ||
| 1380 | #define RT5670_DRC_AGC_CP_MASK (0x1 << 7) | ||
| 1381 | #define RT5670_DRC_AGC_CP_SFT 7 | ||
| 1382 | #define RT5670_DRC_AGC_CP_DIS (0x0 << 7) | ||
| 1383 | #define RT5670_DRC_AGC_CP_EN (0x1 << 7) | ||
| 1384 | #define RT5670_DRC_AGC_CPR_MASK (0x3 << 5) | ||
| 1385 | #define RT5670_DRC_AGC_CPR_SFT 5 | ||
| 1386 | #define RT5670_DRC_AGC_CPR_1_1 (0x0 << 5) | ||
| 1387 | #define RT5670_DRC_AGC_CPR_1_2 (0x1 << 5) | ||
| 1388 | #define RT5670_DRC_AGC_CPR_1_3 (0x2 << 5) | ||
| 1389 | #define RT5670_DRC_AGC_CPR_1_4 (0x3 << 5) | ||
| 1390 | #define RT5670_DRC_AGC_PRB_MASK (0x1f) | ||
| 1391 | #define RT5670_DRC_AGC_PRB_SFT 0 | ||
| 1392 | |||
| 1393 | /* DRC/AGC Control 3 (0xb6) */ | ||
| 1394 | #define RT5670_DRC_AGC_NGB_MASK (0xf << 12) | ||
| 1395 | #define RT5670_DRC_AGC_NGB_SFT 12 | ||
| 1396 | #define RT5670_DRC_AGC_TAR_MASK (0x1f << 7) | ||
| 1397 | #define RT5670_DRC_AGC_TAR_SFT 7 | ||
| 1398 | #define RT5670_DRC_AGC_NG_MASK (0x1 << 6) | ||
| 1399 | #define RT5670_DRC_AGC_NG_SFT 6 | ||
| 1400 | #define RT5670_DRC_AGC_NG_DIS (0x0 << 6) | ||
| 1401 | #define RT5670_DRC_AGC_NG_EN (0x1 << 6) | ||
| 1402 | #define RT5670_DRC_AGC_NGH_MASK (0x1 << 5) | ||
| 1403 | #define RT5670_DRC_AGC_NGH_SFT 5 | ||
| 1404 | #define RT5670_DRC_AGC_NGH_DIS (0x0 << 5) | ||
| 1405 | #define RT5670_DRC_AGC_NGH_EN (0x1 << 5) | ||
| 1406 | #define RT5670_DRC_AGC_NGT_MASK (0x1f) | ||
| 1407 | #define RT5670_DRC_AGC_NGT_SFT 0 | ||
| 1408 | |||
| 1409 | /* Jack Detect Control (0xbb) */ | ||
| 1410 | #define RT5670_JD_MASK (0x7 << 13) | ||
| 1411 | #define RT5670_JD_SFT 13 | ||
| 1412 | #define RT5670_JD_DIS (0x0 << 13) | ||
| 1413 | #define RT5670_JD_GPIO1 (0x1 << 13) | ||
| 1414 | #define RT5670_JD_JD1_IN4P (0x2 << 13) | ||
| 1415 | #define RT5670_JD_JD2_IN4N (0x3 << 13) | ||
| 1416 | #define RT5670_JD_GPIO2 (0x4 << 13) | ||
| 1417 | #define RT5670_JD_GPIO3 (0x5 << 13) | ||
| 1418 | #define RT5670_JD_GPIO4 (0x6 << 13) | ||
| 1419 | #define RT5670_JD_HP_MASK (0x1 << 11) | ||
| 1420 | #define RT5670_JD_HP_SFT 11 | ||
| 1421 | #define RT5670_JD_HP_DIS (0x0 << 11) | ||
| 1422 | #define RT5670_JD_HP_EN (0x1 << 11) | ||
| 1423 | #define RT5670_JD_HP_TRG_MASK (0x1 << 10) | ||
| 1424 | #define RT5670_JD_HP_TRG_SFT 10 | ||
| 1425 | #define RT5670_JD_HP_TRG_LO (0x0 << 10) | ||
| 1426 | #define RT5670_JD_HP_TRG_HI (0x1 << 10) | ||
| 1427 | #define RT5670_JD_SPL_MASK (0x1 << 9) | ||
| 1428 | #define RT5670_JD_SPL_SFT 9 | ||
| 1429 | #define RT5670_JD_SPL_DIS (0x0 << 9) | ||
| 1430 | #define RT5670_JD_SPL_EN (0x1 << 9) | ||
| 1431 | #define RT5670_JD_SPL_TRG_MASK (0x1 << 8) | ||
| 1432 | #define RT5670_JD_SPL_TRG_SFT 8 | ||
| 1433 | #define RT5670_JD_SPL_TRG_LO (0x0 << 8) | ||
| 1434 | #define RT5670_JD_SPL_TRG_HI (0x1 << 8) | ||
| 1435 | #define RT5670_JD_SPR_MASK (0x1 << 7) | ||
| 1436 | #define RT5670_JD_SPR_SFT 7 | ||
| 1437 | #define RT5670_JD_SPR_DIS (0x0 << 7) | ||
| 1438 | #define RT5670_JD_SPR_EN (0x1 << 7) | ||
| 1439 | #define RT5670_JD_SPR_TRG_MASK (0x1 << 6) | ||
| 1440 | #define RT5670_JD_SPR_TRG_SFT 6 | ||
| 1441 | #define RT5670_JD_SPR_TRG_LO (0x0 << 6) | ||
| 1442 | #define RT5670_JD_SPR_TRG_HI (0x1 << 6) | ||
| 1443 | #define RT5670_JD_MO_MASK (0x1 << 5) | ||
| 1444 | #define RT5670_JD_MO_SFT 5 | ||
| 1445 | #define RT5670_JD_MO_DIS (0x0 << 5) | ||
| 1446 | #define RT5670_JD_MO_EN (0x1 << 5) | ||
| 1447 | #define RT5670_JD_MO_TRG_MASK (0x1 << 4) | ||
| 1448 | #define RT5670_JD_MO_TRG_SFT 4 | ||
| 1449 | #define RT5670_JD_MO_TRG_LO (0x0 << 4) | ||
| 1450 | #define RT5670_JD_MO_TRG_HI (0x1 << 4) | ||
| 1451 | #define RT5670_JD_LO_MASK (0x1 << 3) | ||
| 1452 | #define RT5670_JD_LO_SFT 3 | ||
| 1453 | #define RT5670_JD_LO_DIS (0x0 << 3) | ||
| 1454 | #define RT5670_JD_LO_EN (0x1 << 3) | ||
| 1455 | #define RT5670_JD_LO_TRG_MASK (0x1 << 2) | ||
| 1456 | #define RT5670_JD_LO_TRG_SFT 2 | ||
| 1457 | #define RT5670_JD_LO_TRG_LO (0x0 << 2) | ||
| 1458 | #define RT5670_JD_LO_TRG_HI (0x1 << 2) | ||
| 1459 | #define RT5670_JD1_IN4P_MASK (0x1 << 1) | ||
| 1460 | #define RT5670_JD1_IN4P_SFT 1 | ||
| 1461 | #define RT5670_JD1_IN4P_DIS (0x0 << 1) | ||
| 1462 | #define RT5670_JD1_IN4P_EN (0x1 << 1) | ||
| 1463 | #define RT5670_JD2_IN4N_MASK (0x1) | ||
| 1464 | #define RT5670_JD2_IN4N_SFT 0 | ||
| 1465 | #define RT5670_JD2_IN4N_DIS (0x0) | ||
| 1466 | #define RT5670_JD2_IN4N_EN (0x1) | ||
| 1467 | |||
| 1468 | /* IRQ Control 1 (0xbd) */ | ||
| 1469 | #define RT5670_IRQ_JD_MASK (0x1 << 15) | ||
| 1470 | #define RT5670_IRQ_JD_SFT 15 | ||
| 1471 | #define RT5670_IRQ_JD_BP (0x0 << 15) | ||
| 1472 | #define RT5670_IRQ_JD_NOR (0x1 << 15) | ||
| 1473 | #define RT5670_IRQ_OT_MASK (0x1 << 14) | ||
| 1474 | #define RT5670_IRQ_OT_SFT 14 | ||
| 1475 | #define RT5670_IRQ_OT_BP (0x0 << 14) | ||
| 1476 | #define RT5670_IRQ_OT_NOR (0x1 << 14) | ||
| 1477 | #define RT5670_JD_STKY_MASK (0x1 << 13) | ||
| 1478 | #define RT5670_JD_STKY_SFT 13 | ||
| 1479 | #define RT5670_JD_STKY_DIS (0x0 << 13) | ||
| 1480 | #define RT5670_JD_STKY_EN (0x1 << 13) | ||
| 1481 | #define RT5670_OT_STKY_MASK (0x1 << 12) | ||
| 1482 | #define RT5670_OT_STKY_SFT 12 | ||
| 1483 | #define RT5670_OT_STKY_DIS (0x0 << 12) | ||
| 1484 | #define RT5670_OT_STKY_EN (0x1 << 12) | ||
| 1485 | #define RT5670_JD_P_MASK (0x1 << 11) | ||
| 1486 | #define RT5670_JD_P_SFT 11 | ||
| 1487 | #define RT5670_JD_P_NOR (0x0 << 11) | ||
| 1488 | #define RT5670_JD_P_INV (0x1 << 11) | ||
| 1489 | #define RT5670_OT_P_MASK (0x1 << 10) | ||
| 1490 | #define RT5670_OT_P_SFT 10 | ||
| 1491 | #define RT5670_OT_P_NOR (0x0 << 10) | ||
| 1492 | #define RT5670_OT_P_INV (0x1 << 10) | ||
| 1493 | #define RT5670_JD1_1_EN_MASK (0x1 << 9) | ||
| 1494 | #define RT5670_JD1_1_EN_SFT 9 | ||
| 1495 | #define RT5670_JD1_1_DIS (0x0 << 9) | ||
| 1496 | #define RT5670_JD1_1_EN (0x1 << 9) | ||
| 1497 | |||
| 1498 | /* IRQ Control 2 (0xbe) */ | ||
| 1499 | #define RT5670_IRQ_MB1_OC_MASK (0x1 << 15) | ||
| 1500 | #define RT5670_IRQ_MB1_OC_SFT 15 | ||
| 1501 | #define RT5670_IRQ_MB1_OC_BP (0x0 << 15) | ||
| 1502 | #define RT5670_IRQ_MB1_OC_NOR (0x1 << 15) | ||
| 1503 | #define RT5670_IRQ_MB2_OC_MASK (0x1 << 14) | ||
| 1504 | #define RT5670_IRQ_MB2_OC_SFT 14 | ||
| 1505 | #define RT5670_IRQ_MB2_OC_BP (0x0 << 14) | ||
| 1506 | #define RT5670_IRQ_MB2_OC_NOR (0x1 << 14) | ||
| 1507 | #define RT5670_MB1_OC_STKY_MASK (0x1 << 11) | ||
| 1508 | #define RT5670_MB1_OC_STKY_SFT 11 | ||
| 1509 | #define RT5670_MB1_OC_STKY_DIS (0x0 << 11) | ||
| 1510 | #define RT5670_MB1_OC_STKY_EN (0x1 << 11) | ||
| 1511 | #define RT5670_MB2_OC_STKY_MASK (0x1 << 10) | ||
| 1512 | #define RT5670_MB2_OC_STKY_SFT 10 | ||
| 1513 | #define RT5670_MB2_OC_STKY_DIS (0x0 << 10) | ||
| 1514 | #define RT5670_MB2_OC_STKY_EN (0x1 << 10) | ||
| 1515 | #define RT5670_MB1_OC_P_MASK (0x1 << 7) | ||
| 1516 | #define RT5670_MB1_OC_P_SFT 7 | ||
| 1517 | #define RT5670_MB1_OC_P_NOR (0x0 << 7) | ||
| 1518 | #define RT5670_MB1_OC_P_INV (0x1 << 7) | ||
| 1519 | #define RT5670_MB2_OC_P_MASK (0x1 << 6) | ||
| 1520 | #define RT5670_MB2_OC_P_SFT 6 | ||
| 1521 | #define RT5670_MB2_OC_P_NOR (0x0 << 6) | ||
| 1522 | #define RT5670_MB2_OC_P_INV (0x1 << 6) | ||
| 1523 | #define RT5670_MB1_OC_CLR (0x1 << 3) | ||
| 1524 | #define RT5670_MB1_OC_CLR_SFT 3 | ||
| 1525 | #define RT5670_MB2_OC_CLR (0x1 << 2) | ||
| 1526 | #define RT5670_MB2_OC_CLR_SFT 2 | ||
| 1527 | |||
| 1528 | /* GPIO Control 1 (0xc0) */ | ||
| 1529 | #define RT5670_GP1_PIN_MASK (0x1 << 15) | ||
| 1530 | #define RT5670_GP1_PIN_SFT 15 | ||
| 1531 | #define RT5670_GP1_PIN_GPIO1 (0x0 << 15) | ||
| 1532 | #define RT5670_GP1_PIN_IRQ (0x1 << 15) | ||
| 1533 | #define RT5670_GP2_PIN_MASK (0x1 << 14) | ||
| 1534 | #define RT5670_GP2_PIN_SFT 14 | ||
| 1535 | #define RT5670_GP2_PIN_GPIO2 (0x0 << 14) | ||
| 1536 | #define RT5670_GP2_PIN_DMIC1_SCL (0x1 << 14) | ||
| 1537 | #define RT5670_GP3_PIN_MASK (0x3 << 12) | ||
| 1538 | #define RT5670_GP3_PIN_SFT 12 | ||
| 1539 | #define RT5670_GP3_PIN_GPIO3 (0x0 << 12) | ||
| 1540 | #define RT5670_GP3_PIN_DMIC1_SDA (0x1 << 12) | ||
| 1541 | #define RT5670_GP3_PIN_IRQ (0x2 << 12) | ||
| 1542 | #define RT5670_GP4_PIN_MASK (0x1 << 11) | ||
| 1543 | #define RT5670_GP4_PIN_SFT 11 | ||
| 1544 | #define RT5670_GP4_PIN_GPIO4 (0x0 << 11) | ||
| 1545 | #define RT5670_GP4_PIN_DMIC2_SDA (0x1 << 11) | ||
| 1546 | #define RT5670_DP_SIG_MASK (0x1 << 10) | ||
| 1547 | #define RT5670_DP_SIG_SFT 10 | ||
| 1548 | #define RT5670_DP_SIG_TEST (0x0 << 10) | ||
| 1549 | #define RT5670_DP_SIG_AP (0x1 << 10) | ||
| 1550 | #define RT5670_GPIO_M_MASK (0x1 << 9) | ||
| 1551 | #define RT5670_GPIO_M_SFT 9 | ||
| 1552 | #define RT5670_GPIO_M_FLT (0x0 << 9) | ||
| 1553 | #define RT5670_GPIO_M_PH (0x1 << 9) | ||
| 1554 | #define RT5670_I2S2_PIN_MASK (0x1 << 8) | ||
| 1555 | #define RT5670_I2S2_PIN_SFT 8 | ||
| 1556 | #define RT5670_I2S2_PIN_I2S (0x0 << 8) | ||
| 1557 | #define RT5670_I2S2_PIN_GPIO (0x1 << 8) | ||
| 1558 | #define RT5670_GP5_PIN_MASK (0x1 << 7) | ||
| 1559 | #define RT5670_GP5_PIN_SFT 7 | ||
| 1560 | #define RT5670_GP5_PIN_GPIO5 (0x0 << 7) | ||
| 1561 | #define RT5670_GP5_PIN_DMIC3_SDA (0x1 << 7) | ||
| 1562 | #define RT5670_GP6_PIN_MASK (0x1 << 6) | ||
| 1563 | #define RT5670_GP6_PIN_SFT 6 | ||
| 1564 | #define RT5670_GP6_PIN_GPIO6 (0x0 << 6) | ||
| 1565 | #define RT5670_GP6_PIN_DMIC1_SDA (0x1 << 6) | ||
| 1566 | #define RT5670_GP7_PIN_MASK (0x3 << 4) | ||
| 1567 | #define RT5670_GP7_PIN_SFT 4 | ||
| 1568 | #define RT5670_GP7_PIN_GPIO7 (0x0 << 4) | ||
| 1569 | #define RT5670_GP7_PIN_DMIC1_SDA (0x1 << 4) | ||
| 1570 | #define RT5670_GP7_PIN_PDM_SCL2 (0x2 << 4) | ||
| 1571 | #define RT5670_GP8_PIN_MASK (0x1 << 3) | ||
| 1572 | #define RT5670_GP8_PIN_SFT 3 | ||
| 1573 | #define RT5670_GP8_PIN_GPIO8 (0x0 << 3) | ||
| 1574 | #define RT5670_GP8_PIN_DMIC2_SDA (0x1 << 3) | ||
| 1575 | #define RT5670_GP9_PIN_MASK (0x1 << 2) | ||
| 1576 | #define RT5670_GP9_PIN_SFT 2 | ||
| 1577 | #define RT5670_GP9_PIN_GPIO9 (0x0 << 2) | ||
| 1578 | #define RT5670_GP9_PIN_DMIC3_SDA (0x1 << 2) | ||
| 1579 | #define RT5670_GP10_PIN_MASK (0x3) | ||
| 1580 | #define RT5670_GP10_PIN_SFT 0 | ||
| 1581 | #define RT5670_GP10_PIN_GPIO9 (0x0) | ||
| 1582 | #define RT5670_GP10_PIN_DMIC3_SDA (0x1) | ||
| 1583 | #define RT5670_GP10_PIN_PDM_ADT2 (0x2) | ||
| 1584 | |||
| 1585 | /* GPIO Control 2 (0xc1) */ | ||
| 1586 | #define RT5670_GP4_PF_MASK (0x1 << 11) | ||
| 1587 | #define RT5670_GP4_PF_SFT 11 | ||
| 1588 | #define RT5670_GP4_PF_IN (0x0 << 11) | ||
| 1589 | #define RT5670_GP4_PF_OUT (0x1 << 11) | ||
| 1590 | #define RT5670_GP4_OUT_MASK (0x1 << 10) | ||
| 1591 | #define RT5670_GP4_OUT_SFT 10 | ||
| 1592 | #define RT5670_GP4_OUT_LO (0x0 << 10) | ||
| 1593 | #define RT5670_GP4_OUT_HI (0x1 << 10) | ||
| 1594 | #define RT5670_GP4_P_MASK (0x1 << 9) | ||
| 1595 | #define RT5670_GP4_P_SFT 9 | ||
| 1596 | #define RT5670_GP4_P_NOR (0x0 << 9) | ||
| 1597 | #define RT5670_GP4_P_INV (0x1 << 9) | ||
| 1598 | #define RT5670_GP3_PF_MASK (0x1 << 8) | ||
| 1599 | #define RT5670_GP3_PF_SFT 8 | ||
| 1600 | #define RT5670_GP3_PF_IN (0x0 << 8) | ||
| 1601 | #define RT5670_GP3_PF_OUT (0x1 << 8) | ||
| 1602 | #define RT5670_GP3_OUT_MASK (0x1 << 7) | ||
| 1603 | #define RT5670_GP3_OUT_SFT 7 | ||
| 1604 | #define RT5670_GP3_OUT_LO (0x0 << 7) | ||
| 1605 | #define RT5670_GP3_OUT_HI (0x1 << 7) | ||
| 1606 | #define RT5670_GP3_P_MASK (0x1 << 6) | ||
| 1607 | #define RT5670_GP3_P_SFT 6 | ||
| 1608 | #define RT5670_GP3_P_NOR (0x0 << 6) | ||
| 1609 | #define RT5670_GP3_P_INV (0x1 << 6) | ||
| 1610 | #define RT5670_GP2_PF_MASK (0x1 << 5) | ||
| 1611 | #define RT5670_GP2_PF_SFT 5 | ||
| 1612 | #define RT5670_GP2_PF_IN (0x0 << 5) | ||
| 1613 | #define RT5670_GP2_PF_OUT (0x1 << 5) | ||
| 1614 | #define RT5670_GP2_OUT_MASK (0x1 << 4) | ||
| 1615 | #define RT5670_GP2_OUT_SFT 4 | ||
| 1616 | #define RT5670_GP2_OUT_LO (0x0 << 4) | ||
| 1617 | #define RT5670_GP2_OUT_HI (0x1 << 4) | ||
| 1618 | #define RT5670_GP2_P_MASK (0x1 << 3) | ||
| 1619 | #define RT5670_GP2_P_SFT 3 | ||
| 1620 | #define RT5670_GP2_P_NOR (0x0 << 3) | ||
| 1621 | #define RT5670_GP2_P_INV (0x1 << 3) | ||
| 1622 | #define RT5670_GP1_PF_MASK (0x1 << 2) | ||
| 1623 | #define RT5670_GP1_PF_SFT 2 | ||
| 1624 | #define RT5670_GP1_PF_IN (0x0 << 2) | ||
| 1625 | #define RT5670_GP1_PF_OUT (0x1 << 2) | ||
| 1626 | #define RT5670_GP1_OUT_MASK (0x1 << 1) | ||
| 1627 | #define RT5670_GP1_OUT_SFT 1 | ||
| 1628 | #define RT5670_GP1_OUT_LO (0x0 << 1) | ||
| 1629 | #define RT5670_GP1_OUT_HI (0x1 << 1) | ||
| 1630 | #define RT5670_GP1_P_MASK (0x1) | ||
| 1631 | #define RT5670_GP1_P_SFT 0 | ||
| 1632 | #define RT5670_GP1_P_NOR (0x0) | ||
| 1633 | #define RT5670_GP1_P_INV (0x1) | ||
| 1634 | |||
| 1635 | /* Scramble Function (0xcd) */ | ||
| 1636 | #define RT5670_SCB_KEY_MASK (0xff) | ||
| 1637 | #define RT5670_SCB_KEY_SFT 0 | ||
| 1638 | |||
| 1639 | /* Scramble Control (0xce) */ | ||
| 1640 | #define RT5670_SCB_SWAP_MASK (0x1 << 15) | ||
| 1641 | #define RT5670_SCB_SWAP_SFT 15 | ||
| 1642 | #define RT5670_SCB_SWAP_DIS (0x0 << 15) | ||
| 1643 | #define RT5670_SCB_SWAP_EN (0x1 << 15) | ||
| 1644 | #define RT5670_SCB_MASK (0x1 << 14) | ||
| 1645 | #define RT5670_SCB_SFT 14 | ||
| 1646 | #define RT5670_SCB_DIS (0x0 << 14) | ||
| 1647 | #define RT5670_SCB_EN (0x1 << 14) | ||
| 1648 | |||
| 1649 | /* Baseback Control (0xcf) */ | ||
| 1650 | #define RT5670_BB_MASK (0x1 << 15) | ||
| 1651 | #define RT5670_BB_SFT 15 | ||
| 1652 | #define RT5670_BB_DIS (0x0 << 15) | ||
| 1653 | #define RT5670_BB_EN (0x1 << 15) | ||
| 1654 | #define RT5670_BB_CT_MASK (0x7 << 12) | ||
| 1655 | #define RT5670_BB_CT_SFT 12 | ||
| 1656 | #define RT5670_BB_CT_A (0x0 << 12) | ||
| 1657 | #define RT5670_BB_CT_B (0x1 << 12) | ||
| 1658 | #define RT5670_BB_CT_C (0x2 << 12) | ||
| 1659 | #define RT5670_BB_CT_D (0x3 << 12) | ||
| 1660 | #define RT5670_M_BB_L_MASK (0x1 << 9) | ||
| 1661 | #define RT5670_M_BB_L_SFT 9 | ||
| 1662 | #define RT5670_M_BB_R_MASK (0x1 << 8) | ||
| 1663 | #define RT5670_M_BB_R_SFT 8 | ||
| 1664 | #define RT5670_M_BB_HPF_L_MASK (0x1 << 7) | ||
| 1665 | #define RT5670_M_BB_HPF_L_SFT 7 | ||
| 1666 | #define RT5670_M_BB_HPF_R_MASK (0x1 << 6) | ||
| 1667 | #define RT5670_M_BB_HPF_R_SFT 6 | ||
| 1668 | #define RT5670_G_BB_BST_MASK (0x3f) | ||
| 1669 | #define RT5670_G_BB_BST_SFT 0 | ||
| 1670 | |||
| 1671 | /* MP3 Plus Control 1 (0xd0) */ | ||
| 1672 | #define RT5670_M_MP3_L_MASK (0x1 << 15) | ||
| 1673 | #define RT5670_M_MP3_L_SFT 15 | ||
| 1674 | #define RT5670_M_MP3_R_MASK (0x1 << 14) | ||
| 1675 | #define RT5670_M_MP3_R_SFT 14 | ||
| 1676 | #define RT5670_M_MP3_MASK (0x1 << 13) | ||
| 1677 | #define RT5670_M_MP3_SFT 13 | ||
| 1678 | #define RT5670_M_MP3_DIS (0x0 << 13) | ||
| 1679 | #define RT5670_M_MP3_EN (0x1 << 13) | ||
| 1680 | #define RT5670_EG_MP3_MASK (0x1f << 8) | ||
| 1681 | #define RT5670_EG_MP3_SFT 8 | ||
| 1682 | #define RT5670_MP3_HLP_MASK (0x1 << 7) | ||
| 1683 | #define RT5670_MP3_HLP_SFT 7 | ||
| 1684 | #define RT5670_MP3_HLP_DIS (0x0 << 7) | ||
| 1685 | #define RT5670_MP3_HLP_EN (0x1 << 7) | ||
| 1686 | #define RT5670_M_MP3_ORG_L_MASK (0x1 << 6) | ||
| 1687 | #define RT5670_M_MP3_ORG_L_SFT 6 | ||
| 1688 | #define RT5670_M_MP3_ORG_R_MASK (0x1 << 5) | ||
| 1689 | #define RT5670_M_MP3_ORG_R_SFT 5 | ||
| 1690 | |||
| 1691 | /* MP3 Plus Control 2 (0xd1) */ | ||
| 1692 | #define RT5670_MP3_WT_MASK (0x1 << 13) | ||
| 1693 | #define RT5670_MP3_WT_SFT 13 | ||
| 1694 | #define RT5670_MP3_WT_1_4 (0x0 << 13) | ||
| 1695 | #define RT5670_MP3_WT_1_2 (0x1 << 13) | ||
| 1696 | #define RT5670_OG_MP3_MASK (0x1f << 8) | ||
| 1697 | #define RT5670_OG_MP3_SFT 8 | ||
| 1698 | #define RT5670_HG_MP3_MASK (0x3f) | ||
| 1699 | #define RT5670_HG_MP3_SFT 0 | ||
| 1700 | |||
| 1701 | /* 3D HP Control 1 (0xd2) */ | ||
| 1702 | #define RT5670_3D_CF_MASK (0x1 << 15) | ||
| 1703 | #define RT5670_3D_CF_SFT 15 | ||
| 1704 | #define RT5670_3D_CF_DIS (0x0 << 15) | ||
| 1705 | #define RT5670_3D_CF_EN (0x1 << 15) | ||
| 1706 | #define RT5670_3D_HP_MASK (0x1 << 14) | ||
| 1707 | #define RT5670_3D_HP_SFT 14 | ||
| 1708 | #define RT5670_3D_HP_DIS (0x0 << 14) | ||
| 1709 | #define RT5670_3D_HP_EN (0x1 << 14) | ||
| 1710 | #define RT5670_3D_BT_MASK (0x1 << 13) | ||
| 1711 | #define RT5670_3D_BT_SFT 13 | ||
| 1712 | #define RT5670_3D_BT_DIS (0x0 << 13) | ||
| 1713 | #define RT5670_3D_BT_EN (0x1 << 13) | ||
| 1714 | #define RT5670_3D_1F_MIX_MASK (0x3 << 11) | ||
| 1715 | #define RT5670_3D_1F_MIX_SFT 11 | ||
| 1716 | #define RT5670_3D_HP_M_MASK (0x1 << 10) | ||
| 1717 | #define RT5670_3D_HP_M_SFT 10 | ||
| 1718 | #define RT5670_3D_HP_M_SUR (0x0 << 10) | ||
| 1719 | #define RT5670_3D_HP_M_FRO (0x1 << 10) | ||
| 1720 | #define RT5670_M_3D_HRTF_MASK (0x1 << 9) | ||
| 1721 | #define RT5670_M_3D_HRTF_SFT 9 | ||
| 1722 | #define RT5670_M_3D_D2H_MASK (0x1 << 8) | ||
| 1723 | #define RT5670_M_3D_D2H_SFT 8 | ||
| 1724 | #define RT5670_M_3D_D2R_MASK (0x1 << 7) | ||
| 1725 | #define RT5670_M_3D_D2R_SFT 7 | ||
| 1726 | #define RT5670_M_3D_REVB_MASK (0x1 << 6) | ||
| 1727 | #define RT5670_M_3D_REVB_SFT 6 | ||
| 1728 | |||
| 1729 | /* Adjustable high pass filter control 1 (0xd3) */ | ||
| 1730 | #define RT5670_2ND_HPF_MASK (0x1 << 15) | ||
| 1731 | #define RT5670_2ND_HPF_SFT 15 | ||
| 1732 | #define RT5670_2ND_HPF_DIS (0x0 << 15) | ||
| 1733 | #define RT5670_2ND_HPF_EN (0x1 << 15) | ||
| 1734 | #define RT5670_HPF_CF_L_MASK (0x7 << 12) | ||
| 1735 | #define RT5670_HPF_CF_L_SFT 12 | ||
| 1736 | #define RT5670_1ST_HPF_MASK (0x1 << 11) | ||
| 1737 | #define RT5670_1ST_HPF_SFT 11 | ||
| 1738 | #define RT5670_1ST_HPF_DIS (0x0 << 11) | ||
| 1739 | #define RT5670_1ST_HPF_EN (0x1 << 11) | ||
| 1740 | #define RT5670_HPF_CF_R_MASK (0x7 << 8) | ||
| 1741 | #define RT5670_HPF_CF_R_SFT 8 | ||
| 1742 | #define RT5670_ZD_T_MASK (0x3 << 6) | ||
| 1743 | #define RT5670_ZD_T_SFT 6 | ||
| 1744 | #define RT5670_ZD_F_MASK (0x3 << 4) | ||
| 1745 | #define RT5670_ZD_F_SFT 4 | ||
| 1746 | #define RT5670_ZD_F_IM (0x0 << 4) | ||
| 1747 | #define RT5670_ZD_F_ZC_IM (0x1 << 4) | ||
| 1748 | #define RT5670_ZD_F_ZC_IOD (0x2 << 4) | ||
| 1749 | #define RT5670_ZD_F_UN (0x3 << 4) | ||
| 1750 | |||
| 1751 | /* HP calibration control and Amp detection (0xd6) */ | ||
| 1752 | #define RT5670_SI_DAC_MASK (0x1 << 11) | ||
| 1753 | #define RT5670_SI_DAC_SFT 11 | ||
| 1754 | #define RT5670_SI_DAC_AUTO (0x0 << 11) | ||
| 1755 | #define RT5670_SI_DAC_TEST (0x1 << 11) | ||
| 1756 | #define RT5670_DC_CAL_M_MASK (0x1 << 10) | ||
| 1757 | #define RT5670_DC_CAL_M_SFT 10 | ||
| 1758 | #define RT5670_DC_CAL_M_CAL (0x0 << 10) | ||
| 1759 | #define RT5670_DC_CAL_M_NOR (0x1 << 10) | ||
| 1760 | #define RT5670_DC_CAL_MASK (0x1 << 9) | ||
| 1761 | #define RT5670_DC_CAL_SFT 9 | ||
| 1762 | #define RT5670_DC_CAL_DIS (0x0 << 9) | ||
| 1763 | #define RT5670_DC_CAL_EN (0x1 << 9) | ||
| 1764 | #define RT5670_HPD_RCV_MASK (0x7 << 6) | ||
| 1765 | #define RT5670_HPD_RCV_SFT 6 | ||
| 1766 | #define RT5670_HPD_PS_MASK (0x1 << 5) | ||
| 1767 | #define RT5670_HPD_PS_SFT 5 | ||
| 1768 | #define RT5670_HPD_PS_DIS (0x0 << 5) | ||
| 1769 | #define RT5670_HPD_PS_EN (0x1 << 5) | ||
| 1770 | #define RT5670_CAL_M_MASK (0x1 << 4) | ||
| 1771 | #define RT5670_CAL_M_SFT 4 | ||
| 1772 | #define RT5670_CAL_M_DEP (0x0 << 4) | ||
| 1773 | #define RT5670_CAL_M_CAL (0x1 << 4) | ||
| 1774 | #define RT5670_CAL_MASK (0x1 << 3) | ||
| 1775 | #define RT5670_CAL_SFT 3 | ||
| 1776 | #define RT5670_CAL_DIS (0x0 << 3) | ||
| 1777 | #define RT5670_CAL_EN (0x1 << 3) | ||
| 1778 | #define RT5670_CAL_TEST_MASK (0x1 << 2) | ||
| 1779 | #define RT5670_CAL_TEST_SFT 2 | ||
| 1780 | #define RT5670_CAL_TEST_DIS (0x0 << 2) | ||
| 1781 | #define RT5670_CAL_TEST_EN (0x1 << 2) | ||
| 1782 | #define RT5670_CAL_P_MASK (0x3) | ||
| 1783 | #define RT5670_CAL_P_SFT 0 | ||
| 1784 | #define RT5670_CAL_P_NONE (0x0) | ||
| 1785 | #define RT5670_CAL_P_CAL (0x1) | ||
| 1786 | #define RT5670_CAL_P_DAC_CAL (0x2) | ||
| 1787 | |||
| 1788 | /* Soft volume and zero cross control 1 (0xd9) */ | ||
| 1789 | #define RT5670_SV_MASK (0x1 << 15) | ||
| 1790 | #define RT5670_SV_SFT 15 | ||
| 1791 | #define RT5670_SV_DIS (0x0 << 15) | ||
| 1792 | #define RT5670_SV_EN (0x1 << 15) | ||
| 1793 | #define RT5670_SPO_SV_MASK (0x1 << 14) | ||
| 1794 | #define RT5670_SPO_SV_SFT 14 | ||
| 1795 | #define RT5670_SPO_SV_DIS (0x0 << 14) | ||
| 1796 | #define RT5670_SPO_SV_EN (0x1 << 14) | ||
| 1797 | #define RT5670_OUT_SV_MASK (0x1 << 13) | ||
| 1798 | #define RT5670_OUT_SV_SFT 13 | ||
| 1799 | #define RT5670_OUT_SV_DIS (0x0 << 13) | ||
| 1800 | #define RT5670_OUT_SV_EN (0x1 << 13) | ||
| 1801 | #define RT5670_HP_SV_MASK (0x1 << 12) | ||
| 1802 | #define RT5670_HP_SV_SFT 12 | ||
| 1803 | #define RT5670_HP_SV_DIS (0x0 << 12) | ||
| 1804 | #define RT5670_HP_SV_EN (0x1 << 12) | ||
| 1805 | #define RT5670_ZCD_DIG_MASK (0x1 << 11) | ||
| 1806 | #define RT5670_ZCD_DIG_SFT 11 | ||
| 1807 | #define RT5670_ZCD_DIG_DIS (0x0 << 11) | ||
| 1808 | #define RT5670_ZCD_DIG_EN (0x1 << 11) | ||
| 1809 | #define RT5670_ZCD_MASK (0x1 << 10) | ||
| 1810 | #define RT5670_ZCD_SFT 10 | ||
| 1811 | #define RT5670_ZCD_PD (0x0 << 10) | ||
| 1812 | #define RT5670_ZCD_PU (0x1 << 10) | ||
| 1813 | #define RT5670_M_ZCD_MASK (0x3f << 4) | ||
| 1814 | #define RT5670_M_ZCD_SFT 4 | ||
| 1815 | #define RT5670_M_ZCD_RM_L (0x1 << 9) | ||
| 1816 | #define RT5670_M_ZCD_RM_R (0x1 << 8) | ||
| 1817 | #define RT5670_M_ZCD_SM_L (0x1 << 7) | ||
| 1818 | #define RT5670_M_ZCD_SM_R (0x1 << 6) | ||
| 1819 | #define RT5670_M_ZCD_OM_L (0x1 << 5) | ||
| 1820 | #define RT5670_M_ZCD_OM_R (0x1 << 4) | ||
| 1821 | #define RT5670_SV_DLY_MASK (0xf) | ||
| 1822 | #define RT5670_SV_DLY_SFT 0 | ||
| 1823 | |||
| 1824 | /* Soft volume and zero cross control 2 (0xda) */ | ||
| 1825 | #define RT5670_ZCD_HP_MASK (0x1 << 15) | ||
| 1826 | #define RT5670_ZCD_HP_SFT 15 | ||
| 1827 | #define RT5670_ZCD_HP_DIS (0x0 << 15) | ||
| 1828 | #define RT5670_ZCD_HP_EN (0x1 << 15) | ||
| 1829 | |||
| 1830 | |||
| 1831 | /* Codec Private Register definition */ | ||
| 1832 | /* 3D Speaker Control (0x63) */ | ||
| 1833 | #define RT5670_3D_SPK_MASK (0x1 << 15) | ||
| 1834 | #define RT5670_3D_SPK_SFT 15 | ||
| 1835 | #define RT5670_3D_SPK_DIS (0x0 << 15) | ||
| 1836 | #define RT5670_3D_SPK_EN (0x1 << 15) | ||
| 1837 | #define RT5670_3D_SPK_M_MASK (0x3 << 13) | ||
| 1838 | #define RT5670_3D_SPK_M_SFT 13 | ||
| 1839 | #define RT5670_3D_SPK_CG_MASK (0x1f << 8) | ||
| 1840 | #define RT5670_3D_SPK_CG_SFT 8 | ||
| 1841 | #define RT5670_3D_SPK_SG_MASK (0x1f) | ||
| 1842 | #define RT5670_3D_SPK_SG_SFT 0 | ||
| 1843 | |||
| 1844 | /* Wind Noise Detection Control 1 (0x6c) */ | ||
| 1845 | #define RT5670_WND_MASK (0x1 << 15) | ||
| 1846 | #define RT5670_WND_SFT 15 | ||
| 1847 | #define RT5670_WND_DIS (0x0 << 15) | ||
| 1848 | #define RT5670_WND_EN (0x1 << 15) | ||
| 1849 | |||
| 1850 | /* Wind Noise Detection Control 2 (0x6d) */ | ||
| 1851 | #define RT5670_WND_FC_NW_MASK (0x3f << 10) | ||
| 1852 | #define RT5670_WND_FC_NW_SFT 10 | ||
| 1853 | #define RT5670_WND_FC_WK_MASK (0x3f << 4) | ||
| 1854 | #define RT5670_WND_FC_WK_SFT 4 | ||
| 1855 | |||
| 1856 | /* Wind Noise Detection Control 3 (0x6e) */ | ||
| 1857 | #define RT5670_HPF_FC_MASK (0x3f << 6) | ||
| 1858 | #define RT5670_HPF_FC_SFT 6 | ||
| 1859 | #define RT5670_WND_FC_ST_MASK (0x3f) | ||
| 1860 | #define RT5670_WND_FC_ST_SFT 0 | ||
| 1861 | |||
| 1862 | /* Wind Noise Detection Control 4 (0x6f) */ | ||
| 1863 | #define RT5670_WND_TH_LO_MASK (0x3ff) | ||
| 1864 | #define RT5670_WND_TH_LO_SFT 0 | ||
| 1865 | |||
| 1866 | /* Wind Noise Detection Control 5 (0x70) */ | ||
| 1867 | #define RT5670_WND_TH_HI_MASK (0x3ff) | ||
| 1868 | #define RT5670_WND_TH_HI_SFT 0 | ||
| 1869 | |||
| 1870 | /* Wind Noise Detection Control 8 (0x73) */ | ||
| 1871 | #define RT5670_WND_WIND_MASK (0x1 << 13) /* Read-Only */ | ||
| 1872 | #define RT5670_WND_WIND_SFT 13 | ||
| 1873 | #define RT5670_WND_STRONG_MASK (0x1 << 12) /* Read-Only */ | ||
| 1874 | #define RT5670_WND_STRONG_SFT 12 | ||
| 1875 | enum { | ||
| 1876 | RT5670_NO_WIND, | ||
| 1877 | RT5670_BREEZE, | ||
| 1878 | RT5670_STORM, | ||
| 1879 | }; | ||
| 1880 | |||
| 1881 | /* Dipole Speaker Interface (0x75) */ | ||
| 1882 | #define RT5670_DP_ATT_MASK (0x3 << 14) | ||
| 1883 | #define RT5670_DP_ATT_SFT 14 | ||
| 1884 | #define RT5670_DP_SPK_MASK (0x1 << 10) | ||
| 1885 | #define RT5670_DP_SPK_SFT 10 | ||
| 1886 | #define RT5670_DP_SPK_DIS (0x0 << 10) | ||
| 1887 | #define RT5670_DP_SPK_EN (0x1 << 10) | ||
| 1888 | |||
| 1889 | /* EQ Pre Volume Control (0xb3) */ | ||
| 1890 | #define RT5670_EQ_PRE_VOL_MASK (0xffff) | ||
| 1891 | #define RT5670_EQ_PRE_VOL_SFT 0 | ||
| 1892 | |||
| 1893 | /* EQ Post Volume Control (0xb4) */ | ||
| 1894 | #define RT5670_EQ_PST_VOL_MASK (0xffff) | ||
| 1895 | #define RT5670_EQ_PST_VOL_SFT 0 | ||
| 1896 | |||
| 1897 | /* Jack Detect Control 3 (0xf8) */ | ||
| 1898 | #define RT5670_CMP_MIC_IN_DET_MASK (0x7 << 12) | ||
| 1899 | #define RT5670_JD_CBJ_EN (0x1 << 7) | ||
| 1900 | #define RT5670_JD_CBJ_POL (0x1 << 6) | ||
| 1901 | #define RT5670_JD_TRI_CBJ_SEL_MASK (0x7 << 3) | ||
| 1902 | #define RT5670_JD_TRI_CBJ_SEL_SFT (3) | ||
| 1903 | #define RT5670_JD_CBJ_GPIO_JD1 (0x0 << 3) | ||
| 1904 | #define RT5670_JD_CBJ_JD1_1 (0x1 << 3) | ||
| 1905 | #define RT5670_JD_CBJ_JD1_2 (0x2 << 3) | ||
| 1906 | #define RT5670_JD_CBJ_JD2 (0x3 << 3) | ||
| 1907 | #define RT5670_JD_CBJ_JD3 (0x4 << 3) | ||
| 1908 | #define RT5670_JD_CBJ_GPIO_JD2 (0x5 << 3) | ||
| 1909 | #define RT5670_JD_CBJ_MX0B_12 (0x6 << 3) | ||
| 1910 | #define RT5670_JD_TRI_HPO_SEL_MASK (0x7 << 3) | ||
| 1911 | #define RT5670_JD_TRI_HPO_SEL_SFT (0) | ||
| 1912 | #define RT5670_JD_HPO_GPIO_JD1 (0x0) | ||
| 1913 | #define RT5670_JD_HPO_JD1_1 (0x1) | ||
| 1914 | #define RT5670_JD_HPO_JD1_2 (0x2) | ||
| 1915 | #define RT5670_JD_HPO_JD2 (0x3) | ||
| 1916 | #define RT5670_JD_HPO_JD3 (0x4) | ||
| 1917 | #define RT5670_JD_HPO_GPIO_JD2 (0x5) | ||
| 1918 | #define RT5670_JD_HPO_MX0B_12 (0x6) | ||
| 1919 | |||
| 1920 | /* Digital Misc Control (0xfa) */ | ||
| 1921 | #define RT5670_RST_DSP (0x1 << 13) | ||
| 1922 | #define RT5670_IF1_ADC1_IN1_SEL (0x1 << 12) | ||
| 1923 | #define RT5670_IF1_ADC1_IN1_SFT 12 | ||
| 1924 | #define RT5670_IF1_ADC1_IN2_SEL (0x1 << 11) | ||
| 1925 | #define RT5670_IF1_ADC1_IN2_SFT 11 | ||
| 1926 | #define RT5670_IF1_ADC2_IN1_SEL (0x1 << 10) | ||
| 1927 | #define RT5670_IF1_ADC2_IN1_SFT 10 | ||
| 1928 | |||
| 1929 | /* General Control2 (0xfb) */ | ||
| 1930 | #define RT5670_RXDC_SRC_MASK (0x1 << 7) | ||
| 1931 | #define RT5670_RXDC_SRC_STO (0x0 << 7) | ||
| 1932 | #define RT5670_RXDC_SRC_MONO (0x1 << 7) | ||
| 1933 | #define RT5670_RXDC_SRC_SFT (7) | ||
| 1934 | #define RT5670_RXDP2_SEL_MASK (0x1 << 3) | ||
| 1935 | #define RT5670_RXDP2_SEL_IF2 (0x0 << 3) | ||
| 1936 | #define RT5670_RXDP2_SEL_ADC (0x1 << 3) | ||
| 1937 | #define RT5670_RXDP2_SEL_SFT (3) | ||
| 1938 | |||
| 1939 | /* System Clock Source */ | ||
| 1940 | enum { | ||
| 1941 | RT5670_SCLK_S_MCLK, | ||
| 1942 | RT5670_SCLK_S_PLL1, | ||
| 1943 | RT5670_SCLK_S_RCCLK, | ||
| 1944 | }; | ||
| 1945 | |||
| 1946 | /* PLL1 Source */ | ||
| 1947 | enum { | ||
| 1948 | RT5670_PLL1_S_MCLK, | ||
| 1949 | RT5670_PLL1_S_BCLK1, | ||
| 1950 | RT5670_PLL1_S_BCLK2, | ||
| 1951 | RT5670_PLL1_S_BCLK3, | ||
| 1952 | RT5670_PLL1_S_BCLK4, | ||
| 1953 | }; | ||
| 1954 | |||
| 1955 | enum { | ||
| 1956 | RT5670_AIF1, | ||
| 1957 | RT5670_AIF2, | ||
| 1958 | RT5670_AIF3, | ||
| 1959 | RT5670_AIF4, | ||
| 1960 | RT5670_AIFS, | ||
| 1961 | }; | ||
| 1962 | |||
| 1963 | enum { | ||
| 1964 | RT5670_DMIC_DATA_GPIO6, | ||
| 1965 | RT5670_DMIC_DATA_IN2P, | ||
| 1966 | RT5670_DMIC_DATA_GPIO7, | ||
| 1967 | }; | ||
| 1968 | |||
| 1969 | enum { | ||
| 1970 | RT5670_DMIC_DATA_GPIO8, | ||
| 1971 | RT5670_DMIC_DATA_IN3N, | ||
| 1972 | }; | ||
| 1973 | |||
| 1974 | enum { | ||
| 1975 | RT5670_DMIC_DATA_GPIO9, | ||
| 1976 | RT5670_DMIC_DATA_GPIO10, | ||
| 1977 | RT5670_DMIC_DATA_GPIO5, | ||
| 1978 | }; | ||
| 1979 | |||
| 1980 | struct rt5670_priv { | ||
| 1981 | struct snd_soc_codec *codec; | ||
| 1982 | struct rt5670_platform_data pdata; | ||
| 1983 | struct regmap *regmap; | ||
| 1984 | |||
| 1985 | int sysclk; | ||
| 1986 | int sysclk_src; | ||
| 1987 | int lrck[RT5670_AIFS]; | ||
| 1988 | int bclk[RT5670_AIFS]; | ||
| 1989 | int master[RT5670_AIFS]; | ||
| 1990 | |||
| 1991 | int pll_src; | ||
| 1992 | int pll_in; | ||
| 1993 | int pll_out; | ||
| 1994 | |||
| 1995 | int dsp_sw; /* expected parameter setting */ | ||
| 1996 | int dsp_rate; | ||
| 1997 | int jack_type; | ||
| 1998 | }; | ||
| 1999 | |||
| 2000 | #endif /* __RT5670_H__ */ | ||
diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c index 833231e27340..67f14556462f 100644 --- a/sound/soc/codecs/rt5677.c +++ b/sound/soc/codecs/rt5677.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <sound/initval.h> | 27 | #include <sound/initval.h> |
| 28 | #include <sound/tlv.h> | 28 | #include <sound/tlv.h> |
| 29 | 29 | ||
| 30 | #include "rl6231.h" | ||
| 30 | #include "rt5677.h" | 31 | #include "rt5677.h" |
| 31 | 32 | ||
| 32 | #define RT5677_DEVICE_ID 0x6327 | 33 | #define RT5677_DEVICE_ID 0x6327 |
| @@ -604,19 +605,19 @@ static const struct snd_kcontrol_new rt5677_snd_controls[] = { | |||
| 604 | adc_vol_tlv), | 605 | adc_vol_tlv), |
| 605 | 606 | ||
| 606 | /* ADC Boost Volume Control */ | 607 | /* ADC Boost Volume Control */ |
| 607 | SOC_DOUBLE_TLV("STO1 ADC Boost Gain", RT5677_STO1_2_ADC_BST, | 608 | SOC_DOUBLE_TLV("STO1 ADC Boost Volume", RT5677_STO1_2_ADC_BST, |
| 608 | RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0, | 609 | RT5677_STO1_ADC_L_BST_SFT, RT5677_STO1_ADC_R_BST_SFT, 3, 0, |
| 609 | adc_bst_tlv), | 610 | adc_bst_tlv), |
| 610 | SOC_DOUBLE_TLV("STO2 ADC Boost Gain", RT5677_STO1_2_ADC_BST, | 611 | SOC_DOUBLE_TLV("STO2 ADC Boost Volume", RT5677_STO1_2_ADC_BST, |
| 611 | RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0, | 612 | RT5677_STO2_ADC_L_BST_SFT, RT5677_STO2_ADC_R_BST_SFT, 3, 0, |
| 612 | adc_bst_tlv), | 613 | adc_bst_tlv), |
| 613 | SOC_DOUBLE_TLV("STO3 ADC Boost Gain", RT5677_STO3_4_ADC_BST, | 614 | SOC_DOUBLE_TLV("STO3 ADC Boost Volume", RT5677_STO3_4_ADC_BST, |
| 614 | RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0, | 615 | RT5677_STO3_ADC_L_BST_SFT, RT5677_STO3_ADC_R_BST_SFT, 3, 0, |
| 615 | adc_bst_tlv), | 616 | adc_bst_tlv), |
| 616 | SOC_DOUBLE_TLV("STO4 ADC Boost Gain", RT5677_STO3_4_ADC_BST, | 617 | SOC_DOUBLE_TLV("STO4 ADC Boost Volume", RT5677_STO3_4_ADC_BST, |
| 617 | RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0, | 618 | RT5677_STO4_ADC_L_BST_SFT, RT5677_STO4_ADC_R_BST_SFT, 3, 0, |
| 618 | adc_bst_tlv), | 619 | adc_bst_tlv), |
| 619 | SOC_DOUBLE_TLV("Mono ADC Boost Gain", RT5677_ADC_BST_CTRL2, | 620 | SOC_DOUBLE_TLV("Mono ADC Boost Volume", RT5677_ADC_BST_CTRL2, |
| 620 | RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0, | 621 | RT5677_MONO_ADC_L_BST_SFT, RT5677_MONO_ADC_R_BST_SFT, 3, 0, |
| 621 | adc_bst_tlv), | 622 | adc_bst_tlv), |
| 622 | }; | 623 | }; |
| @@ -636,21 +637,7 @@ static int set_dmic_clk(struct snd_soc_dapm_widget *w, | |||
| 636 | { | 637 | { |
| 637 | struct snd_soc_codec *codec = w->codec; | 638 | struct snd_soc_codec *codec = w->codec; |
| 638 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | 639 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); |
| 639 | int div[] = {2, 3, 4, 6, 8, 12}, idx = -EINVAL, i; | 640 | int idx = rl6231_calc_dmic_clk(rt5677->sysclk); |
| 640 | int rate, red, bound, temp; | ||
| 641 | |||
| 642 | rate = rt5677->sysclk; | ||
| 643 | red = 3000000 * 12; | ||
| 644 | for (i = 0; i < ARRAY_SIZE(div); i++) { | ||
| 645 | bound = div[i] * 3000000; | ||
| 646 | if (rate > bound) | ||
| 647 | continue; | ||
| 648 | temp = bound - rate; | ||
| 649 | if (temp < red) { | ||
| 650 | red = temp; | ||
| 651 | idx = i; | ||
| 652 | } | ||
| 653 | } | ||
| 654 | 641 | ||
| 655 | if (idx < 0) | 642 | if (idx < 0) |
| 656 | dev_err(codec->dev, "Failed to set DMIC clock\n"); | 643 | dev_err(codec->dev, "Failed to set DMIC clock\n"); |
| @@ -951,7 +938,7 @@ static const struct snd_kcontrol_new rt5677_ob_7_mix[] = { | |||
| 951 | 938 | ||
| 952 | 939 | ||
| 953 | /* Mux */ | 940 | /* Mux */ |
| 954 | /* DAC1 L/R source */ /* MX-29 [10:8] */ | 941 | /* DAC1 L/R Source */ /* MX-29 [10:8] */ |
| 955 | static const char * const rt5677_dac1_src[] = { | 942 | static const char * const rt5677_dac1_src[] = { |
| 956 | "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01", | 943 | "IF1 DAC 01", "IF2 DAC 01", "IF3 DAC LR", "IF4 DAC LR", "SLB DAC 01", |
| 957 | "OB 01" | 944 | "OB 01" |
| @@ -962,9 +949,9 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 962 | RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src); | 949 | RT5677_DAC1_L_SEL_SFT, rt5677_dac1_src); |
| 963 | 950 | ||
| 964 | static const struct snd_kcontrol_new rt5677_dac1_mux = | 951 | static const struct snd_kcontrol_new rt5677_dac1_mux = |
| 965 | SOC_DAPM_ENUM("DAC1 source", rt5677_dac1_enum); | 952 | SOC_DAPM_ENUM("DAC1 Source", rt5677_dac1_enum); |
| 966 | 953 | ||
| 967 | /* ADDA1 L/R source */ /* MX-29 [1:0] */ | 954 | /* ADDA1 L/R Source */ /* MX-29 [1:0] */ |
| 968 | static const char * const rt5677_adda1_src[] = { | 955 | static const char * const rt5677_adda1_src[] = { |
| 969 | "STO1 ADC MIX", "STO2 ADC MIX", "OB 67", | 956 | "STO1 ADC MIX", "STO2 ADC MIX", "OB 67", |
| 970 | }; | 957 | }; |
| @@ -974,10 +961,10 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 974 | RT5677_ADDA1_SEL_SFT, rt5677_adda1_src); | 961 | RT5677_ADDA1_SEL_SFT, rt5677_adda1_src); |
| 975 | 962 | ||
| 976 | static const struct snd_kcontrol_new rt5677_adda1_mux = | 963 | static const struct snd_kcontrol_new rt5677_adda1_mux = |
| 977 | SOC_DAPM_ENUM("ADDA1 source", rt5677_adda1_enum); | 964 | SOC_DAPM_ENUM("ADDA1 Source", rt5677_adda1_enum); |
| 978 | 965 | ||
| 979 | 966 | ||
| 980 | /*DAC2 L/R source*/ /* MX-1B [6:4] [2:0] */ | 967 | /*DAC2 L/R Source*/ /* MX-1B [6:4] [2:0] */ |
| 981 | static const char * const rt5677_dac2l_src[] = { | 968 | static const char * const rt5677_dac2l_src[] = { |
| 982 | "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2", | 969 | "IF1 DAC 2", "IF2 DAC 2", "IF3 DAC L", "IF4 DAC L", "SLB DAC 2", |
| 983 | "OB 2", | 970 | "OB 2", |
| @@ -988,7 +975,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 988 | RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src); | 975 | RT5677_SEL_DAC2_L_SRC_SFT, rt5677_dac2l_src); |
| 989 | 976 | ||
| 990 | static const struct snd_kcontrol_new rt5677_dac2_l_mux = | 977 | static const struct snd_kcontrol_new rt5677_dac2_l_mux = |
| 991 | SOC_DAPM_ENUM("DAC2 L source", rt5677_dac2l_enum); | 978 | SOC_DAPM_ENUM("DAC2 L Source", rt5677_dac2l_enum); |
| 992 | 979 | ||
| 993 | static const char * const rt5677_dac2r_src[] = { | 980 | static const char * const rt5677_dac2r_src[] = { |
| 994 | "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3", | 981 | "IF1 DAC 3", "IF2 DAC 3", "IF3 DAC R", "IF4 DAC R", "SLB DAC 3", |
| @@ -1000,9 +987,9 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1000 | RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src); | 987 | RT5677_SEL_DAC2_R_SRC_SFT, rt5677_dac2r_src); |
| 1001 | 988 | ||
| 1002 | static const struct snd_kcontrol_new rt5677_dac2_r_mux = | 989 | static const struct snd_kcontrol_new rt5677_dac2_r_mux = |
| 1003 | SOC_DAPM_ENUM("DAC2 R source", rt5677_dac2r_enum); | 990 | SOC_DAPM_ENUM("DAC2 R Source", rt5677_dac2r_enum); |
| 1004 | 991 | ||
| 1005 | /*DAC3 L/R source*/ /* MX-16 [6:4] [2:0] */ | 992 | /*DAC3 L/R Source*/ /* MX-16 [6:4] [2:0] */ |
| 1006 | static const char * const rt5677_dac3l_src[] = { | 993 | static const char * const rt5677_dac3l_src[] = { |
| 1007 | "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L", | 994 | "IF1 DAC 4", "IF2 DAC 4", "IF3 DAC L", "IF4 DAC L", |
| 1008 | "SLB DAC 4", "OB 4" | 995 | "SLB DAC 4", "OB 4" |
| @@ -1013,7 +1000,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1013 | RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src); | 1000 | RT5677_SEL_DAC3_L_SRC_SFT, rt5677_dac3l_src); |
| 1014 | 1001 | ||
| 1015 | static const struct snd_kcontrol_new rt5677_dac3_l_mux = | 1002 | static const struct snd_kcontrol_new rt5677_dac3_l_mux = |
| 1016 | SOC_DAPM_ENUM("DAC3 L source", rt5677_dac3l_enum); | 1003 | SOC_DAPM_ENUM("DAC3 L Source", rt5677_dac3l_enum); |
| 1017 | 1004 | ||
| 1018 | static const char * const rt5677_dac3r_src[] = { | 1005 | static const char * const rt5677_dac3r_src[] = { |
| 1019 | "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R", | 1006 | "IF1 DAC 5", "IF2 DAC 5", "IF3 DAC R", "IF4 DAC R", |
| @@ -1025,9 +1012,9 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1025 | RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src); | 1012 | RT5677_SEL_DAC3_R_SRC_SFT, rt5677_dac3r_src); |
| 1026 | 1013 | ||
| 1027 | static const struct snd_kcontrol_new rt5677_dac3_r_mux = | 1014 | static const struct snd_kcontrol_new rt5677_dac3_r_mux = |
| 1028 | SOC_DAPM_ENUM("DAC3 R source", rt5677_dac3r_enum); | 1015 | SOC_DAPM_ENUM("DAC3 R Source", rt5677_dac3r_enum); |
| 1029 | 1016 | ||
| 1030 | /*DAC4 L/R source*/ /* MX-16 [14:12] [10:8] */ | 1017 | /*DAC4 L/R Source*/ /* MX-16 [14:12] [10:8] */ |
| 1031 | static const char * const rt5677_dac4l_src[] = { | 1018 | static const char * const rt5677_dac4l_src[] = { |
| 1032 | "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L", | 1019 | "IF1 DAC 6", "IF2 DAC 6", "IF3 DAC L", "IF4 DAC L", |
| 1033 | "SLB DAC 6", "OB 6" | 1020 | "SLB DAC 6", "OB 6" |
| @@ -1038,7 +1025,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1038 | RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src); | 1025 | RT5677_SEL_DAC4_L_SRC_SFT, rt5677_dac4l_src); |
| 1039 | 1026 | ||
| 1040 | static const struct snd_kcontrol_new rt5677_dac4_l_mux = | 1027 | static const struct snd_kcontrol_new rt5677_dac4_l_mux = |
| 1041 | SOC_DAPM_ENUM("DAC4 L source", rt5677_dac4l_enum); | 1028 | SOC_DAPM_ENUM("DAC4 L Source", rt5677_dac4l_enum); |
| 1042 | 1029 | ||
| 1043 | static const char * const rt5677_dac4r_src[] = { | 1030 | static const char * const rt5677_dac4r_src[] = { |
| 1044 | "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R", | 1031 | "IF1 DAC 7", "IF2 DAC 7", "IF3 DAC R", "IF4 DAC R", |
| @@ -1050,7 +1037,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1050 | RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src); | 1037 | RT5677_SEL_DAC4_R_SRC_SFT, rt5677_dac4r_src); |
| 1051 | 1038 | ||
| 1052 | static const struct snd_kcontrol_new rt5677_dac4_r_mux = | 1039 | static const struct snd_kcontrol_new rt5677_dac4_r_mux = |
| 1053 | SOC_DAPM_ENUM("DAC4 R source", rt5677_dac4r_enum); | 1040 | SOC_DAPM_ENUM("DAC4 R Source", rt5677_dac4r_enum); |
| 1054 | 1041 | ||
| 1055 | /* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */ | 1042 | /* In/OutBound Source Pass SRC */ /* MX-A5 [3] [4] [0] [1] [2] */ |
| 1056 | static const char * const rt5677_iob_bypass_src[] = { | 1043 | static const char * const rt5677_iob_bypass_src[] = { |
| @@ -1062,35 +1049,35 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1062 | RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src); | 1049 | RT5677_SEL_SRC_OB01_SFT, rt5677_iob_bypass_src); |
| 1063 | 1050 | ||
| 1064 | static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux = | 1051 | static const struct snd_kcontrol_new rt5677_ob01_bypass_src_mux = |
| 1065 | SOC_DAPM_ENUM("OB01 Bypass source", rt5677_ob01_bypass_src_enum); | 1052 | SOC_DAPM_ENUM("OB01 Bypass Source", rt5677_ob01_bypass_src_enum); |
| 1066 | 1053 | ||
| 1067 | static SOC_ENUM_SINGLE_DECL( | 1054 | static SOC_ENUM_SINGLE_DECL( |
| 1068 | rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | 1055 | rt5677_ob23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, |
| 1069 | RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src); | 1056 | RT5677_SEL_SRC_OB23_SFT, rt5677_iob_bypass_src); |
| 1070 | 1057 | ||
| 1071 | static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux = | 1058 | static const struct snd_kcontrol_new rt5677_ob23_bypass_src_mux = |
| 1072 | SOC_DAPM_ENUM("OB23 Bypass source", rt5677_ob23_bypass_src_enum); | 1059 | SOC_DAPM_ENUM("OB23 Bypass Source", rt5677_ob23_bypass_src_enum); |
| 1073 | 1060 | ||
| 1074 | static SOC_ENUM_SINGLE_DECL( | 1061 | static SOC_ENUM_SINGLE_DECL( |
| 1075 | rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | 1062 | rt5677_ib01_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, |
| 1076 | RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src); | 1063 | RT5677_SEL_SRC_IB01_SFT, rt5677_iob_bypass_src); |
| 1077 | 1064 | ||
| 1078 | static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux = | 1065 | static const struct snd_kcontrol_new rt5677_ib01_bypass_src_mux = |
| 1079 | SOC_DAPM_ENUM("IB01 Bypass source", rt5677_ib01_bypass_src_enum); | 1066 | SOC_DAPM_ENUM("IB01 Bypass Source", rt5677_ib01_bypass_src_enum); |
| 1080 | 1067 | ||
| 1081 | static SOC_ENUM_SINGLE_DECL( | 1068 | static SOC_ENUM_SINGLE_DECL( |
| 1082 | rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | 1069 | rt5677_ib23_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, |
| 1083 | RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src); | 1070 | RT5677_SEL_SRC_IB23_SFT, rt5677_iob_bypass_src); |
| 1084 | 1071 | ||
| 1085 | static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux = | 1072 | static const struct snd_kcontrol_new rt5677_ib23_bypass_src_mux = |
| 1086 | SOC_DAPM_ENUM("IB23 Bypass source", rt5677_ib23_bypass_src_enum); | 1073 | SOC_DAPM_ENUM("IB23 Bypass Source", rt5677_ib23_bypass_src_enum); |
| 1087 | 1074 | ||
| 1088 | static SOC_ENUM_SINGLE_DECL( | 1075 | static SOC_ENUM_SINGLE_DECL( |
| 1089 | rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, | 1076 | rt5677_ib45_bypass_src_enum, RT5677_DSP_IN_OUTB_CTRL, |
| 1090 | RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src); | 1077 | RT5677_SEL_SRC_IB45_SFT, rt5677_iob_bypass_src); |
| 1091 | 1078 | ||
| 1092 | static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux = | 1079 | static const struct snd_kcontrol_new rt5677_ib45_bypass_src_mux = |
| 1093 | SOC_DAPM_ENUM("IB45 Bypass source", rt5677_ib45_bypass_src_enum); | 1080 | SOC_DAPM_ENUM("IB45 Bypass Source", rt5677_ib45_bypass_src_enum); |
| 1094 | 1081 | ||
| 1095 | /* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */ | 1082 | /* Stereo ADC Source 2 */ /* MX-27 MX26 MX25 [11:10] */ |
| 1096 | static const char * const rt5677_stereo_adc2_src[] = { | 1083 | static const char * const rt5677_stereo_adc2_src[] = { |
| @@ -1102,21 +1089,21 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1102 | RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src); | 1089 | RT5677_SEL_STO1_ADC2_SFT, rt5677_stereo_adc2_src); |
| 1103 | 1090 | ||
| 1104 | static const struct snd_kcontrol_new rt5677_sto1_adc2_mux = | 1091 | static const struct snd_kcontrol_new rt5677_sto1_adc2_mux = |
| 1105 | SOC_DAPM_ENUM("Stereo1 ADC2 source", rt5677_stereo1_adc2_enum); | 1092 | SOC_DAPM_ENUM("Stereo1 ADC2 Source", rt5677_stereo1_adc2_enum); |
| 1106 | 1093 | ||
| 1107 | static SOC_ENUM_SINGLE_DECL( | 1094 | static SOC_ENUM_SINGLE_DECL( |
| 1108 | rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER, | 1095 | rt5677_stereo2_adc2_enum, RT5677_STO2_ADC_MIXER, |
| 1109 | RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src); | 1096 | RT5677_SEL_STO2_ADC2_SFT, rt5677_stereo_adc2_src); |
| 1110 | 1097 | ||
| 1111 | static const struct snd_kcontrol_new rt5677_sto2_adc2_mux = | 1098 | static const struct snd_kcontrol_new rt5677_sto2_adc2_mux = |
| 1112 | SOC_DAPM_ENUM("Stereo2 ADC2 source", rt5677_stereo2_adc2_enum); | 1099 | SOC_DAPM_ENUM("Stereo2 ADC2 Source", rt5677_stereo2_adc2_enum); |
| 1113 | 1100 | ||
| 1114 | static SOC_ENUM_SINGLE_DECL( | 1101 | static SOC_ENUM_SINGLE_DECL( |
| 1115 | rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER, | 1102 | rt5677_stereo3_adc2_enum, RT5677_STO3_ADC_MIXER, |
| 1116 | RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src); | 1103 | RT5677_SEL_STO3_ADC2_SFT, rt5677_stereo_adc2_src); |
| 1117 | 1104 | ||
| 1118 | static const struct snd_kcontrol_new rt5677_sto3_adc2_mux = | 1105 | static const struct snd_kcontrol_new rt5677_sto3_adc2_mux = |
| 1119 | SOC_DAPM_ENUM("Stereo3 ADC2 source", rt5677_stereo3_adc2_enum); | 1106 | SOC_DAPM_ENUM("Stereo3 ADC2 Source", rt5677_stereo3_adc2_enum); |
| 1120 | 1107 | ||
| 1121 | /* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */ | 1108 | /* DMIC Source */ /* MX-28 [9:8][1:0] MX-27 MX-26 MX-25 MX-24 [9:8] */ |
| 1122 | static const char * const rt5677_dmic_src[] = { | 1109 | static const char * const rt5677_dmic_src[] = { |
| @@ -1128,44 +1115,44 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1128 | RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src); | 1115 | RT5677_SEL_MONO_DMIC_L_SFT, rt5677_dmic_src); |
| 1129 | 1116 | ||
| 1130 | static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux = | 1117 | static const struct snd_kcontrol_new rt5677_mono_dmic_l_mux = |
| 1131 | SOC_DAPM_ENUM("Mono DMIC L source", rt5677_mono_dmic_l_enum); | 1118 | SOC_DAPM_ENUM("Mono DMIC L Source", rt5677_mono_dmic_l_enum); |
| 1132 | 1119 | ||
| 1133 | static SOC_ENUM_SINGLE_DECL( | 1120 | static SOC_ENUM_SINGLE_DECL( |
| 1134 | rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER, | 1121 | rt5677_mono_dmic_r_enum, RT5677_MONO_ADC_MIXER, |
| 1135 | RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src); | 1122 | RT5677_SEL_MONO_DMIC_R_SFT, rt5677_dmic_src); |
| 1136 | 1123 | ||
| 1137 | static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux = | 1124 | static const struct snd_kcontrol_new rt5677_mono_dmic_r_mux = |
| 1138 | SOC_DAPM_ENUM("Mono DMIC R source", rt5677_mono_dmic_r_enum); | 1125 | SOC_DAPM_ENUM("Mono DMIC R Source", rt5677_mono_dmic_r_enum); |
| 1139 | 1126 | ||
| 1140 | static SOC_ENUM_SINGLE_DECL( | 1127 | static SOC_ENUM_SINGLE_DECL( |
| 1141 | rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER, | 1128 | rt5677_stereo1_dmic_enum, RT5677_STO1_ADC_MIXER, |
| 1142 | RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src); | 1129 | RT5677_SEL_STO1_DMIC_SFT, rt5677_dmic_src); |
| 1143 | 1130 | ||
| 1144 | static const struct snd_kcontrol_new rt5677_sto1_dmic_mux = | 1131 | static const struct snd_kcontrol_new rt5677_sto1_dmic_mux = |
| 1145 | SOC_DAPM_ENUM("Stereo1 DMIC source", rt5677_stereo1_dmic_enum); | 1132 | SOC_DAPM_ENUM("Stereo1 DMIC Source", rt5677_stereo1_dmic_enum); |
| 1146 | 1133 | ||
| 1147 | static SOC_ENUM_SINGLE_DECL( | 1134 | static SOC_ENUM_SINGLE_DECL( |
| 1148 | rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER, | 1135 | rt5677_stereo2_dmic_enum, RT5677_STO2_ADC_MIXER, |
| 1149 | RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src); | 1136 | RT5677_SEL_STO2_DMIC_SFT, rt5677_dmic_src); |
| 1150 | 1137 | ||
| 1151 | static const struct snd_kcontrol_new rt5677_sto2_dmic_mux = | 1138 | static const struct snd_kcontrol_new rt5677_sto2_dmic_mux = |
| 1152 | SOC_DAPM_ENUM("Stereo2 DMIC source", rt5677_stereo2_dmic_enum); | 1139 | SOC_DAPM_ENUM("Stereo2 DMIC Source", rt5677_stereo2_dmic_enum); |
| 1153 | 1140 | ||
| 1154 | static SOC_ENUM_SINGLE_DECL( | 1141 | static SOC_ENUM_SINGLE_DECL( |
| 1155 | rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER, | 1142 | rt5677_stereo3_dmic_enum, RT5677_STO3_ADC_MIXER, |
| 1156 | RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src); | 1143 | RT5677_SEL_STO3_DMIC_SFT, rt5677_dmic_src); |
| 1157 | 1144 | ||
| 1158 | static const struct snd_kcontrol_new rt5677_sto3_dmic_mux = | 1145 | static const struct snd_kcontrol_new rt5677_sto3_dmic_mux = |
| 1159 | SOC_DAPM_ENUM("Stereo3 DMIC source", rt5677_stereo3_dmic_enum); | 1146 | SOC_DAPM_ENUM("Stereo3 DMIC Source", rt5677_stereo3_dmic_enum); |
| 1160 | 1147 | ||
| 1161 | static SOC_ENUM_SINGLE_DECL( | 1148 | static SOC_ENUM_SINGLE_DECL( |
| 1162 | rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER, | 1149 | rt5677_stereo4_dmic_enum, RT5677_STO4_ADC_MIXER, |
| 1163 | RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src); | 1150 | RT5677_SEL_STO4_DMIC_SFT, rt5677_dmic_src); |
| 1164 | 1151 | ||
| 1165 | static const struct snd_kcontrol_new rt5677_sto4_dmic_mux = | 1152 | static const struct snd_kcontrol_new rt5677_sto4_dmic_mux = |
| 1166 | SOC_DAPM_ENUM("Stereo4 DMIC source", rt5677_stereo4_dmic_enum); | 1153 | SOC_DAPM_ENUM("Stereo4 DMIC Source", rt5677_stereo4_dmic_enum); |
| 1167 | 1154 | ||
| 1168 | /* Stereo2 ADC source */ /* MX-26 [0] */ | 1155 | /* Stereo2 ADC Source */ /* MX-26 [0] */ |
| 1169 | static const char * const rt5677_stereo2_adc_lr_src[] = { | 1156 | static const char * const rt5677_stereo2_adc_lr_src[] = { |
| 1170 | "L", "LR" | 1157 | "L", "LR" |
| 1171 | }; | 1158 | }; |
| @@ -1175,7 +1162,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1175 | RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src); | 1162 | RT5677_SEL_STO2_LR_MIX_SFT, rt5677_stereo2_adc_lr_src); |
| 1176 | 1163 | ||
| 1177 | static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux = | 1164 | static const struct snd_kcontrol_new rt5677_sto2_adc_lr_mux = |
| 1178 | SOC_DAPM_ENUM("Stereo2 ADC LR source", rt5677_stereo2_adc_lr_enum); | 1165 | SOC_DAPM_ENUM("Stereo2 ADC LR Source", rt5677_stereo2_adc_lr_enum); |
| 1179 | 1166 | ||
| 1180 | /* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */ | 1167 | /* Stereo1 ADC Source 1 */ /* MX-27 MX26 MX25 [13:12] */ |
| 1181 | static const char * const rt5677_stereo_adc1_src[] = { | 1168 | static const char * const rt5677_stereo_adc1_src[] = { |
| @@ -1187,23 +1174,23 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1187 | RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src); | 1174 | RT5677_SEL_STO1_ADC1_SFT, rt5677_stereo_adc1_src); |
| 1188 | 1175 | ||
| 1189 | static const struct snd_kcontrol_new rt5677_sto1_adc1_mux = | 1176 | static const struct snd_kcontrol_new rt5677_sto1_adc1_mux = |
| 1190 | SOC_DAPM_ENUM("Stereo1 ADC1 source", rt5677_stereo1_adc1_enum); | 1177 | SOC_DAPM_ENUM("Stereo1 ADC1 Source", rt5677_stereo1_adc1_enum); |
| 1191 | 1178 | ||
| 1192 | static SOC_ENUM_SINGLE_DECL( | 1179 | static SOC_ENUM_SINGLE_DECL( |
| 1193 | rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER, | 1180 | rt5677_stereo2_adc1_enum, RT5677_STO2_ADC_MIXER, |
| 1194 | RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src); | 1181 | RT5677_SEL_STO2_ADC1_SFT, rt5677_stereo_adc1_src); |
| 1195 | 1182 | ||
| 1196 | static const struct snd_kcontrol_new rt5677_sto2_adc1_mux = | 1183 | static const struct snd_kcontrol_new rt5677_sto2_adc1_mux = |
| 1197 | SOC_DAPM_ENUM("Stereo2 ADC1 source", rt5677_stereo2_adc1_enum); | 1184 | SOC_DAPM_ENUM("Stereo2 ADC1 Source", rt5677_stereo2_adc1_enum); |
| 1198 | 1185 | ||
| 1199 | static SOC_ENUM_SINGLE_DECL( | 1186 | static SOC_ENUM_SINGLE_DECL( |
| 1200 | rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER, | 1187 | rt5677_stereo3_adc1_enum, RT5677_STO3_ADC_MIXER, |
| 1201 | RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src); | 1188 | RT5677_SEL_STO3_ADC1_SFT, rt5677_stereo_adc1_src); |
| 1202 | 1189 | ||
| 1203 | static const struct snd_kcontrol_new rt5677_sto3_adc1_mux = | 1190 | static const struct snd_kcontrol_new rt5677_sto3_adc1_mux = |
| 1204 | SOC_DAPM_ENUM("Stereo3 ADC1 source", rt5677_stereo3_adc1_enum); | 1191 | SOC_DAPM_ENUM("Stereo3 ADC1 Source", rt5677_stereo3_adc1_enum); |
| 1205 | 1192 | ||
| 1206 | /* Mono ADC Left source 2 */ /* MX-28 [11:10] */ | 1193 | /* Mono ADC Left Source 2 */ /* MX-28 [11:10] */ |
| 1207 | static const char * const rt5677_mono_adc2_l_src[] = { | 1194 | static const char * const rt5677_mono_adc2_l_src[] = { |
| 1208 | "DD MIX1L", "DMIC", "MONO DAC MIXL" | 1195 | "DD MIX1L", "DMIC", "MONO DAC MIXL" |
| 1209 | }; | 1196 | }; |
| @@ -1213,9 +1200,9 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1213 | RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src); | 1200 | RT5677_SEL_MONO_ADC_L2_SFT, rt5677_mono_adc2_l_src); |
| 1214 | 1201 | ||
| 1215 | static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux = | 1202 | static const struct snd_kcontrol_new rt5677_mono_adc2_l_mux = |
| 1216 | SOC_DAPM_ENUM("Mono ADC2 L source", rt5677_mono_adc2_l_enum); | 1203 | SOC_DAPM_ENUM("Mono ADC2 L Source", rt5677_mono_adc2_l_enum); |
| 1217 | 1204 | ||
| 1218 | /* Mono ADC Left source 1 */ /* MX-28 [13:12] */ | 1205 | /* Mono ADC Left Source 1 */ /* MX-28 [13:12] */ |
| 1219 | static const char * const rt5677_mono_adc1_l_src[] = { | 1206 | static const char * const rt5677_mono_adc1_l_src[] = { |
| 1220 | "DD MIX1L", "ADC1", "MONO DAC MIXL" | 1207 | "DD MIX1L", "ADC1", "MONO DAC MIXL" |
| 1221 | }; | 1208 | }; |
| @@ -1225,9 +1212,9 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1225 | RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src); | 1212 | RT5677_SEL_MONO_ADC_L1_SFT, rt5677_mono_adc1_l_src); |
| 1226 | 1213 | ||
| 1227 | static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux = | 1214 | static const struct snd_kcontrol_new rt5677_mono_adc1_l_mux = |
| 1228 | SOC_DAPM_ENUM("Mono ADC1 L source", rt5677_mono_adc1_l_enum); | 1215 | SOC_DAPM_ENUM("Mono ADC1 L Source", rt5677_mono_adc1_l_enum); |
| 1229 | 1216 | ||
| 1230 | /* Mono ADC Right source 2 */ /* MX-28 [3:2] */ | 1217 | /* Mono ADC Right Source 2 */ /* MX-28 [3:2] */ |
| 1231 | static const char * const rt5677_mono_adc2_r_src[] = { | 1218 | static const char * const rt5677_mono_adc2_r_src[] = { |
| 1232 | "DD MIX1R", "DMIC", "MONO DAC MIXR" | 1219 | "DD MIX1R", "DMIC", "MONO DAC MIXR" |
| 1233 | }; | 1220 | }; |
| @@ -1237,9 +1224,9 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1237 | RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src); | 1224 | RT5677_SEL_MONO_ADC_R2_SFT, rt5677_mono_adc2_r_src); |
| 1238 | 1225 | ||
| 1239 | static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux = | 1226 | static const struct snd_kcontrol_new rt5677_mono_adc2_r_mux = |
| 1240 | SOC_DAPM_ENUM("Mono ADC2 R source", rt5677_mono_adc2_r_enum); | 1227 | SOC_DAPM_ENUM("Mono ADC2 R Source", rt5677_mono_adc2_r_enum); |
| 1241 | 1228 | ||
| 1242 | /* Mono ADC Right source 1 */ /* MX-28 [5:4] */ | 1229 | /* Mono ADC Right Source 1 */ /* MX-28 [5:4] */ |
| 1243 | static const char * const rt5677_mono_adc1_r_src[] = { | 1230 | static const char * const rt5677_mono_adc1_r_src[] = { |
| 1244 | "DD MIX1R", "ADC2", "MONO DAC MIXR" | 1231 | "DD MIX1R", "ADC2", "MONO DAC MIXR" |
| 1245 | }; | 1232 | }; |
| @@ -1249,7 +1236,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1249 | RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src); | 1236 | RT5677_SEL_MONO_ADC_R1_SFT, rt5677_mono_adc1_r_src); |
| 1250 | 1237 | ||
| 1251 | static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux = | 1238 | static const struct snd_kcontrol_new rt5677_mono_adc1_r_mux = |
| 1252 | SOC_DAPM_ENUM("Mono ADC1 R source", rt5677_mono_adc1_r_enum); | 1239 | SOC_DAPM_ENUM("Mono ADC1 R Source", rt5677_mono_adc1_r_enum); |
| 1253 | 1240 | ||
| 1254 | /* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */ | 1241 | /* Stereo4 ADC Source 2 */ /* MX-24 [11:10] */ |
| 1255 | static const char * const rt5677_stereo4_adc2_src[] = { | 1242 | static const char * const rt5677_stereo4_adc2_src[] = { |
| @@ -1261,7 +1248,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1261 | RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src); | 1248 | RT5677_SEL_STO4_ADC2_SFT, rt5677_stereo4_adc2_src); |
| 1262 | 1249 | ||
| 1263 | static const struct snd_kcontrol_new rt5677_sto4_adc2_mux = | 1250 | static const struct snd_kcontrol_new rt5677_sto4_adc2_mux = |
| 1264 | SOC_DAPM_ENUM("Stereo4 ADC2 source", rt5677_stereo4_adc2_enum); | 1251 | SOC_DAPM_ENUM("Stereo4 ADC2 Source", rt5677_stereo4_adc2_enum); |
| 1265 | 1252 | ||
| 1266 | 1253 | ||
| 1267 | /* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */ | 1254 | /* Stereo4 ADC Source 1 */ /* MX-24 [13:12] */ |
| @@ -1274,7 +1261,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1274 | RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src); | 1261 | RT5677_SEL_STO4_ADC1_SFT, rt5677_stereo4_adc1_src); |
| 1275 | 1262 | ||
| 1276 | static const struct snd_kcontrol_new rt5677_sto4_adc1_mux = | 1263 | static const struct snd_kcontrol_new rt5677_sto4_adc1_mux = |
| 1277 | SOC_DAPM_ENUM("Stereo4 ADC1 source", rt5677_stereo4_adc1_enum); | 1264 | SOC_DAPM_ENUM("Stereo4 ADC1 Source", rt5677_stereo4_adc1_enum); |
| 1278 | 1265 | ||
| 1279 | /* InBound0/1 Source */ /* MX-A3 [14:12] */ | 1266 | /* InBound0/1 Source */ /* MX-A3 [14:12] */ |
| 1280 | static const char * const rt5677_inbound01_src[] = { | 1267 | static const char * const rt5677_inbound01_src[] = { |
| @@ -1416,7 +1403,7 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1416 | static const struct snd_kcontrol_new rt5677_dac3_mux = | 1403 | static const struct snd_kcontrol_new rt5677_dac3_mux = |
| 1417 | SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum); | 1404 | SOC_DAPM_ENUM("Analog DAC3 Source", rt5677_dac3_enum); |
| 1418 | 1405 | ||
| 1419 | /* PDM channel source */ /* MX-31 [13:12][9:8][5:4][1:0] */ | 1406 | /* PDM channel Source */ /* MX-31 [13:12][9:8][5:4][1:0] */ |
| 1420 | static const char * const rt5677_pdm_src[] = { | 1407 | static const char * const rt5677_pdm_src[] = { |
| 1421 | "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2" | 1408 | "STO1 DAC MIX", "MONO DAC MIX", "DD MIX1", "DD MIX2" |
| 1422 | }; | 1409 | }; |
| @@ -1426,28 +1413,28 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1426 | RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src); | 1413 | RT5677_SEL_PDM1_L_SFT, rt5677_pdm_src); |
| 1427 | 1414 | ||
| 1428 | static const struct snd_kcontrol_new rt5677_pdm1_l_mux = | 1415 | static const struct snd_kcontrol_new rt5677_pdm1_l_mux = |
| 1429 | SOC_DAPM_ENUM("PDM1 source", rt5677_pdm1_l_enum); | 1416 | SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_l_enum); |
| 1430 | 1417 | ||
| 1431 | static SOC_ENUM_SINGLE_DECL( | 1418 | static SOC_ENUM_SINGLE_DECL( |
| 1432 | rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL, | 1419 | rt5677_pdm2_l_enum, RT5677_PDM_OUT_CTRL, |
| 1433 | RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src); | 1420 | RT5677_SEL_PDM2_L_SFT, rt5677_pdm_src); |
| 1434 | 1421 | ||
| 1435 | static const struct snd_kcontrol_new rt5677_pdm2_l_mux = | 1422 | static const struct snd_kcontrol_new rt5677_pdm2_l_mux = |
| 1436 | SOC_DAPM_ENUM("PDM2 source", rt5677_pdm2_l_enum); | 1423 | SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_l_enum); |
| 1437 | 1424 | ||
| 1438 | static SOC_ENUM_SINGLE_DECL( | 1425 | static SOC_ENUM_SINGLE_DECL( |
| 1439 | rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL, | 1426 | rt5677_pdm1_r_enum, RT5677_PDM_OUT_CTRL, |
| 1440 | RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src); | 1427 | RT5677_SEL_PDM1_R_SFT, rt5677_pdm_src); |
| 1441 | 1428 | ||
| 1442 | static const struct snd_kcontrol_new rt5677_pdm1_r_mux = | 1429 | static const struct snd_kcontrol_new rt5677_pdm1_r_mux = |
| 1443 | SOC_DAPM_ENUM("PDM1 source", rt5677_pdm1_r_enum); | 1430 | SOC_DAPM_ENUM("PDM1 Source", rt5677_pdm1_r_enum); |
| 1444 | 1431 | ||
| 1445 | static SOC_ENUM_SINGLE_DECL( | 1432 | static SOC_ENUM_SINGLE_DECL( |
| 1446 | rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL, | 1433 | rt5677_pdm2_r_enum, RT5677_PDM_OUT_CTRL, |
| 1447 | RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src); | 1434 | RT5677_SEL_PDM2_R_SFT, rt5677_pdm_src); |
| 1448 | 1435 | ||
| 1449 | static const struct snd_kcontrol_new rt5677_pdm2_r_mux = | 1436 | static const struct snd_kcontrol_new rt5677_pdm2_r_mux = |
| 1450 | SOC_DAPM_ENUM("PDM2 source", rt5677_pdm2_r_enum); | 1437 | SOC_DAPM_ENUM("PDM2 Source", rt5677_pdm2_r_enum); |
| 1451 | 1438 | ||
| 1452 | /* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0]*/ | 1439 | /* TDM IF1/2 SLB ADC1 Data Selection */ /* MX-3C MX-41 [5:4] MX-08 [1:0]*/ |
| 1453 | static const char * const rt5677_if12_adc1_src[] = { | 1440 | static const char * const rt5677_if12_adc1_src[] = { |
| @@ -1459,21 +1446,21 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1459 | RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src); | 1446 | RT5677_IF1_ADC1_SFT, rt5677_if12_adc1_src); |
| 1460 | 1447 | ||
| 1461 | static const struct snd_kcontrol_new rt5677_if1_adc1_mux = | 1448 | static const struct snd_kcontrol_new rt5677_if1_adc1_mux = |
| 1462 | SOC_DAPM_ENUM("IF1 ADC1 source", rt5677_if1_adc1_enum); | 1449 | SOC_DAPM_ENUM("IF1 ADC1 Source", rt5677_if1_adc1_enum); |
| 1463 | 1450 | ||
| 1464 | static SOC_ENUM_SINGLE_DECL( | 1451 | static SOC_ENUM_SINGLE_DECL( |
| 1465 | rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2, | 1452 | rt5677_if2_adc1_enum, RT5677_TDM2_CTRL2, |
| 1466 | RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src); | 1453 | RT5677_IF2_ADC1_SFT, rt5677_if12_adc1_src); |
| 1467 | 1454 | ||
| 1468 | static const struct snd_kcontrol_new rt5677_if2_adc1_mux = | 1455 | static const struct snd_kcontrol_new rt5677_if2_adc1_mux = |
| 1469 | SOC_DAPM_ENUM("IF2 ADC1 source", rt5677_if2_adc1_enum); | 1456 | SOC_DAPM_ENUM("IF2 ADC1 Source", rt5677_if2_adc1_enum); |
| 1470 | 1457 | ||
| 1471 | static SOC_ENUM_SINGLE_DECL( | 1458 | static SOC_ENUM_SINGLE_DECL( |
| 1472 | rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX, | 1459 | rt5677_slb_adc1_enum, RT5677_SLIMBUS_RX, |
| 1473 | RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src); | 1460 | RT5677_SLB_ADC1_SFT, rt5677_if12_adc1_src); |
| 1474 | 1461 | ||
| 1475 | static const struct snd_kcontrol_new rt5677_slb_adc1_mux = | 1462 | static const struct snd_kcontrol_new rt5677_slb_adc1_mux = |
| 1476 | SOC_DAPM_ENUM("SLB ADC1 source", rt5677_slb_adc1_enum); | 1463 | SOC_DAPM_ENUM("SLB ADC1 Source", rt5677_slb_adc1_enum); |
| 1477 | 1464 | ||
| 1478 | /* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */ | 1465 | /* TDM IF1/2 SLB ADC2 Data Selection */ /* MX-3C MX-41 [7:6] MX-08 [3:2] */ |
| 1479 | static const char * const rt5677_if12_adc2_src[] = { | 1466 | static const char * const rt5677_if12_adc2_src[] = { |
| @@ -1485,21 +1472,21 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1485 | RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src); | 1472 | RT5677_IF1_ADC2_SFT, rt5677_if12_adc2_src); |
| 1486 | 1473 | ||
| 1487 | static const struct snd_kcontrol_new rt5677_if1_adc2_mux = | 1474 | static const struct snd_kcontrol_new rt5677_if1_adc2_mux = |
| 1488 | SOC_DAPM_ENUM("IF1 ADC2 source", rt5677_if1_adc2_enum); | 1475 | SOC_DAPM_ENUM("IF1 ADC2 Source", rt5677_if1_adc2_enum); |
| 1489 | 1476 | ||
| 1490 | static SOC_ENUM_SINGLE_DECL( | 1477 | static SOC_ENUM_SINGLE_DECL( |
| 1491 | rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2, | 1478 | rt5677_if2_adc2_enum, RT5677_TDM2_CTRL2, |
| 1492 | RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src); | 1479 | RT5677_IF2_ADC2_SFT, rt5677_if12_adc2_src); |
| 1493 | 1480 | ||
| 1494 | static const struct snd_kcontrol_new rt5677_if2_adc2_mux = | 1481 | static const struct snd_kcontrol_new rt5677_if2_adc2_mux = |
| 1495 | SOC_DAPM_ENUM("IF2 ADC2 source", rt5677_if2_adc2_enum); | 1482 | SOC_DAPM_ENUM("IF2 ADC2 Source", rt5677_if2_adc2_enum); |
| 1496 | 1483 | ||
| 1497 | static SOC_ENUM_SINGLE_DECL( | 1484 | static SOC_ENUM_SINGLE_DECL( |
| 1498 | rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX, | 1485 | rt5677_slb_adc2_enum, RT5677_SLIMBUS_RX, |
| 1499 | RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src); | 1486 | RT5677_SLB_ADC2_SFT, rt5677_if12_adc2_src); |
| 1500 | 1487 | ||
| 1501 | static const struct snd_kcontrol_new rt5677_slb_adc2_mux = | 1488 | static const struct snd_kcontrol_new rt5677_slb_adc2_mux = |
| 1502 | SOC_DAPM_ENUM("SLB ADC2 source", rt5677_slb_adc2_enum); | 1489 | SOC_DAPM_ENUM("SLB ADC2 Source", rt5677_slb_adc2_enum); |
| 1503 | 1490 | ||
| 1504 | /* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */ | 1491 | /* TDM IF1/2 SLB ADC3 Data Selection */ /* MX-3C MX-41 [9:8] MX-08 [5:4] */ |
| 1505 | static const char * const rt5677_if12_adc3_src[] = { | 1492 | static const char * const rt5677_if12_adc3_src[] = { |
| @@ -1511,21 +1498,21 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1511 | RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src); | 1498 | RT5677_IF1_ADC3_SFT, rt5677_if12_adc3_src); |
| 1512 | 1499 | ||
| 1513 | static const struct snd_kcontrol_new rt5677_if1_adc3_mux = | 1500 | static const struct snd_kcontrol_new rt5677_if1_adc3_mux = |
| 1514 | SOC_DAPM_ENUM("IF1 ADC3 source", rt5677_if1_adc3_enum); | 1501 | SOC_DAPM_ENUM("IF1 ADC3 Source", rt5677_if1_adc3_enum); |
| 1515 | 1502 | ||
| 1516 | static SOC_ENUM_SINGLE_DECL( | 1503 | static SOC_ENUM_SINGLE_DECL( |
| 1517 | rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2, | 1504 | rt5677_if2_adc3_enum, RT5677_TDM2_CTRL2, |
| 1518 | RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src); | 1505 | RT5677_IF2_ADC3_SFT, rt5677_if12_adc3_src); |
| 1519 | 1506 | ||
| 1520 | static const struct snd_kcontrol_new rt5677_if2_adc3_mux = | 1507 | static const struct snd_kcontrol_new rt5677_if2_adc3_mux = |
| 1521 | SOC_DAPM_ENUM("IF2 ADC3 source", rt5677_if2_adc3_enum); | 1508 | SOC_DAPM_ENUM("IF2 ADC3 Source", rt5677_if2_adc3_enum); |
| 1522 | 1509 | ||
| 1523 | static SOC_ENUM_SINGLE_DECL( | 1510 | static SOC_ENUM_SINGLE_DECL( |
| 1524 | rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX, | 1511 | rt5677_slb_adc3_enum, RT5677_SLIMBUS_RX, |
| 1525 | RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src); | 1512 | RT5677_SLB_ADC3_SFT, rt5677_if12_adc3_src); |
| 1526 | 1513 | ||
| 1527 | static const struct snd_kcontrol_new rt5677_slb_adc3_mux = | 1514 | static const struct snd_kcontrol_new rt5677_slb_adc3_mux = |
| 1528 | SOC_DAPM_ENUM("SLB ADC3 source", rt5677_slb_adc3_enum); | 1515 | SOC_DAPM_ENUM("SLB ADC3 Source", rt5677_slb_adc3_enum); |
| 1529 | 1516 | ||
| 1530 | /* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */ | 1517 | /* TDM IF1/2 SLB ADC4 Data Selection */ /* MX-3C MX-41 [11:10] MX-08 [7:6] */ |
| 1531 | static const char * const rt5677_if12_adc4_src[] = { | 1518 | static const char * const rt5677_if12_adc4_src[] = { |
| @@ -1537,21 +1524,21 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1537 | RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src); | 1524 | RT5677_IF1_ADC4_SFT, rt5677_if12_adc4_src); |
| 1538 | 1525 | ||
| 1539 | static const struct snd_kcontrol_new rt5677_if1_adc4_mux = | 1526 | static const struct snd_kcontrol_new rt5677_if1_adc4_mux = |
| 1540 | SOC_DAPM_ENUM("IF1 ADC4 source", rt5677_if1_adc4_enum); | 1527 | SOC_DAPM_ENUM("IF1 ADC4 Source", rt5677_if1_adc4_enum); |
| 1541 | 1528 | ||
| 1542 | static SOC_ENUM_SINGLE_DECL( | 1529 | static SOC_ENUM_SINGLE_DECL( |
| 1543 | rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2, | 1530 | rt5677_if2_adc4_enum, RT5677_TDM2_CTRL2, |
| 1544 | RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src); | 1531 | RT5677_IF2_ADC4_SFT, rt5677_if12_adc4_src); |
| 1545 | 1532 | ||
| 1546 | static const struct snd_kcontrol_new rt5677_if2_adc4_mux = | 1533 | static const struct snd_kcontrol_new rt5677_if2_adc4_mux = |
| 1547 | SOC_DAPM_ENUM("IF2 ADC4 source", rt5677_if2_adc4_enum); | 1534 | SOC_DAPM_ENUM("IF2 ADC4 Source", rt5677_if2_adc4_enum); |
| 1548 | 1535 | ||
| 1549 | static SOC_ENUM_SINGLE_DECL( | 1536 | static SOC_ENUM_SINGLE_DECL( |
| 1550 | rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX, | 1537 | rt5677_slb_adc4_enum, RT5677_SLIMBUS_RX, |
| 1551 | RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src); | 1538 | RT5677_SLB_ADC4_SFT, rt5677_if12_adc4_src); |
| 1552 | 1539 | ||
| 1553 | static const struct snd_kcontrol_new rt5677_slb_adc4_mux = | 1540 | static const struct snd_kcontrol_new rt5677_slb_adc4_mux = |
| 1554 | SOC_DAPM_ENUM("SLB ADC4 source", rt5677_slb_adc4_enum); | 1541 | SOC_DAPM_ENUM("SLB ADC4 Source", rt5677_slb_adc4_enum); |
| 1555 | 1542 | ||
| 1556 | /* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4]*/ | 1543 | /* Interface3/4 ADC Data Input */ /* MX-2F [3:0] MX-30 [7:4]*/ |
| 1557 | static const char * const rt5677_if34_adc_src[] = { | 1544 | static const char * const rt5677_if34_adc_src[] = { |
| @@ -1564,14 +1551,14 @@ static SOC_ENUM_SINGLE_DECL( | |||
| 1564 | RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src); | 1551 | RT5677_IF3_ADC_IN_SFT, rt5677_if34_adc_src); |
| 1565 | 1552 | ||
| 1566 | static const struct snd_kcontrol_new rt5677_if3_adc_mux = | 1553 | static const struct snd_kcontrol_new rt5677_if3_adc_mux = |
| 1567 | SOC_DAPM_ENUM("IF3 ADC source", rt5677_if3_adc_enum); | 1554 | SOC_DAPM_ENUM("IF3 ADC Source", rt5677_if3_adc_enum); |
| 1568 | 1555 | ||
| 1569 | static SOC_ENUM_SINGLE_DECL( | 1556 | static SOC_ENUM_SINGLE_DECL( |
| 1570 | rt5677_if4_adc_enum, RT5677_IF4_DATA, | 1557 | rt5677_if4_adc_enum, RT5677_IF4_DATA, |
| 1571 | RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src); | 1558 | RT5677_IF4_ADC_IN_SFT, rt5677_if34_adc_src); |
| 1572 | 1559 | ||
| 1573 | static const struct snd_kcontrol_new rt5677_if4_adc_mux = | 1560 | static const struct snd_kcontrol_new rt5677_if4_adc_mux = |
| 1574 | SOC_DAPM_ENUM("IF4 ADC source", rt5677_if4_adc_enum); | 1561 | SOC_DAPM_ENUM("IF4 ADC Source", rt5677_if4_adc_enum); |
| 1575 | 1562 | ||
| 1576 | static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, | 1563 | static int rt5677_bst1_event(struct snd_soc_dapm_widget *w, |
| 1577 | struct snd_kcontrol *kcontrol, int event) | 1564 | struct snd_kcontrol *kcontrol, int event) |
| @@ -1670,6 +1657,13 @@ static int rt5677_set_micbias1_event(struct snd_soc_dapm_widget *w, | |||
| 1670 | RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 | | 1657 | RT5677_PWR_CLK_MB, RT5677_PWR_CLK_MB1 | |
| 1671 | RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB); | 1658 | RT5677_PWR_PP_MB1 | RT5677_PWR_CLK_MB); |
| 1672 | break; | 1659 | break; |
| 1660 | |||
| 1661 | case SND_SOC_DAPM_PRE_PMD: | ||
| 1662 | regmap_update_bits(rt5677->regmap, RT5677_PWR_ANLG2, | ||
| 1663 | RT5677_PWR_CLK_MB1 | RT5677_PWR_PP_MB1 | | ||
| 1664 | RT5677_PWR_CLK_MB, 0); | ||
| 1665 | break; | ||
| 1666 | |||
| 1673 | default: | 1667 | default: |
| 1674 | return 0; | 1668 | return 0; |
| 1675 | } | 1669 | } |
| @@ -1685,8 +1679,9 @@ static const struct snd_soc_dapm_widget rt5677_dapm_widgets[] = { | |||
| 1685 | 1679 | ||
| 1686 | /* Input Side */ | 1680 | /* Input Side */ |
| 1687 | /* micbias */ | 1681 | /* micbias */ |
| 1688 | SND_SOC_DAPM_SUPPLY("micbias1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT, | 1682 | SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5677_PWR_ANLG2, RT5677_PWR_MB1_BIT, |
| 1689 | 0, rt5677_set_micbias1_event, SND_SOC_DAPM_POST_PMU), | 1683 | 0, rt5677_set_micbias1_event, SND_SOC_DAPM_PRE_PMD | |
| 1684 | SND_SOC_DAPM_POST_PMU), | ||
| 1690 | 1685 | ||
| 1691 | /* Input Lines */ | 1686 | /* Input Lines */ |
| 1692 | SND_SOC_DAPM_INPUT("DMIC L1"), | 1687 | SND_SOC_DAPM_INPUT("DMIC L1"), |
| @@ -2798,21 +2793,6 @@ static const struct snd_soc_dapm_route rt5677_dapm_routes[] = { | |||
| 2798 | { "PDM2R", NULL, "PDM2 R Mux" }, | 2793 | { "PDM2R", NULL, "PDM2 R Mux" }, |
| 2799 | }; | 2794 | }; |
| 2800 | 2795 | ||
| 2801 | static int get_clk_info(int sclk, int rate) | ||
| 2802 | { | ||
| 2803 | int i, pd[] = {1, 2, 3, 4, 6, 8, 12, 16}; | ||
| 2804 | |||
| 2805 | if (sclk <= 0 || rate <= 0) | ||
| 2806 | return -EINVAL; | ||
| 2807 | |||
| 2808 | rate = rate << 8; | ||
| 2809 | for (i = 0; i < ARRAY_SIZE(pd); i++) | ||
| 2810 | if (sclk == rate * pd[i]) | ||
| 2811 | return i; | ||
| 2812 | |||
| 2813 | return -EINVAL; | ||
| 2814 | } | ||
| 2815 | |||
| 2816 | static int rt5677_hw_params(struct snd_pcm_substream *substream, | 2796 | static int rt5677_hw_params(struct snd_pcm_substream *substream, |
| 2817 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | 2797 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) |
| 2818 | { | 2798 | { |
| @@ -2822,7 +2802,7 @@ static int rt5677_hw_params(struct snd_pcm_substream *substream, | |||
| 2822 | int pre_div, bclk_ms, frame_size; | 2802 | int pre_div, bclk_ms, frame_size; |
| 2823 | 2803 | ||
| 2824 | rt5677->lrck[dai->id] = params_rate(params); | 2804 | rt5677->lrck[dai->id] = params_rate(params); |
| 2825 | pre_div = get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]); | 2805 | pre_div = rl6231_get_clk_info(rt5677->sysclk, rt5677->lrck[dai->id]); |
| 2826 | if (pre_div < 0) { | 2806 | if (pre_div < 0) { |
| 2827 | dev_err(codec->dev, "Unsupported clock setting\n"); | 2807 | dev_err(codec->dev, "Unsupported clock setting\n"); |
| 2828 | return -EINVAL; | 2808 | return -EINVAL; |
| @@ -3016,62 +2996,12 @@ static int rt5677_set_dai_sysclk(struct snd_soc_dai *dai, | |||
| 3016 | * Returns 0 for success or negative error code. | 2996 | * Returns 0 for success or negative error code. |
| 3017 | */ | 2997 | */ |
| 3018 | static int rt5677_pll_calc(const unsigned int freq_in, | 2998 | static int rt5677_pll_calc(const unsigned int freq_in, |
| 3019 | const unsigned int freq_out, struct rt5677_pll_code *pll_code) | 2999 | const unsigned int freq_out, struct rl6231_pll_code *pll_code) |
| 3020 | { | 3000 | { |
| 3021 | int max_n = RT5677_PLL_N_MAX, max_m = RT5677_PLL_M_MAX; | 3001 | if (RT5677_PLL_INP_MIN > freq_in) |
| 3022 | int k, red, n_t, pll_out, in_t; | ||
| 3023 | int n = 0, m = 0, m_t = 0; | ||
| 3024 | int out_t, red_t = abs(freq_out - freq_in); | ||
| 3025 | bool m_bp = false, k_bp = false; | ||
| 3026 | |||
| 3027 | if (RT5677_PLL_INP_MAX < freq_in || RT5677_PLL_INP_MIN > freq_in) | ||
| 3028 | return -EINVAL; | 3002 | return -EINVAL; |
| 3029 | 3003 | ||
| 3030 | k = 100000000 / freq_out - 2; | 3004 | return rl6231_pll_calc(freq_in, freq_out, pll_code); |
| 3031 | if (k > RT5677_PLL_K_MAX) | ||
| 3032 | k = RT5677_PLL_K_MAX; | ||
| 3033 | for (n_t = 0; n_t <= max_n; n_t++) { | ||
| 3034 | in_t = freq_in / (k + 2); | ||
| 3035 | pll_out = freq_out / (n_t + 2); | ||
| 3036 | if (in_t < 0) | ||
| 3037 | continue; | ||
| 3038 | if (in_t == pll_out) { | ||
| 3039 | m_bp = true; | ||
| 3040 | n = n_t; | ||
| 3041 | goto code_find; | ||
| 3042 | } | ||
| 3043 | red = abs(in_t - pll_out); | ||
| 3044 | if (red < red_t) { | ||
| 3045 | m_bp = true; | ||
| 3046 | n = n_t; | ||
| 3047 | m = m_t; | ||
| 3048 | if (red == 0) | ||
| 3049 | goto code_find; | ||
| 3050 | red_t = red; | ||
| 3051 | } | ||
| 3052 | for (m_t = 0; m_t <= max_m; m_t++) { | ||
| 3053 | out_t = in_t / (m_t + 2); | ||
| 3054 | red = abs(out_t - pll_out); | ||
| 3055 | if (red < red_t) { | ||
| 3056 | m_bp = false; | ||
| 3057 | n = n_t; | ||
| 3058 | m = m_t; | ||
| 3059 | if (red == 0) | ||
| 3060 | goto code_find; | ||
| 3061 | red_t = red; | ||
| 3062 | } | ||
| 3063 | } | ||
| 3064 | } | ||
| 3065 | pr_debug("Only get approximation about PLL\n"); | ||
| 3066 | |||
| 3067 | code_find: | ||
| 3068 | |||
| 3069 | pll_code->m_bp = m_bp; | ||
| 3070 | pll_code->k_bp = k_bp; | ||
| 3071 | pll_code->m_code = m; | ||
| 3072 | pll_code->n_code = n; | ||
| 3073 | pll_code->k_code = k; | ||
| 3074 | return 0; | ||
| 3075 | } | 3005 | } |
| 3076 | 3006 | ||
| 3077 | static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | 3007 | static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, |
| @@ -3079,7 +3009,7 @@ static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | |||
| 3079 | { | 3009 | { |
| 3080 | struct snd_soc_codec *codec = dai->codec; | 3010 | struct snd_soc_codec *codec = dai->codec; |
| 3081 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); | 3011 | struct rt5677_priv *rt5677 = snd_soc_codec_get_drvdata(codec); |
| 3082 | struct rt5677_pll_code pll_code; | 3012 | struct rl6231_pll_code pll_code; |
| 3083 | int ret; | 3013 | int ret; |
| 3084 | 3014 | ||
| 3085 | if (source == rt5677->pll_src && freq_in == rt5677->pll_in && | 3015 | if (source == rt5677->pll_src && freq_in == rt5677->pll_in && |
| @@ -3137,15 +3067,12 @@ static int rt5677_set_dai_pll(struct snd_soc_dai *dai, int pll_id, int source, | |||
| 3137 | return ret; | 3067 | return ret; |
| 3138 | } | 3068 | } |
| 3139 | 3069 | ||
| 3140 | dev_dbg(codec->dev, "m_bypass=%d k_bypass=%d m=%d n=%d k=%d\n", | 3070 | dev_dbg(codec->dev, "m_bypass=%d m=%d n=%d k=%d\n", |
| 3141 | pll_code.m_bp, pll_code.k_bp, | 3071 | pll_code.m_bp, (pll_code.m_bp ? 0 : pll_code.m_code), |
| 3142 | (pll_code.m_bp ? 0 : pll_code.m_code), pll_code.n_code, | 3072 | pll_code.n_code, pll_code.k_code); |
| 3143 | (pll_code.k_bp ? 0 : pll_code.k_code)); | ||
| 3144 | 3073 | ||
| 3145 | regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1, | 3074 | regmap_write(rt5677->regmap, RT5677_PLL1_CTRL1, |
| 3146 | pll_code.n_code << RT5677_PLL_N_SFT | | 3075 | pll_code.n_code << RT5677_PLL_N_SFT | pll_code.k_code); |
| 3147 | pll_code.k_bp << RT5677_PLL_K_BP_SFT | | ||
| 3148 | (pll_code.k_bp ? 0 : pll_code.k_code)); | ||
| 3149 | regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2, | 3076 | regmap_write(rt5677->regmap, RT5677_PLL1_CTRL2, |
| 3150 | (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT | | 3077 | (pll_code.m_bp ? 0 : pll_code.m_code) << RT5677_PLL_M_SFT | |
| 3151 | pll_code.m_bp << RT5677_PLL_M_BP_SFT); | 3078 | pll_code.m_bp << RT5677_PLL_M_BP_SFT); |
| @@ -3197,7 +3124,7 @@ static int rt5677_set_bias_level(struct snd_soc_codec *codec, | |||
| 3197 | regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0); | 3124 | regmap_update_bits(rt5677->regmap, RT5677_DIG_MISC, 0x1, 0x0); |
| 3198 | regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000); | 3125 | regmap_write(rt5677->regmap, RT5677_PWR_DIG1, 0x0000); |
| 3199 | regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000); | 3126 | regmap_write(rt5677->regmap, RT5677_PWR_DIG2, 0x0000); |
| 3200 | regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0000); | 3127 | regmap_write(rt5677->regmap, RT5677_PWR_ANLG1, 0x0022); |
| 3201 | regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000); | 3128 | regmap_write(rt5677->regmap, RT5677_PWR_ANLG2, 0x0000); |
| 3202 | regmap_update_bits(rt5677->regmap, | 3129 | regmap_update_bits(rt5677->regmap, |
| 3203 | RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000); | 3130 | RT5677_PR_BASE + RT5677_BIAS_CUR4, 0x0f00, 0x0000); |
| @@ -3454,14 +3381,8 @@ static int rt5677_i2c_probe(struct i2c_client *i2c, | |||
| 3454 | regmap_update_bits(rt5677->regmap, RT5677_IN1, | 3381 | regmap_update_bits(rt5677->regmap, RT5677_IN1, |
| 3455 | RT5677_IN_DF2, RT5677_IN_DF2); | 3382 | RT5677_IN_DF2, RT5677_IN_DF2); |
| 3456 | 3383 | ||
| 3457 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677, | 3384 | return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_rt5677, |
| 3458 | rt5677_dai, ARRAY_SIZE(rt5677_dai)); | 3385 | rt5677_dai, ARRAY_SIZE(rt5677_dai)); |
| 3459 | if (ret < 0) | ||
| 3460 | goto err; | ||
| 3461 | |||
| 3462 | return 0; | ||
| 3463 | err: | ||
| 3464 | return ret; | ||
| 3465 | } | 3386 | } |
| 3466 | 3387 | ||
| 3467 | static int rt5677_i2c_remove(struct i2c_client *i2c) | 3388 | static int rt5677_i2c_remove(struct i2c_client *i2c) |
| @@ -3480,18 +3401,7 @@ static struct i2c_driver rt5677_i2c_driver = { | |||
| 3480 | .remove = rt5677_i2c_remove, | 3401 | .remove = rt5677_i2c_remove, |
| 3481 | .id_table = rt5677_i2c_id, | 3402 | .id_table = rt5677_i2c_id, |
| 3482 | }; | 3403 | }; |
| 3483 | 3404 | module_i2c_driver(rt5677_i2c_driver); | |
| 3484 | static int __init rt5677_modinit(void) | ||
| 3485 | { | ||
| 3486 | return i2c_add_driver(&rt5677_i2c_driver); | ||
| 3487 | } | ||
| 3488 | module_init(rt5677_modinit); | ||
| 3489 | |||
| 3490 | static void __exit rt5677_modexit(void) | ||
| 3491 | { | ||
| 3492 | i2c_del_driver(&rt5677_i2c_driver); | ||
| 3493 | } | ||
| 3494 | module_exit(rt5677_modexit); | ||
| 3495 | 3405 | ||
| 3496 | MODULE_DESCRIPTION("ASoC RT5677 driver"); | 3406 | MODULE_DESCRIPTION("ASoC RT5677 driver"); |
| 3497 | MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); | 3407 | MODULE_AUTHOR("Oder Chiou <oder_chiou@realtek.com>"); |
diff --git a/sound/soc/codecs/rt5677.h b/sound/soc/codecs/rt5677.h index af4e9c797408..863393e62096 100644 --- a/sound/soc/codecs/rt5677.h +++ b/sound/soc/codecs/rt5677.h | |||
| @@ -1393,13 +1393,6 @@ | |||
| 1393 | #define RT5677_DSP_IB_9_L (0x1 << 1) | 1393 | #define RT5677_DSP_IB_9_L (0x1 << 1) |
| 1394 | #define RT5677_DSP_IB_9_L_SFT 1 | 1394 | #define RT5677_DSP_IB_9_L_SFT 1 |
| 1395 | 1395 | ||
| 1396 | /* Debug String Length */ | ||
| 1397 | #define RT5677_REG_DISP_LEN 23 | ||
| 1398 | |||
| 1399 | #define RT5677_NO_JACK BIT(0) | ||
| 1400 | #define RT5677_HEADSET_DET BIT(1) | ||
| 1401 | #define RT5677_HEADPHO_DET BIT(2) | ||
| 1402 | |||
| 1403 | /* System Clock Source */ | 1396 | /* System Clock Source */ |
| 1404 | enum { | 1397 | enum { |
| 1405 | RT5677_SCLK_S_MCLK, | 1398 | RT5677_SCLK_S_MCLK, |
| @@ -1425,14 +1418,6 @@ enum { | |||
| 1425 | RT5677_AIFS, | 1418 | RT5677_AIFS, |
| 1426 | }; | 1419 | }; |
| 1427 | 1420 | ||
| 1428 | struct rt5677_pll_code { | ||
| 1429 | bool m_bp; /* Indicates bypass m code or not. */ | ||
| 1430 | bool k_bp; /* Indicates bypass k code or not. */ | ||
| 1431 | int m_code; | ||
| 1432 | int n_code; | ||
| 1433 | int k_code; | ||
| 1434 | }; | ||
| 1435 | |||
| 1436 | struct rt5677_priv { | 1421 | struct rt5677_priv { |
| 1437 | struct snd_soc_codec *codec; | 1422 | struct snd_soc_codec *codec; |
| 1438 | struct rt5677_platform_data pdata; | 1423 | struct rt5677_platform_data pdata; |
diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 3d39f0b5b4a8..e997d271728d 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c | |||
| @@ -724,25 +724,25 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 724 | return ret; | 724 | return ret; |
| 725 | 725 | ||
| 726 | /* set i2s data format */ | 726 | /* set i2s data format */ |
| 727 | switch (params_format(params)) { | 727 | switch (params_width(params)) { |
| 728 | case SNDRV_PCM_FORMAT_S16_LE: | 728 | case 16: |
| 729 | if (sgtl5000->fmt == SND_SOC_DAIFMT_RIGHT_J) | 729 | if (sgtl5000->fmt == SND_SOC_DAIFMT_RIGHT_J) |
| 730 | return -EINVAL; | 730 | return -EINVAL; |
| 731 | i2s_ctl |= SGTL5000_I2S_DLEN_16 << SGTL5000_I2S_DLEN_SHIFT; | 731 | i2s_ctl |= SGTL5000_I2S_DLEN_16 << SGTL5000_I2S_DLEN_SHIFT; |
| 732 | i2s_ctl |= SGTL5000_I2S_SCLKFREQ_32FS << | 732 | i2s_ctl |= SGTL5000_I2S_SCLKFREQ_32FS << |
| 733 | SGTL5000_I2S_SCLKFREQ_SHIFT; | 733 | SGTL5000_I2S_SCLKFREQ_SHIFT; |
| 734 | break; | 734 | break; |
| 735 | case SNDRV_PCM_FORMAT_S20_3LE: | 735 | case 20: |
| 736 | i2s_ctl |= SGTL5000_I2S_DLEN_20 << SGTL5000_I2S_DLEN_SHIFT; | 736 | i2s_ctl |= SGTL5000_I2S_DLEN_20 << SGTL5000_I2S_DLEN_SHIFT; |
| 737 | i2s_ctl |= SGTL5000_I2S_SCLKFREQ_64FS << | 737 | i2s_ctl |= SGTL5000_I2S_SCLKFREQ_64FS << |
| 738 | SGTL5000_I2S_SCLKFREQ_SHIFT; | 738 | SGTL5000_I2S_SCLKFREQ_SHIFT; |
| 739 | break; | 739 | break; |
| 740 | case SNDRV_PCM_FORMAT_S24_LE: | 740 | case 24: |
| 741 | i2s_ctl |= SGTL5000_I2S_DLEN_24 << SGTL5000_I2S_DLEN_SHIFT; | 741 | i2s_ctl |= SGTL5000_I2S_DLEN_24 << SGTL5000_I2S_DLEN_SHIFT; |
| 742 | i2s_ctl |= SGTL5000_I2S_SCLKFREQ_64FS << | 742 | i2s_ctl |= SGTL5000_I2S_SCLKFREQ_64FS << |
| 743 | SGTL5000_I2S_SCLKFREQ_SHIFT; | 743 | SGTL5000_I2S_SCLKFREQ_SHIFT; |
| 744 | break; | 744 | break; |
| 745 | case SNDRV_PCM_FORMAT_S32_LE: | 745 | case 32: |
| 746 | if (sgtl5000->fmt == SND_SOC_DAIFMT_RIGHT_J) | 746 | if (sgtl5000->fmt == SND_SOC_DAIFMT_RIGHT_J) |
| 747 | return -EINVAL; | 747 | return -EINVAL; |
| 748 | i2s_ctl |= SGTL5000_I2S_DLEN_32 << SGTL5000_I2S_DLEN_SHIFT; | 748 | i2s_ctl |= SGTL5000_I2S_DLEN_32 << SGTL5000_I2S_DLEN_SHIFT; |
| @@ -843,10 +843,8 @@ static int ldo_regulator_register(struct snd_soc_codec *codec, | |||
| 843 | 843 | ||
| 844 | ldo = kzalloc(sizeof(struct ldo_regulator), GFP_KERNEL); | 844 | ldo = kzalloc(sizeof(struct ldo_regulator), GFP_KERNEL); |
| 845 | 845 | ||
| 846 | if (!ldo) { | 846 | if (!ldo) |
| 847 | dev_err(codec->dev, "failed to allocate ldo_regulator\n"); | ||
| 848 | return -ENOMEM; | 847 | return -ENOMEM; |
| 849 | } | ||
| 850 | 848 | ||
| 851 | ldo->desc.name = kstrdup(dev_name(codec->dev), GFP_KERNEL); | 849 | ldo->desc.name = kstrdup(dev_name(codec->dev), GFP_KERNEL); |
| 852 | if (!ldo->desc.name) { | 850 | if (!ldo->desc.name) { |
| @@ -1277,7 +1275,7 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) | |||
| 1277 | return ret; | 1275 | return ret; |
| 1278 | } | 1276 | } |
| 1279 | 1277 | ||
| 1280 | ret = devm_regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), | 1278 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(sgtl5000->supplies), |
| 1281 | sgtl5000->supplies); | 1279 | sgtl5000->supplies); |
| 1282 | if (ret) | 1280 | if (ret) |
| 1283 | goto err_ldo_remove; | 1281 | goto err_ldo_remove; |
| @@ -1285,13 +1283,16 @@ static int sgtl5000_enable_regulators(struct snd_soc_codec *codec) | |||
| 1285 | ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), | 1283 | ret = regulator_bulk_enable(ARRAY_SIZE(sgtl5000->supplies), |
| 1286 | sgtl5000->supplies); | 1284 | sgtl5000->supplies); |
| 1287 | if (ret) | 1285 | if (ret) |
| 1288 | goto err_ldo_remove; | 1286 | goto err_regulator_free; |
| 1289 | 1287 | ||
| 1290 | /* wait for all power rails bring up */ | 1288 | /* wait for all power rails bring up */ |
| 1291 | udelay(10); | 1289 | udelay(10); |
| 1292 | 1290 | ||
| 1293 | return 0; | 1291 | return 0; |
| 1294 | 1292 | ||
| 1293 | err_regulator_free: | ||
| 1294 | regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), | ||
| 1295 | sgtl5000->supplies); | ||
| 1295 | err_ldo_remove: | 1296 | err_ldo_remove: |
| 1296 | if (!external_vddd) | 1297 | if (!external_vddd) |
| 1297 | ldo_regulator_remove(codec); | 1298 | ldo_regulator_remove(codec); |
| @@ -1361,6 +1362,8 @@ static int sgtl5000_probe(struct snd_soc_codec *codec) | |||
| 1361 | err: | 1362 | err: |
| 1362 | regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), | 1363 | regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), |
| 1363 | sgtl5000->supplies); | 1364 | sgtl5000->supplies); |
| 1365 | regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), | ||
| 1366 | sgtl5000->supplies); | ||
| 1364 | ldo_regulator_remove(codec); | 1367 | ldo_regulator_remove(codec); |
| 1365 | 1368 | ||
| 1366 | return ret; | 1369 | return ret; |
| @@ -1374,6 +1377,8 @@ static int sgtl5000_remove(struct snd_soc_codec *codec) | |||
| 1374 | 1377 | ||
| 1375 | regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), | 1378 | regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies), |
| 1376 | sgtl5000->supplies); | 1379 | sgtl5000->supplies); |
| 1380 | regulator_bulk_free(ARRAY_SIZE(sgtl5000->supplies), | ||
| 1381 | sgtl5000->supplies); | ||
| 1377 | ldo_regulator_remove(codec); | 1382 | ldo_regulator_remove(codec); |
| 1378 | 1383 | ||
| 1379 | return 0; | 1384 | return 0; |
diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index f26befb0c297..cdf882fa7716 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c | |||
| @@ -167,17 +167,17 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, | |||
| 167 | return -EINVAL; | 167 | return -EINVAL; |
| 168 | } | 168 | } |
| 169 | 169 | ||
| 170 | switch (params_format(params)) { | 170 | switch (params_width(params)) { |
| 171 | case SNDRV_PCM_FORMAT_S8: | 171 | case 8: |
| 172 | width = SI476X_PCM_FORMAT_S8; | 172 | width = SI476X_PCM_FORMAT_S8; |
| 173 | break; | 173 | break; |
| 174 | case SNDRV_PCM_FORMAT_S16_LE: | 174 | case 16: |
| 175 | width = SI476X_PCM_FORMAT_S16_LE; | 175 | width = SI476X_PCM_FORMAT_S16_LE; |
| 176 | break; | 176 | break; |
| 177 | case SNDRV_PCM_FORMAT_S20_3LE: | 177 | case 20: |
| 178 | width = SI476X_PCM_FORMAT_S20_3LE; | 178 | width = SI476X_PCM_FORMAT_S20_3LE; |
| 179 | break; | 179 | break; |
| 180 | case SNDRV_PCM_FORMAT_S24_LE: | 180 | case 24: |
| 181 | width = SI476X_PCM_FORMAT_S24_LE; | 181 | width = SI476X_PCM_FORMAT_S24_LE; |
| 182 | break; | 182 | break; |
| 183 | default: | 183 | default: |
diff --git a/sound/soc/codecs/sirf-audio-codec.c b/sound/soc/codecs/sirf-audio-codec.c index d90cb0fafcb2..06ba4923fd5a 100644 --- a/sound/soc/codecs/sirf-audio-codec.c +++ b/sound/soc/codecs/sirf-audio-codec.c | |||
| @@ -471,8 +471,8 @@ static int sirf_audio_codec_driver_probe(struct platform_device *pdev) | |||
| 471 | 471 | ||
| 472 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 472 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
| 473 | base = devm_ioremap_resource(&pdev->dev, mem_res); | 473 | base = devm_ioremap_resource(&pdev->dev, mem_res); |
| 474 | if (base == NULL) | 474 | if (IS_ERR(base)) |
| 475 | return -ENOMEM; | 475 | return PTR_ERR(base); |
| 476 | 476 | ||
| 477 | sirf_audio_codec->regmap = devm_regmap_init_mmio(&pdev->dev, base, | 477 | sirf_audio_codec->regmap = devm_regmap_init_mmio(&pdev->dev, base, |
| 478 | &sirf_audio_codec_regmap_config); | 478 | &sirf_audio_codec_regmap_config); |
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index 42dff26b3a2a..cf8fa40662f0 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c | |||
| @@ -661,12 +661,12 @@ static int sn95031_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 661 | { | 661 | { |
| 662 | unsigned int format, rate; | 662 | unsigned int format, rate; |
| 663 | 663 | ||
| 664 | switch (params_format(params)) { | 664 | switch (params_width(params)) { |
| 665 | case SNDRV_PCM_FORMAT_S16_LE: | 665 | case 16: |
| 666 | format = BIT(4)|BIT(5); | 666 | format = BIT(4)|BIT(5); |
| 667 | break; | 667 | break; |
| 668 | 668 | ||
| 669 | case SNDRV_PCM_FORMAT_S24_LE: | 669 | case 24: |
| 670 | format = 0; | 670 | format = 0; |
| 671 | break; | 671 | break; |
| 672 | default: | 672 | default: |
diff --git a/sound/soc/codecs/spdif_transmitter.c b/sound/soc/codecs/spdif_transmitter.c index a078aa31052a..e0df537dd4b7 100644 --- a/sound/soc/codecs/spdif_transmitter.c +++ b/sound/soc/codecs/spdif_transmitter.c | |||
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | #define DRV_NAME "spdif-dit" | 25 | #define DRV_NAME "spdif-dit" |
| 26 | 26 | ||
| 27 | #define STUB_RATES SNDRV_PCM_RATE_8000_96000 | 27 | #define STUB_RATES SNDRV_PCM_RATE_8000_192000 |
| 28 | #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ | 28 | #define STUB_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | \ |
| 29 | SNDRV_PCM_FMTBIT_S20_3LE | \ | 29 | SNDRV_PCM_FMTBIT_S20_3LE | \ |
| 30 | SNDRV_PCM_FMTBIT_S24_LE) | 30 | SNDRV_PCM_FMTBIT_S24_LE) |
diff --git a/sound/soc/codecs/ssm2518.c b/sound/soc/codecs/ssm2518.c index 56adb3e2def9..e8680bea5f86 100644 --- a/sound/soc/codecs/ssm2518.c +++ b/sound/soc/codecs/ssm2518.c | |||
| @@ -361,11 +361,11 @@ static int ssm2518_hw_params(struct snd_pcm_substream *substream, | |||
| 361 | return -EINVAL; | 361 | return -EINVAL; |
| 362 | 362 | ||
| 363 | if (ssm2518->right_j) { | 363 | if (ssm2518->right_j) { |
| 364 | switch (params_format(params)) { | 364 | switch (params_width(params)) { |
| 365 | case SNDRV_PCM_FORMAT_S16_LE: | 365 | case 16: |
| 366 | ctrl1 |= SSM2518_SAI_CTRL1_FMT_RJ_16BIT; | 366 | ctrl1 |= SSM2518_SAI_CTRL1_FMT_RJ_16BIT; |
| 367 | break; | 367 | break; |
| 368 | case SNDRV_PCM_FORMAT_S24_LE: | 368 | case 24: |
| 369 | ctrl1 |= SSM2518_SAI_CTRL1_FMT_RJ_24BIT; | 369 | ctrl1 |= SSM2518_SAI_CTRL1_FMT_RJ_24BIT; |
| 370 | break; | 370 | break; |
| 371 | default: | 371 | default: |
diff --git a/sound/soc/codecs/ssm2602.c b/sound/soc/codecs/ssm2602.c index 97b0454eb346..484b3bbe8624 100644 --- a/sound/soc/codecs/ssm2602.c +++ b/sound/soc/codecs/ssm2602.c | |||
| @@ -275,17 +275,17 @@ static int ssm2602_hw_params(struct snd_pcm_substream *substream, | |||
| 275 | regmap_write(ssm2602->regmap, SSM2602_SRATE, srate); | 275 | regmap_write(ssm2602->regmap, SSM2602_SRATE, srate); |
| 276 | 276 | ||
| 277 | /* bit size */ | 277 | /* bit size */ |
| 278 | switch (params_format(params)) { | 278 | switch (params_width(params)) { |
| 279 | case SNDRV_PCM_FORMAT_S16_LE: | 279 | case 16: |
| 280 | iface = 0x0; | 280 | iface = 0x0; |
| 281 | break; | 281 | break; |
| 282 | case SNDRV_PCM_FORMAT_S20_3LE: | 282 | case 20: |
| 283 | iface = 0x4; | 283 | iface = 0x4; |
| 284 | break; | 284 | break; |
| 285 | case SNDRV_PCM_FORMAT_S24_LE: | 285 | case 24: |
| 286 | iface = 0x8; | 286 | iface = 0x8; |
| 287 | break; | 287 | break; |
| 288 | case SNDRV_PCM_FORMAT_S32_LE: | 288 | case 32: |
| 289 | iface = 0xc; | 289 | iface = 0xc; |
| 290 | break; | 290 | break; |
| 291 | default: | 291 | default: |
diff --git a/sound/soc/codecs/sta32x.c b/sound/soc/codecs/sta32x.c index 0579d187135b..48740855566d 100644 --- a/sound/soc/codecs/sta32x.c +++ b/sound/soc/codecs/sta32x.c | |||
| @@ -678,15 +678,11 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, | |||
| 678 | 678 | ||
| 679 | confb = snd_soc_read(codec, STA32X_CONFB); | 679 | confb = snd_soc_read(codec, STA32X_CONFB); |
| 680 | confb &= ~(STA32X_CONFB_SAI_MASK | STA32X_CONFB_SAIFB); | 680 | confb &= ~(STA32X_CONFB_SAI_MASK | STA32X_CONFB_SAIFB); |
| 681 | switch (params_format(params)) { | 681 | switch (params_width(params)) { |
| 682 | case SNDRV_PCM_FORMAT_S24_LE: | 682 | case 24: |
| 683 | case SNDRV_PCM_FORMAT_S24_BE: | ||
| 684 | case SNDRV_PCM_FORMAT_S24_3LE: | ||
| 685 | case SNDRV_PCM_FORMAT_S24_3BE: | ||
| 686 | pr_debug("24bit\n"); | 683 | pr_debug("24bit\n"); |
| 687 | /* fall through */ | 684 | /* fall through */ |
| 688 | case SNDRV_PCM_FORMAT_S32_LE: | 685 | case 32: |
| 689 | case SNDRV_PCM_FORMAT_S32_BE: | ||
| 690 | pr_debug("24bit or 32bit\n"); | 686 | pr_debug("24bit or 32bit\n"); |
| 691 | switch (sta32x->format) { | 687 | switch (sta32x->format) { |
| 692 | case SND_SOC_DAIFMT_I2S: | 688 | case SND_SOC_DAIFMT_I2S: |
| @@ -701,8 +697,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, | |||
| 701 | } | 697 | } |
| 702 | 698 | ||
| 703 | break; | 699 | break; |
| 704 | case SNDRV_PCM_FORMAT_S20_3LE: | 700 | case 20: |
| 705 | case SNDRV_PCM_FORMAT_S20_3BE: | ||
| 706 | pr_debug("20bit\n"); | 701 | pr_debug("20bit\n"); |
| 707 | switch (sta32x->format) { | 702 | switch (sta32x->format) { |
| 708 | case SND_SOC_DAIFMT_I2S: | 703 | case SND_SOC_DAIFMT_I2S: |
| @@ -717,8 +712,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, | |||
| 717 | } | 712 | } |
| 718 | 713 | ||
| 719 | break; | 714 | break; |
| 720 | case SNDRV_PCM_FORMAT_S18_3LE: | 715 | case 18: |
| 721 | case SNDRV_PCM_FORMAT_S18_3BE: | ||
| 722 | pr_debug("18bit\n"); | 716 | pr_debug("18bit\n"); |
| 723 | switch (sta32x->format) { | 717 | switch (sta32x->format) { |
| 724 | case SND_SOC_DAIFMT_I2S: | 718 | case SND_SOC_DAIFMT_I2S: |
| @@ -733,8 +727,7 @@ static int sta32x_hw_params(struct snd_pcm_substream *substream, | |||
| 733 | } | 727 | } |
| 734 | 728 | ||
| 735 | break; | 729 | break; |
| 736 | case SNDRV_PCM_FORMAT_S16_LE: | 730 | case 16: |
| 737 | case SNDRV_PCM_FORMAT_S16_BE: | ||
| 738 | pr_debug("16bit\n"); | 731 | pr_debug("16bit\n"); |
| 739 | switch (sta32x->format) { | 732 | switch (sta32x->format) { |
| 740 | case SND_SOC_DAIFMT_I2S: | 733 | case SND_SOC_DAIFMT_I2S: |
diff --git a/sound/soc/codecs/sta529.c b/sound/soc/codecs/sta529.c index a40c4b0196a3..9aa1323fb2ab 100644 --- a/sound/soc/codecs/sta529.c +++ b/sound/soc/codecs/sta529.c | |||
| @@ -197,16 +197,16 @@ static int sta529_hw_params(struct snd_pcm_substream *substream, | |||
| 197 | int pdata, play_freq_val, record_freq_val; | 197 | int pdata, play_freq_val, record_freq_val; |
| 198 | int bclk_to_fs_ratio; | 198 | int bclk_to_fs_ratio; |
| 199 | 199 | ||
| 200 | switch (params_format(params)) { | 200 | switch (params_width(params)) { |
| 201 | case SNDRV_PCM_FORMAT_S16_LE: | 201 | case 16: |
| 202 | pdata = 1; | 202 | pdata = 1; |
| 203 | bclk_to_fs_ratio = 0; | 203 | bclk_to_fs_ratio = 0; |
| 204 | break; | 204 | break; |
| 205 | case SNDRV_PCM_FORMAT_S24_LE: | 205 | case 24: |
| 206 | pdata = 2; | 206 | pdata = 2; |
| 207 | bclk_to_fs_ratio = 1; | 207 | bclk_to_fs_ratio = 1; |
| 208 | break; | 208 | break; |
| 209 | case SNDRV_PCM_FORMAT_S32_LE: | 209 | case 32: |
| 210 | pdata = 3; | 210 | pdata = 3; |
| 211 | bclk_to_fs_ratio = 2; | 211 | bclk_to_fs_ratio = 2; |
| 212 | break; | 212 | break; |
| @@ -380,10 +380,8 @@ static int sta529_i2c_probe(struct i2c_client *i2c, | |||
| 380 | return -EINVAL; | 380 | return -EINVAL; |
| 381 | 381 | ||
| 382 | sta529 = devm_kzalloc(&i2c->dev, sizeof(struct sta529), GFP_KERNEL); | 382 | sta529 = devm_kzalloc(&i2c->dev, sizeof(struct sta529), GFP_KERNEL); |
| 383 | if (sta529 == NULL) { | 383 | if (!sta529) |
| 384 | dev_err(&i2c->dev, "Can not allocate memory\n"); | ||
| 385 | return -ENOMEM; | 384 | return -ENOMEM; |
| 386 | } | ||
| 387 | 385 | ||
| 388 | sta529->regmap = devm_regmap_init_i2c(i2c, &sta529_regmap); | 386 | sta529->regmap = devm_regmap_init_i2c(i2c, &sta529_regmap); |
| 389 | if (IS_ERR(sta529->regmap)) { | 387 | if (IS_ERR(sta529->regmap)) { |
diff --git a/sound/soc/codecs/tas2552.c b/sound/soc/codecs/tas2552.c new file mode 100644 index 000000000000..23b32960ff1d --- /dev/null +++ b/sound/soc/codecs/tas2552.c | |||
| @@ -0,0 +1,544 @@ | |||
| 1 | /* | ||
| 2 | * tas2552.c - ALSA SoC Texas Instruments TAS2552 Mono Audio Amplifier | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com | ||
| 5 | * | ||
| 6 | * Author: Dan Murphy <dmurphy@ti.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU General Public License | ||
| 10 | * version 2 as published by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #include <linux/module.h> | ||
| 19 | #include <linux/errno.h> | ||
| 20 | #include <linux/device.h> | ||
| 21 | #include <linux/i2c.h> | ||
| 22 | #include <linux/gpio.h> | ||
| 23 | #include <linux/of_gpio.h> | ||
| 24 | #include <linux/pm_runtime.h> | ||
| 25 | #include <linux/regmap.h> | ||
| 26 | #include <linux/slab.h> | ||
| 27 | |||
| 28 | #include <linux/gpio/consumer.h> | ||
| 29 | #include <linux/regulator/consumer.h> | ||
| 30 | |||
| 31 | #include <sound/pcm.h> | ||
| 32 | #include <sound/pcm_params.h> | ||
| 33 | #include <sound/soc.h> | ||
| 34 | #include <sound/soc-dapm.h> | ||
| 35 | #include <sound/tlv.h> | ||
| 36 | #include <sound/tas2552-plat.h> | ||
| 37 | |||
| 38 | #include "tas2552.h" | ||
| 39 | |||
| 40 | static struct reg_default tas2552_reg_defs[] = { | ||
| 41 | {TAS2552_CFG_1, 0x22}, | ||
| 42 | {TAS2552_CFG_3, 0x80}, | ||
| 43 | {TAS2552_DOUT, 0x00}, | ||
| 44 | {TAS2552_OUTPUT_DATA, 0xc0}, | ||
| 45 | {TAS2552_PDM_CFG, 0x01}, | ||
| 46 | {TAS2552_PGA_GAIN, 0x00}, | ||
| 47 | {TAS2552_BOOST_PT_CTRL, 0x0f}, | ||
| 48 | {TAS2552_RESERVED_0D, 0x00}, | ||
| 49 | {TAS2552_LIMIT_RATE_HYS, 0x08}, | ||
| 50 | {TAS2552_CFG_2, 0xef}, | ||
| 51 | {TAS2552_SER_CTRL_1, 0x00}, | ||
| 52 | {TAS2552_SER_CTRL_2, 0x00}, | ||
| 53 | {TAS2552_PLL_CTRL_1, 0x10}, | ||
| 54 | {TAS2552_PLL_CTRL_2, 0x00}, | ||
| 55 | {TAS2552_PLL_CTRL_3, 0x00}, | ||
| 56 | {TAS2552_BTIP, 0x8f}, | ||
| 57 | {TAS2552_BTS_CTRL, 0x80}, | ||
| 58 | {TAS2552_LIMIT_RELEASE, 0x04}, | ||
| 59 | {TAS2552_LIMIT_INT_COUNT, 0x00}, | ||
| 60 | {TAS2552_EDGE_RATE_CTRL, 0x40}, | ||
| 61 | {TAS2552_VBAT_DATA, 0x00}, | ||
| 62 | }; | ||
| 63 | |||
| 64 | #define TAS2552_NUM_SUPPLIES 3 | ||
| 65 | static const char *tas2552_supply_names[TAS2552_NUM_SUPPLIES] = { | ||
| 66 | "vbat", /* vbat voltage */ | ||
| 67 | "iovdd", /* I/O Voltage */ | ||
| 68 | "avdd", /* Analog DAC Voltage */ | ||
| 69 | }; | ||
| 70 | |||
| 71 | struct tas2552_data { | ||
| 72 | struct snd_soc_codec *codec; | ||
| 73 | struct regmap *regmap; | ||
| 74 | struct i2c_client *tas2552_client; | ||
| 75 | struct regulator_bulk_data supplies[TAS2552_NUM_SUPPLIES]; | ||
| 76 | struct gpio_desc *enable_gpio; | ||
| 77 | unsigned char regs[TAS2552_VBAT_DATA]; | ||
| 78 | unsigned int mclk; | ||
| 79 | }; | ||
| 80 | |||
| 81 | static void tas2552_sw_shutdown(struct tas2552_data *tas_data, int sw_shutdown) | ||
| 82 | { | ||
| 83 | u8 cfg1_reg; | ||
| 84 | |||
| 85 | if (sw_shutdown) | ||
| 86 | cfg1_reg = 0; | ||
| 87 | else | ||
| 88 | cfg1_reg = TAS2552_SWS_MASK; | ||
| 89 | |||
| 90 | snd_soc_update_bits(tas_data->codec, TAS2552_CFG_1, | ||
| 91 | TAS2552_SWS_MASK, cfg1_reg); | ||
| 92 | } | ||
| 93 | |||
| 94 | static int tas2552_hw_params(struct snd_pcm_substream *substream, | ||
| 95 | struct snd_pcm_hw_params *params, | ||
| 96 | struct snd_soc_dai *dai) | ||
| 97 | { | ||
| 98 | struct snd_soc_codec *codec = dai->codec; | ||
| 99 | struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev); | ||
| 100 | int sample_rate, pll_clk; | ||
| 101 | int d; | ||
| 102 | u8 p, j; | ||
| 103 | |||
| 104 | /* Turn on Class D amplifier */ | ||
| 105 | snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_CLASSD_EN_MASK, | ||
| 106 | TAS2552_CLASSD_EN); | ||
| 107 | |||
| 108 | if (!tas2552->mclk) | ||
| 109 | return -EINVAL; | ||
| 110 | |||
| 111 | snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, 0); | ||
| 112 | |||
| 113 | if (tas2552->mclk == TAS2552_245MHZ_CLK || | ||
| 114 | tas2552->mclk == TAS2552_225MHZ_CLK) { | ||
| 115 | /* By pass the PLL configuration */ | ||
| 116 | snd_soc_update_bits(codec, TAS2552_PLL_CTRL_2, | ||
| 117 | TAS2552_PLL_BYPASS_MASK, | ||
| 118 | TAS2552_PLL_BYPASS); | ||
| 119 | } else { | ||
| 120 | /* Fill in the PLL control registers for J & D | ||
| 121 | * PLL_CLK = (.5 * freq * J.D) / 2^p | ||
| 122 | * Need to fill in J and D here based on incoming freq | ||
| 123 | */ | ||
| 124 | p = snd_soc_read(codec, TAS2552_PLL_CTRL_1); | ||
| 125 | p = (p >> 7); | ||
| 126 | sample_rate = params_rate(params); | ||
| 127 | |||
| 128 | if (sample_rate == 48000) | ||
| 129 | pll_clk = TAS2552_245MHZ_CLK; | ||
| 130 | else if (sample_rate == 44100) | ||
| 131 | pll_clk = TAS2552_225MHZ_CLK; | ||
| 132 | else { | ||
| 133 | dev_vdbg(codec->dev, "Substream sample rate is not found %i\n", | ||
| 134 | params_rate(params)); | ||
| 135 | return -EINVAL; | ||
| 136 | } | ||
| 137 | |||
| 138 | j = (pll_clk * 2 * (1 << p)) / tas2552->mclk; | ||
| 139 | d = (pll_clk * 2 * (1 << p)) % tas2552->mclk; | ||
| 140 | |||
| 141 | snd_soc_update_bits(codec, TAS2552_PLL_CTRL_1, | ||
| 142 | TAS2552_PLL_J_MASK, j); | ||
| 143 | snd_soc_write(codec, TAS2552_PLL_CTRL_2, | ||
| 144 | (d >> 7) & TAS2552_PLL_D_UPPER_MASK); | ||
| 145 | snd_soc_write(codec, TAS2552_PLL_CTRL_3, | ||
| 146 | d & TAS2552_PLL_D_LOWER_MASK); | ||
| 147 | |||
| 148 | } | ||
| 149 | |||
| 150 | snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, | ||
| 151 | TAS2552_PLL_ENABLE); | ||
| 152 | |||
| 153 | return 0; | ||
| 154 | } | ||
| 155 | |||
| 156 | static int tas2552_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | ||
| 157 | { | ||
| 158 | struct snd_soc_codec *codec = dai->codec; | ||
| 159 | u8 serial_format; | ||
| 160 | u8 serial_control_mask; | ||
| 161 | |||
| 162 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
| 163 | case SND_SOC_DAIFMT_CBS_CFS: | ||
| 164 | serial_format = 0x00; | ||
| 165 | break; | ||
| 166 | case SND_SOC_DAIFMT_CBS_CFM: | ||
| 167 | serial_format = TAS2552_WORD_CLK_MASK; | ||
| 168 | break; | ||
| 169 | case SND_SOC_DAIFMT_CBM_CFS: | ||
| 170 | serial_format = TAS2552_BIT_CLK_MASK; | ||
| 171 | break; | ||
| 172 | case SND_SOC_DAIFMT_CBM_CFM: | ||
| 173 | serial_format = (TAS2552_BIT_CLK_MASK | TAS2552_WORD_CLK_MASK); | ||
| 174 | break; | ||
| 175 | default: | ||
| 176 | dev_vdbg(codec->dev, "DAI Format master is not found\n"); | ||
| 177 | return -EINVAL; | ||
| 178 | } | ||
| 179 | |||
| 180 | serial_control_mask = TAS2552_BIT_CLK_MASK | TAS2552_WORD_CLK_MASK; | ||
| 181 | |||
| 182 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 183 | case SND_SOC_DAIFMT_I2S: | ||
| 184 | serial_format &= TAS2552_DAIFMT_I2S_MASK; | ||
| 185 | break; | ||
| 186 | case SND_SOC_DAIFMT_DSP_A: | ||
| 187 | serial_format |= TAS2552_DAIFMT_DSP; | ||
| 188 | break; | ||
| 189 | case SND_SOC_DAIFMT_RIGHT_J: | ||
| 190 | serial_format |= TAS2552_DAIFMT_RIGHT_J; | ||
| 191 | break; | ||
| 192 | case SND_SOC_DAIFMT_LEFT_J: | ||
| 193 | serial_format |= TAS2552_DAIFMT_LEFT_J; | ||
| 194 | break; | ||
| 195 | default: | ||
| 196 | dev_vdbg(codec->dev, "DAI Format is not found\n"); | ||
| 197 | return -EINVAL; | ||
| 198 | } | ||
| 199 | |||
| 200 | if (fmt & SND_SOC_DAIFMT_FORMAT_MASK) | ||
| 201 | serial_control_mask |= TAS2552_DATA_FORMAT_MASK; | ||
| 202 | |||
| 203 | snd_soc_update_bits(codec, TAS2552_SER_CTRL_1, serial_control_mask, | ||
| 204 | serial_format); | ||
| 205 | |||
| 206 | return 0; | ||
| 207 | } | ||
| 208 | |||
| 209 | static int tas2552_set_dai_sysclk(struct snd_soc_dai *dai, int clk_id, | ||
| 210 | unsigned int freq, int dir) | ||
| 211 | { | ||
| 212 | struct snd_soc_codec *codec = dai->codec; | ||
| 213 | struct tas2552_data *tas2552 = dev_get_drvdata(codec->dev); | ||
| 214 | |||
| 215 | tas2552->mclk = freq; | ||
| 216 | |||
| 217 | return 0; | ||
| 218 | } | ||
| 219 | |||
| 220 | static int tas2552_mute(struct snd_soc_dai *dai, int mute) | ||
| 221 | { | ||
| 222 | u8 cfg1_reg; | ||
| 223 | struct snd_soc_codec *codec = dai->codec; | ||
| 224 | |||
| 225 | if (mute) | ||
| 226 | cfg1_reg = TAS2552_MUTE_MASK; | ||
| 227 | else | ||
| 228 | cfg1_reg = ~TAS2552_MUTE_MASK; | ||
| 229 | |||
| 230 | snd_soc_update_bits(codec, TAS2552_CFG_1, TAS2552_MUTE_MASK, cfg1_reg); | ||
| 231 | |||
| 232 | return 0; | ||
| 233 | } | ||
| 234 | |||
| 235 | #ifdef CONFIG_PM_RUNTIME | ||
| 236 | static int tas2552_runtime_suspend(struct device *dev) | ||
| 237 | { | ||
| 238 | struct tas2552_data *tas2552 = dev_get_drvdata(dev); | ||
| 239 | |||
| 240 | tas2552_sw_shutdown(tas2552, 0); | ||
| 241 | |||
| 242 | regcache_cache_only(tas2552->regmap, true); | ||
| 243 | regcache_mark_dirty(tas2552->regmap); | ||
| 244 | |||
| 245 | if (tas2552->enable_gpio) | ||
| 246 | gpiod_set_value(tas2552->enable_gpio, 0); | ||
| 247 | |||
| 248 | return 0; | ||
| 249 | } | ||
| 250 | |||
| 251 | static int tas2552_runtime_resume(struct device *dev) | ||
| 252 | { | ||
| 253 | struct tas2552_data *tas2552 = dev_get_drvdata(dev); | ||
| 254 | |||
| 255 | if (tas2552->enable_gpio) | ||
| 256 | gpiod_set_value(tas2552->enable_gpio, 1); | ||
| 257 | |||
| 258 | tas2552_sw_shutdown(tas2552, 1); | ||
| 259 | |||
| 260 | regcache_cache_only(tas2552->regmap, false); | ||
| 261 | regcache_sync(tas2552->regmap); | ||
| 262 | |||
| 263 | return 0; | ||
| 264 | } | ||
| 265 | #endif | ||
| 266 | |||
| 267 | static const struct dev_pm_ops tas2552_pm = { | ||
| 268 | SET_RUNTIME_PM_OPS(tas2552_runtime_suspend, tas2552_runtime_resume, | ||
| 269 | NULL) | ||
| 270 | }; | ||
| 271 | |||
| 272 | static void tas2552_shutdown(struct snd_pcm_substream *substream, | ||
| 273 | struct snd_soc_dai *dai) | ||
| 274 | { | ||
| 275 | struct snd_soc_codec *codec = dai->codec; | ||
| 276 | |||
| 277 | snd_soc_update_bits(codec, TAS2552_CFG_2, TAS2552_PLL_ENABLE, 0); | ||
| 278 | } | ||
| 279 | |||
| 280 | static struct snd_soc_dai_ops tas2552_speaker_dai_ops = { | ||
| 281 | .hw_params = tas2552_hw_params, | ||
| 282 | .set_sysclk = tas2552_set_dai_sysclk, | ||
| 283 | .set_fmt = tas2552_set_dai_fmt, | ||
| 284 | .shutdown = tas2552_shutdown, | ||
| 285 | .digital_mute = tas2552_mute, | ||
| 286 | }; | ||
| 287 | |||
| 288 | /* Formats supported by TAS2552 driver. */ | ||
| 289 | #define TAS2552_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE |\ | ||
| 290 | SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S32_LE) | ||
| 291 | |||
| 292 | /* TAS2552 dai structure. */ | ||
| 293 | static struct snd_soc_dai_driver tas2552_dai[] = { | ||
| 294 | { | ||
| 295 | .name = "tas2552-amplifier", | ||
| 296 | .playback = { | ||
| 297 | .stream_name = "Speaker", | ||
| 298 | .channels_min = 2, | ||
| 299 | .channels_max = 2, | ||
| 300 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
| 301 | .formats = TAS2552_FORMATS, | ||
| 302 | }, | ||
| 303 | .ops = &tas2552_speaker_dai_ops, | ||
| 304 | }, | ||
| 305 | }; | ||
| 306 | |||
| 307 | /* | ||
| 308 | * DAC digital volumes. From -7 to 24 dB in 1 dB steps | ||
| 309 | */ | ||
| 310 | static DECLARE_TLV_DB_SCALE(dac_tlv, -7, 100, 24); | ||
| 311 | |||
| 312 | static const struct snd_kcontrol_new tas2552_snd_controls[] = { | ||
| 313 | SOC_SINGLE_TLV("Speaker Driver Playback Volume", | ||
| 314 | TAS2552_PGA_GAIN, 0, 0x1f, 1, dac_tlv), | ||
| 315 | }; | ||
| 316 | |||
| 317 | static const struct reg_default tas2552_init_regs[] = { | ||
| 318 | { TAS2552_RESERVED_0D, 0xc0 }, | ||
| 319 | }; | ||
| 320 | |||
| 321 | static int tas2552_codec_probe(struct snd_soc_codec *codec) | ||
| 322 | { | ||
| 323 | struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); | ||
| 324 | int ret; | ||
| 325 | |||
| 326 | tas2552->codec = codec; | ||
| 327 | |||
| 328 | ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), | ||
| 329 | tas2552->supplies); | ||
| 330 | |||
| 331 | if (ret != 0) { | ||
| 332 | dev_err(codec->dev, "Failed to enable supplies: %d\n", | ||
| 333 | ret); | ||
| 334 | return ret; | ||
| 335 | } | ||
| 336 | |||
| 337 | if (tas2552->enable_gpio) | ||
| 338 | gpiod_set_value(tas2552->enable_gpio, 1); | ||
| 339 | |||
| 340 | ret = pm_runtime_get_sync(codec->dev); | ||
| 341 | if (ret < 0) { | ||
| 342 | dev_err(codec->dev, "Enabling device failed: %d\n", | ||
| 343 | ret); | ||
| 344 | goto probe_fail; | ||
| 345 | } | ||
| 346 | |||
| 347 | snd_soc_write(codec, TAS2552_CFG_1, TAS2552_MUTE_MASK | | ||
| 348 | TAS2552_PLL_SRC_BCLK); | ||
| 349 | snd_soc_write(codec, TAS2552_CFG_3, TAS2552_I2S_OUT_SEL | | ||
| 350 | TAS2552_DIN_SRC_SEL_AVG_L_R | TAS2552_88_96KHZ); | ||
| 351 | snd_soc_write(codec, TAS2552_DOUT, TAS2552_PDM_DATA_I); | ||
| 352 | snd_soc_write(codec, TAS2552_OUTPUT_DATA, TAS2552_PDM_DATA_V_I | 0x8); | ||
| 353 | snd_soc_write(codec, TAS2552_PDM_CFG, TAS2552_PDM_BCLK_SEL); | ||
| 354 | snd_soc_write(codec, TAS2552_BOOST_PT_CTRL, TAS2552_APT_DELAY_200 | | ||
| 355 | TAS2552_APT_THRESH_2_1_7); | ||
| 356 | |||
| 357 | ret = regmap_register_patch(tas2552->regmap, tas2552_init_regs, | ||
| 358 | ARRAY_SIZE(tas2552_init_regs)); | ||
| 359 | if (ret != 0) { | ||
| 360 | dev_err(codec->dev, "Failed to write init registers: %d\n", | ||
| 361 | ret); | ||
| 362 | goto patch_fail; | ||
| 363 | } | ||
| 364 | |||
| 365 | snd_soc_write(codec, TAS2552_CFG_2, TAS2552_CLASSD_EN | | ||
| 366 | TAS2552_BOOST_EN | TAS2552_APT_EN | | ||
| 367 | TAS2552_LIM_EN); | ||
| 368 | return 0; | ||
| 369 | |||
| 370 | patch_fail: | ||
| 371 | pm_runtime_put(codec->dev); | ||
| 372 | probe_fail: | ||
| 373 | if (tas2552->enable_gpio) | ||
| 374 | gpiod_set_value(tas2552->enable_gpio, 0); | ||
| 375 | |||
| 376 | regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), | ||
| 377 | tas2552->supplies); | ||
| 378 | return -EIO; | ||
| 379 | } | ||
| 380 | |||
| 381 | static int tas2552_codec_remove(struct snd_soc_codec *codec) | ||
| 382 | { | ||
| 383 | struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); | ||
| 384 | |||
| 385 | pm_runtime_put(codec->dev); | ||
| 386 | |||
| 387 | if (tas2552->enable_gpio) | ||
| 388 | gpiod_set_value(tas2552->enable_gpio, 0); | ||
| 389 | |||
| 390 | return 0; | ||
| 391 | }; | ||
| 392 | |||
| 393 | #ifdef CONFIG_PM | ||
| 394 | static int tas2552_suspend(struct snd_soc_codec *codec) | ||
| 395 | { | ||
| 396 | struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); | ||
| 397 | int ret; | ||
| 398 | |||
| 399 | ret = regulator_bulk_disable(ARRAY_SIZE(tas2552->supplies), | ||
| 400 | tas2552->supplies); | ||
| 401 | |||
| 402 | if (ret != 0) | ||
| 403 | dev_err(codec->dev, "Failed to disable supplies: %d\n", | ||
| 404 | ret); | ||
| 405 | return 0; | ||
| 406 | } | ||
| 407 | |||
| 408 | static int tas2552_resume(struct snd_soc_codec *codec) | ||
| 409 | { | ||
| 410 | struct tas2552_data *tas2552 = snd_soc_codec_get_drvdata(codec); | ||
| 411 | int ret; | ||
| 412 | |||
| 413 | ret = regulator_bulk_enable(ARRAY_SIZE(tas2552->supplies), | ||
| 414 | tas2552->supplies); | ||
| 415 | |||
| 416 | if (ret != 0) { | ||
| 417 | dev_err(codec->dev, "Failed to enable supplies: %d\n", | ||
| 418 | ret); | ||
| 419 | } | ||
| 420 | |||
| 421 | return 0; | ||
| 422 | } | ||
| 423 | #else | ||
| 424 | #define tas2552_suspend NULL | ||
| 425 | #define tas2552_resume NULL | ||
| 426 | #endif | ||
| 427 | |||
| 428 | static struct snd_soc_codec_driver soc_codec_dev_tas2552 = { | ||
| 429 | .probe = tas2552_codec_probe, | ||
| 430 | .remove = tas2552_codec_remove, | ||
| 431 | .suspend = tas2552_suspend, | ||
| 432 | .resume = tas2552_resume, | ||
| 433 | .controls = tas2552_snd_controls, | ||
| 434 | .num_controls = ARRAY_SIZE(tas2552_snd_controls), | ||
| 435 | }; | ||
| 436 | |||
| 437 | static const struct regmap_config tas2552_regmap_config = { | ||
| 438 | .reg_bits = 8, | ||
| 439 | .val_bits = 8, | ||
| 440 | |||
| 441 | .max_register = TAS2552_MAX_REG, | ||
| 442 | .reg_defaults = tas2552_reg_defs, | ||
| 443 | .num_reg_defaults = ARRAY_SIZE(tas2552_reg_defs), | ||
| 444 | .cache_type = REGCACHE_RBTREE, | ||
| 445 | }; | ||
| 446 | |||
| 447 | static int tas2552_probe(struct i2c_client *client, | ||
| 448 | const struct i2c_device_id *id) | ||
| 449 | { | ||
| 450 | struct device *dev; | ||
| 451 | struct tas2552_data *data; | ||
| 452 | int ret; | ||
| 453 | int i; | ||
| 454 | |||
| 455 | dev = &client->dev; | ||
| 456 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); | ||
| 457 | if (data == NULL) | ||
| 458 | return -ENOMEM; | ||
| 459 | |||
| 460 | data->enable_gpio = devm_gpiod_get(dev, "enable"); | ||
| 461 | if (IS_ERR(data->enable_gpio)) { | ||
| 462 | ret = PTR_ERR(data->enable_gpio); | ||
| 463 | if (ret != -ENOENT && ret != -ENOSYS) | ||
| 464 | return ret; | ||
| 465 | |||
| 466 | data->enable_gpio = NULL; | ||
| 467 | } else { | ||
| 468 | gpiod_direction_output(data->enable_gpio, 0); | ||
| 469 | } | ||
| 470 | |||
| 471 | data->tas2552_client = client; | ||
| 472 | data->regmap = devm_regmap_init_i2c(client, &tas2552_regmap_config); | ||
| 473 | if (IS_ERR(data->regmap)) { | ||
| 474 | ret = PTR_ERR(data->regmap); | ||
| 475 | dev_err(&client->dev, "Failed to allocate register map: %d\n", | ||
| 476 | ret); | ||
| 477 | return ret; | ||
| 478 | } | ||
| 479 | |||
| 480 | for (i = 0; i < ARRAY_SIZE(data->supplies); i++) | ||
| 481 | data->supplies[i].supply = tas2552_supply_names[i]; | ||
| 482 | |||
| 483 | ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(data->supplies), | ||
| 484 | data->supplies); | ||
| 485 | if (ret != 0) { | ||
| 486 | dev_err(dev, "Failed to request supplies: %d\n", ret); | ||
| 487 | return ret; | ||
| 488 | } | ||
| 489 | |||
| 490 | pm_runtime_set_active(&client->dev); | ||
| 491 | pm_runtime_set_autosuspend_delay(&client->dev, 1000); | ||
| 492 | pm_runtime_use_autosuspend(&client->dev); | ||
| 493 | pm_runtime_enable(&client->dev); | ||
| 494 | pm_runtime_mark_last_busy(&client->dev); | ||
| 495 | pm_runtime_put_sync_autosuspend(&client->dev); | ||
| 496 | |||
| 497 | dev_set_drvdata(&client->dev, data); | ||
| 498 | |||
| 499 | ret = snd_soc_register_codec(&client->dev, | ||
| 500 | &soc_codec_dev_tas2552, | ||
| 501 | tas2552_dai, ARRAY_SIZE(tas2552_dai)); | ||
| 502 | if (ret < 0) | ||
| 503 | dev_err(&client->dev, "Failed to register codec: %d\n", ret); | ||
| 504 | |||
| 505 | return ret; | ||
| 506 | } | ||
| 507 | |||
| 508 | static int tas2552_i2c_remove(struct i2c_client *client) | ||
| 509 | { | ||
| 510 | snd_soc_unregister_codec(&client->dev); | ||
| 511 | return 0; | ||
| 512 | } | ||
| 513 | |||
| 514 | static const struct i2c_device_id tas2552_id[] = { | ||
| 515 | { "tas2552", 0 }, | ||
| 516 | { } | ||
| 517 | }; | ||
| 518 | MODULE_DEVICE_TABLE(i2c, tas2552_id); | ||
| 519 | |||
| 520 | #if IS_ENABLED(CONFIG_OF) | ||
| 521 | static const struct of_device_id tas2552_of_match[] = { | ||
| 522 | { .compatible = "ti,tas2552", }, | ||
| 523 | {}, | ||
| 524 | }; | ||
| 525 | MODULE_DEVICE_TABLE(of, tas2552_of_match); | ||
| 526 | #endif | ||
| 527 | |||
| 528 | static struct i2c_driver tas2552_i2c_driver = { | ||
| 529 | .driver = { | ||
| 530 | .name = "tas2552", | ||
| 531 | .owner = THIS_MODULE, | ||
| 532 | .of_match_table = of_match_ptr(tas2552_of_match), | ||
| 533 | .pm = &tas2552_pm, | ||
| 534 | }, | ||
| 535 | .probe = tas2552_probe, | ||
| 536 | .remove = tas2552_i2c_remove, | ||
| 537 | .id_table = tas2552_id, | ||
| 538 | }; | ||
| 539 | |||
| 540 | module_i2c_driver(tas2552_i2c_driver); | ||
| 541 | |||
| 542 | MODULE_AUTHOR("Dan Muprhy <dmurphy@ti.com>"); | ||
| 543 | MODULE_DESCRIPTION("TAS2552 Audio amplifier driver"); | ||
| 544 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/codecs/tas2552.h b/sound/soc/codecs/tas2552.h new file mode 100644 index 000000000000..6cea8f31bf88 --- /dev/null +++ b/sound/soc/codecs/tas2552.h | |||
| @@ -0,0 +1,129 @@ | |||
| 1 | /* | ||
| 2 | * tas2552.h - ALSA SoC Texas Instruments TAS2552 Mono Audio Amplifier | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com | ||
| 5 | * | ||
| 6 | * Author: Dan Murphy <dmurphy@ti.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or | ||
| 9 | * modify it under the terms of the GNU General Public License | ||
| 10 | * version 2 as published by the Free Software Foundation. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | */ | ||
| 17 | |||
| 18 | #ifndef __TAS2552_H__ | ||
| 19 | #define __TAS2552_H__ | ||
| 20 | |||
| 21 | /* Register Address Map */ | ||
| 22 | #define TAS2552_DEVICE_STATUS 0x00 | ||
| 23 | #define TAS2552_CFG_1 0x01 | ||
| 24 | #define TAS2552_CFG_2 0x02 | ||
| 25 | #define TAS2552_CFG_3 0x03 | ||
| 26 | #define TAS2552_DOUT 0x04 | ||
| 27 | #define TAS2552_SER_CTRL_1 0x05 | ||
| 28 | #define TAS2552_SER_CTRL_2 0x06 | ||
| 29 | #define TAS2552_OUTPUT_DATA 0x07 | ||
| 30 | #define TAS2552_PLL_CTRL_1 0x08 | ||
| 31 | #define TAS2552_PLL_CTRL_2 0x09 | ||
| 32 | #define TAS2552_PLL_CTRL_3 0x0a | ||
| 33 | #define TAS2552_BTIP 0x0b | ||
| 34 | #define TAS2552_BTS_CTRL 0x0c | ||
| 35 | #define TAS2552_RESERVED_0D 0x0d | ||
| 36 | #define TAS2552_LIMIT_RATE_HYS 0x0e | ||
| 37 | #define TAS2552_LIMIT_RELEASE 0x0f | ||
| 38 | #define TAS2552_LIMIT_INT_COUNT 0x10 | ||
| 39 | #define TAS2552_PDM_CFG 0x11 | ||
| 40 | #define TAS2552_PGA_GAIN 0x12 | ||
| 41 | #define TAS2552_EDGE_RATE_CTRL 0x13 | ||
| 42 | #define TAS2552_BOOST_PT_CTRL 0x14 | ||
| 43 | #define TAS2552_VER_NUM 0x16 | ||
| 44 | #define TAS2552_VBAT_DATA 0x19 | ||
| 45 | #define TAS2552_MAX_REG 0x20 | ||
| 46 | |||
| 47 | /* CFG1 Register Masks */ | ||
| 48 | #define TAS2552_MUTE_MASK (1 << 2) | ||
| 49 | #define TAS2552_SWS_MASK (1 << 1) | ||
| 50 | #define TAS2552_WCLK_MASK 0x07 | ||
| 51 | #define TAS2552_CLASSD_EN_MASK (1 << 7) | ||
| 52 | |||
| 53 | /* CFG2 Register Masks */ | ||
| 54 | #define TAS2552_CLASSD_EN (1 << 7) | ||
| 55 | #define TAS2552_BOOST_EN (1 << 6) | ||
| 56 | #define TAS2552_APT_EN (1 << 5) | ||
| 57 | #define TAS2552_PLL_ENABLE (1 << 3) | ||
| 58 | #define TAS2552_LIM_EN (1 << 2) | ||
| 59 | #define TAS2552_IVSENSE_EN (1 << 1) | ||
| 60 | |||
| 61 | /* CFG3 Register Masks */ | ||
| 62 | #define TAS2552_WORD_CLK_MASK (1 << 7) | ||
| 63 | #define TAS2552_BIT_CLK_MASK (1 << 6) | ||
| 64 | #define TAS2552_DATA_FORMAT_MASK (0x11 << 2) | ||
| 65 | |||
| 66 | #define TAS2552_DAIFMT_I2S_MASK 0xf3 | ||
| 67 | #define TAS2552_DAIFMT_DSP (1 << 3) | ||
| 68 | #define TAS2552_DAIFMT_RIGHT_J (1 << 4) | ||
| 69 | #define TAS2552_DAIFMT_LEFT_J (0x11 << 3) | ||
| 70 | |||
| 71 | #define TAS2552_PLL_SRC_MCLK 0x00 | ||
| 72 | #define TAS2552_PLL_SRC_BCLK (1 << 3) | ||
| 73 | #define TAS2552_PLL_SRC_IVCLKIN (1 << 4) | ||
| 74 | #define TAS2552_PLL_SRC_1_8_FIXED (0x11 << 3) | ||
| 75 | |||
| 76 | #define TAS2552_DIN_SRC_SEL_MUTED 0x00 | ||
| 77 | #define TAS2552_DIN_SRC_SEL_LEFT (1 << 4) | ||
| 78 | #define TAS2552_DIN_SRC_SEL_RIGHT (1 << 5) | ||
| 79 | #define TAS2552_DIN_SRC_SEL_AVG_L_R (0x11 << 4) | ||
| 80 | |||
| 81 | #define TAS2552_PDM_IN_SEL (1 << 5) | ||
| 82 | #define TAS2552_I2S_OUT_SEL (1 << 6) | ||
| 83 | #define TAS2552_ANALOG_IN_SEL (1 << 7) | ||
| 84 | |||
| 85 | /* CFG3 WCLK Dividers */ | ||
| 86 | #define TAS2552_8KHZ 0x00 | ||
| 87 | #define TAS2552_11_12KHZ (1 << 1) | ||
| 88 | #define TAS2552_16KHZ (1 << 2) | ||
| 89 | #define TAS2552_22_24KHZ (1 << 3) | ||
| 90 | #define TAS2552_32KHZ (1 << 4) | ||
| 91 | #define TAS2552_44_48KHZ (1 << 5) | ||
| 92 | #define TAS2552_88_96KHZ (1 << 6) | ||
| 93 | #define TAS2552_176_192KHZ (1 << 7) | ||
| 94 | |||
| 95 | /* OUTPUT_DATA register */ | ||
| 96 | #define TAS2552_PDM_DATA_I 0x00 | ||
| 97 | #define TAS2552_PDM_DATA_V (1 << 6) | ||
| 98 | #define TAS2552_PDM_DATA_I_V (1 << 7) | ||
| 99 | #define TAS2552_PDM_DATA_V_I (0x11 << 6) | ||
| 100 | |||
| 101 | /* PDM CFG Register */ | ||
| 102 | #define TAS2552_PDM_DATA_ES_RISE 0x4 | ||
| 103 | |||
| 104 | #define TAS2552_PDM_PLL_CLK_SEL 0x00 | ||
| 105 | #define TAS2552_PDM_IV_CLK_SEL (1 << 1) | ||
| 106 | #define TAS2552_PDM_BCLK_SEL (1 << 2) | ||
| 107 | #define TAS2552_PDM_MCLK_SEL (1 << 3) | ||
| 108 | |||
| 109 | /* Boost pass-through register */ | ||
| 110 | #define TAS2552_APT_DELAY_50 0x00 | ||
| 111 | #define TAS2552_APT_DELAY_75 (1 << 1) | ||
| 112 | #define TAS2552_APT_DELAY_125 (1 << 2) | ||
| 113 | #define TAS2552_APT_DELAY_200 (1 << 3) | ||
| 114 | |||
| 115 | #define TAS2552_APT_THRESH_2_5 0x00 | ||
| 116 | #define TAS2552_APT_THRESH_1_7 (1 << 3) | ||
| 117 | #define TAS2552_APT_THRESH_1_4_1_1 (1 << 4) | ||
| 118 | #define TAS2552_APT_THRESH_2_1_7 (0x11 << 2) | ||
| 119 | |||
| 120 | /* PLL Control Register */ | ||
| 121 | #define TAS2552_245MHZ_CLK 24576000 | ||
| 122 | #define TAS2552_225MHZ_CLK 22579200 | ||
| 123 | #define TAS2552_PLL_J_MASK 0x7f | ||
| 124 | #define TAS2552_PLL_D_UPPER_MASK 0x3f | ||
| 125 | #define TAS2552_PLL_D_LOWER_MASK 0xff | ||
| 126 | #define TAS2552_PLL_BYPASS_MASK 0x80 | ||
| 127 | #define TAS2552_PLL_BYPASS 0x80 | ||
| 128 | |||
| 129 | #endif | ||
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index d48491a4a19d..249ef5c4c762 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c | |||
| @@ -36,6 +36,7 @@ | |||
| 36 | #include <linux/gpio.h> | 36 | #include <linux/gpio.h> |
| 37 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
| 38 | #include <linux/regmap.h> | 38 | #include <linux/regmap.h> |
| 39 | #include <linux/regulator/consumer.h> | ||
| 39 | #include <linux/spi/spi.h> | 40 | #include <linux/spi/spi.h> |
| 40 | #include <linux/of.h> | 41 | #include <linux/of.h> |
| 41 | #include <linux/of_device.h> | 42 | #include <linux/of_device.h> |
| @@ -240,6 +241,10 @@ static int tas5086_reg_read(void *context, unsigned int reg, | |||
| 240 | return 0; | 241 | return 0; |
| 241 | } | 242 | } |
| 242 | 243 | ||
| 244 | static const char * const supply_names[] = { | ||
| 245 | "dvdd", "avdd" | ||
| 246 | }; | ||
| 247 | |||
| 243 | struct tas5086_private { | 248 | struct tas5086_private { |
| 244 | struct regmap *regmap; | 249 | struct regmap *regmap; |
| 245 | unsigned int mclk, sclk; | 250 | unsigned int mclk, sclk; |
| @@ -251,6 +256,7 @@ struct tas5086_private { | |||
| 251 | int rate; | 256 | int rate; |
| 252 | /* GPIO driving Reset pin, if any */ | 257 | /* GPIO driving Reset pin, if any */ |
| 253 | int gpio_nreset; | 258 | int gpio_nreset; |
| 259 | struct regulator_bulk_data supplies[ARRAY_SIZE(supply_names)]; | ||
| 254 | }; | 260 | }; |
| 255 | 261 | ||
| 256 | static int tas5086_deemph[] = { 0, 32000, 44100, 48000 }; | 262 | static int tas5086_deemph[] = { 0, 32000, 44100, 48000 }; |
| @@ -419,14 +425,14 @@ static int tas5086_hw_params(struct snd_pcm_substream *substream, | |||
| 419 | } | 425 | } |
| 420 | 426 | ||
| 421 | /* ... then add the offset for the sample bit depth. */ | 427 | /* ... then add the offset for the sample bit depth. */ |
| 422 | switch (params_format(params)) { | 428 | switch (params_width(params)) { |
| 423 | case SNDRV_PCM_FORMAT_S16_LE: | 429 | case 16: |
| 424 | val += 0; | 430 | val += 0; |
| 425 | break; | 431 | break; |
| 426 | case SNDRV_PCM_FORMAT_S20_3LE: | 432 | case 20: |
| 427 | val += 1; | 433 | val += 1; |
| 428 | break; | 434 | break; |
| 429 | case SNDRV_PCM_FORMAT_S24_3LE: | 435 | case 24: |
| 430 | val += 2; | 436 | val += 2; |
| 431 | break; | 437 | break; |
| 432 | default: | 438 | default: |
| @@ -773,6 +779,8 @@ static int tas5086_soc_suspend(struct snd_soc_codec *codec) | |||
| 773 | if (ret < 0) | 779 | if (ret < 0) |
| 774 | return ret; | 780 | return ret; |
| 775 | 781 | ||
| 782 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 783 | |||
| 776 | return 0; | 784 | return 0; |
| 777 | } | 785 | } |
| 778 | 786 | ||
| @@ -781,6 +789,10 @@ static int tas5086_soc_resume(struct snd_soc_codec *codec) | |||
| 781 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 789 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); |
| 782 | int ret; | 790 | int ret; |
| 783 | 791 | ||
| 792 | ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 793 | if (ret < 0) | ||
| 794 | return ret; | ||
| 795 | |||
| 784 | tas5086_reset(priv); | 796 | tas5086_reset(priv); |
| 785 | regcache_mark_dirty(priv->regmap); | 797 | regcache_mark_dirty(priv->regmap); |
| 786 | 798 | ||
| @@ -812,6 +824,12 @@ static int tas5086_probe(struct snd_soc_codec *codec) | |||
| 812 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 824 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); |
| 813 | int i, ret; | 825 | int i, ret; |
| 814 | 826 | ||
| 827 | ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 828 | if (ret < 0) { | ||
| 829 | dev_err(codec->dev, "Failed to enable regulators: %d\n", ret); | ||
| 830 | return ret; | ||
| 831 | } | ||
| 832 | |||
| 815 | priv->pwm_start_mid_z = 0; | 833 | priv->pwm_start_mid_z = 0; |
| 816 | priv->charge_period = 1300000; /* hardware default is 1300 ms */ | 834 | priv->charge_period = 1300000; /* hardware default is 1300 ms */ |
| 817 | 835 | ||
| @@ -832,16 +850,22 @@ static int tas5086_probe(struct snd_soc_codec *codec) | |||
| 832 | } | 850 | } |
| 833 | } | 851 | } |
| 834 | 852 | ||
| 853 | tas5086_reset(priv); | ||
| 835 | ret = tas5086_init(codec->dev, priv); | 854 | ret = tas5086_init(codec->dev, priv); |
| 836 | if (ret < 0) | 855 | if (ret < 0) |
| 837 | return ret; | 856 | goto exit_disable_regulators; |
| 838 | 857 | ||
| 839 | /* set master volume to 0 dB */ | 858 | /* set master volume to 0 dB */ |
| 840 | ret = regmap_write(priv->regmap, TAS5086_MASTER_VOL, 0x30); | 859 | ret = regmap_write(priv->regmap, TAS5086_MASTER_VOL, 0x30); |
| 841 | if (ret < 0) | 860 | if (ret < 0) |
| 842 | return ret; | 861 | goto exit_disable_regulators; |
| 843 | 862 | ||
| 844 | return 0; | 863 | return 0; |
| 864 | |||
| 865 | exit_disable_regulators: | ||
| 866 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 867 | |||
| 868 | return ret; | ||
| 845 | } | 869 | } |
| 846 | 870 | ||
| 847 | static int tas5086_remove(struct snd_soc_codec *codec) | 871 | static int tas5086_remove(struct snd_soc_codec *codec) |
| @@ -852,6 +876,8 @@ static int tas5086_remove(struct snd_soc_codec *codec) | |||
| 852 | /* Set codec to the reset state */ | 876 | /* Set codec to the reset state */ |
| 853 | gpio_set_value(priv->gpio_nreset, 0); | 877 | gpio_set_value(priv->gpio_nreset, 0); |
| 854 | 878 | ||
| 879 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 880 | |||
| 855 | return 0; | 881 | return 0; |
| 856 | }; | 882 | }; |
| 857 | 883 | ||
| @@ -900,6 +926,16 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, | |||
| 900 | if (!priv) | 926 | if (!priv) |
| 901 | return -ENOMEM; | 927 | return -ENOMEM; |
| 902 | 928 | ||
| 929 | for (i = 0; i < ARRAY_SIZE(supply_names); i++) | ||
| 930 | priv->supplies[i].supply = supply_names[i]; | ||
| 931 | |||
| 932 | ret = devm_regulator_bulk_get(dev, ARRAY_SIZE(priv->supplies), | ||
| 933 | priv->supplies); | ||
| 934 | if (ret < 0) { | ||
| 935 | dev_err(dev, "Failed to get regulators: %d\n", ret); | ||
| 936 | return ret; | ||
| 937 | } | ||
| 938 | |||
| 903 | priv->regmap = devm_regmap_init(dev, NULL, i2c, &tas5086_regmap); | 939 | priv->regmap = devm_regmap_init(dev, NULL, i2c, &tas5086_regmap); |
| 904 | if (IS_ERR(priv->regmap)) { | 940 | if (IS_ERR(priv->regmap)) { |
| 905 | ret = PTR_ERR(priv->regmap); | 941 | ret = PTR_ERR(priv->regmap); |
| @@ -919,21 +955,34 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, | |||
| 919 | gpio_nreset = -EINVAL; | 955 | gpio_nreset = -EINVAL; |
| 920 | 956 | ||
| 921 | priv->gpio_nreset = gpio_nreset; | 957 | priv->gpio_nreset = gpio_nreset; |
| 958 | |||
| 959 | ret = regulator_bulk_enable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 960 | if (ret < 0) { | ||
| 961 | dev_err(dev, "Failed to enable regulators: %d\n", ret); | ||
| 962 | return ret; | ||
| 963 | } | ||
| 964 | |||
| 922 | tas5086_reset(priv); | 965 | tas5086_reset(priv); |
| 923 | 966 | ||
| 924 | /* The TAS5086 always returns 0x03 in its TAS5086_DEV_ID register */ | 967 | /* The TAS5086 always returns 0x03 in its TAS5086_DEV_ID register */ |
| 925 | ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i); | 968 | ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i); |
| 926 | if (ret < 0) | 969 | if (ret == 0 && i != 0x3) { |
| 927 | return ret; | ||
| 928 | |||
| 929 | if (i != 0x3) { | ||
| 930 | dev_err(dev, | 970 | dev_err(dev, |
| 931 | "Failed to identify TAS5086 codec (got %02x)\n", i); | 971 | "Failed to identify TAS5086 codec (got %02x)\n", i); |
| 932 | return -ENODEV; | 972 | ret = -ENODEV; |
| 933 | } | 973 | } |
| 934 | 974 | ||
| 935 | return snd_soc_register_codec(&i2c->dev, &soc_codec_dev_tas5086, | 975 | /* |
| 936 | &tas5086_dai, 1); | 976 | * The chip has been identified, so we can turn off the power |
| 977 | * again until the dai link is set up. | ||
| 978 | */ | ||
| 979 | regulator_bulk_disable(ARRAY_SIZE(priv->supplies), priv->supplies); | ||
| 980 | |||
| 981 | if (ret == 0) | ||
| 982 | ret = snd_soc_register_codec(&i2c->dev, &soc_codec_dev_tas5086, | ||
| 983 | &tas5086_dai, 1); | ||
| 984 | |||
| 985 | return ret; | ||
| 937 | } | 986 | } |
| 938 | 987 | ||
| 939 | static int tas5086_i2c_remove(struct i2c_client *i2c) | 988 | static int tas5086_i2c_remove(struct i2c_client *i2c) |
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 686b8b85b956..d67167920c2f 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
| @@ -364,16 +364,16 @@ static int tlv320aic23_hw_params(struct snd_pcm_substream *substream, | |||
| 364 | 364 | ||
| 365 | iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2); | 365 | iface_reg = snd_soc_read(codec, TLV320AIC23_DIGT_FMT) & ~(0x03 << 2); |
| 366 | 366 | ||
| 367 | switch (params_format(params)) { | 367 | switch (params_width(params)) { |
| 368 | case SNDRV_PCM_FORMAT_S16_LE: | 368 | case 16: |
| 369 | break; | 369 | break; |
| 370 | case SNDRV_PCM_FORMAT_S20_3LE: | 370 | case 20: |
| 371 | iface_reg |= (0x01 << 2); | 371 | iface_reg |= (0x01 << 2); |
| 372 | break; | 372 | break; |
| 373 | case SNDRV_PCM_FORMAT_S24_LE: | 373 | case 24: |
| 374 | iface_reg |= (0x02 << 2); | 374 | iface_reg |= (0x02 << 2); |
| 375 | break; | 375 | break; |
| 376 | case SNDRV_PCM_FORMAT_S32_LE: | 376 | case 32: |
| 377 | iface_reg |= (0x03 << 2); | 377 | iface_reg |= (0x03 << 2); |
| 378 | break; | 378 | break; |
| 379 | } | 379 | } |
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 43069de3d56a..620ab9ea1ef0 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c | |||
| @@ -71,8 +71,8 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
| 71 | 71 | ||
| 72 | dev_dbg(&aic26->spi->dev, "aic26_hw_params(substream=%p, params=%p)\n", | 72 | dev_dbg(&aic26->spi->dev, "aic26_hw_params(substream=%p, params=%p)\n", |
| 73 | substream, params); | 73 | substream, params); |
| 74 | dev_dbg(&aic26->spi->dev, "rate=%i format=%i\n", params_rate(params), | 74 | dev_dbg(&aic26->spi->dev, "rate=%i width=%d\n", params_rate(params), |
| 75 | params_format(params)); | 75 | params_width(params)); |
| 76 | 76 | ||
| 77 | switch (params_rate(params)) { | 77 | switch (params_rate(params)) { |
| 78 | case 8000: fsref = 48000; divisor = AIC26_DIV_6; break; | 78 | case 8000: fsref = 48000; divisor = AIC26_DIV_6; break; |
| @@ -89,11 +89,11 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | /* select data word length */ | 91 | /* select data word length */ |
| 92 | switch (params_format(params)) { | 92 | switch (params_width(params)) { |
| 93 | case SNDRV_PCM_FORMAT_S8: wlen = AIC26_WLEN_16; break; | 93 | case 8: wlen = AIC26_WLEN_16; break; |
| 94 | case SNDRV_PCM_FORMAT_S16_BE: wlen = AIC26_WLEN_16; break; | 94 | case 16: wlen = AIC26_WLEN_16; break; |
| 95 | case SNDRV_PCM_FORMAT_S24_BE: wlen = AIC26_WLEN_24; break; | 95 | case 24: wlen = AIC26_WLEN_24; break; |
| 96 | case SNDRV_PCM_FORMAT_S32_BE: wlen = AIC26_WLEN_32; break; | 96 | case 32: wlen = AIC26_WLEN_32; break; |
| 97 | default: | 97 | default: |
| 98 | dev_dbg(&aic26->spi->dev, "bad format\n"); return -EINVAL; | 98 | dev_dbg(&aic26->spi->dev, "bad format\n"); return -EINVAL; |
| 99 | } | 99 | } |
diff --git a/sound/soc/codecs/tlv320aic31xx.c b/sound/soc/codecs/tlv320aic31xx.c index 23419109ecac..0f64c7890eed 100644 --- a/sound/soc/codecs/tlv320aic31xx.c +++ b/sound/soc/codecs/tlv320aic31xx.c | |||
| @@ -249,17 +249,16 @@ static const char * const mic_select_text[] = { | |||
| 249 | "Off", "FFR 10 Ohm", "FFR 20 Ohm", "FFR 40 Ohm" | 249 | "Off", "FFR 10 Ohm", "FFR 20 Ohm", "FFR 40 Ohm" |
| 250 | }; | 250 | }; |
| 251 | 251 | ||
| 252 | static const | 252 | static SOC_ENUM_SINGLE_DECL(mic1lp_p_enum, AIC31XX_MICPGAPI, 6, |
| 253 | SOC_ENUM_SINGLE_DECL(mic1lp_p_enum, AIC31XX_MICPGAPI, 6, mic_select_text); | 253 | mic_select_text); |
| 254 | static const | 254 | static SOC_ENUM_SINGLE_DECL(mic1rp_p_enum, AIC31XX_MICPGAPI, 4, |
| 255 | SOC_ENUM_SINGLE_DECL(mic1rp_p_enum, AIC31XX_MICPGAPI, 4, mic_select_text); | 255 | mic_select_text); |
| 256 | static const | 256 | static SOC_ENUM_SINGLE_DECL(mic1lm_p_enum, AIC31XX_MICPGAPI, 2, |
| 257 | SOC_ENUM_SINGLE_DECL(mic1lm_p_enum, AIC31XX_MICPGAPI, 2, mic_select_text); | 257 | mic_select_text); |
| 258 | 258 | ||
| 259 | static const | 259 | static SOC_ENUM_SINGLE_DECL(cm_m_enum, AIC31XX_MICPGAMI, 6, mic_select_text); |
| 260 | SOC_ENUM_SINGLE_DECL(cm_m_enum, AIC31XX_MICPGAMI, 6, mic_select_text); | 260 | static SOC_ENUM_SINGLE_DECL(mic1lm_m_enum, AIC31XX_MICPGAMI, 4, |
| 261 | static const | 261 | mic_select_text); |
| 262 | SOC_ENUM_SINGLE_DECL(mic1lm_m_enum, AIC31XX_MICPGAMI, 4, mic_select_text); | ||
| 263 | 262 | ||
| 264 | static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6350, 50, 0); | 263 | static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -6350, 50, 0); |
| 265 | static const DECLARE_TLV_DB_SCALE(adc_fgain_tlv, 0, 10, 0); | 264 | static const DECLARE_TLV_DB_SCALE(adc_fgain_tlv, 0, 10, 0); |
| @@ -329,6 +328,7 @@ static int aic31xx_wait_bits(struct aic31xx_priv *aic31xx, unsigned int reg, | |||
| 329 | unsigned int bits; | 328 | unsigned int bits; |
| 330 | int counter = count; | 329 | int counter = count; |
| 331 | int ret = regmap_read(aic31xx->regmap, reg, &bits); | 330 | int ret = regmap_read(aic31xx->regmap, reg, &bits); |
| 331 | |||
| 332 | while ((bits & mask) != wbits && counter && !ret) { | 332 | while ((bits & mask) != wbits && counter && !ret) { |
| 333 | usleep_range(sleep, sleep * 2); | 333 | usleep_range(sleep, sleep * 2); |
| 334 | ret = regmap_read(aic31xx->regmap, reg, &bits); | 334 | ret = regmap_read(aic31xx->regmap, reg, &bits); |
| @@ -435,6 +435,7 @@ static int mic_bias_event(struct snd_soc_dapm_widget *w, | |||
| 435 | { | 435 | { |
| 436 | struct snd_soc_codec *codec = w->codec; | 436 | struct snd_soc_codec *codec = w->codec; |
| 437 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); | 437 | struct aic31xx_priv *aic31xx = snd_soc_codec_get_drvdata(codec); |
| 438 | |||
| 438 | switch (event) { | 439 | switch (event) { |
| 439 | case SND_SOC_DAPM_POST_PMU: | 440 | case SND_SOC_DAPM_POST_PMU: |
| 440 | /* change mic bias voltage to user defined */ | 441 | /* change mic bias voltage to user defined */ |
| @@ -759,8 +760,8 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, | |||
| 759 | struct snd_soc_codec *codec = dai->codec; | 760 | struct snd_soc_codec *codec = dai->codec; |
| 760 | u8 data = 0; | 761 | u8 data = 0; |
| 761 | 762 | ||
| 762 | dev_dbg(codec->dev, "## %s: format %d width %d rate %d\n", | 763 | dev_dbg(codec->dev, "## %s: width %d rate %d\n", |
| 763 | __func__, params_format(params), params_width(params), | 764 | __func__, params_width(params), |
| 764 | params_rate(params)); | 765 | params_rate(params)); |
| 765 | 766 | ||
| 766 | switch (params_width(params)) { | 767 | switch (params_width(params)) { |
| @@ -779,8 +780,8 @@ static int aic31xx_hw_params(struct snd_pcm_substream *substream, | |||
| 779 | AIC31XX_IFACE1_DATALEN_SHIFT); | 780 | AIC31XX_IFACE1_DATALEN_SHIFT); |
| 780 | break; | 781 | break; |
| 781 | default: | 782 | default: |
| 782 | dev_err(codec->dev, "%s: Unsupported format %d\n", | 783 | dev_err(codec->dev, "%s: Unsupported width %d\n", |
| 783 | __func__, params_format(params)); | 784 | __func__, params_width(params)); |
| 784 | return -EINVAL; | 785 | return -EINVAL; |
| 785 | } | 786 | } |
| 786 | 787 | ||
| @@ -1178,7 +1179,7 @@ static void aic31xx_pdata_from_of(struct aic31xx_priv *aic31xx) | |||
| 1178 | } | 1179 | } |
| 1179 | #endif /* CONFIG_OF */ | 1180 | #endif /* CONFIG_OF */ |
| 1180 | 1181 | ||
| 1181 | static void aic31xx_device_init(struct aic31xx_priv *aic31xx) | 1182 | static int aic31xx_device_init(struct aic31xx_priv *aic31xx) |
| 1182 | { | 1183 | { |
| 1183 | int ret, i; | 1184 | int ret, i; |
| 1184 | 1185 | ||
| @@ -1197,7 +1198,7 @@ static void aic31xx_device_init(struct aic31xx_priv *aic31xx) | |||
| 1197 | "aic31xx-reset-pin"); | 1198 | "aic31xx-reset-pin"); |
| 1198 | if (ret < 0) { | 1199 | if (ret < 0) { |
| 1199 | dev_err(aic31xx->dev, "not able to acquire gpio\n"); | 1200 | dev_err(aic31xx->dev, "not able to acquire gpio\n"); |
| 1200 | return; | 1201 | return ret; |
| 1201 | } | 1202 | } |
| 1202 | } | 1203 | } |
| 1203 | 1204 | ||
| @@ -1210,6 +1211,7 @@ static void aic31xx_device_init(struct aic31xx_priv *aic31xx) | |||
| 1210 | if (ret != 0) | 1211 | if (ret != 0) |
| 1211 | dev_err(aic31xx->dev, "Failed to request supplies: %d\n", ret); | 1212 | dev_err(aic31xx->dev, "Failed to request supplies: %d\n", ret); |
| 1212 | 1213 | ||
| 1214 | return ret; | ||
| 1213 | } | 1215 | } |
| 1214 | 1216 | ||
| 1215 | static int aic31xx_i2c_probe(struct i2c_client *i2c, | 1217 | static int aic31xx_i2c_probe(struct i2c_client *i2c, |
| @@ -1239,7 +1241,9 @@ static int aic31xx_i2c_probe(struct i2c_client *i2c, | |||
| 1239 | 1241 | ||
| 1240 | aic31xx->pdata.codec_type = id->driver_data; | 1242 | aic31xx->pdata.codec_type = id->driver_data; |
| 1241 | 1243 | ||
| 1242 | aic31xx_device_init(aic31xx); | 1244 | ret = aic31xx_device_init(aic31xx); |
| 1245 | if (ret) | ||
| 1246 | return ret; | ||
| 1243 | 1247 | ||
| 1244 | return snd_soc_register_codec(&i2c->dev, &soc_codec_driver_aic31xx, | 1248 | return snd_soc_register_codec(&i2c->dev, &soc_codec_driver_aic31xx, |
| 1245 | aic31xx_dai_driver, | 1249 | aic31xx_dai_driver, |
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 1d9b117345a3..6ea662db2410 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c | |||
| @@ -450,16 +450,16 @@ static int aic32x4_hw_params(struct snd_pcm_substream *substream, | |||
| 450 | 450 | ||
| 451 | data = snd_soc_read(codec, AIC32X4_IFACE1); | 451 | data = snd_soc_read(codec, AIC32X4_IFACE1); |
| 452 | data = data & ~(3 << 4); | 452 | data = data & ~(3 << 4); |
| 453 | switch (params_format(params)) { | 453 | switch (params_width(params)) { |
| 454 | case SNDRV_PCM_FORMAT_S16_LE: | 454 | case 16: |
| 455 | break; | 455 | break; |
| 456 | case SNDRV_PCM_FORMAT_S20_3LE: | 456 | case 20: |
| 457 | data |= (AIC32X4_WORD_LEN_20BITS << AIC32X4_DOSRMSB_SHIFT); | 457 | data |= (AIC32X4_WORD_LEN_20BITS << AIC32X4_DOSRMSB_SHIFT); |
| 458 | break; | 458 | break; |
| 459 | case SNDRV_PCM_FORMAT_S24_LE: | 459 | case 24: |
| 460 | data |= (AIC32X4_WORD_LEN_24BITS << AIC32X4_DOSRMSB_SHIFT); | 460 | data |= (AIC32X4_WORD_LEN_24BITS << AIC32X4_DOSRMSB_SHIFT); |
| 461 | break; | 461 | break; |
| 462 | case SNDRV_PCM_FORMAT_S32_LE: | 462 | case 32: |
| 463 | data |= (AIC32X4_WORD_LEN_32BITS << AIC32X4_DOSRMSB_SHIFT); | 463 | data |= (AIC32X4_WORD_LEN_32BITS << AIC32X4_DOSRMSB_SHIFT); |
| 464 | break; | 464 | break; |
| 465 | } | 465 | } |
| @@ -626,32 +626,33 @@ static int aic32x4_probe(struct snd_soc_codec *codec) | |||
| 626 | snd_soc_write(codec, AIC32X4_MICBIAS, AIC32X4_MICBIAS_LDOIN | | 626 | snd_soc_write(codec, AIC32X4_MICBIAS, AIC32X4_MICBIAS_LDOIN | |
| 627 | AIC32X4_MICBIAS_2075V); | 627 | AIC32X4_MICBIAS_2075V); |
| 628 | } | 628 | } |
| 629 | if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE) { | 629 | if (aic32x4->power_cfg & AIC32X4_PWR_AVDD_DVDD_WEAK_DISABLE) |
| 630 | snd_soc_write(codec, AIC32X4_PWRCFG, AIC32X4_AVDDWEAKDISABLE); | 630 | snd_soc_write(codec, AIC32X4_PWRCFG, AIC32X4_AVDDWEAKDISABLE); |
| 631 | } | ||
| 632 | 631 | ||
| 633 | tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ? | 632 | tmp_reg = (aic32x4->power_cfg & AIC32X4_PWR_AIC32X4_LDO_ENABLE) ? |
| 634 | AIC32X4_LDOCTLEN : 0; | 633 | AIC32X4_LDOCTLEN : 0; |
| 635 | snd_soc_write(codec, AIC32X4_LDOCTL, tmp_reg); | 634 | snd_soc_write(codec, AIC32X4_LDOCTL, tmp_reg); |
| 636 | 635 | ||
| 637 | tmp_reg = snd_soc_read(codec, AIC32X4_CMMODE); | 636 | tmp_reg = snd_soc_read(codec, AIC32X4_CMMODE); |
| 638 | if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36) { | 637 | if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_LDOIN_RANGE_18_36) |
| 639 | tmp_reg |= AIC32X4_LDOIN_18_36; | 638 | tmp_reg |= AIC32X4_LDOIN_18_36; |
| 640 | } | 639 | if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED) |
| 641 | if (aic32x4->power_cfg & AIC32X4_PWR_CMMODE_HP_LDOIN_POWERED) { | ||
| 642 | tmp_reg |= AIC32X4_LDOIN2HP; | 640 | tmp_reg |= AIC32X4_LDOIN2HP; |
| 643 | } | ||
| 644 | snd_soc_write(codec, AIC32X4_CMMODE, tmp_reg); | 641 | snd_soc_write(codec, AIC32X4_CMMODE, tmp_reg); |
| 645 | 642 | ||
| 646 | /* Mic PGA routing */ | 643 | /* Mic PGA routing */ |
| 647 | if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K) | 644 | if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_LMIC_IN2R_10K) |
| 648 | snd_soc_write(codec, AIC32X4_LMICPGANIN, AIC32X4_LMICPGANIN_IN2R_10K); | 645 | snd_soc_write(codec, AIC32X4_LMICPGANIN, |
| 646 | AIC32X4_LMICPGANIN_IN2R_10K); | ||
| 649 | else | 647 | else |
| 650 | snd_soc_write(codec, AIC32X4_LMICPGANIN, AIC32X4_LMICPGANIN_CM1L_10K); | 648 | snd_soc_write(codec, AIC32X4_LMICPGANIN, |
| 649 | AIC32X4_LMICPGANIN_CM1L_10K); | ||
| 651 | if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K) | 650 | if (aic32x4->micpga_routing & AIC32X4_MICPGA_ROUTE_RMIC_IN1L_10K) |
| 652 | snd_soc_write(codec, AIC32X4_RMICPGANIN, AIC32X4_RMICPGANIN_IN1L_10K); | 651 | snd_soc_write(codec, AIC32X4_RMICPGANIN, |
| 652 | AIC32X4_RMICPGANIN_IN1L_10K); | ||
| 653 | else | 653 | else |
| 654 | snd_soc_write(codec, AIC32X4_RMICPGANIN, AIC32X4_RMICPGANIN_CM1R_10K); | 654 | snd_soc_write(codec, AIC32X4_RMICPGANIN, |
| 655 | AIC32X4_RMICPGANIN_CM1R_10K); | ||
| 655 | 656 | ||
| 656 | aic32x4_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 657 | aic32x4_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 657 | 658 | ||
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index e12fafbb1e09..64f179ee9834 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
| @@ -873,16 +873,16 @@ static int aic3x_hw_params(struct snd_pcm_substream *substream, | |||
| 873 | 873 | ||
| 874 | /* select data word length */ | 874 | /* select data word length */ |
| 875 | data = snd_soc_read(codec, AIC3X_ASD_INTF_CTRLB) & (~(0x3 << 4)); | 875 | data = snd_soc_read(codec, AIC3X_ASD_INTF_CTRLB) & (~(0x3 << 4)); |
| 876 | switch (params_format(params)) { | 876 | switch (params_width(params)) { |
| 877 | case SNDRV_PCM_FORMAT_S16_LE: | 877 | case 16: |
| 878 | break; | 878 | break; |
| 879 | case SNDRV_PCM_FORMAT_S20_3LE: | 879 | case 20: |
| 880 | data |= (0x01 << 4); | 880 | data |= (0x01 << 4); |
| 881 | break; | 881 | break; |
| 882 | case SNDRV_PCM_FORMAT_S24_LE: | 882 | case 24: |
| 883 | data |= (0x02 << 4); | 883 | data |= (0x02 << 4); |
| 884 | break; | 884 | break; |
| 885 | case SNDRV_PCM_FORMAT_S32_LE: | 885 | case 32: |
| 886 | data |= (0x03 << 4); | 886 | data |= (0x03 << 4); |
| 887 | break; | 887 | break; |
| 888 | } | 888 | } |
| @@ -1194,7 +1194,8 @@ static int aic3x_set_bias_level(struct snd_soc_codec *codec, | |||
| 1194 | 1194 | ||
| 1195 | #define AIC3X_RATES SNDRV_PCM_RATE_8000_96000 | 1195 | #define AIC3X_RATES SNDRV_PCM_RATE_8000_96000 |
| 1196 | #define AIC3X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ | 1196 | #define AIC3X_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S20_3LE | \ |
| 1197 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S32_LE) | 1197 | SNDRV_PCM_FMTBIT_S24_3LE | SNDRV_PCM_FMTBIT_S24_LE | \ |
| 1198 | SNDRV_PCM_FMTBIT_S32_LE) | ||
| 1198 | 1199 | ||
| 1199 | static const struct snd_soc_dai_ops aic3x_dai_ops = { | 1200 | static const struct snd_soc_dai_ops aic3x_dai_ops = { |
| 1200 | .hw_params = aic3x_hw_params, | 1201 | .hw_params = aic3x_hw_params, |
| @@ -1477,10 +1478,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1477 | u32 value; | 1478 | u32 value; |
| 1478 | 1479 | ||
| 1479 | aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); | 1480 | aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); |
| 1480 | if (aic3x == NULL) { | 1481 | if (!aic3x) |
| 1481 | dev_err(&i2c->dev, "failed to create private data\n"); | ||
| 1482 | return -ENOMEM; | 1482 | return -ENOMEM; |
| 1483 | } | ||
| 1484 | 1483 | ||
| 1485 | aic3x->regmap = devm_regmap_init_i2c(i2c, &aic3x_regmap); | 1484 | aic3x->regmap = devm_regmap_init_i2c(i2c, &aic3x_regmap); |
| 1486 | if (IS_ERR(aic3x->regmap)) { | 1485 | if (IS_ERR(aic3x->regmap)) { |
| @@ -1498,10 +1497,8 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1498 | } else if (np) { | 1497 | } else if (np) { |
| 1499 | ai3x_setup = devm_kzalloc(&i2c->dev, sizeof(*ai3x_setup), | 1498 | ai3x_setup = devm_kzalloc(&i2c->dev, sizeof(*ai3x_setup), |
| 1500 | GFP_KERNEL); | 1499 | GFP_KERNEL); |
| 1501 | if (ai3x_setup == NULL) { | 1500 | if (!ai3x_setup) |
| 1502 | dev_err(&i2c->dev, "failed to create private data\n"); | ||
| 1503 | return -ENOMEM; | 1501 | return -ENOMEM; |
| 1504 | } | ||
| 1505 | 1502 | ||
| 1506 | ret = of_get_named_gpio(np, "gpio-reset", 0); | 1503 | ret = of_get_named_gpio(np, "gpio-reset", 0); |
| 1507 | if (ret >= 0) | 1504 | if (ret >= 0) |
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index df3a7506c023..e21ed934bdbf 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c | |||
| @@ -832,18 +832,18 @@ static int dac33_hw_params(struct snd_pcm_substream *substream, | |||
| 832 | return -EINVAL; | 832 | return -EINVAL; |
| 833 | } | 833 | } |
| 834 | 834 | ||
| 835 | switch (params_format(params)) { | 835 | switch (params_width(params)) { |
| 836 | case SNDRV_PCM_FORMAT_S16_LE: | 836 | case 16: |
| 837 | dac33->fifo_size = DAC33_FIFO_SIZE_16BIT; | 837 | dac33->fifo_size = DAC33_FIFO_SIZE_16BIT; |
| 838 | dac33->burst_rate = CALC_BURST_RATE(dac33->burst_bclkdiv, 32); | 838 | dac33->burst_rate = CALC_BURST_RATE(dac33->burst_bclkdiv, 32); |
| 839 | break; | 839 | break; |
| 840 | case SNDRV_PCM_FORMAT_S32_LE: | 840 | case 32: |
| 841 | dac33->fifo_size = DAC33_FIFO_SIZE_24BIT; | 841 | dac33->fifo_size = DAC33_FIFO_SIZE_24BIT; |
| 842 | dac33->burst_rate = CALC_BURST_RATE(dac33->burst_bclkdiv, 64); | 842 | dac33->burst_rate = CALC_BURST_RATE(dac33->burst_bclkdiv, 64); |
| 843 | break; | 843 | break; |
| 844 | default: | 844 | default: |
| 845 | dev_err(codec->dev, "unsupported format %d\n", | 845 | dev_err(codec->dev, "unsupported width %d\n", |
| 846 | params_format(params)); | 846 | params_width(params)); |
| 847 | return -EINVAL; | 847 | return -EINVAL; |
| 848 | } | 848 | } |
| 849 | 849 | ||
| @@ -1404,7 +1404,7 @@ static int dac33_soc_probe(struct snd_soc_codec *codec) | |||
| 1404 | if (dac33->irq >= 0) { | 1404 | if (dac33->irq >= 0) { |
| 1405 | ret = request_irq(dac33->irq, dac33_interrupt_handler, | 1405 | ret = request_irq(dac33->irq, dac33_interrupt_handler, |
| 1406 | IRQF_TRIGGER_RISING, | 1406 | IRQF_TRIGGER_RISING, |
| 1407 | codec->name, codec); | 1407 | codec->component.name, codec); |
| 1408 | if (ret < 0) { | 1408 | if (ret < 0) { |
| 1409 | dev_err(codec->dev, "Could not request IRQ%d (%d)\n", | 1409 | dev_err(codec->dev, "Could not request IRQ%d (%d)\n", |
| 1410 | dac33->irq, ret); | 1410 | dac33->irq, ret); |
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 8fc5a647453b..6fac9e034c48 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
| @@ -381,10 +381,8 @@ static int tpa6130a2_probe(struct i2c_client *client, | |||
| 381 | dev = &client->dev; | 381 | dev = &client->dev; |
| 382 | 382 | ||
| 383 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); | 383 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); |
| 384 | if (data == NULL) { | 384 | if (!data) |
| 385 | dev_err(dev, "Can not allocate memory\n"); | ||
| 386 | return -ENOMEM; | 385 | return -ENOMEM; |
| 387 | } | ||
| 388 | 386 | ||
| 389 | if (pdata) { | 387 | if (pdata) { |
| 390 | data->power_gpio = pdata->power_gpio; | 388 | data->power_gpio = pdata->power_gpio; |
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 69e12a311ba2..b6b0cb399599 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
| @@ -344,17 +344,16 @@ static void twl4030_init_chip(struct snd_soc_codec *codec) | |||
| 344 | static void twl4030_apll_enable(struct snd_soc_codec *codec, int enable) | 344 | static void twl4030_apll_enable(struct snd_soc_codec *codec, int enable) |
| 345 | { | 345 | { |
| 346 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); | 346 | struct twl4030_priv *twl4030 = snd_soc_codec_get_drvdata(codec); |
| 347 | int status = -1; | ||
| 348 | 347 | ||
| 349 | if (enable) { | 348 | if (enable) { |
| 350 | twl4030->apll_enabled++; | 349 | twl4030->apll_enabled++; |
| 351 | if (twl4030->apll_enabled == 1) | 350 | if (twl4030->apll_enabled == 1) |
| 352 | status = twl4030_audio_enable_resource( | 351 | twl4030_audio_enable_resource( |
| 353 | TWL4030_AUDIO_RES_APLL); | 352 | TWL4030_AUDIO_RES_APLL); |
| 354 | } else { | 353 | } else { |
| 355 | twl4030->apll_enabled--; | 354 | twl4030->apll_enabled--; |
| 356 | if (!twl4030->apll_enabled) | 355 | if (!twl4030->apll_enabled) |
| 357 | status = twl4030_audio_disable_resource( | 356 | twl4030_audio_disable_resource( |
| 358 | TWL4030_AUDIO_RES_APLL); | 357 | TWL4030_AUDIO_RES_APLL); |
| 359 | } | 358 | } |
| 360 | } | 359 | } |
| @@ -1764,16 +1763,16 @@ static int twl4030_hw_params(struct snd_pcm_substream *substream, | |||
| 1764 | old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); | 1763 | old_format = twl4030_read(codec, TWL4030_REG_AUDIO_IF); |
| 1765 | format = old_format; | 1764 | format = old_format; |
| 1766 | format &= ~TWL4030_DATA_WIDTH; | 1765 | format &= ~TWL4030_DATA_WIDTH; |
| 1767 | switch (params_format(params)) { | 1766 | switch (params_width(params)) { |
| 1768 | case SNDRV_PCM_FORMAT_S16_LE: | 1767 | case 16: |
| 1769 | format |= TWL4030_DATA_WIDTH_16S_16W; | 1768 | format |= TWL4030_DATA_WIDTH_16S_16W; |
| 1770 | break; | 1769 | break; |
| 1771 | case SNDRV_PCM_FORMAT_S32_LE: | 1770 | case 32: |
| 1772 | format |= TWL4030_DATA_WIDTH_32S_24W; | 1771 | format |= TWL4030_DATA_WIDTH_32S_24W; |
| 1773 | break; | 1772 | break; |
| 1774 | default: | 1773 | default: |
| 1775 | dev_err(codec->dev, "%s: unknown format %d\n", __func__, | 1774 | dev_err(codec->dev, "%s: unsupported bits/sample %d\n", |
| 1776 | params_format(params)); | 1775 | __func__, params_width(params)); |
| 1777 | return -EINVAL; | 1776 | return -EINVAL; |
| 1778 | } | 1777 | } |
| 1779 | 1778 | ||
| @@ -2162,10 +2161,8 @@ static int twl4030_soc_probe(struct snd_soc_codec *codec) | |||
| 2162 | 2161 | ||
| 2163 | twl4030 = devm_kzalloc(codec->dev, sizeof(struct twl4030_priv), | 2162 | twl4030 = devm_kzalloc(codec->dev, sizeof(struct twl4030_priv), |
| 2164 | GFP_KERNEL); | 2163 | GFP_KERNEL); |
| 2165 | if (twl4030 == NULL) { | 2164 | if (!twl4030) |
| 2166 | dev_err(codec->dev, "Can not allocate memory\n"); | ||
| 2167 | return -ENOMEM; | 2165 | return -ENOMEM; |
| 2168 | } | ||
| 2169 | snd_soc_codec_set_drvdata(codec, twl4030); | 2166 | snd_soc_codec_set_drvdata(codec, twl4030); |
| 2170 | /* Set the defaults, and power up the codec */ | 2167 | /* Set the defaults, and power up the codec */ |
| 2171 | twl4030->sysclk = twl4030_audio_get_mclk() / 1000; | 2168 | twl4030->sysclk = twl4030_audio_get_mclk() / 1000; |
diff --git a/sound/soc/codecs/uda134x.c b/sound/soc/codecs/uda134x.c index edf27acc1d77..32b2f78aa62c 100644 --- a/sound/soc/codecs/uda134x.c +++ b/sound/soc/codecs/uda134x.c | |||
| @@ -243,14 +243,14 @@ static int uda134x_hw_params(struct snd_pcm_substream *substream, | |||
| 243 | case SND_SOC_DAIFMT_I2S: | 243 | case SND_SOC_DAIFMT_I2S: |
| 244 | break; | 244 | break; |
| 245 | case SND_SOC_DAIFMT_RIGHT_J: | 245 | case SND_SOC_DAIFMT_RIGHT_J: |
| 246 | switch (params_format(params)) { | 246 | switch (params_width(params)) { |
| 247 | case SNDRV_PCM_FORMAT_S16_LE: | 247 | case 16: |
| 248 | hw_params |= (1<<1); | 248 | hw_params |= (1<<1); |
| 249 | break; | 249 | break; |
| 250 | case SNDRV_PCM_FORMAT_S18_3LE: | 250 | case 18: |
| 251 | hw_params |= (1<<2); | 251 | hw_params |= (1<<2); |
| 252 | break; | 252 | break; |
| 253 | case SNDRV_PCM_FORMAT_S20_3LE: | 253 | case 20: |
| 254 | hw_params |= ((1<<2) | (1<<1)); | 254 | hw_params |= ((1<<2) | (1<<1)); |
| 255 | break; | 255 | break; |
| 256 | default: | 256 | default: |
| @@ -479,7 +479,7 @@ static struct snd_soc_dai_driver uda134x_dai = { | |||
| 479 | static int uda134x_soc_probe(struct snd_soc_codec *codec) | 479 | static int uda134x_soc_probe(struct snd_soc_codec *codec) |
| 480 | { | 480 | { |
| 481 | struct uda134x_priv *uda134x; | 481 | struct uda134x_priv *uda134x; |
| 482 | struct uda134x_platform_data *pd = codec->card->dev->platform_data; | 482 | struct uda134x_platform_data *pd = codec->component.card->dev->platform_data; |
| 483 | const struct snd_soc_dapm_widget *widgets; | 483 | const struct snd_soc_dapm_widget *widgets; |
| 484 | unsigned num_widgets; | 484 | unsigned num_widgets; |
| 485 | 485 | ||
diff --git a/sound/soc/codecs/wl1273.c b/sound/soc/codecs/wl1273.c index 4ead0dc02b87..f3d4e88d0b7b 100644 --- a/sound/soc/codecs/wl1273.c +++ b/sound/soc/codecs/wl1273.c | |||
| @@ -341,8 +341,9 @@ static int wl1273_hw_params(struct snd_pcm_substream *substream, | |||
| 341 | struct wl1273_core *core = wl1273->core; | 341 | struct wl1273_core *core = wl1273->core; |
| 342 | unsigned int rate, width, r; | 342 | unsigned int rate, width, r; |
| 343 | 343 | ||
| 344 | if (params_format(params) != SNDRV_PCM_FORMAT_S16_LE) { | 344 | if (params_width(params) != 16) { |
| 345 | pr_err("Only SNDRV_PCM_FORMAT_S16_LE supported.\n"); | 345 | dev_err(dai->dev, "%d bits/sample not supported\n", |
| 346 | params_width(params)); | ||
| 346 | return -EINVAL; | 347 | return -EINVAL; |
| 347 | } | 348 | } |
| 348 | 349 | ||
| @@ -461,10 +462,8 @@ static int wl1273_probe(struct snd_soc_codec *codec) | |||
| 461 | } | 462 | } |
| 462 | 463 | ||
| 463 | wl1273 = kzalloc(sizeof(struct wl1273_priv), GFP_KERNEL); | 464 | wl1273 = kzalloc(sizeof(struct wl1273_priv), GFP_KERNEL); |
| 464 | if (wl1273 == NULL) { | 465 | if (!wl1273) |
| 465 | dev_err(codec->dev, "Cannot allocate memory.\n"); | ||
| 466 | return -ENOMEM; | 466 | return -ENOMEM; |
| 467 | } | ||
| 468 | 467 | ||
| 469 | wl1273->mode = WL1273_MODE_BT; | 468 | wl1273->mode = WL1273_MODE_BT; |
| 470 | wl1273->core = *core; | 469 | wl1273->core = *core; |
diff --git a/sound/soc/codecs/wm0010.c b/sound/soc/codecs/wm0010.c index 71ce3159a62e..f37989ec7cba 100644 --- a/sound/soc/codecs/wm0010.c +++ b/sound/soc/codecs/wm0010.c | |||
| @@ -144,7 +144,7 @@ static const struct snd_soc_dapm_route wm0010_dapm_routes[] = { | |||
| 144 | 144 | ||
| 145 | static const char *wm0010_state_to_str(enum wm0010_state state) | 145 | static const char *wm0010_state_to_str(enum wm0010_state state) |
| 146 | { | 146 | { |
| 147 | const char *state_to_str[] = { | 147 | static const char * const state_to_str[] = { |
| 148 | "Power off", | 148 | "Power off", |
| 149 | "Out of reset", | 149 | "Out of reset", |
| 150 | "Boot ROM", | 150 | "Boot ROM", |
| @@ -413,7 +413,6 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) | |||
| 413 | 413 | ||
| 414 | xfer = kzalloc(sizeof(*xfer), GFP_KERNEL); | 414 | xfer = kzalloc(sizeof(*xfer), GFP_KERNEL); |
| 415 | if (!xfer) { | 415 | if (!xfer) { |
| 416 | dev_err(codec->dev, "Failed to allocate xfer\n"); | ||
| 417 | ret = -ENOMEM; | 416 | ret = -ENOMEM; |
| 418 | goto abort; | 417 | goto abort; |
| 419 | } | 418 | } |
| @@ -423,8 +422,6 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) | |||
| 423 | 422 | ||
| 424 | out = kzalloc(len, GFP_KERNEL | GFP_DMA); | 423 | out = kzalloc(len, GFP_KERNEL | GFP_DMA); |
| 425 | if (!out) { | 424 | if (!out) { |
| 426 | dev_err(codec->dev, | ||
| 427 | "Failed to allocate RX buffer\n"); | ||
| 428 | ret = -ENOMEM; | 425 | ret = -ENOMEM; |
| 429 | goto abort1; | 426 | goto abort1; |
| 430 | } | 427 | } |
| @@ -432,8 +429,6 @@ static int wm0010_firmware_load(const char *name, struct snd_soc_codec *codec) | |||
| 432 | 429 | ||
| 433 | img = kzalloc(len, GFP_KERNEL | GFP_DMA); | 430 | img = kzalloc(len, GFP_KERNEL | GFP_DMA); |
| 434 | if (!img) { | 431 | if (!img) { |
| 435 | dev_err(codec->dev, | ||
| 436 | "Failed to allocate image buffer\n"); | ||
| 437 | ret = -ENOMEM; | 432 | ret = -ENOMEM; |
| 438 | goto abort1; | 433 | goto abort1; |
| 439 | } | 434 | } |
| @@ -526,14 +521,12 @@ static int wm0010_stage2_load(struct snd_soc_codec *codec) | |||
| 526 | /* Copy to local buffer first as vmalloc causes problems for dma */ | 521 | /* Copy to local buffer first as vmalloc causes problems for dma */ |
| 527 | img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); | 522 | img = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); |
| 528 | if (!img) { | 523 | if (!img) { |
| 529 | dev_err(codec->dev, "Failed to allocate image buffer\n"); | ||
| 530 | ret = -ENOMEM; | 524 | ret = -ENOMEM; |
| 531 | goto abort2; | 525 | goto abort2; |
| 532 | } | 526 | } |
| 533 | 527 | ||
| 534 | out = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); | 528 | out = kzalloc(fw->size, GFP_KERNEL | GFP_DMA); |
| 535 | if (!out) { | 529 | if (!out) { |
| 536 | dev_err(codec->dev, "Failed to allocate output buffer\n"); | ||
| 537 | ret = -ENOMEM; | 530 | ret = -ENOMEM; |
| 538 | goto abort1; | 531 | goto abort1; |
| 539 | } | 532 | } |
| @@ -679,11 +672,8 @@ static int wm0010_boot(struct snd_soc_codec *codec) | |||
| 679 | } | 672 | } |
| 680 | 673 | ||
| 681 | img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA); | 674 | img_swap = kzalloc(len, GFP_KERNEL | GFP_DMA); |
| 682 | if (!img_swap) { | 675 | if (!img_swap) |
| 683 | dev_err(codec->dev, | ||
| 684 | "Failed to allocate image buffer\n"); | ||
| 685 | goto abort; | 676 | goto abort; |
| 686 | } | ||
| 687 | 677 | ||
| 688 | /* We need to re-order for 0010 */ | 678 | /* We need to re-order for 0010 */ |
| 689 | byte_swap_64((u64 *)&pll_rec, img_swap, len); | 679 | byte_swap_64((u64 *)&pll_rec, img_swap, len); |
diff --git a/sound/soc/codecs/wm1250-ev1.c b/sound/soc/codecs/wm1250-ev1.c index 6e6b93d4696e..8011f75fb6cb 100644 --- a/sound/soc/codecs/wm1250-ev1.c +++ b/sound/soc/codecs/wm1250-ev1.c | |||
| @@ -164,7 +164,6 @@ static int wm1250_ev1_pdata(struct i2c_client *i2c) | |||
| 164 | 164 | ||
| 165 | wm1250 = devm_kzalloc(&i2c->dev, sizeof(*wm1250), GFP_KERNEL); | 165 | wm1250 = devm_kzalloc(&i2c->dev, sizeof(*wm1250), GFP_KERNEL); |
| 166 | if (!wm1250) { | 166 | if (!wm1250) { |
| 167 | dev_err(&i2c->dev, "Unable to allocate private data\n"); | ||
| 168 | ret = -ENOMEM; | 167 | ret = -ENOMEM; |
| 169 | goto err; | 168 | goto err; |
| 170 | } | 169 | } |
diff --git a/sound/soc/codecs/wm2000.c b/sound/soc/codecs/wm2000.c index a4c352cc3464..34ef65c52a7d 100644 --- a/sound/soc/codecs/wm2000.c +++ b/sound/soc/codecs/wm2000.c | |||
| @@ -826,10 +826,8 @@ static int wm2000_i2c_probe(struct i2c_client *i2c, | |||
| 826 | 826 | ||
| 827 | wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv), | 827 | wm2000 = devm_kzalloc(&i2c->dev, sizeof(struct wm2000_priv), |
| 828 | GFP_KERNEL); | 828 | GFP_KERNEL); |
| 829 | if (wm2000 == NULL) { | 829 | if (!wm2000) |
| 830 | dev_err(&i2c->dev, "Unable to allocate private data\n"); | ||
| 831 | return -ENOMEM; | 830 | return -ENOMEM; |
| 832 | } | ||
| 833 | 831 | ||
| 834 | mutex_init(&wm2000->lock); | 832 | mutex_init(&wm2000->lock); |
| 835 | 833 | ||
diff --git a/sound/soc/codecs/wm5100.c b/sound/soc/codecs/wm5100.c index 91a9ea2a2056..7bb0d36d4c54 100644 --- a/sound/soc/codecs/wm5100.c +++ b/sound/soc/codecs/wm5100.c | |||
| @@ -735,8 +735,7 @@ WM5100_MIXER_CONTROLS("LHPF4", WM5100_HPLP4MIX_INPUT_1_SOURCE), | |||
| 735 | static void wm5100_seq_notifier(struct snd_soc_dapm_context *dapm, | 735 | static void wm5100_seq_notifier(struct snd_soc_dapm_context *dapm, |
| 736 | enum snd_soc_dapm_type event, int subseq) | 736 | enum snd_soc_dapm_type event, int subseq) |
| 737 | { | 737 | { |
| 738 | struct snd_soc_codec *codec = container_of(dapm, | 738 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); |
| 739 | struct snd_soc_codec, dapm); | ||
| 740 | struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); | 739 | struct wm5100_priv *wm5100 = snd_soc_codec_get_drvdata(codec); |
| 741 | u16 val, expect, i; | 740 | u16 val, expect, i; |
| 742 | 741 | ||
diff --git a/sound/soc/codecs/wm5102.c b/sound/soc/codecs/wm5102.c index 289b64d89abd..f60234962527 100644 --- a/sound/soc/codecs/wm5102.c +++ b/sound/soc/codecs/wm5102.c | |||
| @@ -612,6 +612,62 @@ static int wm5102_sysclk_ev(struct snd_soc_dapm_widget *w, | |||
| 612 | return 0; | 612 | return 0; |
| 613 | } | 613 | } |
| 614 | 614 | ||
| 615 | static int wm5102_out_comp_coeff_get(struct snd_kcontrol *kcontrol, | ||
| 616 | struct snd_ctl_elem_value *ucontrol) | ||
| 617 | { | ||
| 618 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
| 619 | struct arizona *arizona = dev_get_drvdata(codec->dev->parent); | ||
| 620 | uint16_t data; | ||
| 621 | |||
| 622 | mutex_lock(&codec->mutex); | ||
| 623 | data = cpu_to_be16(arizona->dac_comp_coeff); | ||
| 624 | memcpy(ucontrol->value.bytes.data, &data, sizeof(data)); | ||
| 625 | mutex_unlock(&codec->mutex); | ||
| 626 | |||
| 627 | return 0; | ||
| 628 | } | ||
| 629 | |||
| 630 | static int wm5102_out_comp_coeff_put(struct snd_kcontrol *kcontrol, | ||
| 631 | struct snd_ctl_elem_value *ucontrol) | ||
| 632 | { | ||
| 633 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
| 634 | struct arizona *arizona = dev_get_drvdata(codec->dev->parent); | ||
| 635 | |||
| 636 | mutex_lock(&codec->mutex); | ||
| 637 | memcpy(&arizona->dac_comp_coeff, ucontrol->value.bytes.data, | ||
| 638 | sizeof(arizona->dac_comp_coeff)); | ||
| 639 | arizona->dac_comp_coeff = be16_to_cpu(arizona->dac_comp_coeff); | ||
| 640 | mutex_unlock(&codec->mutex); | ||
| 641 | |||
| 642 | return 0; | ||
| 643 | } | ||
| 644 | |||
| 645 | static int wm5102_out_comp_switch_get(struct snd_kcontrol *kcontrol, | ||
| 646 | struct snd_ctl_elem_value *ucontrol) | ||
| 647 | { | ||
| 648 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
| 649 | struct arizona *arizona = dev_get_drvdata(codec->dev->parent); | ||
| 650 | |||
| 651 | mutex_lock(&codec->mutex); | ||
| 652 | ucontrol->value.integer.value[0] = arizona->dac_comp_enabled; | ||
| 653 | mutex_unlock(&codec->mutex); | ||
| 654 | |||
| 655 | return 0; | ||
| 656 | } | ||
| 657 | |||
| 658 | static int wm5102_out_comp_switch_put(struct snd_kcontrol *kcontrol, | ||
| 659 | struct snd_ctl_elem_value *ucontrol) | ||
| 660 | { | ||
| 661 | struct snd_soc_codec *codec = snd_soc_kcontrol_codec(kcontrol); | ||
| 662 | struct arizona *arizona = dev_get_drvdata(codec->dev->parent); | ||
| 663 | |||
| 664 | mutex_lock(&codec->mutex); | ||
| 665 | arizona->dac_comp_enabled = ucontrol->value.integer.value[0]; | ||
| 666 | mutex_unlock(&codec->mutex); | ||
| 667 | |||
| 668 | return 0; | ||
| 669 | } | ||
| 670 | |||
| 615 | static const char *wm5102_osr_text[] = { | 671 | static const char *wm5102_osr_text[] = { |
| 616 | "Low power", "Normal", "High performance", | 672 | "Low power", "Normal", "High performance", |
| 617 | }; | 673 | }; |
| @@ -843,6 +899,12 @@ SOC_SINGLE_TLV("Noise Gate Threshold Volume", ARIZONA_NOISE_GATE_CONTROL, | |||
| 843 | ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv), | 899 | ARIZONA_NGATE_THR_SHIFT, 7, 1, ng_tlv), |
| 844 | SOC_ENUM("Noise Gate Hold", arizona_ng_hold), | 900 | SOC_ENUM("Noise Gate Hold", arizona_ng_hold), |
| 845 | 901 | ||
| 902 | SND_SOC_BYTES_EXT("Output Compensation Coefficient", 2, | ||
| 903 | wm5102_out_comp_coeff_get, wm5102_out_comp_coeff_put), | ||
| 904 | |||
| 905 | SOC_SINGLE_EXT("Output Compensation Switch", 0, 0, 1, 0, | ||
| 906 | wm5102_out_comp_switch_get, wm5102_out_comp_switch_put), | ||
| 907 | |||
| 846 | WM5102_NG_SRC("HPOUT1L", ARIZONA_NOISE_GATE_SELECT_1L), | 908 | WM5102_NG_SRC("HPOUT1L", ARIZONA_NOISE_GATE_SELECT_1L), |
| 847 | WM5102_NG_SRC("HPOUT1R", ARIZONA_NOISE_GATE_SELECT_1R), | 909 | WM5102_NG_SRC("HPOUT1R", ARIZONA_NOISE_GATE_SELECT_1R), |
| 848 | WM5102_NG_SRC("HPOUT2L", ARIZONA_NOISE_GATE_SELECT_2L), | 910 | WM5102_NG_SRC("HPOUT2L", ARIZONA_NOISE_GATE_SELECT_2L), |
| @@ -1653,6 +1715,7 @@ static struct snd_soc_dai_driver wm5102_dai[] = { | |||
| 1653 | }, | 1715 | }, |
| 1654 | .ops = &arizona_dai_ops, | 1716 | .ops = &arizona_dai_ops, |
| 1655 | .symmetric_rates = 1, | 1717 | .symmetric_rates = 1, |
| 1718 | .symmetric_samplebits = 1, | ||
| 1656 | }, | 1719 | }, |
| 1657 | { | 1720 | { |
| 1658 | .name = "wm5102-aif2", | 1721 | .name = "wm5102-aif2", |
| @@ -1674,6 +1737,7 @@ static struct snd_soc_dai_driver wm5102_dai[] = { | |||
| 1674 | }, | 1737 | }, |
| 1675 | .ops = &arizona_dai_ops, | 1738 | .ops = &arizona_dai_ops, |
| 1676 | .symmetric_rates = 1, | 1739 | .symmetric_rates = 1, |
| 1740 | .symmetric_samplebits = 1, | ||
| 1677 | }, | 1741 | }, |
| 1678 | { | 1742 | { |
| 1679 | .name = "wm5102-aif3", | 1743 | .name = "wm5102-aif3", |
| @@ -1695,6 +1759,7 @@ static struct snd_soc_dai_driver wm5102_dai[] = { | |||
| 1695 | }, | 1759 | }, |
| 1696 | .ops = &arizona_dai_ops, | 1760 | .ops = &arizona_dai_ops, |
| 1697 | .symmetric_rates = 1, | 1761 | .symmetric_rates = 1, |
| 1762 | .symmetric_samplebits = 1, | ||
| 1698 | }, | 1763 | }, |
| 1699 | { | 1764 | { |
| 1700 | .name = "wm5102-slim1", | 1765 | .name = "wm5102-slim1", |
diff --git a/sound/soc/codecs/wm5110.c b/sound/soc/codecs/wm5110.c index 2e5fcb559e90..2f2ec26d831c 100644 --- a/sound/soc/codecs/wm5110.c +++ b/sound/soc/codecs/wm5110.c | |||
| @@ -1485,6 +1485,7 @@ static struct snd_soc_dai_driver wm5110_dai[] = { | |||
| 1485 | }, | 1485 | }, |
| 1486 | .ops = &arizona_dai_ops, | 1486 | .ops = &arizona_dai_ops, |
| 1487 | .symmetric_rates = 1, | 1487 | .symmetric_rates = 1, |
| 1488 | .symmetric_samplebits = 1, | ||
| 1488 | }, | 1489 | }, |
| 1489 | { | 1490 | { |
| 1490 | .name = "wm5110-aif2", | 1491 | .name = "wm5110-aif2", |
| @@ -1506,6 +1507,7 @@ static struct snd_soc_dai_driver wm5110_dai[] = { | |||
| 1506 | }, | 1507 | }, |
| 1507 | .ops = &arizona_dai_ops, | 1508 | .ops = &arizona_dai_ops, |
| 1508 | .symmetric_rates = 1, | 1509 | .symmetric_rates = 1, |
| 1510 | .symmetric_samplebits = 1, | ||
| 1509 | }, | 1511 | }, |
| 1510 | { | 1512 | { |
| 1511 | .name = "wm5110-aif3", | 1513 | .name = "wm5110-aif3", |
| @@ -1527,6 +1529,7 @@ static struct snd_soc_dai_driver wm5110_dai[] = { | |||
| 1527 | }, | 1529 | }, |
| 1528 | .ops = &arizona_dai_ops, | 1530 | .ops = &arizona_dai_ops, |
| 1529 | .symmetric_rates = 1, | 1531 | .symmetric_rates = 1, |
| 1532 | .symmetric_samplebits = 1, | ||
| 1530 | }, | 1533 | }, |
| 1531 | { | 1534 | { |
| 1532 | .name = "wm5110-slim1", | 1535 | .name = "wm5110-slim1", |
| @@ -1596,6 +1599,7 @@ static int wm5110_codec_probe(struct snd_soc_codec *codec) | |||
| 1596 | 1599 | ||
| 1597 | arizona_init_spk(codec); | 1600 | arizona_init_spk(codec); |
| 1598 | arizona_init_gpio(codec); | 1601 | arizona_init_gpio(codec); |
| 1602 | arizona_init_mono(codec); | ||
| 1599 | 1603 | ||
| 1600 | ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 8); | 1604 | ret = snd_soc_add_codec_controls(codec, wm_adsp2_fw_controls, 8); |
| 1601 | if (ret != 0) | 1605 | if (ret != 0) |
diff --git a/sound/soc/codecs/wm8350.c b/sound/soc/codecs/wm8350.c index 392285edb595..3dfdcc4197fa 100644 --- a/sound/soc/codecs/wm8350.c +++ b/sound/soc/codecs/wm8350.c | |||
| @@ -918,16 +918,16 @@ static int wm8350_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 918 | ~WM8350_AIF_WL_MASK; | 918 | ~WM8350_AIF_WL_MASK; |
| 919 | 919 | ||
| 920 | /* bit size */ | 920 | /* bit size */ |
| 921 | switch (params_format(params)) { | 921 | switch (params_width(params)) { |
| 922 | case SNDRV_PCM_FORMAT_S16_LE: | 922 | case 16: |
| 923 | break; | 923 | break; |
| 924 | case SNDRV_PCM_FORMAT_S20_3LE: | 924 | case 20: |
| 925 | iface |= 0x1 << 10; | 925 | iface |= 0x1 << 10; |
| 926 | break; | 926 | break; |
| 927 | case SNDRV_PCM_FORMAT_S24_LE: | 927 | case 24: |
| 928 | iface |= 0x2 << 10; | 928 | iface |= 0x2 << 10; |
| 929 | break; | 929 | break; |
| 930 | case SNDRV_PCM_FORMAT_S32_LE: | 930 | case 32: |
| 931 | iface |= 0x3 << 10; | 931 | iface |= 0x3 << 10; |
| 932 | break; | 932 | break; |
| 933 | } | 933 | } |
| @@ -1341,21 +1341,18 @@ int wm8350_hp_jack_detect(struct snd_soc_codec *codec, enum wm8350_jack which, | |||
| 1341 | { | 1341 | { |
| 1342 | struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); | 1342 | struct wm8350_data *priv = snd_soc_codec_get_drvdata(codec); |
| 1343 | struct wm8350 *wm8350 = priv->wm8350; | 1343 | struct wm8350 *wm8350 = priv->wm8350; |
| 1344 | int irq; | ||
| 1345 | int ena; | 1344 | int ena; |
| 1346 | 1345 | ||
| 1347 | switch (which) { | 1346 | switch (which) { |
| 1348 | case WM8350_JDL: | 1347 | case WM8350_JDL: |
| 1349 | priv->hpl.jack = jack; | 1348 | priv->hpl.jack = jack; |
| 1350 | priv->hpl.report = report; | 1349 | priv->hpl.report = report; |
| 1351 | irq = WM8350_IRQ_CODEC_JCK_DET_L; | ||
| 1352 | ena = WM8350_JDL_ENA; | 1350 | ena = WM8350_JDL_ENA; |
| 1353 | break; | 1351 | break; |
| 1354 | 1352 | ||
| 1355 | case WM8350_JDR: | 1353 | case WM8350_JDR: |
| 1356 | priv->hpr.jack = jack; | 1354 | priv->hpr.jack = jack; |
| 1357 | priv->hpr.report = report; | 1355 | priv->hpr.report = report; |
| 1358 | irq = WM8350_IRQ_CODEC_JCK_DET_R; | ||
| 1359 | ena = WM8350_JDR_ENA; | 1356 | ena = WM8350_JDR_ENA; |
| 1360 | break; | 1357 | break; |
| 1361 | 1358 | ||
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index 06e913d3fea1..72471bef2e9a 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c | |||
| @@ -1095,16 +1095,16 @@ static int wm8400_hw_params(struct snd_pcm_substream *substream, | |||
| 1095 | 1095 | ||
| 1096 | audio1 &= ~WM8400_AIF_WL_MASK; | 1096 | audio1 &= ~WM8400_AIF_WL_MASK; |
| 1097 | /* bit size */ | 1097 | /* bit size */ |
| 1098 | switch (params_format(params)) { | 1098 | switch (params_width(params)) { |
| 1099 | case SNDRV_PCM_FORMAT_S16_LE: | 1099 | case 16: |
| 1100 | break; | 1100 | break; |
| 1101 | case SNDRV_PCM_FORMAT_S20_3LE: | 1101 | case 20: |
| 1102 | audio1 |= WM8400_AIF_WL_20BITS; | 1102 | audio1 |= WM8400_AIF_WL_20BITS; |
| 1103 | break; | 1103 | break; |
| 1104 | case SNDRV_PCM_FORMAT_S24_LE: | 1104 | case 24: |
| 1105 | audio1 |= WM8400_AIF_WL_24BITS; | 1105 | audio1 |= WM8400_AIF_WL_24BITS; |
| 1106 | break; | 1106 | break; |
| 1107 | case SNDRV_PCM_FORMAT_S32_LE: | 1107 | case 32: |
| 1108 | audio1 |= WM8400_AIF_WL_32BITS; | 1108 | audio1 |= WM8400_AIF_WL_32BITS; |
| 1109 | break; | 1109 | break; |
| 1110 | } | 1110 | } |
diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c index 1c1e328feeb8..e11127f9069e 100644 --- a/sound/soc/codecs/wm8510.c +++ b/sound/soc/codecs/wm8510.c | |||
| @@ -449,16 +449,16 @@ static int wm8510_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 449 | u16 adn = snd_soc_read(codec, WM8510_ADD) & 0x1f1; | 449 | u16 adn = snd_soc_read(codec, WM8510_ADD) & 0x1f1; |
| 450 | 450 | ||
| 451 | /* bit size */ | 451 | /* bit size */ |
| 452 | switch (params_format(params)) { | 452 | switch (params_width(params)) { |
| 453 | case SNDRV_PCM_FORMAT_S16_LE: | 453 | case 16: |
| 454 | break; | 454 | break; |
| 455 | case SNDRV_PCM_FORMAT_S20_3LE: | 455 | case 20: |
| 456 | iface |= 0x0020; | 456 | iface |= 0x0020; |
| 457 | break; | 457 | break; |
| 458 | case SNDRV_PCM_FORMAT_S24_LE: | 458 | case 24: |
| 459 | iface |= 0x0040; | 459 | iface |= 0x0040; |
| 460 | break; | 460 | break; |
| 461 | case SNDRV_PCM_FORMAT_S32_LE: | 461 | case 32: |
| 462 | iface |= 0x0060; | 462 | iface |= 0x0060; |
| 463 | break; | 463 | break; |
| 464 | } | 464 | } |
diff --git a/sound/soc/codecs/wm8523.c b/sound/soc/codecs/wm8523.c index 601ee8178af1..ec1f5740dbd0 100644 --- a/sound/soc/codecs/wm8523.c +++ b/sound/soc/codecs/wm8523.c | |||
| @@ -163,16 +163,16 @@ static int wm8523_hw_params(struct snd_pcm_substream *substream, | |||
| 163 | aifctrl2 |= lrclk_ratios[i].value; | 163 | aifctrl2 |= lrclk_ratios[i].value; |
| 164 | 164 | ||
| 165 | aifctrl1 &= ~WM8523_WL_MASK; | 165 | aifctrl1 &= ~WM8523_WL_MASK; |
| 166 | switch (params_format(params)) { | 166 | switch (params_width(params)) { |
| 167 | case SNDRV_PCM_FORMAT_S16_LE: | 167 | case 16: |
| 168 | break; | 168 | break; |
| 169 | case SNDRV_PCM_FORMAT_S20_3LE: | 169 | case 20: |
| 170 | aifctrl1 |= 0x8; | 170 | aifctrl1 |= 0x8; |
| 171 | break; | 171 | break; |
| 172 | case SNDRV_PCM_FORMAT_S24_LE: | 172 | case 24: |
| 173 | aifctrl1 |= 0x10; | 173 | aifctrl1 |= 0x10; |
| 174 | break; | 174 | break; |
| 175 | case SNDRV_PCM_FORMAT_S32_LE: | 175 | case 32: |
| 176 | aifctrl1 |= 0x18; | 176 | aifctrl1 |= 0x18; |
| 177 | break; | 177 | break; |
| 178 | } | 178 | } |
diff --git a/sound/soc/codecs/wm8580.c b/sound/soc/codecs/wm8580.c index 7665ff6aea6d..911605ee25b0 100644 --- a/sound/soc/codecs/wm8580.c +++ b/sound/soc/codecs/wm8580.c | |||
| @@ -511,19 +511,19 @@ static int wm8580_paif_hw_params(struct snd_pcm_substream *substream, | |||
| 511 | int i, ratio, osr; | 511 | int i, ratio, osr; |
| 512 | 512 | ||
| 513 | /* bit size */ | 513 | /* bit size */ |
| 514 | switch (params_format(params)) { | 514 | switch (params_width(params)) { |
| 515 | case SNDRV_PCM_FORMAT_S16_LE: | 515 | case 16: |
| 516 | paifa |= 0x8; | 516 | paifa |= 0x8; |
| 517 | break; | 517 | break; |
| 518 | case SNDRV_PCM_FORMAT_S20_3LE: | 518 | case 20: |
| 519 | paifa |= 0x0; | 519 | paifa |= 0x0; |
| 520 | paifb |= WM8580_AIF_LENGTH_20; | 520 | paifb |= WM8580_AIF_LENGTH_20; |
| 521 | break; | 521 | break; |
| 522 | case SNDRV_PCM_FORMAT_S24_LE: | 522 | case 24: |
| 523 | paifa |= 0x0; | 523 | paifa |= 0x0; |
| 524 | paifb |= WM8580_AIF_LENGTH_24; | 524 | paifb |= WM8580_AIF_LENGTH_24; |
| 525 | break; | 525 | break; |
| 526 | case SNDRV_PCM_FORMAT_S32_LE: | 526 | case 32: |
| 527 | paifa |= 0x0; | 527 | paifa |= 0x0; |
| 528 | paifb |= WM8580_AIF_LENGTH_32; | 528 | paifb |= WM8580_AIF_LENGTH_32; |
| 529 | break; | 529 | break; |
diff --git a/sound/soc/codecs/wm8711.c b/sound/soc/codecs/wm8711.c index b0fbcb377baf..32187e739b4f 100644 --- a/sound/soc/codecs/wm8711.c +++ b/sound/soc/codecs/wm8711.c | |||
| @@ -169,13 +169,13 @@ static int wm8711_hw_params(struct snd_pcm_substream *substream, | |||
| 169 | snd_soc_write(codec, WM8711_SRATE, srate); | 169 | snd_soc_write(codec, WM8711_SRATE, srate); |
| 170 | 170 | ||
| 171 | /* bit size */ | 171 | /* bit size */ |
| 172 | switch (params_format(params)) { | 172 | switch (params_width(params)) { |
| 173 | case SNDRV_PCM_FORMAT_S16_LE: | 173 | case 16: |
| 174 | break; | 174 | break; |
| 175 | case SNDRV_PCM_FORMAT_S20_3LE: | 175 | case 20: |
| 176 | iface |= 0x0004; | 176 | iface |= 0x0004; |
| 177 | break; | 177 | break; |
| 178 | case SNDRV_PCM_FORMAT_S24_LE: | 178 | case 24: |
| 179 | iface |= 0x0008; | 179 | iface |= 0x0008; |
| 180 | break; | 180 | break; |
| 181 | } | 181 | } |
diff --git a/sound/soc/codecs/wm8728.c b/sound/soc/codecs/wm8728.c index bac7fc28fe71..38ff826f589a 100644 --- a/sound/soc/codecs/wm8728.c +++ b/sound/soc/codecs/wm8728.c | |||
| @@ -94,13 +94,13 @@ static int wm8728_hw_params(struct snd_pcm_substream *substream, | |||
| 94 | 94 | ||
| 95 | dac &= ~0x18; | 95 | dac &= ~0x18; |
| 96 | 96 | ||
| 97 | switch (params_format(params)) { | 97 | switch (params_width(params)) { |
| 98 | case SNDRV_PCM_FORMAT_S16_LE: | 98 | case 16: |
| 99 | break; | 99 | break; |
| 100 | case SNDRV_PCM_FORMAT_S20_3LE: | 100 | case 20: |
| 101 | dac |= 0x10; | 101 | dac |= 0x10; |
| 102 | break; | 102 | break; |
| 103 | case SNDRV_PCM_FORMAT_S24_LE: | 103 | case 24: |
| 104 | dac |= 0x08; | 104 | dac |= 0x08; |
| 105 | break; | 105 | break; |
| 106 | default: | 106 | default: |
diff --git a/sound/soc/codecs/wm8731.c b/sound/soc/codecs/wm8731.c index 5ada61611324..eebb3280bfad 100644 --- a/sound/soc/codecs/wm8731.c +++ b/sound/soc/codecs/wm8731.c | |||
| @@ -348,13 +348,13 @@ static int wm8731_hw_params(struct snd_pcm_substream *substream, | |||
| 348 | snd_soc_write(codec, WM8731_SRATE, srate); | 348 | snd_soc_write(codec, WM8731_SRATE, srate); |
| 349 | 349 | ||
| 350 | /* bit size */ | 350 | /* bit size */ |
| 351 | switch (params_format(params)) { | 351 | switch (params_width(params)) { |
| 352 | case SNDRV_PCM_FORMAT_S16_LE: | 352 | case 16: |
| 353 | break; | 353 | break; |
| 354 | case SNDRV_PCM_FORMAT_S20_3LE: | 354 | case 20: |
| 355 | iface |= 0x0004; | 355 | iface |= 0x0004; |
| 356 | break; | 356 | break; |
| 357 | case SNDRV_PCM_FORMAT_S24_LE: | 357 | case 24: |
| 358 | iface |= 0x0008; | 358 | iface |= 0x0008; |
| 359 | break; | 359 | break; |
| 360 | } | 360 | } |
diff --git a/sound/soc/codecs/wm8737.c b/sound/soc/codecs/wm8737.c index b27f26cdc049..744a422ecb05 100644 --- a/sound/soc/codecs/wm8737.c +++ b/sound/soc/codecs/wm8737.c | |||
| @@ -367,16 +367,16 @@ static int wm8737_hw_params(struct snd_pcm_substream *substream, | |||
| 367 | 367 | ||
| 368 | clocking |= coeff_div[i].usb | (coeff_div[i].sr << WM8737_SR_SHIFT); | 368 | clocking |= coeff_div[i].usb | (coeff_div[i].sr << WM8737_SR_SHIFT); |
| 369 | 369 | ||
| 370 | switch (params_format(params)) { | 370 | switch (params_width(params)) { |
| 371 | case SNDRV_PCM_FORMAT_S16_LE: | 371 | case 16: |
| 372 | break; | 372 | break; |
| 373 | case SNDRV_PCM_FORMAT_S20_3LE: | 373 | case 20: |
| 374 | af |= 0x8; | 374 | af |= 0x8; |
| 375 | break; | 375 | break; |
| 376 | case SNDRV_PCM_FORMAT_S24_LE: | 376 | case 24: |
| 377 | af |= 0x10; | 377 | af |= 0x10; |
| 378 | break; | 378 | break; |
| 379 | case SNDRV_PCM_FORMAT_S32_LE: | 379 | case 32: |
| 380 | af |= 0x18; | 380 | af |= 0x18; |
| 381 | break; | 381 | break; |
| 382 | default: | 382 | default: |
diff --git a/sound/soc/codecs/wm8741.c b/sound/soc/codecs/wm8741.c index b33542a04607..a237f1627f61 100644 --- a/sound/soc/codecs/wm8741.c +++ b/sound/soc/codecs/wm8741.c | |||
| @@ -241,26 +241,26 @@ static int wm8741_hw_params(struct snd_pcm_substream *substream, | |||
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | /* bit size */ | 243 | /* bit size */ |
| 244 | switch (params_format(params)) { | 244 | switch (params_width(params)) { |
| 245 | case SNDRV_PCM_FORMAT_S16_LE: | 245 | case 16: |
| 246 | break; | 246 | break; |
| 247 | case SNDRV_PCM_FORMAT_S20_3LE: | 247 | case 20: |
| 248 | iface |= 0x0001; | 248 | iface |= 0x0001; |
| 249 | break; | 249 | break; |
| 250 | case SNDRV_PCM_FORMAT_S24_LE: | 250 | case 24: |
| 251 | iface |= 0x0002; | 251 | iface |= 0x0002; |
| 252 | break; | 252 | break; |
| 253 | case SNDRV_PCM_FORMAT_S32_LE: | 253 | case 32: |
| 254 | iface |= 0x0003; | 254 | iface |= 0x0003; |
| 255 | break; | 255 | break; |
| 256 | default: | 256 | default: |
| 257 | dev_dbg(codec->dev, "wm8741_hw_params: Unsupported bit size param = %d", | 257 | dev_dbg(codec->dev, "wm8741_hw_params: Unsupported bit size param = %d", |
| 258 | params_format(params)); | 258 | params_width(params)); |
| 259 | return -EINVAL; | 259 | return -EINVAL; |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | dev_dbg(codec->dev, "wm8741_hw_params: bit size param = %d", | 262 | dev_dbg(codec->dev, "wm8741_hw_params: bit size param = %d", |
| 263 | params_format(params)); | 263 | params_width(params)); |
| 264 | 264 | ||
| 265 | snd_soc_write(codec, WM8741_FORMAT_CONTROL, iface); | 265 | snd_soc_write(codec, WM8741_FORMAT_CONTROL, iface); |
| 266 | return 0; | 266 | return 0; |
diff --git a/sound/soc/codecs/wm8750.c b/sound/soc/codecs/wm8750.c index 33990b63d214..67653a2db223 100644 --- a/sound/soc/codecs/wm8750.c +++ b/sound/soc/codecs/wm8750.c | |||
| @@ -586,16 +586,16 @@ static int wm8750_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 586 | int coeff = get_coeff(wm8750->sysclk, params_rate(params)); | 586 | int coeff = get_coeff(wm8750->sysclk, params_rate(params)); |
| 587 | 587 | ||
| 588 | /* bit size */ | 588 | /* bit size */ |
| 589 | switch (params_format(params)) { | 589 | switch (params_width(params)) { |
| 590 | case SNDRV_PCM_FORMAT_S16_LE: | 590 | case 16: |
| 591 | break; | 591 | break; |
| 592 | case SNDRV_PCM_FORMAT_S20_3LE: | 592 | case 20: |
| 593 | iface |= 0x0004; | 593 | iface |= 0x0004; |
| 594 | break; | 594 | break; |
| 595 | case SNDRV_PCM_FORMAT_S24_LE: | 595 | case 24: |
| 596 | iface |= 0x0008; | 596 | iface |= 0x0008; |
| 597 | break; | 597 | break; |
| 598 | case SNDRV_PCM_FORMAT_S32_LE: | 598 | case 32: |
| 599 | iface |= 0x000c; | 599 | iface |= 0x000c; |
| 600 | break; | 600 | break; |
| 601 | } | 601 | } |
diff --git a/sound/soc/codecs/wm8753.c b/sound/soc/codecs/wm8753.c index 53e57b4049a8..e54e097f4fcb 100644 --- a/sound/soc/codecs/wm8753.c +++ b/sound/soc/codecs/wm8753.c | |||
| @@ -937,16 +937,16 @@ static int wm8753_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 937 | u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x017f; | 937 | u16 srate = snd_soc_read(codec, WM8753_SRATE1) & 0x017f; |
| 938 | 938 | ||
| 939 | /* bit size */ | 939 | /* bit size */ |
| 940 | switch (params_format(params)) { | 940 | switch (params_width(params)) { |
| 941 | case SNDRV_PCM_FORMAT_S16_LE: | 941 | case 16: |
| 942 | break; | 942 | break; |
| 943 | case SNDRV_PCM_FORMAT_S20_3LE: | 943 | case 20: |
| 944 | voice |= 0x0004; | 944 | voice |= 0x0004; |
| 945 | break; | 945 | break; |
| 946 | case SNDRV_PCM_FORMAT_S24_LE: | 946 | case 24: |
| 947 | voice |= 0x0008; | 947 | voice |= 0x0008; |
| 948 | break; | 948 | break; |
| 949 | case SNDRV_PCM_FORMAT_S32_LE: | 949 | case 32: |
| 950 | voice |= 0x000c; | 950 | voice |= 0x000c; |
| 951 | break; | 951 | break; |
| 952 | } | 952 | } |
| @@ -1176,16 +1176,16 @@ static int wm8753_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 1176 | coeff_div[coeff].usb); | 1176 | coeff_div[coeff].usb); |
| 1177 | 1177 | ||
| 1178 | /* bit size */ | 1178 | /* bit size */ |
| 1179 | switch (params_format(params)) { | 1179 | switch (params_width(params)) { |
| 1180 | case SNDRV_PCM_FORMAT_S16_LE: | 1180 | case 16: |
| 1181 | break; | 1181 | break; |
| 1182 | case SNDRV_PCM_FORMAT_S20_3LE: | 1182 | case 20: |
| 1183 | hifi |= 0x0004; | 1183 | hifi |= 0x0004; |
| 1184 | break; | 1184 | break; |
| 1185 | case SNDRV_PCM_FORMAT_S24_LE: | 1185 | case 24: |
| 1186 | hifi |= 0x0008; | 1186 | hifi |= 0x0008; |
| 1187 | break; | 1187 | break; |
| 1188 | case SNDRV_PCM_FORMAT_S32_LE: | 1188 | case 32: |
| 1189 | hifi |= 0x000c; | 1189 | hifi |= 0x000c; |
| 1190 | break; | 1190 | break; |
| 1191 | } | 1191 | } |
diff --git a/sound/soc/codecs/wm8770.c b/sound/soc/codecs/wm8770.c index c61aeb38efb8..180e7a098726 100644 --- a/sound/soc/codecs/wm8770.c +++ b/sound/soc/codecs/wm8770.c | |||
| @@ -426,16 +426,16 @@ static int wm8770_hw_params(struct snd_pcm_substream *substream, | |||
| 426 | wm8770 = snd_soc_codec_get_drvdata(codec); | 426 | wm8770 = snd_soc_codec_get_drvdata(codec); |
| 427 | 427 | ||
| 428 | iface = 0; | 428 | iface = 0; |
| 429 | switch (params_format(params)) { | 429 | switch (params_width(params)) { |
| 430 | case SNDRV_PCM_FORMAT_S16_LE: | 430 | case 16: |
| 431 | break; | 431 | break; |
| 432 | case SNDRV_PCM_FORMAT_S20_3LE: | 432 | case 20: |
| 433 | iface |= 0x10; | 433 | iface |= 0x10; |
| 434 | break; | 434 | break; |
| 435 | case SNDRV_PCM_FORMAT_S24_LE: | 435 | case 24: |
| 436 | iface |= 0x20; | 436 | iface |= 0x20; |
| 437 | break; | 437 | break; |
| 438 | case SNDRV_PCM_FORMAT_S32_LE: | 438 | case 32: |
| 439 | iface |= 0x30; | 439 | iface |= 0x30; |
| 440 | break; | 440 | break; |
| 441 | } | 441 | } |
diff --git a/sound/soc/codecs/wm8804.c b/sound/soc/codecs/wm8804.c index d96e5963ee35..0ea01dfcb6e1 100644 --- a/sound/soc/codecs/wm8804.c +++ b/sound/soc/codecs/wm8804.c | |||
| @@ -270,19 +270,19 @@ static int wm8804_hw_params(struct snd_pcm_substream *substream, | |||
| 270 | 270 | ||
| 271 | codec = dai->codec; | 271 | codec = dai->codec; |
| 272 | 272 | ||
| 273 | switch (params_format(params)) { | 273 | switch (params_width(params)) { |
| 274 | case SNDRV_PCM_FORMAT_S16_LE: | 274 | case 16: |
| 275 | blen = 0x0; | 275 | blen = 0x0; |
| 276 | break; | 276 | break; |
| 277 | case SNDRV_PCM_FORMAT_S20_3LE: | 277 | case 20: |
| 278 | blen = 0x1; | 278 | blen = 0x1; |
| 279 | break; | 279 | break; |
| 280 | case SNDRV_PCM_FORMAT_S24_LE: | 280 | case 24: |
| 281 | blen = 0x2; | 281 | blen = 0x2; |
| 282 | break; | 282 | break; |
| 283 | default: | 283 | default: |
| 284 | dev_err(dai->dev, "Unsupported word length: %u\n", | 284 | dev_err(dai->dev, "Unsupported word length: %u\n", |
| 285 | params_format(params)); | 285 | params_width(params)); |
| 286 | return -EINVAL; | 286 | return -EINVAL; |
| 287 | } | 287 | } |
| 288 | 288 | ||
diff --git a/sound/soc/codecs/wm8900.c b/sound/soc/codecs/wm8900.c index d09fdce57f5a..44a5f1511f0f 100644 --- a/sound/soc/codecs/wm8900.c +++ b/sound/soc/codecs/wm8900.c | |||
| @@ -640,16 +640,16 @@ static int wm8900_hw_params(struct snd_pcm_substream *substream, | |||
| 640 | 640 | ||
| 641 | reg = snd_soc_read(codec, WM8900_REG_AUDIO1) & ~0x60; | 641 | reg = snd_soc_read(codec, WM8900_REG_AUDIO1) & ~0x60; |
| 642 | 642 | ||
| 643 | switch (params_format(params)) { | 643 | switch (params_width(params)) { |
| 644 | case SNDRV_PCM_FORMAT_S16_LE: | 644 | case 16: |
| 645 | break; | 645 | break; |
| 646 | case SNDRV_PCM_FORMAT_S20_3LE: | 646 | case 20: |
| 647 | reg |= 0x20; | 647 | reg |= 0x20; |
| 648 | break; | 648 | break; |
| 649 | case SNDRV_PCM_FORMAT_S24_LE: | 649 | case 24: |
| 650 | reg |= 0x40; | 650 | reg |= 0x40; |
| 651 | break; | 651 | break; |
| 652 | case SNDRV_PCM_FORMAT_S32_LE: | 652 | case 32: |
| 653 | reg |= 0x60; | 653 | reg |= 0x60; |
| 654 | break; | 654 | break; |
| 655 | default: | 655 | default: |
diff --git a/sound/soc/codecs/wm8903.c b/sound/soc/codecs/wm8903.c index b84940c359a1..aa0984864e76 100644 --- a/sound/soc/codecs/wm8903.c +++ b/sound/soc/codecs/wm8903.c | |||
| @@ -281,8 +281,7 @@ static int wm8903_dcs_event(struct snd_soc_dapm_widget *w, | |||
| 281 | static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, | 281 | static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm, |
| 282 | enum snd_soc_dapm_type event, int subseq) | 282 | enum snd_soc_dapm_type event, int subseq) |
| 283 | { | 283 | { |
| 284 | struct snd_soc_codec *codec = container_of(dapm, | 284 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); |
| 285 | struct snd_soc_codec, dapm); | ||
| 286 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); | 285 | struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec); |
| 287 | int dcs_mode = WM8903_DCS_MODE_WRITE_STOP; | 286 | int dcs_mode = WM8903_DCS_MODE_WRITE_STOP; |
| 288 | int i, val; | 287 | int i, val; |
| @@ -1477,19 +1476,19 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream, | |||
| 1477 | 1476 | ||
| 1478 | aif1 &= ~WM8903_AIF_WL_MASK; | 1477 | aif1 &= ~WM8903_AIF_WL_MASK; |
| 1479 | bclk = 2 * fs; | 1478 | bclk = 2 * fs; |
| 1480 | switch (params_format(params)) { | 1479 | switch (params_width(params)) { |
| 1481 | case SNDRV_PCM_FORMAT_S16_LE: | 1480 | case 16: |
| 1482 | bclk *= 16; | 1481 | bclk *= 16; |
| 1483 | break; | 1482 | break; |
| 1484 | case SNDRV_PCM_FORMAT_S20_3LE: | 1483 | case 20: |
| 1485 | bclk *= 20; | 1484 | bclk *= 20; |
| 1486 | aif1 |= 0x4; | 1485 | aif1 |= 0x4; |
| 1487 | break; | 1486 | break; |
| 1488 | case SNDRV_PCM_FORMAT_S24_LE: | 1487 | case 24: |
| 1489 | bclk *= 24; | 1488 | bclk *= 24; |
| 1490 | aif1 |= 0x8; | 1489 | aif1 |= 0x8; |
| 1491 | break; | 1490 | break; |
| 1492 | case SNDRV_PCM_FORMAT_S32_LE: | 1491 | case 32: |
| 1493 | bclk *= 32; | 1492 | bclk *= 32; |
| 1494 | aif1 |= 0xc; | 1493 | aif1 |= 0xc; |
| 1495 | break; | 1494 | break; |
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index f7c549949c54..4d2d2b1380d5 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <linux/clk.h> | ||
| 14 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 15 | #include <linux/moduleparam.h> | 16 | #include <linux/moduleparam.h> |
| 16 | #include <linux/init.h> | 17 | #include <linux/init.h> |
| @@ -49,6 +50,7 @@ static const char *wm8904_supply_names[WM8904_NUM_SUPPLIES] = { | |||
| 49 | /* codec private data */ | 50 | /* codec private data */ |
| 50 | struct wm8904_priv { | 51 | struct wm8904_priv { |
| 51 | struct regmap *regmap; | 52 | struct regmap *regmap; |
| 53 | struct clk *mclk; | ||
| 52 | 54 | ||
| 53 | enum wm8904_type devtype; | 55 | enum wm8904_type devtype; |
| 54 | 56 | ||
| @@ -1290,16 +1292,16 @@ static int wm8904_hw_params(struct snd_pcm_substream *substream, | |||
| 1290 | wm8904->bclk = snd_soc_params_to_bclk(params); | 1292 | wm8904->bclk = snd_soc_params_to_bclk(params); |
| 1291 | } | 1293 | } |
| 1292 | 1294 | ||
| 1293 | switch (params_format(params)) { | 1295 | switch (params_width(params)) { |
| 1294 | case SNDRV_PCM_FORMAT_S16_LE: | 1296 | case 16: |
| 1295 | break; | 1297 | break; |
| 1296 | case SNDRV_PCM_FORMAT_S20_3LE: | 1298 | case 20: |
| 1297 | aif1 |= 0x40; | 1299 | aif1 |= 0x40; |
| 1298 | break; | 1300 | break; |
| 1299 | case SNDRV_PCM_FORMAT_S24_LE: | 1301 | case 24: |
| 1300 | aif1 |= 0x80; | 1302 | aif1 |= 0x80; |
| 1301 | break; | 1303 | break; |
| 1302 | case SNDRV_PCM_FORMAT_S32_LE: | 1304 | case 32: |
| 1303 | aif1 |= 0xc0; | 1305 | aif1 |= 0xc0; |
| 1304 | break; | 1306 | break; |
| 1305 | default: | 1307 | default: |
| @@ -1828,6 +1830,7 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, | |||
| 1828 | 1830 | ||
| 1829 | switch (level) { | 1831 | switch (level) { |
| 1830 | case SND_SOC_BIAS_ON: | 1832 | case SND_SOC_BIAS_ON: |
| 1833 | clk_prepare_enable(wm8904->mclk); | ||
| 1831 | break; | 1834 | break; |
| 1832 | 1835 | ||
| 1833 | case SND_SOC_BIAS_PREPARE: | 1836 | case SND_SOC_BIAS_PREPARE: |
| @@ -1894,6 +1897,7 @@ static int wm8904_set_bias_level(struct snd_soc_codec *codec, | |||
| 1894 | 1897 | ||
| 1895 | regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), | 1898 | regulator_bulk_disable(ARRAY_SIZE(wm8904->supplies), |
| 1896 | wm8904->supplies); | 1899 | wm8904->supplies); |
| 1900 | clk_disable_unprepare(wm8904->mclk); | ||
| 1897 | break; | 1901 | break; |
| 1898 | } | 1902 | } |
| 1899 | codec->dapm.bias_level = level; | 1903 | codec->dapm.bias_level = level; |
| @@ -2013,12 +2017,8 @@ static void wm8904_handle_pdata(struct snd_soc_codec *codec) | |||
| 2013 | /* We need an array of texts for the enum API */ | 2017 | /* We need an array of texts for the enum API */ |
| 2014 | wm8904->drc_texts = kmalloc(sizeof(char *) | 2018 | wm8904->drc_texts = kmalloc(sizeof(char *) |
| 2015 | * pdata->num_drc_cfgs, GFP_KERNEL); | 2019 | * pdata->num_drc_cfgs, GFP_KERNEL); |
| 2016 | if (!wm8904->drc_texts) { | 2020 | if (!wm8904->drc_texts) |
| 2017 | dev_err(codec->dev, | ||
| 2018 | "Failed to allocate %d DRC config texts\n", | ||
| 2019 | pdata->num_drc_cfgs); | ||
| 2020 | return; | 2021 | return; |
| 2021 | } | ||
| 2022 | 2022 | ||
| 2023 | for (i = 0; i < pdata->num_drc_cfgs; i++) | 2023 | for (i = 0; i < pdata->num_drc_cfgs; i++) |
| 2024 | wm8904->drc_texts[i] = pdata->drc_cfgs[i].name; | 2024 | wm8904->drc_texts[i] = pdata->drc_cfgs[i].name; |
| @@ -2110,6 +2110,13 @@ static int wm8904_i2c_probe(struct i2c_client *i2c, | |||
| 2110 | if (wm8904 == NULL) | 2110 | if (wm8904 == NULL) |
| 2111 | return -ENOMEM; | 2111 | return -ENOMEM; |
| 2112 | 2112 | ||
| 2113 | wm8904->mclk = devm_clk_get(&i2c->dev, "mclk"); | ||
| 2114 | if (IS_ERR(wm8904->mclk)) { | ||
| 2115 | ret = PTR_ERR(wm8904->mclk); | ||
| 2116 | dev_err(&i2c->dev, "Failed to get MCLK\n"); | ||
| 2117 | return ret; | ||
| 2118 | } | ||
| 2119 | |||
| 2113 | wm8904->regmap = devm_regmap_init_i2c(i2c, &wm8904_regmap); | 2120 | wm8904->regmap = devm_regmap_init_i2c(i2c, &wm8904_regmap); |
| 2114 | if (IS_ERR(wm8904->regmap)) { | 2121 | if (IS_ERR(wm8904->regmap)) { |
| 2115 | ret = PTR_ERR(wm8904->regmap); | 2122 | ret = PTR_ERR(wm8904->regmap); |
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c index fc6eec9ad66b..52011043e54c 100644 --- a/sound/soc/codecs/wm8940.c +++ b/sound/soc/codecs/wm8940.c | |||
| @@ -430,19 +430,19 @@ static int wm8940_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 430 | if (ret) | 430 | if (ret) |
| 431 | goto error_ret; | 431 | goto error_ret; |
| 432 | 432 | ||
| 433 | switch (params_format(params)) { | 433 | switch (params_width(params)) { |
| 434 | case SNDRV_PCM_FORMAT_S8: | 434 | case 8: |
| 435 | companding = companding | (1 << 5); | 435 | companding = companding | (1 << 5); |
| 436 | break; | 436 | break; |
| 437 | case SNDRV_PCM_FORMAT_S16_LE: | 437 | case 16: |
| 438 | break; | 438 | break; |
| 439 | case SNDRV_PCM_FORMAT_S20_3LE: | 439 | case 20: |
| 440 | iface |= (1 << 5); | 440 | iface |= (1 << 5); |
| 441 | break; | 441 | break; |
| 442 | case SNDRV_PCM_FORMAT_S24_LE: | 442 | case 24: |
| 443 | iface |= (2 << 5); | 443 | iface |= (2 << 5); |
| 444 | break; | 444 | break; |
| 445 | case SNDRV_PCM_FORMAT_S32_LE: | 445 | case 32: |
| 446 | iface |= (3 << 5); | 446 | iface |= (3 << 5); |
| 447 | break; | 447 | break; |
| 448 | } | 448 | } |
diff --git a/sound/soc/codecs/wm8955.c b/sound/soc/codecs/wm8955.c index 2a35108f233d..09d91d9dc4ee 100644 --- a/sound/soc/codecs/wm8955.c +++ b/sound/soc/codecs/wm8955.c | |||
| @@ -597,17 +597,17 @@ static int wm8955_hw_params(struct snd_pcm_substream *substream, | |||
| 597 | int ret; | 597 | int ret; |
| 598 | int wl; | 598 | int wl; |
| 599 | 599 | ||
| 600 | switch (params_format(params)) { | 600 | switch (params_width(params)) { |
| 601 | case SNDRV_PCM_FORMAT_S16_LE: | 601 | case 16: |
| 602 | wl = 0; | 602 | wl = 0; |
| 603 | break; | 603 | break; |
| 604 | case SNDRV_PCM_FORMAT_S20_3LE: | 604 | case 20: |
| 605 | wl = 0x4; | 605 | wl = 0x4; |
| 606 | break; | 606 | break; |
| 607 | case SNDRV_PCM_FORMAT_S24_LE: | 607 | case 24: |
| 608 | wl = 0x8; | 608 | wl = 0x8; |
| 609 | break; | 609 | break; |
| 610 | case SNDRV_PCM_FORMAT_S32_LE: | 610 | case 32: |
| 611 | wl = 0xc; | 611 | wl = 0xc; |
| 612 | break; | 612 | break; |
| 613 | default: | 613 | default: |
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index b2ebb104d879..0dada7f0105e 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c | |||
| @@ -934,12 +934,8 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) | |||
| 934 | /* We need an array of texts for the enum API */ | 934 | /* We need an array of texts for the enum API */ |
| 935 | wm8994->mbc_texts = kmalloc(sizeof(char *) | 935 | wm8994->mbc_texts = kmalloc(sizeof(char *) |
| 936 | * pdata->num_mbc_cfgs, GFP_KERNEL); | 936 | * pdata->num_mbc_cfgs, GFP_KERNEL); |
| 937 | if (!wm8994->mbc_texts) { | 937 | if (!wm8994->mbc_texts) |
| 938 | dev_err(wm8994->hubs.codec->dev, | ||
| 939 | "Failed to allocate %d MBC config texts\n", | ||
| 940 | pdata->num_mbc_cfgs); | ||
| 941 | return; | 938 | return; |
| 942 | } | ||
| 943 | 939 | ||
| 944 | for (i = 0; i < pdata->num_mbc_cfgs; i++) | 940 | for (i = 0; i < pdata->num_mbc_cfgs; i++) |
| 945 | wm8994->mbc_texts[i] = pdata->mbc_cfgs[i].name; | 941 | wm8994->mbc_texts[i] = pdata->mbc_cfgs[i].name; |
| @@ -963,12 +959,8 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) | |||
| 963 | /* We need an array of texts for the enum API */ | 959 | /* We need an array of texts for the enum API */ |
| 964 | wm8994->vss_texts = kmalloc(sizeof(char *) | 960 | wm8994->vss_texts = kmalloc(sizeof(char *) |
| 965 | * pdata->num_vss_cfgs, GFP_KERNEL); | 961 | * pdata->num_vss_cfgs, GFP_KERNEL); |
| 966 | if (!wm8994->vss_texts) { | 962 | if (!wm8994->vss_texts) |
| 967 | dev_err(wm8994->hubs.codec->dev, | ||
| 968 | "Failed to allocate %d VSS config texts\n", | ||
| 969 | pdata->num_vss_cfgs); | ||
| 970 | return; | 963 | return; |
| 971 | } | ||
| 972 | 964 | ||
| 973 | for (i = 0; i < pdata->num_vss_cfgs; i++) | 965 | for (i = 0; i < pdata->num_vss_cfgs; i++) |
| 974 | wm8994->vss_texts[i] = pdata->vss_cfgs[i].name; | 966 | wm8994->vss_texts[i] = pdata->vss_cfgs[i].name; |
| @@ -993,12 +985,8 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) | |||
| 993 | /* We need an array of texts for the enum API */ | 985 | /* We need an array of texts for the enum API */ |
| 994 | wm8994->vss_hpf_texts = kmalloc(sizeof(char *) | 986 | wm8994->vss_hpf_texts = kmalloc(sizeof(char *) |
| 995 | * pdata->num_vss_hpf_cfgs, GFP_KERNEL); | 987 | * pdata->num_vss_hpf_cfgs, GFP_KERNEL); |
| 996 | if (!wm8994->vss_hpf_texts) { | 988 | if (!wm8994->vss_hpf_texts) |
| 997 | dev_err(wm8994->hubs.codec->dev, | ||
| 998 | "Failed to allocate %d VSS HPF config texts\n", | ||
| 999 | pdata->num_vss_hpf_cfgs); | ||
| 1000 | return; | 989 | return; |
| 1001 | } | ||
| 1002 | 990 | ||
| 1003 | for (i = 0; i < pdata->num_vss_hpf_cfgs; i++) | 991 | for (i = 0; i < pdata->num_vss_hpf_cfgs; i++) |
| 1004 | wm8994->vss_hpf_texts[i] = pdata->vss_hpf_cfgs[i].name; | 992 | wm8994->vss_hpf_texts[i] = pdata->vss_hpf_cfgs[i].name; |
| @@ -1024,12 +1012,8 @@ void wm8958_dsp2_init(struct snd_soc_codec *codec) | |||
| 1024 | /* We need an array of texts for the enum API */ | 1012 | /* We need an array of texts for the enum API */ |
| 1025 | wm8994->enh_eq_texts = kmalloc(sizeof(char *) | 1013 | wm8994->enh_eq_texts = kmalloc(sizeof(char *) |
| 1026 | * pdata->num_enh_eq_cfgs, GFP_KERNEL); | 1014 | * pdata->num_enh_eq_cfgs, GFP_KERNEL); |
| 1027 | if (!wm8994->enh_eq_texts) { | 1015 | if (!wm8994->enh_eq_texts) |
| 1028 | dev_err(wm8994->hubs.codec->dev, | ||
| 1029 | "Failed to allocate %d enhanced EQ config texts\n", | ||
| 1030 | pdata->num_enh_eq_cfgs); | ||
| 1031 | return; | 1016 | return; |
| 1032 | } | ||
| 1033 | 1017 | ||
| 1034 | for (i = 0; i < pdata->num_enh_eq_cfgs; i++) | 1018 | for (i = 0; i < pdata->num_enh_eq_cfgs; i++) |
| 1035 | wm8994->enh_eq_texts[i] = pdata->enh_eq_cfgs[i].name; | 1019 | wm8994->enh_eq_texts[i] = pdata->enh_eq_cfgs[i].name; |
diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c index a145d0431b63..4dc4e85116cd 100644 --- a/sound/soc/codecs/wm8960.c +++ b/sound/soc/codecs/wm8960.c | |||
| @@ -472,7 +472,7 @@ static int wm8960_add_widgets(struct snd_soc_codec *codec) | |||
| 472 | * list each time to find the desired power state do so now | 472 | * list each time to find the desired power state do so now |
| 473 | * and save the result. | 473 | * and save the result. |
| 474 | */ | 474 | */ |
| 475 | list_for_each_entry(w, &codec->card->widgets, list) { | 475 | list_for_each_entry(w, &codec->component.card->widgets, list) { |
| 476 | if (w->dapm != &codec->dapm) | 476 | if (w->dapm != &codec->dapm) |
| 477 | continue; | 477 | continue; |
| 478 | if (strcmp(w->name, "LOUT1 PGA") == 0) | 478 | if (strcmp(w->name, "LOUT1 PGA") == 0) |
| @@ -567,24 +567,21 @@ static int wm8960_hw_params(struct snd_pcm_substream *substream, | |||
| 567 | struct snd_soc_codec *codec = dai->codec; | 567 | struct snd_soc_codec *codec = dai->codec; |
| 568 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); | 568 | struct wm8960_priv *wm8960 = snd_soc_codec_get_drvdata(codec); |
| 569 | u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3; | 569 | u16 iface = snd_soc_read(codec, WM8960_IFACE1) & 0xfff3; |
| 570 | snd_pcm_format_t format = params_format(params); | ||
| 571 | int i; | 570 | int i; |
| 572 | 571 | ||
| 573 | /* bit size */ | 572 | /* bit size */ |
| 574 | switch (format) { | 573 | switch (params_width(params)) { |
| 575 | case SNDRV_PCM_FORMAT_S16_LE: | 574 | case 16: |
| 576 | case SNDRV_PCM_FORMAT_S16_BE: | ||
| 577 | break; | 575 | break; |
| 578 | case SNDRV_PCM_FORMAT_S20_3LE: | 576 | case 20: |
| 579 | case SNDRV_PCM_FORMAT_S20_3BE: | ||
| 580 | iface |= 0x0004; | 577 | iface |= 0x0004; |
| 581 | break; | 578 | break; |
| 582 | case SNDRV_PCM_FORMAT_S24_LE: | 579 | case 24: |
| 583 | case SNDRV_PCM_FORMAT_S24_BE: | ||
| 584 | iface |= 0x0008; | 580 | iface |= 0x0008; |
| 585 | break; | 581 | break; |
| 586 | default: | 582 | default: |
| 587 | dev_err(codec->dev, "unsupported format %i\n", format); | 583 | dev_err(codec->dev, "unsupported width %d\n", |
| 584 | params_width(params)); | ||
| 588 | return -EINVAL; | 585 | return -EINVAL; |
| 589 | } | 586 | } |
| 590 | 587 | ||
diff --git a/sound/soc/codecs/wm8961.c b/sound/soc/codecs/wm8961.c index 9c88f04442b3..41d23e920ad5 100644 --- a/sound/soc/codecs/wm8961.c +++ b/sound/soc/codecs/wm8961.c | |||
| @@ -565,16 +565,16 @@ static int wm8961_hw_params(struct snd_pcm_substream *substream, | |||
| 565 | 565 | ||
| 566 | reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); | 566 | reg = snd_soc_read(codec, WM8961_AUDIO_INTERFACE_0); |
| 567 | reg &= ~WM8961_WL_MASK; | 567 | reg &= ~WM8961_WL_MASK; |
| 568 | switch (params_format(params)) { | 568 | switch (params_width(params)) { |
| 569 | case SNDRV_PCM_FORMAT_S16_LE: | 569 | case 16: |
| 570 | break; | 570 | break; |
| 571 | case SNDRV_PCM_FORMAT_S20_3LE: | 571 | case 20: |
| 572 | reg |= 1 << WM8961_WL_SHIFT; | 572 | reg |= 1 << WM8961_WL_SHIFT; |
| 573 | break; | 573 | break; |
| 574 | case SNDRV_PCM_FORMAT_S24_LE: | 574 | case 24: |
| 575 | reg |= 2 << WM8961_WL_SHIFT; | 575 | reg |= 2 << WM8961_WL_SHIFT; |
| 576 | break; | 576 | break; |
| 577 | case SNDRV_PCM_FORMAT_S32_LE: | 577 | case 32: |
| 578 | reg |= 3 << WM8961_WL_SHIFT; | 578 | reg |= 3 << WM8961_WL_SHIFT; |
| 579 | break; | 579 | break; |
| 580 | default: | 580 | default: |
diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c index ca2fda9d72be..1098ae32f1f9 100644 --- a/sound/soc/codecs/wm8962.c +++ b/sound/soc/codecs/wm8962.c | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include <linux/module.h> | 14 | #include <linux/module.h> |
| 15 | #include <linux/moduleparam.h> | 15 | #include <linux/moduleparam.h> |
| 16 | #include <linux/init.h> | 16 | #include <linux/init.h> |
| 17 | #include <linux/clk.h> | ||
| 17 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
| 18 | #include <linux/pm.h> | 19 | #include <linux/pm.h> |
| 19 | #include <linux/gcd.h> | 20 | #include <linux/gcd.h> |
| @@ -2586,16 +2587,16 @@ static int wm8962_hw_params(struct snd_pcm_substream *substream, | |||
| 2586 | if (wm8962->lrclk % 8000 == 0) | 2587 | if (wm8962->lrclk % 8000 == 0) |
| 2587 | adctl3 |= WM8962_SAMPLE_RATE_INT_MODE; | 2588 | adctl3 |= WM8962_SAMPLE_RATE_INT_MODE; |
| 2588 | 2589 | ||
| 2589 | switch (params_format(params)) { | 2590 | switch (params_width(params)) { |
| 2590 | case SNDRV_PCM_FORMAT_S16_LE: | 2591 | case 16: |
| 2591 | break; | 2592 | break; |
| 2592 | case SNDRV_PCM_FORMAT_S20_3LE: | 2593 | case 20: |
| 2593 | aif0 |= 0x4; | 2594 | aif0 |= 0x4; |
| 2594 | break; | 2595 | break; |
| 2595 | case SNDRV_PCM_FORMAT_S24_LE: | 2596 | case 24: |
| 2596 | aif0 |= 0x8; | 2597 | aif0 |= 0x8; |
| 2597 | break; | 2598 | break; |
| 2598 | case SNDRV_PCM_FORMAT_S32_LE: | 2599 | case 32: |
| 2599 | aif0 |= 0xc; | 2600 | aif0 |= 0xc; |
| 2600 | break; | 2601 | break; |
| 2601 | default: | 2602 | default: |
| @@ -3541,6 +3542,8 @@ static int wm8962_set_pdata_from_of(struct i2c_client *i2c, | |||
| 3541 | pdata->gpio_init[i] = 0x0; | 3542 | pdata->gpio_init[i] = 0x0; |
| 3542 | } | 3543 | } |
| 3543 | 3544 | ||
| 3545 | pdata->mclk = devm_clk_get(&i2c->dev, NULL); | ||
| 3546 | |||
| 3544 | return 0; | 3547 | return 0; |
| 3545 | } | 3548 | } |
| 3546 | 3549 | ||
| @@ -3572,6 +3575,14 @@ static int wm8962_i2c_probe(struct i2c_client *i2c, | |||
| 3572 | return ret; | 3575 | return ret; |
| 3573 | } | 3576 | } |
| 3574 | 3577 | ||
| 3578 | /* Mark the mclk pointer to NULL if no mclk assigned */ | ||
| 3579 | if (IS_ERR(wm8962->pdata.mclk)) { | ||
| 3580 | /* But do not ignore the request for probe defer */ | ||
| 3581 | if (PTR_ERR(wm8962->pdata.mclk) == -EPROBE_DEFER) | ||
| 3582 | return -EPROBE_DEFER; | ||
| 3583 | wm8962->pdata.mclk = NULL; | ||
| 3584 | } | ||
| 3585 | |||
| 3575 | for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) | 3586 | for (i = 0; i < ARRAY_SIZE(wm8962->supplies); i++) |
| 3576 | wm8962->supplies[i].supply = wm8962_supply_names[i]; | 3587 | wm8962->supplies[i].supply = wm8962_supply_names[i]; |
| 3577 | 3588 | ||
| @@ -3780,6 +3791,12 @@ static int wm8962_runtime_resume(struct device *dev) | |||
| 3780 | struct wm8962_priv *wm8962 = dev_get_drvdata(dev); | 3791 | struct wm8962_priv *wm8962 = dev_get_drvdata(dev); |
| 3781 | int ret; | 3792 | int ret; |
| 3782 | 3793 | ||
| 3794 | ret = clk_prepare_enable(wm8962->pdata.mclk); | ||
| 3795 | if (ret) { | ||
| 3796 | dev_err(dev, "Failed to enable MCLK: %d\n", ret); | ||
| 3797 | return ret; | ||
| 3798 | } | ||
| 3799 | |||
| 3783 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies), | 3800 | ret = regulator_bulk_enable(ARRAY_SIZE(wm8962->supplies), |
| 3784 | wm8962->supplies); | 3801 | wm8962->supplies); |
| 3785 | if (ret != 0) { | 3802 | if (ret != 0) { |
| @@ -3839,6 +3856,8 @@ static int wm8962_runtime_suspend(struct device *dev) | |||
| 3839 | regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), | 3856 | regulator_bulk_disable(ARRAY_SIZE(wm8962->supplies), |
| 3840 | wm8962->supplies); | 3857 | wm8962->supplies); |
| 3841 | 3858 | ||
| 3859 | clk_disable_unprepare(wm8962->pdata.mclk); | ||
| 3860 | |||
| 3842 | return 0; | 3861 | return 0; |
| 3843 | } | 3862 | } |
| 3844 | #endif | 3863 | #endif |
diff --git a/sound/soc/codecs/wm8971.c b/sound/soc/codecs/wm8971.c index 09b7b4200221..0499cd4cfb71 100644 --- a/sound/soc/codecs/wm8971.c +++ b/sound/soc/codecs/wm8971.c | |||
| @@ -517,16 +517,16 @@ static int wm8971_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 517 | int coeff = get_coeff(wm8971->sysclk, params_rate(params)); | 517 | int coeff = get_coeff(wm8971->sysclk, params_rate(params)); |
| 518 | 518 | ||
| 519 | /* bit size */ | 519 | /* bit size */ |
| 520 | switch (params_format(params)) { | 520 | switch (params_width(params)) { |
| 521 | case SNDRV_PCM_FORMAT_S16_LE: | 521 | case 16: |
| 522 | break; | 522 | break; |
| 523 | case SNDRV_PCM_FORMAT_S20_3LE: | 523 | case 20: |
| 524 | iface |= 0x0004; | 524 | iface |= 0x0004; |
| 525 | break; | 525 | break; |
| 526 | case SNDRV_PCM_FORMAT_S24_LE: | 526 | case 24: |
| 527 | iface |= 0x0008; | 527 | iface |= 0x0008; |
| 528 | break; | 528 | break; |
| 529 | case SNDRV_PCM_FORMAT_S32_LE: | 529 | case 32: |
| 530 | iface |= 0x000c; | 530 | iface |= 0x000c; |
| 531 | break; | 531 | break; |
| 532 | } | 532 | } |
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c index 0627c56fa44e..682e9eda1019 100644 --- a/sound/soc/codecs/wm8974.c +++ b/sound/soc/codecs/wm8974.c | |||
| @@ -445,16 +445,16 @@ static int wm8974_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 445 | u16 adn = snd_soc_read(codec, WM8974_ADD) & 0x1f1; | 445 | u16 adn = snd_soc_read(codec, WM8974_ADD) & 0x1f1; |
| 446 | 446 | ||
| 447 | /* bit size */ | 447 | /* bit size */ |
| 448 | switch (params_format(params)) { | 448 | switch (params_width(params)) { |
| 449 | case SNDRV_PCM_FORMAT_S16_LE: | 449 | case 16: |
| 450 | break; | 450 | break; |
| 451 | case SNDRV_PCM_FORMAT_S20_3LE: | 451 | case 20: |
| 452 | iface |= 0x0020; | 452 | iface |= 0x0020; |
| 453 | break; | 453 | break; |
| 454 | case SNDRV_PCM_FORMAT_S24_LE: | 454 | case 24: |
| 455 | iface |= 0x0040; | 455 | iface |= 0x0040; |
| 456 | break; | 456 | break; |
| 457 | case SNDRV_PCM_FORMAT_S32_LE: | 457 | case 32: |
| 458 | iface |= 0x0060; | 458 | iface |= 0x0060; |
| 459 | break; | 459 | break; |
| 460 | } | 460 | } |
diff --git a/sound/soc/codecs/wm8978.c b/sound/soc/codecs/wm8978.c index 28ef46c91f62..ee2ba574952b 100644 --- a/sound/soc/codecs/wm8978.c +++ b/sound/soc/codecs/wm8978.c | |||
| @@ -736,16 +736,16 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, | |||
| 736 | return -EINVAL; | 736 | return -EINVAL; |
| 737 | 737 | ||
| 738 | /* bit size */ | 738 | /* bit size */ |
| 739 | switch (params_format(params)) { | 739 | switch (params_width(params)) { |
| 740 | case SNDRV_PCM_FORMAT_S16_LE: | 740 | case 16: |
| 741 | break; | 741 | break; |
| 742 | case SNDRV_PCM_FORMAT_S20_3LE: | 742 | case 20: |
| 743 | iface_ctl |= 0x20; | 743 | iface_ctl |= 0x20; |
| 744 | break; | 744 | break; |
| 745 | case SNDRV_PCM_FORMAT_S24_LE: | 745 | case 24: |
| 746 | iface_ctl |= 0x40; | 746 | iface_ctl |= 0x40; |
| 747 | break; | 747 | break; |
| 748 | case SNDRV_PCM_FORMAT_S32_LE: | 748 | case 32: |
| 749 | iface_ctl |= 0x60; | 749 | iface_ctl |= 0x60; |
| 750 | break; | 750 | break; |
| 751 | } | 751 | } |
| @@ -817,8 +817,8 @@ static int wm8978_hw_params(struct snd_pcm_substream *substream, | |||
| 817 | wm8978->sysclk == WM8978_MCLK ? | 817 | wm8978->sysclk == WM8978_MCLK ? |
| 818 | ", consider using PLL" : ""); | 818 | ", consider using PLL" : ""); |
| 819 | 819 | ||
| 820 | dev_dbg(codec->dev, "%s: fmt %d, rate %u, MCLK divisor #%d\n", __func__, | 820 | dev_dbg(codec->dev, "%s: width %d, rate %u, MCLK divisor #%d\n", __func__, |
| 821 | params_format(params), params_rate(params), best); | 821 | params_width(params), params_rate(params), best); |
| 822 | 822 | ||
| 823 | /* MCLK divisor mask = 0xe0 */ | 823 | /* MCLK divisor mask = 0xe0 */ |
| 824 | snd_soc_update_bits(codec, WM8978_CLOCKING, 0xe0, best << 5); | 824 | snd_soc_update_bits(codec, WM8978_CLOCKING, 0xe0, best << 5); |
diff --git a/sound/soc/codecs/wm8983.c b/sound/soc/codecs/wm8983.c index 19d5baa38f5c..ac5defda8824 100644 --- a/sound/soc/codecs/wm8983.c +++ b/sound/soc/codecs/wm8983.c | |||
| @@ -719,22 +719,22 @@ static int wm8983_hw_params(struct snd_pcm_substream *substream, | |||
| 719 | 719 | ||
| 720 | wm8983->bclk = ret; | 720 | wm8983->bclk = ret; |
| 721 | 721 | ||
| 722 | switch (params_format(params)) { | 722 | switch (params_width(params)) { |
| 723 | case SNDRV_PCM_FORMAT_S16_LE: | 723 | case 16: |
| 724 | blen = 0x0; | 724 | blen = 0x0; |
| 725 | break; | 725 | break; |
| 726 | case SNDRV_PCM_FORMAT_S20_3LE: | 726 | case 20: |
| 727 | blen = 0x1; | 727 | blen = 0x1; |
| 728 | break; | 728 | break; |
| 729 | case SNDRV_PCM_FORMAT_S24_LE: | 729 | case 24: |
| 730 | blen = 0x2; | 730 | blen = 0x2; |
| 731 | break; | 731 | break; |
| 732 | case SNDRV_PCM_FORMAT_S32_LE: | 732 | case 32: |
| 733 | blen = 0x3; | 733 | blen = 0x3; |
| 734 | break; | 734 | break; |
| 735 | default: | 735 | default: |
| 736 | dev_err(dai->dev, "Unsupported word length %u\n", | 736 | dev_err(dai->dev, "Unsupported word length %u\n", |
| 737 | params_format(params)); | 737 | params_width(params)); |
| 738 | return -EINVAL; | 738 | return -EINVAL; |
| 739 | } | 739 | } |
| 740 | 740 | ||
diff --git a/sound/soc/codecs/wm8985.c b/sound/soc/codecs/wm8985.c index 0f5780c09f3a..ee380190399f 100644 --- a/sound/soc/codecs/wm8985.c +++ b/sound/soc/codecs/wm8985.c | |||
| @@ -698,22 +698,22 @@ static int wm8985_hw_params(struct snd_pcm_substream *substream, | |||
| 698 | if ((int)wm8985->bclk < 0) | 698 | if ((int)wm8985->bclk < 0) |
| 699 | return wm8985->bclk; | 699 | return wm8985->bclk; |
| 700 | 700 | ||
| 701 | switch (params_format(params)) { | 701 | switch (params_width(params)) { |
| 702 | case SNDRV_PCM_FORMAT_S16_LE: | 702 | case 16: |
| 703 | blen = 0x0; | 703 | blen = 0x0; |
| 704 | break; | 704 | break; |
| 705 | case SNDRV_PCM_FORMAT_S20_3LE: | 705 | case 20: |
| 706 | blen = 0x1; | 706 | blen = 0x1; |
| 707 | break; | 707 | break; |
| 708 | case SNDRV_PCM_FORMAT_S24_LE: | 708 | case 24: |
| 709 | blen = 0x2; | 709 | blen = 0x2; |
| 710 | break; | 710 | break; |
| 711 | case SNDRV_PCM_FORMAT_S32_LE: | 711 | case 32: |
| 712 | blen = 0x3; | 712 | blen = 0x3; |
| 713 | break; | 713 | break; |
| 714 | default: | 714 | default: |
| 715 | dev_err(dai->dev, "Unsupported word length %u\n", | 715 | dev_err(dai->dev, "Unsupported word length %u\n", |
| 716 | params_format(params)); | 716 | params_width(params)); |
| 717 | return -EINVAL; | 717 | return -EINVAL; |
| 718 | } | 718 | } |
| 719 | 719 | ||
| @@ -980,9 +980,6 @@ static int wm8985_resume(struct snd_soc_codec *codec) | |||
| 980 | 980 | ||
| 981 | static int wm8985_remove(struct snd_soc_codec *codec) | 981 | static int wm8985_remove(struct snd_soc_codec *codec) |
| 982 | { | 982 | { |
| 983 | struct wm8985_priv *wm8985; | ||
| 984 | |||
| 985 | wm8985 = snd_soc_codec_get_drvdata(codec); | ||
| 986 | wm8985_set_bias_level(codec, SND_SOC_BIAS_OFF); | 983 | wm8985_set_bias_level(codec, SND_SOC_BIAS_OFF); |
| 987 | return 0; | 984 | return 0; |
| 988 | } | 985 | } |
diff --git a/sound/soc/codecs/wm8988.c b/sound/soc/codecs/wm8988.c index d3fea46d58e8..a5130d965146 100644 --- a/sound/soc/codecs/wm8988.c +++ b/sound/soc/codecs/wm8988.c | |||
| @@ -687,16 +687,16 @@ static int wm8988_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 687 | } | 687 | } |
| 688 | 688 | ||
| 689 | /* bit size */ | 689 | /* bit size */ |
| 690 | switch (params_format(params)) { | 690 | switch (params_width(params)) { |
| 691 | case SNDRV_PCM_FORMAT_S16_LE: | 691 | case 16: |
| 692 | break; | 692 | break; |
| 693 | case SNDRV_PCM_FORMAT_S20_3LE: | 693 | case 20: |
| 694 | iface |= 0x0004; | 694 | iface |= 0x0004; |
| 695 | break; | 695 | break; |
| 696 | case SNDRV_PCM_FORMAT_S24_LE: | 696 | case 24: |
| 697 | iface |= 0x0008; | 697 | iface |= 0x0008; |
| 698 | break; | 698 | break; |
| 699 | case SNDRV_PCM_FORMAT_S32_LE: | 699 | case 32: |
| 700 | iface |= 0x000c; | 700 | iface |= 0x000c; |
| 701 | break; | 701 | break; |
| 702 | } | 702 | } |
diff --git a/sound/soc/codecs/wm8990.c b/sound/soc/codecs/wm8990.c index b5c1f0f07058..03e43e3f395e 100644 --- a/sound/soc/codecs/wm8990.c +++ b/sound/soc/codecs/wm8990.c | |||
| @@ -1073,16 +1073,16 @@ static int wm8990_hw_params(struct snd_pcm_substream *substream, | |||
| 1073 | 1073 | ||
| 1074 | audio1 &= ~WM8990_AIF_WL_MASK; | 1074 | audio1 &= ~WM8990_AIF_WL_MASK; |
| 1075 | /* bit size */ | 1075 | /* bit size */ |
| 1076 | switch (params_format(params)) { | 1076 | switch (params_width(params)) { |
| 1077 | case SNDRV_PCM_FORMAT_S16_LE: | 1077 | case 16: |
| 1078 | break; | 1078 | break; |
| 1079 | case SNDRV_PCM_FORMAT_S20_3LE: | 1079 | case 20: |
| 1080 | audio1 |= WM8990_AIF_WL_20BITS; | 1080 | audio1 |= WM8990_AIF_WL_20BITS; |
| 1081 | break; | 1081 | break; |
| 1082 | case SNDRV_PCM_FORMAT_S24_LE: | 1082 | case 24: |
| 1083 | audio1 |= WM8990_AIF_WL_24BITS; | 1083 | audio1 |= WM8990_AIF_WL_24BITS; |
| 1084 | break; | 1084 | break; |
| 1085 | case SNDRV_PCM_FORMAT_S32_LE: | 1085 | case 32: |
| 1086 | audio1 |= WM8990_AIF_WL_32BITS; | 1086 | audio1 |= WM8990_AIF_WL_32BITS; |
| 1087 | break; | 1087 | break; |
| 1088 | } | 1088 | } |
diff --git a/sound/soc/codecs/wm8991.c b/sound/soc/codecs/wm8991.c index b8fd284fc0c0..d0be89731cdb 100644 --- a/sound/soc/codecs/wm8991.c +++ b/sound/soc/codecs/wm8991.c | |||
| @@ -1081,16 +1081,16 @@ static int wm8991_hw_params(struct snd_pcm_substream *substream, | |||
| 1081 | 1081 | ||
| 1082 | audio1 &= ~WM8991_AIF_WL_MASK; | 1082 | audio1 &= ~WM8991_AIF_WL_MASK; |
| 1083 | /* bit size */ | 1083 | /* bit size */ |
| 1084 | switch (params_format(params)) { | 1084 | switch (params_width(params)) { |
| 1085 | case SNDRV_PCM_FORMAT_S16_LE: | 1085 | case 16: |
| 1086 | break; | 1086 | break; |
| 1087 | case SNDRV_PCM_FORMAT_S20_3LE: | 1087 | case 20: |
| 1088 | audio1 |= WM8991_AIF_WL_20BITS; | 1088 | audio1 |= WM8991_AIF_WL_20BITS; |
| 1089 | break; | 1089 | break; |
| 1090 | case SNDRV_PCM_FORMAT_S24_LE: | 1090 | case 24: |
| 1091 | audio1 |= WM8991_AIF_WL_24BITS; | 1091 | audio1 |= WM8991_AIF_WL_24BITS; |
| 1092 | break; | 1092 | break; |
| 1093 | case SNDRV_PCM_FORMAT_S32_LE: | 1093 | case 32: |
| 1094 | audio1 |= WM8991_AIF_WL_32BITS; | 1094 | audio1 |= WM8991_AIF_WL_32BITS; |
| 1095 | break; | 1095 | break; |
| 1096 | } | 1096 | } |
diff --git a/sound/soc/codecs/wm8993.c b/sound/soc/codecs/wm8993.c index f825dc04ebe1..93b14eda355a 100644 --- a/sound/soc/codecs/wm8993.c +++ b/sound/soc/codecs/wm8993.c | |||
| @@ -1214,19 +1214,19 @@ static int wm8993_hw_params(struct snd_pcm_substream *substream, | |||
| 1214 | wm8993->tdm_slots, wm8993->tdm_width); | 1214 | wm8993->tdm_slots, wm8993->tdm_width); |
| 1215 | wm8993->bclk *= wm8993->tdm_width * wm8993->tdm_slots; | 1215 | wm8993->bclk *= wm8993->tdm_width * wm8993->tdm_slots; |
| 1216 | } else { | 1216 | } else { |
| 1217 | switch (params_format(params)) { | 1217 | switch (params_width(params)) { |
| 1218 | case SNDRV_PCM_FORMAT_S16_LE: | 1218 | case 16: |
| 1219 | wm8993->bclk *= 16; | 1219 | wm8993->bclk *= 16; |
| 1220 | break; | 1220 | break; |
| 1221 | case SNDRV_PCM_FORMAT_S20_3LE: | 1221 | case 20: |
| 1222 | wm8993->bclk *= 20; | 1222 | wm8993->bclk *= 20; |
| 1223 | aif1 |= 0x8; | 1223 | aif1 |= 0x8; |
| 1224 | break; | 1224 | break; |
| 1225 | case SNDRV_PCM_FORMAT_S24_LE: | 1225 | case 24: |
| 1226 | wm8993->bclk *= 24; | 1226 | wm8993->bclk *= 24; |
| 1227 | aif1 |= 0x10; | 1227 | aif1 |= 0x10; |
| 1228 | break; | 1228 | break; |
| 1229 | case SNDRV_PCM_FORMAT_S32_LE: | 1229 | case 32: |
| 1230 | wm8993->bclk *= 32; | 1230 | wm8993->bclk *= 32; |
| 1231 | aif1 |= 0x18; | 1231 | aif1 |= 0x18; |
| 1232 | break; | 1232 | break; |
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 247b39013fba..6cc0566dc29a 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
| @@ -2815,19 +2815,19 @@ static int wm8994_hw_params(struct snd_pcm_substream *substream, | |||
| 2815 | } | 2815 | } |
| 2816 | 2816 | ||
| 2817 | bclk_rate = params_rate(params); | 2817 | bclk_rate = params_rate(params); |
| 2818 | switch (params_format(params)) { | 2818 | switch (params_width(params)) { |
| 2819 | case SNDRV_PCM_FORMAT_S16_LE: | 2819 | case 16: |
| 2820 | bclk_rate *= 16; | 2820 | bclk_rate *= 16; |
| 2821 | break; | 2821 | break; |
| 2822 | case SNDRV_PCM_FORMAT_S20_3LE: | 2822 | case 20: |
| 2823 | bclk_rate *= 20; | 2823 | bclk_rate *= 20; |
| 2824 | aif1 |= 0x20; | 2824 | aif1 |= 0x20; |
| 2825 | break; | 2825 | break; |
| 2826 | case SNDRV_PCM_FORMAT_S24_LE: | 2826 | case 24: |
| 2827 | bclk_rate *= 24; | 2827 | bclk_rate *= 24; |
| 2828 | aif1 |= 0x40; | 2828 | aif1 |= 0x40; |
| 2829 | break; | 2829 | break; |
| 2830 | case SNDRV_PCM_FORMAT_S32_LE: | 2830 | case 32: |
| 2831 | bclk_rate *= 32; | 2831 | bclk_rate *= 32; |
| 2832 | aif1 |= 0x60; | 2832 | aif1 |= 0x60; |
| 2833 | break; | 2833 | break; |
| @@ -2966,16 +2966,16 @@ static int wm8994_aif3_hw_params(struct snd_pcm_substream *substream, | |||
| 2966 | return 0; | 2966 | return 0; |
| 2967 | } | 2967 | } |
| 2968 | 2968 | ||
| 2969 | switch (params_format(params)) { | 2969 | switch (params_width(params)) { |
| 2970 | case SNDRV_PCM_FORMAT_S16_LE: | 2970 | case 16: |
| 2971 | break; | 2971 | break; |
| 2972 | case SNDRV_PCM_FORMAT_S20_3LE: | 2972 | case 20: |
| 2973 | aif1 |= 0x20; | 2973 | aif1 |= 0x20; |
| 2974 | break; | 2974 | break; |
| 2975 | case SNDRV_PCM_FORMAT_S24_LE: | 2975 | case 24: |
| 2976 | aif1 |= 0x40; | 2976 | aif1 |= 0x40; |
| 2977 | break; | 2977 | break; |
| 2978 | case SNDRV_PCM_FORMAT_S32_LE: | 2978 | case 32: |
| 2979 | aif1 |= 0x60; | 2979 | aif1 |= 0x60; |
| 2980 | break; | 2980 | break; |
| 2981 | default: | 2981 | default: |
| @@ -3296,12 +3296,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) | |||
| 3296 | /* We need an array of texts for the enum API */ | 3296 | /* We need an array of texts for the enum API */ |
| 3297 | wm8994->drc_texts = devm_kzalloc(wm8994->hubs.codec->dev, | 3297 | wm8994->drc_texts = devm_kzalloc(wm8994->hubs.codec->dev, |
| 3298 | sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL); | 3298 | sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL); |
| 3299 | if (!wm8994->drc_texts) { | 3299 | if (!wm8994->drc_texts) |
| 3300 | dev_err(wm8994->hubs.codec->dev, | ||
| 3301 | "Failed to allocate %d DRC config texts\n", | ||
| 3302 | pdata->num_drc_cfgs); | ||
| 3303 | return; | 3300 | return; |
| 3304 | } | ||
| 3305 | 3301 | ||
| 3306 | for (i = 0; i < pdata->num_drc_cfgs; i++) | 3302 | for (i = 0; i < pdata->num_drc_cfgs; i++) |
| 3307 | wm8994->drc_texts[i] = pdata->drc_cfgs[i].name; | 3303 | wm8994->drc_texts[i] = pdata->drc_cfgs[i].name; |
| @@ -3505,6 +3501,7 @@ static irqreturn_t wm8994_mic_irq(int irq, void *data) | |||
| 3505 | return IRQ_HANDLED; | 3501 | return IRQ_HANDLED; |
| 3506 | } | 3502 | } |
| 3507 | 3503 | ||
| 3504 | /* Should be called with accdet_lock held */ | ||
| 3508 | static void wm1811_micd_stop(struct snd_soc_codec *codec) | 3505 | static void wm1811_micd_stop(struct snd_soc_codec *codec) |
| 3509 | { | 3506 | { |
| 3510 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); | 3507 | struct wm8994_priv *wm8994 = snd_soc_codec_get_drvdata(codec); |
| @@ -3512,14 +3509,10 @@ static void wm1811_micd_stop(struct snd_soc_codec *codec) | |||
| 3512 | if (!wm8994->jackdet) | 3509 | if (!wm8994->jackdet) |
| 3513 | return; | 3510 | return; |
| 3514 | 3511 | ||
| 3515 | mutex_lock(&wm8994->accdet_lock); | ||
| 3516 | |||
| 3517 | snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0); | 3512 | snd_soc_update_bits(codec, WM8958_MIC_DETECT_1, WM8958_MICD_ENA, 0); |
| 3518 | 3513 | ||
| 3519 | wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK); | 3514 | wm1811_jackdet_set_mode(codec, WM1811_JACKDET_MODE_JACK); |
| 3520 | 3515 | ||
| 3521 | mutex_unlock(&wm8994->accdet_lock); | ||
| 3522 | |||
| 3523 | if (wm8994->wm8994->pdata.jd_ext_cap) | 3516 | if (wm8994->wm8994->pdata.jd_ext_cap) |
| 3524 | snd_soc_dapm_disable_pin(&codec->dapm, | 3517 | snd_soc_dapm_disable_pin(&codec->dapm, |
| 3525 | "MICBIAS2"); | 3518 | "MICBIAS2"); |
| @@ -3560,10 +3553,10 @@ static void wm8958_open_circuit_work(struct work_struct *work) | |||
| 3560 | open_circuit_work.work); | 3553 | open_circuit_work.work); |
| 3561 | struct device *dev = wm8994->wm8994->dev; | 3554 | struct device *dev = wm8994->wm8994->dev; |
| 3562 | 3555 | ||
| 3563 | wm1811_micd_stop(wm8994->hubs.codec); | ||
| 3564 | |||
| 3565 | mutex_lock(&wm8994->accdet_lock); | 3556 | mutex_lock(&wm8994->accdet_lock); |
| 3566 | 3557 | ||
| 3558 | wm1811_micd_stop(wm8994->hubs.codec); | ||
| 3559 | |||
| 3567 | dev_dbg(dev, "Reporting open circuit\n"); | 3560 | dev_dbg(dev, "Reporting open circuit\n"); |
| 3568 | 3561 | ||
| 3569 | wm8994->jack_mic = false; | 3562 | wm8994->jack_mic = false; |
diff --git a/sound/soc/codecs/wm8995.c b/sound/soc/codecs/wm8995.c index 863a2c38bcb5..cae4ac5a5730 100644 --- a/sound/soc/codecs/wm8995.c +++ b/sound/soc/codecs/wm8995.c | |||
| @@ -1597,21 +1597,21 @@ static int wm8995_hw_params(struct snd_pcm_substream *substream, | |||
| 1597 | return bclk_rate; | 1597 | return bclk_rate; |
| 1598 | 1598 | ||
| 1599 | aif1 = 0; | 1599 | aif1 = 0; |
| 1600 | switch (params_format(params)) { | 1600 | switch (params_width(params)) { |
| 1601 | case SNDRV_PCM_FORMAT_S16_LE: | 1601 | case 16: |
| 1602 | break; | 1602 | break; |
| 1603 | case SNDRV_PCM_FORMAT_S20_3LE: | 1603 | case 20: |
| 1604 | aif1 |= (0x1 << WM8995_AIF1_WL_SHIFT); | 1604 | aif1 |= (0x1 << WM8995_AIF1_WL_SHIFT); |
| 1605 | break; | 1605 | break; |
| 1606 | case SNDRV_PCM_FORMAT_S24_LE: | 1606 | case 24: |
| 1607 | aif1 |= (0x2 << WM8995_AIF1_WL_SHIFT); | 1607 | aif1 |= (0x2 << WM8995_AIF1_WL_SHIFT); |
| 1608 | break; | 1608 | break; |
| 1609 | case SNDRV_PCM_FORMAT_S32_LE: | 1609 | case 32: |
| 1610 | aif1 |= (0x3 << WM8995_AIF1_WL_SHIFT); | 1610 | aif1 |= (0x3 << WM8995_AIF1_WL_SHIFT); |
| 1611 | break; | 1611 | break; |
| 1612 | default: | 1612 | default: |
| 1613 | dev_err(dai->dev, "Unsupported word length %u\n", | 1613 | dev_err(dai->dev, "Unsupported word length %u\n", |
| 1614 | params_format(params)); | 1614 | params_width(params)); |
| 1615 | return -EINVAL; | 1615 | return -EINVAL; |
| 1616 | } | 1616 | } |
| 1617 | 1617 | ||
diff --git a/sound/soc/codecs/wm8996.c b/sound/soc/codecs/wm8996.c index 69266332760e..f16ff4f56923 100644 --- a/sound/soc/codecs/wm8996.c +++ b/sound/soc/codecs/wm8996.c | |||
| @@ -620,15 +620,12 @@ static int bg_event(struct snd_soc_dapm_widget *w, | |||
| 620 | static int cp_event(struct snd_soc_dapm_widget *w, | 620 | static int cp_event(struct snd_soc_dapm_widget *w, |
| 621 | struct snd_kcontrol *kcontrol, int event) | 621 | struct snd_kcontrol *kcontrol, int event) |
| 622 | { | 622 | { |
| 623 | int ret = 0; | ||
| 624 | |||
| 625 | switch (event) { | 623 | switch (event) { |
| 626 | case SND_SOC_DAPM_POST_PMU: | 624 | case SND_SOC_DAPM_POST_PMU: |
| 627 | msleep(5); | 625 | msleep(5); |
| 628 | break; | 626 | break; |
| 629 | default: | 627 | default: |
| 630 | WARN(1, "Invalid event %d\n", event); | 628 | WARN(1, "Invalid event %d\n", event); |
| 631 | ret = -EINVAL; | ||
| 632 | } | 629 | } |
| 633 | 630 | ||
| 634 | return 0; | 631 | return 0; |
| @@ -690,8 +687,7 @@ static void wait_for_dc_servo(struct snd_soc_codec *codec, u16 mask) | |||
| 690 | static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, | 687 | static void wm8996_seq_notifier(struct snd_soc_dapm_context *dapm, |
| 691 | enum snd_soc_dapm_type event, int subseq) | 688 | enum snd_soc_dapm_type event, int subseq) |
| 692 | { | 689 | { |
| 693 | struct snd_soc_codec *codec = container_of(dapm, | 690 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); |
| 694 | struct snd_soc_codec, dapm); | ||
| 695 | struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); | 691 | struct wm8996_priv *wm8996 = snd_soc_codec_get_drvdata(codec); |
| 696 | u16 val, mask; | 692 | u16 val, mask; |
| 697 | 693 | ||
diff --git a/sound/soc/codecs/wm8997.c b/sound/soc/codecs/wm8997.c index bb9b47b956aa..ab33fe596519 100644 --- a/sound/soc/codecs/wm8997.c +++ b/sound/soc/codecs/wm8997.c | |||
| @@ -967,6 +967,7 @@ static struct snd_soc_dai_driver wm8997_dai[] = { | |||
| 967 | }, | 967 | }, |
| 968 | .ops = &arizona_dai_ops, | 968 | .ops = &arizona_dai_ops, |
| 969 | .symmetric_rates = 1, | 969 | .symmetric_rates = 1, |
| 970 | .symmetric_samplebits = 1, | ||
| 970 | }, | 971 | }, |
| 971 | { | 972 | { |
| 972 | .name = "wm8997-aif2", | 973 | .name = "wm8997-aif2", |
| @@ -988,6 +989,7 @@ static struct snd_soc_dai_driver wm8997_dai[] = { | |||
| 988 | }, | 989 | }, |
| 989 | .ops = &arizona_dai_ops, | 990 | .ops = &arizona_dai_ops, |
| 990 | .symmetric_rates = 1, | 991 | .symmetric_rates = 1, |
| 992 | .symmetric_samplebits = 1, | ||
| 991 | }, | 993 | }, |
| 992 | { | 994 | { |
| 993 | .name = "wm8997-slim1", | 995 | .name = "wm8997-slim1", |
diff --git a/sound/soc/codecs/wm9081.c b/sound/soc/codecs/wm9081.c index 185eb97769e7..0cdc9e2184ab 100644 --- a/sound/soc/codecs/wm9081.c +++ b/sound/soc/codecs/wm9081.c | |||
| @@ -1029,19 +1029,19 @@ static int wm9081_hw_params(struct snd_pcm_substream *substream, | |||
| 1029 | /* Otherwise work out a BCLK from the sample size */ | 1029 | /* Otherwise work out a BCLK from the sample size */ |
| 1030 | wm9081->bclk = 2 * wm9081->fs; | 1030 | wm9081->bclk = 2 * wm9081->fs; |
| 1031 | 1031 | ||
| 1032 | switch (params_format(params)) { | 1032 | switch (params_width(params)) { |
| 1033 | case SNDRV_PCM_FORMAT_S16_LE: | 1033 | case 16: |
| 1034 | wm9081->bclk *= 16; | 1034 | wm9081->bclk *= 16; |
| 1035 | break; | 1035 | break; |
| 1036 | case SNDRV_PCM_FORMAT_S20_3LE: | 1036 | case 20: |
| 1037 | wm9081->bclk *= 20; | 1037 | wm9081->bclk *= 20; |
| 1038 | aif2 |= 0x4; | 1038 | aif2 |= 0x4; |
| 1039 | break; | 1039 | break; |
| 1040 | case SNDRV_PCM_FORMAT_S24_LE: | 1040 | case 24: |
| 1041 | wm9081->bclk *= 24; | 1041 | wm9081->bclk *= 24; |
| 1042 | aif2 |= 0x8; | 1042 | aif2 |= 0x8; |
| 1043 | break; | 1043 | break; |
| 1044 | case SNDRV_PCM_FORMAT_S32_LE: | 1044 | case 32: |
| 1045 | wm9081->bclk *= 32; | 1045 | wm9081->bclk *= 32; |
| 1046 | aif2 |= 0xc; | 1046 | aif2 |= 0xc; |
| 1047 | break; | 1047 | break; |
diff --git a/sound/soc/codecs/wm9090.c b/sound/soc/codecs/wm9090.c index 87934171f063..a13f0725611a 100644 --- a/sound/soc/codecs/wm9090.c +++ b/sound/soc/codecs/wm9090.c | |||
| @@ -613,10 +613,8 @@ static int wm9090_i2c_probe(struct i2c_client *i2c, | |||
| 613 | int ret; | 613 | int ret; |
| 614 | 614 | ||
| 615 | wm9090 = devm_kzalloc(&i2c->dev, sizeof(*wm9090), GFP_KERNEL); | 615 | wm9090 = devm_kzalloc(&i2c->dev, sizeof(*wm9090), GFP_KERNEL); |
| 616 | if (wm9090 == NULL) { | 616 | if (!wm9090) |
| 617 | dev_err(&i2c->dev, "Can not allocate memory\n"); | ||
| 618 | return -ENOMEM; | 617 | return -ENOMEM; |
| 619 | } | ||
| 620 | 618 | ||
| 621 | wm9090->regmap = devm_regmap_init_i2c(i2c, &wm9090_regmap); | 619 | wm9090->regmap = devm_regmap_init_i2c(i2c, &wm9090_regmap); |
| 622 | if (IS_ERR(wm9090->regmap)) { | 620 | if (IS_ERR(wm9090->regmap)) { |
diff --git a/sound/soc/codecs/wm9713.c b/sound/soc/codecs/wm9713.c index 2a9c6d11330c..bddee30a4bc7 100644 --- a/sound/soc/codecs/wm9713.c +++ b/sound/soc/codecs/wm9713.c | |||
| @@ -953,16 +953,16 @@ static int wm9713_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 953 | struct snd_soc_codec *codec = dai->codec; | 953 | struct snd_soc_codec *codec = dai->codec; |
| 954 | u16 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0xfff3; | 954 | u16 reg = ac97_read(codec, AC97_CENTER_LFE_MASTER) & 0xfff3; |
| 955 | 955 | ||
| 956 | switch (params_format(params)) { | 956 | switch (params_width(params)) { |
| 957 | case SNDRV_PCM_FORMAT_S16_LE: | 957 | case 16: |
| 958 | break; | 958 | break; |
| 959 | case SNDRV_PCM_FORMAT_S20_3LE: | 959 | case 20: |
| 960 | reg |= 0x0004; | 960 | reg |= 0x0004; |
| 961 | break; | 961 | break; |
| 962 | case SNDRV_PCM_FORMAT_S24_LE: | 962 | case 24: |
| 963 | reg |= 0x0008; | 963 | reg |= 0x0008; |
| 964 | break; | 964 | break; |
| 965 | case SNDRV_PCM_FORMAT_S32_LE: | 965 | case 32: |
| 966 | reg |= 0x000c; | 966 | reg |= 0x000c; |
| 967 | break; | 967 | break; |
| 968 | } | 968 | } |
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 060027182dcb..f412a9911a75 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
| @@ -1382,7 +1382,7 @@ int wm_adsp1_event(struct snd_soc_dapm_widget *w, | |||
| 1382 | int ret; | 1382 | int ret; |
| 1383 | int val; | 1383 | int val; |
| 1384 | 1384 | ||
| 1385 | dsp->card = codec->card; | 1385 | dsp->card = codec->component.card; |
| 1386 | 1386 | ||
| 1387 | switch (event) { | 1387 | switch (event) { |
| 1388 | case SND_SOC_DAPM_POST_PMU: | 1388 | case SND_SOC_DAPM_POST_PMU: |
| @@ -1617,7 +1617,7 @@ int wm_adsp2_early_event(struct snd_soc_dapm_widget *w, | |||
| 1617 | struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); | 1617 | struct wm_adsp *dsps = snd_soc_codec_get_drvdata(codec); |
| 1618 | struct wm_adsp *dsp = &dsps[w->shift]; | 1618 | struct wm_adsp *dsp = &dsps[w->shift]; |
| 1619 | 1619 | ||
| 1620 | dsp->card = codec->card; | 1620 | dsp->card = codec->component.card; |
| 1621 | 1621 | ||
| 1622 | switch (event) { | 1622 | switch (event) { |
| 1623 | case SND_SOC_DAPM_PRE_PMU: | 1623 | case SND_SOC_DAPM_PRE_PMU: |
| @@ -1758,3 +1758,5 @@ int wm_adsp2_init(struct wm_adsp *adsp, bool dvfs) | |||
| 1758 | return 0; | 1758 | return 0; |
| 1759 | } | 1759 | } |
| 1760 | EXPORT_SYMBOL_GPL(wm_adsp2_init); | 1760 | EXPORT_SYMBOL_GPL(wm_adsp2_init); |
| 1761 | |||
| 1762 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/codecs/wm_hubs.c b/sound/soc/codecs/wm_hubs.c index 916817fe6632..374537d5e179 100644 --- a/sound/soc/codecs/wm_hubs.c +++ b/sound/soc/codecs/wm_hubs.c | |||
| @@ -183,10 +183,8 @@ static void wm_hubs_dcs_cache_set(struct snd_soc_codec *codec, u16 dcs_cfg) | |||
| 183 | return; | 183 | return; |
| 184 | 184 | ||
| 185 | cache = devm_kzalloc(codec->dev, sizeof(*cache), GFP_KERNEL); | 185 | cache = devm_kzalloc(codec->dev, sizeof(*cache), GFP_KERNEL); |
| 186 | if (!cache) { | 186 | if (!cache) |
| 187 | dev_err(codec->dev, "Failed to allocate DCS cache entry\n"); | ||
| 188 | return; | 187 | return; |
| 189 | } | ||
| 190 | 188 | ||
| 191 | cache->left = snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME); | 189 | cache->left = snd_soc_read(codec, WM8993_LEFT_OUTPUT_VOLUME); |
| 192 | cache->left &= WM8993_HPOUT1L_VOL_MASK; | 190 | cache->left &= WM8993_HPOUT1L_VOL_MASK; |
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index 50a098749b9e..d69510c53239 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig | |||
| @@ -1,12 +1,29 @@ | |||
| 1 | config SND_DAVINCI_SOC | 1 | config SND_DAVINCI_SOC |
| 2 | tristate "SoC Audio for TI DAVINCI or AM33XX/AM43XX chips" | 2 | tristate "SoC Audio for TI DAVINCI" |
| 3 | depends on ARCH_DAVINCI || SOC_AM33XX || SOC_AM43XX | 3 | depends on ARCH_DAVINCI |
| 4 | |||
| 5 | config SND_EDMA_SOC | ||
| 6 | tristate "SoC Audio for Texas Instruments chips using eDMA (AM33XX/43XX)" | ||
| 7 | depends on SOC_AM33XX || SOC_AM43XX | ||
| 8 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
| 9 | help | ||
| 10 | Say Y or M here if you want audio support for TI SoC which uses eDMA. | ||
| 11 | The following line of SoCs are supported by this platform driver: | ||
| 12 | - AM335x | ||
| 13 | - AM437x/AM438x | ||
| 4 | 14 | ||
| 5 | config SND_DAVINCI_SOC_I2S | 15 | config SND_DAVINCI_SOC_I2S |
| 6 | tristate | 16 | tristate |
| 7 | 17 | ||
| 8 | config SND_DAVINCI_SOC_MCASP | 18 | config SND_DAVINCI_SOC_MCASP |
| 9 | tristate | 19 | tristate "Multichannel Audio Serial Port (McASP) support" |
| 20 | depends on SND_DAVINCI_SOC || SND_OMAP_SOC || SND_EDMA_SOC | ||
| 21 | help | ||
| 22 | Say Y or M here if you want to have support for McASP IP found in | ||
| 23 | various Texas Instruments SoCs like: | ||
| 24 | - daVinci devices | ||
| 25 | - Sitara line of SoCs (AM335x, AM438x, etc) | ||
| 26 | - DRA7x devices | ||
| 10 | 27 | ||
| 11 | config SND_DAVINCI_SOC_VCIF | 28 | config SND_DAVINCI_SOC_VCIF |
| 12 | tristate | 29 | tristate |
| @@ -18,7 +35,7 @@ config SND_DAVINCI_SOC_GENERIC_EVM | |||
| 18 | 35 | ||
| 19 | config SND_AM33XX_SOC_EVM | 36 | config SND_AM33XX_SOC_EVM |
| 20 | tristate "SoC Audio for the AM33XX chip based boards" | 37 | tristate "SoC Audio for the AM33XX chip based boards" |
| 21 | depends on SND_DAVINCI_SOC && SOC_AM33XX && I2C | 38 | depends on SND_EDMA_SOC && SOC_AM33XX && I2C |
| 22 | select SND_DAVINCI_SOC_GENERIC_EVM | 39 | select SND_DAVINCI_SOC_GENERIC_EVM |
| 23 | help | 40 | help |
| 24 | Say Y or M if you want to add support for SoC audio on AM33XX | 41 | Say Y or M if you want to add support for SoC audio on AM33XX |
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile index 744d4d9a0184..09bf2ba92d38 100644 --- a/sound/soc/davinci/Makefile +++ b/sound/soc/davinci/Makefile | |||
| @@ -1,10 +1,12 @@ | |||
| 1 | # DAVINCI Platform Support | 1 | # DAVINCI Platform Support |
| 2 | snd-soc-davinci-objs := davinci-pcm.o | 2 | snd-soc-davinci-objs := davinci-pcm.o |
| 3 | snd-soc-edma-objs := edma-pcm.o | ||
| 3 | snd-soc-davinci-i2s-objs := davinci-i2s.o | 4 | snd-soc-davinci-i2s-objs := davinci-i2s.o |
| 4 | snd-soc-davinci-mcasp-objs:= davinci-mcasp.o | 5 | snd-soc-davinci-mcasp-objs:= davinci-mcasp.o |
| 5 | snd-soc-davinci-vcif-objs:= davinci-vcif.o | 6 | snd-soc-davinci-vcif-objs:= davinci-vcif.o |
| 6 | 7 | ||
| 7 | obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o | 8 | obj-$(CONFIG_SND_DAVINCI_SOC) += snd-soc-davinci.o |
| 9 | obj-$(CONFIG_SND_EDMA_SOC) += snd-soc-edma.o | ||
| 8 | obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o | 10 | obj-$(CONFIG_SND_DAVINCI_SOC_I2S) += snd-soc-davinci-i2s.o |
| 9 | obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o | 11 | obj-$(CONFIG_SND_DAVINCI_SOC_MCASP) += snd-soc-davinci-mcasp.o |
| 10 | obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o | 12 | obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o |
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 9afb14629a17..c28508da34cf 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
| @@ -27,6 +27,7 @@ | |||
| 27 | #include <linux/of_platform.h> | 27 | #include <linux/of_platform.h> |
| 28 | #include <linux/of_device.h> | 28 | #include <linux/of_device.h> |
| 29 | 29 | ||
| 30 | #include <sound/asoundef.h> | ||
| 30 | #include <sound/core.h> | 31 | #include <sound/core.h> |
| 31 | #include <sound/pcm.h> | 32 | #include <sound/pcm.h> |
| 32 | #include <sound/pcm_params.h> | 33 | #include <sound/pcm_params.h> |
| @@ -36,6 +37,7 @@ | |||
| 36 | #include <sound/omap-pcm.h> | 37 | #include <sound/omap-pcm.h> |
| 37 | 38 | ||
| 38 | #include "davinci-pcm.h" | 39 | #include "davinci-pcm.h" |
| 40 | #include "edma-pcm.h" | ||
| 39 | #include "davinci-mcasp.h" | 41 | #include "davinci-mcasp.h" |
| 40 | 42 | ||
| 41 | #define MCASP_MAX_AFIFO_DEPTH 64 | 43 | #define MCASP_MAX_AFIFO_DEPTH 64 |
| @@ -63,6 +65,7 @@ struct davinci_mcasp { | |||
| 63 | u8 num_serializer; | 65 | u8 num_serializer; |
| 64 | u8 *serial_dir; | 66 | u8 *serial_dir; |
| 65 | u8 version; | 67 | u8 version; |
| 68 | u8 bclk_div; | ||
| 66 | u16 bclk_lrclk_ratio; | 69 | u16 bclk_lrclk_ratio; |
| 67 | int streams; | 70 | int streams; |
| 68 | 71 | ||
| @@ -417,6 +420,7 @@ static int davinci_mcasp_set_clkdiv(struct snd_soc_dai *dai, int div_id, int div | |||
| 417 | ACLKXDIV(div - 1), ACLKXDIV_MASK); | 420 | ACLKXDIV(div - 1), ACLKXDIV_MASK); |
| 418 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, | 421 | mcasp_mod_bits(mcasp, DAVINCI_MCASP_ACLKRCTL_REG, |
| 419 | ACLKRDIV(div - 1), ACLKRDIV_MASK); | 422 | ACLKRDIV(div - 1), ACLKRDIV_MASK); |
| 423 | mcasp->bclk_div = div; | ||
| 420 | break; | 424 | break; |
| 421 | 425 | ||
| 422 | case 2: /* BCLK/LRCLK ratio */ | 426 | case 2: /* BCLK/LRCLK ratio */ |
| @@ -637,8 +641,12 @@ static int mcasp_i2s_hw_param(struct davinci_mcasp *mcasp, int stream) | |||
| 637 | } | 641 | } |
| 638 | 642 | ||
| 639 | /* S/PDIF */ | 643 | /* S/PDIF */ |
| 640 | static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp) | 644 | static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp, |
| 645 | unsigned int rate) | ||
| 641 | { | 646 | { |
| 647 | u32 cs_value = 0; | ||
| 648 | u8 *cs_bytes = (u8*) &cs_value; | ||
| 649 | |||
| 642 | /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 | 650 | /* Set the TX format : 24 bit right rotation, 32 bit slot, Pad 0 |
| 643 | and LSB first */ | 651 | and LSB first */ |
| 644 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXROT(6) | TXSSZ(15)); | 652 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXFMT_REG, TXROT(6) | TXSSZ(15)); |
| @@ -660,6 +668,46 @@ static int mcasp_dit_hw_param(struct davinci_mcasp *mcasp) | |||
| 660 | /* Enable the DIT */ | 668 | /* Enable the DIT */ |
| 661 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); | 669 | mcasp_set_bits(mcasp, DAVINCI_MCASP_TXDITCTL_REG, DITEN); |
| 662 | 670 | ||
| 671 | /* Set S/PDIF channel status bits */ | ||
| 672 | cs_bytes[0] = IEC958_AES0_CON_NOT_COPYRIGHT; | ||
| 673 | cs_bytes[1] = IEC958_AES1_CON_PCM_CODER; | ||
| 674 | |||
| 675 | switch (rate) { | ||
| 676 | case 22050: | ||
| 677 | cs_bytes[3] |= IEC958_AES3_CON_FS_22050; | ||
| 678 | break; | ||
| 679 | case 24000: | ||
| 680 | cs_bytes[3] |= IEC958_AES3_CON_FS_24000; | ||
| 681 | break; | ||
| 682 | case 32000: | ||
| 683 | cs_bytes[3] |= IEC958_AES3_CON_FS_32000; | ||
| 684 | break; | ||
| 685 | case 44100: | ||
| 686 | cs_bytes[3] |= IEC958_AES3_CON_FS_44100; | ||
| 687 | break; | ||
| 688 | case 48000: | ||
| 689 | cs_bytes[3] |= IEC958_AES3_CON_FS_48000; | ||
| 690 | break; | ||
| 691 | case 88200: | ||
| 692 | cs_bytes[3] |= IEC958_AES3_CON_FS_88200; | ||
| 693 | break; | ||
| 694 | case 96000: | ||
| 695 | cs_bytes[3] |= IEC958_AES3_CON_FS_96000; | ||
| 696 | break; | ||
| 697 | case 176400: | ||
| 698 | cs_bytes[3] |= IEC958_AES3_CON_FS_176400; | ||
| 699 | break; | ||
| 700 | case 192000: | ||
| 701 | cs_bytes[3] |= IEC958_AES3_CON_FS_192000; | ||
| 702 | break; | ||
| 703 | default: | ||
| 704 | printk(KERN_WARNING "unsupported sampling rate: %d\n", rate); | ||
| 705 | return -EINVAL; | ||
| 706 | } | ||
| 707 | |||
| 708 | mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRA_REG, cs_value); | ||
| 709 | mcasp_set_reg(mcasp, DAVINCI_MCASP_DITCSRB_REG, cs_value); | ||
| 710 | |||
| 663 | return 0; | 711 | return 0; |
| 664 | } | 712 | } |
| 665 | 713 | ||
| @@ -675,15 +723,22 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, | |||
| 675 | int period_size = params_period_size(params); | 723 | int period_size = params_period_size(params); |
| 676 | int ret; | 724 | int ret; |
| 677 | 725 | ||
| 678 | /* If mcasp is BCLK master we need to set BCLK divider */ | 726 | /* |
| 679 | if (mcasp->bclk_master) { | 727 | * If mcasp is BCLK master, and a BCLK divider was not provided by |
| 728 | * the machine driver, we need to calculate the ratio. | ||
| 729 | */ | ||
| 730 | if (mcasp->bclk_master && mcasp->bclk_div == 0 && mcasp->sysclk_freq) { | ||
| 680 | unsigned int bclk_freq = snd_soc_params_to_bclk(params); | 731 | unsigned int bclk_freq = snd_soc_params_to_bclk(params); |
| 732 | unsigned int div = mcasp->sysclk_freq / bclk_freq; | ||
| 681 | if (mcasp->sysclk_freq % bclk_freq != 0) { | 733 | if (mcasp->sysclk_freq % bclk_freq != 0) { |
| 682 | dev_err(mcasp->dev, "Can't produce required BCLK\n"); | 734 | if (((mcasp->sysclk_freq / div) - bclk_freq) > |
| 683 | return -EINVAL; | 735 | (bclk_freq - (mcasp->sysclk_freq / (div+1)))) |
| 736 | div++; | ||
| 737 | dev_warn(mcasp->dev, | ||
| 738 | "Inaccurate BCLK: %u Hz / %u != %u Hz\n", | ||
| 739 | mcasp->sysclk_freq, div, bclk_freq); | ||
| 684 | } | 740 | } |
| 685 | davinci_mcasp_set_clkdiv( | 741 | davinci_mcasp_set_clkdiv(cpu_dai, 1, div); |
| 686 | cpu_dai, 1, mcasp->sysclk_freq / bclk_freq); | ||
| 687 | } | 742 | } |
| 688 | 743 | ||
| 689 | ret = mcasp_common_hw_param(mcasp, substream->stream, | 744 | ret = mcasp_common_hw_param(mcasp, substream->stream, |
| @@ -692,7 +747,7 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, | |||
| 692 | return ret; | 747 | return ret; |
| 693 | 748 | ||
| 694 | if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) | 749 | if (mcasp->op_mode == DAVINCI_MCASP_DIT_MODE) |
| 695 | ret = mcasp_dit_hw_param(mcasp); | 750 | ret = mcasp_dit_hw_param(mcasp, params_rate(params)); |
| 696 | else | 751 | else |
| 697 | ret = mcasp_i2s_hw_param(mcasp, substream->stream); | 752 | ret = mcasp_i2s_hw_param(mcasp, substream->stream); |
| 698 | 753 | ||
| @@ -720,6 +775,10 @@ static int davinci_mcasp_hw_params(struct snd_pcm_substream *substream, | |||
| 720 | 775 | ||
| 721 | case SNDRV_PCM_FORMAT_U24_LE: | 776 | case SNDRV_PCM_FORMAT_U24_LE: |
| 722 | case SNDRV_PCM_FORMAT_S24_LE: | 777 | case SNDRV_PCM_FORMAT_S24_LE: |
| 778 | dma_params->data_type = 4; | ||
| 779 | word_length = 24; | ||
| 780 | break; | ||
| 781 | |||
| 723 | case SNDRV_PCM_FORMAT_U32_LE: | 782 | case SNDRV_PCM_FORMAT_U32_LE: |
| 724 | case SNDRV_PCM_FORMAT_S32_LE: | 783 | case SNDRV_PCM_FORMAT_S32_LE: |
| 725 | dma_params->data_type = 4; | 784 | dma_params->data_type = 4; |
| @@ -778,7 +837,7 @@ static int davinci_mcasp_dai_probe(struct snd_soc_dai *dai) | |||
| 778 | { | 837 | { |
| 779 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); | 838 | struct davinci_mcasp *mcasp = snd_soc_dai_get_drvdata(dai); |
| 780 | 839 | ||
| 781 | if (mcasp->version == MCASP_VERSION_4) { | 840 | if (mcasp->version >= MCASP_VERSION_3) { |
| 782 | /* Using dmaengine PCM */ | 841 | /* Using dmaengine PCM */ |
| 783 | dai->playback_dma_data = | 842 | dai->playback_dma_data = |
| 784 | &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK]; | 843 | &mcasp->dma_data[SNDRV_PCM_STREAM_PLAYBACK]; |
| @@ -1223,14 +1282,28 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
| 1223 | goto err; | 1282 | goto err; |
| 1224 | 1283 | ||
| 1225 | switch (mcasp->version) { | 1284 | switch (mcasp->version) { |
| 1285 | #if IS_BUILTIN(CONFIG_SND_DAVINCI_SOC) || \ | ||
| 1286 | (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \ | ||
| 1287 | IS_MODULE(CONFIG_SND_DAVINCI_SOC)) | ||
| 1226 | case MCASP_VERSION_1: | 1288 | case MCASP_VERSION_1: |
| 1227 | case MCASP_VERSION_2: | 1289 | case MCASP_VERSION_2: |
| 1228 | case MCASP_VERSION_3: | ||
| 1229 | ret = davinci_soc_platform_register(&pdev->dev); | 1290 | ret = davinci_soc_platform_register(&pdev->dev); |
| 1230 | break; | 1291 | break; |
| 1292 | #endif | ||
| 1293 | #if IS_BUILTIN(CONFIG_SND_EDMA_SOC) || \ | ||
| 1294 | (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \ | ||
| 1295 | IS_MODULE(CONFIG_SND_EDMA_SOC)) | ||
| 1296 | case MCASP_VERSION_3: | ||
| 1297 | ret = edma_pcm_platform_register(&pdev->dev); | ||
| 1298 | break; | ||
| 1299 | #endif | ||
| 1300 | #if IS_BUILTIN(CONFIG_SND_OMAP_SOC) || \ | ||
| 1301 | (IS_MODULE(CONFIG_SND_DAVINCI_SOC_MCASP) && \ | ||
| 1302 | IS_MODULE(CONFIG_SND_OMAP_SOC)) | ||
| 1231 | case MCASP_VERSION_4: | 1303 | case MCASP_VERSION_4: |
| 1232 | ret = omap_pcm_platform_register(&pdev->dev); | 1304 | ret = omap_pcm_platform_register(&pdev->dev); |
| 1233 | break; | 1305 | break; |
| 1306 | #endif | ||
| 1234 | default: | 1307 | default: |
| 1235 | dev_err(&pdev->dev, "Invalid McASP version: %d\n", | 1308 | dev_err(&pdev->dev, "Invalid McASP version: %d\n", |
| 1236 | mcasp->version); | 1309 | mcasp->version); |
diff --git a/sound/soc/davinci/edma-pcm.c b/sound/soc/davinci/edma-pcm.c index d38afb1c61ae..605e643133db 100644 --- a/sound/soc/davinci/edma-pcm.c +++ b/sound/soc/davinci/edma-pcm.c | |||
| @@ -28,8 +28,8 @@ | |||
| 28 | static const struct snd_pcm_hardware edma_pcm_hardware = { | 28 | static const struct snd_pcm_hardware edma_pcm_hardware = { |
| 29 | .info = SNDRV_PCM_INFO_MMAP | | 29 | .info = SNDRV_PCM_INFO_MMAP | |
| 30 | SNDRV_PCM_INFO_MMAP_VALID | | 30 | SNDRV_PCM_INFO_MMAP_VALID | |
| 31 | SNDRV_PCM_INFO_BATCH | | ||
| 32 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | | 31 | SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME | |
| 32 | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP | | ||
| 33 | SNDRV_PCM_INFO_INTERLEAVED, | 33 | SNDRV_PCM_INFO_INTERLEAVED, |
| 34 | .buffer_bytes_max = 128 * 1024, | 34 | .buffer_bytes_max = 128 * 1024, |
| 35 | .period_bytes_min = 32, | 35 | .period_bytes_min = 32, |
diff --git a/sound/soc/davinci/edma-pcm.h b/sound/soc/davinci/edma-pcm.h index 894c378c0f74..b0957744851c 100644 --- a/sound/soc/davinci/edma-pcm.h +++ b/sound/soc/davinci/edma-pcm.h | |||
| @@ -20,6 +20,13 @@ | |||
| 20 | #ifndef __EDMA_PCM_H__ | 20 | #ifndef __EDMA_PCM_H__ |
| 21 | #define __EDMA_PCM_H__ | 21 | #define __EDMA_PCM_H__ |
| 22 | 22 | ||
| 23 | #if IS_ENABLED(CONFIG_SND_EDMA_SOC) | ||
| 23 | int edma_pcm_platform_register(struct device *dev); | 24 | int edma_pcm_platform_register(struct device *dev); |
| 25 | #else | ||
| 26 | static inline int edma_pcm_platform_register(struct device *dev) | ||
| 27 | { | ||
| 28 | return 0; | ||
| 29 | } | ||
| 30 | #endif /* CONFIG_SND_EDMA_SOC */ | ||
| 24 | 31 | ||
| 25 | #endif /* __EDMA_PCM_H__ */ | 32 | #endif /* __EDMA_PCM_H__ */ |
diff --git a/sound/soc/fsl/Kconfig b/sound/soc/fsl/Kconfig index 37933629cbed..f54a8fc99291 100644 --- a/sound/soc/fsl/Kconfig +++ b/sound/soc/fsl/Kconfig | |||
| @@ -2,9 +2,20 @@ menu "SoC Audio for Freescale CPUs" | |||
| 2 | 2 | ||
| 3 | comment "Common SoC Audio options for Freescale CPUs:" | 3 | comment "Common SoC Audio options for Freescale CPUs:" |
| 4 | 4 | ||
| 5 | config SND_SOC_FSL_ASRC | ||
| 6 | tristate "Asynchronous Sample Rate Converter (ASRC) module support" | ||
| 7 | select REGMAP_MMIO | ||
| 8 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
| 9 | help | ||
| 10 | Say Y if you want to add Asynchronous Sample Rate Converter (ASRC) | ||
| 11 | support for the Freescale CPUs. | ||
| 12 | This option is only useful for out-of-tree drivers since | ||
| 13 | in-tree drivers select it automatically. | ||
| 14 | |||
| 5 | config SND_SOC_FSL_SAI | 15 | config SND_SOC_FSL_SAI |
| 6 | tristate "Synchronous Audio Interface (SAI) module support" | 16 | tristate "Synchronous Audio Interface (SAI) module support" |
| 7 | select REGMAP_MMIO | 17 | select REGMAP_MMIO |
| 18 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n | ||
| 8 | select SND_SOC_GENERIC_DMAENGINE_PCM | 19 | select SND_SOC_GENERIC_DMAENGINE_PCM |
| 9 | help | 20 | help |
| 10 | Say Y if you want to add Synchronous Audio Interface (SAI) | 21 | Say Y if you want to add Synchronous Audio Interface (SAI) |
| @@ -15,7 +26,7 @@ config SND_SOC_FSL_SAI | |||
| 15 | config SND_SOC_FSL_SSI | 26 | config SND_SOC_FSL_SSI |
| 16 | tristate "Synchronous Serial Interface module support" | 27 | tristate "Synchronous Serial Interface module support" |
| 17 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n | 28 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n |
| 18 | select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n && ARCH_MXC | 29 | select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n && (MXC_TZIC || MXC_AVIC) |
| 19 | select REGMAP_MMIO | 30 | select REGMAP_MMIO |
| 20 | help | 31 | help |
| 21 | Say Y if you want to add Synchronous Serial Interface (SSI) | 32 | Say Y if you want to add Synchronous Serial Interface (SSI) |
| @@ -27,7 +38,7 @@ config SND_SOC_FSL_SPDIF | |||
| 27 | tristate "Sony/Philips Digital Interface module support" | 38 | tristate "Sony/Philips Digital Interface module support" |
| 28 | select REGMAP_MMIO | 39 | select REGMAP_MMIO |
| 29 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n | 40 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n |
| 30 | select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n && ARCH_MXC | 41 | select SND_SOC_IMX_PCM_FIQ if SND_IMX_SOC != n && (MXC_TZIC || MXC_AVIC) |
| 31 | help | 42 | help |
| 32 | Say Y if you want to add Sony/Philips Digital Interface (SPDIF) | 43 | Say Y if you want to add Sony/Philips Digital Interface (SPDIF) |
| 33 | support for the Freescale CPUs. | 44 | support for the Freescale CPUs. |
| @@ -37,6 +48,7 @@ config SND_SOC_FSL_SPDIF | |||
| 37 | config SND_SOC_FSL_ESAI | 48 | config SND_SOC_FSL_ESAI |
| 38 | tristate "Enhanced Serial Audio Interface (ESAI) module support" | 49 | tristate "Enhanced Serial Audio Interface (ESAI) module support" |
| 39 | select REGMAP_MMIO | 50 | select REGMAP_MMIO |
| 51 | select SND_SOC_IMX_PCM_DMA if SND_IMX_SOC != n | ||
| 40 | select SND_SOC_FSL_UTILS | 52 | select SND_SOC_FSL_UTILS |
| 41 | help | 53 | help |
| 42 | Say Y if you want to add Enhanced Synchronous Audio Interface | 54 | Say Y if you want to add Enhanced Synchronous Audio Interface |
diff --git a/sound/soc/fsl/Makefile b/sound/soc/fsl/Makefile index db254e358c18..9ff59267eac9 100644 --- a/sound/soc/fsl/Makefile +++ b/sound/soc/fsl/Makefile | |||
| @@ -11,6 +11,7 @@ snd-soc-p1022-rdk-objs := p1022_rdk.o | |||
| 11 | obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o | 11 | obj-$(CONFIG_SND_SOC_P1022_RDK) += snd-soc-p1022-rdk.o |
| 12 | 12 | ||
| 13 | # Freescale SSI/DMA/SAI/SPDIF Support | 13 | # Freescale SSI/DMA/SAI/SPDIF Support |
| 14 | snd-soc-fsl-asrc-objs := fsl_asrc.o fsl_asrc_dma.o | ||
| 14 | snd-soc-fsl-sai-objs := fsl_sai.o | 15 | snd-soc-fsl-sai-objs := fsl_sai.o |
| 15 | snd-soc-fsl-ssi-y := fsl_ssi.o | 16 | snd-soc-fsl-ssi-y := fsl_ssi.o |
| 16 | snd-soc-fsl-ssi-$(CONFIG_DEBUG_FS) += fsl_ssi_dbg.o | 17 | snd-soc-fsl-ssi-$(CONFIG_DEBUG_FS) += fsl_ssi_dbg.o |
| @@ -18,6 +19,7 @@ snd-soc-fsl-spdif-objs := fsl_spdif.o | |||
| 18 | snd-soc-fsl-esai-objs := fsl_esai.o | 19 | snd-soc-fsl-esai-objs := fsl_esai.o |
| 19 | snd-soc-fsl-utils-objs := fsl_utils.o | 20 | snd-soc-fsl-utils-objs := fsl_utils.o |
| 20 | snd-soc-fsl-dma-objs := fsl_dma.o | 21 | snd-soc-fsl-dma-objs := fsl_dma.o |
| 22 | obj-$(CONFIG_SND_SOC_FSL_ASRC) += snd-soc-fsl-asrc.o | ||
| 21 | obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o | 23 | obj-$(CONFIG_SND_SOC_FSL_SAI) += snd-soc-fsl-sai.o |
| 22 | obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o | 24 | obj-$(CONFIG_SND_SOC_FSL_SSI) += snd-soc-fsl-ssi.o |
| 23 | obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o | 25 | obj-$(CONFIG_SND_SOC_FSL_SPDIF) += snd-soc-fsl-spdif.o |
diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c new file mode 100644 index 000000000000..822110420b71 --- /dev/null +++ b/sound/soc/fsl/fsl_asrc.c | |||
| @@ -0,0 +1,995 @@ | |||
| 1 | /* | ||
| 2 | * Freescale ASRC ALSA SoC Digital Audio Interface (DAI) driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Freescale Semiconductor, Inc. | ||
| 5 | * | ||
| 6 | * Author: Nicolin Chen <nicoleotsuka@gmail.com> | ||
| 7 | * | ||
| 8 | * This file is licensed under the terms of the GNU General Public License | ||
| 9 | * version 2. This program is licensed "as is" without any warranty of any | ||
| 10 | * kind, whether express or implied. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/clk.h> | ||
| 14 | #include <linux/delay.h> | ||
| 15 | #include <linux/dma-mapping.h> | ||
| 16 | #include <linux/module.h> | ||
| 17 | #include <linux/of_platform.h> | ||
| 18 | #include <linux/platform_data/dma-imx.h> | ||
| 19 | #include <linux/pm_runtime.h> | ||
| 20 | #include <sound/dmaengine_pcm.h> | ||
| 21 | #include <sound/pcm_params.h> | ||
| 22 | |||
| 23 | #include "fsl_asrc.h" | ||
| 24 | |||
| 25 | #define IDEAL_RATIO_DECIMAL_DEPTH 26 | ||
| 26 | |||
| 27 | #define pair_err(fmt, ...) \ | ||
| 28 | dev_err(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__) | ||
| 29 | |||
| 30 | #define pair_dbg(fmt, ...) \ | ||
| 31 | dev_dbg(&asrc_priv->pdev->dev, "Pair %c: " fmt, 'A' + index, ##__VA_ARGS__) | ||
| 32 | |||
| 33 | /* Sample rates are aligned with that defined in pcm.h file */ | ||
| 34 | static const u8 process_option[][8][2] = { | ||
| 35 | /* 32kHz 44.1kHz 48kHz 64kHz 88.2kHz 96kHz 176kHz 192kHz */ | ||
| 36 | {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 5512Hz */ | ||
| 37 | {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 8kHz */ | ||
| 38 | {{0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 11025Hz */ | ||
| 39 | {{0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 16kHz */ | ||
| 40 | {{0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0}, {0, 0}, {0, 0},}, /* 22050Hz */ | ||
| 41 | {{0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0}, {0, 0},}, /* 32kHz */ | ||
| 42 | {{0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0},}, /* 44.1kHz */ | ||
| 43 | {{0, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0}, {0, 0},}, /* 48kHz */ | ||
| 44 | {{1, 2}, {0, 2}, {0, 2}, {0, 1}, {0, 1}, {0, 1}, {0, 1}, {0, 0},}, /* 64kHz */ | ||
| 45 | {{1, 2}, {1, 2}, {1, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},}, /* 88.2kHz */ | ||
| 46 | {{1, 2}, {1, 2}, {1, 2}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1},}, /* 96kHz */ | ||
| 47 | {{2, 2}, {2, 2}, {2, 2}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1},}, /* 176kHz */ | ||
| 48 | {{2, 2}, {2, 2}, {2, 2}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1},}, /* 192kHz */ | ||
| 49 | }; | ||
| 50 | |||
| 51 | /* Corresponding to process_option */ | ||
| 52 | static int supported_input_rate[] = { | ||
| 53 | 5512, 8000, 11025, 16000, 22050, 32000, 44100, 48000, 64000, 88200, | ||
| 54 | 96000, 176400, 192000, | ||
| 55 | }; | ||
| 56 | |||
| 57 | static int supported_asrc_rate[] = { | ||
| 58 | 32000, 44100, 48000, 64000, 88200, 96000, 176400, 192000, | ||
| 59 | }; | ||
| 60 | |||
| 61 | /** | ||
| 62 | * The following tables map the relationship between asrc_inclk/asrc_outclk in | ||
| 63 | * fsl_asrc.h and the registers of ASRCSR | ||
| 64 | */ | ||
| 65 | static unsigned char input_clk_map_imx35[] = { | ||
| 66 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, | ||
| 67 | }; | ||
| 68 | |||
| 69 | static unsigned char output_clk_map_imx35[] = { | ||
| 70 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0xa, 0xb, 0xc, 0xd, 0xe, 0xf, | ||
| 71 | }; | ||
| 72 | |||
| 73 | /* i.MX53 uses the same map for input and output */ | ||
| 74 | static unsigned char input_clk_map_imx53[] = { | ||
| 75 | /* 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf */ | ||
| 76 | 0x0, 0x1, 0x2, 0x7, 0x4, 0x5, 0x6, 0x3, 0x8, 0x9, 0xa, 0xb, 0xc, 0xf, 0xe, 0xd, | ||
| 77 | }; | ||
| 78 | |||
| 79 | static unsigned char output_clk_map_imx53[] = { | ||
| 80 | /* 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xa 0xb 0xc 0xd 0xe 0xf */ | ||
| 81 | 0x8, 0x9, 0xa, 0x7, 0xc, 0x5, 0x6, 0xb, 0x0, 0x1, 0x2, 0x3, 0x4, 0xf, 0xe, 0xd, | ||
| 82 | }; | ||
| 83 | |||
| 84 | static unsigned char *clk_map[2]; | ||
| 85 | |||
| 86 | /** | ||
| 87 | * Request ASRC pair | ||
| 88 | * | ||
| 89 | * It assigns pair by the order of A->C->B because allocation of pair B, | ||
| 90 | * within range [ANCA, ANCA+ANCB-1], depends on the channels of pair A | ||
| 91 | * while pair A and pair C are comparatively independent. | ||
| 92 | */ | ||
| 93 | static int fsl_asrc_request_pair(int channels, struct fsl_asrc_pair *pair) | ||
| 94 | { | ||
| 95 | enum asrc_pair_index index = ASRC_INVALID_PAIR; | ||
| 96 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 97 | struct device *dev = &asrc_priv->pdev->dev; | ||
| 98 | unsigned long lock_flags; | ||
| 99 | int i, ret = 0; | ||
| 100 | |||
| 101 | spin_lock_irqsave(&asrc_priv->lock, lock_flags); | ||
| 102 | |||
| 103 | for (i = ASRC_PAIR_A; i < ASRC_PAIR_MAX_NUM; i++) { | ||
| 104 | if (asrc_priv->pair[i] != NULL) | ||
| 105 | continue; | ||
| 106 | |||
| 107 | index = i; | ||
| 108 | |||
| 109 | if (i != ASRC_PAIR_B) | ||
| 110 | break; | ||
| 111 | } | ||
| 112 | |||
| 113 | if (index == ASRC_INVALID_PAIR) { | ||
| 114 | dev_err(dev, "all pairs are busy now\n"); | ||
| 115 | ret = -EBUSY; | ||
| 116 | } else if (asrc_priv->channel_avail < channels) { | ||
| 117 | dev_err(dev, "can't afford required channels: %d\n", channels); | ||
| 118 | ret = -EINVAL; | ||
| 119 | } else { | ||
| 120 | asrc_priv->channel_avail -= channels; | ||
| 121 | asrc_priv->pair[index] = pair; | ||
| 122 | pair->channels = channels; | ||
| 123 | pair->index = index; | ||
| 124 | } | ||
| 125 | |||
| 126 | spin_unlock_irqrestore(&asrc_priv->lock, lock_flags); | ||
| 127 | |||
| 128 | return ret; | ||
| 129 | } | ||
| 130 | |||
| 131 | /** | ||
| 132 | * Release ASRC pair | ||
| 133 | * | ||
| 134 | * It clears the resource from asrc_priv and releases the occupied channels. | ||
| 135 | */ | ||
| 136 | static void fsl_asrc_release_pair(struct fsl_asrc_pair *pair) | ||
| 137 | { | ||
| 138 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 139 | enum asrc_pair_index index = pair->index; | ||
| 140 | unsigned long lock_flags; | ||
| 141 | |||
| 142 | /* Make sure the pair is disabled */ | ||
| 143 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 144 | ASRCTR_ASRCEi_MASK(index), 0); | ||
| 145 | |||
| 146 | spin_lock_irqsave(&asrc_priv->lock, lock_flags); | ||
| 147 | |||
| 148 | asrc_priv->channel_avail += pair->channels; | ||
| 149 | asrc_priv->pair[index] = NULL; | ||
| 150 | pair->error = 0; | ||
| 151 | |||
| 152 | spin_unlock_irqrestore(&asrc_priv->lock, lock_flags); | ||
| 153 | } | ||
| 154 | |||
| 155 | /** | ||
| 156 | * Configure input and output thresholds | ||
| 157 | */ | ||
| 158 | static void fsl_asrc_set_watermarks(struct fsl_asrc_pair *pair, u32 in, u32 out) | ||
| 159 | { | ||
| 160 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 161 | enum asrc_pair_index index = pair->index; | ||
| 162 | |||
| 163 | regmap_update_bits(asrc_priv->regmap, REG_ASRMCR(index), | ||
| 164 | ASRMCRi_EXTTHRSHi_MASK | | ||
| 165 | ASRMCRi_INFIFO_THRESHOLD_MASK | | ||
| 166 | ASRMCRi_OUTFIFO_THRESHOLD_MASK, | ||
| 167 | ASRMCRi_EXTTHRSHi | | ||
| 168 | ASRMCRi_INFIFO_THRESHOLD(in) | | ||
| 169 | ASRMCRi_OUTFIFO_THRESHOLD(out)); | ||
| 170 | } | ||
| 171 | |||
| 172 | /** | ||
| 173 | * Calculate the total divisor between asrck clock rate and sample rate | ||
| 174 | * | ||
| 175 | * It follows the formula clk_rate = samplerate * (2 ^ prescaler) * divider | ||
| 176 | */ | ||
| 177 | static u32 fsl_asrc_cal_asrck_divisor(struct fsl_asrc_pair *pair, u32 div) | ||
| 178 | { | ||
| 179 | u32 ps; | ||
| 180 | |||
| 181 | /* Calculate the divisors: prescaler [2^0, 2^7], divder [1, 8] */ | ||
| 182 | for (ps = 0; div > 8; ps++) | ||
| 183 | div >>= 1; | ||
| 184 | |||
| 185 | return ((div - 1) << ASRCDRi_AxCPi_WIDTH) | ps; | ||
| 186 | } | ||
| 187 | |||
| 188 | /** | ||
| 189 | * Calculate and set the ratio for Ideal Ratio mode only | ||
| 190 | * | ||
| 191 | * The ratio is a 32-bit fixed point value with 26 fractional bits. | ||
| 192 | */ | ||
| 193 | static int fsl_asrc_set_ideal_ratio(struct fsl_asrc_pair *pair, | ||
| 194 | int inrate, int outrate) | ||
| 195 | { | ||
| 196 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 197 | enum asrc_pair_index index = pair->index; | ||
| 198 | unsigned long ratio; | ||
| 199 | int i; | ||
| 200 | |||
| 201 | if (!outrate) { | ||
| 202 | pair_err("output rate should not be zero\n"); | ||
| 203 | return -EINVAL; | ||
| 204 | } | ||
| 205 | |||
| 206 | /* Calculate the intergal part of the ratio */ | ||
| 207 | ratio = (inrate / outrate) << IDEAL_RATIO_DECIMAL_DEPTH; | ||
| 208 | |||
| 209 | /* ... and then the 26 depth decimal part */ | ||
| 210 | inrate %= outrate; | ||
| 211 | |||
| 212 | for (i = 1; i <= IDEAL_RATIO_DECIMAL_DEPTH; i++) { | ||
| 213 | inrate <<= 1; | ||
| 214 | |||
| 215 | if (inrate < outrate) | ||
| 216 | continue; | ||
| 217 | |||
| 218 | ratio |= 1 << (IDEAL_RATIO_DECIMAL_DEPTH - i); | ||
| 219 | inrate -= outrate; | ||
| 220 | |||
| 221 | if (!inrate) | ||
| 222 | break; | ||
| 223 | } | ||
| 224 | |||
| 225 | regmap_write(asrc_priv->regmap, REG_ASRIDRL(index), ratio); | ||
| 226 | regmap_write(asrc_priv->regmap, REG_ASRIDRH(index), ratio >> 24); | ||
| 227 | |||
| 228 | return 0; | ||
| 229 | } | ||
| 230 | |||
| 231 | /** | ||
| 232 | * Configure the assigned ASRC pair | ||
| 233 | * | ||
| 234 | * It configures those ASRC registers according to a configuration instance | ||
| 235 | * of struct asrc_config which includes in/output sample rate, width, channel | ||
| 236 | * and clock settings. | ||
| 237 | */ | ||
| 238 | static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) | ||
| 239 | { | ||
| 240 | struct asrc_config *config = pair->config; | ||
| 241 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 242 | enum asrc_pair_index index = pair->index; | ||
| 243 | u32 inrate, outrate, indiv, outdiv; | ||
| 244 | u32 clk_index[2], div[2]; | ||
| 245 | int in, out, channels; | ||
| 246 | struct clk *clk; | ||
| 247 | bool ideal; | ||
| 248 | |||
| 249 | if (!config) { | ||
| 250 | pair_err("invalid pair config\n"); | ||
| 251 | return -EINVAL; | ||
| 252 | } | ||
| 253 | |||
| 254 | /* Validate channels */ | ||
| 255 | if (config->channel_num < 1 || config->channel_num > 10) { | ||
| 256 | pair_err("does not support %d channels\n", config->channel_num); | ||
| 257 | return -EINVAL; | ||
| 258 | } | ||
| 259 | |||
| 260 | /* Validate output width */ | ||
| 261 | if (config->output_word_width == ASRC_WIDTH_8_BIT) { | ||
| 262 | pair_err("does not support 8bit width output\n"); | ||
| 263 | return -EINVAL; | ||
| 264 | } | ||
| 265 | |||
| 266 | inrate = config->input_sample_rate; | ||
| 267 | outrate = config->output_sample_rate; | ||
| 268 | ideal = config->inclk == INCLK_NONE; | ||
| 269 | |||
| 270 | /* Validate input and output sample rates */ | ||
| 271 | for (in = 0; in < ARRAY_SIZE(supported_input_rate); in++) | ||
| 272 | if (inrate == supported_input_rate[in]) | ||
| 273 | break; | ||
| 274 | |||
| 275 | if (in == ARRAY_SIZE(supported_input_rate)) { | ||
| 276 | pair_err("unsupported input sample rate: %dHz\n", inrate); | ||
| 277 | return -EINVAL; | ||
| 278 | } | ||
| 279 | |||
| 280 | for (out = 0; out < ARRAY_SIZE(supported_asrc_rate); out++) | ||
| 281 | if (outrate == supported_asrc_rate[out]) | ||
| 282 | break; | ||
| 283 | |||
| 284 | if (out == ARRAY_SIZE(supported_asrc_rate)) { | ||
| 285 | pair_err("unsupported output sample rate: %dHz\n", outrate); | ||
| 286 | return -EINVAL; | ||
| 287 | } | ||
| 288 | |||
| 289 | /* Validate input and output clock sources */ | ||
| 290 | clk_index[IN] = clk_map[IN][config->inclk]; | ||
| 291 | clk_index[OUT] = clk_map[OUT][config->outclk]; | ||
| 292 | |||
| 293 | /* We only have output clock for ideal ratio mode */ | ||
| 294 | clk = asrc_priv->asrck_clk[clk_index[ideal ? OUT : IN]]; | ||
| 295 | |||
| 296 | div[IN] = clk_get_rate(clk) / inrate; | ||
| 297 | if (div[IN] == 0) { | ||
| 298 | pair_err("failed to support input sample rate %dHz by asrck_%x\n", | ||
| 299 | inrate, clk_index[ideal ? OUT : IN]); | ||
| 300 | return -EINVAL; | ||
| 301 | } | ||
| 302 | |||
| 303 | clk = asrc_priv->asrck_clk[clk_index[OUT]]; | ||
| 304 | |||
| 305 | /* Use fixed output rate for Ideal Ratio mode (INCLK_NONE) */ | ||
| 306 | if (ideal) | ||
| 307 | div[OUT] = clk_get_rate(clk) / IDEAL_RATIO_RATE; | ||
| 308 | else | ||
| 309 | div[OUT] = clk_get_rate(clk) / outrate; | ||
| 310 | |||
| 311 | if (div[OUT] == 0) { | ||
| 312 | pair_err("failed to support output sample rate %dHz by asrck_%x\n", | ||
| 313 | outrate, clk_index[OUT]); | ||
| 314 | return -EINVAL; | ||
| 315 | } | ||
| 316 | |||
| 317 | /* Set the channel number */ | ||
| 318 | channels = config->channel_num; | ||
| 319 | |||
| 320 | if (asrc_priv->channel_bits < 4) | ||
| 321 | channels /= 2; | ||
| 322 | |||
| 323 | /* Update channels for current pair */ | ||
| 324 | regmap_update_bits(asrc_priv->regmap, REG_ASRCNCR, | ||
| 325 | ASRCNCR_ANCi_MASK(index, asrc_priv->channel_bits), | ||
| 326 | ASRCNCR_ANCi(index, channels, asrc_priv->channel_bits)); | ||
| 327 | |||
| 328 | /* Default setting: Automatic selection for processing mode */ | ||
| 329 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 330 | ASRCTR_ATSi_MASK(index), ASRCTR_ATS(index)); | ||
| 331 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 332 | ASRCTR_USRi_MASK(index), 0); | ||
| 333 | |||
| 334 | /* Set the input and output clock sources */ | ||
| 335 | regmap_update_bits(asrc_priv->regmap, REG_ASRCSR, | ||
| 336 | ASRCSR_AICSi_MASK(index) | ASRCSR_AOCSi_MASK(index), | ||
| 337 | ASRCSR_AICS(index, clk_index[IN]) | | ||
| 338 | ASRCSR_AOCS(index, clk_index[OUT])); | ||
| 339 | |||
| 340 | /* Calculate the input clock divisors */ | ||
| 341 | indiv = fsl_asrc_cal_asrck_divisor(pair, div[IN]); | ||
| 342 | outdiv = fsl_asrc_cal_asrck_divisor(pair, div[OUT]); | ||
| 343 | |||
| 344 | /* Suppose indiv and outdiv includes prescaler, so add its MASK too */ | ||
| 345 | regmap_update_bits(asrc_priv->regmap, REG_ASRCDR(index), | ||
| 346 | ASRCDRi_AOCPi_MASK(index) | ASRCDRi_AICPi_MASK(index) | | ||
| 347 | ASRCDRi_AOCDi_MASK(index) | ASRCDRi_AICDi_MASK(index), | ||
| 348 | ASRCDRi_AOCP(index, outdiv) | ASRCDRi_AICP(index, indiv)); | ||
| 349 | |||
| 350 | /* Implement word_width configurations */ | ||
| 351 | regmap_update_bits(asrc_priv->regmap, REG_ASRMCR1(index), | ||
| 352 | ASRMCR1i_OW16_MASK | ASRMCR1i_IWD_MASK, | ||
| 353 | ASRMCR1i_OW16(config->output_word_width) | | ||
| 354 | ASRMCR1i_IWD(config->input_word_width)); | ||
| 355 | |||
| 356 | /* Enable BUFFER STALL */ | ||
| 357 | regmap_update_bits(asrc_priv->regmap, REG_ASRMCR(index), | ||
| 358 | ASRMCRi_BUFSTALLi_MASK, ASRMCRi_BUFSTALLi); | ||
| 359 | |||
| 360 | /* Set default thresholds for input and output FIFO */ | ||
| 361 | fsl_asrc_set_watermarks(pair, ASRC_INPUTFIFO_THRESHOLD, | ||
| 362 | ASRC_INPUTFIFO_THRESHOLD); | ||
| 363 | |||
| 364 | /* Configure the followings only for Ideal Ratio mode */ | ||
| 365 | if (!ideal) | ||
| 366 | return 0; | ||
| 367 | |||
| 368 | /* Clear ASTSx bit to use Ideal Ratio mode */ | ||
| 369 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 370 | ASRCTR_ATSi_MASK(index), 0); | ||
| 371 | |||
| 372 | /* Enable Ideal Ratio mode */ | ||
| 373 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 374 | ASRCTR_IDRi_MASK(index) | ASRCTR_USRi_MASK(index), | ||
| 375 | ASRCTR_IDR(index) | ASRCTR_USR(index)); | ||
| 376 | |||
| 377 | /* Apply configurations for pre- and post-processing */ | ||
| 378 | regmap_update_bits(asrc_priv->regmap, REG_ASRCFG, | ||
| 379 | ASRCFG_PREMODi_MASK(index) | ASRCFG_POSTMODi_MASK(index), | ||
| 380 | ASRCFG_PREMOD(index, process_option[in][out][0]) | | ||
| 381 | ASRCFG_POSTMOD(index, process_option[in][out][1])); | ||
| 382 | |||
| 383 | return fsl_asrc_set_ideal_ratio(pair, inrate, outrate); | ||
| 384 | } | ||
| 385 | |||
| 386 | /** | ||
| 387 | * Start the assigned ASRC pair | ||
| 388 | * | ||
| 389 | * It enables the assigned pair and makes it stopped at the stall level. | ||
| 390 | */ | ||
| 391 | static void fsl_asrc_start_pair(struct fsl_asrc_pair *pair) | ||
| 392 | { | ||
| 393 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 394 | enum asrc_pair_index index = pair->index; | ||
| 395 | int reg, retry = 10, i; | ||
| 396 | |||
| 397 | /* Enable the current pair */ | ||
| 398 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 399 | ASRCTR_ASRCEi_MASK(index), ASRCTR_ASRCE(index)); | ||
| 400 | |||
| 401 | /* Wait for status of initialization */ | ||
| 402 | do { | ||
| 403 | udelay(5); | ||
| 404 | regmap_read(asrc_priv->regmap, REG_ASRCFG, ®); | ||
| 405 | reg &= ASRCFG_INIRQi_MASK(index); | ||
| 406 | } while (!reg && --retry); | ||
| 407 | |||
| 408 | /* Make the input fifo to ASRC STALL level */ | ||
| 409 | regmap_read(asrc_priv->regmap, REG_ASRCNCR, ®); | ||
| 410 | for (i = 0; i < pair->channels * 4; i++) | ||
| 411 | regmap_write(asrc_priv->regmap, REG_ASRDI(index), 0); | ||
| 412 | |||
| 413 | /* Enable overload interrupt */ | ||
| 414 | regmap_write(asrc_priv->regmap, REG_ASRIER, ASRIER_AOLIE); | ||
| 415 | } | ||
| 416 | |||
| 417 | /** | ||
| 418 | * Stop the assigned ASRC pair | ||
| 419 | */ | ||
| 420 | static void fsl_asrc_stop_pair(struct fsl_asrc_pair *pair) | ||
| 421 | { | ||
| 422 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 423 | enum asrc_pair_index index = pair->index; | ||
| 424 | |||
| 425 | /* Stop the current pair */ | ||
| 426 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 427 | ASRCTR_ASRCEi_MASK(index), 0); | ||
| 428 | } | ||
| 429 | |||
| 430 | /** | ||
| 431 | * Get DMA channel according to the pair and direction. | ||
| 432 | */ | ||
| 433 | struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir) | ||
| 434 | { | ||
| 435 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 436 | enum asrc_pair_index index = pair->index; | ||
| 437 | char name[4]; | ||
| 438 | |||
| 439 | sprintf(name, "%cx%c", dir == IN ? 'r' : 't', index + 'a'); | ||
| 440 | |||
| 441 | return dma_request_slave_channel(&asrc_priv->pdev->dev, name); | ||
| 442 | } | ||
| 443 | EXPORT_SYMBOL_GPL(fsl_asrc_get_dma_channel); | ||
| 444 | |||
| 445 | static int fsl_asrc_dai_hw_params(struct snd_pcm_substream *substream, | ||
| 446 | struct snd_pcm_hw_params *params, | ||
| 447 | struct snd_soc_dai *dai) | ||
| 448 | { | ||
| 449 | struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai); | ||
| 450 | int width = snd_pcm_format_width(params_format(params)); | ||
| 451 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 452 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 453 | unsigned int channels = params_channels(params); | ||
| 454 | unsigned int rate = params_rate(params); | ||
| 455 | struct asrc_config config; | ||
| 456 | int word_width, ret; | ||
| 457 | |||
| 458 | ret = fsl_asrc_request_pair(channels, pair); | ||
| 459 | if (ret) { | ||
| 460 | dev_err(dai->dev, "fail to request asrc pair\n"); | ||
| 461 | return ret; | ||
| 462 | } | ||
| 463 | |||
| 464 | pair->config = &config; | ||
| 465 | |||
| 466 | if (width == 16) | ||
| 467 | width = ASRC_WIDTH_16_BIT; | ||
| 468 | else | ||
| 469 | width = ASRC_WIDTH_24_BIT; | ||
| 470 | |||
| 471 | if (asrc_priv->asrc_width == 16) | ||
| 472 | word_width = ASRC_WIDTH_16_BIT; | ||
| 473 | else | ||
| 474 | word_width = ASRC_WIDTH_24_BIT; | ||
| 475 | |||
| 476 | config.pair = pair->index; | ||
| 477 | config.channel_num = channels; | ||
| 478 | config.inclk = INCLK_NONE; | ||
| 479 | config.outclk = OUTCLK_ASRCK1_CLK; | ||
| 480 | |||
| 481 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
| 482 | config.input_word_width = width; | ||
| 483 | config.output_word_width = word_width; | ||
| 484 | config.input_sample_rate = rate; | ||
| 485 | config.output_sample_rate = asrc_priv->asrc_rate; | ||
| 486 | } else { | ||
| 487 | config.input_word_width = word_width; | ||
| 488 | config.output_word_width = width; | ||
| 489 | config.input_sample_rate = asrc_priv->asrc_rate; | ||
| 490 | config.output_sample_rate = rate; | ||
| 491 | } | ||
| 492 | |||
| 493 | ret = fsl_asrc_config_pair(pair); | ||
| 494 | if (ret) { | ||
| 495 | dev_err(dai->dev, "fail to config asrc pair\n"); | ||
| 496 | return ret; | ||
| 497 | } | ||
| 498 | |||
| 499 | return 0; | ||
| 500 | } | ||
| 501 | |||
| 502 | static int fsl_asrc_dai_hw_free(struct snd_pcm_substream *substream, | ||
| 503 | struct snd_soc_dai *dai) | ||
| 504 | { | ||
| 505 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 506 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 507 | |||
| 508 | if (pair) | ||
| 509 | fsl_asrc_release_pair(pair); | ||
| 510 | |||
| 511 | return 0; | ||
| 512 | } | ||
| 513 | |||
| 514 | static int fsl_asrc_dai_trigger(struct snd_pcm_substream *substream, int cmd, | ||
| 515 | struct snd_soc_dai *dai) | ||
| 516 | { | ||
| 517 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 518 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 519 | |||
| 520 | switch (cmd) { | ||
| 521 | case SNDRV_PCM_TRIGGER_START: | ||
| 522 | case SNDRV_PCM_TRIGGER_RESUME: | ||
| 523 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
| 524 | fsl_asrc_start_pair(pair); | ||
| 525 | break; | ||
| 526 | case SNDRV_PCM_TRIGGER_STOP: | ||
| 527 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
| 528 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
| 529 | fsl_asrc_stop_pair(pair); | ||
| 530 | break; | ||
| 531 | default: | ||
| 532 | return -EINVAL; | ||
| 533 | } | ||
| 534 | |||
| 535 | return 0; | ||
| 536 | } | ||
| 537 | |||
| 538 | static struct snd_soc_dai_ops fsl_asrc_dai_ops = { | ||
| 539 | .hw_params = fsl_asrc_dai_hw_params, | ||
| 540 | .hw_free = fsl_asrc_dai_hw_free, | ||
| 541 | .trigger = fsl_asrc_dai_trigger, | ||
| 542 | }; | ||
| 543 | |||
| 544 | static int fsl_asrc_dai_probe(struct snd_soc_dai *dai) | ||
| 545 | { | ||
| 546 | struct fsl_asrc *asrc_priv = snd_soc_dai_get_drvdata(dai); | ||
| 547 | |||
| 548 | snd_soc_dai_init_dma_data(dai, &asrc_priv->dma_params_tx, | ||
| 549 | &asrc_priv->dma_params_rx); | ||
| 550 | |||
| 551 | return 0; | ||
| 552 | } | ||
| 553 | |||
| 554 | #define FSL_ASRC_RATES SNDRV_PCM_RATE_8000_192000 | ||
| 555 | #define FSL_ASRC_FORMATS (SNDRV_PCM_FMTBIT_S24_LE | \ | ||
| 556 | SNDRV_PCM_FMTBIT_S16_LE | \ | ||
| 557 | SNDRV_PCM_FMTBIT_S20_3LE) | ||
| 558 | |||
| 559 | static struct snd_soc_dai_driver fsl_asrc_dai = { | ||
| 560 | .probe = fsl_asrc_dai_probe, | ||
| 561 | .playback = { | ||
| 562 | .stream_name = "ASRC-Playback", | ||
| 563 | .channels_min = 1, | ||
| 564 | .channels_max = 10, | ||
| 565 | .rates = FSL_ASRC_RATES, | ||
| 566 | .formats = FSL_ASRC_FORMATS, | ||
| 567 | }, | ||
| 568 | .capture = { | ||
| 569 | .stream_name = "ASRC-Capture", | ||
| 570 | .channels_min = 1, | ||
| 571 | .channels_max = 10, | ||
| 572 | .rates = FSL_ASRC_RATES, | ||
| 573 | .formats = FSL_ASRC_FORMATS, | ||
| 574 | }, | ||
| 575 | .ops = &fsl_asrc_dai_ops, | ||
| 576 | }; | ||
| 577 | |||
| 578 | static const struct snd_soc_component_driver fsl_asrc_component = { | ||
| 579 | .name = "fsl-asrc-dai", | ||
| 580 | }; | ||
| 581 | |||
| 582 | static bool fsl_asrc_readable_reg(struct device *dev, unsigned int reg) | ||
| 583 | { | ||
| 584 | switch (reg) { | ||
| 585 | case REG_ASRCTR: | ||
| 586 | case REG_ASRIER: | ||
| 587 | case REG_ASRCNCR: | ||
| 588 | case REG_ASRCFG: | ||
| 589 | case REG_ASRCSR: | ||
| 590 | case REG_ASRCDR1: | ||
| 591 | case REG_ASRCDR2: | ||
| 592 | case REG_ASRSTR: | ||
| 593 | case REG_ASRPM1: | ||
| 594 | case REG_ASRPM2: | ||
| 595 | case REG_ASRPM3: | ||
| 596 | case REG_ASRPM4: | ||
| 597 | case REG_ASRPM5: | ||
| 598 | case REG_ASRTFR1: | ||
| 599 | case REG_ASRCCR: | ||
| 600 | case REG_ASRDOA: | ||
| 601 | case REG_ASRDOB: | ||
| 602 | case REG_ASRDOC: | ||
| 603 | case REG_ASRIDRHA: | ||
| 604 | case REG_ASRIDRLA: | ||
| 605 | case REG_ASRIDRHB: | ||
| 606 | case REG_ASRIDRLB: | ||
| 607 | case REG_ASRIDRHC: | ||
| 608 | case REG_ASRIDRLC: | ||
| 609 | case REG_ASR76K: | ||
| 610 | case REG_ASR56K: | ||
| 611 | case REG_ASRMCRA: | ||
| 612 | case REG_ASRFSTA: | ||
| 613 | case REG_ASRMCRB: | ||
| 614 | case REG_ASRFSTB: | ||
| 615 | case REG_ASRMCRC: | ||
| 616 | case REG_ASRFSTC: | ||
| 617 | case REG_ASRMCR1A: | ||
| 618 | case REG_ASRMCR1B: | ||
| 619 | case REG_ASRMCR1C: | ||
| 620 | return true; | ||
| 621 | default: | ||
| 622 | return false; | ||
| 623 | } | ||
| 624 | } | ||
| 625 | |||
| 626 | static bool fsl_asrc_volatile_reg(struct device *dev, unsigned int reg) | ||
| 627 | { | ||
| 628 | switch (reg) { | ||
| 629 | case REG_ASRSTR: | ||
| 630 | case REG_ASRDIA: | ||
| 631 | case REG_ASRDIB: | ||
| 632 | case REG_ASRDIC: | ||
| 633 | case REG_ASRDOA: | ||
| 634 | case REG_ASRDOB: | ||
| 635 | case REG_ASRDOC: | ||
| 636 | case REG_ASRFSTA: | ||
| 637 | case REG_ASRFSTB: | ||
| 638 | case REG_ASRFSTC: | ||
| 639 | case REG_ASRCFG: | ||
| 640 | return true; | ||
| 641 | default: | ||
| 642 | return false; | ||
| 643 | } | ||
| 644 | } | ||
| 645 | |||
| 646 | static bool fsl_asrc_writeable_reg(struct device *dev, unsigned int reg) | ||
| 647 | { | ||
| 648 | switch (reg) { | ||
| 649 | case REG_ASRCTR: | ||
| 650 | case REG_ASRIER: | ||
| 651 | case REG_ASRCNCR: | ||
| 652 | case REG_ASRCFG: | ||
| 653 | case REG_ASRCSR: | ||
| 654 | case REG_ASRCDR1: | ||
| 655 | case REG_ASRCDR2: | ||
| 656 | case REG_ASRSTR: | ||
| 657 | case REG_ASRPM1: | ||
| 658 | case REG_ASRPM2: | ||
| 659 | case REG_ASRPM3: | ||
| 660 | case REG_ASRPM4: | ||
| 661 | case REG_ASRPM5: | ||
| 662 | case REG_ASRTFR1: | ||
| 663 | case REG_ASRCCR: | ||
| 664 | case REG_ASRDIA: | ||
| 665 | case REG_ASRDIB: | ||
| 666 | case REG_ASRDIC: | ||
| 667 | case REG_ASRIDRHA: | ||
| 668 | case REG_ASRIDRLA: | ||
| 669 | case REG_ASRIDRHB: | ||
| 670 | case REG_ASRIDRLB: | ||
| 671 | case REG_ASRIDRHC: | ||
| 672 | case REG_ASRIDRLC: | ||
| 673 | case REG_ASR76K: | ||
| 674 | case REG_ASR56K: | ||
| 675 | case REG_ASRMCRA: | ||
| 676 | case REG_ASRMCRB: | ||
| 677 | case REG_ASRMCRC: | ||
| 678 | case REG_ASRMCR1A: | ||
| 679 | case REG_ASRMCR1B: | ||
| 680 | case REG_ASRMCR1C: | ||
| 681 | return true; | ||
| 682 | default: | ||
| 683 | return false; | ||
| 684 | } | ||
| 685 | } | ||
| 686 | |||
| 687 | static struct regmap_config fsl_asrc_regmap_config = { | ||
| 688 | .reg_bits = 32, | ||
| 689 | .reg_stride = 4, | ||
| 690 | .val_bits = 32, | ||
| 691 | |||
| 692 | .max_register = REG_ASRMCR1C, | ||
| 693 | .readable_reg = fsl_asrc_readable_reg, | ||
| 694 | .volatile_reg = fsl_asrc_volatile_reg, | ||
| 695 | .writeable_reg = fsl_asrc_writeable_reg, | ||
| 696 | .cache_type = REGCACHE_RBTREE, | ||
| 697 | }; | ||
| 698 | |||
| 699 | /** | ||
| 700 | * Initialize ASRC registers with a default configurations | ||
| 701 | */ | ||
| 702 | static int fsl_asrc_init(struct fsl_asrc *asrc_priv) | ||
| 703 | { | ||
| 704 | /* Halt ASRC internal FP when input FIFO needs data for pair A, B, C */ | ||
| 705 | regmap_write(asrc_priv->regmap, REG_ASRCTR, ASRCTR_ASRCEN); | ||
| 706 | |||
| 707 | /* Disable interrupt by default */ | ||
| 708 | regmap_write(asrc_priv->regmap, REG_ASRIER, 0x0); | ||
| 709 | |||
| 710 | /* Apply recommended settings for parameters from Reference Manual */ | ||
| 711 | regmap_write(asrc_priv->regmap, REG_ASRPM1, 0x7fffff); | ||
| 712 | regmap_write(asrc_priv->regmap, REG_ASRPM2, 0x255555); | ||
| 713 | regmap_write(asrc_priv->regmap, REG_ASRPM3, 0xff7280); | ||
| 714 | regmap_write(asrc_priv->regmap, REG_ASRPM4, 0xff7280); | ||
| 715 | regmap_write(asrc_priv->regmap, REG_ASRPM5, 0xff7280); | ||
| 716 | |||
| 717 | /* Base address for task queue FIFO. Set to 0x7C */ | ||
| 718 | regmap_update_bits(asrc_priv->regmap, REG_ASRTFR1, | ||
| 719 | ASRTFR1_TF_BASE_MASK, ASRTFR1_TF_BASE(0xfc)); | ||
| 720 | |||
| 721 | /* Set the processing clock for 76KHz to 133M */ | ||
| 722 | regmap_write(asrc_priv->regmap, REG_ASR76K, 0x06D6); | ||
| 723 | |||
| 724 | /* Set the processing clock for 56KHz to 133M */ | ||
| 725 | return regmap_write(asrc_priv->regmap, REG_ASR56K, 0x0947); | ||
| 726 | } | ||
| 727 | |||
| 728 | /** | ||
| 729 | * Interrupt handler for ASRC | ||
| 730 | */ | ||
| 731 | static irqreturn_t fsl_asrc_isr(int irq, void *dev_id) | ||
| 732 | { | ||
| 733 | struct fsl_asrc *asrc_priv = (struct fsl_asrc *)dev_id; | ||
| 734 | struct device *dev = &asrc_priv->pdev->dev; | ||
| 735 | enum asrc_pair_index index; | ||
| 736 | u32 status; | ||
| 737 | |||
| 738 | regmap_read(asrc_priv->regmap, REG_ASRSTR, &status); | ||
| 739 | |||
| 740 | /* Clean overload error */ | ||
| 741 | regmap_write(asrc_priv->regmap, REG_ASRSTR, ASRSTR_AOLE); | ||
| 742 | |||
| 743 | /* | ||
| 744 | * We here use dev_dbg() for all exceptions because ASRC itself does | ||
| 745 | * not care if FIFO overflowed or underrun while a warning in the | ||
| 746 | * interrupt would result a ridged conversion. | ||
| 747 | */ | ||
| 748 | for (index = ASRC_PAIR_A; index < ASRC_PAIR_MAX_NUM; index++) { | ||
| 749 | if (!asrc_priv->pair[index]) | ||
| 750 | continue; | ||
| 751 | |||
| 752 | if (status & ASRSTR_ATQOL) { | ||
| 753 | asrc_priv->pair[index]->error |= ASRC_TASK_Q_OVERLOAD; | ||
| 754 | dev_dbg(dev, "ASRC Task Queue FIFO overload\n"); | ||
| 755 | } | ||
| 756 | |||
| 757 | if (status & ASRSTR_AOOL(index)) { | ||
| 758 | asrc_priv->pair[index]->error |= ASRC_OUTPUT_TASK_OVERLOAD; | ||
| 759 | pair_dbg("Output Task Overload\n"); | ||
| 760 | } | ||
| 761 | |||
| 762 | if (status & ASRSTR_AIOL(index)) { | ||
| 763 | asrc_priv->pair[index]->error |= ASRC_INPUT_TASK_OVERLOAD; | ||
| 764 | pair_dbg("Input Task Overload\n"); | ||
| 765 | } | ||
| 766 | |||
| 767 | if (status & ASRSTR_AODO(index)) { | ||
| 768 | asrc_priv->pair[index]->error |= ASRC_OUTPUT_BUFFER_OVERFLOW; | ||
| 769 | pair_dbg("Output Data Buffer has overflowed\n"); | ||
| 770 | } | ||
| 771 | |||
| 772 | if (status & ASRSTR_AIDU(index)) { | ||
| 773 | asrc_priv->pair[index]->error |= ASRC_INPUT_BUFFER_UNDERRUN; | ||
| 774 | pair_dbg("Input Data Buffer has underflowed\n"); | ||
| 775 | } | ||
| 776 | } | ||
| 777 | |||
| 778 | return IRQ_HANDLED; | ||
| 779 | } | ||
| 780 | |||
| 781 | static int fsl_asrc_probe(struct platform_device *pdev) | ||
| 782 | { | ||
| 783 | struct device_node *np = pdev->dev.of_node; | ||
| 784 | struct fsl_asrc *asrc_priv; | ||
| 785 | struct resource *res; | ||
| 786 | void __iomem *regs; | ||
| 787 | int irq, ret, i; | ||
| 788 | char tmp[16]; | ||
| 789 | |||
| 790 | asrc_priv = devm_kzalloc(&pdev->dev, sizeof(*asrc_priv), GFP_KERNEL); | ||
| 791 | if (!asrc_priv) | ||
| 792 | return -ENOMEM; | ||
| 793 | |||
| 794 | asrc_priv->pdev = pdev; | ||
| 795 | strcpy(asrc_priv->name, np->name); | ||
| 796 | |||
| 797 | /* Get the addresses and IRQ */ | ||
| 798 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 799 | regs = devm_ioremap_resource(&pdev->dev, res); | ||
| 800 | if (IS_ERR(regs)) | ||
| 801 | return PTR_ERR(regs); | ||
| 802 | |||
| 803 | asrc_priv->paddr = res->start; | ||
| 804 | |||
| 805 | /* Register regmap and let it prepare core clock */ | ||
| 806 | if (of_property_read_bool(np, "big-endian")) | ||
| 807 | fsl_asrc_regmap_config.val_format_endian = REGMAP_ENDIAN_BIG; | ||
| 808 | |||
| 809 | asrc_priv->regmap = devm_regmap_init_mmio_clk(&pdev->dev, "mem", regs, | ||
| 810 | &fsl_asrc_regmap_config); | ||
| 811 | if (IS_ERR(asrc_priv->regmap)) { | ||
| 812 | dev_err(&pdev->dev, "failed to init regmap\n"); | ||
| 813 | return PTR_ERR(asrc_priv->regmap); | ||
| 814 | } | ||
| 815 | |||
| 816 | irq = platform_get_irq(pdev, 0); | ||
| 817 | if (irq < 0) { | ||
| 818 | dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); | ||
| 819 | return irq; | ||
| 820 | } | ||
| 821 | |||
| 822 | ret = devm_request_irq(&pdev->dev, irq, fsl_asrc_isr, 0, | ||
| 823 | asrc_priv->name, asrc_priv); | ||
| 824 | if (ret) { | ||
| 825 | dev_err(&pdev->dev, "failed to claim irq %u: %d\n", irq, ret); | ||
| 826 | return ret; | ||
| 827 | } | ||
| 828 | |||
| 829 | asrc_priv->mem_clk = devm_clk_get(&pdev->dev, "mem"); | ||
| 830 | if (IS_ERR(asrc_priv->mem_clk)) { | ||
| 831 | dev_err(&pdev->dev, "failed to get mem clock\n"); | ||
| 832 | return PTR_ERR(asrc_priv->mem_clk); | ||
| 833 | } | ||
| 834 | |||
| 835 | asrc_priv->ipg_clk = devm_clk_get(&pdev->dev, "ipg"); | ||
| 836 | if (IS_ERR(asrc_priv->ipg_clk)) { | ||
| 837 | dev_err(&pdev->dev, "failed to get ipg clock\n"); | ||
| 838 | return PTR_ERR(asrc_priv->ipg_clk); | ||
| 839 | } | ||
| 840 | |||
| 841 | for (i = 0; i < ASRC_CLK_MAX_NUM; i++) { | ||
| 842 | sprintf(tmp, "asrck_%x", i); | ||
| 843 | asrc_priv->asrck_clk[i] = devm_clk_get(&pdev->dev, tmp); | ||
| 844 | if (IS_ERR(asrc_priv->asrck_clk[i])) { | ||
| 845 | dev_err(&pdev->dev, "failed to get %s clock\n", tmp); | ||
| 846 | return PTR_ERR(asrc_priv->asrck_clk[i]); | ||
| 847 | } | ||
| 848 | } | ||
| 849 | |||
| 850 | if (of_device_is_compatible(pdev->dev.of_node, "fsl,imx35-asrc")) { | ||
| 851 | asrc_priv->channel_bits = 3; | ||
| 852 | clk_map[IN] = input_clk_map_imx35; | ||
| 853 | clk_map[OUT] = output_clk_map_imx35; | ||
| 854 | } else { | ||
| 855 | asrc_priv->channel_bits = 4; | ||
| 856 | clk_map[IN] = input_clk_map_imx53; | ||
| 857 | clk_map[OUT] = output_clk_map_imx53; | ||
| 858 | } | ||
| 859 | |||
| 860 | ret = fsl_asrc_init(asrc_priv); | ||
| 861 | if (ret) { | ||
| 862 | dev_err(&pdev->dev, "failed to init asrc %d\n", ret); | ||
| 863 | return -EINVAL; | ||
| 864 | } | ||
| 865 | |||
| 866 | asrc_priv->channel_avail = 10; | ||
| 867 | |||
| 868 | ret = of_property_read_u32(np, "fsl,asrc-rate", | ||
| 869 | &asrc_priv->asrc_rate); | ||
| 870 | if (ret) { | ||
| 871 | dev_err(&pdev->dev, "failed to get output rate\n"); | ||
| 872 | return -EINVAL; | ||
| 873 | } | ||
| 874 | |||
| 875 | ret = of_property_read_u32(np, "fsl,asrc-width", | ||
| 876 | &asrc_priv->asrc_width); | ||
| 877 | if (ret) { | ||
| 878 | dev_err(&pdev->dev, "failed to get output width\n"); | ||
| 879 | return -EINVAL; | ||
| 880 | } | ||
| 881 | |||
| 882 | if (asrc_priv->asrc_width != 16 && asrc_priv->asrc_width != 24) { | ||
| 883 | dev_warn(&pdev->dev, "unsupported width, switching to 24bit\n"); | ||
| 884 | asrc_priv->asrc_width = 24; | ||
| 885 | } | ||
| 886 | |||
| 887 | platform_set_drvdata(pdev, asrc_priv); | ||
| 888 | pm_runtime_enable(&pdev->dev); | ||
| 889 | spin_lock_init(&asrc_priv->lock); | ||
| 890 | |||
| 891 | ret = devm_snd_soc_register_component(&pdev->dev, &fsl_asrc_component, | ||
| 892 | &fsl_asrc_dai, 1); | ||
| 893 | if (ret) { | ||
| 894 | dev_err(&pdev->dev, "failed to register ASoC DAI\n"); | ||
| 895 | return ret; | ||
| 896 | } | ||
| 897 | |||
| 898 | ret = devm_snd_soc_register_platform(&pdev->dev, &fsl_asrc_platform); | ||
| 899 | if (ret) { | ||
| 900 | dev_err(&pdev->dev, "failed to register ASoC platform\n"); | ||
| 901 | return ret; | ||
| 902 | } | ||
| 903 | |||
| 904 | dev_info(&pdev->dev, "driver registered\n"); | ||
| 905 | |||
| 906 | return 0; | ||
| 907 | } | ||
| 908 | |||
| 909 | #ifdef CONFIG_PM_RUNTIME | ||
| 910 | static int fsl_asrc_runtime_resume(struct device *dev) | ||
| 911 | { | ||
| 912 | struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); | ||
| 913 | int i; | ||
| 914 | |||
| 915 | clk_prepare_enable(asrc_priv->mem_clk); | ||
| 916 | clk_prepare_enable(asrc_priv->ipg_clk); | ||
| 917 | for (i = 0; i < ASRC_CLK_MAX_NUM; i++) | ||
| 918 | clk_prepare_enable(asrc_priv->asrck_clk[i]); | ||
| 919 | |||
| 920 | return 0; | ||
| 921 | } | ||
| 922 | |||
| 923 | static int fsl_asrc_runtime_suspend(struct device *dev) | ||
| 924 | { | ||
| 925 | struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); | ||
| 926 | int i; | ||
| 927 | |||
| 928 | for (i = 0; i < ASRC_CLK_MAX_NUM; i++) | ||
| 929 | clk_disable_unprepare(asrc_priv->asrck_clk[i]); | ||
| 930 | clk_disable_unprepare(asrc_priv->ipg_clk); | ||
| 931 | clk_disable_unprepare(asrc_priv->mem_clk); | ||
| 932 | |||
| 933 | return 0; | ||
| 934 | } | ||
| 935 | #endif /* CONFIG_PM_RUNTIME */ | ||
| 936 | |||
| 937 | #ifdef CONFIG_PM_SLEEP | ||
| 938 | static int fsl_asrc_suspend(struct device *dev) | ||
| 939 | { | ||
| 940 | struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); | ||
| 941 | |||
| 942 | regcache_cache_only(asrc_priv->regmap, true); | ||
| 943 | regcache_mark_dirty(asrc_priv->regmap); | ||
| 944 | |||
| 945 | return 0; | ||
| 946 | } | ||
| 947 | |||
| 948 | static int fsl_asrc_resume(struct device *dev) | ||
| 949 | { | ||
| 950 | struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); | ||
| 951 | u32 asrctr; | ||
| 952 | |||
| 953 | /* Stop all pairs provisionally */ | ||
| 954 | regmap_read(asrc_priv->regmap, REG_ASRCTR, &asrctr); | ||
| 955 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 956 | ASRCTR_ASRCEi_ALL_MASK, 0); | ||
| 957 | |||
| 958 | /* Restore all registers */ | ||
| 959 | regcache_cache_only(asrc_priv->regmap, false); | ||
| 960 | regcache_sync(asrc_priv->regmap); | ||
| 961 | |||
| 962 | /* Restart enabled pairs */ | ||
| 963 | regmap_update_bits(asrc_priv->regmap, REG_ASRCTR, | ||
| 964 | ASRCTR_ASRCEi_ALL_MASK, asrctr); | ||
| 965 | |||
| 966 | return 0; | ||
| 967 | } | ||
| 968 | #endif /* CONFIG_PM_SLEEP */ | ||
| 969 | |||
| 970 | static const struct dev_pm_ops fsl_asrc_pm = { | ||
| 971 | SET_RUNTIME_PM_OPS(fsl_asrc_runtime_suspend, fsl_asrc_runtime_resume, NULL) | ||
| 972 | SET_SYSTEM_SLEEP_PM_OPS(fsl_asrc_suspend, fsl_asrc_resume) | ||
| 973 | }; | ||
| 974 | |||
| 975 | static const struct of_device_id fsl_asrc_ids[] = { | ||
| 976 | { .compatible = "fsl,imx35-asrc", }, | ||
| 977 | { .compatible = "fsl,imx53-asrc", }, | ||
| 978 | {} | ||
| 979 | }; | ||
| 980 | MODULE_DEVICE_TABLE(of, fsl_asrc_ids); | ||
| 981 | |||
| 982 | static struct platform_driver fsl_asrc_driver = { | ||
| 983 | .probe = fsl_asrc_probe, | ||
| 984 | .driver = { | ||
| 985 | .name = "fsl-asrc", | ||
| 986 | .of_match_table = fsl_asrc_ids, | ||
| 987 | .pm = &fsl_asrc_pm, | ||
| 988 | }, | ||
| 989 | }; | ||
| 990 | module_platform_driver(fsl_asrc_driver); | ||
| 991 | |||
| 992 | MODULE_DESCRIPTION("Freescale ASRC ASoC driver"); | ||
| 993 | MODULE_AUTHOR("Nicolin Chen <nicoleotsuka@gmail.com>"); | ||
| 994 | MODULE_ALIAS("platform:fsl-asrc"); | ||
| 995 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/fsl/fsl_asrc.h b/sound/soc/fsl/fsl_asrc.h new file mode 100644 index 000000000000..a3f211f53c23 --- /dev/null +++ b/sound/soc/fsl/fsl_asrc.h | |||
| @@ -0,0 +1,461 @@ | |||
| 1 | /* | ||
| 2 | * fsl_asrc.h - Freescale ASRC ALSA SoC header file | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Freescale Semiconductor, Inc. | ||
| 5 | * | ||
| 6 | * Author: Nicolin Chen <nicoleotsuka@gmail.com> | ||
| 7 | * | ||
| 8 | * This file is licensed under the terms of the GNU General Public License | ||
| 9 | * version 2. This program is licensed "as is" without any warranty of any | ||
| 10 | * kind, whether express or implied. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #ifndef _FSL_ASRC_H | ||
| 14 | #define _FSL_ASRC_H | ||
| 15 | |||
| 16 | #define IN 0 | ||
| 17 | #define OUT 1 | ||
| 18 | |||
| 19 | #define ASRC_DMA_BUFFER_NUM 2 | ||
| 20 | #define ASRC_INPUTFIFO_THRESHOLD 32 | ||
| 21 | #define ASRC_OUTPUTFIFO_THRESHOLD 32 | ||
| 22 | #define ASRC_FIFO_THRESHOLD_MIN 0 | ||
| 23 | #define ASRC_FIFO_THRESHOLD_MAX 63 | ||
| 24 | #define ASRC_DMA_BUFFER_SIZE (1024 * 48 * 4) | ||
| 25 | #define ASRC_MAX_BUFFER_SIZE (1024 * 48) | ||
| 26 | #define ASRC_OUTPUT_LAST_SAMPLE 8 | ||
| 27 | |||
| 28 | #define IDEAL_RATIO_RATE 1000000 | ||
| 29 | |||
| 30 | #define REG_ASRCTR 0x00 | ||
| 31 | #define REG_ASRIER 0x04 | ||
| 32 | #define REG_ASRCNCR 0x0C | ||
| 33 | #define REG_ASRCFG 0x10 | ||
| 34 | #define REG_ASRCSR 0x14 | ||
| 35 | |||
| 36 | #define REG_ASRCDR1 0x18 | ||
| 37 | #define REG_ASRCDR2 0x1C | ||
| 38 | #define REG_ASRCDR(i) ((i < 2) ? REG_ASRCDR1 : REG_ASRCDR2) | ||
| 39 | |||
| 40 | #define REG_ASRSTR 0x20 | ||
| 41 | #define REG_ASRRA 0x24 | ||
| 42 | #define REG_ASRRB 0x28 | ||
| 43 | #define REG_ASRRC 0x2C | ||
| 44 | #define REG_ASRPM1 0x40 | ||
| 45 | #define REG_ASRPM2 0x44 | ||
| 46 | #define REG_ASRPM3 0x48 | ||
| 47 | #define REG_ASRPM4 0x4C | ||
| 48 | #define REG_ASRPM5 0x50 | ||
| 49 | #define REG_ASRTFR1 0x54 | ||
| 50 | #define REG_ASRCCR 0x5C | ||
| 51 | |||
| 52 | #define REG_ASRDIA 0x60 | ||
| 53 | #define REG_ASRDOA 0x64 | ||
| 54 | #define REG_ASRDIB 0x68 | ||
| 55 | #define REG_ASRDOB 0x6C | ||
| 56 | #define REG_ASRDIC 0x70 | ||
| 57 | #define REG_ASRDOC 0x74 | ||
| 58 | #define REG_ASRDI(i) (REG_ASRDIA + (i << 3)) | ||
| 59 | #define REG_ASRDO(i) (REG_ASRDOA + (i << 3)) | ||
| 60 | #define REG_ASRDx(x, i) (x == IN ? REG_ASRDI(i) : REG_ASRDO(i)) | ||
| 61 | |||
| 62 | #define REG_ASRIDRHA 0x80 | ||
| 63 | #define REG_ASRIDRLA 0x84 | ||
| 64 | #define REG_ASRIDRHB 0x88 | ||
| 65 | #define REG_ASRIDRLB 0x8C | ||
| 66 | #define REG_ASRIDRHC 0x90 | ||
| 67 | #define REG_ASRIDRLC 0x94 | ||
| 68 | #define REG_ASRIDRH(i) (REG_ASRIDRHA + (i << 3)) | ||
| 69 | #define REG_ASRIDRL(i) (REG_ASRIDRLA + (i << 3)) | ||
| 70 | |||
| 71 | #define REG_ASR76K 0x98 | ||
| 72 | #define REG_ASR56K 0x9C | ||
| 73 | |||
| 74 | #define REG_ASRMCRA 0xA0 | ||
| 75 | #define REG_ASRFSTA 0xA4 | ||
| 76 | #define REG_ASRMCRB 0xA8 | ||
| 77 | #define REG_ASRFSTB 0xAC | ||
| 78 | #define REG_ASRMCRC 0xB0 | ||
| 79 | #define REG_ASRFSTC 0xB4 | ||
| 80 | #define REG_ASRMCR(i) (REG_ASRMCRA + (i << 3)) | ||
| 81 | #define REG_ASRFST(i) (REG_ASRFSTA + (i << 3)) | ||
| 82 | |||
| 83 | #define REG_ASRMCR1A 0xC0 | ||
| 84 | #define REG_ASRMCR1B 0xC4 | ||
| 85 | #define REG_ASRMCR1C 0xC8 | ||
| 86 | #define REG_ASRMCR1(i) (REG_ASRMCR1A + (i << 2)) | ||
| 87 | |||
| 88 | |||
| 89 | /* REG0 0x00 REG_ASRCTR */ | ||
| 90 | #define ASRCTR_ATSi_SHIFT(i) (20 + i) | ||
| 91 | #define ASRCTR_ATSi_MASK(i) (1 << ASRCTR_ATSi_SHIFT(i)) | ||
| 92 | #define ASRCTR_ATS(i) (1 << ASRCTR_ATSi_SHIFT(i)) | ||
| 93 | #define ASRCTR_USRi_SHIFT(i) (14 + (i << 1)) | ||
| 94 | #define ASRCTR_USRi_MASK(i) (1 << ASRCTR_USRi_SHIFT(i)) | ||
| 95 | #define ASRCTR_USR(i) (1 << ASRCTR_USRi_SHIFT(i)) | ||
| 96 | #define ASRCTR_IDRi_SHIFT(i) (13 + (i << 1)) | ||
| 97 | #define ASRCTR_IDRi_MASK(i) (1 << ASRCTR_IDRi_SHIFT(i)) | ||
| 98 | #define ASRCTR_IDR(i) (1 << ASRCTR_IDRi_SHIFT(i)) | ||
| 99 | #define ASRCTR_SRST_SHIFT 4 | ||
| 100 | #define ASRCTR_SRST_MASK (1 << ASRCTR_SRST_SHIFT) | ||
| 101 | #define ASRCTR_SRST (1 << ASRCTR_SRST_SHIFT) | ||
| 102 | #define ASRCTR_ASRCEi_SHIFT(i) (1 + i) | ||
| 103 | #define ASRCTR_ASRCEi_MASK(i) (1 << ASRCTR_ASRCEi_SHIFT(i)) | ||
| 104 | #define ASRCTR_ASRCE(i) (1 << ASRCTR_ASRCEi_SHIFT(i)) | ||
| 105 | #define ASRCTR_ASRCEi_ALL_MASK (0x7 << ASRCTR_ASRCEi_SHIFT(0)) | ||
| 106 | #define ASRCTR_ASRCEN_SHIFT 0 | ||
| 107 | #define ASRCTR_ASRCEN_MASK (1 << ASRCTR_ASRCEN_SHIFT) | ||
| 108 | #define ASRCTR_ASRCEN (1 << ASRCTR_ASRCEN_SHIFT) | ||
| 109 | |||
| 110 | /* REG1 0x04 REG_ASRIER */ | ||
| 111 | #define ASRIER_AFPWE_SHIFT 7 | ||
| 112 | #define ASRIER_AFPWE_MASK (1 << ASRIER_AFPWE_SHIFT) | ||
| 113 | #define ASRIER_AFPWE (1 << ASRIER_AFPWE_SHIFT) | ||
| 114 | #define ASRIER_AOLIE_SHIFT 6 | ||
| 115 | #define ASRIER_AOLIE_MASK (1 << ASRIER_AOLIE_SHIFT) | ||
| 116 | #define ASRIER_AOLIE (1 << ASRIER_AOLIE_SHIFT) | ||
| 117 | #define ASRIER_ADOEi_SHIFT(i) (3 + i) | ||
| 118 | #define ASRIER_ADOEi_MASK(i) (1 << ASRIER_ADOEi_SHIFT(i)) | ||
| 119 | #define ASRIER_ADOE(i) (1 << ASRIER_ADOEi_SHIFT(i)) | ||
| 120 | #define ASRIER_ADIEi_SHIFT(i) (0 + i) | ||
| 121 | #define ASRIER_ADIEi_MASK(i) (1 << ASRIER_ADIEi_SHIFT(i)) | ||
| 122 | #define ASRIER_ADIE(i) (1 << ASRIER_ADIEi_SHIFT(i)) | ||
| 123 | |||
| 124 | /* REG2 0x0C REG_ASRCNCR */ | ||
| 125 | #define ASRCNCR_ANCi_SHIFT(i, b) (b * i) | ||
| 126 | #define ASRCNCR_ANCi_MASK(i, b) (((1 << b) - 1) << ASRCNCR_ANCi_SHIFT(i, b)) | ||
| 127 | #define ASRCNCR_ANCi(i, v, b) ((v << ASRCNCR_ANCi_SHIFT(i, b)) & ASRCNCR_ANCi_MASK(i, b)) | ||
| 128 | |||
| 129 | /* REG3 0x10 REG_ASRCFG */ | ||
| 130 | #define ASRCFG_INIRQi_SHIFT(i) (21 + i) | ||
| 131 | #define ASRCFG_INIRQi_MASK(i) (1 << ASRCFG_INIRQi_SHIFT(i)) | ||
| 132 | #define ASRCFG_INIRQi (1 << ASRCFG_INIRQi_SHIFT(i)) | ||
| 133 | #define ASRCFG_NDPRi_SHIFT(i) (18 + i) | ||
| 134 | #define ASRCFG_NDPRi_MASK(i) (1 << ASRCFG_NDPRi_SHIFT(i)) | ||
| 135 | #define ASRCFG_NDPRi (1 << ASRCFG_NDPRi_SHIFT(i)) | ||
| 136 | #define ASRCFG_POSTMODi_SHIFT(i) (8 + (i << 2)) | ||
| 137 | #define ASRCFG_POSTMODi_WIDTH 2 | ||
| 138 | #define ASRCFG_POSTMODi_MASK(i) (((1 << ASRCFG_POSTMODi_WIDTH) - 1) << ASRCFG_POSTMODi_SHIFT(i)) | ||
| 139 | #define ASRCFG_POSTMOD(i, v) ((v) << ASRCFG_POSTMODi_SHIFT(i)) | ||
| 140 | #define ASRCFG_POSTMODi_UP(i) (0 << ASRCFG_POSTMODi_SHIFT(i)) | ||
| 141 | #define ASRCFG_POSTMODi_DCON(i) (1 << ASRCFG_POSTMODi_SHIFT(i)) | ||
| 142 | #define ASRCFG_POSTMODi_DOWN(i) (2 << ASRCFG_POSTMODi_SHIFT(i)) | ||
| 143 | #define ASRCFG_PREMODi_SHIFT(i) (6 + (i << 2)) | ||
| 144 | #define ASRCFG_PREMODi_WIDTH 2 | ||
| 145 | #define ASRCFG_PREMODi_MASK(i) (((1 << ASRCFG_PREMODi_WIDTH) - 1) << ASRCFG_PREMODi_SHIFT(i)) | ||
| 146 | #define ASRCFG_PREMOD(i, v) ((v) << ASRCFG_PREMODi_SHIFT(i)) | ||
| 147 | #define ASRCFG_PREMODi_UP(i) (0 << ASRCFG_PREMODi_SHIFT(i)) | ||
| 148 | #define ASRCFG_PREMODi_DCON(i) (1 << ASRCFG_PREMODi_SHIFT(i)) | ||
| 149 | #define ASRCFG_PREMODi_DOWN(i) (2 << ASRCFG_PREMODi_SHIFT(i)) | ||
| 150 | #define ASRCFG_PREMODi_BYPASS(i) (3 << ASRCFG_PREMODi_SHIFT(i)) | ||
| 151 | |||
| 152 | /* REG4 0x14 REG_ASRCSR */ | ||
| 153 | #define ASRCSR_AxCSi_WIDTH 4 | ||
| 154 | #define ASRCSR_AxCSi_MASK ((1 << ASRCSR_AxCSi_WIDTH) - 1) | ||
| 155 | #define ASRCSR_AOCSi_SHIFT(i) (12 + (i << 2)) | ||
| 156 | #define ASRCSR_AOCSi_MASK(i) (((1 << ASRCSR_AxCSi_WIDTH) - 1) << ASRCSR_AOCSi_SHIFT(i)) | ||
| 157 | #define ASRCSR_AOCS(i, v) ((v) << ASRCSR_AOCSi_SHIFT(i)) | ||
| 158 | #define ASRCSR_AICSi_SHIFT(i) (i << 2) | ||
| 159 | #define ASRCSR_AICSi_MASK(i) (((1 << ASRCSR_AxCSi_WIDTH) - 1) << ASRCSR_AICSi_SHIFT(i)) | ||
| 160 | #define ASRCSR_AICS(i, v) ((v) << ASRCSR_AICSi_SHIFT(i)) | ||
| 161 | |||
| 162 | /* REG5&6 0x18 & 0x1C REG_ASRCDR1 & ASRCDR2 */ | ||
| 163 | #define ASRCDRi_AxCPi_WIDTH 3 | ||
| 164 | #define ASRCDRi_AICPi_SHIFT(i) (0 + (i % 2) * 6) | ||
| 165 | #define ASRCDRi_AICPi_MASK(i) (((1 << ASRCDRi_AxCPi_WIDTH) - 1) << ASRCDRi_AICPi_SHIFT(i)) | ||
| 166 | #define ASRCDRi_AICP(i, v) ((v) << ASRCDRi_AICPi_SHIFT(i)) | ||
| 167 | #define ASRCDRi_AICDi_SHIFT(i) (3 + (i % 2) * 6) | ||
| 168 | #define ASRCDRi_AICDi_MASK(i) (((1 << ASRCDRi_AxCPi_WIDTH) - 1) << ASRCDRi_AICDi_SHIFT(i)) | ||
| 169 | #define ASRCDRi_AICD(i, v) ((v) << ASRCDRi_AICDi_SHIFT(i)) | ||
| 170 | #define ASRCDRi_AOCPi_SHIFT(i) ((i < 2) ? 12 + i * 6 : 6) | ||
| 171 | #define ASRCDRi_AOCPi_MASK(i) (((1 << ASRCDRi_AxCPi_WIDTH) - 1) << ASRCDRi_AOCPi_SHIFT(i)) | ||
| 172 | #define ASRCDRi_AOCP(i, v) ((v) << ASRCDRi_AOCPi_SHIFT(i)) | ||
| 173 | #define ASRCDRi_AOCDi_SHIFT(i) ((i < 2) ? 15 + i * 6 : 9) | ||
| 174 | #define ASRCDRi_AOCDi_MASK(i) (((1 << ASRCDRi_AxCPi_WIDTH) - 1) << ASRCDRi_AOCDi_SHIFT(i)) | ||
| 175 | #define ASRCDRi_AOCD(i, v) ((v) << ASRCDRi_AOCDi_SHIFT(i)) | ||
| 176 | |||
| 177 | /* REG7 0x20 REG_ASRSTR */ | ||
| 178 | #define ASRSTR_DSLCNT_SHIFT 21 | ||
| 179 | #define ASRSTR_DSLCNT_MASK (1 << ASRSTR_DSLCNT_SHIFT) | ||
| 180 | #define ASRSTR_DSLCNT (1 << ASRSTR_DSLCNT_SHIFT) | ||
| 181 | #define ASRSTR_ATQOL_SHIFT 20 | ||
| 182 | #define ASRSTR_ATQOL_MASK (1 << ASRSTR_ATQOL_SHIFT) | ||
| 183 | #define ASRSTR_ATQOL (1 << ASRSTR_ATQOL_SHIFT) | ||
| 184 | #define ASRSTR_AOOLi_SHIFT(i) (17 + i) | ||
| 185 | #define ASRSTR_AOOLi_MASK(i) (1 << ASRSTR_AOOLi_SHIFT(i)) | ||
| 186 | #define ASRSTR_AOOL(i) (1 << ASRSTR_AOOLi_SHIFT(i)) | ||
| 187 | #define ASRSTR_AIOLi_SHIFT(i) (14 + i) | ||
| 188 | #define ASRSTR_AIOLi_MASK(i) (1 << ASRSTR_AIOLi_SHIFT(i)) | ||
| 189 | #define ASRSTR_AIOL(i) (1 << ASRSTR_AIOLi_SHIFT(i)) | ||
| 190 | #define ASRSTR_AODOi_SHIFT(i) (11 + i) | ||
| 191 | #define ASRSTR_AODOi_MASK(i) (1 << ASRSTR_AODOi_SHIFT(i)) | ||
| 192 | #define ASRSTR_AODO(i) (1 << ASRSTR_AODOi_SHIFT(i)) | ||
| 193 | #define ASRSTR_AIDUi_SHIFT(i) (8 + i) | ||
| 194 | #define ASRSTR_AIDUi_MASK(i) (1 << ASRSTR_AIDUi_SHIFT(i)) | ||
| 195 | #define ASRSTR_AIDU(i) (1 << ASRSTR_AIDUi_SHIFT(i)) | ||
| 196 | #define ASRSTR_FPWT_SHIFT 7 | ||
| 197 | #define ASRSTR_FPWT_MASK (1 << ASRSTR_FPWT_SHIFT) | ||
| 198 | #define ASRSTR_FPWT (1 << ASRSTR_FPWT_SHIFT) | ||
| 199 | #define ASRSTR_AOLE_SHIFT 6 | ||
| 200 | #define ASRSTR_AOLE_MASK (1 << ASRSTR_AOLE_SHIFT) | ||
| 201 | #define ASRSTR_AOLE (1 << ASRSTR_AOLE_SHIFT) | ||
| 202 | #define ASRSTR_AODEi_SHIFT(i) (3 + i) | ||
| 203 | #define ASRSTR_AODFi_MASK(i) (1 << ASRSTR_AODEi_SHIFT(i)) | ||
| 204 | #define ASRSTR_AODF(i) (1 << ASRSTR_AODEi_SHIFT(i)) | ||
| 205 | #define ASRSTR_AIDEi_SHIFT(i) (0 + i) | ||
| 206 | #define ASRSTR_AIDEi_MASK(i) (1 << ASRSTR_AIDEi_SHIFT(i)) | ||
| 207 | #define ASRSTR_AIDE(i) (1 << ASRSTR_AIDEi_SHIFT(i)) | ||
| 208 | |||
| 209 | /* REG10 0x54 REG_ASRTFR1 */ | ||
| 210 | #define ASRTFR1_TF_BASE_WIDTH 7 | ||
| 211 | #define ASRTFR1_TF_BASE_SHIFT 6 | ||
| 212 | #define ASRTFR1_TF_BASE_MASK (((1 << ASRTFR1_TF_BASE_WIDTH) - 1) << ASRTFR1_TF_BASE_SHIFT) | ||
| 213 | #define ASRTFR1_TF_BASE(i) ((i) << ASRTFR1_TF_BASE_SHIFT) | ||
| 214 | |||
| 215 | /* | ||
| 216 | * REG22 0xA0 REG_ASRMCRA | ||
| 217 | * REG24 0xA8 REG_ASRMCRB | ||
| 218 | * REG26 0xB0 REG_ASRMCRC | ||
| 219 | */ | ||
| 220 | #define ASRMCRi_ZEROBUFi_SHIFT 23 | ||
| 221 | #define ASRMCRi_ZEROBUFi_MASK (1 << ASRMCRi_ZEROBUFi_SHIFT) | ||
| 222 | #define ASRMCRi_ZEROBUFi (1 << ASRMCRi_ZEROBUFi_SHIFT) | ||
| 223 | #define ASRMCRi_EXTTHRSHi_SHIFT 22 | ||
| 224 | #define ASRMCRi_EXTTHRSHi_MASK (1 << ASRMCRi_EXTTHRSHi_SHIFT) | ||
| 225 | #define ASRMCRi_EXTTHRSHi (1 << ASRMCRi_EXTTHRSHi_SHIFT) | ||
| 226 | #define ASRMCRi_BUFSTALLi_SHIFT 21 | ||
| 227 | #define ASRMCRi_BUFSTALLi_MASK (1 << ASRMCRi_BUFSTALLi_SHIFT) | ||
| 228 | #define ASRMCRi_BUFSTALLi (1 << ASRMCRi_BUFSTALLi_SHIFT) | ||
| 229 | #define ASRMCRi_BYPASSPOLYi_SHIFT 20 | ||
| 230 | #define ASRMCRi_BYPASSPOLYi_MASK (1 << ASRMCRi_BYPASSPOLYi_SHIFT) | ||
| 231 | #define ASRMCRi_BYPASSPOLYi (1 << ASRMCRi_BYPASSPOLYi_SHIFT) | ||
| 232 | #define ASRMCRi_OUTFIFO_THRESHOLD_WIDTH 6 | ||
| 233 | #define ASRMCRi_OUTFIFO_THRESHOLD_SHIFT 12 | ||
| 234 | #define ASRMCRi_OUTFIFO_THRESHOLD_MASK (((1 << ASRMCRi_OUTFIFO_THRESHOLD_WIDTH) - 1) << ASRMCRi_OUTFIFO_THRESHOLD_SHIFT) | ||
| 235 | #define ASRMCRi_OUTFIFO_THRESHOLD(v) (((v) << ASRMCRi_OUTFIFO_THRESHOLD_SHIFT) & ASRMCRi_OUTFIFO_THRESHOLD_MASK) | ||
| 236 | #define ASRMCRi_RSYNIFi_SHIFT 11 | ||
| 237 | #define ASRMCRi_RSYNIFi_MASK (1 << ASRMCRi_RSYNIFi_SHIFT) | ||
| 238 | #define ASRMCRi_RSYNIFi (1 << ASRMCRi_RSYNIFi_SHIFT) | ||
| 239 | #define ASRMCRi_RSYNOFi_SHIFT 10 | ||
| 240 | #define ASRMCRi_RSYNOFi_MASK (1 << ASRMCRi_RSYNOFi_SHIFT) | ||
| 241 | #define ASRMCRi_RSYNOFi (1 << ASRMCRi_RSYNOFi_SHIFT) | ||
| 242 | #define ASRMCRi_INFIFO_THRESHOLD_WIDTH 6 | ||
| 243 | #define ASRMCRi_INFIFO_THRESHOLD_SHIFT 0 | ||
| 244 | #define ASRMCRi_INFIFO_THRESHOLD_MASK (((1 << ASRMCRi_INFIFO_THRESHOLD_WIDTH) - 1) << ASRMCRi_INFIFO_THRESHOLD_SHIFT) | ||
| 245 | #define ASRMCRi_INFIFO_THRESHOLD(v) (((v) << ASRMCRi_INFIFO_THRESHOLD_SHIFT) & ASRMCRi_INFIFO_THRESHOLD_MASK) | ||
| 246 | |||
| 247 | /* | ||
| 248 | * REG23 0xA4 REG_ASRFSTA | ||
| 249 | * REG25 0xAC REG_ASRFSTB | ||
| 250 | * REG27 0xB4 REG_ASRFSTC | ||
| 251 | */ | ||
| 252 | #define ASRFSTi_OAFi_SHIFT 23 | ||
| 253 | #define ASRFSTi_OAFi_MASK (1 << ASRFSTi_OAFi_SHIFT) | ||
| 254 | #define ASRFSTi_OAFi (1 << ASRFSTi_OAFi_SHIFT) | ||
| 255 | #define ASRFSTi_OUTPUT_FIFO_WIDTH 7 | ||
| 256 | #define ASRFSTi_OUTPUT_FIFO_SHIFT 12 | ||
| 257 | #define ASRFSTi_OUTPUT_FIFO_MASK (((1 << ASRFSTi_OUTPUT_FIFO_WIDTH) - 1) << ASRFSTi_OUTPUT_FIFO_SHIFT) | ||
| 258 | #define ASRFSTi_IAEi_SHIFT 11 | ||
| 259 | #define ASRFSTi_IAEi_MASK (1 << ASRFSTi_OAFi_SHIFT) | ||
| 260 | #define ASRFSTi_IAEi (1 << ASRFSTi_OAFi_SHIFT) | ||
| 261 | #define ASRFSTi_INPUT_FIFO_WIDTH 7 | ||
| 262 | #define ASRFSTi_INPUT_FIFO_SHIFT 0 | ||
| 263 | #define ASRFSTi_INPUT_FIFO_MASK ((1 << ASRFSTi_INPUT_FIFO_WIDTH) - 1) | ||
| 264 | |||
| 265 | /* REG28 0xC0 & 0xC4 & 0xC8 REG_ASRMCR1i */ | ||
| 266 | #define ASRMCR1i_IWD_WIDTH 3 | ||
| 267 | #define ASRMCR1i_IWD_SHIFT 9 | ||
| 268 | #define ASRMCR1i_IWD_MASK (((1 << ASRMCR1i_IWD_WIDTH) - 1) << ASRMCR1i_IWD_SHIFT) | ||
| 269 | #define ASRMCR1i_IWD(v) ((v) << ASRMCR1i_IWD_SHIFT) | ||
| 270 | #define ASRMCR1i_IMSB_SHIFT 8 | ||
| 271 | #define ASRMCR1i_IMSB_MASK (1 << ASRMCR1i_IMSB_SHIFT) | ||
| 272 | #define ASRMCR1i_IMSB_MSB (1 << ASRMCR1i_IMSB_SHIFT) | ||
| 273 | #define ASRMCR1i_IMSB_LSB (0 << ASRMCR1i_IMSB_SHIFT) | ||
| 274 | #define ASRMCR1i_OMSB_SHIFT 2 | ||
| 275 | #define ASRMCR1i_OMSB_MASK (1 << ASRMCR1i_OMSB_SHIFT) | ||
| 276 | #define ASRMCR1i_OMSB_MSB (1 << ASRMCR1i_OMSB_SHIFT) | ||
| 277 | #define ASRMCR1i_OMSB_LSB (0 << ASRMCR1i_OMSB_SHIFT) | ||
| 278 | #define ASRMCR1i_OSGN_SHIFT 1 | ||
| 279 | #define ASRMCR1i_OSGN_MASK (1 << ASRMCR1i_OSGN_SHIFT) | ||
| 280 | #define ASRMCR1i_OSGN (1 << ASRMCR1i_OSGN_SHIFT) | ||
| 281 | #define ASRMCR1i_OW16_SHIFT 0 | ||
| 282 | #define ASRMCR1i_OW16_MASK (1 << ASRMCR1i_OW16_SHIFT) | ||
| 283 | #define ASRMCR1i_OW16(v) ((v) << ASRMCR1i_OW16_SHIFT) | ||
| 284 | |||
| 285 | |||
| 286 | enum asrc_pair_index { | ||
| 287 | ASRC_INVALID_PAIR = -1, | ||
| 288 | ASRC_PAIR_A = 0, | ||
| 289 | ASRC_PAIR_B = 1, | ||
| 290 | ASRC_PAIR_C = 2, | ||
| 291 | }; | ||
| 292 | |||
| 293 | #define ASRC_PAIR_MAX_NUM (ASRC_PAIR_C + 1) | ||
| 294 | |||
| 295 | enum asrc_inclk { | ||
| 296 | INCLK_NONE = 0x03, | ||
| 297 | INCLK_ESAI_RX = 0x00, | ||
| 298 | INCLK_SSI1_RX = 0x01, | ||
| 299 | INCLK_SSI2_RX = 0x02, | ||
| 300 | INCLK_SSI3_RX = 0x07, | ||
| 301 | INCLK_SPDIF_RX = 0x04, | ||
| 302 | INCLK_MLB_CLK = 0x05, | ||
| 303 | INCLK_PAD = 0x06, | ||
| 304 | INCLK_ESAI_TX = 0x08, | ||
| 305 | INCLK_SSI1_TX = 0x09, | ||
| 306 | INCLK_SSI2_TX = 0x0a, | ||
| 307 | INCLK_SSI3_TX = 0x0b, | ||
| 308 | INCLK_SPDIF_TX = 0x0c, | ||
| 309 | INCLK_ASRCK1_CLK = 0x0f, | ||
| 310 | }; | ||
| 311 | |||
| 312 | enum asrc_outclk { | ||
| 313 | OUTCLK_NONE = 0x03, | ||
| 314 | OUTCLK_ESAI_TX = 0x00, | ||
| 315 | OUTCLK_SSI1_TX = 0x01, | ||
| 316 | OUTCLK_SSI2_TX = 0x02, | ||
| 317 | OUTCLK_SSI3_TX = 0x07, | ||
| 318 | OUTCLK_SPDIF_TX = 0x04, | ||
| 319 | OUTCLK_MLB_CLK = 0x05, | ||
| 320 | OUTCLK_PAD = 0x06, | ||
| 321 | OUTCLK_ESAI_RX = 0x08, | ||
| 322 | OUTCLK_SSI1_RX = 0x09, | ||
| 323 | OUTCLK_SSI2_RX = 0x0a, | ||
| 324 | OUTCLK_SSI3_RX = 0x0b, | ||
| 325 | OUTCLK_SPDIF_RX = 0x0c, | ||
| 326 | OUTCLK_ASRCK1_CLK = 0x0f, | ||
| 327 | }; | ||
| 328 | |||
| 329 | #define ASRC_CLK_MAX_NUM 16 | ||
| 330 | |||
| 331 | enum asrc_word_width { | ||
| 332 | ASRC_WIDTH_24_BIT = 0, | ||
| 333 | ASRC_WIDTH_16_BIT = 1, | ||
| 334 | ASRC_WIDTH_8_BIT = 2, | ||
| 335 | }; | ||
| 336 | |||
| 337 | struct asrc_config { | ||
| 338 | enum asrc_pair_index pair; | ||
| 339 | unsigned int channel_num; | ||
| 340 | unsigned int buffer_num; | ||
| 341 | unsigned int dma_buffer_size; | ||
| 342 | unsigned int input_sample_rate; | ||
| 343 | unsigned int output_sample_rate; | ||
| 344 | enum asrc_word_width input_word_width; | ||
| 345 | enum asrc_word_width output_word_width; | ||
| 346 | enum asrc_inclk inclk; | ||
| 347 | enum asrc_outclk outclk; | ||
| 348 | }; | ||
| 349 | |||
| 350 | struct asrc_req { | ||
| 351 | unsigned int chn_num; | ||
| 352 | enum asrc_pair_index index; | ||
| 353 | }; | ||
| 354 | |||
| 355 | struct asrc_querybuf { | ||
| 356 | unsigned int buffer_index; | ||
| 357 | unsigned int input_length; | ||
| 358 | unsigned int output_length; | ||
| 359 | unsigned long input_offset; | ||
| 360 | unsigned long output_offset; | ||
| 361 | }; | ||
| 362 | |||
| 363 | struct asrc_convert_buffer { | ||
| 364 | void *input_buffer_vaddr; | ||
| 365 | void *output_buffer_vaddr; | ||
| 366 | unsigned int input_buffer_length; | ||
| 367 | unsigned int output_buffer_length; | ||
| 368 | }; | ||
| 369 | |||
| 370 | struct asrc_status_flags { | ||
| 371 | enum asrc_pair_index index; | ||
| 372 | unsigned int overload_error; | ||
| 373 | }; | ||
| 374 | |||
| 375 | enum asrc_error_status { | ||
| 376 | ASRC_TASK_Q_OVERLOAD = 0x01, | ||
| 377 | ASRC_OUTPUT_TASK_OVERLOAD = 0x02, | ||
| 378 | ASRC_INPUT_TASK_OVERLOAD = 0x04, | ||
| 379 | ASRC_OUTPUT_BUFFER_OVERFLOW = 0x08, | ||
| 380 | ASRC_INPUT_BUFFER_UNDERRUN = 0x10, | ||
| 381 | }; | ||
| 382 | |||
| 383 | struct dma_block { | ||
| 384 | dma_addr_t dma_paddr; | ||
| 385 | void *dma_vaddr; | ||
| 386 | unsigned int length; | ||
| 387 | }; | ||
| 388 | |||
| 389 | /** | ||
| 390 | * fsl_asrc_pair: ASRC Pair private data | ||
| 391 | * | ||
| 392 | * @asrc_priv: pointer to its parent module | ||
| 393 | * @config: configuration profile | ||
| 394 | * @error: error record | ||
| 395 | * @index: pair index (ASRC_PAIR_A, ASRC_PAIR_B, ASRC_PAIR_C) | ||
| 396 | * @channels: occupied channel number | ||
| 397 | * @desc: input and output dma descriptors | ||
| 398 | * @dma_chan: inputer and output DMA channels | ||
| 399 | * @dma_data: private dma data | ||
| 400 | * @pos: hardware pointer position | ||
| 401 | * @private: pair private area | ||
| 402 | */ | ||
| 403 | struct fsl_asrc_pair { | ||
| 404 | struct fsl_asrc *asrc_priv; | ||
| 405 | struct asrc_config *config; | ||
| 406 | unsigned int error; | ||
| 407 | |||
| 408 | enum asrc_pair_index index; | ||
| 409 | unsigned int channels; | ||
| 410 | |||
| 411 | struct dma_async_tx_descriptor *desc[2]; | ||
| 412 | struct dma_chan *dma_chan[2]; | ||
| 413 | struct imx_dma_data dma_data; | ||
| 414 | unsigned int pos; | ||
| 415 | |||
| 416 | void *private; | ||
| 417 | }; | ||
| 418 | |||
| 419 | /** | ||
| 420 | * fsl_asrc_pair: ASRC private data | ||
| 421 | * | ||
| 422 | * @dma_params_rx: DMA parameters for receive channel | ||
| 423 | * @dma_params_tx: DMA parameters for transmit channel | ||
| 424 | * @pdev: platform device pointer | ||
| 425 | * @regmap: regmap handler | ||
| 426 | * @paddr: physical address to the base address of registers | ||
| 427 | * @mem_clk: clock source to access register | ||
| 428 | * @ipg_clk: clock source to drive peripheral | ||
| 429 | * @asrck_clk: clock sources to driver ASRC internal logic | ||
| 430 | * @lock: spin lock for resource protection | ||
| 431 | * @pair: pair pointers | ||
| 432 | * @channel_bits: width of ASRCNCR register for each pair | ||
| 433 | * @channel_avail: non-occupied channel numbers | ||
| 434 | * @asrc_rate: default sample rate for ASoC Back-Ends | ||
| 435 | * @asrc_width: default sample width for ASoC Back-Ends | ||
| 436 | * @name: driver name | ||
| 437 | */ | ||
| 438 | struct fsl_asrc { | ||
| 439 | struct snd_dmaengine_dai_dma_data dma_params_rx; | ||
| 440 | struct snd_dmaengine_dai_dma_data dma_params_tx; | ||
| 441 | struct platform_device *pdev; | ||
| 442 | struct regmap *regmap; | ||
| 443 | unsigned long paddr; | ||
| 444 | struct clk *mem_clk; | ||
| 445 | struct clk *ipg_clk; | ||
| 446 | struct clk *asrck_clk[ASRC_CLK_MAX_NUM]; | ||
| 447 | spinlock_t lock; | ||
| 448 | |||
| 449 | struct fsl_asrc_pair *pair[ASRC_PAIR_MAX_NUM]; | ||
| 450 | unsigned int channel_bits; | ||
| 451 | unsigned int channel_avail; | ||
| 452 | |||
| 453 | int asrc_rate; | ||
| 454 | int asrc_width; | ||
| 455 | |||
| 456 | char name[32]; | ||
| 457 | }; | ||
| 458 | |||
| 459 | extern struct snd_soc_platform_driver fsl_asrc_platform; | ||
| 460 | struct dma_chan *fsl_asrc_get_dma_channel(struct fsl_asrc_pair *pair, bool dir); | ||
| 461 | #endif /* _FSL_ASRC_H */ | ||
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c new file mode 100644 index 000000000000..ffc000bc1f15 --- /dev/null +++ b/sound/soc/fsl/fsl_asrc_dma.c | |||
| @@ -0,0 +1,391 @@ | |||
| 1 | /* | ||
| 2 | * Freescale ASRC ALSA SoC Platform (DMA) driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2014 Freescale Semiconductor, Inc. | ||
| 5 | * | ||
| 6 | * Author: Nicolin Chen <nicoleotsuka@gmail.com> | ||
| 7 | * | ||
| 8 | * This file is licensed under the terms of the GNU General Public License | ||
| 9 | * version 2. This program is licensed "as is" without any warranty of any | ||
| 10 | * kind, whether express or implied. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/dma-mapping.h> | ||
| 14 | #include <linux/module.h> | ||
| 15 | #include <linux/platform_data/dma-imx.h> | ||
| 16 | #include <sound/dmaengine_pcm.h> | ||
| 17 | #include <sound/pcm_params.h> | ||
| 18 | |||
| 19 | #include "fsl_asrc.h" | ||
| 20 | |||
| 21 | #define FSL_ASRC_DMABUF_SIZE (256 * 1024) | ||
| 22 | |||
| 23 | static struct snd_pcm_hardware snd_imx_hardware = { | ||
| 24 | .info = SNDRV_PCM_INFO_INTERLEAVED | | ||
| 25 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
| 26 | SNDRV_PCM_INFO_MMAP | | ||
| 27 | SNDRV_PCM_INFO_MMAP_VALID | | ||
| 28 | SNDRV_PCM_INFO_PAUSE | | ||
| 29 | SNDRV_PCM_INFO_RESUME, | ||
| 30 | .buffer_bytes_max = FSL_ASRC_DMABUF_SIZE, | ||
| 31 | .period_bytes_min = 128, | ||
| 32 | .period_bytes_max = 65535, /* Limited by SDMA engine */ | ||
| 33 | .periods_min = 2, | ||
| 34 | .periods_max = 255, | ||
| 35 | .fifo_size = 0, | ||
| 36 | }; | ||
| 37 | |||
| 38 | static bool filter(struct dma_chan *chan, void *param) | ||
| 39 | { | ||
| 40 | if (!imx_dma_is_general_purpose(chan)) | ||
| 41 | return false; | ||
| 42 | |||
| 43 | chan->private = param; | ||
| 44 | |||
| 45 | return true; | ||
| 46 | } | ||
| 47 | |||
| 48 | static void fsl_asrc_dma_complete(void *arg) | ||
| 49 | { | ||
| 50 | struct snd_pcm_substream *substream = arg; | ||
| 51 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 52 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 53 | |||
| 54 | pair->pos += snd_pcm_lib_period_bytes(substream); | ||
| 55 | if (pair->pos >= snd_pcm_lib_buffer_bytes(substream)) | ||
| 56 | pair->pos = 0; | ||
| 57 | |||
| 58 | snd_pcm_period_elapsed(substream); | ||
| 59 | } | ||
| 60 | |||
| 61 | static int fsl_asrc_dma_prepare_and_submit(struct snd_pcm_substream *substream) | ||
| 62 | { | ||
| 63 | u8 dir = substream->stream == SNDRV_PCM_STREAM_PLAYBACK ? OUT : IN; | ||
| 64 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 65 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 66 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 67 | struct device *dev = rtd->platform->dev; | ||
| 68 | unsigned long flags = DMA_CTRL_ACK; | ||
| 69 | |||
| 70 | /* Prepare and submit Front-End DMA channel */ | ||
| 71 | if (!substream->runtime->no_period_wakeup) | ||
| 72 | flags |= DMA_PREP_INTERRUPT; | ||
| 73 | |||
| 74 | pair->pos = 0; | ||
| 75 | pair->desc[!dir] = dmaengine_prep_dma_cyclic( | ||
| 76 | pair->dma_chan[!dir], runtime->dma_addr, | ||
| 77 | snd_pcm_lib_buffer_bytes(substream), | ||
| 78 | snd_pcm_lib_period_bytes(substream), | ||
| 79 | dir == OUT ? DMA_TO_DEVICE : DMA_FROM_DEVICE, flags); | ||
| 80 | if (!pair->desc[!dir]) { | ||
| 81 | dev_err(dev, "failed to prepare slave DMA for Front-End\n"); | ||
| 82 | return -ENOMEM; | ||
| 83 | } | ||
| 84 | |||
| 85 | pair->desc[!dir]->callback = fsl_asrc_dma_complete; | ||
| 86 | pair->desc[!dir]->callback_param = substream; | ||
| 87 | |||
| 88 | dmaengine_submit(pair->desc[!dir]); | ||
| 89 | |||
| 90 | /* Prepare and submit Back-End DMA channel */ | ||
| 91 | pair->desc[dir] = dmaengine_prep_dma_cyclic( | ||
| 92 | pair->dma_chan[dir], 0xffff, 64, 64, DMA_DEV_TO_DEV, 0); | ||
| 93 | if (!pair->desc[dir]) { | ||
| 94 | dev_err(dev, "failed to prepare slave DMA for Back-End\n"); | ||
| 95 | return -ENOMEM; | ||
| 96 | } | ||
| 97 | |||
| 98 | dmaengine_submit(pair->desc[dir]); | ||
| 99 | |||
| 100 | return 0; | ||
| 101 | } | ||
| 102 | |||
| 103 | static int fsl_asrc_dma_trigger(struct snd_pcm_substream *substream, int cmd) | ||
| 104 | { | ||
| 105 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 106 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 107 | int ret; | ||
| 108 | |||
| 109 | switch (cmd) { | ||
| 110 | case SNDRV_PCM_TRIGGER_START: | ||
| 111 | case SNDRV_PCM_TRIGGER_RESUME: | ||
| 112 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
| 113 | ret = fsl_asrc_dma_prepare_and_submit(substream); | ||
| 114 | if (ret) | ||
| 115 | return ret; | ||
| 116 | dma_async_issue_pending(pair->dma_chan[IN]); | ||
| 117 | dma_async_issue_pending(pair->dma_chan[OUT]); | ||
| 118 | break; | ||
| 119 | case SNDRV_PCM_TRIGGER_STOP: | ||
| 120 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
| 121 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
| 122 | dmaengine_terminate_all(pair->dma_chan[OUT]); | ||
| 123 | dmaengine_terminate_all(pair->dma_chan[IN]); | ||
| 124 | break; | ||
| 125 | default: | ||
| 126 | return -EINVAL; | ||
| 127 | } | ||
| 128 | |||
| 129 | return 0; | ||
| 130 | } | ||
| 131 | |||
| 132 | static int fsl_asrc_dma_hw_params(struct snd_pcm_substream *substream, | ||
| 133 | struct snd_pcm_hw_params *params) | ||
| 134 | { | ||
| 135 | enum dma_slave_buswidth buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
| 136 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 137 | bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | ||
| 138 | struct snd_dmaengine_dai_dma_data *dma_params_fe = NULL; | ||
| 139 | struct snd_dmaengine_dai_dma_data *dma_params_be = NULL; | ||
| 140 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 141 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 142 | struct fsl_asrc *asrc_priv = pair->asrc_priv; | ||
| 143 | struct dma_slave_config config_fe, config_be; | ||
| 144 | enum asrc_pair_index index = pair->index; | ||
| 145 | struct device *dev = rtd->platform->dev; | ||
| 146 | int stream = substream->stream; | ||
| 147 | struct imx_dma_data *tmp_data; | ||
| 148 | struct snd_soc_dpcm *dpcm; | ||
| 149 | struct dma_chan *tmp_chan; | ||
| 150 | struct device *dev_be; | ||
| 151 | u8 dir = tx ? OUT : IN; | ||
| 152 | dma_cap_mask_t mask; | ||
| 153 | int ret; | ||
| 154 | |||
| 155 | /* Fetch the Back-End dma_data from DPCM */ | ||
| 156 | list_for_each_entry(dpcm, &rtd->dpcm[stream].be_clients, list_be) { | ||
| 157 | struct snd_soc_pcm_runtime *be = dpcm->be; | ||
| 158 | struct snd_pcm_substream *substream_be; | ||
| 159 | struct snd_soc_dai *dai = be->cpu_dai; | ||
| 160 | |||
| 161 | if (dpcm->fe != rtd) | ||
| 162 | continue; | ||
| 163 | |||
| 164 | substream_be = snd_soc_dpcm_get_substream(be, stream); | ||
| 165 | dma_params_be = snd_soc_dai_get_dma_data(dai, substream_be); | ||
| 166 | dev_be = dai->dev; | ||
| 167 | break; | ||
| 168 | } | ||
| 169 | |||
| 170 | if (!dma_params_be) { | ||
| 171 | dev_err(dev, "failed to get the substream of Back-End\n"); | ||
| 172 | return -EINVAL; | ||
| 173 | } | ||
| 174 | |||
| 175 | /* Override dma_data of the Front-End and config its dmaengine */ | ||
| 176 | dma_params_fe = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 177 | dma_params_fe->addr = asrc_priv->paddr + REG_ASRDx(!dir, index); | ||
| 178 | dma_params_fe->maxburst = dma_params_be->maxburst; | ||
| 179 | |||
| 180 | pair->dma_chan[!dir] = fsl_asrc_get_dma_channel(pair, !dir); | ||
| 181 | if (!pair->dma_chan[!dir]) { | ||
| 182 | dev_err(dev, "failed to request DMA channel\n"); | ||
| 183 | return -EINVAL; | ||
| 184 | } | ||
| 185 | |||
| 186 | memset(&config_fe, 0, sizeof(config_fe)); | ||
| 187 | ret = snd_dmaengine_pcm_prepare_slave_config(substream, params, &config_fe); | ||
| 188 | if (ret) { | ||
| 189 | dev_err(dev, "failed to prepare DMA config for Front-End\n"); | ||
| 190 | return ret; | ||
| 191 | } | ||
| 192 | |||
| 193 | ret = dmaengine_slave_config(pair->dma_chan[!dir], &config_fe); | ||
| 194 | if (ret) { | ||
| 195 | dev_err(dev, "failed to config DMA channel for Front-End\n"); | ||
| 196 | return ret; | ||
| 197 | } | ||
| 198 | |||
| 199 | /* Request and config DMA channel for Back-End */ | ||
| 200 | dma_cap_zero(mask); | ||
| 201 | dma_cap_set(DMA_SLAVE, mask); | ||
| 202 | dma_cap_set(DMA_CYCLIC, mask); | ||
| 203 | |||
| 204 | /* Get DMA request of Back-End */ | ||
| 205 | tmp_chan = dma_request_slave_channel(dev_be, tx ? "tx" : "rx"); | ||
| 206 | tmp_data = tmp_chan->private; | ||
| 207 | pair->dma_data.dma_request = tmp_data->dma_request; | ||
| 208 | dma_release_channel(tmp_chan); | ||
| 209 | |||
| 210 | /* Get DMA request of Front-End */ | ||
| 211 | tmp_chan = fsl_asrc_get_dma_channel(pair, dir); | ||
| 212 | tmp_data = tmp_chan->private; | ||
| 213 | pair->dma_data.dma_request2 = tmp_data->dma_request; | ||
| 214 | pair->dma_data.peripheral_type = tmp_data->peripheral_type; | ||
| 215 | pair->dma_data.priority = tmp_data->priority; | ||
| 216 | dma_release_channel(tmp_chan); | ||
| 217 | |||
| 218 | pair->dma_chan[dir] = dma_request_channel(mask, filter, &pair->dma_data); | ||
| 219 | if (!pair->dma_chan[dir]) { | ||
| 220 | dev_err(dev, "failed to request DMA channel for Back-End\n"); | ||
| 221 | return -EINVAL; | ||
| 222 | } | ||
| 223 | |||
| 224 | if (asrc_priv->asrc_width == 16) | ||
| 225 | buswidth = DMA_SLAVE_BUSWIDTH_2_BYTES; | ||
| 226 | else | ||
| 227 | buswidth = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
| 228 | |||
| 229 | config_be.direction = DMA_DEV_TO_DEV; | ||
| 230 | config_be.src_addr_width = buswidth; | ||
| 231 | config_be.src_maxburst = dma_params_be->maxburst; | ||
| 232 | config_be.dst_addr_width = buswidth; | ||
| 233 | config_be.dst_maxburst = dma_params_be->maxburst; | ||
| 234 | |||
| 235 | if (tx) { | ||
| 236 | config_be.src_addr = asrc_priv->paddr + REG_ASRDO(index); | ||
| 237 | config_be.dst_addr = dma_params_be->addr; | ||
| 238 | } else { | ||
| 239 | config_be.dst_addr = asrc_priv->paddr + REG_ASRDI(index); | ||
| 240 | config_be.src_addr = dma_params_be->addr; | ||
| 241 | } | ||
| 242 | |||
| 243 | ret = dmaengine_slave_config(pair->dma_chan[dir], &config_be); | ||
| 244 | if (ret) { | ||
| 245 | dev_err(dev, "failed to config DMA channel for Back-End\n"); | ||
| 246 | return ret; | ||
| 247 | } | ||
| 248 | |||
| 249 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | ||
| 250 | |||
| 251 | return 0; | ||
| 252 | } | ||
| 253 | |||
| 254 | static int fsl_asrc_dma_hw_free(struct snd_pcm_substream *substream) | ||
| 255 | { | ||
| 256 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 257 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 258 | |||
| 259 | snd_pcm_set_runtime_buffer(substream, NULL); | ||
| 260 | |||
| 261 | if (pair->dma_chan[IN]) | ||
| 262 | dma_release_channel(pair->dma_chan[IN]); | ||
| 263 | |||
| 264 | if (pair->dma_chan[OUT]) | ||
| 265 | dma_release_channel(pair->dma_chan[OUT]); | ||
| 266 | |||
| 267 | pair->dma_chan[IN] = NULL; | ||
| 268 | pair->dma_chan[OUT] = NULL; | ||
| 269 | |||
| 270 | return 0; | ||
| 271 | } | ||
| 272 | |||
| 273 | static int fsl_asrc_dma_startup(struct snd_pcm_substream *substream) | ||
| 274 | { | ||
| 275 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 276 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 277 | struct device *dev = rtd->platform->dev; | ||
| 278 | struct fsl_asrc *asrc_priv = dev_get_drvdata(dev); | ||
| 279 | struct fsl_asrc_pair *pair; | ||
| 280 | |||
| 281 | pair = kzalloc(sizeof(struct fsl_asrc_pair), GFP_KERNEL); | ||
| 282 | if (!pair) { | ||
| 283 | dev_err(dev, "failed to allocate pair\n"); | ||
| 284 | return -ENOMEM; | ||
| 285 | } | ||
| 286 | |||
| 287 | pair->asrc_priv = asrc_priv; | ||
| 288 | |||
| 289 | runtime->private_data = pair; | ||
| 290 | |||
| 291 | snd_pcm_hw_constraint_integer(substream->runtime, | ||
| 292 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
| 293 | snd_soc_set_runtime_hwparams(substream, &snd_imx_hardware); | ||
| 294 | |||
| 295 | return 0; | ||
| 296 | } | ||
| 297 | |||
| 298 | static int fsl_asrc_dma_shutdown(struct snd_pcm_substream *substream) | ||
| 299 | { | ||
| 300 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 301 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 302 | struct fsl_asrc *asrc_priv; | ||
| 303 | |||
| 304 | if (!pair) | ||
| 305 | return 0; | ||
| 306 | |||
| 307 | asrc_priv = pair->asrc_priv; | ||
| 308 | |||
| 309 | if (asrc_priv->pair[pair->index] == pair) | ||
| 310 | asrc_priv->pair[pair->index] = NULL; | ||
| 311 | |||
| 312 | kfree(pair); | ||
| 313 | |||
| 314 | return 0; | ||
| 315 | } | ||
| 316 | |||
| 317 | static snd_pcm_uframes_t fsl_asrc_dma_pcm_pointer(struct snd_pcm_substream *substream) | ||
| 318 | { | ||
| 319 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 320 | struct fsl_asrc_pair *pair = runtime->private_data; | ||
| 321 | |||
| 322 | return bytes_to_frames(substream->runtime, pair->pos); | ||
| 323 | } | ||
| 324 | |||
| 325 | static struct snd_pcm_ops fsl_asrc_dma_pcm_ops = { | ||
| 326 | .ioctl = snd_pcm_lib_ioctl, | ||
| 327 | .hw_params = fsl_asrc_dma_hw_params, | ||
| 328 | .hw_free = fsl_asrc_dma_hw_free, | ||
| 329 | .trigger = fsl_asrc_dma_trigger, | ||
| 330 | .open = fsl_asrc_dma_startup, | ||
| 331 | .close = fsl_asrc_dma_shutdown, | ||
| 332 | .pointer = fsl_asrc_dma_pcm_pointer, | ||
| 333 | }; | ||
| 334 | |||
| 335 | static int fsl_asrc_dma_pcm_new(struct snd_soc_pcm_runtime *rtd) | ||
| 336 | { | ||
| 337 | struct snd_card *card = rtd->card->snd_card; | ||
| 338 | struct snd_pcm_substream *substream; | ||
| 339 | struct snd_pcm *pcm = rtd->pcm; | ||
| 340 | int ret, i; | ||
| 341 | |||
| 342 | ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); | ||
| 343 | if (ret) { | ||
| 344 | dev_err(card->dev, "failed to set DMA mask\n"); | ||
| 345 | return ret; | ||
| 346 | } | ||
| 347 | |||
| 348 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_LAST; i++) { | ||
| 349 | substream = pcm->streams[i].substream; | ||
| 350 | if (!substream) | ||
| 351 | continue; | ||
| 352 | |||
| 353 | ret = snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, pcm->card->dev, | ||
| 354 | FSL_ASRC_DMABUF_SIZE, &substream->dma_buffer); | ||
| 355 | if (ret) { | ||
| 356 | dev_err(card->dev, "failed to allocate DMA buffer\n"); | ||
| 357 | goto err; | ||
| 358 | } | ||
| 359 | } | ||
| 360 | |||
| 361 | return 0; | ||
| 362 | |||
| 363 | err: | ||
| 364 | if (--i == 0 && pcm->streams[i].substream) | ||
| 365 | snd_dma_free_pages(&pcm->streams[i].substream->dma_buffer); | ||
| 366 | |||
| 367 | return ret; | ||
| 368 | } | ||
| 369 | |||
| 370 | static void fsl_asrc_dma_pcm_free(struct snd_pcm *pcm) | ||
| 371 | { | ||
| 372 | struct snd_pcm_substream *substream; | ||
| 373 | int i; | ||
| 374 | |||
| 375 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_LAST; i++) { | ||
| 376 | substream = pcm->streams[i].substream; | ||
| 377 | if (!substream) | ||
| 378 | continue; | ||
| 379 | |||
| 380 | snd_dma_free_pages(&substream->dma_buffer); | ||
| 381 | substream->dma_buffer.area = NULL; | ||
| 382 | substream->dma_buffer.addr = 0; | ||
| 383 | } | ||
| 384 | } | ||
| 385 | |||
| 386 | struct snd_soc_platform_driver fsl_asrc_platform = { | ||
| 387 | .ops = &fsl_asrc_dma_pcm_ops, | ||
| 388 | .pcm_new = fsl_asrc_dma_pcm_new, | ||
| 389 | .pcm_free = fsl_asrc_dma_pcm_free, | ||
| 390 | }; | ||
| 391 | EXPORT_SYMBOL_GPL(fsl_asrc_platform); | ||
diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c index d719caf26dc2..72d154e7dd03 100644 --- a/sound/soc/fsl/fsl_esai.c +++ b/sound/soc/fsl/fsl_esai.c | |||
| @@ -624,12 +624,14 @@ static int fsl_esai_dai_probe(struct snd_soc_dai *dai) | |||
| 624 | static struct snd_soc_dai_driver fsl_esai_dai = { | 624 | static struct snd_soc_dai_driver fsl_esai_dai = { |
| 625 | .probe = fsl_esai_dai_probe, | 625 | .probe = fsl_esai_dai_probe, |
| 626 | .playback = { | 626 | .playback = { |
| 627 | .stream_name = "CPU-Playback", | ||
| 627 | .channels_min = 1, | 628 | .channels_min = 1, |
| 628 | .channels_max = 12, | 629 | .channels_max = 12, |
| 629 | .rates = FSL_ESAI_RATES, | 630 | .rates = FSL_ESAI_RATES, |
| 630 | .formats = FSL_ESAI_FORMATS, | 631 | .formats = FSL_ESAI_FORMATS, |
| 631 | }, | 632 | }, |
| 632 | .capture = { | 633 | .capture = { |
| 634 | .stream_name = "CPU-Capture", | ||
| 633 | .channels_min = 1, | 635 | .channels_min = 1, |
| 634 | .channels_max = 8, | 636 | .channels_max = 8, |
| 635 | .rates = FSL_ESAI_RATES, | 637 | .rates = FSL_ESAI_RATES, |
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index c5a0e8af8226..faa049797897 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c | |||
| @@ -106,7 +106,7 @@ irq_rx: | |||
| 106 | xcsr &= ~FSL_SAI_CSR_xF_MASK; | 106 | xcsr &= ~FSL_SAI_CSR_xF_MASK; |
| 107 | 107 | ||
| 108 | if (flags) | 108 | if (flags) |
| 109 | regmap_write(sai->regmap, FSL_SAI_TCSR, flags | xcsr); | 109 | regmap_write(sai->regmap, FSL_SAI_RCSR, flags | xcsr); |
| 110 | 110 | ||
| 111 | out: | 111 | out: |
| 112 | if (irq_none) | 112 | if (irq_none) |
| @@ -327,7 +327,7 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 327 | { | 327 | { |
| 328 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); | 328 | struct fsl_sai *sai = snd_soc_dai_get_drvdata(cpu_dai); |
| 329 | bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | 329 | bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
| 330 | u32 tcsr, rcsr; | 330 | u32 xcsr, count = 100; |
| 331 | 331 | ||
| 332 | /* | 332 | /* |
| 333 | * The transmitter bit clock and frame sync are to be | 333 | * The transmitter bit clock and frame sync are to be |
| @@ -338,9 +338,6 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 338 | regmap_update_bits(sai->regmap, FSL_SAI_RCR2, FSL_SAI_CR2_SYNC, | 338 | regmap_update_bits(sai->regmap, FSL_SAI_RCR2, FSL_SAI_CR2_SYNC, |
| 339 | FSL_SAI_CR2_SYNC); | 339 | FSL_SAI_CR2_SYNC); |
| 340 | 340 | ||
| 341 | regmap_read(sai->regmap, FSL_SAI_TCSR, &tcsr); | ||
| 342 | regmap_read(sai->regmap, FSL_SAI_RCSR, &rcsr); | ||
| 343 | |||
| 344 | /* | 341 | /* |
| 345 | * It is recommended that the transmitter is the last enabled | 342 | * It is recommended that the transmitter is the last enabled |
| 346 | * and the first disabled. | 343 | * and the first disabled. |
| @@ -349,17 +346,16 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 349 | case SNDRV_PCM_TRIGGER_START: | 346 | case SNDRV_PCM_TRIGGER_START: |
| 350 | case SNDRV_PCM_TRIGGER_RESUME: | 347 | case SNDRV_PCM_TRIGGER_RESUME: |
| 351 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 348 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 352 | if (!(tcsr & FSL_SAI_CSR_FRDE || rcsr & FSL_SAI_CSR_FRDE)) { | 349 | regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), |
| 353 | regmap_update_bits(sai->regmap, FSL_SAI_RCSR, | 350 | FSL_SAI_CSR_FRDE, FSL_SAI_CSR_FRDE); |
| 354 | FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); | 351 | |
| 355 | regmap_update_bits(sai->regmap, FSL_SAI_TCSR, | 352 | regmap_update_bits(sai->regmap, FSL_SAI_RCSR, |
| 356 | FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); | 353 | FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); |
| 357 | } | 354 | regmap_update_bits(sai->regmap, FSL_SAI_TCSR, |
| 355 | FSL_SAI_CSR_TERE, FSL_SAI_CSR_TERE); | ||
| 358 | 356 | ||
| 359 | regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), | 357 | regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), |
| 360 | FSL_SAI_CSR_xIE_MASK, FSL_SAI_FLAGS); | 358 | FSL_SAI_CSR_xIE_MASK, FSL_SAI_FLAGS); |
| 361 | regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx), | ||
| 362 | FSL_SAI_CSR_FRDE, FSL_SAI_CSR_FRDE); | ||
| 363 | break; | 359 | break; |
| 364 | case SNDRV_PCM_TRIGGER_STOP: | 360 | case SNDRV_PCM_TRIGGER_STOP: |
| 365 | case SNDRV_PCM_TRIGGER_SUSPEND: | 361 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| @@ -370,11 +366,24 @@ static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 370 | FSL_SAI_CSR_xIE_MASK, 0); | 366 | FSL_SAI_CSR_xIE_MASK, 0); |
| 371 | 367 | ||
| 372 | /* Check if the opposite FRDE is also disabled */ | 368 | /* Check if the opposite FRDE is also disabled */ |
| 373 | if (!(tx ? rcsr & FSL_SAI_CSR_FRDE : tcsr & FSL_SAI_CSR_FRDE)) { | 369 | regmap_read(sai->regmap, FSL_SAI_xCSR(!tx), &xcsr); |
| 370 | if (!(xcsr & FSL_SAI_CSR_FRDE)) { | ||
| 371 | /* Disable both directions and reset their FIFOs */ | ||
| 374 | regmap_update_bits(sai->regmap, FSL_SAI_TCSR, | 372 | regmap_update_bits(sai->regmap, FSL_SAI_TCSR, |
| 375 | FSL_SAI_CSR_TERE, 0); | 373 | FSL_SAI_CSR_TERE, 0); |
| 376 | regmap_update_bits(sai->regmap, FSL_SAI_RCSR, | 374 | regmap_update_bits(sai->regmap, FSL_SAI_RCSR, |
| 377 | FSL_SAI_CSR_TERE, 0); | 375 | FSL_SAI_CSR_TERE, 0); |
| 376 | |||
| 377 | /* TERE will remain set till the end of current frame */ | ||
| 378 | do { | ||
| 379 | udelay(10); | ||
| 380 | regmap_read(sai->regmap, FSL_SAI_xCSR(tx), &xcsr); | ||
| 381 | } while (--count && xcsr & FSL_SAI_CSR_TERE); | ||
| 382 | |||
| 383 | regmap_update_bits(sai->regmap, FSL_SAI_TCSR, | ||
| 384 | FSL_SAI_CSR_FR, FSL_SAI_CSR_FR); | ||
| 385 | regmap_update_bits(sai->regmap, FSL_SAI_RCSR, | ||
| 386 | FSL_SAI_CSR_FR, FSL_SAI_CSR_FR); | ||
| 378 | } | 387 | } |
| 379 | break; | 388 | break; |
| 380 | default: | 389 | default: |
| @@ -446,12 +455,14 @@ static int fsl_sai_dai_probe(struct snd_soc_dai *cpu_dai) | |||
| 446 | static struct snd_soc_dai_driver fsl_sai_dai = { | 455 | static struct snd_soc_dai_driver fsl_sai_dai = { |
| 447 | .probe = fsl_sai_dai_probe, | 456 | .probe = fsl_sai_dai_probe, |
| 448 | .playback = { | 457 | .playback = { |
| 458 | .stream_name = "CPU-Playback", | ||
| 449 | .channels_min = 1, | 459 | .channels_min = 1, |
| 450 | .channels_max = 2, | 460 | .channels_max = 2, |
| 451 | .rates = SNDRV_PCM_RATE_8000_96000, | 461 | .rates = SNDRV_PCM_RATE_8000_96000, |
| 452 | .formats = FSL_SAI_FORMATS, | 462 | .formats = FSL_SAI_FORMATS, |
| 453 | }, | 463 | }, |
| 454 | .capture = { | 464 | .capture = { |
| 465 | .stream_name = "CPU-Capture", | ||
| 455 | .channels_min = 1, | 466 | .channels_min = 1, |
| 456 | .channels_max = 2, | 467 | .channels_max = 2, |
| 457 | .rates = SNDRV_PCM_RATE_8000_96000, | 468 | .rates = SNDRV_PCM_RATE_8000_96000, |
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index d7a60614dd21..70acfe4a9bd5 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c | |||
| @@ -32,10 +32,13 @@ | |||
| 32 | #define FSL_SPDIF_TXFIFO_WML 0x8 | 32 | #define FSL_SPDIF_TXFIFO_WML 0x8 |
| 33 | #define FSL_SPDIF_RXFIFO_WML 0x8 | 33 | #define FSL_SPDIF_RXFIFO_WML 0x8 |
| 34 | 34 | ||
| 35 | #define INTR_FOR_PLAYBACK (INT_TXFIFO_RESYNC) | 35 | #define INTR_FOR_PLAYBACK (INT_TXFIFO_RESYNC) |
| 36 | #define INTR_FOR_CAPTURE (INT_SYM_ERR | INT_BIT_ERR | INT_URX_FUL | INT_URX_OV|\ | 36 | #define INTR_FOR_CAPTURE (INT_SYM_ERR | INT_BIT_ERR | INT_URX_FUL |\ |
| 37 | INT_QRX_FUL | INT_QRX_OV | INT_UQ_SYNC | INT_UQ_ERR |\ | 37 | INT_URX_OV | INT_QRX_FUL | INT_QRX_OV |\ |
| 38 | INT_RXFIFO_RESYNC | INT_LOSS_LOCK | INT_DPLL_LOCKED) | 38 | INT_UQ_SYNC | INT_UQ_ERR | INT_RXFIFO_RESYNC |\ |
| 39 | INT_LOSS_LOCK | INT_DPLL_LOCKED) | ||
| 40 | |||
| 41 | #define SIE_INTR_FOR(tx) (tx ? INTR_FOR_PLAYBACK : INTR_FOR_CAPTURE) | ||
| 39 | 42 | ||
| 40 | /* Index list for the values that has if (DPLL Locked) condition */ | 43 | /* Index list for the values that has if (DPLL Locked) condition */ |
| 41 | static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0xa, 0xb }; | 44 | static u8 srpc_dpll_locked[] = { 0x0, 0x1, 0x2, 0x3, 0x4, 0xa, 0xb }; |
| @@ -96,7 +99,7 @@ struct fsl_spdif_priv { | |||
| 96 | struct platform_device *pdev; | 99 | struct platform_device *pdev; |
| 97 | struct regmap *regmap; | 100 | struct regmap *regmap; |
| 98 | bool dpll_locked; | 101 | bool dpll_locked; |
| 99 | u16 txrate[SPDIF_TXRATE_MAX]; | 102 | u32 txrate[SPDIF_TXRATE_MAX]; |
| 100 | u8 txclk_df[SPDIF_TXRATE_MAX]; | 103 | u8 txclk_df[SPDIF_TXRATE_MAX]; |
| 101 | u8 sysclk_df[SPDIF_TXRATE_MAX]; | 104 | u8 sysclk_df[SPDIF_TXRATE_MAX]; |
| 102 | u8 txclk_src[SPDIF_TXRATE_MAX]; | 105 | u8 txclk_src[SPDIF_TXRATE_MAX]; |
| @@ -137,10 +140,9 @@ static void spdif_irq_sym_error(struct fsl_spdif_priv *spdif_priv) | |||
| 137 | 140 | ||
| 138 | dev_dbg(&pdev->dev, "isr: receiver found illegal symbol\n"); | 141 | dev_dbg(&pdev->dev, "isr: receiver found illegal symbol\n"); |
| 139 | 142 | ||
| 140 | if (!spdif_priv->dpll_locked) { | 143 | /* Clear illegal symbol if DPLL unlocked since no audio stream */ |
| 141 | /* DPLL unlocked seems no audio stream */ | 144 | if (!spdif_priv->dpll_locked) |
| 142 | regmap_update_bits(regmap, REG_SPDIF_SIE, INT_SYM_ERR, 0); | 145 | regmap_update_bits(regmap, REG_SPDIF_SIE, INT_SYM_ERR, 0); |
| 143 | } | ||
| 144 | } | 146 | } |
| 145 | 147 | ||
| 146 | /* U/Q Channel receive register full */ | 148 | /* U/Q Channel receive register full */ |
| @@ -335,8 +337,8 @@ static void spdif_write_channel_status(struct fsl_spdif_priv *spdif_priv) | |||
| 335 | u32 ch_status; | 337 | u32 ch_status; |
| 336 | 338 | ||
| 337 | ch_status = (bitrev8(ctrl->ch_status[0]) << 16) | | 339 | ch_status = (bitrev8(ctrl->ch_status[0]) << 16) | |
| 338 | (bitrev8(ctrl->ch_status[1]) << 8) | | 340 | (bitrev8(ctrl->ch_status[1]) << 8) | |
| 339 | bitrev8(ctrl->ch_status[2]); | 341 | bitrev8(ctrl->ch_status[2]); |
| 340 | regmap_write(regmap, REG_SPDIF_STCSCH, ch_status); | 342 | regmap_write(regmap, REG_SPDIF_STCSCH, ch_status); |
| 341 | 343 | ||
| 342 | dev_dbg(&pdev->dev, "STCSCH: 0x%06x\n", ch_status); | 344 | dev_dbg(&pdev->dev, "STCSCH: 0x%06x\n", ch_status); |
| @@ -390,6 +392,14 @@ static int spdif_set_sample_rate(struct snd_pcm_substream *substream, | |||
| 390 | rate = SPDIF_TXRATE_48000; | 392 | rate = SPDIF_TXRATE_48000; |
| 391 | csfs = IEC958_AES3_CON_FS_48000; | 393 | csfs = IEC958_AES3_CON_FS_48000; |
| 392 | break; | 394 | break; |
| 395 | case 96000: | ||
| 396 | rate = SPDIF_TXRATE_96000; | ||
| 397 | csfs = IEC958_AES3_CON_FS_96000; | ||
| 398 | break; | ||
| 399 | case 192000: | ||
| 400 | rate = SPDIF_TXRATE_192000; | ||
| 401 | csfs = IEC958_AES3_CON_FS_192000; | ||
| 402 | break; | ||
| 393 | default: | 403 | default: |
| 394 | dev_err(&pdev->dev, "unsupported sample rate %d\n", sample_rate); | 404 | dev_err(&pdev->dev, "unsupported sample rate %d\n", sample_rate); |
| 395 | return -EINVAL; | 405 | return -EINVAL; |
| @@ -433,13 +443,12 @@ clk_set_bypass: | |||
| 433 | spdif_set_cstatus(ctrl, IEC958_AES3_CON_FS, csfs); | 443 | spdif_set_cstatus(ctrl, IEC958_AES3_CON_FS, csfs); |
| 434 | 444 | ||
| 435 | /* select clock source and divisor */ | 445 | /* select clock source and divisor */ |
| 436 | stc = STC_TXCLK_ALL_EN | STC_TXCLK_SRC_SET(clk) | STC_TXCLK_DF(txclk_df); | 446 | stc = STC_TXCLK_ALL_EN | STC_TXCLK_SRC_SET(clk) | |
| 437 | mask = STC_TXCLK_ALL_EN_MASK | STC_TXCLK_SRC_MASK | STC_TXCLK_DF_MASK; | 447 | STC_TXCLK_DF(txclk_df) | STC_SYSCLK_DF(sysclk_df); |
| 448 | mask = STC_TXCLK_ALL_EN_MASK | STC_TXCLK_SRC_MASK | | ||
| 449 | STC_TXCLK_DF_MASK | STC_SYSCLK_DF_MASK; | ||
| 438 | regmap_update_bits(regmap, REG_SPDIF_STC, mask, stc); | 450 | regmap_update_bits(regmap, REG_SPDIF_STC, mask, stc); |
| 439 | 451 | ||
| 440 | regmap_update_bits(regmap, REG_SPDIF_STC, | ||
| 441 | STC_SYSCLK_DF_MASK, STC_SYSCLK_DF(sysclk_df)); | ||
| 442 | |||
| 443 | dev_dbg(&pdev->dev, "set sample rate to %dHz for %dHz playback\n", | 452 | dev_dbg(&pdev->dev, "set sample rate to %dHz for %dHz playback\n", |
| 444 | spdif_priv->txrate[rate], sample_rate); | 453 | spdif_priv->txrate[rate], sample_rate); |
| 445 | 454 | ||
| @@ -553,7 +562,7 @@ static int fsl_spdif_hw_params(struct snd_pcm_substream *substream, | |||
| 553 | return ret; | 562 | return ret; |
| 554 | } | 563 | } |
| 555 | spdif_set_cstatus(ctrl, IEC958_AES3_CON_CLOCK, | 564 | spdif_set_cstatus(ctrl, IEC958_AES3_CON_CLOCK, |
| 556 | IEC958_AES3_CON_CLOCK_1000PPM); | 565 | IEC958_AES3_CON_CLOCK_1000PPM); |
| 557 | spdif_write_channel_status(spdif_priv); | 566 | spdif_write_channel_status(spdif_priv); |
| 558 | } else { | 567 | } else { |
| 559 | /* Setup rx clock source */ | 568 | /* Setup rx clock source */ |
| @@ -569,9 +578,9 @@ static int fsl_spdif_trigger(struct snd_pcm_substream *substream, | |||
| 569 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 578 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 570 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(rtd->cpu_dai); | 579 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(rtd->cpu_dai); |
| 571 | struct regmap *regmap = spdif_priv->regmap; | 580 | struct regmap *regmap = spdif_priv->regmap; |
| 572 | int is_playack = (substream->stream == SNDRV_PCM_STREAM_PLAYBACK); | 581 | bool tx = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
| 573 | u32 intr = is_playack ? INTR_FOR_PLAYBACK : INTR_FOR_CAPTURE; | 582 | u32 intr = SIE_INTR_FOR(tx); |
| 574 | u32 dmaen = is_playack ? SCR_DMA_TX_EN : SCR_DMA_RX_EN;; | 583 | u32 dmaen = SCR_DMA_xX_EN(tx); |
| 575 | 584 | ||
| 576 | switch (cmd) { | 585 | switch (cmd) { |
| 577 | case SNDRV_PCM_TRIGGER_START: | 586 | case SNDRV_PCM_TRIGGER_START: |
| @@ -662,9 +671,8 @@ static int fsl_spdif_capture_get(struct snd_kcontrol *kcontrol, | |||
| 662 | u32 cstatus, val; | 671 | u32 cstatus, val; |
| 663 | 672 | ||
| 664 | regmap_read(regmap, REG_SPDIF_SIS, &val); | 673 | regmap_read(regmap, REG_SPDIF_SIS, &val); |
| 665 | if (!(val & INT_CNEW)) { | 674 | if (!(val & INT_CNEW)) |
| 666 | return -EAGAIN; | 675 | return -EAGAIN; |
| 667 | } | ||
| 668 | 676 | ||
| 669 | regmap_read(regmap, REG_SPDIF_SRCSH, &cstatus); | 677 | regmap_read(regmap, REG_SPDIF_SRCSH, &cstatus); |
| 670 | ucontrol->value.iec958.status[0] = (cstatus >> 16) & 0xFF; | 678 | ucontrol->value.iec958.status[0] = (cstatus >> 16) & 0xFF; |
| @@ -693,15 +701,14 @@ static int fsl_spdif_subcode_get(struct snd_kcontrol *kcontrol, | |||
| 693 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); | 701 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); |
| 694 | struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; | 702 | struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; |
| 695 | unsigned long flags; | 703 | unsigned long flags; |
| 696 | int ret = 0; | 704 | int ret = -EAGAIN; |
| 697 | 705 | ||
| 698 | spin_lock_irqsave(&ctrl->ctl_lock, flags); | 706 | spin_lock_irqsave(&ctrl->ctl_lock, flags); |
| 699 | if (ctrl->ready_buf) { | 707 | if (ctrl->ready_buf) { |
| 700 | int idx = (ctrl->ready_buf - 1) * SPDIF_UBITS_SIZE; | 708 | int idx = (ctrl->ready_buf - 1) * SPDIF_UBITS_SIZE; |
| 701 | memcpy(&ucontrol->value.iec958.subcode[0], | 709 | memcpy(&ucontrol->value.iec958.subcode[0], |
| 702 | &ctrl->subcode[idx], SPDIF_UBITS_SIZE); | 710 | &ctrl->subcode[idx], SPDIF_UBITS_SIZE); |
| 703 | } else { | 711 | ret = 0; |
| 704 | ret = -EAGAIN; | ||
| 705 | } | 712 | } |
| 706 | spin_unlock_irqrestore(&ctrl->ctl_lock, flags); | 713 | spin_unlock_irqrestore(&ctrl->ctl_lock, flags); |
| 707 | 714 | ||
| @@ -726,15 +733,14 @@ static int fsl_spdif_qget(struct snd_kcontrol *kcontrol, | |||
| 726 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); | 733 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); |
| 727 | struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; | 734 | struct spdif_mixer_control *ctrl = &spdif_priv->fsl_spdif_control; |
| 728 | unsigned long flags; | 735 | unsigned long flags; |
| 729 | int ret = 0; | 736 | int ret = -EAGAIN; |
| 730 | 737 | ||
| 731 | spin_lock_irqsave(&ctrl->ctl_lock, flags); | 738 | spin_lock_irqsave(&ctrl->ctl_lock, flags); |
| 732 | if (ctrl->ready_buf) { | 739 | if (ctrl->ready_buf) { |
| 733 | int idx = (ctrl->ready_buf - 1) * SPDIF_QSUB_SIZE; | 740 | int idx = (ctrl->ready_buf - 1) * SPDIF_QSUB_SIZE; |
| 734 | memcpy(&ucontrol->value.bytes.data[0], | 741 | memcpy(&ucontrol->value.bytes.data[0], |
| 735 | &ctrl->qsub[idx], SPDIF_QSUB_SIZE); | 742 | &ctrl->qsub[idx], SPDIF_QSUB_SIZE); |
| 736 | } else { | 743 | ret = 0; |
| 737 | ret = -EAGAIN; | ||
| 738 | } | 744 | } |
| 739 | spin_unlock_irqrestore(&ctrl->ctl_lock, flags); | 745 | spin_unlock_irqrestore(&ctrl->ctl_lock, flags); |
| 740 | 746 | ||
| @@ -799,10 +805,10 @@ static int spdif_get_rxclk_rate(struct fsl_spdif_priv *spdif_priv, | |||
| 799 | regmap_read(regmap, REG_SPDIF_SRPC, &phaseconf); | 805 | regmap_read(regmap, REG_SPDIF_SRPC, &phaseconf); |
| 800 | 806 | ||
| 801 | clksrc = (phaseconf >> SRPC_CLKSRC_SEL_OFFSET) & 0xf; | 807 | clksrc = (phaseconf >> SRPC_CLKSRC_SEL_OFFSET) & 0xf; |
| 802 | if (srpc_dpll_locked[clksrc] && (phaseconf & SRPC_DPLL_LOCKED)) { | 808 | |
| 803 | /* Get bus clock from system */ | 809 | /* Get bus clock from system */ |
| 810 | if (srpc_dpll_locked[clksrc] && (phaseconf & SRPC_DPLL_LOCKED)) | ||
| 804 | busclk_freq = clk_get_rate(spdif_priv->sysclk); | 811 | busclk_freq = clk_get_rate(spdif_priv->sysclk); |
| 805 | } | ||
| 806 | 812 | ||
| 807 | /* FreqMeas_CLK = (BUS_CLK * FreqMeas) / 2 ^ 10 / GAINSEL / 128 */ | 813 | /* FreqMeas_CLK = (BUS_CLK * FreqMeas) / 2 ^ 10 / GAINSEL / 128 */ |
| 808 | tmpval64 = (u64) busclk_freq * freqmeas; | 814 | tmpval64 = (u64) busclk_freq * freqmeas; |
| @@ -826,12 +832,12 @@ static int fsl_spdif_rxrate_get(struct snd_kcontrol *kcontrol, | |||
| 826 | { | 832 | { |
| 827 | struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); | 833 | struct snd_soc_dai *cpu_dai = snd_kcontrol_chip(kcontrol); |
| 828 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); | 834 | struct fsl_spdif_priv *spdif_priv = snd_soc_dai_get_drvdata(cpu_dai); |
| 829 | int rate = spdif_get_rxclk_rate(spdif_priv, SPDIF_DEFAULT_GAINSEL); | 835 | int rate = 0; |
| 830 | 836 | ||
| 831 | if (spdif_priv->dpll_locked) | 837 | if (spdif_priv->dpll_locked) |
| 832 | ucontrol->value.integer.value[0] = rate; | 838 | rate = spdif_get_rxclk_rate(spdif_priv, SPDIF_DEFAULT_GAINSEL); |
| 833 | else | 839 | |
| 834 | ucontrol->value.integer.value[0] = 0; | 840 | ucontrol->value.integer.value[0] = rate; |
| 835 | 841 | ||
| 836 | return 0; | 842 | return 0; |
| 837 | } | 843 | } |
| @@ -969,12 +975,14 @@ static int fsl_spdif_dai_probe(struct snd_soc_dai *dai) | |||
| 969 | static struct snd_soc_dai_driver fsl_spdif_dai = { | 975 | static struct snd_soc_dai_driver fsl_spdif_dai = { |
| 970 | .probe = &fsl_spdif_dai_probe, | 976 | .probe = &fsl_spdif_dai_probe, |
| 971 | .playback = { | 977 | .playback = { |
| 978 | .stream_name = "CPU-Playback", | ||
| 972 | .channels_min = 2, | 979 | .channels_min = 2, |
| 973 | .channels_max = 2, | 980 | .channels_max = 2, |
| 974 | .rates = FSL_SPDIF_RATES_PLAYBACK, | 981 | .rates = FSL_SPDIF_RATES_PLAYBACK, |
| 975 | .formats = FSL_SPDIF_FORMATS_PLAYBACK, | 982 | .formats = FSL_SPDIF_FORMATS_PLAYBACK, |
| 976 | }, | 983 | }, |
| 977 | .capture = { | 984 | .capture = { |
| 985 | .stream_name = "CPU-Capture", | ||
| 978 | .channels_min = 2, | 986 | .channels_min = 2, |
| 979 | .channels_max = 2, | 987 | .channels_max = 2, |
| 980 | .rates = FSL_SPDIF_RATES_CAPTURE, | 988 | .rates = FSL_SPDIF_RATES_CAPTURE, |
| @@ -1046,7 +1054,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, | |||
| 1046 | struct clk *clk, u64 savesub, | 1054 | struct clk *clk, u64 savesub, |
| 1047 | enum spdif_txrate index, bool round) | 1055 | enum spdif_txrate index, bool round) |
| 1048 | { | 1056 | { |
| 1049 | const u32 rate[] = { 32000, 44100, 48000 }; | 1057 | const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 }; |
| 1050 | bool is_sysclk = clk == spdif_priv->sysclk; | 1058 | bool is_sysclk = clk == spdif_priv->sysclk; |
| 1051 | u64 rate_ideal, rate_actual, sub; | 1059 | u64 rate_ideal, rate_actual, sub; |
| 1052 | u32 sysclk_dfmin, sysclk_dfmax; | 1060 | u32 sysclk_dfmin, sysclk_dfmax; |
| @@ -1105,7 +1113,7 @@ out: | |||
| 1105 | static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv, | 1113 | static int fsl_spdif_probe_txclk(struct fsl_spdif_priv *spdif_priv, |
| 1106 | enum spdif_txrate index) | 1114 | enum spdif_txrate index) |
| 1107 | { | 1115 | { |
| 1108 | const u32 rate[] = { 32000, 44100, 48000 }; | 1116 | const u32 rate[] = { 32000, 44100, 48000, 96000, 192000 }; |
| 1109 | struct platform_device *pdev = spdif_priv->pdev; | 1117 | struct platform_device *pdev = spdif_priv->pdev; |
| 1110 | struct device *dev = &pdev->dev; | 1118 | struct device *dev = &pdev->dev; |
| 1111 | u64 savesub = 100000, ret; | 1119 | u64 savesub = 100000, ret; |
| @@ -1238,12 +1246,12 @@ static int fsl_spdif_probe(struct platform_device *pdev) | |||
| 1238 | spin_lock_init(&ctrl->ctl_lock); | 1246 | spin_lock_init(&ctrl->ctl_lock); |
| 1239 | 1247 | ||
| 1240 | /* Init tx channel status default value */ | 1248 | /* Init tx channel status default value */ |
| 1241 | ctrl->ch_status[0] = | 1249 | ctrl->ch_status[0] = IEC958_AES0_CON_NOT_COPYRIGHT | |
| 1242 | IEC958_AES0_CON_NOT_COPYRIGHT | IEC958_AES0_CON_EMPHASIS_5015; | 1250 | IEC958_AES0_CON_EMPHASIS_5015; |
| 1243 | ctrl->ch_status[1] = IEC958_AES1_CON_DIGDIGCONV_ID; | 1251 | ctrl->ch_status[1] = IEC958_AES1_CON_DIGDIGCONV_ID; |
| 1244 | ctrl->ch_status[2] = 0x00; | 1252 | ctrl->ch_status[2] = 0x00; |
| 1245 | ctrl->ch_status[3] = | 1253 | ctrl->ch_status[3] = IEC958_AES3_CON_FS_44100 | |
| 1246 | IEC958_AES3_CON_FS_44100 | IEC958_AES3_CON_CLOCK_1000PPM; | 1254 | IEC958_AES3_CON_CLOCK_1000PPM; |
| 1247 | 1255 | ||
| 1248 | spdif_priv->dpll_locked = false; | 1256 | spdif_priv->dpll_locked = false; |
| 1249 | 1257 | ||
diff --git a/sound/soc/fsl/fsl_spdif.h b/sound/soc/fsl/fsl_spdif.h index 16fde4b927d3..00bd3514c610 100644 --- a/sound/soc/fsl/fsl_spdif.h +++ b/sound/soc/fsl/fsl_spdif.h | |||
| @@ -93,6 +93,8 @@ | |||
| 93 | #define SCR_USRC_SEL_RECV (0x1 << SCR_USRC_SEL_OFFSET) | 93 | #define SCR_USRC_SEL_RECV (0x1 << SCR_USRC_SEL_OFFSET) |
| 94 | #define SCR_USRC_SEL_CHIP (0x3 << SCR_USRC_SEL_OFFSET) | 94 | #define SCR_USRC_SEL_CHIP (0x3 << SCR_USRC_SEL_OFFSET) |
| 95 | 95 | ||
| 96 | #define SCR_DMA_xX_EN(tx) (tx ? SCR_DMA_TX_EN : SCR_DMA_RX_EN) | ||
| 97 | |||
| 96 | /* SPDIF CDText control */ | 98 | /* SPDIF CDText control */ |
| 97 | #define SRCD_CD_USER_OFFSET 1 | 99 | #define SRCD_CD_USER_OFFSET 1 |
| 98 | #define SRCD_CD_USER (1 << SRCD_CD_USER_OFFSET) | 100 | #define SRCD_CD_USER (1 << SRCD_CD_USER_OFFSET) |
| @@ -164,8 +166,10 @@ enum spdif_txrate { | |||
| 164 | SPDIF_TXRATE_32000 = 0, | 166 | SPDIF_TXRATE_32000 = 0, |
| 165 | SPDIF_TXRATE_44100, | 167 | SPDIF_TXRATE_44100, |
| 166 | SPDIF_TXRATE_48000, | 168 | SPDIF_TXRATE_48000, |
| 169 | SPDIF_TXRATE_96000, | ||
| 170 | SPDIF_TXRATE_192000, | ||
| 167 | }; | 171 | }; |
| 168 | #define SPDIF_TXRATE_MAX (SPDIF_TXRATE_48000 + 1) | 172 | #define SPDIF_TXRATE_MAX (SPDIF_TXRATE_192000 + 1) |
| 169 | 173 | ||
| 170 | 174 | ||
| 171 | #define SPDIF_CSTATUS_BYTE 6 | 175 | #define SPDIF_CSTATUS_BYTE 6 |
| @@ -175,7 +179,9 @@ enum spdif_txrate { | |||
| 175 | 179 | ||
| 176 | #define FSL_SPDIF_RATES_PLAYBACK (SNDRV_PCM_RATE_32000 | \ | 180 | #define FSL_SPDIF_RATES_PLAYBACK (SNDRV_PCM_RATE_32000 | \ |
| 177 | SNDRV_PCM_RATE_44100 | \ | 181 | SNDRV_PCM_RATE_44100 | \ |
| 178 | SNDRV_PCM_RATE_48000) | 182 | SNDRV_PCM_RATE_48000 | \ |
| 183 | SNDRV_PCM_RATE_96000 | \ | ||
| 184 | SNDRV_PCM_RATE_192000) | ||
| 179 | 185 | ||
| 180 | #define FSL_SPDIF_RATES_CAPTURE (SNDRV_PCM_RATE_16000 | \ | 186 | #define FSL_SPDIF_RATES_CAPTURE (SNDRV_PCM_RATE_16000 | \ |
| 181 | SNDRV_PCM_RATE_32000 | \ | 187 | SNDRV_PCM_RATE_32000 | \ |
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index 9bfef55d77d1..87eb5776a39b 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
| @@ -590,8 +590,8 @@ static int fsl_ssi_set_bclk(struct snd_pcm_substream *substream, | |||
| 590 | else | 590 | else |
| 591 | clkrate = clk_round_rate(ssi_private->baudclk, tmprate); | 591 | clkrate = clk_round_rate(ssi_private->baudclk, tmprate); |
| 592 | 592 | ||
| 593 | do_div(clkrate, factor); | 593 | clkrate /= factor; |
| 594 | afreq = (u32)clkrate / (i + 1); | 594 | afreq = clkrate / (i + 1); |
| 595 | 595 | ||
| 596 | if (freq == afreq) | 596 | if (freq == afreq) |
| 597 | sub = 0; | 597 | sub = 0; |
| @@ -1032,12 +1032,14 @@ static const struct snd_soc_dai_ops fsl_ssi_dai_ops = { | |||
| 1032 | static struct snd_soc_dai_driver fsl_ssi_dai_template = { | 1032 | static struct snd_soc_dai_driver fsl_ssi_dai_template = { |
| 1033 | .probe = fsl_ssi_dai_probe, | 1033 | .probe = fsl_ssi_dai_probe, |
| 1034 | .playback = { | 1034 | .playback = { |
| 1035 | .stream_name = "CPU-Playback", | ||
| 1035 | .channels_min = 1, | 1036 | .channels_min = 1, |
| 1036 | .channels_max = 2, | 1037 | .channels_max = 2, |
| 1037 | .rates = FSLSSI_I2S_RATES, | 1038 | .rates = FSLSSI_I2S_RATES, |
| 1038 | .formats = FSLSSI_I2S_FORMATS, | 1039 | .formats = FSLSSI_I2S_FORMATS, |
| 1039 | }, | 1040 | }, |
| 1040 | .capture = { | 1041 | .capture = { |
| 1042 | .stream_name = "CPU-Capture", | ||
| 1041 | .channels_min = 1, | 1043 | .channels_min = 1, |
| 1042 | .channels_max = 2, | 1044 | .channels_max = 2, |
| 1043 | .rates = FSLSSI_I2S_RATES, | 1045 | .rates = FSLSSI_I2S_RATES, |
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c index 267717aa96c1..46f9beb6b273 100644 --- a/sound/soc/fsl/imx-audmux.c +++ b/sound/soc/fsl/imx-audmux.c | |||
| @@ -67,7 +67,7 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, | |||
| 67 | { | 67 | { |
| 68 | ssize_t ret; | 68 | ssize_t ret; |
| 69 | char *buf; | 69 | char *buf; |
| 70 | int port = (int)file->private_data; | 70 | uintptr_t port = (uintptr_t)file->private_data; |
| 71 | u32 pdcr, ptcr; | 71 | u32 pdcr, ptcr; |
| 72 | 72 | ||
| 73 | if (audmux_clk) { | 73 | if (audmux_clk) { |
| @@ -147,7 +147,7 @@ static const struct file_operations audmux_debugfs_fops = { | |||
| 147 | 147 | ||
| 148 | static void audmux_debugfs_init(void) | 148 | static void audmux_debugfs_init(void) |
| 149 | { | 149 | { |
| 150 | int i; | 150 | uintptr_t i; |
| 151 | char buf[20]; | 151 | char buf[20]; |
| 152 | 152 | ||
| 153 | audmux_debugfs_root = debugfs_create_dir("audmux", NULL); | 153 | audmux_debugfs_root = debugfs_create_dir("audmux", NULL); |
| @@ -157,10 +157,10 @@ static void audmux_debugfs_init(void) | |||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | for (i = 0; i < MX31_AUDMUX_PORT7_SSI_PINS_7 + 1; i++) { | 159 | for (i = 0; i < MX31_AUDMUX_PORT7_SSI_PINS_7 + 1; i++) { |
| 160 | snprintf(buf, sizeof(buf), "ssi%d", i); | 160 | snprintf(buf, sizeof(buf), "ssi%lu", i); |
| 161 | if (!debugfs_create_file(buf, 0444, audmux_debugfs_root, | 161 | if (!debugfs_create_file(buf, 0444, audmux_debugfs_root, |
| 162 | (void *)i, &audmux_debugfs_fops)) | 162 | (void *)i, &audmux_debugfs_fops)) |
| 163 | pr_warning("Failed to create AUDMUX port %d debugfs file\n", | 163 | pr_warning("Failed to create AUDMUX port %lu debugfs file\n", |
| 164 | i); | 164 | i); |
| 165 | } | 165 | } |
| 166 | } | 166 | } |
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 0849b7b83f0a..0db94f492e97 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c | |||
| @@ -59,7 +59,6 @@ int imx_pcm_dma_init(struct platform_device *pdev) | |||
| 59 | { | 59 | { |
| 60 | return devm_snd_dmaengine_pcm_register(&pdev->dev, | 60 | return devm_snd_dmaengine_pcm_register(&pdev->dev, |
| 61 | &imx_dmaengine_pcm_config, | 61 | &imx_dmaengine_pcm_config, |
| 62 | SND_DMAENGINE_PCM_FLAG_NO_RESIDUE | | ||
| 63 | SND_DMAENGINE_PCM_FLAG_COMPAT); | 62 | SND_DMAENGINE_PCM_FLAG_COMPAT); |
| 64 | } | 63 | } |
| 65 | EXPORT_SYMBOL_GPL(imx_pcm_dma_init); | 64 | EXPORT_SYMBOL_GPL(imx_pcm_dma_init); |
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 03a7fdcdf114..159e517fa09a 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
| @@ -116,6 +116,7 @@ asoc_simple_card_sub_parse_of(struct device_node *np, | |||
| 116 | { | 116 | { |
| 117 | struct device_node *node; | 117 | struct device_node *node; |
| 118 | struct clk *clk; | 118 | struct clk *clk; |
| 119 | u32 val; | ||
| 119 | int ret; | 120 | int ret; |
| 120 | 121 | ||
| 121 | /* | 122 | /* |
| @@ -151,10 +152,8 @@ asoc_simple_card_sub_parse_of(struct device_node *np, | |||
| 151 | } | 152 | } |
| 152 | 153 | ||
| 153 | dai->sysclk = clk_get_rate(clk); | 154 | dai->sysclk = clk_get_rate(clk); |
| 154 | } else if (of_property_read_bool(np, "system-clock-frequency")) { | 155 | } else if (!of_property_read_u32(np, "system-clock-frequency", &val)) { |
| 155 | of_property_read_u32(np, | 156 | dai->sysclk = val; |
| 156 | "system-clock-frequency", | ||
| 157 | &dai->sysclk); | ||
| 158 | } else { | 157 | } else { |
| 159 | clk = of_clk_get(node, 0); | 158 | clk = of_clk_get(node, 0); |
| 160 | if (!IS_ERR(clk)) | 159 | if (!IS_ERR(clk)) |
| @@ -303,6 +302,7 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
| 303 | { | 302 | { |
| 304 | struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link; | 303 | struct snd_soc_dai_link *dai_link = priv->snd_card.dai_link; |
| 305 | struct simple_dai_props *dai_props = priv->dai_props; | 304 | struct simple_dai_props *dai_props = priv->dai_props; |
| 305 | u32 val; | ||
| 306 | int ret; | 306 | int ret; |
| 307 | 307 | ||
| 308 | /* parsing the card name from DT */ | 308 | /* parsing the card name from DT */ |
| @@ -325,8 +325,9 @@ static int asoc_simple_card_parse_of(struct device_node *node, | |||
| 325 | } | 325 | } |
| 326 | 326 | ||
| 327 | /* Factor to mclk, used in hw_params() */ | 327 | /* Factor to mclk, used in hw_params() */ |
| 328 | of_property_read_u32(node, "simple-audio-card,mclk-fs", | 328 | ret = of_property_read_u32(node, "simple-audio-card,mclk-fs", &val); |
| 329 | &priv->mclk_fs); | 329 | if (ret == 0) |
| 330 | priv->mclk_fs = val; | ||
| 330 | 331 | ||
| 331 | dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ? | 332 | dev_dbg(dev, "New simple-card: %s\n", priv->snd_card.name ? |
| 332 | priv->snd_card.name : ""); | 333 | priv->snd_card.name : ""); |
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig index c30fedb3e149..f5b4a9c79cdf 100644 --- a/sound/soc/intel/Kconfig +++ b/sound/soc/intel/Kconfig | |||
| @@ -58,3 +58,15 @@ config SND_SOC_INTEL_BYT_MAX98090_MACH | |||
| 58 | help | 58 | help |
| 59 | This adds audio driver for Intel Baytrail platform based boards | 59 | This adds audio driver for Intel Baytrail platform based boards |
| 60 | with the MAX98090 audio codec. | 60 | with the MAX98090 audio codec. |
| 61 | |||
| 62 | config SND_SOC_INTEL_BROADWELL_MACH | ||
| 63 | tristate "ASoC Audio DSP support for Intel Broadwell Wildcatpoint" | ||
| 64 | depends on SND_SOC_INTEL_SST && X86_INTEL_LPSS && DW_DMAC | ||
| 65 | select SND_SOC_INTEL_HASWELL | ||
| 66 | select SND_COMPRESS_OFFLOAD | ||
| 67 | select SND_SOC_RT286 | ||
| 68 | help | ||
| 69 | This adds support for the Wilcatpoint Audio DSP on Intel(R) Broadwell | ||
| 70 | Ultrabook platforms. | ||
| 71 | Say Y if you have such a device | ||
| 72 | If unsure select "N". | ||
diff --git a/sound/soc/intel/Makefile b/sound/soc/intel/Makefile index 4bfca79a42ba..7acbfc43a0c6 100644 --- a/sound/soc/intel/Makefile +++ b/sound/soc/intel/Makefile | |||
| @@ -24,7 +24,9 @@ obj-$(CONFIG_SND_SOC_INTEL_BAYTRAIL) += snd-soc-sst-baytrail-pcm.o | |||
| 24 | snd-soc-sst-haswell-objs := haswell.o | 24 | snd-soc-sst-haswell-objs := haswell.o |
| 25 | snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o | 25 | snd-soc-sst-byt-rt5640-mach-objs := byt-rt5640.o |
| 26 | snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o | 26 | snd-soc-sst-byt-max98090-mach-objs := byt-max98090.o |
| 27 | snd-soc-sst-broadwell-objs := broadwell.o | ||
| 27 | 28 | ||
| 28 | obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o | 29 | obj-$(CONFIG_SND_SOC_INTEL_HASWELL_MACH) += snd-soc-sst-haswell.o |
| 29 | obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o | 30 | obj-$(CONFIG_SND_SOC_INTEL_BYT_RT5640_MACH) += snd-soc-sst-byt-rt5640-mach.o |
| 30 | obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o | 31 | obj-$(CONFIG_SND_SOC_INTEL_BYT_MAX98090_MACH) += snd-soc-sst-byt-max98090-mach.o |
| 32 | obj-$(CONFIG_SND_SOC_INTEL_BROADWELL_MACH) += snd-soc-sst-broadwell.o | ||
diff --git a/sound/soc/intel/broadwell.c b/sound/soc/intel/broadwell.c new file mode 100644 index 000000000000..0e550f14028f --- /dev/null +++ b/sound/soc/intel/broadwell.c | |||
| @@ -0,0 +1,251 @@ | |||
| 1 | /* | ||
| 2 | * Intel Broadwell Wildcatpoint SST Audio | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013, Intel Corporation. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or | ||
| 7 | * modify it under the terms of the GNU General Public License version | ||
| 8 | * 2 as published by the Free Software Foundation. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include <linux/module.h> | ||
| 18 | #include <linux/platform_device.h> | ||
| 19 | #include <sound/core.h> | ||
| 20 | #include <sound/pcm.h> | ||
| 21 | #include <sound/soc.h> | ||
| 22 | #include <sound/pcm_params.h> | ||
| 23 | |||
| 24 | #include "sst-dsp.h" | ||
| 25 | #include "sst-haswell-ipc.h" | ||
| 26 | |||
| 27 | #include "../codecs/rt286.h" | ||
| 28 | |||
| 29 | static const struct snd_soc_dapm_widget broadwell_widgets[] = { | ||
| 30 | SND_SOC_DAPM_HP("Headphones", NULL), | ||
| 31 | SND_SOC_DAPM_SPK("Speaker", NULL), | ||
| 32 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | ||
| 33 | SND_SOC_DAPM_MIC("DMIC1", NULL), | ||
| 34 | SND_SOC_DAPM_MIC("DMIC2", NULL), | ||
| 35 | SND_SOC_DAPM_LINE("Line Jack", NULL), | ||
| 36 | }; | ||
| 37 | |||
| 38 | static const struct snd_soc_dapm_route broadwell_rt286_map[] = { | ||
| 39 | |||
| 40 | /* speaker */ | ||
| 41 | {"Speaker", NULL, "SPOR"}, | ||
| 42 | {"Speaker", NULL, "SPOL"}, | ||
| 43 | |||
| 44 | /* HP jack connectors - unknown if we have jack deteck */ | ||
| 45 | {"Headphones", NULL, "HPO Pin"}, | ||
| 46 | |||
| 47 | /* other jacks */ | ||
| 48 | {"MIC1", NULL, "Mic Jack"}, | ||
| 49 | {"LINE1", NULL, "Line Jack"}, | ||
| 50 | |||
| 51 | /* digital mics */ | ||
| 52 | {"DMIC1 Pin", NULL, "DMIC1"}, | ||
| 53 | {"DMIC2 Pin", NULL, "DMIC2"}, | ||
| 54 | |||
| 55 | /* CODEC BE connections */ | ||
| 56 | {"SSP0 CODEC IN", NULL, "AIF1 Capture"}, | ||
| 57 | {"AIF1 Playback", NULL, "SSP0 CODEC OUT"}, | ||
| 58 | }; | ||
| 59 | |||
| 60 | static int broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, | ||
| 61 | struct snd_pcm_hw_params *params) | ||
| 62 | { | ||
| 63 | struct snd_interval *rate = hw_param_interval(params, | ||
| 64 | SNDRV_PCM_HW_PARAM_RATE); | ||
| 65 | struct snd_interval *channels = hw_param_interval(params, | ||
| 66 | SNDRV_PCM_HW_PARAM_CHANNELS); | ||
| 67 | |||
| 68 | /* The ADSP will covert the FE rate to 48k, stereo */ | ||
| 69 | rate->min = rate->max = 48000; | ||
| 70 | channels->min = channels->max = 2; | ||
| 71 | |||
| 72 | /* set SSP0 to 16 bit */ | ||
| 73 | snd_mask_set(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - | ||
| 74 | SNDRV_PCM_HW_PARAM_FIRST_MASK], | ||
| 75 | SNDRV_PCM_FORMAT_S16_LE); | ||
| 76 | return 0; | ||
| 77 | } | ||
| 78 | |||
| 79 | static int broadwell_rt286_hw_params(struct snd_pcm_substream *substream, | ||
| 80 | struct snd_pcm_hw_params *params) | ||
| 81 | { | ||
| 82 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 83 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
| 84 | int ret; | ||
| 85 | |||
| 86 | ret = snd_soc_dai_set_sysclk(codec_dai, RT286_SCLK_S_PLL, 24000000, | ||
| 87 | SND_SOC_CLOCK_IN); | ||
| 88 | |||
| 89 | if (ret < 0) { | ||
| 90 | dev_err(rtd->dev, "can't set codec sysclk configuration\n"); | ||
| 91 | return ret; | ||
| 92 | } | ||
| 93 | |||
| 94 | return ret; | ||
| 95 | } | ||
| 96 | |||
| 97 | static struct snd_soc_ops broadwell_rt286_ops = { | ||
| 98 | .hw_params = broadwell_rt286_hw_params, | ||
| 99 | }; | ||
| 100 | |||
| 101 | static int broadwell_rtd_init(struct snd_soc_pcm_runtime *rtd) | ||
| 102 | { | ||
| 103 | struct snd_soc_codec *codec = rtd->codec; | ||
| 104 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
| 105 | struct sst_pdata *pdata = dev_get_platdata(rtd->platform->dev); | ||
| 106 | struct sst_hsw *broadwell = pdata->dsp; | ||
| 107 | int ret; | ||
| 108 | |||
| 109 | /* Set ADSP SSP port settings */ | ||
| 110 | ret = sst_hsw_device_set_config(broadwell, SST_HSW_DEVICE_SSP_0, | ||
| 111 | SST_HSW_DEVICE_MCLK_FREQ_24_MHZ, | ||
| 112 | SST_HSW_DEVICE_CLOCK_MASTER, 9); | ||
| 113 | if (ret < 0) { | ||
| 114 | dev_err(rtd->dev, "error: failed to set device config\n"); | ||
| 115 | return ret; | ||
| 116 | } | ||
| 117 | |||
| 118 | /* always connected - check HP for jack detect */ | ||
| 119 | snd_soc_dapm_enable_pin(dapm, "Headphones"); | ||
| 120 | snd_soc_dapm_enable_pin(dapm, "Speaker"); | ||
| 121 | snd_soc_dapm_enable_pin(dapm, "Mic Jack"); | ||
| 122 | snd_soc_dapm_enable_pin(dapm, "Line Jack"); | ||
| 123 | snd_soc_dapm_enable_pin(dapm, "DMIC1"); | ||
| 124 | snd_soc_dapm_enable_pin(dapm, "DMIC2"); | ||
| 125 | |||
| 126 | return 0; | ||
| 127 | } | ||
| 128 | |||
| 129 | /* broadwell digital audio interface glue - connects codec <--> CPU */ | ||
| 130 | static struct snd_soc_dai_link broadwell_rt286_dais[] = { | ||
| 131 | /* Front End DAI links */ | ||
| 132 | { | ||
| 133 | .name = "System PCM", | ||
| 134 | .stream_name = "System Playback", | ||
| 135 | .cpu_dai_name = "System Pin", | ||
| 136 | .platform_name = "haswell-pcm-audio", | ||
| 137 | .dynamic = 1, | ||
| 138 | .codec_name = "snd-soc-dummy", | ||
| 139 | .codec_dai_name = "snd-soc-dummy-dai", | ||
| 140 | .init = broadwell_rtd_init, | ||
| 141 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | ||
| 142 | .dpcm_playback = 1, | ||
| 143 | }, | ||
| 144 | { | ||
| 145 | .name = "Offload0", | ||
| 146 | .stream_name = "Offload0 Playback", | ||
| 147 | .cpu_dai_name = "Offload0 Pin", | ||
| 148 | .platform_name = "haswell-pcm-audio", | ||
| 149 | .dynamic = 1, | ||
| 150 | .codec_name = "snd-soc-dummy", | ||
| 151 | .codec_dai_name = "snd-soc-dummy-dai", | ||
| 152 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | ||
| 153 | .dpcm_playback = 1, | ||
| 154 | }, | ||
| 155 | { | ||
| 156 | .name = "Offload1", | ||
| 157 | .stream_name = "Offload1 Playback", | ||
| 158 | .cpu_dai_name = "Offload1 Pin", | ||
| 159 | .platform_name = "haswell-pcm-audio", | ||
| 160 | .dynamic = 1, | ||
| 161 | .codec_name = "snd-soc-dummy", | ||
| 162 | .codec_dai_name = "snd-soc-dummy-dai", | ||
| 163 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | ||
| 164 | .dpcm_playback = 1, | ||
| 165 | }, | ||
| 166 | { | ||
| 167 | .name = "Loopback PCM", | ||
| 168 | .stream_name = "Loopback", | ||
| 169 | .cpu_dai_name = "Loopback Pin", | ||
| 170 | .platform_name = "haswell-pcm-audio", | ||
| 171 | .dynamic = 0, | ||
| 172 | .codec_name = "snd-soc-dummy", | ||
| 173 | .codec_dai_name = "snd-soc-dummy-dai", | ||
| 174 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | ||
| 175 | .dpcm_capture = 1, | ||
| 176 | }, | ||
| 177 | { | ||
| 178 | .name = "Capture PCM", | ||
| 179 | .stream_name = "Capture", | ||
| 180 | .cpu_dai_name = "Capture Pin", | ||
| 181 | .platform_name = "haswell-pcm-audio", | ||
| 182 | .dynamic = 1, | ||
| 183 | .codec_name = "snd-soc-dummy", | ||
| 184 | .codec_dai_name = "snd-soc-dummy-dai", | ||
| 185 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | ||
| 186 | .dpcm_capture = 1, | ||
| 187 | }, | ||
| 188 | |||
| 189 | /* Back End DAI links */ | ||
| 190 | { | ||
| 191 | /* SSP0 - Codec */ | ||
| 192 | .name = "Codec", | ||
| 193 | .be_id = 0, | ||
| 194 | .cpu_dai_name = "snd-soc-dummy-dai", | ||
| 195 | .platform_name = "snd-soc-dummy", | ||
| 196 | .no_pcm = 1, | ||
| 197 | .codec_name = "i2c-INT343A:00", | ||
| 198 | .codec_dai_name = "rt286-aif1", | ||
| 199 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
| 200 | SND_SOC_DAIFMT_CBS_CFS, | ||
| 201 | .ignore_suspend = 1, | ||
| 202 | .ignore_pmdown_time = 1, | ||
| 203 | .be_hw_params_fixup = broadwell_ssp0_fixup, | ||
| 204 | .ops = &broadwell_rt286_ops, | ||
| 205 | .dpcm_playback = 1, | ||
| 206 | .dpcm_capture = 1, | ||
| 207 | }, | ||
| 208 | }; | ||
| 209 | |||
| 210 | /* broadwell audio machine driver for WPT + RT286S */ | ||
| 211 | static struct snd_soc_card broadwell_rt286 = { | ||
| 212 | .name = "broadwell-rt286", | ||
| 213 | .owner = THIS_MODULE, | ||
| 214 | .dai_link = broadwell_rt286_dais, | ||
| 215 | .num_links = ARRAY_SIZE(broadwell_rt286_dais), | ||
| 216 | .dapm_widgets = broadwell_widgets, | ||
| 217 | .num_dapm_widgets = ARRAY_SIZE(broadwell_widgets), | ||
| 218 | .dapm_routes = broadwell_rt286_map, | ||
| 219 | .num_dapm_routes = ARRAY_SIZE(broadwell_rt286_map), | ||
| 220 | .fully_routed = true, | ||
| 221 | }; | ||
| 222 | |||
| 223 | static int broadwell_audio_probe(struct platform_device *pdev) | ||
| 224 | { | ||
| 225 | broadwell_rt286.dev = &pdev->dev; | ||
| 226 | |||
| 227 | return snd_soc_register_card(&broadwell_rt286); | ||
| 228 | } | ||
| 229 | |||
| 230 | static int broadwell_audio_remove(struct platform_device *pdev) | ||
| 231 | { | ||
| 232 | snd_soc_unregister_card(&broadwell_rt286); | ||
| 233 | return 0; | ||
| 234 | } | ||
| 235 | |||
| 236 | static struct platform_driver broadwell_audio = { | ||
| 237 | .probe = broadwell_audio_probe, | ||
| 238 | .remove = broadwell_audio_remove, | ||
| 239 | .driver = { | ||
| 240 | .name = "broadwell-audio", | ||
| 241 | .owner = THIS_MODULE, | ||
| 242 | }, | ||
| 243 | }; | ||
| 244 | |||
| 245 | module_platform_driver(broadwell_audio) | ||
| 246 | |||
| 247 | /* Module information */ | ||
| 248 | MODULE_AUTHOR("Liam Girdwood, Xingchao Wang"); | ||
| 249 | MODULE_DESCRIPTION("Intel SST Audio for WPT/Broadwell"); | ||
| 250 | MODULE_LICENSE("GPL v2"); | ||
| 251 | MODULE_ALIAS("platform:broadwell-audio"); | ||
diff --git a/sound/soc/intel/byt-max98090.c b/sound/soc/intel/byt-max98090.c index 5fc98c64a3f4..b8b8af571ef1 100644 --- a/sound/soc/intel/byt-max98090.c +++ b/sound/soc/intel/byt-max98090.c | |||
| @@ -39,8 +39,7 @@ static const struct snd_soc_dapm_widget byt_max98090_widgets[] = { | |||
| 39 | 39 | ||
| 40 | static const struct snd_soc_dapm_route byt_max98090_audio_map[] = { | 40 | static const struct snd_soc_dapm_route byt_max98090_audio_map[] = { |
| 41 | {"IN34", NULL, "Headset Mic"}, | 41 | {"IN34", NULL, "Headset Mic"}, |
| 42 | {"IN34", NULL, "MICBIAS"}, | 42 | {"Headset Mic", NULL, "MICBIAS"}, |
| 43 | {"MICBIAS", NULL, "Headset Mic"}, | ||
| 44 | {"DMICL", NULL, "Int Mic"}, | 43 | {"DMICL", NULL, "Int Mic"}, |
| 45 | {"Headphone", NULL, "HPL"}, | 44 | {"Headphone", NULL, "HPL"}, |
| 46 | {"Headphone", NULL, "HPR"}, | 45 | {"Headphone", NULL, "HPR"}, |
| @@ -64,14 +63,6 @@ static struct snd_soc_jack_pin hs_jack_pins[] = { | |||
| 64 | .pin = "Headset Mic", | 63 | .pin = "Headset Mic", |
| 65 | .mask = SND_JACK_MICROPHONE, | 64 | .mask = SND_JACK_MICROPHONE, |
| 66 | }, | 65 | }, |
| 67 | { | ||
| 68 | .pin = "Ext Spk", | ||
| 69 | .mask = SND_JACK_LINEOUT, | ||
| 70 | }, | ||
| 71 | { | ||
| 72 | .pin = "Int Mic", | ||
| 73 | .mask = SND_JACK_LINEIN, | ||
| 74 | }, | ||
| 75 | }; | 66 | }; |
| 76 | 67 | ||
| 77 | static struct snd_soc_jack_gpio hs_jack_gpios[] = { | 68 | static struct snd_soc_jack_gpio hs_jack_gpios[] = { |
| @@ -84,7 +75,8 @@ static struct snd_soc_jack_gpio hs_jack_gpios[] = { | |||
| 84 | { | 75 | { |
| 85 | .name = "mic-gpio", | 76 | .name = "mic-gpio", |
| 86 | .idx = 1, | 77 | .idx = 1, |
| 87 | .report = SND_JACK_MICROPHONE | SND_JACK_LINEIN, | 78 | .invert = 1, |
| 79 | .report = SND_JACK_MICROPHONE, | ||
| 88 | .debounce_time = 200, | 80 | .debounce_time = 200, |
| 89 | }, | 81 | }, |
| 90 | }; | 82 | }; |
| @@ -108,7 +100,8 @@ static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) | |||
| 108 | } | 100 | } |
| 109 | 101 | ||
| 110 | /* Enable jack detection */ | 102 | /* Enable jack detection */ |
| 111 | ret = snd_soc_jack_new(codec, "Headphone", SND_JACK_HEADPHONE, jack); | 103 | ret = snd_soc_jack_new(codec, "Headset", |
| 104 | SND_JACK_LINEOUT | SND_JACK_HEADSET, jack); | ||
| 112 | if (ret) | 105 | if (ret) |
| 113 | return ret; | 106 | return ret; |
| 114 | 107 | ||
| @@ -117,13 +110,9 @@ static int byt_max98090_init(struct snd_soc_pcm_runtime *runtime) | |||
| 117 | if (ret) | 110 | if (ret) |
| 118 | return ret; | 111 | return ret; |
| 119 | 112 | ||
| 120 | ret = snd_soc_jack_add_gpiods(card->dev->parent, jack, | 113 | return snd_soc_jack_add_gpiods(card->dev->parent, jack, |
| 121 | ARRAY_SIZE(hs_jack_gpios), | 114 | ARRAY_SIZE(hs_jack_gpios), |
| 122 | hs_jack_gpios); | 115 | hs_jack_gpios); |
| 123 | if (ret) | ||
| 124 | return ret; | ||
| 125 | |||
| 126 | return max98090_mic_detect(codec, jack); | ||
| 127 | } | 116 | } |
| 128 | 117 | ||
| 129 | static struct snd_soc_dai_link byt_max98090_dais[] = { | 118 | static struct snd_soc_dai_link byt_max98090_dais[] = { |
diff --git a/sound/soc/intel/byt-rt5640.c b/sound/soc/intel/byt-rt5640.c index 53d160d39972..234a58de3c53 100644 --- a/sound/soc/intel/byt-rt5640.c +++ b/sound/soc/intel/byt-rt5640.c | |||
| @@ -34,6 +34,7 @@ static const struct snd_soc_dapm_widget byt_rt5640_widgets[] = { | |||
| 34 | }; | 34 | }; |
| 35 | 35 | ||
| 36 | static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = { | 36 | static const struct snd_soc_dapm_route byt_rt5640_audio_map[] = { |
| 37 | {"Headset Mic", NULL, "MICBIAS1"}, | ||
| 37 | {"IN2P", NULL, "Headset Mic"}, | 38 | {"IN2P", NULL, "Headset Mic"}, |
| 38 | {"IN2N", NULL, "Headset Mic"}, | 39 | {"IN2N", NULL, "Headset Mic"}, |
| 39 | {"DMIC1", NULL, "Internal Mic"}, | 40 | {"DMIC1", NULL, "Internal Mic"}, |
diff --git a/sound/soc/intel/sst-atom-controls.h b/sound/soc/intel/sst-atom-controls.h new file mode 100644 index 000000000000..14063ab8c7c5 --- /dev/null +++ b/sound/soc/intel/sst-atom-controls.h | |||
| @@ -0,0 +1,30 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2013-14 Intel Corp | ||
| 3 | * Author: Ramesh Babu <ramesh.babu.koul@intel.com> | ||
| 4 | * Omair M Abdullah <omair.m.abdullah@intel.com> | ||
| 5 | * Samreen Nilofer <samreen.nilofer@intel.com> | ||
| 6 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; version 2 of the License. | ||
| 11 | * | ||
| 12 | * This program is distributed in the hope that it will be useful, but | ||
| 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 15 | * General Public License for more details. | ||
| 16 | * | ||
| 17 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
| 18 | * | ||
| 19 | */ | ||
| 20 | |||
| 21 | #ifndef __SST_CONTROLS_V2_H__ | ||
| 22 | #define __SST_CONTROLS_V2_H__ | ||
| 23 | |||
| 24 | enum { | ||
| 25 | MERR_DPCM_AUDIO = 0, | ||
| 26 | MERR_DPCM_COMPR, | ||
| 27 | }; | ||
| 28 | |||
| 29 | |||
| 30 | #endif | ||
diff --git a/sound/soc/intel/sst-baytrail-ipc.c b/sound/soc/intel/sst-baytrail-ipc.c index d207b22ea330..67673a2c0f41 100644 --- a/sound/soc/intel/sst-baytrail-ipc.c +++ b/sound/soc/intel/sst-baytrail-ipc.c | |||
| @@ -122,6 +122,26 @@ struct sst_byt_tstamp { | |||
| 122 | u32 channel_peak[8]; | 122 | u32 channel_peak[8]; |
| 123 | } __packed; | 123 | } __packed; |
| 124 | 124 | ||
| 125 | struct sst_byt_fw_version { | ||
| 126 | u8 build; | ||
| 127 | u8 minor; | ||
| 128 | u8 major; | ||
| 129 | u8 type; | ||
| 130 | } __packed; | ||
| 131 | |||
| 132 | struct sst_byt_fw_build_info { | ||
| 133 | u8 date[16]; | ||
| 134 | u8 time[16]; | ||
| 135 | } __packed; | ||
| 136 | |||
| 137 | struct sst_byt_fw_init { | ||
| 138 | struct sst_byt_fw_version fw_version; | ||
| 139 | struct sst_byt_fw_build_info build_info; | ||
| 140 | u16 result; | ||
| 141 | u8 module_id; | ||
| 142 | u8 debug_info; | ||
| 143 | } __packed; | ||
| 144 | |||
| 125 | /* driver internal IPC message structure */ | 145 | /* driver internal IPC message structure */ |
| 126 | struct ipc_message { | 146 | struct ipc_message { |
| 127 | struct list_head list; | 147 | struct list_head list; |
| @@ -868,6 +888,7 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) | |||
| 868 | { | 888 | { |
| 869 | struct sst_byt *byt; | 889 | struct sst_byt *byt; |
| 870 | struct sst_fw *byt_sst_fw; | 890 | struct sst_fw *byt_sst_fw; |
| 891 | struct sst_byt_fw_init init; | ||
| 871 | int err; | 892 | int err; |
| 872 | 893 | ||
| 873 | dev_dbg(dev, "initialising Byt DSP IPC\n"); | 894 | dev_dbg(dev, "initialising Byt DSP IPC\n"); |
| @@ -929,6 +950,15 @@ int sst_byt_dsp_init(struct device *dev, struct sst_pdata *pdata) | |||
| 929 | goto boot_err; | 950 | goto boot_err; |
| 930 | } | 951 | } |
| 931 | 952 | ||
| 953 | /* show firmware information */ | ||
| 954 | sst_dsp_inbox_read(byt->dsp, &init, sizeof(init)); | ||
| 955 | dev_info(byt->dev, "FW version: %02x.%02x.%02x.%02x\n", | ||
| 956 | init.fw_version.major, init.fw_version.minor, | ||
| 957 | init.fw_version.build, init.fw_version.type); | ||
| 958 | dev_info(byt->dev, "Build type: %x\n", init.fw_version.type); | ||
| 959 | dev_info(byt->dev, "Build date: %s %s\n", | ||
| 960 | init.build_info.date, init.build_info.time); | ||
| 961 | |||
| 932 | pdata->dsp = byt; | 962 | pdata->dsp = byt; |
| 933 | byt->fw = byt_sst_fw; | 963 | byt->fw = byt_sst_fw; |
| 934 | 964 | ||
diff --git a/sound/soc/intel/sst-baytrail-pcm.c b/sound/soc/intel/sst-baytrail-pcm.c index 8eab97368ea7..599401c0c655 100644 --- a/sound/soc/intel/sst-baytrail-pcm.c +++ b/sound/soc/intel/sst-baytrail-pcm.c | |||
| @@ -32,7 +32,7 @@ static const struct snd_pcm_hardware sst_byt_pcm_hardware = { | |||
| 32 | SNDRV_PCM_INFO_PAUSE | | 32 | SNDRV_PCM_INFO_PAUSE | |
| 33 | SNDRV_PCM_INFO_RESUME, | 33 | SNDRV_PCM_INFO_RESUME, |
| 34 | .formats = SNDRV_PCM_FMTBIT_S16_LE | | 34 | .formats = SNDRV_PCM_FMTBIT_S16_LE | |
| 35 | SNDRV_PCM_FORMAT_S24_LE, | 35 | SNDRV_PCM_FMTBIT_S24_LE, |
| 36 | .period_bytes_min = 384, | 36 | .period_bytes_min = 384, |
| 37 | .period_bytes_max = 48000, | 37 | .period_bytes_max = 48000, |
| 38 | .periods_min = 2, | 38 | .periods_min = 2, |
diff --git a/sound/soc/intel/sst-dsp.c b/sound/soc/intel/sst-dsp.c index 0b715b20a2d7..cd23060a0d86 100644 --- a/sound/soc/intel/sst-dsp.c +++ b/sound/soc/intel/sst-dsp.c | |||
| @@ -224,19 +224,23 @@ EXPORT_SYMBOL_GPL(sst_dsp_shim_update_bits64); | |||
| 224 | 224 | ||
| 225 | void sst_dsp_dump(struct sst_dsp *sst) | 225 | void sst_dsp_dump(struct sst_dsp *sst) |
| 226 | { | 226 | { |
| 227 | sst->ops->dump(sst); | 227 | if (sst->ops->dump) |
| 228 | sst->ops->dump(sst); | ||
| 228 | } | 229 | } |
| 229 | EXPORT_SYMBOL_GPL(sst_dsp_dump); | 230 | EXPORT_SYMBOL_GPL(sst_dsp_dump); |
| 230 | 231 | ||
| 231 | void sst_dsp_reset(struct sst_dsp *sst) | 232 | void sst_dsp_reset(struct sst_dsp *sst) |
| 232 | { | 233 | { |
| 233 | sst->ops->reset(sst); | 234 | if (sst->ops->reset) |
| 235 | sst->ops->reset(sst); | ||
| 234 | } | 236 | } |
| 235 | EXPORT_SYMBOL_GPL(sst_dsp_reset); | 237 | EXPORT_SYMBOL_GPL(sst_dsp_reset); |
| 236 | 238 | ||
| 237 | int sst_dsp_boot(struct sst_dsp *sst) | 239 | int sst_dsp_boot(struct sst_dsp *sst) |
| 238 | { | 240 | { |
| 239 | sst->ops->boot(sst); | 241 | if (sst->ops->boot) |
| 242 | sst->ops->boot(sst); | ||
| 243 | |||
| 240 | return 0; | 244 | return 0; |
| 241 | } | 245 | } |
| 242 | EXPORT_SYMBOL_GPL(sst_dsp_boot); | 246 | EXPORT_SYMBOL_GPL(sst_dsp_boot); |
diff --git a/sound/soc/intel/sst-dsp.h b/sound/soc/intel/sst-dsp.h index e44423be66c4..3165dfa97408 100644 --- a/sound/soc/intel/sst-dsp.h +++ b/sound/soc/intel/sst-dsp.h | |||
| @@ -52,7 +52,11 @@ | |||
| 52 | #define SST_CLKCTL 0x78 | 52 | #define SST_CLKCTL 0x78 |
| 53 | #define SST_CSR2 0x80 | 53 | #define SST_CSR2 0x80 |
| 54 | #define SST_LTRC 0xE0 | 54 | #define SST_LTRC 0xE0 |
| 55 | #define SST_HDMC 0xE8 | 55 | #define SST_HMDC 0xE8 |
| 56 | |||
| 57 | #define SST_SHIM_BEGIN SST_CSR | ||
| 58 | #define SST_SHIM_END SST_HDMC | ||
| 59 | |||
| 56 | #define SST_DBGO 0xF0 | 60 | #define SST_DBGO 0xF0 |
| 57 | 61 | ||
| 58 | #define SST_SHIM_SIZE 0x100 | 62 | #define SST_SHIM_SIZE 0x100 |
| @@ -73,6 +77,8 @@ | |||
| 73 | #define SST_CSR_S0IOCS (0x1 << 21) | 77 | #define SST_CSR_S0IOCS (0x1 << 21) |
| 74 | #define SST_CSR_S1IOCS (0x1 << 23) | 78 | #define SST_CSR_S1IOCS (0x1 << 23) |
| 75 | #define SST_CSR_LPCS (0x1 << 31) | 79 | #define SST_CSR_LPCS (0x1 << 31) |
| 80 | #define SST_CSR_24MHZ_LPCS (SST_CSR_SBCS0 | SST_CSR_SBCS1 | SST_CSR_LPCS) | ||
| 81 | #define SST_CSR_24MHZ_NO_LPCS (SST_CSR_SBCS0 | SST_CSR_SBCS1) | ||
| 76 | #define SST_BYT_CSR_RST (0x1 << 0) | 82 | #define SST_BYT_CSR_RST (0x1 << 0) |
| 77 | #define SST_BYT_CSR_VECTOR_SEL (0x1 << 1) | 83 | #define SST_BYT_CSR_VECTOR_SEL (0x1 << 1) |
| 78 | #define SST_BYT_CSR_STALL (0x1 << 2) | 84 | #define SST_BYT_CSR_STALL (0x1 << 2) |
| @@ -92,6 +98,14 @@ | |||
| 92 | #define SST_IMRX_DONE (0x1 << 0) | 98 | #define SST_IMRX_DONE (0x1 << 0) |
| 93 | #define SST_BYT_IMRX_REQUEST (0x1 << 1) | 99 | #define SST_BYT_IMRX_REQUEST (0x1 << 1) |
| 94 | 100 | ||
| 101 | /* IMRD / IMD */ | ||
| 102 | #define SST_IMRD_DONE (0x1 << 0) | ||
| 103 | #define SST_IMRD_BUSY (0x1 << 1) | ||
| 104 | #define SST_IMRD_SSP0 (0x1 << 16) | ||
| 105 | #define SST_IMRD_DMAC0 (0x1 << 21) | ||
| 106 | #define SST_IMRD_DMAC1 (0x1 << 22) | ||
| 107 | #define SST_IMRD_DMAC (SST_IMRD_DMAC0 | SST_IMRD_DMAC1) | ||
| 108 | |||
| 95 | /* IPCX / IPCC */ | 109 | /* IPCX / IPCC */ |
| 96 | #define SST_IPCX_DONE (0x1 << 30) | 110 | #define SST_IPCX_DONE (0x1 << 30) |
| 97 | #define SST_IPCX_BUSY (0x1 << 31) | 111 | #define SST_IPCX_BUSY (0x1 << 31) |
| @@ -118,9 +132,21 @@ | |||
| 118 | /* LTRC */ | 132 | /* LTRC */ |
| 119 | #define SST_LTRC_VAL(x) (x << 0) | 133 | #define SST_LTRC_VAL(x) (x << 0) |
| 120 | 134 | ||
| 121 | /* HDMC */ | 135 | /* HMDC */ |
| 122 | #define SST_HDMC_HDDA0(x) (x << 0) | 136 | #define SST_HMDC_HDDA0(x) (x << 0) |
| 123 | #define SST_HDMC_HDDA1(x) (x << 7) | 137 | #define SST_HMDC_HDDA1(x) (x << 7) |
| 138 | #define SST_HMDC_HDDA_E0_CH0 1 | ||
| 139 | #define SST_HMDC_HDDA_E0_CH1 2 | ||
| 140 | #define SST_HMDC_HDDA_E0_CH2 4 | ||
| 141 | #define SST_HMDC_HDDA_E0_CH3 8 | ||
| 142 | #define SST_HMDC_HDDA_E1_CH0 SST_HMDC_HDDA1(SST_HMDC_HDDA_E0_CH0) | ||
| 143 | #define SST_HMDC_HDDA_E1_CH1 SST_HMDC_HDDA1(SST_HMDC_HDDA_E0_CH1) | ||
| 144 | #define SST_HMDC_HDDA_E1_CH2 SST_HMDC_HDDA1(SST_HMDC_HDDA_E0_CH2) | ||
| 145 | #define SST_HMDC_HDDA_E1_CH3 SST_HMDC_HDDA1(SST_HMDC_HDDA_E0_CH3) | ||
| 146 | #define SST_HMDC_HDDA_E0_ALLCH (SST_HMDC_HDDA_E0_CH0 | SST_HMDC_HDDA_E0_CH1 | \ | ||
| 147 | SST_HMDC_HDDA_E0_CH2 | SST_HMDC_HDDA_E0_CH3) | ||
| 148 | #define SST_HMDC_HDDA_E1_ALLCH (SST_HMDC_HDDA_E1_CH0 | SST_HMDC_HDDA_E1_CH1 | \ | ||
| 149 | SST_HMDC_HDDA_E1_CH2 | SST_HMDC_HDDA_E1_CH3) | ||
| 124 | 150 | ||
| 125 | 151 | ||
| 126 | /* SST Vendor Defined Registers and bits */ | 152 | /* SST Vendor Defined Registers and bits */ |
| @@ -130,11 +156,16 @@ | |||
| 130 | #define SST_VDRTCTL3 0xaC | 156 | #define SST_VDRTCTL3 0xaC |
| 131 | 157 | ||
| 132 | /* VDRTCTL0 */ | 158 | /* VDRTCTL0 */ |
| 159 | #define SST_VDRTCL0_APLLSE_MASK 1 | ||
| 133 | #define SST_VDRTCL0_DSRAMPGE_SHIFT 16 | 160 | #define SST_VDRTCL0_DSRAMPGE_SHIFT 16 |
| 134 | #define SST_VDRTCL0_DSRAMPGE_MASK (0xffff << SST_VDRTCL0_DSRAMPGE_SHIFT) | 161 | #define SST_VDRTCL0_DSRAMPGE_MASK (0xffff << SST_VDRTCL0_DSRAMPGE_SHIFT) |
| 135 | #define SST_VDRTCL0_ISRAMPGE_SHIFT 6 | 162 | #define SST_VDRTCL0_ISRAMPGE_SHIFT 6 |
| 136 | #define SST_VDRTCL0_ISRAMPGE_MASK (0x3ff << SST_VDRTCL0_ISRAMPGE_SHIFT) | 163 | #define SST_VDRTCL0_ISRAMPGE_MASK (0x3ff << SST_VDRTCL0_ISRAMPGE_SHIFT) |
| 137 | 164 | ||
| 165 | /* PMCS */ | ||
| 166 | #define SST_PMCS 0x84 | ||
| 167 | #define SST_PMCS_PS_MASK 0x3 | ||
| 168 | |||
| 138 | struct sst_dsp; | 169 | struct sst_dsp; |
| 139 | 170 | ||
| 140 | /* | 171 | /* |
diff --git a/sound/soc/intel/sst-haswell-dsp.c b/sound/soc/intel/sst-haswell-dsp.c index 535f517629fd..4b6c163c10ff 100644 --- a/sound/soc/intel/sst-haswell-dsp.c +++ b/sound/soc/intel/sst-haswell-dsp.c | |||
| @@ -28,9 +28,6 @@ | |||
| 28 | #include <linux/firmware.h> | 28 | #include <linux/firmware.h> |
| 29 | #include <linux/pm_runtime.h> | 29 | #include <linux/pm_runtime.h> |
| 30 | 30 | ||
| 31 | #include <linux/acpi.h> | ||
| 32 | #include <acpi/acpi_bus.h> | ||
| 33 | |||
| 34 | #include "sst-dsp.h" | 31 | #include "sst-dsp.h" |
| 35 | #include "sst-dsp-priv.h" | 32 | #include "sst-dsp-priv.h" |
| 36 | #include "sst-haswell-ipc.h" | 33 | #include "sst-haswell-ipc.h" |
| @@ -272,9 +269,9 @@ static void hsw_boot(struct sst_dsp *sst) | |||
| 272 | SST_CSR2_SDFD_SSP1); | 269 | SST_CSR2_SDFD_SSP1); |
| 273 | 270 | ||
| 274 | /* enable DMA engine 0,1 all channels to access host memory */ | 271 | /* enable DMA engine 0,1 all channels to access host memory */ |
| 275 | sst_dsp_shim_update_bits_unlocked(sst, SST_HDMC, | 272 | sst_dsp_shim_update_bits_unlocked(sst, SST_HMDC, |
| 276 | SST_HDMC_HDDA1(0xff) | SST_HDMC_HDDA0(0xff), | 273 | SST_HMDC_HDDA1(0xff) | SST_HMDC_HDDA0(0xff), |
| 277 | SST_HDMC_HDDA1(0xff) | SST_HDMC_HDDA0(0xff)); | 274 | SST_HMDC_HDDA1(0xff) | SST_HMDC_HDDA0(0xff)); |
| 278 | 275 | ||
| 279 | /* disable all clock gating */ | 276 | /* disable all clock gating */ |
| 280 | writel(0x0, sst->addr.pci_cfg + SST_VDRTCTL2); | 277 | writel(0x0, sst->addr.pci_cfg + SST_VDRTCTL2); |
| @@ -313,9 +310,7 @@ static const struct sst_adsp_memregion lp_region[] = { | |||
| 313 | 310 | ||
| 314 | /* wild cat point ADSP mem regions */ | 311 | /* wild cat point ADSP mem regions */ |
| 315 | static const struct sst_adsp_memregion wpt_region[] = { | 312 | static const struct sst_adsp_memregion wpt_region[] = { |
| 316 | {0x00000, 0x40000, 8, SST_MEM_DRAM}, /* D-SRAM0 - 8 * 32kB */ | 313 | {0x00000, 0xA0000, 20, SST_MEM_DRAM}, /* D-SRAM0,D-SRAM1,D-SRAM2 - 20 * 32kB */ |
| 317 | {0x40000, 0x80000, 8, SST_MEM_DRAM}, /* D-SRAM1 - 8 * 32kB */ | ||
| 318 | {0x80000, 0xA0000, 4, SST_MEM_DRAM}, /* D-SRAM2 - 4 * 32kB */ | ||
| 319 | {0xA0000, 0xF0000, 10, SST_MEM_IRAM}, /* I-SRAM - 10 * 32kB */ | 314 | {0xA0000, 0xF0000, 10, SST_MEM_IRAM}, /* I-SRAM - 10 * 32kB */ |
| 320 | }; | 315 | }; |
| 321 | 316 | ||
| @@ -339,26 +334,56 @@ static int hsw_acpi_resource_map(struct sst_dsp *sst, struct sst_pdata *pdata) | |||
| 339 | return 0; | 334 | return 0; |
| 340 | } | 335 | } |
| 341 | 336 | ||
| 337 | struct sst_sram_shift { | ||
| 338 | u32 dev_id; /* SST Device IDs */ | ||
| 339 | u32 iram_shift; | ||
| 340 | u32 dram_shift; | ||
| 341 | }; | ||
| 342 | |||
| 343 | static const struct sst_sram_shift sram_shift[] = { | ||
| 344 | {SST_DEV_ID_LYNX_POINT, 6, 16}, /* lp */ | ||
| 345 | {SST_DEV_ID_WILDCAT_POINT, 2, 12}, /* wpt */ | ||
| 346 | }; | ||
| 342 | static u32 hsw_block_get_bit(struct sst_mem_block *block) | 347 | static u32 hsw_block_get_bit(struct sst_mem_block *block) |
| 343 | { | 348 | { |
| 344 | u32 bit = 0, shift = 0; | 349 | u32 bit = 0, shift = 0, index; |
| 350 | struct sst_dsp *sst = block->dsp; | ||
| 345 | 351 | ||
| 346 | switch (block->type) { | 352 | for (index = 0; index < ARRAY_SIZE(sram_shift); index++) { |
| 347 | case SST_MEM_DRAM: | 353 | if (sram_shift[index].dev_id == sst->id) |
| 348 | shift = 16; | 354 | break; |
| 349 | break; | ||
| 350 | case SST_MEM_IRAM: | ||
| 351 | shift = 6; | ||
| 352 | break; | ||
| 353 | default: | ||
| 354 | return 0; | ||
| 355 | } | 355 | } |
| 356 | 356 | ||
| 357 | if (index < ARRAY_SIZE(sram_shift)) { | ||
| 358 | switch (block->type) { | ||
| 359 | case SST_MEM_DRAM: | ||
| 360 | shift = sram_shift[index].dram_shift; | ||
| 361 | break; | ||
| 362 | case SST_MEM_IRAM: | ||
| 363 | shift = sram_shift[index].iram_shift; | ||
| 364 | break; | ||
| 365 | default: | ||
| 366 | shift = 0; | ||
| 367 | } | ||
| 368 | } else | ||
| 369 | shift = 0; | ||
| 370 | |||
| 357 | bit = 1 << (block->index + shift); | 371 | bit = 1 << (block->index + shift); |
| 358 | 372 | ||
| 359 | return bit; | 373 | return bit; |
| 360 | } | 374 | } |
| 361 | 375 | ||
| 376 | /*dummy read a SRAM block.*/ | ||
| 377 | static void sst_mem_block_dummy_read(struct sst_mem_block *block) | ||
| 378 | { | ||
| 379 | u32 size; | ||
| 380 | u8 tmp_buf[4]; | ||
| 381 | struct sst_dsp *sst = block->dsp; | ||
| 382 | |||
| 383 | size = block->size > 4 ? 4 : block->size; | ||
| 384 | memcpy_fromio(tmp_buf, sst->addr.lpe + block->offset, size); | ||
| 385 | } | ||
| 386 | |||
| 362 | /* enable 32kB memory block - locks held by caller */ | 387 | /* enable 32kB memory block - locks held by caller */ |
| 363 | static int hsw_block_enable(struct sst_mem_block *block) | 388 | static int hsw_block_enable(struct sst_mem_block *block) |
| 364 | { | 389 | { |
| @@ -378,6 +403,8 @@ static int hsw_block_enable(struct sst_mem_block *block) | |||
| 378 | /* wait 18 DSP clock ticks */ | 403 | /* wait 18 DSP clock ticks */ |
| 379 | udelay(10); | 404 | udelay(10); |
| 380 | 405 | ||
| 406 | /*add a dummy read before the SRAM block is written, otherwise the writing may miss bytes sometimes.*/ | ||
| 407 | sst_mem_block_dummy_read(block); | ||
| 381 | return 0; | 408 | return 0; |
| 382 | } | 409 | } |
| 383 | 410 | ||
| @@ -488,8 +515,9 @@ static int hsw_init(struct sst_dsp *sst, struct sst_pdata *pdata) | |||
| 488 | } | 515 | } |
| 489 | } | 516 | } |
| 490 | 517 | ||
| 491 | /* set default power gating mask */ | 518 | /* set default power gating control, enable power gating control for all blocks. that is, |
| 492 | writel(0x0, sst->addr.pci_cfg + SST_VDRTCTL0); | 519 | can't be accessed, please enable each block before accessing. */ |
| 520 | writel(0xffffffff, sst->addr.pci_cfg + SST_VDRTCTL0); | ||
| 493 | 521 | ||
| 494 | return 0; | 522 | return 0; |
| 495 | } | 523 | } |
diff --git a/sound/soc/intel/sst-haswell-ipc.c b/sound/soc/intel/sst-haswell-ipc.c index 434236343ddf..b6291516dbbf 100644 --- a/sound/soc/intel/sst-haswell-ipc.c +++ b/sound/soc/intel/sst-haswell-ipc.c | |||
| @@ -183,7 +183,7 @@ struct sst_hsw_ipc_fw_ready { | |||
| 183 | u32 inbox_size; | 183 | u32 inbox_size; |
| 184 | u32 outbox_size; | 184 | u32 outbox_size; |
| 185 | u32 fw_info_size; | 185 | u32 fw_info_size; |
| 186 | u8 fw_info[1]; | 186 | u8 fw_info[IPC_MAX_MAILBOX_BYTES - 5 * sizeof(u32)]; |
| 187 | } __attribute__((packed)); | 187 | } __attribute__((packed)); |
| 188 | 188 | ||
| 189 | struct ipc_message { | 189 | struct ipc_message { |
| @@ -457,9 +457,10 @@ static void ipc_tx_msgs(struct kthread_work *work) | |||
| 457 | return; | 457 | return; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | /* if the DSP is busy we will TX messages after IRQ */ | 460 | /* if the DSP is busy, we will TX messages after IRQ. |
| 461 | * also postpone if we are in the middle of procesing completion irq*/ | ||
| 461 | ipcx = sst_dsp_shim_read_unlocked(hsw->dsp, SST_IPCX); | 462 | ipcx = sst_dsp_shim_read_unlocked(hsw->dsp, SST_IPCX); |
| 462 | if (ipcx & SST_IPCX_BUSY) { | 463 | if (ipcx & (SST_IPCX_BUSY | SST_IPCX_DONE)) { |
| 463 | spin_unlock_irqrestore(&hsw->dsp->spinlock, flags); | 464 | spin_unlock_irqrestore(&hsw->dsp->spinlock, flags); |
| 464 | return; | 465 | return; |
| 465 | } | 466 | } |
| @@ -502,6 +503,7 @@ static int tx_wait_done(struct sst_hsw *hsw, struct ipc_message *msg, | |||
| 502 | ipc_shim_dbg(hsw, "message timeout"); | 503 | ipc_shim_dbg(hsw, "message timeout"); |
| 503 | 504 | ||
| 504 | trace_ipc_error("error message timeout for", msg->header); | 505 | trace_ipc_error("error message timeout for", msg->header); |
| 506 | list_del(&msg->list); | ||
| 505 | ret = -ETIMEDOUT; | 507 | ret = -ETIMEDOUT; |
| 506 | } else { | 508 | } else { |
| 507 | 509 | ||
| @@ -569,6 +571,9 @@ static void hsw_fw_ready(struct sst_hsw *hsw, u32 header) | |||
| 569 | { | 571 | { |
| 570 | struct sst_hsw_ipc_fw_ready fw_ready; | 572 | struct sst_hsw_ipc_fw_ready fw_ready; |
| 571 | u32 offset; | 573 | u32 offset; |
| 574 | u8 fw_info[IPC_MAX_MAILBOX_BYTES - 5 * sizeof(u32)]; | ||
| 575 | char *tmp[5], *pinfo; | ||
| 576 | int i = 0; | ||
| 572 | 577 | ||
| 573 | offset = (header & 0x1FFFFFFF) << 3; | 578 | offset = (header & 0x1FFFFFFF) << 3; |
| 574 | 579 | ||
| @@ -589,6 +594,19 @@ static void hsw_fw_ready(struct sst_hsw *hsw, u32 header) | |||
| 589 | fw_ready.inbox_offset, fw_ready.inbox_size); | 594 | fw_ready.inbox_offset, fw_ready.inbox_size); |
| 590 | dev_dbg(hsw->dev, " mailbox downstream 0x%x - size 0x%x\n", | 595 | dev_dbg(hsw->dev, " mailbox downstream 0x%x - size 0x%x\n", |
| 591 | fw_ready.outbox_offset, fw_ready.outbox_size); | 596 | fw_ready.outbox_offset, fw_ready.outbox_size); |
| 597 | if (fw_ready.fw_info_size < sizeof(fw_ready.fw_info)) { | ||
| 598 | fw_ready.fw_info[fw_ready.fw_info_size] = 0; | ||
| 599 | dev_dbg(hsw->dev, " Firmware info: %s \n", fw_ready.fw_info); | ||
| 600 | |||
| 601 | /* log the FW version info got from the mailbox here. */ | ||
| 602 | memcpy(fw_info, fw_ready.fw_info, fw_ready.fw_info_size); | ||
| 603 | pinfo = &fw_info[0]; | ||
| 604 | for (i = 0; i < sizeof(tmp) / sizeof(char *); i++) | ||
| 605 | tmp[i] = strsep(&pinfo, " "); | ||
| 606 | dev_info(hsw->dev, "FW loaded, mailbox readback FW info: type %s, - " | ||
| 607 | "version: %s.%s, build %s, source commit id: %s\n", | ||
| 608 | tmp[0], tmp[1], tmp[2], tmp[3], tmp[4]); | ||
| 609 | } | ||
| 592 | } | 610 | } |
| 593 | 611 | ||
| 594 | static void hsw_notification_work(struct work_struct *work) | 612 | static void hsw_notification_work(struct work_struct *work) |
| @@ -671,7 +689,9 @@ static void hsw_stream_update(struct sst_hsw *hsw, struct ipc_message *msg) | |||
| 671 | switch (stream_msg) { | 689 | switch (stream_msg) { |
| 672 | case IPC_STR_STAGE_MESSAGE: | 690 | case IPC_STR_STAGE_MESSAGE: |
| 673 | case IPC_STR_NOTIFICATION: | 691 | case IPC_STR_NOTIFICATION: |
| 692 | break; | ||
| 674 | case IPC_STR_RESET: | 693 | case IPC_STR_RESET: |
| 694 | trace_ipc_notification("stream reset", stream->reply.stream_hw_id); | ||
| 675 | break; | 695 | break; |
| 676 | case IPC_STR_PAUSE: | 696 | case IPC_STR_PAUSE: |
| 677 | stream->running = false; | 697 | stream->running = false; |
| @@ -762,7 +782,8 @@ static int hsw_process_reply(struct sst_hsw *hsw, u32 header) | |||
| 762 | } | 782 | } |
| 763 | 783 | ||
| 764 | /* update any stream states */ | 784 | /* update any stream states */ |
| 765 | hsw_stream_update(hsw, msg); | 785 | if (msg_get_global_type(header) == IPC_GLB_STREAM_MESSAGE) |
| 786 | hsw_stream_update(hsw, msg); | ||
| 766 | 787 | ||
| 767 | /* wake up and return the error if we have waiters on this message ? */ | 788 | /* wake up and return the error if we have waiters on this message ? */ |
| 768 | list_del(&msg->list); | 789 | list_del(&msg->list); |
| @@ -1628,7 +1649,7 @@ int sst_hsw_dx_set_state(struct sst_hsw *hsw, | |||
| 1628 | enum sst_hsw_dx_state state, struct sst_hsw_ipc_dx_reply *dx) | 1649 | enum sst_hsw_dx_state state, struct sst_hsw_ipc_dx_reply *dx) |
| 1629 | { | 1650 | { |
| 1630 | u32 header, state_; | 1651 | u32 header, state_; |
| 1631 | int ret; | 1652 | int ret, item; |
| 1632 | 1653 | ||
| 1633 | header = IPC_GLB_TYPE(IPC_GLB_ENTER_DX_STATE); | 1654 | header = IPC_GLB_TYPE(IPC_GLB_ENTER_DX_STATE); |
| 1634 | state_ = state; | 1655 | state_ = state; |
| @@ -1642,6 +1663,13 @@ int sst_hsw_dx_set_state(struct sst_hsw *hsw, | |||
| 1642 | return ret; | 1663 | return ret; |
| 1643 | } | 1664 | } |
| 1644 | 1665 | ||
| 1666 | for (item = 0; item < dx->entries_no; item++) { | ||
| 1667 | dev_dbg(hsw->dev, | ||
| 1668 | "Item[%d] offset[%x] - size[%x] - source[%x]\n", | ||
| 1669 | item, dx->mem_info[item].offset, | ||
| 1670 | dx->mem_info[item].size, | ||
| 1671 | dx->mem_info[item].source); | ||
| 1672 | } | ||
| 1645 | dev_dbg(hsw->dev, "ipc: got %d entry numbers for state %d\n", | 1673 | dev_dbg(hsw->dev, "ipc: got %d entry numbers for state %d\n", |
| 1646 | dx->entries_no, state); | 1674 | dx->entries_no, state); |
| 1647 | 1675 | ||
| @@ -1775,8 +1803,6 @@ int sst_hsw_dsp_init(struct device *dev, struct sst_pdata *pdata) | |||
| 1775 | 1803 | ||
| 1776 | /* get the FW version */ | 1804 | /* get the FW version */ |
| 1777 | sst_hsw_fw_get_version(hsw, &version); | 1805 | sst_hsw_fw_get_version(hsw, &version); |
| 1778 | dev_info(hsw->dev, "FW loaded: type %d - version: %d.%d build %d\n", | ||
| 1779 | version.type, version.major, version.minor, version.build); | ||
| 1780 | 1806 | ||
| 1781 | /* get the globalmixer */ | 1807 | /* get the globalmixer */ |
| 1782 | ret = sst_hsw_mixer_get_info(hsw); | 1808 | ret = sst_hsw_mixer_get_info(hsw); |
diff --git a/sound/soc/intel/sst-haswell-pcm.c b/sound/soc/intel/sst-haswell-pcm.c index 058efb17c568..61bf6da4bb02 100644 --- a/sound/soc/intel/sst-haswell-pcm.c +++ b/sound/soc/intel/sst-haswell-pcm.c | |||
| @@ -80,7 +80,7 @@ static const struct snd_pcm_hardware hsw_pcm_hardware = { | |||
| 80 | SNDRV_PCM_INFO_PAUSE | | 80 | SNDRV_PCM_INFO_PAUSE | |
| 81 | SNDRV_PCM_INFO_RESUME | | 81 | SNDRV_PCM_INFO_RESUME | |
| 82 | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, | 82 | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, |
| 83 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FORMAT_S24_LE | | 83 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | |
| 84 | SNDRV_PCM_FMTBIT_S32_LE, | 84 | SNDRV_PCM_FMTBIT_S32_LE, |
| 85 | .period_bytes_min = PAGE_SIZE, | 85 | .period_bytes_min = PAGE_SIZE, |
| 86 | .period_bytes_max = (HSW_PCM_PERIODS_MAX / HSW_PCM_PERIODS_MIN) * PAGE_SIZE, | 86 | .period_bytes_max = (HSW_PCM_PERIODS_MAX / HSW_PCM_PERIODS_MIN) * PAGE_SIZE, |
| @@ -400,7 +400,15 @@ static int hsw_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 400 | sst_hsw_stream_set_valid(hsw, pcm_data->stream, 16); | 400 | sst_hsw_stream_set_valid(hsw, pcm_data->stream, 16); |
| 401 | break; | 401 | break; |
| 402 | case SNDRV_PCM_FORMAT_S24_LE: | 402 | case SNDRV_PCM_FORMAT_S24_LE: |
| 403 | bits = SST_HSW_DEPTH_24BIT; | 403 | bits = SST_HSW_DEPTH_32BIT; |
| 404 | sst_hsw_stream_set_valid(hsw, pcm_data->stream, 24); | ||
| 405 | break; | ||
| 406 | case SNDRV_PCM_FORMAT_S8: | ||
| 407 | bits = SST_HSW_DEPTH_8BIT; | ||
| 408 | sst_hsw_stream_set_valid(hsw, pcm_data->stream, 8); | ||
| 409 | break; | ||
| 410 | case SNDRV_PCM_FORMAT_S32_LE: | ||
| 411 | bits = SST_HSW_DEPTH_32BIT; | ||
| 404 | sst_hsw_stream_set_valid(hsw, pcm_data->stream, 32); | 412 | sst_hsw_stream_set_valid(hsw, pcm_data->stream, 32); |
| 405 | break; | 413 | break; |
| 406 | default: | 414 | default: |
| @@ -685,8 +693,9 @@ static int hsw_pcm_new(struct snd_soc_pcm_runtime *rtd) | |||
| 685 | } | 693 | } |
| 686 | 694 | ||
| 687 | #define HSW_FORMATS \ | 695 | #define HSW_FORMATS \ |
| 688 | (SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S16_LE |\ | 696 | (SNDRV_PCM_FMTBIT_S32_LE | SNDRV_PCM_FMTBIT_S24_LE | \ |
| 689 | SNDRV_PCM_FMTBIT_S32_LE) | 697 | SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S16_LE |\ |
| 698 | SNDRV_PCM_FMTBIT_S8) | ||
| 690 | 699 | ||
| 691 | static struct snd_soc_dai_driver hsw_dais[] = { | 700 | static struct snd_soc_dai_driver hsw_dais[] = { |
| 692 | { | 701 | { |
| @@ -696,7 +705,7 @@ static struct snd_soc_dai_driver hsw_dais[] = { | |||
| 696 | .channels_min = 2, | 705 | .channels_min = 2, |
| 697 | .channels_max = 2, | 706 | .channels_max = 2, |
| 698 | .rates = SNDRV_PCM_RATE_48000, | 707 | .rates = SNDRV_PCM_RATE_48000, |
| 699 | .formats = SNDRV_PCM_FMTBIT_S16_LE, | 708 | .formats = SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE, |
| 700 | }, | 709 | }, |
| 701 | }, | 710 | }, |
| 702 | { | 711 | { |
| @@ -727,8 +736,8 @@ static struct snd_soc_dai_driver hsw_dais[] = { | |||
| 727 | .stream_name = "Loopback Capture", | 736 | .stream_name = "Loopback Capture", |
| 728 | .channels_min = 2, | 737 | .channels_min = 2, |
| 729 | .channels_max = 2, | 738 | .channels_max = 2, |
| 730 | .rates = SNDRV_PCM_RATE_8000_192000, | 739 | .rates = SNDRV_PCM_RATE_48000, |
| 731 | .formats = HSW_FORMATS, | 740 | .formats = SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE, |
| 732 | }, | 741 | }, |
| 733 | }, | 742 | }, |
| 734 | { | 743 | { |
| @@ -737,8 +746,8 @@ static struct snd_soc_dai_driver hsw_dais[] = { | |||
| 737 | .stream_name = "Analog Capture", | 746 | .stream_name = "Analog Capture", |
| 738 | .channels_min = 2, | 747 | .channels_min = 2, |
| 739 | .channels_max = 2, | 748 | .channels_max = 2, |
| 740 | .rates = SNDRV_PCM_RATE_8000_192000, | 749 | .rates = SNDRV_PCM_RATE_48000, |
| 741 | .formats = HSW_FORMATS, | 750 | .formats = SNDRV_PCM_FMTBIT_S24_LE | SNDRV_PCM_FMTBIT_S16_LE, |
| 742 | }, | 751 | }, |
| 743 | }, | 752 | }, |
| 744 | }; | 753 | }; |
diff --git a/sound/soc/intel/sst-mfld-dsp.h b/sound/soc/intel/sst-mfld-dsp.h index 8d482d76475a..4257263157cd 100644 --- a/sound/soc/intel/sst-mfld-dsp.h +++ b/sound/soc/intel/sst-mfld-dsp.h | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | /* | 3 | /* |
| 4 | * sst_mfld_dsp.h - Intel SST Driver for audio engine | 4 | * sst_mfld_dsp.h - Intel SST Driver for audio engine |
| 5 | * | 5 | * |
| 6 | * Copyright (C) 2008-12 Intel Corporation | 6 | * Copyright (C) 2008-14 Intel Corporation |
| 7 | * Authors: Vinod Koul <vinod.koul@linux.intel.com> | 7 | * Authors: Vinod Koul <vinod.koul@linux.intel.com> |
| 8 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 8 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 9 | * | 9 | * |
| @@ -19,6 +19,142 @@ | |||
| 19 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 19 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 20 | */ | 20 | */ |
| 21 | 21 | ||
| 22 | #define SST_MAX_BIN_BYTES 1024 | ||
| 23 | |||
| 24 | #define MAX_DBG_RW_BYTES 80 | ||
| 25 | #define MAX_NUM_SCATTER_BUFFERS 8 | ||
| 26 | #define MAX_LOOP_BACK_DWORDS 8 | ||
| 27 | /* IPC base address and mailbox, timestamp offsets */ | ||
| 28 | #define SST_MAILBOX_SIZE 0x0400 | ||
| 29 | #define SST_MAILBOX_SEND 0x0000 | ||
| 30 | #define SST_TIME_STAMP 0x1800 | ||
| 31 | #define SST_TIME_STAMP_MRFLD 0x800 | ||
| 32 | #define SST_RESERVED_OFFSET 0x1A00 | ||
| 33 | #define SST_SCU_LPE_MAILBOX 0x1000 | ||
| 34 | #define SST_LPE_SCU_MAILBOX 0x1400 | ||
| 35 | #define SST_SCU_LPE_LOG_BUF (SST_SCU_LPE_MAILBOX+16) | ||
| 36 | #define PROCESS_MSG 0x80 | ||
| 37 | |||
| 38 | /* Message ID's for IPC messages */ | ||
| 39 | /* Bits B7: SST or IA/SC ; B6-B4: Msg Category; B3-B0: Msg Type */ | ||
| 40 | |||
| 41 | /* I2L Firmware/Codec Download msgs */ | ||
| 42 | #define IPC_IA_PREP_LIB_DNLD 0x01 | ||
| 43 | #define IPC_IA_LIB_DNLD_CMPLT 0x02 | ||
| 44 | #define IPC_IA_GET_FW_VERSION 0x04 | ||
| 45 | #define IPC_IA_GET_FW_BUILD_INF 0x05 | ||
| 46 | #define IPC_IA_GET_FW_INFO 0x06 | ||
| 47 | #define IPC_IA_GET_FW_CTXT 0x07 | ||
| 48 | #define IPC_IA_SET_FW_CTXT 0x08 | ||
| 49 | #define IPC_IA_PREPARE_SHUTDOWN 0x31 | ||
| 50 | /* I2L Codec Config/control msgs */ | ||
| 51 | #define IPC_PREP_D3 0x10 | ||
| 52 | #define IPC_IA_SET_CODEC_PARAMS 0x10 | ||
| 53 | #define IPC_IA_GET_CODEC_PARAMS 0x11 | ||
| 54 | #define IPC_IA_SET_PPP_PARAMS 0x12 | ||
| 55 | #define IPC_IA_GET_PPP_PARAMS 0x13 | ||
| 56 | #define IPC_SST_PERIOD_ELAPSED_MRFLD 0xA | ||
| 57 | #define IPC_IA_ALG_PARAMS 0x1A | ||
| 58 | #define IPC_IA_TUNING_PARAMS 0x1B | ||
| 59 | #define IPC_IA_SET_RUNTIME_PARAMS 0x1C | ||
| 60 | #define IPC_IA_SET_PARAMS 0x1 | ||
| 61 | #define IPC_IA_GET_PARAMS 0x2 | ||
| 62 | |||
| 63 | #define IPC_EFFECTS_CREATE 0xE | ||
| 64 | #define IPC_EFFECTS_DESTROY 0xF | ||
| 65 | |||
| 66 | /* I2L Stream config/control msgs */ | ||
| 67 | #define IPC_IA_ALLOC_STREAM_MRFLD 0x2 | ||
| 68 | #define IPC_IA_ALLOC_STREAM 0x20 /* Allocate a stream ID */ | ||
| 69 | #define IPC_IA_FREE_STREAM_MRFLD 0x03 | ||
| 70 | #define IPC_IA_FREE_STREAM 0x21 /* Free the stream ID */ | ||
| 71 | #define IPC_IA_SET_STREAM_PARAMS 0x22 | ||
| 72 | #define IPC_IA_SET_STREAM_PARAMS_MRFLD 0x12 | ||
| 73 | #define IPC_IA_GET_STREAM_PARAMS 0x23 | ||
| 74 | #define IPC_IA_PAUSE_STREAM 0x24 | ||
| 75 | #define IPC_IA_PAUSE_STREAM_MRFLD 0x4 | ||
| 76 | #define IPC_IA_RESUME_STREAM 0x25 | ||
| 77 | #define IPC_IA_RESUME_STREAM_MRFLD 0x5 | ||
| 78 | #define IPC_IA_DROP_STREAM 0x26 | ||
| 79 | #define IPC_IA_DROP_STREAM_MRFLD 0x07 | ||
| 80 | #define IPC_IA_DRAIN_STREAM 0x27 /* Short msg with str_id */ | ||
| 81 | #define IPC_IA_DRAIN_STREAM_MRFLD 0x8 | ||
| 82 | #define IPC_IA_CONTROL_ROUTING 0x29 | ||
| 83 | #define IPC_IA_VTSV_UPDATE_MODULES 0x20 | ||
| 84 | #define IPC_IA_VTSV_DETECTED 0x21 | ||
| 85 | |||
| 86 | #define IPC_IA_START_STREAM_MRFLD 0X06 | ||
| 87 | #define IPC_IA_START_STREAM 0x30 /* Short msg with str_id */ | ||
| 88 | |||
| 89 | #define IPC_IA_SET_GAIN_MRFLD 0x21 | ||
| 90 | /* Debug msgs */ | ||
| 91 | #define IPC_IA_DBG_MEM_READ 0x40 | ||
| 92 | #define IPC_IA_DBG_MEM_WRITE 0x41 | ||
| 93 | #define IPC_IA_DBG_LOOP_BACK 0x42 | ||
| 94 | #define IPC_IA_DBG_LOG_ENABLE 0x45 | ||
| 95 | #define IPC_IA_DBG_SET_PROBE_PARAMS 0x47 | ||
| 96 | |||
| 97 | /* L2I Firmware/Codec Download msgs */ | ||
| 98 | #define IPC_IA_FW_INIT_CMPLT 0x81 | ||
| 99 | #define IPC_IA_FW_INIT_CMPLT_MRFLD 0x01 | ||
| 100 | #define IPC_IA_FW_ASYNC_ERR_MRFLD 0x11 | ||
| 101 | |||
| 102 | /* L2I Codec Config/control msgs */ | ||
| 103 | #define IPC_SST_FRAGMENT_ELPASED 0x90 /* Request IA more data */ | ||
| 104 | |||
| 105 | #define IPC_SST_BUF_UNDER_RUN 0x92 /* PB Under run and stopped */ | ||
| 106 | #define IPC_SST_BUF_OVER_RUN 0x93 /* CAP Under run and stopped */ | ||
| 107 | #define IPC_SST_DRAIN_END 0x94 /* PB Drain complete and stopped */ | ||
| 108 | #define IPC_SST_CHNGE_SSP_PARAMS 0x95 /* PB SSP parameters changed */ | ||
| 109 | #define IPC_SST_STREAM_PROCESS_FATAL_ERR 0x96/* error in processing a stream */ | ||
| 110 | #define IPC_SST_PERIOD_ELAPSED 0x97 /* period elapsed */ | ||
| 111 | |||
| 112 | #define IPC_SST_ERROR_EVENT 0x99 /* Buffer over run occurred */ | ||
| 113 | /* L2S messages */ | ||
| 114 | #define IPC_SC_DDR_LINK_UP 0xC0 | ||
| 115 | #define IPC_SC_DDR_LINK_DOWN 0xC1 | ||
| 116 | #define IPC_SC_SET_LPECLK_REQ 0xC2 | ||
| 117 | #define IPC_SC_SSP_BIT_BANG 0xC3 | ||
| 118 | |||
| 119 | /* L2I Error reporting msgs */ | ||
| 120 | #define IPC_IA_MEM_ALLOC_FAIL 0xE0 | ||
| 121 | #define IPC_IA_PROC_ERR 0xE1 /* error in processing a | ||
| 122 | stream can be used by playback and | ||
| 123 | capture modules */ | ||
| 124 | |||
| 125 | /* L2I Debug msgs */ | ||
| 126 | #define IPC_IA_PRINT_STRING 0xF0 | ||
| 127 | |||
| 128 | /* Buffer under-run */ | ||
| 129 | #define IPC_IA_BUF_UNDER_RUN_MRFLD 0x0B | ||
| 130 | |||
| 131 | /* Mrfld specific defines: | ||
| 132 | * For asynchronous messages(INIT_CMPLT, PERIOD_ELAPSED, ASYNC_ERROR) | ||
| 133 | * received from FW, the format is: | ||
| 134 | * - IPC High: pvt_id is set to zero. Always short message. | ||
| 135 | * - msg_id is in lower 16-bits of IPC low payload. | ||
| 136 | * - pipe_id is in higher 16-bits of IPC low payload for period_elapsed. | ||
| 137 | * - error id is in higher 16-bits of IPC low payload for async errors. | ||
| 138 | */ | ||
| 139 | #define SST_ASYNC_DRV_ID 0 | ||
| 140 | |||
| 141 | /* Command Response or Acknowledge message to any IPC message will have | ||
| 142 | * same message ID and stream ID information which is sent. | ||
| 143 | * There is no specific Ack message ID. The data field is used as response | ||
| 144 | * meaning. | ||
| 145 | */ | ||
| 146 | enum ackData { | ||
| 147 | IPC_ACK_SUCCESS = 0, | ||
| 148 | IPC_ACK_FAILURE, | ||
| 149 | }; | ||
| 150 | |||
| 151 | enum ipc_ia_msg_id { | ||
| 152 | IPC_CMD = 1, /*!< Task Control message ID */ | ||
| 153 | IPC_SET_PARAMS = 2,/*!< Task Set param message ID */ | ||
| 154 | IPC_GET_PARAMS = 3, /*!< Task Get param message ID */ | ||
| 155 | IPC_INVALID = 0xFF, /*!<Task Get param message ID */ | ||
| 156 | }; | ||
| 157 | |||
| 22 | enum sst_codec_types { | 158 | enum sst_codec_types { |
| 23 | /* AUDIO/MUSIC CODEC Type Definitions */ | 159 | /* AUDIO/MUSIC CODEC Type Definitions */ |
| 24 | SST_CODEC_TYPE_UNKNOWN = 0, | 160 | SST_CODEC_TYPE_UNKNOWN = 0, |
| @@ -35,14 +171,157 @@ enum stream_type { | |||
| 35 | SST_STREAM_TYPE_MUSIC = 1, | 171 | SST_STREAM_TYPE_MUSIC = 1, |
| 36 | }; | 172 | }; |
| 37 | 173 | ||
| 174 | enum sst_error_codes { | ||
| 175 | /* Error code,response to msgId: Description */ | ||
| 176 | /* Common error codes */ | ||
| 177 | SST_SUCCESS = 0, /* Success */ | ||
| 178 | SST_ERR_INVALID_STREAM_ID = 1, | ||
| 179 | SST_ERR_INVALID_MSG_ID = 2, | ||
| 180 | SST_ERR_INVALID_STREAM_OP = 3, | ||
| 181 | SST_ERR_INVALID_PARAMS = 4, | ||
| 182 | SST_ERR_INVALID_CODEC = 5, | ||
| 183 | SST_ERR_INVALID_MEDIA_TYPE = 6, | ||
| 184 | SST_ERR_STREAM_ERR = 7, | ||
| 185 | |||
| 186 | SST_ERR_STREAM_IN_USE = 15, | ||
| 187 | }; | ||
| 188 | |||
| 189 | struct ipc_dsp_hdr { | ||
| 190 | u16 mod_index_id:8; /*!< DSP Command ID specific to tasks */ | ||
| 191 | u16 pipe_id:8; /*!< instance of the module in the pipeline */ | ||
| 192 | u16 mod_id; /*!< Pipe_id */ | ||
| 193 | u16 cmd_id; /*!< Module ID = lpe_algo_types_t */ | ||
| 194 | u16 length; /*!< Length of the payload only */ | ||
| 195 | } __packed; | ||
| 196 | |||
| 197 | union ipc_header_high { | ||
| 198 | struct { | ||
| 199 | u32 msg_id:8; /* Message ID - Max 256 Message Types */ | ||
| 200 | u32 task_id:4; /* Task ID associated with this comand */ | ||
| 201 | u32 drv_id:4; /* Identifier for the driver to track*/ | ||
| 202 | u32 rsvd1:8; /* Reserved */ | ||
| 203 | u32 result:4; /* Reserved */ | ||
| 204 | u32 res_rqd:1; /* Response rqd */ | ||
| 205 | u32 large:1; /* Large Message if large = 1 */ | ||
| 206 | u32 done:1; /* bit 30 - Done bit */ | ||
| 207 | u32 busy:1; /* bit 31 - busy bit*/ | ||
| 208 | } part; | ||
| 209 | u32 full; | ||
| 210 | } __packed; | ||
| 211 | /* IPC header */ | ||
| 212 | union ipc_header_mrfld { | ||
| 213 | struct { | ||
| 214 | u32 header_low_payload; | ||
| 215 | union ipc_header_high header_high; | ||
| 216 | } p; | ||
| 217 | u64 full; | ||
| 218 | } __packed; | ||
| 219 | /* CAUTION NOTE: All IPC message body must be multiple of 32 bits.*/ | ||
| 220 | |||
| 221 | /* IPC Header */ | ||
| 222 | union ipc_header { | ||
| 223 | struct { | ||
| 224 | u32 msg_id:8; /* Message ID - Max 256 Message Types */ | ||
| 225 | u32 str_id:5; | ||
| 226 | u32 large:1; /* Large Message if large = 1 */ | ||
| 227 | u32 reserved:2; /* Reserved for future use */ | ||
| 228 | u32 data:14; /* Ack/Info for msg, size of msg in Mailbox */ | ||
| 229 | u32 done:1; /* bit 30 */ | ||
| 230 | u32 busy:1; /* bit 31 */ | ||
| 231 | } part; | ||
| 232 | u32 full; | ||
| 233 | } __packed; | ||
| 234 | |||
| 235 | /* Firmware build info */ | ||
| 236 | struct sst_fw_build_info { | ||
| 237 | unsigned char date[16]; /* Firmware build date */ | ||
| 238 | unsigned char time[16]; /* Firmware build time */ | ||
| 239 | } __packed; | ||
| 240 | |||
| 241 | /* Firmware Version info */ | ||
| 242 | struct snd_sst_fw_version { | ||
| 243 | u8 build; /* build number*/ | ||
| 244 | u8 minor; /* minor number*/ | ||
| 245 | u8 major; /* major number*/ | ||
| 246 | u8 type; /* build type */ | ||
| 247 | }; | ||
| 248 | |||
| 249 | struct ipc_header_fw_init { | ||
| 250 | struct snd_sst_fw_version fw_version;/* Firmware version details */ | ||
| 251 | struct sst_fw_build_info build_info; | ||
| 252 | u16 result; /* Fw init result */ | ||
| 253 | u8 module_id; /* Module ID in case of error */ | ||
| 254 | u8 debug_info; /* Debug info from Module ID in case of fail */ | ||
| 255 | } __packed; | ||
| 256 | |||
| 257 | struct snd_sst_tstamp { | ||
| 258 | u64 ring_buffer_counter; /* PB/CP: Bytes copied from/to DDR. */ | ||
| 259 | u64 hardware_counter; /* PB/CP: Bytes DMAed to/from SSP. */ | ||
| 260 | u64 frames_decoded; | ||
| 261 | u64 bytes_decoded; | ||
| 262 | u64 bytes_copied; | ||
| 263 | u32 sampling_frequency; | ||
| 264 | u32 channel_peak[8]; | ||
| 265 | } __packed; | ||
| 266 | |||
| 267 | /* Stream type params struture for Alloc stream */ | ||
| 268 | struct snd_sst_str_type { | ||
| 269 | u8 codec_type; /* Codec type */ | ||
| 270 | u8 str_type; /* 1 = voice 2 = music */ | ||
| 271 | u8 operation; /* Playback or Capture */ | ||
| 272 | u8 protected_str; /* 0=Non DRM, 1=DRM */ | ||
| 273 | u8 time_slots; | ||
| 274 | u8 reserved; /* Reserved */ | ||
| 275 | u16 result; /* Result used for acknowledgment */ | ||
| 276 | } __packed; | ||
| 277 | |||
| 278 | /* Library info structure */ | ||
| 279 | struct module_info { | ||
| 280 | u32 lib_version; | ||
| 281 | u32 lib_type;/*TBD- KLOCKWORK u8 lib_type;*/ | ||
| 282 | u32 media_type; | ||
| 283 | u8 lib_name[12]; | ||
| 284 | u32 lib_caps; | ||
| 285 | unsigned char b_date[16]; /* Lib build date */ | ||
| 286 | unsigned char b_time[16]; /* Lib build time */ | ||
| 287 | } __packed; | ||
| 288 | |||
| 289 | /* Library slot info */ | ||
| 290 | struct lib_slot_info { | ||
| 291 | u8 slot_num; /* 1 or 2 */ | ||
| 292 | u8 reserved1; | ||
| 293 | u16 reserved2; | ||
| 294 | u32 iram_size; /* slot size in IRAM */ | ||
| 295 | u32 dram_size; /* slot size in DRAM */ | ||
| 296 | u32 iram_offset; /* starting offset of slot in IRAM */ | ||
| 297 | u32 dram_offset; /* starting offset of slot in DRAM */ | ||
| 298 | } __packed; | ||
| 299 | |||
| 300 | struct snd_ppp_mixer_params { | ||
| 301 | __u32 type; /*Type of the parameter */ | ||
| 302 | __u32 size; | ||
| 303 | __u32 input_stream_bitmap; /*Input stream Bit Map*/ | ||
| 304 | } __packed; | ||
| 305 | |||
| 306 | struct snd_sst_lib_download { | ||
| 307 | struct module_info lib_info; /* library info type, capabilities etc */ | ||
| 308 | struct lib_slot_info slot_info; /* slot info to be downloaded */ | ||
| 309 | u32 mod_entry_pt; | ||
| 310 | }; | ||
| 311 | |||
| 312 | struct snd_sst_lib_download_info { | ||
| 313 | struct snd_sst_lib_download dload_lib; | ||
| 314 | u16 result; /* Result used for acknowledgment */ | ||
| 315 | u8 pvt_id; /* Private ID */ | ||
| 316 | u8 reserved; /* for alignment */ | ||
| 317 | }; | ||
| 38 | struct snd_pcm_params { | 318 | struct snd_pcm_params { |
| 39 | u8 num_chan; /* 1=Mono, 2=Stereo */ | 319 | u8 num_chan; /* 1=Mono, 2=Stereo */ |
| 40 | u8 pcm_wd_sz; /* 16/24 - bit*/ | 320 | u8 pcm_wd_sz; /* 16/24 - bit*/ |
| 41 | u32 reserved; /* Bitrate in bits per second */ | 321 | u8 use_offload_path; /* 0-PCM using period elpased & ALSA interfaces |
| 42 | u32 sfreq; /* Sampling rate in Hz */ | 322 | 1-PCM stream via compressed interface */ |
| 43 | u8 use_offload_path; | ||
| 44 | u8 reserved2; | 323 | u8 reserved2; |
| 45 | u16 reserved3; | 324 | u32 sfreq; /* Sampling rate in Hz */ |
| 46 | u8 channel_map[8]; | 325 | u8 channel_map[8]; |
| 47 | } __packed; | 326 | } __packed; |
| 48 | 327 | ||
| @@ -76,6 +355,7 @@ struct snd_aac_params { | |||
| 76 | struct snd_wma_params { | 355 | struct snd_wma_params { |
| 77 | u8 num_chan; /* 1=Mono, 2=Stereo */ | 356 | u8 num_chan; /* 1=Mono, 2=Stereo */ |
| 78 | u8 pcm_wd_sz; /* 16/24 - bit*/ | 357 | u8 pcm_wd_sz; /* 16/24 - bit*/ |
| 358 | u16 reserved1; | ||
| 79 | u32 brate; /* Use the hard coded value. */ | 359 | u32 brate; /* Use the hard coded value. */ |
| 80 | u32 sfreq; /* Sampling freq eg. 8000, 441000, 48000 */ | 360 | u32 sfreq; /* Sampling freq eg. 8000, 441000, 48000 */ |
| 81 | u32 channel_mask; /* Channel Mask */ | 361 | u32 channel_mask; /* Channel Mask */ |
| @@ -101,26 +381,153 @@ struct sst_address_info { | |||
| 101 | }; | 381 | }; |
| 102 | 382 | ||
| 103 | struct snd_sst_alloc_params_ext { | 383 | struct snd_sst_alloc_params_ext { |
| 104 | struct sst_address_info ring_buf_info[8]; | 384 | __u16 sg_count; |
| 105 | u8 sg_count; | 385 | __u16 reserved; |
| 106 | u8 reserved; | 386 | __u32 frag_size; /*Number of samples after which period elapsed |
| 107 | u16 reserved2; | ||
| 108 | u32 frag_size; /*Number of samples after which period elapsed | ||
| 109 | message is sent valid only if path = 0*/ | 387 | message is sent valid only if path = 0*/ |
| 110 | } __packed; | 388 | struct sst_address_info ring_buf_info[8]; |
| 389 | }; | ||
| 111 | 390 | ||
| 112 | struct snd_sst_stream_params { | 391 | struct snd_sst_stream_params { |
| 113 | union snd_sst_codec_params uc; | 392 | union snd_sst_codec_params uc; |
| 114 | } __packed; | 393 | } __packed; |
| 115 | 394 | ||
| 116 | struct snd_sst_params { | 395 | struct snd_sst_params { |
| 396 | u32 result; | ||
| 117 | u32 stream_id; | 397 | u32 stream_id; |
| 118 | u8 codec; | 398 | u8 codec; |
| 119 | u8 ops; | 399 | u8 ops; |
| 120 | u8 stream_type; | 400 | u8 stream_type; |
| 121 | u8 device_type; | 401 | u8 device_type; |
| 402 | u8 task; | ||
| 122 | struct snd_sst_stream_params sparams; | 403 | struct snd_sst_stream_params sparams; |
| 123 | struct snd_sst_alloc_params_ext aparams; | 404 | struct snd_sst_alloc_params_ext aparams; |
| 124 | }; | 405 | }; |
| 125 | 406 | ||
| 407 | struct snd_sst_alloc_mrfld { | ||
| 408 | u16 codec_type; | ||
| 409 | u8 operation; | ||
| 410 | u8 sg_count; | ||
| 411 | struct sst_address_info ring_buf_info[8]; | ||
| 412 | u32 frag_size; | ||
| 413 | u32 ts; | ||
| 414 | struct snd_sst_stream_params codec_params; | ||
| 415 | } __packed; | ||
| 416 | |||
| 417 | /* Alloc stream params structure */ | ||
| 418 | struct snd_sst_alloc_params { | ||
| 419 | struct snd_sst_str_type str_type; | ||
| 420 | struct snd_sst_stream_params stream_params; | ||
| 421 | struct snd_sst_alloc_params_ext alloc_params; | ||
| 422 | } __packed; | ||
| 423 | |||
| 424 | /* Alloc stream response message */ | ||
| 425 | struct snd_sst_alloc_response { | ||
| 426 | struct snd_sst_str_type str_type; /* Stream type for allocation */ | ||
| 427 | struct snd_sst_lib_download lib_dnld; /* Valid only for codec dnld */ | ||
| 428 | }; | ||
| 429 | |||
| 430 | /* Drop response */ | ||
| 431 | struct snd_sst_drop_response { | ||
| 432 | u32 result; | ||
| 433 | u32 bytes; | ||
| 434 | }; | ||
| 435 | |||
| 436 | struct snd_sst_async_msg { | ||
| 437 | u32 msg_id; /* Async msg id */ | ||
| 438 | u32 payload[0]; | ||
| 439 | }; | ||
| 440 | |||
| 441 | struct snd_sst_async_err_msg { | ||
| 442 | u32 fw_resp; /* Firmware Result */ | ||
| 443 | u32 lib_resp; /*Library result */ | ||
| 444 | } __packed; | ||
| 445 | |||
| 446 | struct snd_sst_vol { | ||
| 447 | u32 stream_id; | ||
| 448 | s32 volume; | ||
| 449 | u32 ramp_duration; | ||
| 450 | u32 ramp_type; /* Ramp type, default=0 */ | ||
| 451 | }; | ||
| 452 | |||
| 453 | /* Gain library parameters for mrfld | ||
| 454 | * based on DSP command spec v0.82 | ||
| 455 | */ | ||
| 456 | struct snd_sst_gain_v2 { | ||
| 457 | u16 gain_cell_num; /* num of gain cells to modify*/ | ||
| 458 | u8 cell_nbr_idx; /* instance index*/ | ||
| 459 | u8 cell_path_idx; /* pipe-id */ | ||
| 460 | u16 module_id; /*module id */ | ||
| 461 | u16 left_cell_gain; /* left gain value in dB*/ | ||
| 462 | u16 right_cell_gain; /* right gain value in dB*/ | ||
| 463 | u16 gain_time_const; /* gain time constant*/ | ||
| 464 | } __packed; | ||
| 465 | |||
| 466 | struct snd_sst_mute { | ||
| 467 | u32 stream_id; | ||
| 468 | u32 mute; | ||
| 469 | }; | ||
| 470 | |||
| 471 | struct snd_sst_runtime_params { | ||
| 472 | u8 type; | ||
| 473 | u8 str_id; | ||
| 474 | u8 size; | ||
| 475 | u8 rsvd; | ||
| 476 | void *addr; | ||
| 477 | } __packed; | ||
| 478 | |||
| 479 | enum stream_param_type { | ||
| 480 | SST_SET_TIME_SLOT = 0, | ||
| 481 | SST_SET_CHANNEL_INFO = 1, | ||
| 482 | OTHERS = 2, /*reserved for future params*/ | ||
| 483 | }; | ||
| 484 | |||
| 485 | /* CSV Voice call routing structure */ | ||
| 486 | struct snd_sst_control_routing { | ||
| 487 | u8 control; /* 0=start, 1=Stop */ | ||
| 488 | u8 reserved[3]; /* Reserved- for 32 bit alignment */ | ||
| 489 | }; | ||
| 490 | |||
| 491 | struct ipc_post { | ||
| 492 | struct list_head node; | ||
| 493 | union ipc_header header; /* driver specific */ | ||
| 494 | bool is_large; | ||
| 495 | bool is_process_reply; | ||
| 496 | union ipc_header_mrfld mrfld_header; | ||
| 497 | char *mailbox_data; | ||
| 498 | }; | ||
| 499 | |||
| 500 | struct snd_sst_ctxt_params { | ||
| 501 | u32 address; /* Physical Address in DDR where the context is stored */ | ||
| 502 | u32 size; /* size of the context */ | ||
| 503 | }; | ||
| 504 | |||
| 505 | struct snd_sst_lpe_log_params { | ||
| 506 | u8 dbg_type; | ||
| 507 | u8 module_id; | ||
| 508 | u8 log_level; | ||
| 509 | u8 reserved; | ||
| 510 | } __packed; | ||
| 511 | |||
| 512 | enum snd_sst_bytes_type { | ||
| 513 | SND_SST_BYTES_SET = 0x1, | ||
| 514 | SND_SST_BYTES_GET = 0x2, | ||
| 515 | }; | ||
| 516 | |||
| 517 | struct snd_sst_bytes_v2 { | ||
| 518 | u8 type; | ||
| 519 | u8 ipc_msg; | ||
| 520 | u8 block; | ||
| 521 | u8 task_id; | ||
| 522 | u8 pipe_id; | ||
| 523 | u8 rsvd; | ||
| 524 | u16 len; | ||
| 525 | char bytes[0]; | ||
| 526 | }; | ||
| 527 | |||
| 528 | #define MAX_VTSV_FILES 2 | ||
| 529 | struct snd_sst_vtsv_info { | ||
| 530 | struct sst_address_info vfiles[MAX_VTSV_FILES]; | ||
| 531 | } __packed; | ||
| 532 | |||
| 126 | #endif /* __SST_MFLD_DSP_H__ */ | 533 | #endif /* __SST_MFLD_DSP_H__ */ |
diff --git a/sound/soc/intel/sst-mfld-platform-compress.c b/sound/soc/intel/sst-mfld-platform-compress.c index 02abd19fce1d..29c059ca19e8 100644 --- a/sound/soc/intel/sst-mfld-platform-compress.c +++ b/sound/soc/intel/sst-mfld-platform-compress.c | |||
| @@ -100,14 +100,19 @@ static int sst_platform_compr_set_params(struct snd_compr_stream *cstream, | |||
| 100 | int retval; | 100 | int retval; |
| 101 | struct snd_sst_params str_params; | 101 | struct snd_sst_params str_params; |
| 102 | struct sst_compress_cb cb; | 102 | struct sst_compress_cb cb; |
| 103 | struct snd_soc_pcm_runtime *rtd = cstream->private_data; | ||
| 104 | struct snd_soc_platform *platform = rtd->platform; | ||
| 105 | struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); | ||
| 103 | 106 | ||
| 104 | stream = cstream->runtime->private_data; | 107 | stream = cstream->runtime->private_data; |
| 105 | /* construct fw structure for this*/ | 108 | /* construct fw structure for this*/ |
| 106 | memset(&str_params, 0, sizeof(str_params)); | 109 | memset(&str_params, 0, sizeof(str_params)); |
| 107 | 110 | ||
| 108 | str_params.ops = STREAM_OPS_PLAYBACK; | 111 | /* fill the device type and stream id to pass to SST driver */ |
| 109 | str_params.stream_type = SST_STREAM_TYPE_MUSIC; | 112 | retval = sst_fill_stream_params(cstream, ctx, &str_params, true); |
| 110 | str_params.device_type = SND_SST_DEVICE_COMPRESS; | 113 | pr_debug("compr_set_params: fill stream params ret_val = 0x%x\n", retval); |
| 114 | if (retval < 0) | ||
| 115 | return retval; | ||
| 111 | 116 | ||
| 112 | switch (params->codec.id) { | 117 | switch (params->codec.id) { |
| 113 | case SND_AUDIOCODEC_MP3: { | 118 | case SND_AUDIOCODEC_MP3: { |
diff --git a/sound/soc/intel/sst-mfld-platform-pcm.c b/sound/soc/intel/sst-mfld-platform-pcm.c index 7c790f51d259..706212a6a68c 100644 --- a/sound/soc/intel/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/sst-mfld-platform-pcm.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * sst_mfld_platform.c - Intel MID Platform driver | 2 | * sst_mfld_platform.c - Intel MID Platform driver |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 2010-2013 Intel Corp | 4 | * Copyright (C) 2010-2014 Intel Corp |
| 5 | * Author: Vinod Koul <vinod.koul@intel.com> | 5 | * Author: Vinod Koul <vinod.koul@intel.com> |
| 6 | * Author: Harsha Priya <priya.harsha@intel.com> | 6 | * Author: Harsha Priya <priya.harsha@intel.com> |
| 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 7 | * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| @@ -27,7 +27,9 @@ | |||
| 27 | #include <sound/pcm_params.h> | 27 | #include <sound/pcm_params.h> |
| 28 | #include <sound/soc.h> | 28 | #include <sound/soc.h> |
| 29 | #include <sound/compress_driver.h> | 29 | #include <sound/compress_driver.h> |
| 30 | #include <asm/platform_sst_audio.h> | ||
| 30 | #include "sst-mfld-platform.h" | 31 | #include "sst-mfld-platform.h" |
| 32 | #include "sst-atom-controls.h" | ||
| 31 | 33 | ||
| 32 | struct sst_device *sst; | 34 | struct sst_device *sst; |
| 33 | static DEFINE_MUTEX(sst_lock); | 35 | static DEFINE_MUTEX(sst_lock); |
| @@ -92,6 +94,13 @@ static struct snd_pcm_hardware sst_platform_pcm_hw = { | |||
| 92 | .fifo_size = SST_FIFO_SIZE, | 94 | .fifo_size = SST_FIFO_SIZE, |
| 93 | }; | 95 | }; |
| 94 | 96 | ||
| 97 | static struct sst_dev_stream_map dpcm_strm_map[] = { | ||
| 98 | {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}, /* Reserved, not in use */ | ||
| 99 | {MERR_DPCM_AUDIO, 0, SNDRV_PCM_STREAM_PLAYBACK, PIPE_MEDIA1_IN, SST_TASK_ID_MEDIA, 0}, | ||
| 100 | {MERR_DPCM_COMPR, 0, SNDRV_PCM_STREAM_PLAYBACK, PIPE_MEDIA0_IN, SST_TASK_ID_MEDIA, 0}, | ||
| 101 | {MERR_DPCM_AUDIO, 0, SNDRV_PCM_STREAM_CAPTURE, PIPE_PCM1_OUT, SST_TASK_ID_MEDIA, 0}, | ||
| 102 | }; | ||
| 103 | |||
| 95 | /* MFLD - MSIC */ | 104 | /* MFLD - MSIC */ |
| 96 | static struct snd_soc_dai_driver sst_platform_dai[] = { | 105 | static struct snd_soc_dai_driver sst_platform_dai[] = { |
| 97 | { | 106 | { |
| @@ -143,58 +152,142 @@ static inline int sst_get_stream_status(struct sst_runtime_stream *stream) | |||
| 143 | return state; | 152 | return state; |
| 144 | } | 153 | } |
| 145 | 154 | ||
| 155 | static void sst_fill_alloc_params(struct snd_pcm_substream *substream, | ||
| 156 | struct snd_sst_alloc_params_ext *alloc_param) | ||
| 157 | { | ||
| 158 | unsigned int channels; | ||
| 159 | snd_pcm_uframes_t period_size; | ||
| 160 | ssize_t periodbytes; | ||
| 161 | ssize_t buffer_bytes = snd_pcm_lib_buffer_bytes(substream); | ||
| 162 | u32 buffer_addr = virt_to_phys(substream->dma_buffer.area); | ||
| 163 | |||
| 164 | channels = substream->runtime->channels; | ||
| 165 | period_size = substream->runtime->period_size; | ||
| 166 | periodbytes = samples_to_bytes(substream->runtime, period_size); | ||
| 167 | alloc_param->ring_buf_info[0].addr = buffer_addr; | ||
| 168 | alloc_param->ring_buf_info[0].size = buffer_bytes; | ||
| 169 | alloc_param->sg_count = 1; | ||
| 170 | alloc_param->reserved = 0; | ||
| 171 | alloc_param->frag_size = periodbytes * channels; | ||
| 172 | |||
| 173 | } | ||
| 146 | static void sst_fill_pcm_params(struct snd_pcm_substream *substream, | 174 | static void sst_fill_pcm_params(struct snd_pcm_substream *substream, |
| 147 | struct sst_pcm_params *param) | 175 | struct snd_sst_stream_params *param) |
| 148 | { | 176 | { |
| 177 | param->uc.pcm_params.num_chan = (u8) substream->runtime->channels; | ||
| 178 | param->uc.pcm_params.pcm_wd_sz = substream->runtime->sample_bits; | ||
| 179 | param->uc.pcm_params.sfreq = substream->runtime->rate; | ||
| 180 | |||
| 181 | /* PCM stream via ALSA interface */ | ||
| 182 | param->uc.pcm_params.use_offload_path = 0; | ||
| 183 | param->uc.pcm_params.reserved2 = 0; | ||
| 184 | memset(param->uc.pcm_params.channel_map, 0, sizeof(u8)); | ||
| 149 | 185 | ||
| 150 | param->num_chan = (u8) substream->runtime->channels; | ||
| 151 | param->pcm_wd_sz = substream->runtime->sample_bits; | ||
| 152 | param->reserved = 0; | ||
| 153 | param->sfreq = substream->runtime->rate; | ||
| 154 | param->ring_buffer_size = snd_pcm_lib_buffer_bytes(substream); | ||
| 155 | param->period_count = substream->runtime->period_size; | ||
| 156 | param->ring_buffer_addr = virt_to_phys(substream->dma_buffer.area); | ||
| 157 | pr_debug("period_cnt = %d\n", param->period_count); | ||
| 158 | pr_debug("sfreq= %d, wd_sz = %d\n", param->sfreq, param->pcm_wd_sz); | ||
| 159 | } | 186 | } |
| 160 | 187 | ||
| 161 | static int sst_platform_alloc_stream(struct snd_pcm_substream *substream) | 188 | static int sst_get_stream_mapping(int dev, int sdev, int dir, |
| 189 | struct sst_dev_stream_map *map, int size) | ||
| 190 | { | ||
| 191 | int i; | ||
| 192 | |||
| 193 | if (map == NULL) | ||
| 194 | return -EINVAL; | ||
| 195 | |||
| 196 | |||
| 197 | /* index 0 is not used in stream map */ | ||
| 198 | for (i = 1; i < size; i++) { | ||
| 199 | if ((map[i].dev_num == dev) && (map[i].direction == dir)) | ||
| 200 | return i; | ||
| 201 | } | ||
| 202 | return 0; | ||
| 203 | } | ||
| 204 | |||
| 205 | int sst_fill_stream_params(void *substream, | ||
| 206 | const struct sst_data *ctx, struct snd_sst_params *str_params, bool is_compress) | ||
| 207 | { | ||
| 208 | int map_size; | ||
| 209 | int index; | ||
| 210 | struct sst_dev_stream_map *map; | ||
| 211 | struct snd_pcm_substream *pstream = NULL; | ||
| 212 | struct snd_compr_stream *cstream = NULL; | ||
| 213 | |||
| 214 | map = ctx->pdata->pdev_strm_map; | ||
| 215 | map_size = ctx->pdata->strm_map_size; | ||
| 216 | |||
| 217 | if (is_compress == true) | ||
| 218 | cstream = (struct snd_compr_stream *)substream; | ||
| 219 | else | ||
| 220 | pstream = (struct snd_pcm_substream *)substream; | ||
| 221 | |||
| 222 | str_params->stream_type = SST_STREAM_TYPE_MUSIC; | ||
| 223 | |||
| 224 | /* For pcm streams */ | ||
| 225 | if (pstream) { | ||
| 226 | index = sst_get_stream_mapping(pstream->pcm->device, | ||
| 227 | pstream->number, pstream->stream, | ||
| 228 | map, map_size); | ||
| 229 | if (index <= 0) | ||
| 230 | return -EINVAL; | ||
| 231 | |||
| 232 | str_params->stream_id = index; | ||
| 233 | str_params->device_type = map[index].device_id; | ||
| 234 | str_params->task = map[index].task_id; | ||
| 235 | |||
| 236 | str_params->ops = (u8)pstream->stream; | ||
| 237 | } | ||
| 238 | |||
| 239 | if (cstream) { | ||
| 240 | index = sst_get_stream_mapping(cstream->device->device, | ||
| 241 | 0, cstream->direction, | ||
| 242 | map, map_size); | ||
| 243 | if (index <= 0) | ||
| 244 | return -EINVAL; | ||
| 245 | str_params->stream_id = index; | ||
| 246 | str_params->device_type = map[index].device_id; | ||
| 247 | str_params->task = map[index].task_id; | ||
| 248 | |||
| 249 | str_params->ops = (u8)cstream->direction; | ||
| 250 | } | ||
| 251 | return 0; | ||
| 252 | } | ||
| 253 | |||
| 254 | static int sst_platform_alloc_stream(struct snd_pcm_substream *substream, | ||
| 255 | struct snd_soc_platform *platform) | ||
| 162 | { | 256 | { |
| 163 | struct sst_runtime_stream *stream = | 257 | struct sst_runtime_stream *stream = |
| 164 | substream->runtime->private_data; | 258 | substream->runtime->private_data; |
| 165 | struct sst_pcm_params param = {0}; | 259 | struct snd_sst_stream_params param = {{{0,},},}; |
| 166 | struct sst_stream_params str_params = {0}; | 260 | struct snd_sst_params str_params = {0}; |
| 167 | int ret_val; | 261 | struct snd_sst_alloc_params_ext alloc_params = {0}; |
| 262 | int ret_val = 0; | ||
| 263 | struct sst_data *ctx = snd_soc_platform_get_drvdata(platform); | ||
| 168 | 264 | ||
| 169 | /* set codec params and inform SST driver the same */ | 265 | /* set codec params and inform SST driver the same */ |
| 170 | sst_fill_pcm_params(substream, ¶m); | 266 | sst_fill_pcm_params(substream, ¶m); |
| 267 | sst_fill_alloc_params(substream, &alloc_params); | ||
| 171 | substream->runtime->dma_area = substream->dma_buffer.area; | 268 | substream->runtime->dma_area = substream->dma_buffer.area; |
| 172 | str_params.sparams = param; | 269 | str_params.sparams = param; |
| 173 | str_params.codec = param.codec; | 270 | str_params.aparams = alloc_params; |
| 174 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 271 | str_params.codec = SST_CODEC_TYPE_PCM; |
| 175 | str_params.ops = STREAM_OPS_PLAYBACK; | 272 | |
| 176 | str_params.device_type = substream->pcm->device + 1; | 273 | /* fill the device type and stream id to pass to SST driver */ |
| 177 | pr_debug("Playbck stream,Device %d\n", | 274 | ret_val = sst_fill_stream_params(substream, ctx, &str_params, false); |
| 178 | substream->pcm->device); | ||
| 179 | } else { | ||
| 180 | str_params.ops = STREAM_OPS_CAPTURE; | ||
| 181 | str_params.device_type = SND_SST_DEVICE_CAPTURE; | ||
| 182 | pr_debug("Capture stream,Device %d\n", | ||
| 183 | substream->pcm->device); | ||
| 184 | } | ||
| 185 | ret_val = stream->ops->open(&str_params); | ||
| 186 | pr_debug("SST_SND_PLAY/CAPTURE ret_val = %x\n", ret_val); | ||
| 187 | if (ret_val < 0) | 275 | if (ret_val < 0) |
| 188 | return ret_val; | 276 | return ret_val; |
| 189 | 277 | ||
| 190 | stream->stream_info.str_id = ret_val; | 278 | stream->stream_info.str_id = str_params.stream_id; |
| 191 | pr_debug("str id : %d\n", stream->stream_info.str_id); | 279 | |
| 280 | ret_val = stream->ops->open(&str_params); | ||
| 281 | if (ret_val <= 0) | ||
| 282 | return ret_val; | ||
| 283 | |||
| 284 | |||
| 192 | return ret_val; | 285 | return ret_val; |
| 193 | } | 286 | } |
| 194 | 287 | ||
| 195 | static void sst_period_elapsed(void *mad_substream) | 288 | static void sst_period_elapsed(void *arg) |
| 196 | { | 289 | { |
| 197 | struct snd_pcm_substream *substream = mad_substream; | 290 | struct snd_pcm_substream *substream = arg; |
| 198 | struct sst_runtime_stream *stream; | 291 | struct sst_runtime_stream *stream; |
| 199 | int status; | 292 | int status; |
| 200 | 293 | ||
| @@ -218,7 +311,7 @@ static int sst_platform_init_stream(struct snd_pcm_substream *substream) | |||
| 218 | pr_debug("setting buffer ptr param\n"); | 311 | pr_debug("setting buffer ptr param\n"); |
| 219 | sst_set_stream_status(stream, SST_PLATFORM_INIT); | 312 | sst_set_stream_status(stream, SST_PLATFORM_INIT); |
| 220 | stream->stream_info.period_elapsed = sst_period_elapsed; | 313 | stream->stream_info.period_elapsed = sst_period_elapsed; |
| 221 | stream->stream_info.mad_substream = substream; | 314 | stream->stream_info.arg = substream; |
| 222 | stream->stream_info.buffer_ptr = 0; | 315 | stream->stream_info.buffer_ptr = 0; |
| 223 | stream->stream_info.sfreq = substream->runtime->rate; | 316 | stream->stream_info.sfreq = substream->runtime->rate; |
| 224 | ret_val = stream->ops->device_control( | 317 | ret_val = stream->ops->device_control( |
| @@ -230,19 +323,12 @@ static int sst_platform_init_stream(struct snd_pcm_substream *substream) | |||
| 230 | } | 323 | } |
| 231 | /* end -- helper functions */ | 324 | /* end -- helper functions */ |
| 232 | 325 | ||
| 233 | static int sst_platform_open(struct snd_pcm_substream *substream) | 326 | static int sst_media_open(struct snd_pcm_substream *substream, |
| 327 | struct snd_soc_dai *dai) | ||
| 234 | { | 328 | { |
| 329 | int ret_val = 0; | ||
| 235 | struct snd_pcm_runtime *runtime = substream->runtime; | 330 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 236 | struct sst_runtime_stream *stream; | 331 | struct sst_runtime_stream *stream; |
| 237 | int ret_val; | ||
| 238 | |||
| 239 | pr_debug("sst_platform_open called\n"); | ||
| 240 | |||
| 241 | snd_soc_set_runtime_hwparams(substream, &sst_platform_pcm_hw); | ||
| 242 | ret_val = snd_pcm_hw_constraint_integer(runtime, | ||
| 243 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
| 244 | if (ret_val < 0) | ||
| 245 | return ret_val; | ||
| 246 | 332 | ||
| 247 | stream = kzalloc(sizeof(*stream), GFP_KERNEL); | 333 | stream = kzalloc(sizeof(*stream), GFP_KERNEL); |
| 248 | if (!stream) | 334 | if (!stream) |
| @@ -251,50 +337,69 @@ static int sst_platform_open(struct snd_pcm_substream *substream) | |||
| 251 | 337 | ||
| 252 | /* get the sst ops */ | 338 | /* get the sst ops */ |
| 253 | mutex_lock(&sst_lock); | 339 | mutex_lock(&sst_lock); |
| 254 | if (!sst) { | 340 | if (!sst || |
| 341 | !try_module_get(sst->dev->driver->owner)) { | ||
| 255 | pr_err("no device available to run\n"); | 342 | pr_err("no device available to run\n"); |
| 256 | mutex_unlock(&sst_lock); | 343 | ret_val = -ENODEV; |
| 257 | kfree(stream); | 344 | goto out_ops; |
| 258 | return -ENODEV; | ||
| 259 | } | ||
| 260 | if (!try_module_get(sst->dev->driver->owner)) { | ||
| 261 | mutex_unlock(&sst_lock); | ||
| 262 | kfree(stream); | ||
| 263 | return -ENODEV; | ||
| 264 | } | 345 | } |
| 265 | stream->ops = sst->ops; | 346 | stream->ops = sst->ops; |
| 266 | mutex_unlock(&sst_lock); | 347 | mutex_unlock(&sst_lock); |
| 267 | 348 | ||
| 268 | stream->stream_info.str_id = 0; | 349 | stream->stream_info.str_id = 0; |
| 269 | sst_set_stream_status(stream, SST_PLATFORM_INIT); | 350 | |
| 270 | stream->stream_info.mad_substream = substream; | 351 | stream->stream_info.arg = substream; |
| 271 | /* allocate memory for SST API set */ | 352 | /* allocate memory for SST API set */ |
| 272 | runtime->private_data = stream; | 353 | runtime->private_data = stream; |
| 273 | 354 | ||
| 274 | return 0; | 355 | /* Make sure, that the period size is always even */ |
| 356 | snd_pcm_hw_constraint_step(substream->runtime, 0, | ||
| 357 | SNDRV_PCM_HW_PARAM_PERIODS, 2); | ||
| 358 | |||
| 359 | return snd_pcm_hw_constraint_integer(runtime, | ||
| 360 | SNDRV_PCM_HW_PARAM_PERIODS); | ||
| 361 | out_ops: | ||
| 362 | kfree(stream); | ||
| 363 | mutex_unlock(&sst_lock); | ||
| 364 | return ret_val; | ||
| 275 | } | 365 | } |
| 276 | 366 | ||
| 277 | static int sst_platform_close(struct snd_pcm_substream *substream) | 367 | static void sst_media_close(struct snd_pcm_substream *substream, |
| 368 | struct snd_soc_dai *dai) | ||
| 278 | { | 369 | { |
| 279 | struct sst_runtime_stream *stream; | 370 | struct sst_runtime_stream *stream; |
| 280 | int ret_val = 0, str_id; | 371 | int ret_val = 0, str_id; |
| 281 | 372 | ||
| 282 | pr_debug("sst_platform_close called\n"); | ||
| 283 | stream = substream->runtime->private_data; | 373 | stream = substream->runtime->private_data; |
| 284 | str_id = stream->stream_info.str_id; | 374 | str_id = stream->stream_info.str_id; |
| 285 | if (str_id) | 375 | if (str_id) |
| 286 | ret_val = stream->ops->close(str_id); | 376 | ret_val = stream->ops->close(str_id); |
| 287 | module_put(sst->dev->driver->owner); | 377 | module_put(sst->dev->driver->owner); |
| 288 | kfree(stream); | 378 | kfree(stream); |
| 289 | return ret_val; | ||
| 290 | } | 379 | } |
| 291 | 380 | ||
| 292 | static int sst_platform_pcm_prepare(struct snd_pcm_substream *substream) | 381 | static inline unsigned int get_current_pipe_id(struct snd_soc_platform *platform, |
| 382 | struct snd_pcm_substream *substream) | ||
| 383 | { | ||
| 384 | struct sst_data *sst = snd_soc_platform_get_drvdata(platform); | ||
| 385 | struct sst_dev_stream_map *map = sst->pdata->pdev_strm_map; | ||
| 386 | struct sst_runtime_stream *stream = | ||
| 387 | substream->runtime->private_data; | ||
| 388 | u32 str_id = stream->stream_info.str_id; | ||
| 389 | unsigned int pipe_id; | ||
| 390 | pipe_id = map[str_id].device_id; | ||
| 391 | |||
| 392 | pr_debug("%s: got pipe_id = %#x for str_id = %d\n", | ||
| 393 | __func__, pipe_id, str_id); | ||
| 394 | return pipe_id; | ||
| 395 | } | ||
| 396 | |||
| 397 | static int sst_media_prepare(struct snd_pcm_substream *substream, | ||
| 398 | struct snd_soc_dai *dai) | ||
| 293 | { | 399 | { |
| 294 | struct sst_runtime_stream *stream; | 400 | struct sst_runtime_stream *stream; |
| 295 | int ret_val = 0, str_id; | 401 | int ret_val = 0, str_id; |
| 296 | 402 | ||
| 297 | pr_debug("sst_platform_pcm_prepare called\n"); | ||
| 298 | stream = substream->runtime->private_data; | 403 | stream = substream->runtime->private_data; |
| 299 | str_id = stream->stream_info.str_id; | 404 | str_id = stream->stream_info.str_id; |
| 300 | if (stream->stream_info.str_id) { | 405 | if (stream->stream_info.str_id) { |
| @@ -303,8 +408,8 @@ static int sst_platform_pcm_prepare(struct snd_pcm_substream *substream) | |||
| 303 | return ret_val; | 408 | return ret_val; |
| 304 | } | 409 | } |
| 305 | 410 | ||
| 306 | ret_val = sst_platform_alloc_stream(substream); | 411 | ret_val = sst_platform_alloc_stream(substream, dai->platform); |
| 307 | if (ret_val < 0) | 412 | if (ret_val <= 0) |
| 308 | return ret_val; | 413 | return ret_val; |
| 309 | snprintf(substream->pcm->id, sizeof(substream->pcm->id), | 414 | snprintf(substream->pcm->id, sizeof(substream->pcm->id), |
| 310 | "%d", stream->stream_info.str_id); | 415 | "%d", stream->stream_info.str_id); |
| @@ -316,6 +421,41 @@ static int sst_platform_pcm_prepare(struct snd_pcm_substream *substream) | |||
| 316 | return ret_val; | 421 | return ret_val; |
| 317 | } | 422 | } |
| 318 | 423 | ||
| 424 | static int sst_media_hw_params(struct snd_pcm_substream *substream, | ||
| 425 | struct snd_pcm_hw_params *params, | ||
| 426 | struct snd_soc_dai *dai) | ||
| 427 | { | ||
| 428 | snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); | ||
| 429 | memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); | ||
| 430 | return 0; | ||
| 431 | } | ||
| 432 | |||
| 433 | static int sst_media_hw_free(struct snd_pcm_substream *substream, | ||
| 434 | struct snd_soc_dai *dai) | ||
| 435 | { | ||
| 436 | return snd_pcm_lib_free_pages(substream); | ||
| 437 | } | ||
| 438 | |||
| 439 | static struct snd_soc_dai_ops sst_media_dai_ops = { | ||
| 440 | .startup = sst_media_open, | ||
| 441 | .shutdown = sst_media_close, | ||
| 442 | .prepare = sst_media_prepare, | ||
| 443 | .hw_params = sst_media_hw_params, | ||
| 444 | .hw_free = sst_media_hw_free, | ||
| 445 | }; | ||
| 446 | |||
| 447 | static int sst_platform_open(struct snd_pcm_substream *substream) | ||
| 448 | { | ||
| 449 | struct snd_pcm_runtime *runtime; | ||
| 450 | |||
| 451 | if (substream->pcm->internal) | ||
| 452 | return 0; | ||
| 453 | |||
| 454 | runtime = substream->runtime; | ||
| 455 | runtime->hw = sst_platform_pcm_hw; | ||
| 456 | return 0; | ||
| 457 | } | ||
| 458 | |||
| 319 | static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream, | 459 | static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream, |
| 320 | int cmd) | 460 | int cmd) |
| 321 | { | 461 | { |
| @@ -331,7 +471,7 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream, | |||
| 331 | pr_debug("sst: Trigger Start\n"); | 471 | pr_debug("sst: Trigger Start\n"); |
| 332 | str_cmd = SST_SND_START; | 472 | str_cmd = SST_SND_START; |
| 333 | status = SST_PLATFORM_RUNNING; | 473 | status = SST_PLATFORM_RUNNING; |
| 334 | stream->stream_info.mad_substream = substream; | 474 | stream->stream_info.arg = substream; |
| 335 | break; | 475 | break; |
| 336 | case SNDRV_PCM_TRIGGER_STOP: | 476 | case SNDRV_PCM_TRIGGER_STOP: |
| 337 | pr_debug("sst: in stop\n"); | 477 | pr_debug("sst: in stop\n"); |
| @@ -377,32 +517,15 @@ static snd_pcm_uframes_t sst_platform_pcm_pointer | |||
| 377 | pr_err("sst: error code = %d\n", ret_val); | 517 | pr_err("sst: error code = %d\n", ret_val); |
| 378 | return ret_val; | 518 | return ret_val; |
| 379 | } | 519 | } |
| 380 | return stream->stream_info.buffer_ptr; | 520 | substream->runtime->delay = str_info->pcm_delay; |
| 381 | } | 521 | return str_info->buffer_ptr; |
| 382 | |||
| 383 | static int sst_platform_pcm_hw_params(struct snd_pcm_substream *substream, | ||
| 384 | struct snd_pcm_hw_params *params) | ||
| 385 | { | ||
| 386 | snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); | ||
| 387 | memset(substream->runtime->dma_area, 0, params_buffer_bytes(params)); | ||
| 388 | |||
| 389 | return 0; | ||
| 390 | } | ||
| 391 | |||
| 392 | static int sst_platform_pcm_hw_free(struct snd_pcm_substream *substream) | ||
| 393 | { | ||
| 394 | return snd_pcm_lib_free_pages(substream); | ||
| 395 | } | 522 | } |
| 396 | 523 | ||
| 397 | static struct snd_pcm_ops sst_platform_ops = { | 524 | static struct snd_pcm_ops sst_platform_ops = { |
| 398 | .open = sst_platform_open, | 525 | .open = sst_platform_open, |
| 399 | .close = sst_platform_close, | ||
| 400 | .ioctl = snd_pcm_lib_ioctl, | 526 | .ioctl = snd_pcm_lib_ioctl, |
| 401 | .prepare = sst_platform_pcm_prepare, | ||
| 402 | .trigger = sst_platform_pcm_trigger, | 527 | .trigger = sst_platform_pcm_trigger, |
| 403 | .pointer = sst_platform_pcm_pointer, | 528 | .pointer = sst_platform_pcm_pointer, |
| 404 | .hw_params = sst_platform_pcm_hw_params, | ||
| 405 | .hw_free = sst_platform_pcm_hw_free, | ||
| 406 | }; | 529 | }; |
| 407 | 530 | ||
| 408 | static void sst_pcm_free(struct snd_pcm *pcm) | 531 | static void sst_pcm_free(struct snd_pcm *pcm) |
| @@ -413,15 +536,15 @@ static void sst_pcm_free(struct snd_pcm *pcm) | |||
| 413 | 536 | ||
| 414 | static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) | 537 | static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd) |
| 415 | { | 538 | { |
| 539 | struct snd_soc_dai *dai = rtd->cpu_dai; | ||
| 416 | struct snd_pcm *pcm = rtd->pcm; | 540 | struct snd_pcm *pcm = rtd->pcm; |
| 417 | int retval = 0; | 541 | int retval = 0; |
| 418 | 542 | ||
| 419 | pr_debug("sst_pcm_new called\n"); | 543 | if (dai->driver->playback.channels_min || |
| 420 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream || | 544 | dai->driver->capture.channels_min) { |
| 421 | pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
| 422 | retval = snd_pcm_lib_preallocate_pages_for_all(pcm, | 545 | retval = snd_pcm_lib_preallocate_pages_for_all(pcm, |
| 423 | SNDRV_DMA_TYPE_CONTINUOUS, | 546 | SNDRV_DMA_TYPE_CONTINUOUS, |
| 424 | snd_dma_continuous_data(GFP_KERNEL), | 547 | snd_dma_continuous_data(GFP_DMA), |
| 425 | SST_MIN_BUFFER, SST_MAX_BUFFER); | 548 | SST_MIN_BUFFER, SST_MAX_BUFFER); |
| 426 | if (retval) { | 549 | if (retval) { |
| 427 | pr_err("dma buffer allocationf fail\n"); | 550 | pr_err("dma buffer allocationf fail\n"); |
| @@ -445,10 +568,28 @@ static const struct snd_soc_component_driver sst_component = { | |||
| 445 | 568 | ||
| 446 | static int sst_platform_probe(struct platform_device *pdev) | 569 | static int sst_platform_probe(struct platform_device *pdev) |
| 447 | { | 570 | { |
| 571 | struct sst_data *drv; | ||
| 448 | int ret; | 572 | int ret; |
| 573 | struct sst_platform_data *pdata; | ||
| 574 | |||
| 575 | drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL); | ||
| 576 | if (drv == NULL) { | ||
| 577 | pr_err("kzalloc failed\n"); | ||
| 578 | return -ENOMEM; | ||
| 579 | } | ||
| 580 | |||
| 581 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | ||
| 582 | if (pdata == NULL) { | ||
| 583 | pr_err("kzalloc failed for pdata\n"); | ||
| 584 | return -ENOMEM; | ||
| 585 | } | ||
| 586 | |||
| 587 | pdata->pdev_strm_map = dpcm_strm_map; | ||
| 588 | pdata->strm_map_size = ARRAY_SIZE(dpcm_strm_map); | ||
| 589 | drv->pdata = pdata; | ||
| 590 | mutex_init(&drv->lock); | ||
| 591 | dev_set_drvdata(&pdev->dev, drv); | ||
| 449 | 592 | ||
| 450 | pr_debug("sst_platform_probe called\n"); | ||
| 451 | sst = NULL; | ||
| 452 | ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); | 593 | ret = snd_soc_register_platform(&pdev->dev, &sst_soc_platform_drv); |
| 453 | if (ret) { | 594 | if (ret) { |
| 454 | pr_err("registering soc platform failed\n"); | 595 | pr_err("registering soc platform failed\n"); |
diff --git a/sound/soc/intel/sst-mfld-platform.h b/sound/soc/intel/sst-mfld-platform.h index 6c5e7dc49e3c..6c6a42c08e24 100644 --- a/sound/soc/intel/sst-mfld-platform.h +++ b/sound/soc/intel/sst-mfld-platform.h | |||
| @@ -39,9 +39,10 @@ extern struct sst_device *sst; | |||
| 39 | 39 | ||
| 40 | struct pcm_stream_info { | 40 | struct pcm_stream_info { |
| 41 | int str_id; | 41 | int str_id; |
| 42 | void *mad_substream; | 42 | void *arg; |
| 43 | void (*period_elapsed) (void *mad_substream); | 43 | void (*period_elapsed) (void *arg); |
| 44 | unsigned long long buffer_ptr; | 44 | unsigned long long buffer_ptr; |
| 45 | unsigned long long pcm_delay; | ||
| 45 | int sfreq; | 46 | int sfreq; |
| 46 | }; | 47 | }; |
| 47 | 48 | ||
| @@ -62,7 +63,9 @@ enum sst_controls { | |||
| 62 | SST_SND_BUFFER_POINTER = 0x05, | 63 | SST_SND_BUFFER_POINTER = 0x05, |
| 63 | SST_SND_STREAM_INIT = 0x06, | 64 | SST_SND_STREAM_INIT = 0x06, |
| 64 | SST_SND_START = 0x07, | 65 | SST_SND_START = 0x07, |
| 65 | SST_MAX_CONTROLS = 0x07, | 66 | SST_SET_BYTE_STREAM = 0x100A, |
| 67 | SST_GET_BYTE_STREAM = 0x100B, | ||
| 68 | SST_MAX_CONTROLS = SST_GET_BYTE_STREAM, | ||
| 66 | }; | 69 | }; |
| 67 | 70 | ||
| 68 | enum sst_stream_ops { | 71 | enum sst_stream_ops { |
| @@ -124,8 +127,9 @@ struct compress_sst_ops { | |||
| 124 | }; | 127 | }; |
| 125 | 128 | ||
| 126 | struct sst_ops { | 129 | struct sst_ops { |
| 127 | int (*open) (struct sst_stream_params *str_param); | 130 | int (*open) (struct snd_sst_params *str_param); |
| 128 | int (*device_control) (int cmd, void *arg); | 131 | int (*device_control) (int cmd, void *arg); |
| 132 | int (*set_generic_params)(enum sst_controls cmd, void *arg); | ||
| 129 | int (*close) (unsigned int str_id); | 133 | int (*close) (unsigned int str_id); |
| 130 | }; | 134 | }; |
| 131 | 135 | ||
| @@ -143,10 +147,27 @@ struct sst_device { | |||
| 143 | char *name; | 147 | char *name; |
| 144 | struct device *dev; | 148 | struct device *dev; |
| 145 | struct sst_ops *ops; | 149 | struct sst_ops *ops; |
| 150 | struct platform_device *pdev; | ||
| 146 | struct compress_sst_ops *compr_ops; | 151 | struct compress_sst_ops *compr_ops; |
| 147 | }; | 152 | }; |
| 148 | 153 | ||
| 154 | struct sst_data; | ||
| 149 | void sst_set_stream_status(struct sst_runtime_stream *stream, int state); | 155 | void sst_set_stream_status(struct sst_runtime_stream *stream, int state); |
| 156 | int sst_fill_stream_params(void *substream, const struct sst_data *ctx, | ||
| 157 | struct snd_sst_params *str_params, bool is_compress); | ||
| 158 | |||
| 159 | struct sst_algo_int_control_v2 { | ||
| 160 | struct soc_mixer_control mc; | ||
| 161 | u16 module_id; /* module identifieer */ | ||
| 162 | u16 pipe_id; /* location info: pipe_id + instance_id */ | ||
| 163 | u16 instance_id; | ||
| 164 | unsigned int value; /* Value received is stored here */ | ||
| 165 | }; | ||
| 166 | struct sst_data { | ||
| 167 | struct platform_device *pdev; | ||
| 168 | struct sst_platform_data *pdata; | ||
| 169 | struct mutex lock; | ||
| 170 | }; | ||
| 150 | int sst_register_dsp(struct sst_device *sst); | 171 | int sst_register_dsp(struct sst_device *sst); |
| 151 | int sst_unregister_dsp(struct sst_device *sst); | 172 | int sst_unregister_dsp(struct sst_device *sst); |
| 152 | #endif | 173 | #endif |
diff --git a/sound/soc/kirkwood/Kconfig b/sound/soc/kirkwood/Kconfig index 06f4e8aa93ae..132bb83f8e99 100644 --- a/sound/soc/kirkwood/Kconfig +++ b/sound/soc/kirkwood/Kconfig | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | config SND_KIRKWOOD_SOC | 1 | config SND_KIRKWOOD_SOC |
| 2 | tristate "SoC Audio for the Marvell Kirkwood and Dove chips" | 2 | tristate "SoC Audio for the Marvell Kirkwood and Dove chips" |
| 3 | depends on ARCH_KIRKWOOD || ARCH_DOVE || ARCH_MVEBU || MACH_KIRKWOOD || COMPILE_TEST | 3 | depends on ARCH_DOVE || ARCH_MVEBU || COMPILE_TEST |
| 4 | help | 4 | help |
| 5 | Say Y or M if you want to add support for codecs attached to | 5 | Say Y or M if you want to add support for codecs attached to |
| 6 | the Kirkwood I2S interface. You will also need to select the | 6 | the Kirkwood I2S interface. You will also need to select the |
| @@ -15,20 +15,3 @@ config SND_KIRKWOOD_SOC_ARMADA370_DB | |||
| 15 | Say Y if you want to add support for SoC audio on | 15 | Say Y if you want to add support for SoC audio on |
| 16 | the Armada 370 Development Board. | 16 | the Armada 370 Development Board. |
| 17 | 17 | ||
| 18 | config SND_KIRKWOOD_SOC_OPENRD | ||
| 19 | tristate "SoC Audio support for Kirkwood Openrd Client" | ||
| 20 | depends on SND_KIRKWOOD_SOC && (MACH_OPENRD_CLIENT || MACH_OPENRD_ULTIMATE || COMPILE_TEST) | ||
| 21 | depends on I2C | ||
| 22 | select SND_SOC_CS42L51 | ||
| 23 | help | ||
| 24 | Say Y if you want to add support for SoC audio on | ||
| 25 | Openrd Client. | ||
| 26 | |||
| 27 | config SND_KIRKWOOD_SOC_T5325 | ||
| 28 | tristate "SoC Audio support for HP t5325" | ||
| 29 | depends on SND_KIRKWOOD_SOC && (MACH_T5325 || COMPILE_TEST) && I2C | ||
| 30 | select SND_SOC_ALC5623 | ||
| 31 | help | ||
| 32 | Say Y if you want to add support for SoC audio on | ||
| 33 | the HP t5325 thin client. | ||
| 34 | |||
diff --git a/sound/soc/kirkwood/Makefile b/sound/soc/kirkwood/Makefile index 7c1d8fe09e6b..c36b03d8006c 100644 --- a/sound/soc/kirkwood/Makefile +++ b/sound/soc/kirkwood/Makefile | |||
| @@ -2,10 +2,6 @@ snd-soc-kirkwood-objs := kirkwood-dma.o kirkwood-i2s.o | |||
| 2 | 2 | ||
| 3 | obj-$(CONFIG_SND_KIRKWOOD_SOC) += snd-soc-kirkwood.o | 3 | obj-$(CONFIG_SND_KIRKWOOD_SOC) += snd-soc-kirkwood.o |
| 4 | 4 | ||
| 5 | snd-soc-openrd-objs := kirkwood-openrd.o | ||
| 6 | snd-soc-t5325-objs := kirkwood-t5325.o | ||
| 7 | snd-soc-armada-370-db-objs := armada-370-db.o | 5 | snd-soc-armada-370-db-objs := armada-370-db.o |
| 8 | 6 | ||
| 9 | obj-$(CONFIG_SND_KIRKWOOD_SOC_ARMADA370_DB) += snd-soc-armada-370-db.o | 7 | obj-$(CONFIG_SND_KIRKWOOD_SOC_ARMADA370_DB) += snd-soc-armada-370-db.o |
| 10 | obj-$(CONFIG_SND_KIRKWOOD_SOC_OPENRD) += snd-soc-openrd.o | ||
| 11 | obj-$(CONFIG_SND_KIRKWOOD_SOC_T5325) += snd-soc-t5325.o | ||
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index aac22fccdcdc..4cf2245950d7 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c | |||
| @@ -28,11 +28,12 @@ static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs) | |||
| 28 | } | 28 | } |
| 29 | 29 | ||
| 30 | static struct snd_pcm_hardware kirkwood_dma_snd_hw = { | 30 | static struct snd_pcm_hardware kirkwood_dma_snd_hw = { |
| 31 | .info = (SNDRV_PCM_INFO_INTERLEAVED | | 31 | .info = SNDRV_PCM_INFO_INTERLEAVED | |
| 32 | SNDRV_PCM_INFO_MMAP | | 32 | SNDRV_PCM_INFO_MMAP | |
| 33 | SNDRV_PCM_INFO_MMAP_VALID | | 33 | SNDRV_PCM_INFO_MMAP_VALID | |
| 34 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | 34 | SNDRV_PCM_INFO_BLOCK_TRANSFER | |
| 35 | SNDRV_PCM_INFO_PAUSE), | 35 | SNDRV_PCM_INFO_PAUSE | |
| 36 | SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, | ||
| 36 | .buffer_bytes_max = KIRKWOOD_SND_MAX_BUFFER_BYTES, | 37 | .buffer_bytes_max = KIRKWOOD_SND_MAX_BUFFER_BYTES, |
| 37 | .period_bytes_min = KIRKWOOD_SND_MIN_PERIOD_BYTES, | 38 | .period_bytes_min = KIRKWOOD_SND_MIN_PERIOD_BYTES, |
| 38 | .period_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES, | 39 | .period_bytes_max = KIRKWOOD_SND_MAX_PERIOD_BYTES, |
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 9f842222e798..0704cd6d2314 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c | |||
| @@ -212,7 +212,8 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 212 | KIRKWOOD_PLAYCTL_SIZE_MASK); | 212 | KIRKWOOD_PLAYCTL_SIZE_MASK); |
| 213 | priv->ctl_play |= ctl_play; | 213 | priv->ctl_play |= ctl_play; |
| 214 | } else { | 214 | } else { |
| 215 | priv->ctl_rec &= ~KIRKWOOD_RECCTL_SIZE_MASK; | 215 | priv->ctl_rec &= ~(KIRKWOOD_RECCTL_ENABLE_MASK | |
| 216 | KIRKWOOD_RECCTL_SIZE_MASK); | ||
| 216 | priv->ctl_rec |= ctl_rec; | 217 | priv->ctl_rec |= ctl_rec; |
| 217 | } | 218 | } |
| 218 | 219 | ||
| @@ -221,14 +222,24 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 221 | return 0; | 222 | return 0; |
| 222 | } | 223 | } |
| 223 | 224 | ||
| 225 | static unsigned kirkwood_i2s_play_mute(unsigned ctl) | ||
| 226 | { | ||
| 227 | if (!(ctl & KIRKWOOD_PLAYCTL_I2S_EN)) | ||
| 228 | ctl |= KIRKWOOD_PLAYCTL_I2S_MUTE; | ||
| 229 | if (!(ctl & KIRKWOOD_PLAYCTL_SPDIF_EN)) | ||
| 230 | ctl |= KIRKWOOD_PLAYCTL_SPDIF_MUTE; | ||
| 231 | return ctl; | ||
| 232 | } | ||
| 233 | |||
| 224 | static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | 234 | static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, |
| 225 | int cmd, struct snd_soc_dai *dai) | 235 | int cmd, struct snd_soc_dai *dai) |
| 226 | { | 236 | { |
| 237 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 227 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); | 238 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); |
| 228 | uint32_t ctl, value; | 239 | uint32_t ctl, value; |
| 229 | 240 | ||
| 230 | ctl = readl(priv->io + KIRKWOOD_PLAYCTL); | 241 | ctl = readl(priv->io + KIRKWOOD_PLAYCTL); |
| 231 | if (ctl & KIRKWOOD_PLAYCTL_PAUSE) { | 242 | if ((ctl & KIRKWOOD_PLAYCTL_ENABLE_MASK) == 0) { |
| 232 | unsigned timeout = 5000; | 243 | unsigned timeout = 5000; |
| 233 | /* | 244 | /* |
| 234 | * The Armada510 spec says that if we enter pause mode, the | 245 | * The Armada510 spec says that if we enter pause mode, the |
| @@ -256,14 +267,16 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | |||
| 256 | ctl &= ~KIRKWOOD_PLAYCTL_SPDIF_EN; /* i2s */ | 267 | ctl &= ~KIRKWOOD_PLAYCTL_SPDIF_EN; /* i2s */ |
| 257 | else | 268 | else |
| 258 | ctl &= ~KIRKWOOD_PLAYCTL_I2S_EN; /* spdif */ | 269 | ctl &= ~KIRKWOOD_PLAYCTL_I2S_EN; /* spdif */ |
| 259 | 270 | ctl = kirkwood_i2s_play_mute(ctl); | |
| 260 | value = ctl & ~KIRKWOOD_PLAYCTL_ENABLE_MASK; | 271 | value = ctl & ~KIRKWOOD_PLAYCTL_ENABLE_MASK; |
| 261 | writel(value, priv->io + KIRKWOOD_PLAYCTL); | 272 | writel(value, priv->io + KIRKWOOD_PLAYCTL); |
| 262 | 273 | ||
| 263 | /* enable interrupts */ | 274 | /* enable interrupts */ |
| 264 | value = readl(priv->io + KIRKWOOD_INT_MASK); | 275 | if (!runtime->no_period_wakeup) { |
| 265 | value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES; | 276 | value = readl(priv->io + KIRKWOOD_INT_MASK); |
| 266 | writel(value, priv->io + KIRKWOOD_INT_MASK); | 277 | value |= KIRKWOOD_INT_CAUSE_PLAY_BYTES; |
| 278 | writel(value, priv->io + KIRKWOOD_INT_MASK); | ||
| 279 | } | ||
| 267 | 280 | ||
| 268 | /* enable playback */ | 281 | /* enable playback */ |
| 269 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); | 282 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); |
| @@ -295,6 +308,7 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | |||
| 295 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 308 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 296 | ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | | 309 | ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | |
| 297 | KIRKWOOD_PLAYCTL_SPDIF_MUTE); | 310 | KIRKWOOD_PLAYCTL_SPDIF_MUTE); |
| 311 | ctl = kirkwood_i2s_play_mute(ctl); | ||
| 298 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); | 312 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); |
| 299 | break; | 313 | break; |
| 300 | 314 | ||
| @@ -322,8 +336,7 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream, | |||
| 322 | else | 336 | else |
| 323 | ctl &= ~KIRKWOOD_RECCTL_I2S_EN; /* spdif */ | 337 | ctl &= ~KIRKWOOD_RECCTL_I2S_EN; /* spdif */ |
| 324 | 338 | ||
| 325 | value = ctl & ~(KIRKWOOD_RECCTL_I2S_EN | | 339 | value = ctl & ~KIRKWOOD_RECCTL_ENABLE_MASK; |
| 326 | KIRKWOOD_RECCTL_SPDIF_EN); | ||
| 327 | writel(value, priv->io + KIRKWOOD_RECCTL); | 340 | writel(value, priv->io + KIRKWOOD_RECCTL); |
| 328 | 341 | ||
| 329 | /* enable interrupts */ | 342 | /* enable interrupts */ |
| @@ -347,7 +360,7 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream, | |||
| 347 | 360 | ||
| 348 | /* disable all records */ | 361 | /* disable all records */ |
| 349 | value = readl(priv->io + KIRKWOOD_RECCTL); | 362 | value = readl(priv->io + KIRKWOOD_RECCTL); |
| 350 | value &= ~(KIRKWOOD_RECCTL_I2S_EN | KIRKWOOD_RECCTL_SPDIF_EN); | 363 | value &= ~KIRKWOOD_RECCTL_ENABLE_MASK; |
| 351 | writel(value, priv->io + KIRKWOOD_RECCTL); | 364 | writel(value, priv->io + KIRKWOOD_RECCTL); |
| 352 | break; | 365 | break; |
| 353 | 366 | ||
| @@ -411,7 +424,7 @@ static int kirkwood_i2s_init(struct kirkwood_dma_data *priv) | |||
| 411 | writel(value, priv->io + KIRKWOOD_PLAYCTL); | 424 | writel(value, priv->io + KIRKWOOD_PLAYCTL); |
| 412 | 425 | ||
| 413 | value = readl(priv->io + KIRKWOOD_RECCTL); | 426 | value = readl(priv->io + KIRKWOOD_RECCTL); |
| 414 | value &= ~(KIRKWOOD_RECCTL_I2S_EN | KIRKWOOD_RECCTL_SPDIF_EN); | 427 | value &= ~KIRKWOOD_RECCTL_ENABLE_MASK; |
| 415 | writel(value, priv->io + KIRKWOOD_RECCTL); | 428 | writel(value, priv->io + KIRKWOOD_RECCTL); |
| 416 | 429 | ||
| 417 | return 0; | 430 | return 0; |
diff --git a/sound/soc/kirkwood/kirkwood-openrd.c b/sound/soc/kirkwood/kirkwood-openrd.c deleted file mode 100644 index 65f2a5b9ec3b..000000000000 --- a/sound/soc/kirkwood/kirkwood-openrd.c +++ /dev/null | |||
| @@ -1,109 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * kirkwood-openrd.c | ||
| 3 | * | ||
| 4 | * (c) 2010 Arnaud Patard <apatard@mandriva.com> | ||
| 5 | * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org> | ||
| 6 | * | ||
| 7 | * This program is free software; you can redistribute it and/or modify it | ||
| 8 | * under the terms of the GNU General Public License as published by the | ||
| 9 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 10 | * option) any later version. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/module.h> | ||
| 14 | #include <linux/moduleparam.h> | ||
| 15 | #include <linux/interrupt.h> | ||
| 16 | #include <linux/platform_device.h> | ||
| 17 | #include <linux/slab.h> | ||
| 18 | #include <sound/soc.h> | ||
| 19 | #include <linux/platform_data/asoc-kirkwood.h> | ||
| 20 | #include "../codecs/cs42l51.h" | ||
| 21 | |||
| 22 | static int openrd_client_hw_params(struct snd_pcm_substream *substream, | ||
| 23 | struct snd_pcm_hw_params *params) | ||
| 24 | { | ||
| 25 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 26 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
| 27 | unsigned int freq; | ||
| 28 | |||
| 29 | switch (params_rate(params)) { | ||
| 30 | default: | ||
| 31 | case 44100: | ||
| 32 | freq = 11289600; | ||
| 33 | break; | ||
| 34 | case 48000: | ||
| 35 | freq = 12288000; | ||
| 36 | break; | ||
| 37 | case 96000: | ||
| 38 | freq = 24576000; | ||
| 39 | break; | ||
| 40 | } | ||
| 41 | |||
| 42 | return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN); | ||
| 43 | |||
| 44 | } | ||
| 45 | |||
| 46 | static struct snd_soc_ops openrd_client_ops = { | ||
| 47 | .hw_params = openrd_client_hw_params, | ||
| 48 | }; | ||
| 49 | |||
| 50 | |||
| 51 | static struct snd_soc_dai_link openrd_client_dai[] = { | ||
| 52 | { | ||
| 53 | .name = "CS42L51", | ||
| 54 | .stream_name = "CS42L51 HiFi", | ||
| 55 | .cpu_dai_name = "i2s", | ||
| 56 | .platform_name = "mvebu-audio", | ||
| 57 | .codec_dai_name = "cs42l51-hifi", | ||
| 58 | .codec_name = "cs42l51-codec.0-004a", | ||
| 59 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, | ||
| 60 | .ops = &openrd_client_ops, | ||
| 61 | }, | ||
| 62 | }; | ||
| 63 | |||
| 64 | |||
| 65 | static struct snd_soc_card openrd_client = { | ||
| 66 | .name = "OpenRD Client", | ||
| 67 | .owner = THIS_MODULE, | ||
| 68 | .dai_link = openrd_client_dai, | ||
| 69 | .num_links = ARRAY_SIZE(openrd_client_dai), | ||
| 70 | }; | ||
| 71 | |||
| 72 | static int openrd_probe(struct platform_device *pdev) | ||
| 73 | { | ||
| 74 | struct snd_soc_card *card = &openrd_client; | ||
| 75 | int ret; | ||
| 76 | |||
| 77 | card->dev = &pdev->dev; | ||
| 78 | |||
| 79 | ret = snd_soc_register_card(card); | ||
| 80 | if (ret) | ||
| 81 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | ||
| 82 | ret); | ||
| 83 | return ret; | ||
| 84 | } | ||
| 85 | |||
| 86 | static int openrd_remove(struct platform_device *pdev) | ||
| 87 | { | ||
| 88 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
| 89 | |||
| 90 | snd_soc_unregister_card(card); | ||
| 91 | return 0; | ||
| 92 | } | ||
| 93 | |||
| 94 | static struct platform_driver openrd_driver = { | ||
| 95 | .driver = { | ||
| 96 | .name = "openrd-client-audio", | ||
| 97 | .owner = THIS_MODULE, | ||
| 98 | }, | ||
| 99 | .probe = openrd_probe, | ||
| 100 | .remove = openrd_remove, | ||
| 101 | }; | ||
| 102 | |||
| 103 | module_platform_driver(openrd_driver); | ||
| 104 | |||
| 105 | /* Module information */ | ||
| 106 | MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); | ||
| 107 | MODULE_DESCRIPTION("ALSA SoC OpenRD Client"); | ||
| 108 | MODULE_LICENSE("GPL"); | ||
| 109 | MODULE_ALIAS("platform:openrd-client-audio"); | ||
diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c deleted file mode 100644 index 844b8415a011..000000000000 --- a/sound/soc/kirkwood/kirkwood-t5325.c +++ /dev/null | |||
| @@ -1,116 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * kirkwood-t5325.c | ||
| 3 | * | ||
| 4 | * (c) 2010 Arnaud Patard <arnaud.patard@rtp-net.org> | ||
| 5 | * | ||
| 6 | * This program is free software; you can redistribute it and/or modify it | ||
| 7 | * under the terms of the GNU General Public License as published by the | ||
| 8 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 9 | * option) any later version. | ||
| 10 | */ | ||
| 11 | |||
| 12 | #include <linux/module.h> | ||
| 13 | #include <linux/moduleparam.h> | ||
| 14 | #include <linux/interrupt.h> | ||
| 15 | #include <linux/platform_device.h> | ||
| 16 | #include <linux/slab.h> | ||
| 17 | #include <sound/soc.h> | ||
| 18 | #include <linux/platform_data/asoc-kirkwood.h> | ||
| 19 | #include "../codecs/alc5623.h" | ||
| 20 | |||
| 21 | static int t5325_hw_params(struct snd_pcm_substream *substream, | ||
| 22 | struct snd_pcm_hw_params *params) | ||
| 23 | { | ||
| 24 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 25 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
| 26 | unsigned int freq; | ||
| 27 | |||
| 28 | freq = params_rate(params) * 256; | ||
| 29 | |||
| 30 | return snd_soc_dai_set_sysclk(codec_dai, 0, freq, SND_SOC_CLOCK_IN); | ||
| 31 | |||
| 32 | } | ||
| 33 | |||
| 34 | static struct snd_soc_ops t5325_ops = { | ||
| 35 | .hw_params = t5325_hw_params, | ||
| 36 | }; | ||
| 37 | |||
| 38 | static const struct snd_soc_dapm_widget t5325_dapm_widgets[] = { | ||
| 39 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | ||
| 40 | SND_SOC_DAPM_SPK("Speaker", NULL), | ||
| 41 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | ||
| 42 | }; | ||
| 43 | |||
| 44 | static const struct snd_soc_dapm_route t5325_route[] = { | ||
| 45 | { "Headphone Jack", NULL, "HPL" }, | ||
| 46 | { "Headphone Jack", NULL, "HPR" }, | ||
| 47 | |||
| 48 | {"Speaker", NULL, "SPKOUT"}, | ||
| 49 | {"Speaker", NULL, "SPKOUTN"}, | ||
| 50 | |||
| 51 | { "MIC1", NULL, "Mic Jack" }, | ||
| 52 | { "MIC2", NULL, "Mic Jack" }, | ||
| 53 | }; | ||
| 54 | |||
| 55 | static struct snd_soc_dai_link t5325_dai[] = { | ||
| 56 | { | ||
| 57 | .name = "ALC5621", | ||
| 58 | .stream_name = "ALC5621 HiFi", | ||
| 59 | .cpu_dai_name = "i2s", | ||
| 60 | .platform_name = "mvebu-audio", | ||
| 61 | .codec_dai_name = "alc5621-hifi", | ||
| 62 | .codec_name = "alc562x-codec.0-001a", | ||
| 63 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_CBS_CFS, | ||
| 64 | .ops = &t5325_ops, | ||
| 65 | }, | ||
| 66 | }; | ||
| 67 | |||
| 68 | static struct snd_soc_card t5325 = { | ||
| 69 | .name = "t5325", | ||
| 70 | .owner = THIS_MODULE, | ||
| 71 | .dai_link = t5325_dai, | ||
| 72 | .num_links = ARRAY_SIZE(t5325_dai), | ||
| 73 | |||
| 74 | .dapm_widgets = t5325_dapm_widgets, | ||
| 75 | .num_dapm_widgets = ARRAY_SIZE(t5325_dapm_widgets), | ||
| 76 | .dapm_routes = t5325_route, | ||
| 77 | .num_dapm_routes = ARRAY_SIZE(t5325_route), | ||
| 78 | }; | ||
| 79 | |||
| 80 | static int t5325_probe(struct platform_device *pdev) | ||
| 81 | { | ||
| 82 | struct snd_soc_card *card = &t5325; | ||
| 83 | int ret; | ||
| 84 | |||
| 85 | card->dev = &pdev->dev; | ||
| 86 | |||
| 87 | ret = snd_soc_register_card(card); | ||
| 88 | if (ret) | ||
| 89 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | ||
| 90 | ret); | ||
| 91 | return ret; | ||
| 92 | } | ||
| 93 | |||
| 94 | static int t5325_remove(struct platform_device *pdev) | ||
| 95 | { | ||
| 96 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
| 97 | |||
| 98 | snd_soc_unregister_card(card); | ||
| 99 | return 0; | ||
| 100 | } | ||
| 101 | |||
| 102 | static struct platform_driver t5325_driver = { | ||
| 103 | .driver = { | ||
| 104 | .name = "t5325-audio", | ||
| 105 | .owner = THIS_MODULE, | ||
| 106 | }, | ||
| 107 | .probe = t5325_probe, | ||
| 108 | .remove = t5325_remove, | ||
| 109 | }; | ||
| 110 | |||
| 111 | module_platform_driver(t5325_driver); | ||
| 112 | |||
| 113 | MODULE_AUTHOR("Arnaud Patard <arnaud.patard@rtp-net.org>"); | ||
| 114 | MODULE_DESCRIPTION("ALSA SoC t5325 audio client"); | ||
| 115 | MODULE_LICENSE("GPL"); | ||
| 116 | MODULE_ALIAS("platform:t5325-audio"); | ||
diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index bf23afbba1d7..90e32a781424 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h | |||
| @@ -38,6 +38,9 @@ | |||
| 38 | #define KIRKWOOD_RECCTL_SIZE_24 (1<<0) | 38 | #define KIRKWOOD_RECCTL_SIZE_24 (1<<0) |
| 39 | #define KIRKWOOD_RECCTL_SIZE_32 (0<<0) | 39 | #define KIRKWOOD_RECCTL_SIZE_32 (0<<0) |
| 40 | 40 | ||
| 41 | #define KIRKWOOD_RECCTL_ENABLE_MASK (KIRKWOOD_RECCTL_SPDIF_EN | \ | ||
| 42 | KIRKWOOD_RECCTL_I2S_EN) | ||
| 43 | |||
| 41 | #define KIRKWOOD_REC_BUF_ADDR 0x1004 | 44 | #define KIRKWOOD_REC_BUF_ADDR 0x1004 |
| 42 | #define KIRKWOOD_REC_BUF_SIZE 0x1008 | 45 | #define KIRKWOOD_REC_BUF_SIZE 0x1008 |
| 43 | #define KIRKWOOD_REC_BYTE_COUNT 0x100C | 46 | #define KIRKWOOD_REC_BYTE_COUNT 0x100C |
| @@ -121,9 +124,9 @@ | |||
| 121 | 124 | ||
| 122 | /* Theses values come from the marvell alsa driver */ | 125 | /* Theses values come from the marvell alsa driver */ |
| 123 | /* need to find where they come from */ | 126 | /* need to find where they come from */ |
| 124 | #define KIRKWOOD_SND_MIN_PERIODS 8 | 127 | #define KIRKWOOD_SND_MIN_PERIODS 2 |
| 125 | #define KIRKWOOD_SND_MAX_PERIODS 16 | 128 | #define KIRKWOOD_SND_MAX_PERIODS 16 |
| 126 | #define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x800 | 129 | #define KIRKWOOD_SND_MIN_PERIOD_BYTES 256 |
| 127 | #define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x8000 | 130 | #define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x8000 |
| 128 | #define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \ | 131 | #define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \ |
| 129 | * KIRKWOOD_SND_MAX_PERIODS) | 132 | * KIRKWOOD_SND_MAX_PERIODS) |
diff --git a/sound/soc/omap/ams-delta.c b/sound/soc/omap/ams-delta.c index 0cc41f94de4e..8c9cc64a9dfb 100644 --- a/sound/soc/omap/ams-delta.c +++ b/sound/soc/omap/ams-delta.c | |||
| @@ -301,7 +301,7 @@ static int cx81801_open(struct tty_struct *tty) | |||
| 301 | static void cx81801_close(struct tty_struct *tty) | 301 | static void cx81801_close(struct tty_struct *tty) |
| 302 | { | 302 | { |
| 303 | struct snd_soc_codec *codec = tty->disc_data; | 303 | struct snd_soc_codec *codec = tty->disc_data; |
| 304 | struct snd_soc_dapm_context *dapm = &codec->card->dapm; | 304 | struct snd_soc_dapm_context *dapm = &codec->component.card->dapm; |
| 305 | 305 | ||
| 306 | del_timer_sync(&cx81801_timer); | 306 | del_timer_sync(&cx81801_timer); |
| 307 | 307 | ||
diff --git a/sound/soc/omap/omap-dmic.c b/sound/soc/omap/omap-dmic.c index 6925d7141215..0f34e28a3d55 100644 --- a/sound/soc/omap/omap-dmic.c +++ b/sound/soc/omap/omap-dmic.c | |||
| @@ -466,7 +466,7 @@ static int asoc_dmic_probe(struct platform_device *pdev) | |||
| 466 | 466 | ||
| 467 | mutex_init(&dmic->mutex); | 467 | mutex_init(&dmic->mutex); |
| 468 | 468 | ||
| 469 | dmic->fclk = clk_get(dmic->dev, "fck"); | 469 | dmic->fclk = devm_clk_get(dmic->dev, "fck"); |
| 470 | if (IS_ERR(dmic->fclk)) { | 470 | if (IS_ERR(dmic->fclk)) { |
| 471 | dev_err(dmic->dev, "cant get fck\n"); | 471 | dev_err(dmic->dev, "cant get fck\n"); |
| 472 | return -ENODEV; | 472 | return -ENODEV; |
| @@ -475,8 +475,7 @@ static int asoc_dmic_probe(struct platform_device *pdev) | |||
| 475 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma"); | 475 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dma"); |
| 476 | if (!res) { | 476 | if (!res) { |
| 477 | dev_err(dmic->dev, "invalid dma memory resource\n"); | 477 | dev_err(dmic->dev, "invalid dma memory resource\n"); |
| 478 | ret = -ENODEV; | 478 | return -ENODEV; |
| 479 | goto err_put_clk; | ||
| 480 | } | 479 | } |
| 481 | dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG; | 480 | dmic->dma_data.addr = res->start + OMAP_DMIC_DATA_REG; |
| 482 | 481 | ||
| @@ -484,34 +483,19 @@ static int asoc_dmic_probe(struct platform_device *pdev) | |||
| 484 | 483 | ||
| 485 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); | 484 | res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); |
| 486 | dmic->io_base = devm_ioremap_resource(&pdev->dev, res); | 485 | dmic->io_base = devm_ioremap_resource(&pdev->dev, res); |
| 487 | if (IS_ERR(dmic->io_base)) { | 486 | if (IS_ERR(dmic->io_base)) |
| 488 | ret = PTR_ERR(dmic->io_base); | 487 | return PTR_ERR(dmic->io_base); |
| 489 | goto err_put_clk; | ||
| 490 | } | ||
| 491 | 488 | ||
| 492 | 489 | ||
| 493 | ret = snd_soc_register_component(&pdev->dev, &omap_dmic_component, | 490 | ret = devm_snd_soc_register_component(&pdev->dev, |
| 494 | &omap_dmic_dai, 1); | 491 | &omap_dmic_component, |
| 492 | &omap_dmic_dai, 1); | ||
| 495 | if (ret) | 493 | if (ret) |
| 496 | goto err_put_clk; | 494 | return ret; |
| 497 | 495 | ||
| 498 | ret = omap_pcm_platform_register(&pdev->dev); | 496 | ret = omap_pcm_platform_register(&pdev->dev); |
| 499 | if (ret) | 497 | if (ret) |
| 500 | goto err_put_clk; | 498 | return ret; |
| 501 | |||
| 502 | return 0; | ||
| 503 | |||
| 504 | err_put_clk: | ||
| 505 | clk_put(dmic->fclk); | ||
| 506 | return ret; | ||
| 507 | } | ||
| 508 | |||
| 509 | static int asoc_dmic_remove(struct platform_device *pdev) | ||
| 510 | { | ||
| 511 | struct omap_dmic *dmic = platform_get_drvdata(pdev); | ||
| 512 | |||
| 513 | snd_soc_unregister_component(&pdev->dev); | ||
| 514 | clk_put(dmic->fclk); | ||
| 515 | 499 | ||
| 516 | return 0; | 500 | return 0; |
| 517 | } | 501 | } |
| @@ -529,7 +513,6 @@ static struct platform_driver asoc_dmic_driver = { | |||
| 529 | .of_match_table = omap_dmic_of_match, | 513 | .of_match_table = omap_dmic_of_match, |
| 530 | }, | 514 | }, |
| 531 | .probe = asoc_dmic_probe, | 515 | .probe = asoc_dmic_probe, |
| 532 | .remove = asoc_dmic_remove, | ||
| 533 | }; | 516 | }; |
| 534 | 517 | ||
| 535 | module_platform_driver(asoc_dmic_driver); | 518 | module_platform_driver(asoc_dmic_driver); |
diff --git a/sound/soc/omap/omap-mcbsp.c b/sound/soc/omap/omap-mcbsp.c index efe2cd699b77..bd3ef2a88be0 100644 --- a/sound/soc/omap/omap-mcbsp.c +++ b/sound/soc/omap/omap-mcbsp.c | |||
| @@ -805,8 +805,9 @@ static int asoc_mcbsp_probe(struct platform_device *pdev) | |||
| 805 | if (ret) | 805 | if (ret) |
| 806 | return ret; | 806 | return ret; |
| 807 | 807 | ||
| 808 | ret = snd_soc_register_component(&pdev->dev, &omap_mcbsp_component, | 808 | ret = devm_snd_soc_register_component(&pdev->dev, |
| 809 | &omap_mcbsp_dai, 1); | 809 | &omap_mcbsp_component, |
| 810 | &omap_mcbsp_dai, 1); | ||
| 810 | if (ret) | 811 | if (ret) |
| 811 | return ret; | 812 | return ret; |
| 812 | 813 | ||
| @@ -817,8 +818,6 @@ static int asoc_mcbsp_remove(struct platform_device *pdev) | |||
| 817 | { | 818 | { |
| 818 | struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); | 819 | struct omap_mcbsp *mcbsp = platform_get_drvdata(pdev); |
| 819 | 820 | ||
| 820 | snd_soc_unregister_component(&pdev->dev); | ||
| 821 | |||
| 822 | if (mcbsp->pdata->ops && mcbsp->pdata->ops->free) | 821 | if (mcbsp->pdata->ops && mcbsp->pdata->ops->free) |
| 823 | mcbsp->pdata->ops->free(mcbsp->id); | 822 | mcbsp->pdata->ops->free(mcbsp->id); |
| 824 | 823 | ||
diff --git a/sound/soc/omap/omap-pcm.c b/sound/soc/omap/omap-pcm.c index 8d809f8509c8..f4b05bc23e4b 100644 --- a/sound/soc/omap/omap-pcm.c +++ b/sound/soc/omap/omap-pcm.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include <sound/pcm_params.h> | 31 | #include <sound/pcm_params.h> |
| 32 | #include <sound/dmaengine_pcm.h> | 32 | #include <sound/dmaengine_pcm.h> |
| 33 | #include <sound/soc.h> | 33 | #include <sound/soc.h> |
| 34 | #include <sound/omap-pcm.h> | ||
| 34 | 35 | ||
| 35 | #ifdef CONFIG_ARCH_OMAP1 | 36 | #ifdef CONFIG_ARCH_OMAP1 |
| 36 | #define pcm_omap1510() cpu_is_omap1510() | 37 | #define pcm_omap1510() cpu_is_omap1510() |
diff --git a/sound/soc/pxa/pxa-ssp.c b/sound/soc/pxa/pxa-ssp.c index 199a8b377553..0109f6c2334e 100644 --- a/sound/soc/pxa/pxa-ssp.c +++ b/sound/soc/pxa/pxa-ssp.c | |||
| @@ -723,7 +723,8 @@ static int pxa_ssp_probe(struct snd_soc_dai *dai) | |||
| 723 | ssp_handle = of_parse_phandle(dev->of_node, "port", 0); | 723 | ssp_handle = of_parse_phandle(dev->of_node, "port", 0); |
| 724 | if (!ssp_handle) { | 724 | if (!ssp_handle) { |
| 725 | dev_err(dev, "unable to get 'port' phandle\n"); | 725 | dev_err(dev, "unable to get 'port' phandle\n"); |
| 726 | return -ENODEV; | 726 | ret = -ENODEV; |
| 727 | goto err_priv; | ||
| 727 | } | 728 | } |
| 728 | 729 | ||
| 729 | priv->ssp = pxa_ssp_request_of(ssp_handle, "SoC audio"); | 730 | priv->ssp = pxa_ssp_request_of(ssp_handle, "SoC audio"); |
diff --git a/sound/soc/rockchip/Kconfig b/sound/soc/rockchip/Kconfig new file mode 100644 index 000000000000..c196a466eef6 --- /dev/null +++ b/sound/soc/rockchip/Kconfig | |||
| @@ -0,0 +1,12 @@ | |||
| 1 | config SND_SOC_ROCKCHIP | ||
| 2 | tristate "ASoC support for Rockchip" | ||
| 3 | depends on COMPILE_TEST || ARCH_ROCKCHIP | ||
| 4 | select SND_SOC_GENERIC_DMAENGINE_PCM | ||
| 5 | select SND_ROCKCHIP_I2S | ||
| 6 | help | ||
| 7 | Say Y or M if you want to add support for codecs attached to | ||
| 8 | the Rockchip SoCs' Audio interfaces. You will also need to | ||
| 9 | select the audio interfaces to support below. | ||
| 10 | |||
| 11 | config SND_ROCKCHIP_I2S | ||
| 12 | tristate | ||
diff --git a/sound/soc/rockchip/Makefile b/sound/soc/rockchip/Makefile new file mode 100644 index 000000000000..1006418e1394 --- /dev/null +++ b/sound/soc/rockchip/Makefile | |||
| @@ -0,0 +1,4 @@ | |||
| 1 | # ROCKCHIP Platform Support | ||
| 2 | snd-soc-i2s-objs := rockchip_i2s.o | ||
| 3 | |||
| 4 | obj-$(CONFIG_SND_ROCKCHIP_I2S) += snd-soc-i2s.o | ||
diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c new file mode 100644 index 000000000000..8d8e4b59049f --- /dev/null +++ b/sound/soc/rockchip/rockchip_i2s.c | |||
| @@ -0,0 +1,529 @@ | |||
| 1 | /* sound/soc/rockchip/rockchip_i2s.c | ||
| 2 | * | ||
| 3 | * ALSA SoC Audio Layer - Rockchip I2S Controller driver | ||
| 4 | * | ||
| 5 | * Copyright (c) 2014 Rockchip Electronics Co. Ltd. | ||
| 6 | * Author: Jianqun <jay.xu@rock-chips.com> | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License version 2 as | ||
| 10 | * published by the Free Software Foundation. | ||
| 11 | */ | ||
| 12 | |||
| 13 | #include <linux/module.h> | ||
| 14 | #include <linux/delay.h> | ||
| 15 | #include <linux/of_gpio.h> | ||
| 16 | #include <linux/clk.h> | ||
| 17 | #include <linux/pm_runtime.h> | ||
| 18 | #include <linux/regmap.h> | ||
| 19 | #include <sound/pcm_params.h> | ||
| 20 | #include <sound/dmaengine_pcm.h> | ||
| 21 | |||
| 22 | #include "rockchip_i2s.h" | ||
| 23 | |||
| 24 | #define DRV_NAME "rockchip-i2s" | ||
| 25 | |||
| 26 | struct rk_i2s_dev { | ||
| 27 | struct device *dev; | ||
| 28 | |||
| 29 | struct clk *hclk; | ||
| 30 | struct clk *mclk; | ||
| 31 | |||
| 32 | struct snd_dmaengine_dai_dma_data capture_dma_data; | ||
| 33 | struct snd_dmaengine_dai_dma_data playback_dma_data; | ||
| 34 | |||
| 35 | struct regmap *regmap; | ||
| 36 | |||
| 37 | /* | ||
| 38 | * Used to indicate the tx/rx status. | ||
| 39 | * I2S controller hopes to start the tx and rx together, | ||
| 40 | * also to stop them when they are both try to stop. | ||
| 41 | */ | ||
| 42 | bool tx_start; | ||
| 43 | bool rx_start; | ||
| 44 | }; | ||
| 45 | |||
| 46 | static int i2s_runtime_suspend(struct device *dev) | ||
| 47 | { | ||
| 48 | struct rk_i2s_dev *i2s = dev_get_drvdata(dev); | ||
| 49 | |||
| 50 | clk_disable_unprepare(i2s->mclk); | ||
| 51 | |||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | |||
| 55 | static int i2s_runtime_resume(struct device *dev) | ||
| 56 | { | ||
| 57 | struct rk_i2s_dev *i2s = dev_get_drvdata(dev); | ||
| 58 | int ret; | ||
| 59 | |||
| 60 | ret = clk_prepare_enable(i2s->mclk); | ||
| 61 | if (ret) { | ||
| 62 | dev_err(i2s->dev, "clock enable failed %d\n", ret); | ||
| 63 | return ret; | ||
| 64 | } | ||
| 65 | |||
| 66 | return 0; | ||
| 67 | } | ||
| 68 | |||
| 69 | static inline struct rk_i2s_dev *to_info(struct snd_soc_dai *dai) | ||
| 70 | { | ||
| 71 | return snd_soc_dai_get_drvdata(dai); | ||
| 72 | } | ||
| 73 | |||
| 74 | static void rockchip_snd_txctrl(struct rk_i2s_dev *i2s, int on) | ||
| 75 | { | ||
| 76 | unsigned int val = 0; | ||
| 77 | int retry = 10; | ||
| 78 | |||
| 79 | if (on) { | ||
| 80 | regmap_update_bits(i2s->regmap, I2S_DMACR, | ||
| 81 | I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_ENABLE); | ||
| 82 | |||
| 83 | regmap_update_bits(i2s->regmap, I2S_XFER, | ||
| 84 | I2S_XFER_TXS_START | I2S_XFER_RXS_START, | ||
| 85 | I2S_XFER_TXS_START | I2S_XFER_RXS_START); | ||
| 86 | |||
| 87 | i2s->tx_start = true; | ||
| 88 | } else { | ||
| 89 | i2s->tx_start = false; | ||
| 90 | |||
| 91 | regmap_update_bits(i2s->regmap, I2S_DMACR, | ||
| 92 | I2S_DMACR_TDE_ENABLE, I2S_DMACR_TDE_DISABLE); | ||
| 93 | |||
| 94 | if (!i2s->rx_start) { | ||
| 95 | regmap_update_bits(i2s->regmap, I2S_XFER, | ||
| 96 | I2S_XFER_TXS_START | | ||
| 97 | I2S_XFER_RXS_START, | ||
| 98 | I2S_XFER_TXS_STOP | | ||
| 99 | I2S_XFER_RXS_STOP); | ||
| 100 | |||
| 101 | regmap_update_bits(i2s->regmap, I2S_CLR, | ||
| 102 | I2S_CLR_TXC | I2S_CLR_RXC, | ||
| 103 | I2S_CLR_TXC | I2S_CLR_RXC); | ||
| 104 | |||
| 105 | regmap_read(i2s->regmap, I2S_CLR, &val); | ||
| 106 | |||
| 107 | /* Should wait for clear operation to finish */ | ||
| 108 | while (val) { | ||
| 109 | regmap_read(i2s->regmap, I2S_CLR, &val); | ||
| 110 | retry--; | ||
| 111 | if (!retry) | ||
| 112 | dev_warn(i2s->dev, "fail to clear\n"); | ||
| 113 | } | ||
| 114 | } | ||
| 115 | } | ||
| 116 | } | ||
| 117 | |||
| 118 | static void rockchip_snd_rxctrl(struct rk_i2s_dev *i2s, int on) | ||
| 119 | { | ||
| 120 | unsigned int val = 0; | ||
| 121 | int retry = 10; | ||
| 122 | |||
| 123 | if (on) { | ||
| 124 | regmap_update_bits(i2s->regmap, I2S_DMACR, | ||
| 125 | I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_ENABLE); | ||
| 126 | |||
| 127 | regmap_update_bits(i2s->regmap, I2S_XFER, | ||
| 128 | I2S_XFER_TXS_START | I2S_XFER_RXS_START, | ||
| 129 | I2S_XFER_TXS_START | I2S_XFER_RXS_START); | ||
| 130 | |||
| 131 | i2s->rx_start = true; | ||
| 132 | } else { | ||
| 133 | i2s->rx_start = false; | ||
| 134 | |||
| 135 | regmap_update_bits(i2s->regmap, I2S_DMACR, | ||
| 136 | I2S_DMACR_RDE_ENABLE, I2S_DMACR_RDE_DISABLE); | ||
| 137 | |||
| 138 | if (!i2s->tx_start) { | ||
| 139 | regmap_update_bits(i2s->regmap, I2S_XFER, | ||
| 140 | I2S_XFER_TXS_START | | ||
| 141 | I2S_XFER_RXS_START, | ||
| 142 | I2S_XFER_TXS_STOP | | ||
| 143 | I2S_XFER_RXS_STOP); | ||
| 144 | |||
| 145 | regmap_update_bits(i2s->regmap, I2S_CLR, | ||
| 146 | I2S_CLR_TXC | I2S_CLR_RXC, | ||
| 147 | I2S_CLR_TXC | I2S_CLR_RXC); | ||
| 148 | |||
| 149 | regmap_read(i2s->regmap, I2S_CLR, &val); | ||
| 150 | |||
| 151 | /* Should wait for clear operation to finish */ | ||
| 152 | while (val) { | ||
| 153 | regmap_read(i2s->regmap, I2S_CLR, &val); | ||
| 154 | retry--; | ||
| 155 | if (!retry) | ||
| 156 | dev_warn(i2s->dev, "fail to clear\n"); | ||
| 157 | } | ||
| 158 | } | ||
| 159 | } | ||
| 160 | } | ||
| 161 | |||
| 162 | static int rockchip_i2s_set_fmt(struct snd_soc_dai *cpu_dai, | ||
| 163 | unsigned int fmt) | ||
| 164 | { | ||
| 165 | struct rk_i2s_dev *i2s = to_info(cpu_dai); | ||
| 166 | unsigned int mask = 0, val = 0; | ||
| 167 | |||
| 168 | mask = I2S_CKR_MSS_SLAVE; | ||
| 169 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
| 170 | case SND_SOC_DAIFMT_CBS_CFS: | ||
| 171 | val = I2S_CKR_MSS_SLAVE; | ||
| 172 | break; | ||
| 173 | case SND_SOC_DAIFMT_CBM_CFM: | ||
| 174 | val = I2S_CKR_MSS_MASTER; | ||
| 175 | break; | ||
| 176 | default: | ||
| 177 | return -EINVAL; | ||
| 178 | } | ||
| 179 | |||
| 180 | regmap_update_bits(i2s->regmap, I2S_CKR, mask, val); | ||
| 181 | |||
| 182 | mask = I2S_TXCR_IBM_MASK; | ||
| 183 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 184 | case SND_SOC_DAIFMT_RIGHT_J: | ||
| 185 | val = I2S_TXCR_IBM_RSJM; | ||
| 186 | break; | ||
| 187 | case SND_SOC_DAIFMT_LEFT_J: | ||
| 188 | val = I2S_TXCR_IBM_LSJM; | ||
| 189 | break; | ||
| 190 | case SND_SOC_DAIFMT_I2S: | ||
| 191 | val = I2S_TXCR_IBM_NORMAL; | ||
| 192 | break; | ||
| 193 | default: | ||
| 194 | return -EINVAL; | ||
| 195 | } | ||
| 196 | |||
| 197 | regmap_update_bits(i2s->regmap, I2S_TXCR, mask, val); | ||
| 198 | |||
| 199 | mask = I2S_RXCR_IBM_MASK; | ||
| 200 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 201 | case SND_SOC_DAIFMT_RIGHT_J: | ||
| 202 | val = I2S_RXCR_IBM_RSJM; | ||
| 203 | break; | ||
| 204 | case SND_SOC_DAIFMT_LEFT_J: | ||
| 205 | val = I2S_RXCR_IBM_LSJM; | ||
| 206 | break; | ||
| 207 | case SND_SOC_DAIFMT_I2S: | ||
| 208 | val = I2S_RXCR_IBM_NORMAL; | ||
| 209 | break; | ||
| 210 | default: | ||
| 211 | return -EINVAL; | ||
| 212 | } | ||
| 213 | |||
| 214 | regmap_update_bits(i2s->regmap, I2S_RXCR, mask, val); | ||
| 215 | |||
| 216 | return 0; | ||
| 217 | } | ||
| 218 | |||
| 219 | static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream, | ||
| 220 | struct snd_pcm_hw_params *params, | ||
| 221 | struct snd_soc_dai *dai) | ||
| 222 | { | ||
| 223 | struct rk_i2s_dev *i2s = to_info(dai); | ||
| 224 | unsigned int val = 0; | ||
| 225 | |||
| 226 | switch (params_format(params)) { | ||
| 227 | case SNDRV_PCM_FORMAT_S8: | ||
| 228 | val |= I2S_TXCR_VDW(8); | ||
| 229 | break; | ||
| 230 | case SNDRV_PCM_FORMAT_S16_LE: | ||
| 231 | val |= I2S_TXCR_VDW(16); | ||
| 232 | break; | ||
| 233 | case SNDRV_PCM_FORMAT_S20_3LE: | ||
| 234 | val |= I2S_TXCR_VDW(20); | ||
| 235 | break; | ||
| 236 | case SNDRV_PCM_FORMAT_S24_LE: | ||
| 237 | val |= I2S_TXCR_VDW(24); | ||
| 238 | break; | ||
| 239 | default: | ||
| 240 | return -EINVAL; | ||
| 241 | } | ||
| 242 | |||
| 243 | regmap_update_bits(i2s->regmap, I2S_TXCR, I2S_TXCR_VDW_MASK, val); | ||
| 244 | regmap_update_bits(i2s->regmap, I2S_RXCR, I2S_RXCR_VDW_MASK, val); | ||
| 245 | |||
| 246 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
| 247 | dai->playback_dma_data = &i2s->playback_dma_data; | ||
| 248 | regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_TDL_MASK, | ||
| 249 | I2S_DMACR_TDL(1) | I2S_DMACR_TDE_ENABLE); | ||
| 250 | } else { | ||
| 251 | dai->capture_dma_data = &i2s->capture_dma_data; | ||
| 252 | regmap_update_bits(i2s->regmap, I2S_DMACR, I2S_DMACR_RDL_MASK, | ||
| 253 | I2S_DMACR_RDL(1) | I2S_DMACR_RDE_ENABLE); | ||
| 254 | } | ||
| 255 | |||
| 256 | return 0; | ||
| 257 | } | ||
| 258 | |||
| 259 | static int rockchip_i2s_trigger(struct snd_pcm_substream *substream, | ||
| 260 | int cmd, struct snd_soc_dai *dai) | ||
| 261 | { | ||
| 262 | struct rk_i2s_dev *i2s = to_info(dai); | ||
| 263 | int ret = 0; | ||
| 264 | |||
| 265 | switch (cmd) { | ||
| 266 | case SNDRV_PCM_TRIGGER_START: | ||
| 267 | case SNDRV_PCM_TRIGGER_RESUME: | ||
| 268 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
| 269 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
| 270 | rockchip_snd_rxctrl(i2s, 1); | ||
| 271 | else | ||
| 272 | rockchip_snd_txctrl(i2s, 1); | ||
| 273 | break; | ||
| 274 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
| 275 | case SNDRV_PCM_TRIGGER_STOP: | ||
| 276 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
| 277 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | ||
| 278 | rockchip_snd_rxctrl(i2s, 0); | ||
| 279 | else | ||
| 280 | rockchip_snd_txctrl(i2s, 0); | ||
| 281 | break; | ||
| 282 | default: | ||
| 283 | ret = -EINVAL; | ||
| 284 | break; | ||
| 285 | } | ||
| 286 | |||
| 287 | return ret; | ||
| 288 | } | ||
| 289 | |||
| 290 | static int rockchip_i2s_set_sysclk(struct snd_soc_dai *cpu_dai, int clk_id, | ||
| 291 | unsigned int freq, int dir) | ||
| 292 | { | ||
| 293 | struct rk_i2s_dev *i2s = to_info(cpu_dai); | ||
| 294 | int ret; | ||
| 295 | |||
| 296 | ret = clk_set_rate(i2s->mclk, freq); | ||
| 297 | if (ret) | ||
| 298 | dev_err(i2s->dev, "Fail to set mclk %d\n", ret); | ||
| 299 | |||
| 300 | return ret; | ||
| 301 | } | ||
| 302 | |||
| 303 | static const struct snd_soc_dai_ops rockchip_i2s_dai_ops = { | ||
| 304 | .hw_params = rockchip_i2s_hw_params, | ||
| 305 | .set_sysclk = rockchip_i2s_set_sysclk, | ||
| 306 | .set_fmt = rockchip_i2s_set_fmt, | ||
| 307 | .trigger = rockchip_i2s_trigger, | ||
| 308 | }; | ||
| 309 | |||
| 310 | static struct snd_soc_dai_driver rockchip_i2s_dai = { | ||
| 311 | .playback = { | ||
| 312 | .channels_min = 2, | ||
| 313 | .channels_max = 8, | ||
| 314 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
| 315 | .formats = (SNDRV_PCM_FMTBIT_S8 | | ||
| 316 | SNDRV_PCM_FMTBIT_S16_LE | | ||
| 317 | SNDRV_PCM_FMTBIT_S20_3LE | | ||
| 318 | SNDRV_PCM_FMTBIT_S24_LE), | ||
| 319 | }, | ||
| 320 | .capture = { | ||
| 321 | .channels_min = 2, | ||
| 322 | .channels_max = 2, | ||
| 323 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
| 324 | .formats = (SNDRV_PCM_FMTBIT_S8 | | ||
| 325 | SNDRV_PCM_FMTBIT_S16_LE | | ||
| 326 | SNDRV_PCM_FMTBIT_S20_3LE | | ||
| 327 | SNDRV_PCM_FMTBIT_S24_LE), | ||
| 328 | }, | ||
| 329 | .ops = &rockchip_i2s_dai_ops, | ||
| 330 | }; | ||
| 331 | |||
| 332 | static const struct snd_soc_component_driver rockchip_i2s_component = { | ||
| 333 | .name = DRV_NAME, | ||
| 334 | }; | ||
| 335 | |||
| 336 | static bool rockchip_i2s_wr_reg(struct device *dev, unsigned int reg) | ||
| 337 | { | ||
| 338 | switch (reg) { | ||
| 339 | case I2S_TXCR: | ||
| 340 | case I2S_RXCR: | ||
| 341 | case I2S_CKR: | ||
| 342 | case I2S_DMACR: | ||
| 343 | case I2S_INTCR: | ||
| 344 | case I2S_XFER: | ||
| 345 | case I2S_CLR: | ||
| 346 | case I2S_TXDR: | ||
| 347 | return true; | ||
| 348 | default: | ||
| 349 | return false; | ||
| 350 | } | ||
| 351 | } | ||
| 352 | |||
| 353 | static bool rockchip_i2s_rd_reg(struct device *dev, unsigned int reg) | ||
| 354 | { | ||
| 355 | switch (reg) { | ||
| 356 | case I2S_TXCR: | ||
| 357 | case I2S_RXCR: | ||
| 358 | case I2S_CKR: | ||
| 359 | case I2S_DMACR: | ||
| 360 | case I2S_INTCR: | ||
| 361 | case I2S_XFER: | ||
| 362 | case I2S_CLR: | ||
| 363 | case I2S_RXDR: | ||
| 364 | return true; | ||
| 365 | default: | ||
| 366 | return false; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | static bool rockchip_i2s_volatile_reg(struct device *dev, unsigned int reg) | ||
| 371 | { | ||
| 372 | switch (reg) { | ||
| 373 | case I2S_FIFOLR: | ||
| 374 | case I2S_INTSR: | ||
| 375 | return true; | ||
| 376 | default: | ||
| 377 | return false; | ||
| 378 | } | ||
| 379 | } | ||
| 380 | |||
| 381 | static bool rockchip_i2s_precious_reg(struct device *dev, unsigned int reg) | ||
| 382 | { | ||
| 383 | switch (reg) { | ||
| 384 | case I2S_FIFOLR: | ||
| 385 | return true; | ||
| 386 | default: | ||
| 387 | return false; | ||
| 388 | } | ||
| 389 | } | ||
| 390 | |||
| 391 | static const struct regmap_config rockchip_i2s_regmap_config = { | ||
| 392 | .reg_bits = 32, | ||
| 393 | .reg_stride = 4, | ||
| 394 | .val_bits = 32, | ||
| 395 | .max_register = I2S_RXDR, | ||
| 396 | .writeable_reg = rockchip_i2s_wr_reg, | ||
| 397 | .readable_reg = rockchip_i2s_rd_reg, | ||
| 398 | .volatile_reg = rockchip_i2s_volatile_reg, | ||
| 399 | .precious_reg = rockchip_i2s_precious_reg, | ||
| 400 | .cache_type = REGCACHE_FLAT, | ||
| 401 | }; | ||
| 402 | |||
| 403 | static int rockchip_i2s_probe(struct platform_device *pdev) | ||
| 404 | { | ||
| 405 | struct rk_i2s_dev *i2s; | ||
| 406 | struct resource *res; | ||
| 407 | void __iomem *regs; | ||
| 408 | int ret; | ||
| 409 | |||
| 410 | i2s = devm_kzalloc(&pdev->dev, sizeof(*i2s), GFP_KERNEL); | ||
| 411 | if (!i2s) { | ||
| 412 | dev_err(&pdev->dev, "Can't allocate rk_i2s_dev\n"); | ||
| 413 | return -ENOMEM; | ||
| 414 | } | ||
| 415 | |||
| 416 | /* try to prepare related clocks */ | ||
| 417 | i2s->hclk = devm_clk_get(&pdev->dev, "i2s_hclk"); | ||
| 418 | if (IS_ERR(i2s->hclk)) { | ||
| 419 | dev_err(&pdev->dev, "Can't retrieve i2s bus clock\n"); | ||
| 420 | return PTR_ERR(i2s->hclk); | ||
| 421 | } | ||
| 422 | |||
| 423 | i2s->mclk = devm_clk_get(&pdev->dev, "i2s_clk"); | ||
| 424 | if (IS_ERR(i2s->mclk)) { | ||
| 425 | dev_err(&pdev->dev, "Can't retrieve i2s master clock\n"); | ||
| 426 | return PTR_ERR(i2s->mclk); | ||
| 427 | } | ||
| 428 | |||
| 429 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 430 | regs = devm_ioremap_resource(&pdev->dev, res); | ||
| 431 | if (IS_ERR(regs)) | ||
| 432 | return PTR_ERR(regs); | ||
| 433 | |||
| 434 | i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs, | ||
| 435 | &rockchip_i2s_regmap_config); | ||
| 436 | if (IS_ERR(i2s->regmap)) { | ||
| 437 | dev_err(&pdev->dev, | ||
| 438 | "Failed to initialise managed register map\n"); | ||
| 439 | return PTR_ERR(i2s->regmap); | ||
| 440 | } | ||
| 441 | |||
| 442 | i2s->playback_dma_data.addr = res->start + I2S_TXDR; | ||
| 443 | i2s->playback_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
| 444 | i2s->playback_dma_data.maxburst = 16; | ||
| 445 | |||
| 446 | i2s->capture_dma_data.addr = res->start + I2S_RXDR; | ||
| 447 | i2s->capture_dma_data.addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
| 448 | i2s->capture_dma_data.maxburst = 16; | ||
| 449 | |||
| 450 | i2s->dev = &pdev->dev; | ||
| 451 | dev_set_drvdata(&pdev->dev, i2s); | ||
| 452 | |||
| 453 | pm_runtime_enable(&pdev->dev); | ||
| 454 | if (!pm_runtime_enabled(&pdev->dev)) { | ||
| 455 | ret = i2s_runtime_resume(&pdev->dev); | ||
| 456 | if (ret) | ||
| 457 | goto err_pm_disable; | ||
| 458 | } | ||
| 459 | |||
| 460 | ret = devm_snd_soc_register_component(&pdev->dev, | ||
| 461 | &rockchip_i2s_component, | ||
| 462 | &rockchip_i2s_dai, 1); | ||
| 463 | if (ret) { | ||
| 464 | dev_err(&pdev->dev, "Could not register DAI\n"); | ||
| 465 | goto err_suspend; | ||
| 466 | } | ||
| 467 | |||
| 468 | ret = snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); | ||
| 469 | if (ret) { | ||
| 470 | dev_err(&pdev->dev, "Could not register PCM\n"); | ||
| 471 | goto err_pcm_register; | ||
| 472 | } | ||
| 473 | |||
| 474 | return 0; | ||
| 475 | |||
| 476 | err_pcm_register: | ||
| 477 | snd_dmaengine_pcm_unregister(&pdev->dev); | ||
| 478 | err_suspend: | ||
| 479 | if (!pm_runtime_status_suspended(&pdev->dev)) | ||
| 480 | i2s_runtime_suspend(&pdev->dev); | ||
| 481 | err_pm_disable: | ||
| 482 | pm_runtime_disable(&pdev->dev); | ||
| 483 | |||
| 484 | return ret; | ||
| 485 | } | ||
| 486 | |||
| 487 | static int rockchip_i2s_remove(struct platform_device *pdev) | ||
| 488 | { | ||
| 489 | struct rk_i2s_dev *i2s = dev_get_drvdata(&pdev->dev); | ||
| 490 | |||
| 491 | pm_runtime_disable(&pdev->dev); | ||
| 492 | if (!pm_runtime_status_suspended(&pdev->dev)) | ||
| 493 | i2s_runtime_suspend(&pdev->dev); | ||
| 494 | |||
| 495 | clk_disable_unprepare(i2s->mclk); | ||
| 496 | clk_disable_unprepare(i2s->hclk); | ||
| 497 | snd_dmaengine_pcm_unregister(&pdev->dev); | ||
| 498 | snd_soc_unregister_component(&pdev->dev); | ||
| 499 | |||
| 500 | return 0; | ||
| 501 | } | ||
| 502 | |||
| 503 | static const struct of_device_id rockchip_i2s_match[] = { | ||
| 504 | { .compatible = "rockchip,rk3066-i2s", }, | ||
| 505 | {}, | ||
| 506 | }; | ||
| 507 | |||
| 508 | static const struct dev_pm_ops rockchip_i2s_pm_ops = { | ||
| 509 | SET_RUNTIME_PM_OPS(i2s_runtime_suspend, i2s_runtime_resume, | ||
| 510 | NULL) | ||
| 511 | }; | ||
| 512 | |||
| 513 | static struct platform_driver rockchip_i2s_driver = { | ||
| 514 | .probe = rockchip_i2s_probe, | ||
| 515 | .remove = rockchip_i2s_remove, | ||
| 516 | .driver = { | ||
| 517 | .name = DRV_NAME, | ||
| 518 | .owner = THIS_MODULE, | ||
| 519 | .of_match_table = of_match_ptr(rockchip_i2s_match), | ||
| 520 | .pm = &rockchip_i2s_pm_ops, | ||
| 521 | }, | ||
| 522 | }; | ||
| 523 | module_platform_driver(rockchip_i2s_driver); | ||
| 524 | |||
| 525 | MODULE_DESCRIPTION("ROCKCHIP IIS ASoC Interface"); | ||
| 526 | MODULE_AUTHOR("jianqun <jay.xu@rock-chips.com>"); | ||
| 527 | MODULE_LICENSE("GPL v2"); | ||
| 528 | MODULE_ALIAS("platform:" DRV_NAME); | ||
| 529 | MODULE_DEVICE_TABLE(of, rockchip_i2s_match); | ||
diff --git a/sound/soc/rockchip/rockchip_i2s.h b/sound/soc/rockchip/rockchip_i2s.h new file mode 100644 index 000000000000..89a5d8bc6ee7 --- /dev/null +++ b/sound/soc/rockchip/rockchip_i2s.h | |||
| @@ -0,0 +1,223 @@ | |||
| 1 | /* | ||
| 2 | * sound/soc/rockchip/rockchip_i2s.h | ||
| 3 | * | ||
| 4 | * ALSA SoC Audio Layer - Rockchip I2S Controller driver | ||
| 5 | * | ||
| 6 | * Copyright (c) 2014 Rockchip Electronics Co. Ltd. | ||
| 7 | * Author: Jianqun xu <jay.xu@rock-chips.com> | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License version 2 as | ||
| 11 | * published by the Free Software Foundation. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #ifndef _ROCKCHIP_IIS_H | ||
| 15 | #define _ROCKCHIP_IIS_H | ||
| 16 | |||
| 17 | /* | ||
| 18 | * TXCR | ||
| 19 | * transmit operation control register | ||
| 20 | */ | ||
| 21 | #define I2S_TXCR_RCNT_SHIFT 17 | ||
| 22 | #define I2S_TXCR_RCNT_MASK (0x3f << I2S_TXCR_RCNT_SHIFT) | ||
| 23 | #define I2S_TXCR_CSR_SHIFT 15 | ||
| 24 | #define I2S_TXCR_CSR(x) (x << I2S_TXCR_CSR_SHIFT) | ||
| 25 | #define I2S_TXCR_CSR_MASK (3 << I2S_TXCR_CSR_SHIFT) | ||
| 26 | #define I2S_TXCR_HWT BIT(14) | ||
| 27 | #define I2S_TXCR_SJM_SHIFT 12 | ||
| 28 | #define I2S_TXCR_SJM_R (0 << I2S_TXCR_SJM_SHIFT) | ||
| 29 | #define I2S_TXCR_SJM_L (1 << I2S_TXCR_SJM_SHIFT) | ||
| 30 | #define I2S_TXCR_FBM_SHIFT 11 | ||
| 31 | #define I2S_TXCR_FBM_MSB (0 << I2S_TXCR_FBM_SHIFT) | ||
| 32 | #define I2S_TXCR_FBM_LSB (1 << I2S_TXCR_FBM_SHIFT) | ||
| 33 | #define I2S_TXCR_IBM_SHIFT 9 | ||
| 34 | #define I2S_TXCR_IBM_NORMAL (0 << I2S_TXCR_IBM_SHIFT) | ||
| 35 | #define I2S_TXCR_IBM_LSJM (1 << I2S_TXCR_IBM_SHIFT) | ||
| 36 | #define I2S_TXCR_IBM_RSJM (2 << I2S_TXCR_IBM_SHIFT) | ||
| 37 | #define I2S_TXCR_IBM_MASK (3 << I2S_TXCR_IBM_SHIFT) | ||
| 38 | #define I2S_TXCR_PBM_SHIFT 7 | ||
| 39 | #define I2S_TXCR_PBM_MODE(x) (x << I2S_TXCR_PBM_SHIFT) | ||
| 40 | #define I2S_TXCR_PBM_MASK (3 << I2S_TXCR_PBM_SHIFT) | ||
| 41 | #define I2S_TXCR_TFS_SHIFT 5 | ||
| 42 | #define I2S_TXCR_TFS_I2S (0 << I2S_TXCR_TFS_SHIFT) | ||
| 43 | #define I2S_TXCR_TFS_PCM (1 << I2S_TXCR_TFS_SHIFT) | ||
| 44 | #define I2S_TXCR_VDW_SHIFT 0 | ||
| 45 | #define I2S_TXCR_VDW(x) ((x - 1) << I2S_TXCR_VDW_SHIFT) | ||
| 46 | #define I2S_TXCR_VDW_MASK (0x1f << I2S_TXCR_VDW_SHIFT) | ||
| 47 | |||
| 48 | /* | ||
| 49 | * RXCR | ||
| 50 | * receive operation control register | ||
| 51 | */ | ||
| 52 | #define I2S_RXCR_HWT BIT(14) | ||
| 53 | #define I2S_RXCR_SJM_SHIFT 12 | ||
| 54 | #define I2S_RXCR_SJM_R (0 << I2S_RXCR_SJM_SHIFT) | ||
| 55 | #define I2S_RXCR_SJM_L (1 << I2S_RXCR_SJM_SHIFT) | ||
| 56 | #define I2S_RXCR_FBM_SHIFT 11 | ||
| 57 | #define I2S_RXCR_FBM_MSB (0 << I2S_RXCR_FBM_SHIFT) | ||
| 58 | #define I2S_RXCR_FBM_LSB (1 << I2S_RXCR_FBM_SHIFT) | ||
| 59 | #define I2S_RXCR_IBM_SHIFT 9 | ||
| 60 | #define I2S_RXCR_IBM_NORMAL (0 << I2S_RXCR_IBM_SHIFT) | ||
| 61 | #define I2S_RXCR_IBM_LSJM (1 << I2S_RXCR_IBM_SHIFT) | ||
| 62 | #define I2S_RXCR_IBM_RSJM (2 << I2S_RXCR_IBM_SHIFT) | ||
| 63 | #define I2S_RXCR_IBM_MASK (3 << I2S_RXCR_IBM_SHIFT) | ||
| 64 | #define I2S_RXCR_PBM_SHIFT 7 | ||
| 65 | #define I2S_RXCR_PBM_MODE(x) (x << I2S_RXCR_PBM_SHIFT) | ||
| 66 | #define I2S_RXCR_PBM_MASK (3 << I2S_RXCR_PBM_SHIFT) | ||
| 67 | #define I2S_RXCR_TFS_SHIFT 5 | ||
| 68 | #define I2S_RXCR_TFS_I2S (0 << I2S_RXCR_TFS_SHIFT) | ||
| 69 | #define I2S_RXCR_TFS_PCM (1 << I2S_RXCR_TFS_SHIFT) | ||
| 70 | #define I2S_RXCR_VDW_SHIFT 0 | ||
| 71 | #define I2S_RXCR_VDW(x) ((x - 1) << I2S_RXCR_VDW_SHIFT) | ||
| 72 | #define I2S_RXCR_VDW_MASK (0x1f << I2S_RXCR_VDW_SHIFT) | ||
| 73 | |||
| 74 | /* | ||
| 75 | * CKR | ||
| 76 | * clock generation register | ||
| 77 | */ | ||
| 78 | #define I2S_CKR_MSS_SHIFT 27 | ||
| 79 | #define I2S_CKR_MSS_MASTER (0 << I2S_CKR_MSS_SHIFT) | ||
| 80 | #define I2S_CKR_MSS_SLAVE (1 << I2S_CKR_MSS_SHIFT) | ||
| 81 | #define I2S_CKR_MSS_MASK (1 << I2S_CKR_MSS_SHIFT) | ||
| 82 | #define I2S_CKR_CKP_SHIFT 26 | ||
| 83 | #define I2S_CKR_CKP_NEG (0 << I2S_CKR_CKP_SHIFT) | ||
| 84 | #define I2S_CKR_CKP_POS (1 << I2S_CKR_CKP_SHIFT) | ||
| 85 | #define I2S_CKR_RLP_SHIFT 25 | ||
| 86 | #define I2S_CKR_RLP_NORMAL (0 << I2S_CKR_RLP_SHIFT) | ||
| 87 | #define I2S_CKR_RLP_OPPSITE (1 << I2S_CKR_RLP_SHIFT) | ||
| 88 | #define I2S_CKR_TLP_SHIFT 24 | ||
| 89 | #define I2S_CKR_TLP_NORMAL (0 << I2S_CKR_TLP_SHIFT) | ||
| 90 | #define I2S_CKR_TLP_OPPSITE (1 << I2S_CKR_TLP_SHIFT) | ||
| 91 | #define I2S_CKR_MDIV_SHIFT 16 | ||
| 92 | #define I2S_CKR_MDIV(x) ((x - 1) << I2S_CKR_MDIV_SHIFT) | ||
| 93 | #define I2S_CKR_MDIV_MASK (0xff << I2S_CKR_MDIV_SHIFT) | ||
| 94 | #define I2S_CKR_RSD_SHIFT 8 | ||
| 95 | #define I2S_CKR_RSD(x) ((x - 1) << I2S_CKR_RSD_SHIFT) | ||
| 96 | #define I2S_CKR_RSD_MASK (0xff << I2S_CKR_RSD_SHIFT) | ||
| 97 | #define I2S_CKR_TSD_SHIFT 0 | ||
| 98 | #define I2S_CKR_TSD(x) ((x - 1) << I2S_CKR_TSD_SHIFT) | ||
| 99 | #define I2S_CKR_TSD_MASK (0xff << I2S_CKR_TSD_SHIFT) | ||
| 100 | |||
| 101 | /* | ||
| 102 | * FIFOLR | ||
| 103 | * FIFO level register | ||
| 104 | */ | ||
| 105 | #define I2S_FIFOLR_RFL_SHIFT 24 | ||
| 106 | #define I2S_FIFOLR_RFL_MASK (0x3f << I2S_FIFOLR_RFL_SHIFT) | ||
| 107 | #define I2S_FIFOLR_TFL3_SHIFT 18 | ||
| 108 | #define I2S_FIFOLR_TFL3_MASK (0x3f << I2S_FIFOLR_TFL3_SHIFT) | ||
| 109 | #define I2S_FIFOLR_TFL2_SHIFT 12 | ||
| 110 | #define I2S_FIFOLR_TFL2_MASK (0x3f << I2S_FIFOLR_TFL2_SHIFT) | ||
| 111 | #define I2S_FIFOLR_TFL1_SHIFT 6 | ||
| 112 | #define I2S_FIFOLR_TFL1_MASK (0x3f << I2S_FIFOLR_TFL1_SHIFT) | ||
| 113 | #define I2S_FIFOLR_TFL0_SHIFT 0 | ||
| 114 | #define I2S_FIFOLR_TFL0_MASK (0x3f << I2S_FIFOLR_TFL0_SHIFT) | ||
| 115 | |||
| 116 | /* | ||
| 117 | * DMACR | ||
| 118 | * DMA control register | ||
| 119 | */ | ||
| 120 | #define I2S_DMACR_RDE_SHIFT 24 | ||
| 121 | #define I2S_DMACR_RDE_DISABLE (0 << I2S_DMACR_RDE_SHIFT) | ||
| 122 | #define I2S_DMACR_RDE_ENABLE (1 << I2S_DMACR_RDE_SHIFT) | ||
| 123 | #define I2S_DMACR_RDL_SHIFT 16 | ||
| 124 | #define I2S_DMACR_RDL(x) ((x - 1) << I2S_DMACR_RDL_SHIFT) | ||
| 125 | #define I2S_DMACR_RDL_MASK (0x1f << I2S_DMACR_RDL_SHIFT) | ||
| 126 | #define I2S_DMACR_TDE_SHIFT 8 | ||
| 127 | #define I2S_DMACR_TDE_DISABLE (0 << I2S_DMACR_TDE_SHIFT) | ||
| 128 | #define I2S_DMACR_TDE_ENABLE (1 << I2S_DMACR_TDE_SHIFT) | ||
| 129 | #define I2S_DMACR_TDL_SHIFT 0 | ||
| 130 | #define I2S_DMACR_TDL(x) ((x - 1) << I2S_DMACR_TDL_SHIFT) | ||
| 131 | #define I2S_DMACR_TDL_MASK (0x1f << I2S_DMACR_TDL_SHIFT) | ||
| 132 | |||
| 133 | /* | ||
| 134 | * INTCR | ||
| 135 | * interrupt control register | ||
| 136 | */ | ||
| 137 | #define I2S_INTCR_RFT_SHIFT 20 | ||
| 138 | #define I2S_INTCR_RFT(x) ((x - 1) << I2S_INTCR_RFT_SHIFT) | ||
| 139 | #define I2S_INTCR_RXOIC BIT(18) | ||
| 140 | #define I2S_INTCR_RXOIE_SHIFT 17 | ||
| 141 | #define I2S_INTCR_RXOIE_DISABLE (0 << I2S_INTCR_RXOIE_SHIFT) | ||
| 142 | #define I2S_INTCR_RXOIE_ENABLE (1 << I2S_INTCR_RXOIE_SHIFT) | ||
| 143 | #define I2S_INTCR_RXFIE_SHIFT 16 | ||
| 144 | #define I2S_INTCR_RXFIE_DISABLE (0 << I2S_INTCR_RXFIE_SHIFT) | ||
| 145 | #define I2S_INTCR_RXFIE_ENABLE (1 << I2S_INTCR_RXFIE_SHIFT) | ||
| 146 | #define I2S_INTCR_TFT_SHIFT 4 | ||
| 147 | #define I2S_INTCR_TFT(x) ((x - 1) << I2S_INTCR_TFT_SHIFT) | ||
| 148 | #define I2S_INTCR_TFT_MASK (0x1f << I2S_INTCR_TFT_SHIFT) | ||
| 149 | #define I2S_INTCR_TXUIC BIT(2) | ||
| 150 | #define I2S_INTCR_TXUIE_SHIFT 1 | ||
| 151 | #define I2S_INTCR_TXUIE_DISABLE (0 << I2S_INTCR_TXUIE_SHIFT) | ||
| 152 | #define I2S_INTCR_TXUIE_ENABLE (1 << I2S_INTCR_TXUIE_SHIFT) | ||
| 153 | |||
| 154 | /* | ||
| 155 | * INTSR | ||
| 156 | * interrupt status register | ||
| 157 | */ | ||
| 158 | #define I2S_INTSR_TXEIE_SHIFT 0 | ||
| 159 | #define I2S_INTSR_TXEIE_DISABLE (0 << I2S_INTSR_TXEIE_SHIFT) | ||
| 160 | #define I2S_INTSR_TXEIE_ENABLE (1 << I2S_INTSR_TXEIE_SHIFT) | ||
| 161 | #define I2S_INTSR_RXOI_SHIFT 17 | ||
| 162 | #define I2S_INTSR_RXOI_INA (0 << I2S_INTSR_RXOI_SHIFT) | ||
| 163 | #define I2S_INTSR_RXOI_ACT (1 << I2S_INTSR_RXOI_SHIFT) | ||
| 164 | #define I2S_INTSR_RXFI_SHIFT 16 | ||
| 165 | #define I2S_INTSR_RXFI_INA (0 << I2S_INTSR_RXFI_SHIFT) | ||
| 166 | #define I2S_INTSR_RXFI_ACT (1 << I2S_INTSR_RXFI_SHIFT) | ||
| 167 | #define I2S_INTSR_TXUI_SHIFT 1 | ||
| 168 | #define I2S_INTSR_TXUI_INA (0 << I2S_INTSR_TXUI_SHIFT) | ||
| 169 | #define I2S_INTSR_TXUI_ACT (1 << I2S_INTSR_TXUI_SHIFT) | ||
| 170 | #define I2S_INTSR_TXEI_SHIFT 0 | ||
| 171 | #define I2S_INTSR_TXEI_INA (0 << I2S_INTSR_TXEI_SHIFT) | ||
| 172 | #define I2S_INTSR_TXEI_ACT (1 << I2S_INTSR_TXEI_SHIFT) | ||
| 173 | |||
| 174 | /* | ||
| 175 | * XFER | ||
| 176 | * Transfer start register | ||
| 177 | */ | ||
| 178 | #define I2S_XFER_RXS_SHIFT 1 | ||
| 179 | #define I2S_XFER_RXS_STOP (0 << I2S_XFER_RXS_SHIFT) | ||
| 180 | #define I2S_XFER_RXS_START (1 << I2S_XFER_RXS_SHIFT) | ||
| 181 | #define I2S_XFER_TXS_SHIFT 0 | ||
| 182 | #define I2S_XFER_TXS_STOP (0 << I2S_XFER_TXS_SHIFT) | ||
| 183 | #define I2S_XFER_TXS_START (1 << I2S_XFER_TXS_SHIFT) | ||
| 184 | |||
| 185 | /* | ||
| 186 | * CLR | ||
| 187 | * clear SCLK domain logic register | ||
| 188 | */ | ||
| 189 | #define I2S_CLR_RXC BIT(1) | ||
| 190 | #define I2S_CLR_TXC BIT(0) | ||
| 191 | |||
| 192 | /* | ||
| 193 | * TXDR | ||
| 194 | * Transimt FIFO data register, write only. | ||
| 195 | */ | ||
| 196 | #define I2S_TXDR_MASK (0xff) | ||
| 197 | |||
| 198 | /* | ||
| 199 | * RXDR | ||
| 200 | * Receive FIFO data register, write only. | ||
| 201 | */ | ||
| 202 | #define I2S_RXDR_MASK (0xff) | ||
| 203 | |||
| 204 | /* Clock divider id */ | ||
| 205 | enum { | ||
| 206 | ROCKCHIP_DIV_MCLK = 0, | ||
| 207 | ROCKCHIP_DIV_BCLK, | ||
| 208 | }; | ||
| 209 | |||
| 210 | /* I2S REGS */ | ||
| 211 | #define I2S_TXCR (0x0000) | ||
| 212 | #define I2S_RXCR (0x0004) | ||
| 213 | #define I2S_CKR (0x0008) | ||
| 214 | #define I2S_FIFOLR (0x000c) | ||
| 215 | #define I2S_DMACR (0x0010) | ||
| 216 | #define I2S_INTCR (0x0014) | ||
| 217 | #define I2S_INTSR (0x0018) | ||
| 218 | #define I2S_XFER (0x001c) | ||
| 219 | #define I2S_CLR (0x0020) | ||
| 220 | #define I2S_TXDR (0x0024) | ||
| 221 | #define I2S_RXDR (0x0028) | ||
| 222 | |||
| 223 | #endif /* _ROCKCHIP_IIS_H */ | ||
diff --git a/sound/soc/s6000/Kconfig b/sound/soc/s6000/Kconfig index c74eb3d4a47c..f244a2566f20 100644 --- a/sound/soc/s6000/Kconfig +++ b/sound/soc/s6000/Kconfig | |||
| @@ -1,17 +1,24 @@ | |||
| 1 | config SND_S6000_SOC | 1 | config SND_S6000_SOC |
| 2 | tristate "SoC Audio for the Stretch s6000 family" | 2 | tristate "SoC Audio for the Stretch s6000 family" |
| 3 | depends on XTENSA_VARIANT_S6000 | 3 | depends on XTENSA_VARIANT_S6000 || COMPILE_TEST |
| 4 | depends on HAS_IOMEM | ||
| 5 | select SND_S6000_SOC_PCM if XTENSA_VARIANT_S6000 | ||
| 4 | help | 6 | help |
| 5 | Say Y or M if you want to add support for codecs attached to | 7 | Say Y or M if you want to add support for codecs attached to |
| 6 | s6000 family chips. You will also need to select the platform | 8 | s6000 family chips. You will also need to select the platform |
| 7 | to support below. | 9 | to support below. |
| 8 | 10 | ||
| 11 | config SND_S6000_SOC_PCM | ||
| 12 | tristate | ||
| 13 | |||
| 9 | config SND_S6000_SOC_I2S | 14 | config SND_S6000_SOC_I2S |
| 10 | tristate | 15 | tristate |
| 11 | 16 | ||
| 12 | config SND_S6000_SOC_S6IPCAM | 17 | config SND_S6000_SOC_S6IPCAM |
| 13 | tristate "SoC Audio support for Stretch 6105 IP Camera" | 18 | bool "SoC Audio support for Stretch 6105 IP Camera" |
| 14 | depends on SND_S6000_SOC && XTENSA_PLATFORM_S6105 | 19 | depends on SND_S6000_SOC=y |
| 20 | depends on I2C=y | ||
| 21 | depends on XTENSA_PLATFORM_S6105 || COMPILE_TEST | ||
| 15 | select SND_S6000_SOC_I2S | 22 | select SND_S6000_SOC_I2S |
| 16 | select SND_SOC_TLV320AIC3X | 23 | select SND_SOC_TLV320AIC3X |
| 17 | help | 24 | help |
diff --git a/sound/soc/s6000/Makefile b/sound/soc/s6000/Makefile index 7a613612e010..0f0ae2a012aa 100644 --- a/sound/soc/s6000/Makefile +++ b/sound/soc/s6000/Makefile | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | snd-soc-s6000-objs := s6000-pcm.o | 2 | snd-soc-s6000-objs := s6000-pcm.o |
| 3 | snd-soc-s6000-i2s-objs := s6000-i2s.o | 3 | snd-soc-s6000-i2s-objs := s6000-i2s.o |
| 4 | 4 | ||
| 5 | obj-$(CONFIG_SND_S6000_SOC) += snd-soc-s6000.o | 5 | obj-$(CONFIG_SND_S6000_SOC_PCM) += snd-soc-s6000.o |
| 6 | obj-$(CONFIG_SND_S6000_SOC_I2S) += snd-soc-s6000-i2s.o | 6 | obj-$(CONFIG_SND_S6000_SOC_I2S) += snd-soc-s6000-i2s.o |
| 7 | 7 | ||
| 8 | # s6105 Machine Support | 8 | # s6105 Machine Support |
diff --git a/sound/soc/s6000/s6000-i2s.c b/sound/soc/s6000/s6000-i2s.c index 7eba7979b9af..1c8d01166e5b 100644 --- a/sound/soc/s6000/s6000-i2s.c +++ b/sound/soc/s6000/s6000-i2s.c | |||
| @@ -570,7 +570,7 @@ err_release_none: | |||
| 570 | return ret; | 570 | return ret; |
| 571 | } | 571 | } |
| 572 | 572 | ||
| 573 | static void s6000_i2s_remove(struct platform_device *pdev) | 573 | static int s6000_i2s_remove(struct platform_device *pdev) |
| 574 | { | 574 | { |
| 575 | struct s6000_i2s_dev *dev = dev_get_drvdata(&pdev->dev); | 575 | struct s6000_i2s_dev *dev = dev_get_drvdata(&pdev->dev); |
| 576 | struct resource *region; | 576 | struct resource *region; |
| @@ -597,6 +597,8 @@ static void s6000_i2s_remove(struct platform_device *pdev) | |||
| 597 | iounmap(mmio); | 597 | iounmap(mmio); |
| 598 | region = platform_get_resource(pdev, IORESOURCE_IO, 0); | 598 | region = platform_get_resource(pdev, IORESOURCE_IO, 0); |
| 599 | release_mem_region(region->start, resource_size(region)); | 599 | release_mem_region(region->start, resource_size(region)); |
| 600 | |||
| 601 | return 0; | ||
| 600 | } | 602 | } |
| 601 | 603 | ||
| 602 | static struct platform_driver s6000_i2s_driver = { | 604 | static struct platform_driver s6000_i2s_driver = { |
diff --git a/sound/soc/s6000/s6105-ipcam.c b/sound/soc/s6000/s6105-ipcam.c index 0b21d1dc80c1..3510c01f8a6a 100644 --- a/sound/soc/s6000/s6105-ipcam.c +++ b/sound/soc/s6000/s6105-ipcam.c | |||
| @@ -19,8 +19,6 @@ | |||
| 19 | #include <sound/pcm.h> | 19 | #include <sound/pcm.h> |
| 20 | #include <sound/soc.h> | 20 | #include <sound/soc.h> |
| 21 | 21 | ||
| 22 | #include <variant/dmac.h> | ||
| 23 | |||
| 24 | #include "s6000-pcm.h" | 22 | #include "s6000-pcm.h" |
| 25 | #include "s6000-i2s.h" | 23 | #include "s6000-i2s.h" |
| 26 | 24 | ||
| @@ -135,22 +133,8 @@ static const struct snd_kcontrol_new audio_out_mux = { | |||
| 135 | /* Logic for a aic3x as connected on the s6105 ip camera ref design */ | 133 | /* Logic for a aic3x as connected on the s6105 ip camera ref design */ |
| 136 | static int s6105_aic3x_init(struct snd_soc_pcm_runtime *rtd) | 134 | static int s6105_aic3x_init(struct snd_soc_pcm_runtime *rtd) |
| 137 | { | 135 | { |
| 138 | struct snd_soc_codec *codec = rtd->codec; | ||
| 139 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
| 140 | struct snd_soc_card *card = rtd->card; | 136 | struct snd_soc_card *card = rtd->card; |
| 141 | 137 | ||
| 142 | /* not present */ | ||
| 143 | snd_soc_dapm_nc_pin(dapm, "MONO_LOUT"); | ||
| 144 | snd_soc_dapm_nc_pin(dapm, "LINE2L"); | ||
| 145 | snd_soc_dapm_nc_pin(dapm, "LINE2R"); | ||
| 146 | |||
| 147 | /* not connected */ | ||
| 148 | snd_soc_dapm_nc_pin(dapm, "MIC3L"); /* LINE2L on this chip */ | ||
| 149 | snd_soc_dapm_nc_pin(dapm, "MIC3R"); /* LINE2R on this chip */ | ||
| 150 | snd_soc_dapm_nc_pin(dapm, "LLOUT"); | ||
| 151 | snd_soc_dapm_nc_pin(dapm, "RLOUT"); | ||
| 152 | snd_soc_dapm_nc_pin(dapm, "HPRCOM"); | ||
| 153 | |||
| 154 | /* must correspond to audio_out_mux.private_value initializer */ | 138 | /* must correspond to audio_out_mux.private_value initializer */ |
| 155 | snd_soc_dapm_disable_pin(&card->dapm, "Audio Out Differential"); | 139 | snd_soc_dapm_disable_pin(&card->dapm, "Audio Out Differential"); |
| 156 | 140 | ||
| @@ -182,6 +166,7 @@ static struct snd_soc_card snd_soc_card_s6105 = { | |||
| 182 | .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets), | 166 | .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets), |
| 183 | .dapm_routes = audio_map, | 167 | .dapm_routes = audio_map, |
| 184 | .num_dapm_routes = ARRAY_SIZE(audio_map), | 168 | .num_dapm_routes = ARRAY_SIZE(audio_map), |
| 169 | .fully_routed = true, | ||
| 185 | }; | 170 | }; |
| 186 | 171 | ||
| 187 | static struct s6000_snd_platform_data s6105_snd_data __initdata = { | 172 | static struct s6000_snd_platform_data s6105_snd_data __initdata = { |
diff --git a/sound/soc/samsung/Kconfig b/sound/soc/samsung/Kconfig index 753b8c93ab51..55a38697443d 100644 --- a/sound/soc/samsung/Kconfig +++ b/sound/soc/samsung/Kconfig | |||
| @@ -1,25 +1,16 @@ | |||
| 1 | config SND_SOC_SAMSUNG | 1 | config SND_SOC_SAMSUNG |
| 2 | tristate "ASoC support for Samsung" | 2 | tristate "ASoC support for Samsung" |
| 3 | depends on PLAT_SAMSUNG | 3 | depends on PLAT_SAMSUNG |
| 4 | select S3C2410_DMA if ARCH_S3C24XX | 4 | depends on S3C64XX_PL080 || !ARCH_S3C64XX |
| 5 | select S3C64XX_PL080 if ARCH_S3C64XX | 5 | depends on S3C24XX_DMAC || !ARCH_S3C24XX |
| 6 | select SND_S3C_DMA if !ARCH_S3C24XX | 6 | select SND_SOC_GENERIC_DMAENGINE_PCM |
| 7 | select SND_S3C_DMA_LEGACY if ARCH_S3C24XX | ||
| 8 | select SND_SOC_GENERIC_DMAENGINE_PCM if !ARCH_S3C24XX | ||
| 9 | help | 7 | help |
| 10 | Say Y or M if you want to add support for codecs attached to | 8 | Say Y or M if you want to add support for codecs attached to |
| 11 | the Samsung SoCs' Audio interfaces. You will also need to | 9 | the Samsung SoCs' Audio interfaces. You will also need to |
| 12 | select the audio interfaces to support below. | 10 | select the audio interfaces to support below. |
| 13 | 11 | ||
| 14 | config SND_S3C_DMA | ||
| 15 | tristate | ||
| 16 | |||
| 17 | config SND_S3C_DMA_LEGACY | ||
| 18 | tristate | ||
| 19 | |||
| 20 | config SND_S3C24XX_I2S | 12 | config SND_S3C24XX_I2S |
| 21 | tristate | 13 | tristate |
| 22 | select S3C24XX_DMA | ||
| 23 | 14 | ||
| 24 | config SND_S3C_I2SV2_SOC | 15 | config SND_S3C_I2SV2_SOC |
| 25 | tristate | 16 | tristate |
| @@ -27,7 +18,6 @@ config SND_S3C_I2SV2_SOC | |||
| 27 | config SND_S3C2412_SOC_I2S | 18 | config SND_S3C2412_SOC_I2S |
| 28 | tristate | 19 | tristate |
| 29 | select SND_S3C_I2SV2_SOC | 20 | select SND_S3C_I2SV2_SOC |
| 30 | select S3C2410_DMA | ||
| 31 | 21 | ||
| 32 | config SND_SAMSUNG_PCM | 22 | config SND_SAMSUNG_PCM |
| 33 | tristate | 23 | tristate |
| @@ -55,7 +45,7 @@ config SND_SOC_SAMSUNG_NEO1973_WM8753 | |||
| 55 | 45 | ||
| 56 | config SND_SOC_SAMSUNG_JIVE_WM8750 | 46 | config SND_SOC_SAMSUNG_JIVE_WM8750 |
| 57 | tristate "SoC I2S Audio support for Jive" | 47 | tristate "SoC I2S Audio support for Jive" |
| 58 | depends on SND_SOC_SAMSUNG && MACH_JIVE | 48 | depends on SND_SOC_SAMSUNG && MACH_JIVE && I2C |
| 59 | select SND_SOC_WM8750 | 49 | select SND_SOC_WM8750 |
| 60 | select SND_S3C2412_SOC_I2S | 50 | select SND_S3C2412_SOC_I2S |
| 61 | help | 51 | help |
| @@ -63,7 +53,7 @@ config SND_SOC_SAMSUNG_JIVE_WM8750 | |||
| 63 | 53 | ||
| 64 | config SND_SOC_SAMSUNG_SMDK_WM8580 | 54 | config SND_SOC_SAMSUNG_SMDK_WM8580 |
| 65 | tristate "SoC I2S Audio support for WM8580 on SMDK" | 55 | tristate "SoC I2S Audio support for WM8580 on SMDK" |
| 66 | depends on SND_SOC_SAMSUNG && (MACH_SMDK6410 || MACH_SMDKC100 || MACH_SMDK6440 || MACH_SMDK6450 || MACH_SMDKV210 || MACH_SMDKC110) | 56 | depends on SND_SOC_SAMSUNG && (MACH_SMDK6410 || MACH_SMDKC100 || MACH_SMDKV210 || MACH_SMDKC110) |
| 67 | depends on REGMAP_I2C | 57 | depends on REGMAP_I2C |
| 68 | select SND_SOC_WM8580 | 58 | select SND_SOC_WM8580 |
| 69 | select SND_SAMSUNG_I2S | 59 | select SND_SAMSUNG_I2S |
| @@ -83,7 +73,6 @@ config SND_SOC_SAMSUNG_SMDK_WM8994 | |||
| 83 | config SND_SOC_SAMSUNG_SMDK2443_WM9710 | 73 | config SND_SOC_SAMSUNG_SMDK2443_WM9710 |
| 84 | tristate "SoC AC97 Audio support for SMDK2443 - WM9710" | 74 | tristate "SoC AC97 Audio support for SMDK2443 - WM9710" |
| 85 | depends on SND_SOC_SAMSUNG && MACH_SMDK2443 | 75 | depends on SND_SOC_SAMSUNG && MACH_SMDK2443 |
| 86 | select S3C2410_DMA | ||
| 87 | select AC97_BUS | 76 | select AC97_BUS |
| 88 | select SND_SOC_AC97_CODEC | 77 | select SND_SOC_AC97_CODEC |
| 89 | select SND_SAMSUNG_AC97 | 78 | select SND_SAMSUNG_AC97 |
| @@ -94,7 +83,6 @@ config SND_SOC_SAMSUNG_SMDK2443_WM9710 | |||
| 94 | config SND_SOC_SAMSUNG_LN2440SBC_ALC650 | 83 | config SND_SOC_SAMSUNG_LN2440SBC_ALC650 |
| 95 | tristate "SoC AC97 Audio support for LN2440SBC - ALC650" | 84 | tristate "SoC AC97 Audio support for LN2440SBC - ALC650" |
| 96 | depends on SND_SOC_SAMSUNG && ARCH_S3C24XX | 85 | depends on SND_SOC_SAMSUNG && ARCH_S3C24XX |
| 97 | select S3C2410_DMA | ||
| 98 | select AC97_BUS | 86 | select AC97_BUS |
| 99 | select SND_SOC_AC97_CODEC | 87 | select SND_SOC_AC97_CODEC |
| 100 | select SND_SAMSUNG_AC97 | 88 | select SND_SAMSUNG_AC97 |
| @@ -154,7 +142,7 @@ config SND_SOC_SAMSUNG_SMDK_WM9713 | |||
| 154 | 142 | ||
| 155 | config SND_SOC_SMARTQ | 143 | config SND_SOC_SMARTQ |
| 156 | tristate "SoC I2S Audio support for SmartQ board" | 144 | tristate "SoC I2S Audio support for SmartQ board" |
| 157 | depends on SND_SOC_SAMSUNG && MACH_SMARTQ | 145 | depends on SND_SOC_SAMSUNG && MACH_SMARTQ && I2C |
| 158 | select SND_SAMSUNG_I2S | 146 | select SND_SAMSUNG_I2S |
| 159 | select SND_SOC_WM8750 | 147 | select SND_SOC_WM8750 |
| 160 | 148 | ||
| @@ -178,7 +166,7 @@ config SND_SOC_SAMSUNG_SMDK_SPDIF | |||
| 178 | 166 | ||
| 179 | config SND_SOC_SMDK_WM8580_PCM | 167 | config SND_SOC_SMDK_WM8580_PCM |
| 180 | tristate "SoC PCM Audio support for WM8580 on SMDK" | 168 | tristate "SoC PCM Audio support for WM8580 on SMDK" |
| 181 | depends on SND_SOC_SAMSUNG && (MACH_SMDK6450 || MACH_SMDKV210 || MACH_SMDKC110) | 169 | depends on SND_SOC_SAMSUNG && (MACH_SMDKV210 || MACH_SMDKC110) |
| 182 | depends on REGMAP_I2C | 170 | depends on REGMAP_I2C |
| 183 | select SND_SOC_WM8580 | 171 | select SND_SOC_WM8580 |
| 184 | select SND_SAMSUNG_PCM | 172 | select SND_SAMSUNG_PCM |
| @@ -206,7 +194,7 @@ config SND_SOC_SPEYSIDE | |||
| 206 | 194 | ||
| 207 | config SND_SOC_TOBERMORY | 195 | config SND_SOC_TOBERMORY |
| 208 | tristate "Audio support for Wolfson Tobermory" | 196 | tristate "Audio support for Wolfson Tobermory" |
| 209 | depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 && INPUT | 197 | depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 && INPUT && I2C |
| 210 | select SND_SAMSUNG_I2S | 198 | select SND_SAMSUNG_I2S |
| 211 | select SND_SOC_WM8962 | 199 | select SND_SOC_WM8962 |
| 212 | 200 | ||
| @@ -222,7 +210,7 @@ config SND_SOC_BELLS | |||
| 222 | 210 | ||
| 223 | config SND_SOC_LOWLAND | 211 | config SND_SOC_LOWLAND |
| 224 | tristate "Audio support for Wolfson Lowland" | 212 | tristate "Audio support for Wolfson Lowland" |
| 225 | depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 | 213 | depends on SND_SOC_SAMSUNG && MACH_WLF_CRAGG_6410 && I2C |
| 226 | select SND_SAMSUNG_I2S | 214 | select SND_SAMSUNG_I2S |
| 227 | select SND_SOC_WM5100 | 215 | select SND_SOC_WM5100 |
| 228 | select SND_SOC_WM9081 | 216 | select SND_SOC_WM9081 |
| @@ -236,10 +224,18 @@ config SND_SOC_LITTLEMILL | |||
| 236 | 224 | ||
| 237 | config SND_SOC_SNOW | 225 | config SND_SOC_SNOW |
| 238 | tristate "Audio support for Google Snow boards" | 226 | tristate "Audio support for Google Snow boards" |
| 239 | depends on SND_SOC_SAMSUNG | 227 | depends on SND_SOC_SAMSUNG && I2C |
| 240 | select SND_SOC_MAX98090 | 228 | select SND_SOC_MAX98090 |
| 241 | select SND_SOC_MAX98095 | 229 | select SND_SOC_MAX98095 |
| 242 | select SND_SAMSUNG_I2S | 230 | select SND_SAMSUNG_I2S |
| 243 | help | 231 | help |
| 244 | Say Y if you want to add audio support for various Snow | 232 | Say Y if you want to add audio support for various Snow |
| 245 | boards based on Exynos5 series of SoCs. | 233 | boards based on Exynos5 series of SoCs. |
| 234 | |||
| 235 | config SND_SOC_ODROIDX2 | ||
| 236 | tristate "Audio support for Odroid-X2 and Odroid-U3" | ||
| 237 | depends on SND_SOC_SAMSUNG | ||
| 238 | select SND_SOC_MAX98090 | ||
| 239 | select SND_SAMSUNG_I2S | ||
| 240 | help | ||
| 241 | Say Y here to enable audio support for the Odroid-X2/U3. | ||
diff --git a/sound/soc/samsung/Makefile b/sound/soc/samsung/Makefile index 6d0212ba571c..91505ddaaf95 100644 --- a/sound/soc/samsung/Makefile +++ b/sound/soc/samsung/Makefile | |||
| @@ -1,6 +1,5 @@ | |||
| 1 | # S3c24XX Platform Support | 1 | # S3c24XX Platform Support |
| 2 | snd-soc-s3c-dma-objs := dmaengine.o | 2 | snd-soc-s3c-dma-objs := dmaengine.o |
| 3 | snd-soc-s3c-dma-legacy-objs := dma.o | ||
| 4 | snd-soc-idma-objs := idma.o | 3 | snd-soc-idma-objs := idma.o |
| 5 | snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o | 4 | snd-soc-s3c24xx-i2s-objs := s3c24xx-i2s.o |
| 6 | snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o | 5 | snd-soc-s3c2412-i2s-objs := s3c2412-i2s.o |
| @@ -10,8 +9,7 @@ snd-soc-samsung-spdif-objs := spdif.o | |||
| 10 | snd-soc-pcm-objs := pcm.o | 9 | snd-soc-pcm-objs := pcm.o |
| 11 | snd-soc-i2s-objs := i2s.o | 10 | snd-soc-i2s-objs := i2s.o |
| 12 | 11 | ||
| 13 | obj-$(CONFIG_SND_S3C_DMA) += snd-soc-s3c-dma.o | 12 | obj-$(CONFIG_SND_SOC_SAMSUNG) += snd-soc-s3c-dma.o |
| 14 | obj-$(CONFIG_SND_S3C_DMA_LEGACY) += snd-soc-s3c-dma-legacy.o | ||
| 15 | obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o | 13 | obj-$(CONFIG_SND_S3C24XX_I2S) += snd-soc-s3c24xx-i2s.o |
| 16 | obj-$(CONFIG_SND_SAMSUNG_AC97) += snd-soc-ac97.o | 14 | obj-$(CONFIG_SND_SAMSUNG_AC97) += snd-soc-ac97.o |
| 17 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o | 15 | obj-$(CONFIG_SND_S3C2412_SOC_I2S) += snd-soc-s3c2412-i2s.o |
| @@ -46,6 +44,7 @@ snd-soc-tobermory-objs := tobermory.o | |||
| 46 | snd-soc-lowland-objs := lowland.o | 44 | snd-soc-lowland-objs := lowland.o |
| 47 | snd-soc-littlemill-objs := littlemill.o | 45 | snd-soc-littlemill-objs := littlemill.o |
| 48 | snd-soc-bells-objs := bells.o | 46 | snd-soc-bells-objs := bells.o |
| 47 | snd-soc-odroidx2-max98090-objs := odroidx2_max98090.o | ||
| 49 | 48 | ||
| 50 | obj-$(CONFIG_SND_SOC_SAMSUNG_JIVE_WM8750) += snd-soc-jive-wm8750.o | 49 | obj-$(CONFIG_SND_SOC_SAMSUNG_JIVE_WM8750) += snd-soc-jive-wm8750.o |
| 51 | obj-$(CONFIG_SND_SOC_SAMSUNG_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o | 50 | obj-$(CONFIG_SND_SOC_SAMSUNG_NEO1973_WM8753) += snd-soc-neo1973-wm8753.o |
| @@ -71,3 +70,4 @@ obj-$(CONFIG_SND_SOC_TOBERMORY) += snd-soc-tobermory.o | |||
| 71 | obj-$(CONFIG_SND_SOC_LOWLAND) += snd-soc-lowland.o | 70 | obj-$(CONFIG_SND_SOC_LOWLAND) += snd-soc-lowland.o |
| 72 | obj-$(CONFIG_SND_SOC_LITTLEMILL) += snd-soc-littlemill.o | 71 | obj-$(CONFIG_SND_SOC_LITTLEMILL) += snd-soc-littlemill.o |
| 73 | obj-$(CONFIG_SND_SOC_BELLS) += snd-soc-bells.o | 72 | obj-$(CONFIG_SND_SOC_BELLS) += snd-soc-bells.o |
| 73 | obj-$(CONFIG_SND_SOC_ODROIDX2) += snd-soc-odroidx2-max98090.o | ||
diff --git a/sound/soc/samsung/ac97.c b/sound/soc/samsung/ac97.c index 68d9303047e8..e1615113fd84 100644 --- a/sound/soc/samsung/ac97.c +++ b/sound/soc/samsung/ac97.c | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | 19 | ||
| 20 | #include <sound/soc.h> | 20 | #include <sound/soc.h> |
| 21 | 21 | ||
| 22 | #include <mach/dma.h> | ||
| 23 | #include "regs-ac97.h" | 22 | #include "regs-ac97.h" |
| 24 | #include <linux/platform_data/asoc-s3c.h> | 23 | #include <linux/platform_data/asoc-s3c.h> |
| 25 | 24 | ||
| @@ -39,30 +38,15 @@ struct s3c_ac97_info { | |||
| 39 | }; | 38 | }; |
| 40 | static struct s3c_ac97_info s3c_ac97; | 39 | static struct s3c_ac97_info s3c_ac97; |
| 41 | 40 | ||
| 42 | static struct s3c_dma_client s3c_dma_client_out = { | ||
| 43 | .name = "AC97 PCMOut" | ||
| 44 | }; | ||
| 45 | |||
| 46 | static struct s3c_dma_client s3c_dma_client_in = { | ||
| 47 | .name = "AC97 PCMIn" | ||
| 48 | }; | ||
| 49 | |||
| 50 | static struct s3c_dma_client s3c_dma_client_micin = { | ||
| 51 | .name = "AC97 MicIn" | ||
| 52 | }; | ||
| 53 | |||
| 54 | static struct s3c_dma_params s3c_ac97_pcm_out = { | 41 | static struct s3c_dma_params s3c_ac97_pcm_out = { |
| 55 | .client = &s3c_dma_client_out, | ||
| 56 | .dma_size = 4, | 42 | .dma_size = 4, |
| 57 | }; | 43 | }; |
| 58 | 44 | ||
| 59 | static struct s3c_dma_params s3c_ac97_pcm_in = { | 45 | static struct s3c_dma_params s3c_ac97_pcm_in = { |
| 60 | .client = &s3c_dma_client_in, | ||
| 61 | .dma_size = 4, | 46 | .dma_size = 4, |
| 62 | }; | 47 | }; |
| 63 | 48 | ||
| 64 | static struct s3c_dma_params s3c_ac97_mic_in = { | 49 | static struct s3c_dma_params s3c_ac97_mic_in = { |
| 65 | .client = &s3c_dma_client_micin, | ||
| 66 | .dma_size = 4, | 50 | .dma_size = 4, |
| 67 | }; | 51 | }; |
| 68 | 52 | ||
| @@ -225,9 +209,6 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 225 | struct snd_soc_dai *dai) | 209 | struct snd_soc_dai *dai) |
| 226 | { | 210 | { |
| 227 | u32 ac_glbctrl; | 211 | u32 ac_glbctrl; |
| 228 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 229 | struct s3c_dma_params *dma_data = | ||
| 230 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 231 | 212 | ||
| 232 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); | 213 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); |
| 233 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) | 214 | if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) |
| @@ -253,11 +234,6 @@ static int s3c_ac97_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 253 | 234 | ||
| 254 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); | 235 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); |
| 255 | 236 | ||
| 256 | if (!dma_data->ops) | ||
| 257 | dma_data->ops = samsung_dma_get_ops(); | ||
| 258 | |||
| 259 | dma_data->ops->started(dma_data->channel); | ||
| 260 | |||
| 261 | return 0; | 237 | return 0; |
| 262 | } | 238 | } |
| 263 | 239 | ||
| @@ -265,9 +241,6 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, | |||
| 265 | int cmd, struct snd_soc_dai *dai) | 241 | int cmd, struct snd_soc_dai *dai) |
| 266 | { | 242 | { |
| 267 | u32 ac_glbctrl; | 243 | u32 ac_glbctrl; |
| 268 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 269 | struct s3c_dma_params *dma_data = | ||
| 270 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 271 | 244 | ||
| 272 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); | 245 | ac_glbctrl = readl(s3c_ac97.regs + S3C_AC97_GLBCTRL); |
| 273 | ac_glbctrl &= ~S3C_AC97_GLBCTRL_MICINTM_MASK; | 246 | ac_glbctrl &= ~S3C_AC97_GLBCTRL_MICINTM_MASK; |
| @@ -287,11 +260,6 @@ static int s3c_ac97_mic_trigger(struct snd_pcm_substream *substream, | |||
| 287 | 260 | ||
| 288 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); | 261 | writel(ac_glbctrl, s3c_ac97.regs + S3C_AC97_GLBCTRL); |
| 289 | 262 | ||
| 290 | if (!dma_data->ops) | ||
| 291 | dma_data->ops = samsung_dma_get_ops(); | ||
| 292 | |||
| 293 | dma_data->ops->started(dma_data->channel); | ||
| 294 | |||
| 295 | return 0; | 263 | return 0; |
| 296 | } | 264 | } |
| 297 | 265 | ||
diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c deleted file mode 100644 index d9dc7bcc0336..000000000000 --- a/sound/soc/samsung/dma.c +++ /dev/null | |||
| @@ -1,454 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * dma.c -- ALSA Soc Audio Layer | ||
| 3 | * | ||
| 4 | * (c) 2006 Wolfson Microelectronics PLC. | ||
| 5 | * Graeme Gregory graeme.gregory@wolfsonmicro.com or linux@wolfsonmicro.com | ||
| 6 | * | ||
| 7 | * Copyright 2004-2005 Simtec Electronics | ||
| 8 | * http://armlinux.simtec.co.uk/ | ||
| 9 | * Ben Dooks <ben@simtec.co.uk> | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or modify it | ||
| 12 | * under the terms of the GNU General Public License as published by the | ||
| 13 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 14 | * option) any later version. | ||
| 15 | */ | ||
| 16 | |||
| 17 | #include <linux/slab.h> | ||
| 18 | #include <linux/dma-mapping.h> | ||
| 19 | #include <linux/module.h> | ||
| 20 | |||
| 21 | #include <sound/soc.h> | ||
| 22 | #include <sound/pcm_params.h> | ||
| 23 | |||
| 24 | #include <asm/dma.h> | ||
| 25 | #include <mach/hardware.h> | ||
| 26 | #include <mach/dma.h> | ||
| 27 | |||
| 28 | #include "dma.h" | ||
| 29 | |||
| 30 | #define ST_RUNNING (1<<0) | ||
| 31 | #define ST_OPENED (1<<1) | ||
| 32 | |||
| 33 | static const struct snd_pcm_hardware dma_hardware = { | ||
| 34 | .info = SNDRV_PCM_INFO_INTERLEAVED | | ||
| 35 | SNDRV_PCM_INFO_BLOCK_TRANSFER | | ||
| 36 | SNDRV_PCM_INFO_MMAP | | ||
| 37 | SNDRV_PCM_INFO_MMAP_VALID, | ||
| 38 | .buffer_bytes_max = 128*1024, | ||
| 39 | .period_bytes_min = PAGE_SIZE, | ||
| 40 | .period_bytes_max = PAGE_SIZE*2, | ||
| 41 | .periods_min = 2, | ||
| 42 | .periods_max = 128, | ||
| 43 | .fifo_size = 32, | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct runtime_data { | ||
| 47 | spinlock_t lock; | ||
| 48 | int state; | ||
| 49 | unsigned int dma_loaded; | ||
| 50 | unsigned int dma_period; | ||
| 51 | dma_addr_t dma_start; | ||
| 52 | dma_addr_t dma_pos; | ||
| 53 | dma_addr_t dma_end; | ||
| 54 | struct s3c_dma_params *params; | ||
| 55 | }; | ||
| 56 | |||
| 57 | static void audio_buffdone(void *data); | ||
| 58 | |||
| 59 | /* dma_enqueue | ||
| 60 | * | ||
| 61 | * place a dma buffer onto the queue for the dma system | ||
| 62 | * to handle. | ||
| 63 | */ | ||
| 64 | static void dma_enqueue(struct snd_pcm_substream *substream) | ||
| 65 | { | ||
| 66 | struct runtime_data *prtd = substream->runtime->private_data; | ||
| 67 | dma_addr_t pos = prtd->dma_pos; | ||
| 68 | unsigned int limit; | ||
| 69 | struct samsung_dma_prep dma_info; | ||
| 70 | |||
| 71 | pr_debug("Entered %s\n", __func__); | ||
| 72 | |||
| 73 | limit = (prtd->dma_end - prtd->dma_start) / prtd->dma_period; | ||
| 74 | |||
| 75 | pr_debug("%s: loaded %d, limit %d\n", | ||
| 76 | __func__, prtd->dma_loaded, limit); | ||
| 77 | |||
| 78 | dma_info.cap = (samsung_dma_has_circular() ? DMA_CYCLIC : DMA_SLAVE); | ||
| 79 | dma_info.direction = | ||
| 80 | (substream->stream == SNDRV_PCM_STREAM_PLAYBACK | ||
| 81 | ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); | ||
| 82 | dma_info.fp = audio_buffdone; | ||
| 83 | dma_info.fp_param = substream; | ||
| 84 | dma_info.period = prtd->dma_period; | ||
| 85 | dma_info.len = prtd->dma_period*limit; | ||
| 86 | |||
| 87 | if (dma_info.cap == DMA_CYCLIC) { | ||
| 88 | dma_info.buf = pos; | ||
| 89 | prtd->params->ops->prepare(prtd->params->ch, &dma_info); | ||
| 90 | prtd->dma_loaded += limit; | ||
| 91 | return; | ||
| 92 | } | ||
| 93 | |||
| 94 | while (prtd->dma_loaded < limit) { | ||
| 95 | pr_debug("dma_loaded: %d\n", prtd->dma_loaded); | ||
| 96 | |||
| 97 | if ((pos + dma_info.period) > prtd->dma_end) { | ||
| 98 | dma_info.period = prtd->dma_end - pos; | ||
| 99 | pr_debug("%s: corrected dma len %ld\n", | ||
| 100 | __func__, dma_info.period); | ||
| 101 | } | ||
| 102 | |||
| 103 | dma_info.buf = pos; | ||
| 104 | prtd->params->ops->prepare(prtd->params->ch, &dma_info); | ||
| 105 | |||
| 106 | prtd->dma_loaded++; | ||
| 107 | pos += prtd->dma_period; | ||
| 108 | if (pos >= prtd->dma_end) | ||
| 109 | pos = prtd->dma_start; | ||
| 110 | } | ||
| 111 | |||
| 112 | prtd->dma_pos = pos; | ||
| 113 | } | ||
| 114 | |||
| 115 | static void audio_buffdone(void *data) | ||
| 116 | { | ||
| 117 | struct snd_pcm_substream *substream = data; | ||
| 118 | struct runtime_data *prtd = substream->runtime->private_data; | ||
| 119 | |||
| 120 | pr_debug("Entered %s\n", __func__); | ||
| 121 | |||
| 122 | if (prtd->state & ST_RUNNING) { | ||
| 123 | prtd->dma_pos += prtd->dma_period; | ||
| 124 | if (prtd->dma_pos >= prtd->dma_end) | ||
| 125 | prtd->dma_pos = prtd->dma_start; | ||
| 126 | |||
| 127 | if (substream) | ||
| 128 | snd_pcm_period_elapsed(substream); | ||
| 129 | |||
| 130 | spin_lock(&prtd->lock); | ||
| 131 | if (!samsung_dma_has_circular()) { | ||
| 132 | prtd->dma_loaded--; | ||
| 133 | dma_enqueue(substream); | ||
| 134 | } | ||
| 135 | spin_unlock(&prtd->lock); | ||
| 136 | } | ||
| 137 | } | ||
| 138 | |||
| 139 | static int dma_hw_params(struct snd_pcm_substream *substream, | ||
| 140 | struct snd_pcm_hw_params *params) | ||
| 141 | { | ||
| 142 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 143 | struct runtime_data *prtd = runtime->private_data; | ||
| 144 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 145 | unsigned long totbytes = params_buffer_bytes(params); | ||
| 146 | struct s3c_dma_params *dma = | ||
| 147 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 148 | struct samsung_dma_req req; | ||
| 149 | struct samsung_dma_config config; | ||
| 150 | |||
| 151 | pr_debug("Entered %s\n", __func__); | ||
| 152 | |||
| 153 | /* return if this is a bufferless transfer e.g. | ||
| 154 | * codec <--> BT codec or GSM modem -- lg FIXME */ | ||
| 155 | if (!dma) | ||
| 156 | return 0; | ||
| 157 | |||
| 158 | /* this may get called several times by oss emulation | ||
| 159 | * with different params -HW */ | ||
| 160 | if (prtd->params == NULL) { | ||
| 161 | /* prepare DMA */ | ||
| 162 | prtd->params = dma; | ||
| 163 | |||
| 164 | pr_debug("params %p, client %p, channel %d\n", prtd->params, | ||
| 165 | prtd->params->client, prtd->params->channel); | ||
| 166 | |||
| 167 | prtd->params->ops = samsung_dma_get_ops(); | ||
| 168 | |||
| 169 | req.cap = (samsung_dma_has_circular() ? | ||
| 170 | DMA_CYCLIC : DMA_SLAVE); | ||
| 171 | req.client = prtd->params->client; | ||
| 172 | config.direction = | ||
| 173 | (substream->stream == SNDRV_PCM_STREAM_PLAYBACK | ||
| 174 | ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); | ||
| 175 | config.width = prtd->params->dma_size; | ||
| 176 | config.fifo = prtd->params->dma_addr; | ||
| 177 | prtd->params->ch = prtd->params->ops->request( | ||
| 178 | prtd->params->channel, &req, rtd->cpu_dai->dev, | ||
| 179 | prtd->params->ch_name); | ||
| 180 | if (!prtd->params->ch) { | ||
| 181 | pr_err("Failed to allocate DMA channel\n"); | ||
| 182 | return -ENXIO; | ||
| 183 | } | ||
| 184 | prtd->params->ops->config(prtd->params->ch, &config); | ||
| 185 | } | ||
| 186 | |||
| 187 | snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); | ||
| 188 | |||
| 189 | runtime->dma_bytes = totbytes; | ||
| 190 | |||
| 191 | spin_lock_irq(&prtd->lock); | ||
| 192 | prtd->dma_loaded = 0; | ||
| 193 | prtd->dma_period = params_period_bytes(params); | ||
| 194 | prtd->dma_start = runtime->dma_addr; | ||
| 195 | prtd->dma_pos = prtd->dma_start; | ||
| 196 | prtd->dma_end = prtd->dma_start + totbytes; | ||
| 197 | spin_unlock_irq(&prtd->lock); | ||
| 198 | |||
| 199 | return 0; | ||
| 200 | } | ||
| 201 | |||
| 202 | static int dma_hw_free(struct snd_pcm_substream *substream) | ||
| 203 | { | ||
| 204 | struct runtime_data *prtd = substream->runtime->private_data; | ||
| 205 | |||
| 206 | pr_debug("Entered %s\n", __func__); | ||
| 207 | |||
| 208 | snd_pcm_set_runtime_buffer(substream, NULL); | ||
| 209 | |||
| 210 | if (prtd->params) { | ||
| 211 | prtd->params->ops->flush(prtd->params->ch); | ||
| 212 | prtd->params->ops->release(prtd->params->ch, | ||
| 213 | prtd->params->client); | ||
| 214 | prtd->params = NULL; | ||
| 215 | } | ||
| 216 | |||
| 217 | return 0; | ||
| 218 | } | ||
| 219 | |||
| 220 | static int dma_prepare(struct snd_pcm_substream *substream) | ||
| 221 | { | ||
| 222 | struct runtime_data *prtd = substream->runtime->private_data; | ||
| 223 | int ret = 0; | ||
| 224 | |||
| 225 | pr_debug("Entered %s\n", __func__); | ||
| 226 | |||
| 227 | /* return if this is a bufferless transfer e.g. | ||
| 228 | * codec <--> BT codec or GSM modem -- lg FIXME */ | ||
| 229 | if (!prtd->params) | ||
| 230 | return 0; | ||
| 231 | |||
| 232 | /* flush the DMA channel */ | ||
| 233 | prtd->params->ops->flush(prtd->params->ch); | ||
| 234 | |||
| 235 | prtd->dma_loaded = 0; | ||
| 236 | prtd->dma_pos = prtd->dma_start; | ||
| 237 | |||
| 238 | /* enqueue dma buffers */ | ||
| 239 | dma_enqueue(substream); | ||
| 240 | |||
| 241 | return ret; | ||
| 242 | } | ||
| 243 | |||
| 244 | static int dma_trigger(struct snd_pcm_substream *substream, int cmd) | ||
| 245 | { | ||
| 246 | struct runtime_data *prtd = substream->runtime->private_data; | ||
| 247 | int ret = 0; | ||
| 248 | |||
| 249 | pr_debug("Entered %s\n", __func__); | ||
| 250 | |||
| 251 | spin_lock(&prtd->lock); | ||
| 252 | |||
| 253 | switch (cmd) { | ||
| 254 | case SNDRV_PCM_TRIGGER_START: | ||
| 255 | prtd->state |= ST_RUNNING; | ||
| 256 | prtd->params->ops->trigger(prtd->params->ch); | ||
| 257 | break; | ||
| 258 | |||
| 259 | case SNDRV_PCM_TRIGGER_STOP: | ||
| 260 | prtd->state &= ~ST_RUNNING; | ||
| 261 | prtd->params->ops->stop(prtd->params->ch); | ||
| 262 | break; | ||
| 263 | |||
| 264 | default: | ||
| 265 | ret = -EINVAL; | ||
| 266 | break; | ||
| 267 | } | ||
| 268 | |||
| 269 | spin_unlock(&prtd->lock); | ||
| 270 | |||
| 271 | return ret; | ||
| 272 | } | ||
| 273 | |||
| 274 | static snd_pcm_uframes_t | ||
| 275 | dma_pointer(struct snd_pcm_substream *substream) | ||
| 276 | { | ||
| 277 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 278 | struct runtime_data *prtd = runtime->private_data; | ||
| 279 | unsigned long res; | ||
| 280 | |||
| 281 | pr_debug("Entered %s\n", __func__); | ||
| 282 | |||
| 283 | res = prtd->dma_pos - prtd->dma_start; | ||
| 284 | |||
| 285 | pr_debug("Pointer offset: %lu\n", res); | ||
| 286 | |||
| 287 | /* we seem to be getting the odd error from the pcm library due | ||
| 288 | * to out-of-bounds pointers. this is maybe due to the dma engine | ||
| 289 | * not having loaded the new values for the channel before being | ||
| 290 | * called... (todo - fix ) | ||
| 291 | */ | ||
| 292 | |||
| 293 | if (res >= snd_pcm_lib_buffer_bytes(substream)) { | ||
| 294 | if (res == snd_pcm_lib_buffer_bytes(substream)) | ||
| 295 | res = 0; | ||
| 296 | } | ||
| 297 | |||
| 298 | return bytes_to_frames(substream->runtime, res); | ||
| 299 | } | ||
| 300 | |||
| 301 | static int dma_open(struct snd_pcm_substream *substream) | ||
| 302 | { | ||
| 303 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 304 | struct runtime_data *prtd; | ||
| 305 | |||
| 306 | pr_debug("Entered %s\n", __func__); | ||
| 307 | |||
| 308 | snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS); | ||
| 309 | snd_soc_set_runtime_hwparams(substream, &dma_hardware); | ||
| 310 | |||
| 311 | prtd = kzalloc(sizeof(struct runtime_data), GFP_KERNEL); | ||
| 312 | if (prtd == NULL) | ||
| 313 | return -ENOMEM; | ||
| 314 | |||
| 315 | spin_lock_init(&prtd->lock); | ||
| 316 | |||
| 317 | runtime->private_data = prtd; | ||
| 318 | return 0; | ||
| 319 | } | ||
| 320 | |||
| 321 | static int dma_close(struct snd_pcm_substream *substream) | ||
| 322 | { | ||
| 323 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 324 | struct runtime_data *prtd = runtime->private_data; | ||
| 325 | |||
| 326 | pr_debug("Entered %s\n", __func__); | ||
| 327 | |||
| 328 | if (!prtd) | ||
| 329 | pr_debug("dma_close called with prtd == NULL\n"); | ||
| 330 | |||
| 331 | kfree(prtd); | ||
| 332 | |||
| 333 | return 0; | ||
| 334 | } | ||
| 335 | |||
| 336 | static int dma_mmap(struct snd_pcm_substream *substream, | ||
| 337 | struct vm_area_struct *vma) | ||
| 338 | { | ||
| 339 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 340 | |||
| 341 | pr_debug("Entered %s\n", __func__); | ||
| 342 | |||
| 343 | return dma_mmap_writecombine(substream->pcm->card->dev, vma, | ||
| 344 | runtime->dma_area, | ||
| 345 | runtime->dma_addr, | ||
| 346 | runtime->dma_bytes); | ||
| 347 | } | ||
| 348 | |||
| 349 | static struct snd_pcm_ops dma_ops = { | ||
| 350 | .open = dma_open, | ||
| 351 | .close = dma_close, | ||
| 352 | .ioctl = snd_pcm_lib_ioctl, | ||
| 353 | .hw_params = dma_hw_params, | ||
| 354 | .hw_free = dma_hw_free, | ||
| 355 | .prepare = dma_prepare, | ||
| 356 | .trigger = dma_trigger, | ||
| 357 | .pointer = dma_pointer, | ||
| 358 | .mmap = dma_mmap, | ||
| 359 | }; | ||
| 360 | |||
| 361 | static int preallocate_dma_buffer(struct snd_pcm *pcm, int stream) | ||
| 362 | { | ||
| 363 | struct snd_pcm_substream *substream = pcm->streams[stream].substream; | ||
| 364 | struct snd_dma_buffer *buf = &substream->dma_buffer; | ||
| 365 | size_t size = dma_hardware.buffer_bytes_max; | ||
| 366 | |||
| 367 | pr_debug("Entered %s\n", __func__); | ||
| 368 | |||
| 369 | buf->dev.type = SNDRV_DMA_TYPE_DEV; | ||
| 370 | buf->dev.dev = pcm->card->dev; | ||
| 371 | buf->private_data = NULL; | ||
| 372 | buf->area = dma_alloc_writecombine(pcm->card->dev, size, | ||
| 373 | &buf->addr, GFP_KERNEL); | ||
| 374 | if (!buf->area) | ||
| 375 | return -ENOMEM; | ||
| 376 | buf->bytes = size; | ||
| 377 | return 0; | ||
| 378 | } | ||
| 379 | |||
| 380 | static void dma_free_dma_buffers(struct snd_pcm *pcm) | ||
| 381 | { | ||
| 382 | struct snd_pcm_substream *substream; | ||
| 383 | struct snd_dma_buffer *buf; | ||
| 384 | int stream; | ||
| 385 | |||
| 386 | pr_debug("Entered %s\n", __func__); | ||
| 387 | |||
| 388 | for (stream = 0; stream < 2; stream++) { | ||
| 389 | substream = pcm->streams[stream].substream; | ||
| 390 | if (!substream) | ||
| 391 | continue; | ||
| 392 | |||
| 393 | buf = &substream->dma_buffer; | ||
| 394 | if (!buf->area) | ||
| 395 | continue; | ||
| 396 | |||
| 397 | dma_free_writecombine(pcm->card->dev, buf->bytes, | ||
| 398 | buf->area, buf->addr); | ||
| 399 | buf->area = NULL; | ||
| 400 | } | ||
| 401 | } | ||
| 402 | |||
| 403 | static int dma_new(struct snd_soc_pcm_runtime *rtd) | ||
| 404 | { | ||
| 405 | struct snd_card *card = rtd->card->snd_card; | ||
| 406 | struct snd_pcm *pcm = rtd->pcm; | ||
| 407 | int ret; | ||
| 408 | |||
| 409 | pr_debug("Entered %s\n", __func__); | ||
| 410 | |||
| 411 | ret = dma_coerce_mask_and_coherent(card->dev, DMA_BIT_MASK(32)); | ||
| 412 | if (ret) | ||
| 413 | return ret; | ||
| 414 | |||
| 415 | if (pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream) { | ||
| 416 | ret = preallocate_dma_buffer(pcm, | ||
| 417 | SNDRV_PCM_STREAM_PLAYBACK); | ||
| 418 | if (ret) | ||
| 419 | goto out; | ||
| 420 | } | ||
| 421 | |||
| 422 | if (pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream) { | ||
| 423 | ret = preallocate_dma_buffer(pcm, | ||
| 424 | SNDRV_PCM_STREAM_CAPTURE); | ||
| 425 | if (ret) | ||
| 426 | goto out; | ||
| 427 | } | ||
| 428 | out: | ||
| 429 | return ret; | ||
| 430 | } | ||
| 431 | |||
| 432 | static struct snd_soc_platform_driver samsung_asoc_platform = { | ||
| 433 | .ops = &dma_ops, | ||
| 434 | .pcm_new = dma_new, | ||
| 435 | .pcm_free = dma_free_dma_buffers, | ||
| 436 | }; | ||
| 437 | |||
| 438 | void samsung_asoc_init_dma_data(struct snd_soc_dai *dai, | ||
| 439 | struct s3c_dma_params *playback, | ||
| 440 | struct s3c_dma_params *capture) | ||
| 441 | { | ||
| 442 | snd_soc_dai_init_dma_data(dai, playback, capture); | ||
| 443 | } | ||
| 444 | EXPORT_SYMBOL_GPL(samsung_asoc_init_dma_data); | ||
| 445 | |||
| 446 | int samsung_asoc_dma_platform_register(struct device *dev) | ||
| 447 | { | ||
| 448 | return devm_snd_soc_register_platform(dev, &samsung_asoc_platform); | ||
| 449 | } | ||
| 450 | EXPORT_SYMBOL_GPL(samsung_asoc_dma_platform_register); | ||
| 451 | |||
| 452 | MODULE_AUTHOR("Ben Dooks, <ben@simtec.co.uk>"); | ||
| 453 | MODULE_DESCRIPTION("Samsung ASoC DMA Driver"); | ||
| 454 | MODULE_LICENSE("GPL"); | ||
diff --git a/sound/soc/samsung/dma.h b/sound/soc/samsung/dma.h index 070ab0f09609..0e85dcfec023 100644 --- a/sound/soc/samsung/dma.h +++ b/sound/soc/samsung/dma.h | |||
| @@ -14,17 +14,10 @@ | |||
| 14 | 14 | ||
| 15 | #include <sound/dmaengine_pcm.h> | 15 | #include <sound/dmaengine_pcm.h> |
| 16 | 16 | ||
| 17 | struct s3c_dma_client { | ||
| 18 | char *name; | ||
| 19 | }; | ||
| 20 | |||
| 21 | struct s3c_dma_params { | 17 | struct s3c_dma_params { |
| 22 | struct s3c_dma_client *client; /* stream identifier */ | ||
| 23 | int channel; /* Channel ID */ | 18 | int channel; /* Channel ID */ |
| 24 | dma_addr_t dma_addr; | 19 | dma_addr_t dma_addr; |
| 25 | int dma_size; /* Size of the DMA transfer */ | 20 | int dma_size; /* Size of the DMA transfer */ |
| 26 | unsigned ch; | ||
| 27 | struct samsung_dma_ops *ops; | ||
| 28 | char *ch_name; | 21 | char *ch_name; |
| 29 | struct snd_dmaengine_dai_dma_data dma_data; | 22 | struct snd_dmaengine_dai_dma_data dma_data; |
| 30 | }; | 23 | }; |
diff --git a/sound/soc/samsung/dmaengine.c b/sound/soc/samsung/dmaengine.c index a0e4e7948909..506f5bf6d082 100644 --- a/sound/soc/samsung/dmaengine.c +++ b/sound/soc/samsung/dmaengine.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | 17 | ||
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/amba/pl08x.h> | 19 | #include <linux/amba/pl08x.h> |
| 20 | #include <linux/platform_data/dma-s3c24xx.h> | ||
| 20 | 21 | ||
| 21 | #include <sound/core.h> | 22 | #include <sound/core.h> |
| 22 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
| @@ -29,6 +30,8 @@ | |||
| 29 | 30 | ||
| 30 | #ifdef CONFIG_ARCH_S3C64XX | 31 | #ifdef CONFIG_ARCH_S3C64XX |
| 31 | #define filter_fn pl08x_filter_id | 32 | #define filter_fn pl08x_filter_id |
| 33 | #elif defined(CONFIG_ARCH_S3C24XX) | ||
| 34 | #define filter_fn s3c24xx_dma_filter | ||
| 32 | #else | 35 | #else |
| 33 | #define filter_fn NULL | 36 | #define filter_fn NULL |
| 34 | #endif | 37 | #endif |
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index 2ac76fa3e742..03eec22f0f46 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c | |||
| @@ -68,6 +68,8 @@ struct i2s_dai { | |||
| 68 | #define DAI_OPENED (1 << 0) /* Dai is opened */ | 68 | #define DAI_OPENED (1 << 0) /* Dai is opened */ |
| 69 | #define DAI_MANAGER (1 << 1) /* Dai is the manager */ | 69 | #define DAI_MANAGER (1 << 1) /* Dai is the manager */ |
| 70 | unsigned mode; | 70 | unsigned mode; |
| 71 | /* CDCLK pin direction: 0 - input, 1 - output */ | ||
| 72 | unsigned int cdclk_out:1; | ||
| 71 | /* Driver for this DAI */ | 73 | /* Driver for this DAI */ |
| 72 | struct snd_soc_dai_driver i2s_dai_drv; | 74 | struct snd_soc_dai_driver i2s_dai_drv; |
| 73 | /* DMA parameters */ | 75 | /* DMA parameters */ |
| @@ -737,6 +739,9 @@ static int i2s_startup(struct snd_pcm_substream *substream, | |||
| 737 | 739 | ||
| 738 | spin_unlock_irqrestore(&lock, flags); | 740 | spin_unlock_irqrestore(&lock, flags); |
| 739 | 741 | ||
| 742 | if (!is_opened(other) && i2s->cdclk_out) | ||
| 743 | i2s_set_sysclk(dai, SAMSUNG_I2S_CDCLK, | ||
| 744 | 0, SND_SOC_CLOCK_OUT); | ||
| 740 | return 0; | 745 | return 0; |
| 741 | } | 746 | } |
| 742 | 747 | ||
| @@ -752,9 +757,13 @@ static void i2s_shutdown(struct snd_pcm_substream *substream, | |||
| 752 | i2s->mode &= ~DAI_OPENED; | 757 | i2s->mode &= ~DAI_OPENED; |
| 753 | i2s->mode &= ~DAI_MANAGER; | 758 | i2s->mode &= ~DAI_MANAGER; |
| 754 | 759 | ||
| 755 | if (is_opened(other)) | 760 | if (is_opened(other)) { |
| 756 | other->mode |= DAI_MANAGER; | 761 | other->mode |= DAI_MANAGER; |
| 757 | 762 | } else { | |
| 763 | u32 mod = readl(i2s->addr + I2SMOD); | ||
| 764 | i2s->cdclk_out = !(mod & MOD_CDCLKCON); | ||
| 765 | other->cdclk_out = i2s->cdclk_out; | ||
| 766 | } | ||
| 758 | /* Reset any constraint on RFS and BFS */ | 767 | /* Reset any constraint on RFS and BFS */ |
| 759 | i2s->rfs = 0; | 768 | i2s->rfs = 0; |
| 760 | i2s->bfs = 0; | 769 | i2s->bfs = 0; |
| @@ -920,11 +929,9 @@ static int i2s_suspend(struct snd_soc_dai *dai) | |||
| 920 | { | 929 | { |
| 921 | struct i2s_dai *i2s = to_info(dai); | 930 | struct i2s_dai *i2s = to_info(dai); |
| 922 | 931 | ||
| 923 | if (dai->active) { | 932 | i2s->suspend_i2smod = readl(i2s->addr + I2SMOD); |
| 924 | i2s->suspend_i2smod = readl(i2s->addr + I2SMOD); | 933 | i2s->suspend_i2scon = readl(i2s->addr + I2SCON); |
| 925 | i2s->suspend_i2scon = readl(i2s->addr + I2SCON); | 934 | i2s->suspend_i2spsr = readl(i2s->addr + I2SPSR); |
| 926 | i2s->suspend_i2spsr = readl(i2s->addr + I2SPSR); | ||
| 927 | } | ||
| 928 | 935 | ||
| 929 | return 0; | 936 | return 0; |
| 930 | } | 937 | } |
| @@ -933,11 +940,9 @@ static int i2s_resume(struct snd_soc_dai *dai) | |||
| 933 | { | 940 | { |
| 934 | struct i2s_dai *i2s = to_info(dai); | 941 | struct i2s_dai *i2s = to_info(dai); |
| 935 | 942 | ||
| 936 | if (dai->active) { | 943 | writel(i2s->suspend_i2scon, i2s->addr + I2SCON); |
| 937 | writel(i2s->suspend_i2scon, i2s->addr + I2SCON); | 944 | writel(i2s->suspend_i2smod, i2s->addr + I2SMOD); |
| 938 | writel(i2s->suspend_i2smod, i2s->addr + I2SMOD); | 945 | writel(i2s->suspend_i2spsr, i2s->addr + I2SPSR); |
| 939 | writel(i2s->suspend_i2spsr, i2s->addr + I2SPSR); | ||
| 940 | } | ||
| 941 | 946 | ||
| 942 | return 0; | 947 | return 0; |
| 943 | } | 948 | } |
| @@ -1216,11 +1221,7 @@ static int samsung_i2s_probe(struct platform_device *pdev) | |||
| 1216 | 1221 | ||
| 1217 | pri_dai->dma_playback.dma_addr = regs_base + I2STXD; | 1222 | pri_dai->dma_playback.dma_addr = regs_base + I2STXD; |
| 1218 | pri_dai->dma_capture.dma_addr = regs_base + I2SRXD; | 1223 | pri_dai->dma_capture.dma_addr = regs_base + I2SRXD; |
| 1219 | pri_dai->dma_playback.client = | ||
| 1220 | (struct s3c_dma_client *)&pri_dai->dma_playback; | ||
| 1221 | pri_dai->dma_playback.ch_name = "tx"; | 1224 | pri_dai->dma_playback.ch_name = "tx"; |
| 1222 | pri_dai->dma_capture.client = | ||
| 1223 | (struct s3c_dma_client *)&pri_dai->dma_capture; | ||
| 1224 | pri_dai->dma_capture.ch_name = "rx"; | 1225 | pri_dai->dma_capture.ch_name = "rx"; |
| 1225 | pri_dai->dma_playback.dma_size = 4; | 1226 | pri_dai->dma_playback.dma_size = 4; |
| 1226 | pri_dai->dma_capture.dma_size = 4; | 1227 | pri_dai->dma_capture.dma_size = 4; |
| @@ -1238,8 +1239,6 @@ static int samsung_i2s_probe(struct platform_device *pdev) | |||
| 1238 | goto err; | 1239 | goto err; |
| 1239 | } | 1240 | } |
| 1240 | sec_dai->dma_playback.dma_addr = regs_base + I2STXDS; | 1241 | sec_dai->dma_playback.dma_addr = regs_base + I2STXDS; |
| 1241 | sec_dai->dma_playback.client = | ||
| 1242 | (struct s3c_dma_client *)&sec_dai->dma_playback; | ||
| 1243 | sec_dai->dma_playback.ch_name = "tx-sec"; | 1242 | sec_dai->dma_playback.ch_name = "tx-sec"; |
| 1244 | 1243 | ||
| 1245 | if (!np) { | 1244 | if (!np) { |
diff --git a/sound/soc/samsung/idma.c b/sound/soc/samsung/idma.c index 8cc5770abb39..db6cefa18017 100644 --- a/sound/soc/samsung/idma.c +++ b/sound/soc/samsung/idma.c | |||
| @@ -261,10 +261,9 @@ static int idma_mmap(struct snd_pcm_substream *substream, | |||
| 261 | static irqreturn_t iis_irq(int irqno, void *dev_id) | 261 | static irqreturn_t iis_irq(int irqno, void *dev_id) |
| 262 | { | 262 | { |
| 263 | struct idma_ctrl *prtd = (struct idma_ctrl *)dev_id; | 263 | struct idma_ctrl *prtd = (struct idma_ctrl *)dev_id; |
| 264 | u32 iiscon, iisahb, val, addr; | 264 | u32 iisahb, val, addr; |
| 265 | 265 | ||
| 266 | iisahb = readl(idma.regs + I2SAHB); | 266 | iisahb = readl(idma.regs + I2SAHB); |
| 267 | iiscon = readl(idma.regs + I2SCON); | ||
| 268 | 267 | ||
| 269 | val = (iisahb & AHB_LVL0INT) ? AHB_CLRLVL0INT : 0; | 268 | val = (iisahb & AHB_LVL0INT) ? AHB_CLRLVL0INT : 0; |
| 270 | 269 | ||
diff --git a/sound/soc/samsung/odroidx2_max98090.c b/sound/soc/samsung/odroidx2_max98090.c new file mode 100644 index 000000000000..278edf9e2a87 --- /dev/null +++ b/sound/soc/samsung/odroidx2_max98090.c | |||
| @@ -0,0 +1,177 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2014 Samsung Electronics Co., Ltd. | ||
| 3 | * | ||
| 4 | * This program is free software; you can redistribute it and/or modify it | ||
| 5 | * under the terms of the GNU General Public License as published by the | ||
| 6 | * Free Software Foundation; either version 2 of the License, or (at your | ||
| 7 | * option) any later version. | ||
| 8 | */ | ||
| 9 | |||
| 10 | #include <linux/of.h> | ||
| 11 | #include <linux/module.h> | ||
| 12 | #include <sound/soc.h> | ||
| 13 | #include <sound/pcm_params.h> | ||
| 14 | #include "i2s.h" | ||
| 15 | |||
| 16 | struct odroidx2_drv_data { | ||
| 17 | const struct snd_soc_dapm_widget *dapm_widgets; | ||
| 18 | unsigned int num_dapm_widgets; | ||
| 19 | }; | ||
| 20 | |||
| 21 | /* The I2S CDCLK output clock frequency for the MAX98090 codec */ | ||
| 22 | #define MAX98090_MCLK 19200000 | ||
| 23 | |||
| 24 | static int odroidx2_late_probe(struct snd_soc_card *card) | ||
| 25 | { | ||
| 26 | struct snd_soc_dai *codec_dai = card->rtd[0].codec_dai; | ||
| 27 | struct snd_soc_dai *cpu_dai = card->rtd[0].cpu_dai; | ||
| 28 | int ret; | ||
| 29 | |||
| 30 | ret = snd_soc_dai_set_sysclk(codec_dai, 0, MAX98090_MCLK, | ||
| 31 | SND_SOC_CLOCK_IN); | ||
| 32 | if (ret < 0) | ||
| 33 | return ret; | ||
| 34 | |||
| 35 | /* Set the cpu DAI configuration in order to use CDCLK */ | ||
| 36 | return snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_CDCLK, | ||
| 37 | 0, SND_SOC_CLOCK_OUT); | ||
| 38 | } | ||
| 39 | |||
| 40 | static const struct snd_soc_dapm_widget odroidx2_dapm_widgets[] = { | ||
| 41 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | ||
| 42 | SND_SOC_DAPM_MIC("Mic Jack", NULL), | ||
| 43 | SND_SOC_DAPM_MIC("DMIC", NULL), | ||
| 44 | }; | ||
| 45 | |||
| 46 | static const struct snd_soc_dapm_widget odroidu3_dapm_widgets[] = { | ||
| 47 | SND_SOC_DAPM_HP("Headphone Jack", NULL), | ||
| 48 | SND_SOC_DAPM_SPK("Speakers", NULL), | ||
| 49 | }; | ||
| 50 | |||
| 51 | static struct snd_soc_dai_link odroidx2_dai[] = { | ||
| 52 | { | ||
| 53 | .name = "MAX98090", | ||
| 54 | .stream_name = "MAX98090 PCM", | ||
| 55 | .codec_dai_name = "HiFi", | ||
| 56 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | | ||
| 57 | SND_SOC_DAIFMT_CBM_CFM, | ||
| 58 | } | ||
| 59 | }; | ||
| 60 | |||
| 61 | static struct snd_soc_card odroidx2 = { | ||
| 62 | .owner = THIS_MODULE, | ||
| 63 | .dai_link = odroidx2_dai, | ||
| 64 | .num_links = ARRAY_SIZE(odroidx2_dai), | ||
| 65 | .fully_routed = true, | ||
| 66 | .late_probe = odroidx2_late_probe, | ||
| 67 | }; | ||
| 68 | |||
| 69 | struct odroidx2_drv_data odroidx2_drvdata = { | ||
| 70 | .dapm_widgets = odroidx2_dapm_widgets, | ||
| 71 | .num_dapm_widgets = ARRAY_SIZE(odroidx2_dapm_widgets), | ||
| 72 | }; | ||
| 73 | |||
| 74 | struct odroidx2_drv_data odroidu3_drvdata = { | ||
| 75 | .dapm_widgets = odroidu3_dapm_widgets, | ||
| 76 | .num_dapm_widgets = ARRAY_SIZE(odroidu3_dapm_widgets), | ||
| 77 | }; | ||
| 78 | |||
| 79 | static const struct of_device_id odroidx2_audio_of_match[] = { | ||
| 80 | { | ||
| 81 | .compatible = "samsung,odroidx2-audio", | ||
| 82 | .data = &odroidx2_drvdata, | ||
| 83 | }, { | ||
| 84 | .compatible = "samsung,odroidu3-audio", | ||
| 85 | .data = &odroidu3_drvdata, | ||
| 86 | }, | ||
| 87 | { }, | ||
| 88 | }; | ||
| 89 | MODULE_DEVICE_TABLE(of, odroidx2_audio_of_match); | ||
| 90 | |||
| 91 | static int odroidx2_audio_probe(struct platform_device *pdev) | ||
| 92 | { | ||
| 93 | struct device_node *snd_node = pdev->dev.of_node; | ||
| 94 | struct snd_soc_card *card = &odroidx2; | ||
| 95 | struct device_node *i2s_node, *codec_node; | ||
| 96 | struct odroidx2_drv_data *dd; | ||
| 97 | const struct of_device_id *of_id; | ||
| 98 | int ret; | ||
| 99 | |||
| 100 | of_id = of_match_node(odroidx2_audio_of_match, snd_node); | ||
| 101 | dd = (struct odroidx2_drv_data *)of_id->data; | ||
| 102 | |||
| 103 | card->num_dapm_widgets = dd->num_dapm_widgets; | ||
| 104 | card->dapm_widgets = dd->dapm_widgets; | ||
| 105 | |||
| 106 | card->dev = &pdev->dev; | ||
| 107 | |||
| 108 | ret = snd_soc_of_parse_card_name(card, "samsung,model"); | ||
| 109 | if (ret < 0) | ||
| 110 | return ret; | ||
| 111 | |||
| 112 | ret = snd_soc_of_parse_audio_routing(card, "samsung,audio-routing"); | ||
| 113 | if (ret < 0) | ||
| 114 | return ret; | ||
| 115 | |||
| 116 | codec_node = of_parse_phandle(snd_node, "samsung,audio-codec", 0); | ||
| 117 | if (!codec_node) { | ||
| 118 | dev_err(&pdev->dev, | ||
| 119 | "Failed parsing samsung,i2s-codec property\n"); | ||
| 120 | return -EINVAL; | ||
| 121 | } | ||
| 122 | |||
| 123 | i2s_node = of_parse_phandle(snd_node, "samsung,i2s-controller", 0); | ||
| 124 | if (!i2s_node) { | ||
| 125 | dev_err(&pdev->dev, | ||
| 126 | "Failed parsing samsung,i2s-controller property\n"); | ||
| 127 | ret = -EINVAL; | ||
| 128 | goto err_put_codec_n; | ||
| 129 | } | ||
| 130 | |||
| 131 | odroidx2_dai[0].codec_of_node = codec_node; | ||
| 132 | odroidx2_dai[0].cpu_of_node = i2s_node; | ||
| 133 | odroidx2_dai[0].platform_of_node = i2s_node; | ||
| 134 | |||
| 135 | ret = snd_soc_register_card(card); | ||
| 136 | if (ret) { | ||
| 137 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | ||
| 138 | ret); | ||
| 139 | goto err_put_i2s_n; | ||
| 140 | } | ||
| 141 | return 0; | ||
| 142 | |||
| 143 | err_put_i2s_n: | ||
| 144 | of_node_put(i2s_node); | ||
| 145 | err_put_codec_n: | ||
| 146 | of_node_put(codec_node); | ||
| 147 | return ret; | ||
| 148 | } | ||
| 149 | |||
| 150 | static int odroidx2_audio_remove(struct platform_device *pdev) | ||
| 151 | { | ||
| 152 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
| 153 | |||
| 154 | snd_soc_unregister_card(card); | ||
| 155 | |||
| 156 | of_node_put((struct device_node *)odroidx2_dai[0].cpu_of_node); | ||
| 157 | of_node_put((struct device_node *)odroidx2_dai[0].codec_of_node); | ||
| 158 | |||
| 159 | return 0; | ||
| 160 | } | ||
| 161 | |||
| 162 | static struct platform_driver odroidx2_audio_driver = { | ||
| 163 | .driver = { | ||
| 164 | .name = "odroidx2-audio", | ||
| 165 | .owner = THIS_MODULE, | ||
| 166 | .of_match_table = odroidx2_audio_of_match, | ||
| 167 | .pm = &snd_soc_pm_ops, | ||
| 168 | }, | ||
| 169 | .probe = odroidx2_audio_probe, | ||
| 170 | .remove = odroidx2_audio_remove, | ||
| 171 | }; | ||
| 172 | module_platform_driver(odroidx2_audio_driver); | ||
| 173 | |||
| 174 | MODULE_AUTHOR("Chen Zhen <zhen1.chen@samsung.com>"); | ||
| 175 | MODULE_AUTHOR("Sylwester Nawrocki <s.nawrocki@samsung.com>"); | ||
| 176 | MODULE_DESCRIPTION("ALSA SoC Odroid X2/U3 Audio Support"); | ||
| 177 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/samsung/pcm.c b/sound/soc/samsung/pcm.c index 4c5f97fe45c8..bac034b15a27 100644 --- a/sound/soc/samsung/pcm.c +++ b/sound/soc/samsung/pcm.c | |||
| @@ -131,32 +131,20 @@ struct s3c_pcm_info { | |||
| 131 | struct s3c_dma_params *dma_capture; | 131 | struct s3c_dma_params *dma_capture; |
| 132 | }; | 132 | }; |
| 133 | 133 | ||
| 134 | static struct s3c_dma_client s3c_pcm_dma_client_out = { | ||
| 135 | .name = "PCM Stereo out" | ||
| 136 | }; | ||
| 137 | |||
| 138 | static struct s3c_dma_client s3c_pcm_dma_client_in = { | ||
| 139 | .name = "PCM Stereo in" | ||
| 140 | }; | ||
| 141 | |||
| 142 | static struct s3c_dma_params s3c_pcm_stereo_out[] = { | 134 | static struct s3c_dma_params s3c_pcm_stereo_out[] = { |
| 143 | [0] = { | 135 | [0] = { |
| 144 | .client = &s3c_pcm_dma_client_out, | ||
| 145 | .dma_size = 4, | 136 | .dma_size = 4, |
| 146 | }, | 137 | }, |
| 147 | [1] = { | 138 | [1] = { |
| 148 | .client = &s3c_pcm_dma_client_out, | ||
| 149 | .dma_size = 4, | 139 | .dma_size = 4, |
| 150 | }, | 140 | }, |
| 151 | }; | 141 | }; |
| 152 | 142 | ||
| 153 | static struct s3c_dma_params s3c_pcm_stereo_in[] = { | 143 | static struct s3c_dma_params s3c_pcm_stereo_in[] = { |
| 154 | [0] = { | 144 | [0] = { |
| 155 | .client = &s3c_pcm_dma_client_in, | ||
| 156 | .dma_size = 4, | 145 | .dma_size = 4, |
| 157 | }, | 146 | }, |
| 158 | [1] = { | 147 | [1] = { |
| 159 | .client = &s3c_pcm_dma_client_in, | ||
| 160 | .dma_size = 4, | 148 | .dma_size = 4, |
| 161 | }, | 149 | }, |
| 162 | }; | 150 | }; |
diff --git a/sound/soc/samsung/s3c-i2s-v2.c b/sound/soc/samsung/s3c-i2s-v2.c index 0ff4bbe23af3..df65c5b494b1 100644 --- a/sound/soc/samsung/s3c-i2s-v2.c +++ b/sound/soc/samsung/s3c-i2s-v2.c | |||
| @@ -22,8 +22,6 @@ | |||
| 22 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
| 23 | #include <sound/pcm_params.h> | 23 | #include <sound/pcm_params.h> |
| 24 | 24 | ||
| 25 | #include <mach/dma.h> | ||
| 26 | |||
| 27 | #include "regs-i2s-v2.h" | 25 | #include "regs-i2s-v2.h" |
| 28 | #include "s3c-i2s-v2.h" | 26 | #include "s3c-i2s-v2.h" |
| 29 | #include "dma.h" | 27 | #include "dma.h" |
| @@ -392,8 +390,6 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 392 | int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); | 390 | int capture = (substream->stream == SNDRV_PCM_STREAM_CAPTURE); |
| 393 | unsigned long irqs; | 391 | unsigned long irqs; |
| 394 | int ret = 0; | 392 | int ret = 0; |
| 395 | struct s3c_dma_params *dma_data = | ||
| 396 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 397 | 393 | ||
| 398 | pr_debug("Entered %s\n", __func__); | 394 | pr_debug("Entered %s\n", __func__); |
| 399 | 395 | ||
| @@ -424,13 +420,6 @@ static int s3c2412_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 424 | 420 | ||
| 425 | local_irq_restore(irqs); | 421 | local_irq_restore(irqs); |
| 426 | 422 | ||
| 427 | /* | ||
| 428 | * Load the next buffer to DMA to meet the reqirement | ||
| 429 | * of the auto reload mechanism of S3C24XX. | ||
| 430 | * This call won't bother S3C64XX. | ||
| 431 | */ | ||
| 432 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); | ||
| 433 | |||
| 434 | break; | 423 | break; |
| 435 | 424 | ||
| 436 | case SNDRV_PCM_TRIGGER_STOP: | 425 | case SNDRV_PCM_TRIGGER_STOP: |
| @@ -644,12 +633,6 @@ int s3c_i2sv2_probe(struct snd_soc_dai *dai, | |||
| 644 | /* record our i2s structure for later use in the callbacks */ | 633 | /* record our i2s structure for later use in the callbacks */ |
| 645 | snd_soc_dai_set_drvdata(dai, i2s); | 634 | snd_soc_dai_set_drvdata(dai, i2s); |
| 646 | 635 | ||
| 647 | i2s->regs = ioremap(base, 0x100); | ||
| 648 | if (i2s->regs == NULL) { | ||
| 649 | dev_err(dev, "cannot ioremap registers\n"); | ||
| 650 | return -ENXIO; | ||
| 651 | } | ||
| 652 | |||
| 653 | i2s->iis_pclk = clk_get(dev, "iis"); | 636 | i2s->iis_pclk = clk_get(dev, "iis"); |
| 654 | if (IS_ERR(i2s->iis_pclk)) { | 637 | if (IS_ERR(i2s->iis_pclk)) { |
| 655 | dev_err(dev, "failed to get iis_clock\n"); | 638 | dev_err(dev, "failed to get iis_clock\n"); |
| @@ -729,7 +712,7 @@ int s3c_i2sv2_register_component(struct device *dev, int id, | |||
| 729 | struct snd_soc_component_driver *cmp_drv, | 712 | struct snd_soc_component_driver *cmp_drv, |
| 730 | struct snd_soc_dai_driver *dai_drv) | 713 | struct snd_soc_dai_driver *dai_drv) |
| 731 | { | 714 | { |
| 732 | struct snd_soc_dai_ops *ops = dai_drv->ops; | 715 | struct snd_soc_dai_ops *ops = (struct snd_soc_dai_ops *)dai_drv->ops; |
| 733 | 716 | ||
| 734 | ops->trigger = s3c2412_i2s_trigger; | 717 | ops->trigger = s3c2412_i2s_trigger; |
| 735 | if (!ops->hw_params) | 718 | if (!ops->hw_params) |
diff --git a/sound/soc/samsung/s3c2412-i2s.c b/sound/soc/samsung/s3c2412-i2s.c index 08c059be9104..27b339c6580e 100644 --- a/sound/soc/samsung/s3c2412-i2s.c +++ b/sound/soc/samsung/s3c2412-i2s.c | |||
| @@ -33,25 +33,15 @@ | |||
| 33 | #include "regs-i2s-v2.h" | 33 | #include "regs-i2s-v2.h" |
| 34 | #include "s3c2412-i2s.h" | 34 | #include "s3c2412-i2s.h" |
| 35 | 35 | ||
| 36 | static struct s3c_dma_client s3c2412_dma_client_out = { | ||
| 37 | .name = "I2S PCM Stereo out" | ||
| 38 | }; | ||
| 39 | |||
| 40 | static struct s3c_dma_client s3c2412_dma_client_in = { | ||
| 41 | .name = "I2S PCM Stereo in" | ||
| 42 | }; | ||
| 43 | |||
| 44 | static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { | 36 | static struct s3c_dma_params s3c2412_i2s_pcm_stereo_out = { |
| 45 | .client = &s3c2412_dma_client_out, | ||
| 46 | .channel = DMACH_I2S_OUT, | 37 | .channel = DMACH_I2S_OUT, |
| 47 | .dma_addr = S3C2410_PA_IIS + S3C2412_IISTXD, | 38 | .ch_name = "tx", |
| 48 | .dma_size = 4, | 39 | .dma_size = 4, |
| 49 | }; | 40 | }; |
| 50 | 41 | ||
| 51 | static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { | 42 | static struct s3c_dma_params s3c2412_i2s_pcm_stereo_in = { |
| 52 | .client = &s3c2412_dma_client_in, | ||
| 53 | .channel = DMACH_I2S_IN, | 43 | .channel = DMACH_I2S_IN, |
| 54 | .dma_addr = S3C2410_PA_IIS + S3C2412_IISRXD, | 44 | .ch_name = "rx", |
| 55 | .dma_size = 4, | 45 | .dma_size = 4, |
| 56 | }; | 46 | }; |
| 57 | 47 | ||
| @@ -63,6 +53,9 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai) | |||
| 63 | 53 | ||
| 64 | pr_debug("Entered %s\n", __func__); | 54 | pr_debug("Entered %s\n", __func__); |
| 65 | 55 | ||
| 56 | samsung_asoc_init_dma_data(dai, &s3c2412_i2s_pcm_stereo_out, | ||
| 57 | &s3c2412_i2s_pcm_stereo_in); | ||
| 58 | |||
| 66 | ret = s3c_i2sv2_probe(dai, &s3c2412_i2s, S3C2410_PA_IIS); | 59 | ret = s3c_i2sv2_probe(dai, &s3c2412_i2s, S3C2410_PA_IIS); |
| 67 | if (ret) | 60 | if (ret) |
| 68 | return ret; | 61 | return ret; |
| @@ -70,17 +63,16 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai) | |||
| 70 | s3c2412_i2s.dma_capture = &s3c2412_i2s_pcm_stereo_in; | 63 | s3c2412_i2s.dma_capture = &s3c2412_i2s_pcm_stereo_in; |
| 71 | s3c2412_i2s.dma_playback = &s3c2412_i2s_pcm_stereo_out; | 64 | s3c2412_i2s.dma_playback = &s3c2412_i2s_pcm_stereo_out; |
| 72 | 65 | ||
| 73 | s3c2412_i2s.iis_cclk = clk_get(dai->dev, "i2sclk"); | 66 | s3c2412_i2s.iis_cclk = devm_clk_get(dai->dev, "i2sclk"); |
| 74 | if (IS_ERR(s3c2412_i2s.iis_cclk)) { | 67 | if (IS_ERR(s3c2412_i2s.iis_cclk)) { |
| 75 | pr_err("failed to get i2sclk clock\n"); | 68 | pr_err("failed to get i2sclk clock\n"); |
| 76 | iounmap(s3c2412_i2s.regs); | ||
| 77 | return PTR_ERR(s3c2412_i2s.iis_cclk); | 69 | return PTR_ERR(s3c2412_i2s.iis_cclk); |
| 78 | } | 70 | } |
| 79 | 71 | ||
| 80 | /* Set MPLL as the source for IIS CLK */ | 72 | /* Set MPLL as the source for IIS CLK */ |
| 81 | 73 | ||
| 82 | clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll")); | 74 | clk_set_parent(s3c2412_i2s.iis_cclk, clk_get(NULL, "mpll")); |
| 83 | clk_enable(s3c2412_i2s.iis_cclk); | 75 | clk_prepare_enable(s3c2412_i2s.iis_cclk); |
| 84 | 76 | ||
| 85 | s3c2412_i2s.iis_cclk = s3c2412_i2s.iis_pclk; | 77 | s3c2412_i2s.iis_cclk = s3c2412_i2s.iis_pclk; |
| 86 | 78 | ||
| @@ -93,9 +85,7 @@ static int s3c2412_i2s_probe(struct snd_soc_dai *dai) | |||
| 93 | 85 | ||
| 94 | static int s3c2412_i2s_remove(struct snd_soc_dai *dai) | 86 | static int s3c2412_i2s_remove(struct snd_soc_dai *dai) |
| 95 | { | 87 | { |
| 96 | clk_disable(s3c2412_i2s.iis_cclk); | 88 | clk_disable_unprepare(s3c2412_i2s.iis_cclk); |
| 97 | clk_put(s3c2412_i2s.iis_cclk); | ||
| 98 | iounmap(s3c2412_i2s.regs); | ||
| 99 | 89 | ||
| 100 | return 0; | 90 | return 0; |
| 101 | } | 91 | } |
| @@ -105,18 +95,10 @@ static int s3c2412_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 105 | struct snd_soc_dai *cpu_dai) | 95 | struct snd_soc_dai *cpu_dai) |
| 106 | { | 96 | { |
| 107 | struct s3c_i2sv2_info *i2s = snd_soc_dai_get_drvdata(cpu_dai); | 97 | struct s3c_i2sv2_info *i2s = snd_soc_dai_get_drvdata(cpu_dai); |
| 108 | struct s3c_dma_params *dma_data; | ||
| 109 | u32 iismod; | 98 | u32 iismod; |
| 110 | 99 | ||
| 111 | pr_debug("Entered %s\n", __func__); | 100 | pr_debug("Entered %s\n", __func__); |
| 112 | 101 | ||
| 113 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 114 | dma_data = i2s->dma_playback; | ||
| 115 | else | ||
| 116 | dma_data = i2s->dma_capture; | ||
| 117 | |||
| 118 | snd_soc_dai_set_dma_data(cpu_dai, substream, dma_data); | ||
| 119 | |||
| 120 | iismod = readl(i2s->regs + S3C2412_IISMOD); | 102 | iismod = readl(i2s->regs + S3C2412_IISMOD); |
| 121 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); | 103 | pr_debug("%s: r: IISMOD: %x\n", __func__, iismod); |
| 122 | 104 | ||
| @@ -169,6 +151,15 @@ static const struct snd_soc_component_driver s3c2412_i2s_component = { | |||
| 169 | static int s3c2412_iis_dev_probe(struct platform_device *pdev) | 151 | static int s3c2412_iis_dev_probe(struct platform_device *pdev) |
| 170 | { | 152 | { |
| 171 | int ret = 0; | 153 | int ret = 0; |
| 154 | struct resource *res; | ||
| 155 | |||
| 156 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 157 | s3c2412_i2s.regs = devm_ioremap_resource(&pdev->dev, res); | ||
| 158 | if (IS_ERR(s3c2412_i2s.regs)) | ||
| 159 | return PTR_ERR(s3c2412_i2s.regs); | ||
| 160 | |||
| 161 | s3c2412_i2s_pcm_stereo_out.dma_addr = res->start + S3C2412_IISTXD; | ||
| 162 | s3c2412_i2s_pcm_stereo_in.dma_addr = res->start + S3C2412_IISRXD; | ||
| 172 | 163 | ||
| 173 | ret = s3c_i2sv2_register_component(&pdev->dev, -1, | 164 | ret = s3c_i2sv2_register_component(&pdev->dev, -1, |
| 174 | &s3c2412_i2s_component, | 165 | &s3c2412_i2s_component, |
diff --git a/sound/soc/samsung/s3c24xx-i2s.c b/sound/soc/samsung/s3c24xx-i2s.c index 9aba9fb7df0e..e87d9a2053b8 100644 --- a/sound/soc/samsung/s3c24xx-i2s.c +++ b/sound/soc/samsung/s3c24xx-i2s.c | |||
| @@ -31,25 +31,15 @@ | |||
| 31 | #include "dma.h" | 31 | #include "dma.h" |
| 32 | #include "s3c24xx-i2s.h" | 32 | #include "s3c24xx-i2s.h" |
| 33 | 33 | ||
| 34 | static struct s3c_dma_client s3c24xx_dma_client_out = { | ||
| 35 | .name = "I2S PCM Stereo out" | ||
| 36 | }; | ||
| 37 | |||
| 38 | static struct s3c_dma_client s3c24xx_dma_client_in = { | ||
| 39 | .name = "I2S PCM Stereo in" | ||
| 40 | }; | ||
| 41 | |||
| 42 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { | 34 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_out = { |
| 43 | .client = &s3c24xx_dma_client_out, | ||
| 44 | .channel = DMACH_I2S_OUT, | 35 | .channel = DMACH_I2S_OUT, |
| 45 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, | 36 | .ch_name = "tx", |
| 46 | .dma_size = 2, | 37 | .dma_size = 2, |
| 47 | }; | 38 | }; |
| 48 | 39 | ||
| 49 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { | 40 | static struct s3c_dma_params s3c24xx_i2s_pcm_stereo_in = { |
| 50 | .client = &s3c24xx_dma_client_in, | ||
| 51 | .channel = DMACH_I2S_IN, | 41 | .channel = DMACH_I2S_IN, |
| 52 | .dma_addr = S3C2410_PA_IIS + S3C2410_IISFIFO, | 42 | .ch_name = "rx", |
| 53 | .dma_size = 2, | 43 | .dma_size = 2, |
| 54 | }; | 44 | }; |
| 55 | 45 | ||
| @@ -231,18 +221,12 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 231 | struct snd_pcm_hw_params *params, | 221 | struct snd_pcm_hw_params *params, |
| 232 | struct snd_soc_dai *dai) | 222 | struct snd_soc_dai *dai) |
| 233 | { | 223 | { |
| 234 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 224 | struct snd_dmaengine_dai_dma_data *dma_data; |
| 235 | struct s3c_dma_params *dma_data; | ||
| 236 | u32 iismod; | 225 | u32 iismod; |
| 237 | 226 | ||
| 238 | pr_debug("Entered %s\n", __func__); | 227 | pr_debug("Entered %s\n", __func__); |
| 239 | 228 | ||
| 240 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | 229 | dma_data = snd_soc_dai_get_dma_data(dai, substream); |
| 241 | dma_data = &s3c24xx_i2s_pcm_stereo_out; | ||
| 242 | else | ||
| 243 | dma_data = &s3c24xx_i2s_pcm_stereo_in; | ||
| 244 | |||
| 245 | snd_soc_dai_set_dma_data(rtd->cpu_dai, substream, dma_data); | ||
| 246 | 230 | ||
| 247 | /* Working copies of register */ | 231 | /* Working copies of register */ |
| 248 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); | 232 | iismod = readl(s3c24xx_i2s.regs + S3C2410_IISMOD); |
| @@ -251,11 +235,11 @@ static int s3c24xx_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 251 | switch (params_width(params)) { | 235 | switch (params_width(params)) { |
| 252 | case 8: | 236 | case 8: |
| 253 | iismod &= ~S3C2410_IISMOD_16BIT; | 237 | iismod &= ~S3C2410_IISMOD_16BIT; |
| 254 | dma_data->dma_size = 1; | 238 | dma_data->addr_width = 1; |
| 255 | break; | 239 | break; |
| 256 | case 16: | 240 | case 16: |
| 257 | iismod |= S3C2410_IISMOD_16BIT; | 241 | iismod |= S3C2410_IISMOD_16BIT; |
| 258 | dma_data->dma_size = 2; | 242 | dma_data->addr_width = 2; |
| 259 | break; | 243 | break; |
| 260 | default: | 244 | default: |
| 261 | return -EINVAL; | 245 | return -EINVAL; |
| @@ -270,8 +254,6 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 270 | struct snd_soc_dai *dai) | 254 | struct snd_soc_dai *dai) |
| 271 | { | 255 | { |
| 272 | int ret = 0; | 256 | int ret = 0; |
| 273 | struct s3c_dma_params *dma_data = | ||
| 274 | snd_soc_dai_get_dma_data(dai, substream); | ||
| 275 | 257 | ||
| 276 | pr_debug("Entered %s\n", __func__); | 258 | pr_debug("Entered %s\n", __func__); |
| 277 | 259 | ||
| @@ -290,7 +272,6 @@ static int s3c24xx_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 290 | else | 272 | else |
| 291 | s3c24xx_snd_txctrl(1); | 273 | s3c24xx_snd_txctrl(1); |
| 292 | 274 | ||
| 293 | s3c2410_dma_ctrl(dma_data->channel, S3C2410_DMAOP_STARTED); | ||
| 294 | break; | 275 | break; |
| 295 | case SNDRV_PCM_TRIGGER_STOP: | 276 | case SNDRV_PCM_TRIGGER_STOP: |
| 296 | case SNDRV_PCM_TRIGGER_SUSPEND: | 277 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| @@ -380,17 +361,15 @@ static int s3c24xx_i2s_probe(struct snd_soc_dai *dai) | |||
| 380 | { | 361 | { |
| 381 | pr_debug("Entered %s\n", __func__); | 362 | pr_debug("Entered %s\n", __func__); |
| 382 | 363 | ||
| 383 | s3c24xx_i2s.regs = ioremap(S3C2410_PA_IIS, 0x100); | 364 | samsung_asoc_init_dma_data(dai, &s3c24xx_i2s_pcm_stereo_out, |
| 384 | if (s3c24xx_i2s.regs == NULL) | 365 | &s3c24xx_i2s_pcm_stereo_in); |
| 385 | return -ENXIO; | ||
| 386 | 366 | ||
| 387 | s3c24xx_i2s.iis_clk = clk_get(dai->dev, "iis"); | 367 | s3c24xx_i2s.iis_clk = devm_clk_get(dai->dev, "iis"); |
| 388 | if (IS_ERR(s3c24xx_i2s.iis_clk)) { | 368 | if (IS_ERR(s3c24xx_i2s.iis_clk)) { |
| 389 | pr_err("failed to get iis_clock\n"); | 369 | pr_err("failed to get iis_clock\n"); |
| 390 | iounmap(s3c24xx_i2s.regs); | ||
| 391 | return PTR_ERR(s3c24xx_i2s.iis_clk); | 370 | return PTR_ERR(s3c24xx_i2s.iis_clk); |
| 392 | } | 371 | } |
| 393 | clk_enable(s3c24xx_i2s.iis_clk); | 372 | clk_prepare_enable(s3c24xx_i2s.iis_clk); |
| 394 | 373 | ||
| 395 | /* Configure the I2S pins (GPE0...GPE4) in correct mode */ | 374 | /* Configure the I2S pins (GPE0...GPE4) in correct mode */ |
| 396 | s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2), | 375 | s3c_gpio_cfgall_range(S3C2410_GPE(0), 5, S3C_GPIO_SFN(2), |
| @@ -414,7 +393,7 @@ static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) | |||
| 414 | s3c24xx_i2s.iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); | 393 | s3c24xx_i2s.iisfcon = readl(s3c24xx_i2s.regs + S3C2410_IISFCON); |
| 415 | s3c24xx_i2s.iispsr = readl(s3c24xx_i2s.regs + S3C2410_IISPSR); | 394 | s3c24xx_i2s.iispsr = readl(s3c24xx_i2s.regs + S3C2410_IISPSR); |
| 416 | 395 | ||
| 417 | clk_disable(s3c24xx_i2s.iis_clk); | 396 | clk_disable_unprepare(s3c24xx_i2s.iis_clk); |
| 418 | 397 | ||
| 419 | return 0; | 398 | return 0; |
| 420 | } | 399 | } |
| @@ -422,7 +401,7 @@ static int s3c24xx_i2s_suspend(struct snd_soc_dai *cpu_dai) | |||
| 422 | static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) | 401 | static int s3c24xx_i2s_resume(struct snd_soc_dai *cpu_dai) |
| 423 | { | 402 | { |
| 424 | pr_debug("Entered %s\n", __func__); | 403 | pr_debug("Entered %s\n", __func__); |
| 425 | clk_enable(s3c24xx_i2s.iis_clk); | 404 | clk_prepare_enable(s3c24xx_i2s.iis_clk); |
| 426 | 405 | ||
| 427 | writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); | 406 | writel(s3c24xx_i2s.iiscon, s3c24xx_i2s.regs + S3C2410_IISCON); |
| 428 | writel(s3c24xx_i2s.iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); | 407 | writel(s3c24xx_i2s.iismod, s3c24xx_i2s.regs + S3C2410_IISMOD); |
| @@ -474,6 +453,19 @@ static const struct snd_soc_component_driver s3c24xx_i2s_component = { | |||
| 474 | static int s3c24xx_iis_dev_probe(struct platform_device *pdev) | 453 | static int s3c24xx_iis_dev_probe(struct platform_device *pdev) |
| 475 | { | 454 | { |
| 476 | int ret = 0; | 455 | int ret = 0; |
| 456 | struct resource *res; | ||
| 457 | |||
| 458 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 459 | if (!res) { | ||
| 460 | dev_err(&pdev->dev, "Can't get IO resource.\n"); | ||
| 461 | return -ENOENT; | ||
| 462 | } | ||
| 463 | s3c24xx_i2s.regs = devm_ioremap_resource(&pdev->dev, res); | ||
| 464 | if (s3c24xx_i2s.regs == NULL) | ||
| 465 | return -ENXIO; | ||
| 466 | |||
| 467 | s3c24xx_i2s_pcm_stereo_out.dma_addr = res->start + S3C2410_IISFIFO; | ||
| 468 | s3c24xx_i2s_pcm_stereo_in.dma_addr = res->start + S3C2410_IISFIFO; | ||
| 477 | 469 | ||
| 478 | ret = devm_snd_soc_register_component(&pdev->dev, | 470 | ret = devm_snd_soc_register_component(&pdev->dev, |
| 479 | &s3c24xx_i2s_component, &s3c24xx_i2s_dai, 1); | 471 | &s3c24xx_i2s_component, &s3c24xx_i2s_dai, 1); |
diff --git a/sound/soc/samsung/smdk_wm8580pcm.c b/sound/soc/samsung/smdk_wm8580pcm.c index e119aaa91c28..63d079303561 100644 --- a/sound/soc/samsung/smdk_wm8580pcm.c +++ b/sound/soc/samsung/smdk_wm8580pcm.c | |||
| @@ -25,7 +25,7 @@ | |||
| 25 | * o '0' means 'OFF' | 25 | * o '0' means 'OFF' |
| 26 | * o 'X' means 'Don't care' | 26 | * o 'X' means 'Don't care' |
| 27 | * | 27 | * |
| 28 | * SMDK6410, SMDK6440, SMDK6450 Base B/D: CFG1-0000, CFG2-1111 | 28 | * SMDK6410 Base B/D: CFG1-0000, CFG2-1111 |
| 29 | * SMDKC110, SMDKV210: CFGB11-100100, CFGB12-0000 | 29 | * SMDKC110, SMDKV210: CFGB11-100100, CFGB12-0000 |
| 30 | */ | 30 | */ |
| 31 | 31 | ||
diff --git a/sound/soc/samsung/snow.c b/sound/soc/samsung/snow.c index 014c177840ba..0acf5d0eed53 100644 --- a/sound/soc/samsung/snow.c +++ b/sound/soc/samsung/snow.c | |||
| @@ -92,6 +92,9 @@ static int snow_probe(struct platform_device *pdev) | |||
| 92 | 92 | ||
| 93 | card->dev = &pdev->dev; | 93 | card->dev = &pdev->dev; |
| 94 | 94 | ||
| 95 | /* Update card-name if provided through DT, else use default name */ | ||
| 96 | snd_soc_of_parse_card_name(card, "samsung,model"); | ||
| 97 | |||
| 95 | ret = devm_snd_soc_register_card(&pdev->dev, card); | 98 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 96 | if (ret) { | 99 | if (ret) { |
| 97 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | 100 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); |
| @@ -103,6 +106,7 @@ static int snow_probe(struct platform_device *pdev) | |||
| 103 | 106 | ||
| 104 | static const struct of_device_id snow_of_match[] = { | 107 | static const struct of_device_id snow_of_match[] = { |
| 105 | { .compatible = "google,snow-audio-max98090", }, | 108 | { .compatible = "google,snow-audio-max98090", }, |
| 109 | { .compatible = "google,snow-audio-max98091", }, | ||
| 106 | { .compatible = "google,snow-audio-max98095", }, | 110 | { .compatible = "google,snow-audio-max98095", }, |
| 107 | {}, | 111 | {}, |
| 108 | }; | 112 | }; |
diff --git a/sound/soc/samsung/spdif.c b/sound/soc/samsung/spdif.c index d9ffc48fce5e..d7d2e208f486 100644 --- a/sound/soc/samsung/spdif.c +++ b/sound/soc/samsung/spdif.c | |||
| @@ -93,10 +93,6 @@ struct samsung_spdif_info { | |||
| 93 | struct s3c_dma_params *dma_playback; | 93 | struct s3c_dma_params *dma_playback; |
| 94 | }; | 94 | }; |
| 95 | 95 | ||
| 96 | static struct s3c_dma_client spdif_dma_client_out = { | ||
| 97 | .name = "S/PDIF Stereo out", | ||
| 98 | }; | ||
| 99 | |||
| 100 | static struct s3c_dma_params spdif_stereo_out; | 96 | static struct s3c_dma_params spdif_stereo_out; |
| 101 | static struct samsung_spdif_info spdif_info; | 97 | static struct samsung_spdif_info spdif_info; |
| 102 | 98 | ||
| @@ -435,7 +431,6 @@ static int spdif_probe(struct platform_device *pdev) | |||
| 435 | } | 431 | } |
| 436 | 432 | ||
| 437 | spdif_stereo_out.dma_size = 2; | 433 | spdif_stereo_out.dma_size = 2; |
| 438 | spdif_stereo_out.client = &spdif_dma_client_out; | ||
| 439 | spdif_stereo_out.dma_addr = mem_res->start + DATA_OUTBUF; | 434 | spdif_stereo_out.dma_addr = mem_res->start + DATA_OUTBUF; |
| 440 | spdif_stereo_out.channel = dma_res->start; | 435 | spdif_stereo_out.channel = dma_res->start; |
| 441 | 436 | ||
diff --git a/sound/soc/sh/Kconfig b/sound/soc/sh/Kconfig index b43fdf0d08af..80245b6eebd6 100644 --- a/sound/soc/sh/Kconfig +++ b/sound/soc/sh/Kconfig | |||
| @@ -37,7 +37,7 @@ config SND_SOC_SH4_SIU | |||
| 37 | config SND_SOC_RCAR | 37 | config SND_SOC_RCAR |
| 38 | tristate "R-Car series SRU/SCU/SSIU/SSI support" | 38 | tristate "R-Car series SRU/SCU/SSIU/SSI support" |
| 39 | select SND_SIMPLE_CARD | 39 | select SND_SIMPLE_CARD |
| 40 | select REGMAP | 40 | select REGMAP_MMIO |
| 41 | help | 41 | help |
| 42 | This option enables R-Car SUR/SCU/SSIU/SSI sound support | 42 | This option enables R-Car SUR/SCU/SSIU/SSI sound support |
| 43 | 43 | ||
diff --git a/sound/soc/sh/fsi.c b/sound/soc/sh/fsi.c index 710a079a7377..c76344350e44 100644 --- a/sound/soc/sh/fsi.c +++ b/sound/soc/sh/fsi.c | |||
| @@ -232,11 +232,7 @@ struct fsi_stream { | |||
| 232 | * these are for DMAEngine | 232 | * these are for DMAEngine |
| 233 | */ | 233 | */ |
| 234 | struct dma_chan *chan; | 234 | struct dma_chan *chan; |
| 235 | struct work_struct work; | ||
| 236 | dma_addr_t dma; | ||
| 237 | int dma_id; | 235 | int dma_id; |
| 238 | int loop_cnt; | ||
| 239 | int additional_pos; | ||
| 240 | }; | 236 | }; |
| 241 | 237 | ||
| 242 | struct fsi_clk { | 238 | struct fsi_clk { |
| @@ -264,12 +260,12 @@ struct fsi_priv { | |||
| 264 | u32 fmt; | 260 | u32 fmt; |
| 265 | 261 | ||
| 266 | int chan_num:16; | 262 | int chan_num:16; |
| 267 | int clk_master:1; | 263 | unsigned int clk_master:1; |
| 268 | int clk_cpg:1; | 264 | unsigned int clk_cpg:1; |
| 269 | int spdif:1; | 265 | unsigned int spdif:1; |
| 270 | int enable_stream:1; | 266 | unsigned int enable_stream:1; |
| 271 | int bit_clk_inv:1; | 267 | unsigned int bit_clk_inv:1; |
| 272 | int lr_clk_inv:1; | 268 | unsigned int lr_clk_inv:1; |
| 273 | }; | 269 | }; |
| 274 | 270 | ||
| 275 | struct fsi_stream_handler { | 271 | struct fsi_stream_handler { |
| @@ -1042,6 +1038,26 @@ static int fsi_clk_set_rate_cpg(struct device *dev, | |||
| 1042 | return ret; | 1038 | return ret; |
| 1043 | } | 1039 | } |
| 1044 | 1040 | ||
| 1041 | static void fsi_pointer_update(struct fsi_stream *io, int size) | ||
| 1042 | { | ||
| 1043 | io->buff_sample_pos += size; | ||
| 1044 | |||
| 1045 | if (io->buff_sample_pos >= | ||
| 1046 | io->period_samples * (io->period_pos + 1)) { | ||
| 1047 | struct snd_pcm_substream *substream = io->substream; | ||
| 1048 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 1049 | |||
| 1050 | io->period_pos++; | ||
| 1051 | |||
| 1052 | if (io->period_pos >= runtime->periods) { | ||
| 1053 | io->buff_sample_pos = 0; | ||
| 1054 | io->period_pos = 0; | ||
| 1055 | } | ||
| 1056 | |||
| 1057 | snd_pcm_period_elapsed(substream); | ||
| 1058 | } | ||
| 1059 | } | ||
| 1060 | |||
| 1045 | /* | 1061 | /* |
| 1046 | * pio data transfer handler | 1062 | * pio data transfer handler |
| 1047 | */ | 1063 | */ |
| @@ -1108,31 +1124,11 @@ static int fsi_pio_transfer(struct fsi_priv *fsi, struct fsi_stream *io, | |||
| 1108 | void (*run32)(struct fsi_priv *fsi, u8 *buf, int samples), | 1124 | void (*run32)(struct fsi_priv *fsi, u8 *buf, int samples), |
| 1109 | int samples) | 1125 | int samples) |
| 1110 | { | 1126 | { |
| 1111 | struct snd_pcm_runtime *runtime; | ||
| 1112 | struct snd_pcm_substream *substream; | ||
| 1113 | u8 *buf; | 1127 | u8 *buf; |
| 1114 | int over_period; | ||
| 1115 | 1128 | ||
| 1116 | if (!fsi_stream_is_working(fsi, io)) | 1129 | if (!fsi_stream_is_working(fsi, io)) |
| 1117 | return -EINVAL; | 1130 | return -EINVAL; |
| 1118 | 1131 | ||
| 1119 | over_period = 0; | ||
| 1120 | substream = io->substream; | ||
| 1121 | runtime = substream->runtime; | ||
| 1122 | |||
| 1123 | /* FSI FIFO has limit. | ||
| 1124 | * So, this driver can not send periods data at a time | ||
| 1125 | */ | ||
| 1126 | if (io->buff_sample_pos >= | ||
| 1127 | io->period_samples * (io->period_pos + 1)) { | ||
| 1128 | |||
| 1129 | over_period = 1; | ||
| 1130 | io->period_pos = (io->period_pos + 1) % runtime->periods; | ||
| 1131 | |||
| 1132 | if (0 == io->period_pos) | ||
| 1133 | io->buff_sample_pos = 0; | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | buf = fsi_pio_get_area(fsi, io); | 1132 | buf = fsi_pio_get_area(fsi, io); |
| 1137 | 1133 | ||
| 1138 | switch (io->sample_width) { | 1134 | switch (io->sample_width) { |
| @@ -1146,11 +1142,7 @@ static int fsi_pio_transfer(struct fsi_priv *fsi, struct fsi_stream *io, | |||
| 1146 | return -EINVAL; | 1142 | return -EINVAL; |
| 1147 | } | 1143 | } |
| 1148 | 1144 | ||
| 1149 | /* update buff_sample_pos */ | 1145 | fsi_pointer_update(io, samples); |
| 1150 | io->buff_sample_pos += samples; | ||
| 1151 | |||
| 1152 | if (over_period) | ||
| 1153 | snd_pcm_period_elapsed(substream); | ||
| 1154 | 1146 | ||
| 1155 | return 0; | 1147 | return 0; |
| 1156 | } | 1148 | } |
| @@ -1279,11 +1271,6 @@ static irqreturn_t fsi_interrupt(int irq, void *data) | |||
| 1279 | */ | 1271 | */ |
| 1280 | static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io) | 1272 | static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io) |
| 1281 | { | 1273 | { |
| 1282 | struct snd_pcm_runtime *runtime = io->substream->runtime; | ||
| 1283 | struct snd_soc_dai *dai = fsi_get_dai(io->substream); | ||
| 1284 | enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ? | ||
| 1285 | DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
| 1286 | |||
| 1287 | /* | 1274 | /* |
| 1288 | * 24bit data : 24bit bus / package in back | 1275 | * 24bit data : 24bit bus / package in back |
| 1289 | * 16bit data : 16bit bus / stream mode | 1276 | * 16bit data : 16bit bus / stream mode |
| @@ -1291,107 +1278,48 @@ static int fsi_dma_init(struct fsi_priv *fsi, struct fsi_stream *io) | |||
| 1291 | io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | | 1278 | io->bus_option = BUSOP_SET(24, PACKAGE_24BITBUS_BACK) | |
| 1292 | BUSOP_SET(16, PACKAGE_16BITBUS_STREAM); | 1279 | BUSOP_SET(16, PACKAGE_16BITBUS_STREAM); |
| 1293 | 1280 | ||
| 1294 | io->loop_cnt = 2; /* push 1st, 2nd period first, then 3rd, 4th... */ | ||
| 1295 | io->additional_pos = 0; | ||
| 1296 | io->dma = dma_map_single(dai->dev, runtime->dma_area, | ||
| 1297 | snd_pcm_lib_buffer_bytes(io->substream), dir); | ||
| 1298 | return 0; | 1281 | return 0; |
| 1299 | } | 1282 | } |
| 1300 | 1283 | ||
| 1301 | static int fsi_dma_quit(struct fsi_priv *fsi, struct fsi_stream *io) | ||
| 1302 | { | ||
| 1303 | struct snd_soc_dai *dai = fsi_get_dai(io->substream); | ||
| 1304 | enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ? | ||
| 1305 | DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
| 1306 | |||
| 1307 | dma_unmap_single(dai->dev, io->dma, | ||
| 1308 | snd_pcm_lib_buffer_bytes(io->substream), dir); | ||
| 1309 | return 0; | ||
| 1310 | } | ||
| 1311 | |||
| 1312 | static dma_addr_t fsi_dma_get_area(struct fsi_stream *io, int additional) | ||
| 1313 | { | ||
| 1314 | struct snd_pcm_runtime *runtime = io->substream->runtime; | ||
| 1315 | int period = io->period_pos + additional; | ||
| 1316 | |||
| 1317 | if (period >= runtime->periods) | ||
| 1318 | period = 0; | ||
| 1319 | |||
| 1320 | return io->dma + samples_to_bytes(runtime, period * io->period_samples); | ||
| 1321 | } | ||
| 1322 | |||
| 1323 | static void fsi_dma_complete(void *data) | 1284 | static void fsi_dma_complete(void *data) |
| 1324 | { | 1285 | { |
| 1325 | struct fsi_stream *io = (struct fsi_stream *)data; | 1286 | struct fsi_stream *io = (struct fsi_stream *)data; |
| 1326 | struct fsi_priv *fsi = fsi_stream_to_priv(io); | 1287 | struct fsi_priv *fsi = fsi_stream_to_priv(io); |
| 1327 | struct snd_pcm_runtime *runtime = io->substream->runtime; | ||
| 1328 | struct snd_soc_dai *dai = fsi_get_dai(io->substream); | ||
| 1329 | enum dma_data_direction dir = fsi_stream_is_play(fsi, io) ? | ||
| 1330 | DMA_TO_DEVICE : DMA_FROM_DEVICE; | ||
| 1331 | 1288 | ||
| 1332 | dma_sync_single_for_cpu(dai->dev, fsi_dma_get_area(io, 0), | 1289 | fsi_pointer_update(io, io->period_samples); |
| 1333 | samples_to_bytes(runtime, io->period_samples), dir); | ||
| 1334 | |||
| 1335 | io->buff_sample_pos += io->period_samples; | ||
| 1336 | io->period_pos++; | ||
| 1337 | |||
| 1338 | if (io->period_pos >= runtime->periods) { | ||
| 1339 | io->period_pos = 0; | ||
| 1340 | io->buff_sample_pos = 0; | ||
| 1341 | } | ||
| 1342 | 1290 | ||
| 1343 | fsi_count_fifo_err(fsi); | 1291 | fsi_count_fifo_err(fsi); |
| 1344 | fsi_stream_transfer(io); | ||
| 1345 | |||
| 1346 | snd_pcm_period_elapsed(io->substream); | ||
| 1347 | } | 1292 | } |
| 1348 | 1293 | ||
| 1349 | static void fsi_dma_do_work(struct work_struct *work) | 1294 | static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) |
| 1350 | { | 1295 | { |
| 1351 | struct fsi_stream *io = container_of(work, struct fsi_stream, work); | 1296 | struct snd_soc_dai *dai = fsi_get_dai(io->substream); |
| 1352 | struct fsi_priv *fsi = fsi_stream_to_priv(io); | 1297 | struct snd_pcm_substream *substream = io->substream; |
| 1353 | struct snd_soc_dai *dai; | ||
| 1354 | struct dma_async_tx_descriptor *desc; | 1298 | struct dma_async_tx_descriptor *desc; |
| 1355 | struct snd_pcm_runtime *runtime; | ||
| 1356 | enum dma_data_direction dir; | ||
| 1357 | int is_play = fsi_stream_is_play(fsi, io); | 1299 | int is_play = fsi_stream_is_play(fsi, io); |
| 1358 | int len, i; | 1300 | enum dma_data_direction dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE; |
| 1359 | dma_addr_t buf; | 1301 | int ret = -EIO; |
| 1360 | 1302 | ||
| 1361 | if (!fsi_stream_is_working(fsi, io)) | 1303 | desc = dmaengine_prep_dma_cyclic(io->chan, |
| 1362 | return; | 1304 | substream->runtime->dma_addr, |
| 1363 | 1305 | snd_pcm_lib_buffer_bytes(substream), | |
| 1364 | dai = fsi_get_dai(io->substream); | 1306 | snd_pcm_lib_period_bytes(substream), |
| 1365 | runtime = io->substream->runtime; | 1307 | dir, |
| 1366 | dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | 1308 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
| 1367 | len = samples_to_bytes(runtime, io->period_samples); | 1309 | if (!desc) { |
| 1368 | 1310 | dev_err(dai->dev, "dmaengine_prep_dma_cyclic() fail\n"); | |
| 1369 | for (i = 0; i < io->loop_cnt; i++) { | 1311 | goto fsi_dma_transfer_err; |
| 1370 | buf = fsi_dma_get_area(io, io->additional_pos); | 1312 | } |
| 1371 | |||
| 1372 | dma_sync_single_for_device(dai->dev, buf, len, dir); | ||
| 1373 | |||
| 1374 | desc = dmaengine_prep_slave_single(io->chan, buf, len, dir, | ||
| 1375 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
| 1376 | if (!desc) { | ||
| 1377 | dev_err(dai->dev, "dmaengine_prep_slave_sg() fail\n"); | ||
| 1378 | return; | ||
| 1379 | } | ||
| 1380 | |||
| 1381 | desc->callback = fsi_dma_complete; | ||
| 1382 | desc->callback_param = io; | ||
| 1383 | |||
| 1384 | if (dmaengine_submit(desc) < 0) { | ||
| 1385 | dev_err(dai->dev, "tx_submit() fail\n"); | ||
| 1386 | return; | ||
| 1387 | } | ||
| 1388 | 1313 | ||
| 1389 | dma_async_issue_pending(io->chan); | 1314 | desc->callback = fsi_dma_complete; |
| 1315 | desc->callback_param = io; | ||
| 1390 | 1316 | ||
| 1391 | io->additional_pos = 1; | 1317 | if (dmaengine_submit(desc) < 0) { |
| 1318 | dev_err(dai->dev, "tx_submit() fail\n"); | ||
| 1319 | goto fsi_dma_transfer_err; | ||
| 1392 | } | 1320 | } |
| 1393 | 1321 | ||
| 1394 | io->loop_cnt = 1; | 1322 | dma_async_issue_pending(io->chan); |
| 1395 | 1323 | ||
| 1396 | /* | 1324 | /* |
| 1397 | * FIXME | 1325 | * FIXME |
| @@ -1408,13 +1336,11 @@ static void fsi_dma_do_work(struct work_struct *work) | |||
| 1408 | fsi_reg_write(fsi, DIFF_ST, 0); | 1336 | fsi_reg_write(fsi, DIFF_ST, 0); |
| 1409 | } | 1337 | } |
| 1410 | } | 1338 | } |
| 1411 | } | ||
| 1412 | 1339 | ||
| 1413 | static int fsi_dma_transfer(struct fsi_priv *fsi, struct fsi_stream *io) | 1340 | ret = 0; |
| 1414 | { | ||
| 1415 | schedule_work(&io->work); | ||
| 1416 | 1341 | ||
| 1417 | return 0; | 1342 | fsi_dma_transfer_err: |
| 1343 | return ret; | ||
| 1418 | } | 1344 | } |
| 1419 | 1345 | ||
| 1420 | static int fsi_dma_push_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, | 1346 | static int fsi_dma_push_start_stop(struct fsi_priv *fsi, struct fsi_stream *io, |
| @@ -1475,15 +1401,11 @@ static int fsi_dma_probe(struct fsi_priv *fsi, struct fsi_stream *io, struct dev | |||
| 1475 | return fsi_stream_probe(fsi, dev); | 1401 | return fsi_stream_probe(fsi, dev); |
| 1476 | } | 1402 | } |
| 1477 | 1403 | ||
| 1478 | INIT_WORK(&io->work, fsi_dma_do_work); | ||
| 1479 | |||
| 1480 | return 0; | 1404 | return 0; |
| 1481 | } | 1405 | } |
| 1482 | 1406 | ||
| 1483 | static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) | 1407 | static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) |
| 1484 | { | 1408 | { |
| 1485 | cancel_work_sync(&io->work); | ||
| 1486 | |||
| 1487 | fsi_stream_stop(fsi, io); | 1409 | fsi_stream_stop(fsi, io); |
| 1488 | 1410 | ||
| 1489 | if (io->chan) | 1411 | if (io->chan) |
| @@ -1495,7 +1417,6 @@ static int fsi_dma_remove(struct fsi_priv *fsi, struct fsi_stream *io) | |||
| 1495 | 1417 | ||
| 1496 | static struct fsi_stream_handler fsi_dma_push_handler = { | 1418 | static struct fsi_stream_handler fsi_dma_push_handler = { |
| 1497 | .init = fsi_dma_init, | 1419 | .init = fsi_dma_init, |
| 1498 | .quit = fsi_dma_quit, | ||
| 1499 | .probe = fsi_dma_probe, | 1420 | .probe = fsi_dma_probe, |
| 1500 | .transfer = fsi_dma_transfer, | 1421 | .transfer = fsi_dma_transfer, |
| 1501 | .remove = fsi_dma_remove, | 1422 | .remove = fsi_dma_remove, |
| @@ -1657,9 +1578,9 @@ static int fsi_dai_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 1657 | if (!ret) | 1578 | if (!ret) |
| 1658 | ret = fsi_hw_startup(fsi, io, dai->dev); | 1579 | ret = fsi_hw_startup(fsi, io, dai->dev); |
| 1659 | if (!ret) | 1580 | if (!ret) |
| 1660 | ret = fsi_stream_transfer(io); | 1581 | ret = fsi_stream_start(fsi, io); |
| 1661 | if (!ret) | 1582 | if (!ret) |
| 1662 | fsi_stream_start(fsi, io); | 1583 | ret = fsi_stream_transfer(io); |
| 1663 | break; | 1584 | break; |
| 1664 | case SNDRV_PCM_TRIGGER_STOP: | 1585 | case SNDRV_PCM_TRIGGER_STOP: |
| 1665 | if (!ret) | 1586 | if (!ret) |
| @@ -1850,16 +1771,10 @@ static void fsi_pcm_free(struct snd_pcm *pcm) | |||
| 1850 | 1771 | ||
| 1851 | static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) | 1772 | static int fsi_pcm_new(struct snd_soc_pcm_runtime *rtd) |
| 1852 | { | 1773 | { |
| 1853 | struct snd_pcm *pcm = rtd->pcm; | ||
| 1854 | |||
| 1855 | /* | ||
| 1856 | * dont use SNDRV_DMA_TYPE_DEV, since it will oops the SH kernel | ||
| 1857 | * in MMAP mode (i.e. aplay -M) | ||
| 1858 | */ | ||
| 1859 | return snd_pcm_lib_preallocate_pages_for_all( | 1774 | return snd_pcm_lib_preallocate_pages_for_all( |
| 1860 | pcm, | 1775 | rtd->pcm, |
| 1861 | SNDRV_DMA_TYPE_CONTINUOUS, | 1776 | SNDRV_DMA_TYPE_DEV, |
| 1862 | snd_dma_continuous_data(GFP_KERNEL), | 1777 | rtd->card->snd_card->dev, |
| 1863 | PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); | 1778 | PREALLOC_BUFFER, PREALLOC_BUFFER_MAX); |
| 1864 | } | 1779 | } |
| 1865 | 1780 | ||
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index 4e86265f625c..19f78963e8b9 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
| @@ -138,6 +138,17 @@ char *rsnd_mod_name(struct rsnd_mod *mod) | |||
| 138 | return mod->ops->name; | 138 | return mod->ops->name; |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | char *rsnd_mod_dma_name(struct rsnd_mod *mod) | ||
| 142 | { | ||
| 143 | if (!mod || !mod->ops) | ||
| 144 | return "unknown"; | ||
| 145 | |||
| 146 | if (!mod->ops->dma_name) | ||
| 147 | return mod->ops->name; | ||
| 148 | |||
| 149 | return mod->ops->dma_name(mod); | ||
| 150 | } | ||
| 151 | |||
| 141 | void rsnd_mod_init(struct rsnd_priv *priv, | 152 | void rsnd_mod_init(struct rsnd_priv *priv, |
| 142 | struct rsnd_mod *mod, | 153 | struct rsnd_mod *mod, |
| 143 | struct rsnd_mod_ops *ops, | 154 | struct rsnd_mod_ops *ops, |
| @@ -153,26 +164,8 @@ void rsnd_mod_init(struct rsnd_priv *priv, | |||
| 153 | /* | 164 | /* |
| 154 | * rsnd_dma functions | 165 | * rsnd_dma functions |
| 155 | */ | 166 | */ |
| 156 | static void __rsnd_dma_start(struct rsnd_dma *dma); | ||
| 157 | static void rsnd_dma_continue(struct rsnd_dma *dma) | ||
| 158 | { | ||
| 159 | /* push next A or B plane */ | ||
| 160 | dma->submit_loop = 1; | ||
| 161 | schedule_work(&dma->work); | ||
| 162 | } | ||
| 163 | |||
| 164 | void rsnd_dma_start(struct rsnd_dma *dma) | ||
| 165 | { | ||
| 166 | /* push both A and B plane*/ | ||
| 167 | dma->offset = 0; | ||
| 168 | dma->submit_loop = 2; | ||
| 169 | __rsnd_dma_start(dma); | ||
| 170 | } | ||
| 171 | |||
| 172 | void rsnd_dma_stop(struct rsnd_dma *dma) | 167 | void rsnd_dma_stop(struct rsnd_dma *dma) |
| 173 | { | 168 | { |
| 174 | dma->submit_loop = 0; | ||
| 175 | cancel_work_sync(&dma->work); | ||
| 176 | dmaengine_terminate_all(dma->chan); | 169 | dmaengine_terminate_all(dma->chan); |
| 177 | } | 170 | } |
| 178 | 171 | ||
| @@ -180,11 +173,7 @@ static void rsnd_dma_complete(void *data) | |||
| 180 | { | 173 | { |
| 181 | struct rsnd_dma *dma = (struct rsnd_dma *)data; | 174 | struct rsnd_dma *dma = (struct rsnd_dma *)data; |
| 182 | struct rsnd_mod *mod = rsnd_dma_to_mod(dma); | 175 | struct rsnd_mod *mod = rsnd_dma_to_mod(dma); |
| 183 | struct rsnd_priv *priv = rsnd_mod_to_priv(rsnd_dma_to_mod(dma)); | ||
| 184 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | 176 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); |
| 185 | unsigned long flags; | ||
| 186 | |||
| 187 | rsnd_lock(priv, flags); | ||
| 188 | 177 | ||
| 189 | /* | 178 | /* |
| 190 | * Renesas sound Gen1 needs 1 DMAC, | 179 | * Renesas sound Gen1 needs 1 DMAC, |
| @@ -197,57 +186,41 @@ static void rsnd_dma_complete(void *data) | |||
| 197 | * rsnd_dai_pointer_update() will be called twice, | 186 | * rsnd_dai_pointer_update() will be called twice, |
| 198 | * ant it will breaks io->byte_pos | 187 | * ant it will breaks io->byte_pos |
| 199 | */ | 188 | */ |
| 200 | if (dma->submit_loop) | ||
| 201 | rsnd_dma_continue(dma); | ||
| 202 | |||
| 203 | rsnd_unlock(priv, flags); | ||
| 204 | 189 | ||
| 205 | rsnd_dai_pointer_update(io, io->byte_per_period); | 190 | rsnd_dai_pointer_update(io, io->byte_per_period); |
| 206 | } | 191 | } |
| 207 | 192 | ||
| 208 | static void __rsnd_dma_start(struct rsnd_dma *dma) | 193 | void rsnd_dma_start(struct rsnd_dma *dma) |
| 209 | { | 194 | { |
| 210 | struct rsnd_mod *mod = rsnd_dma_to_mod(dma); | 195 | struct rsnd_mod *mod = rsnd_dma_to_mod(dma); |
| 211 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | 196 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
| 212 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | 197 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); |
| 213 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); | 198 | struct snd_pcm_substream *substream = io->substream; |
| 214 | struct device *dev = rsnd_priv_to_dev(priv); | 199 | struct device *dev = rsnd_priv_to_dev(priv); |
| 215 | struct dma_async_tx_descriptor *desc; | 200 | struct dma_async_tx_descriptor *desc; |
| 216 | dma_addr_t buf; | ||
| 217 | size_t len = io->byte_per_period; | ||
| 218 | int i; | ||
| 219 | 201 | ||
| 220 | for (i = 0; i < dma->submit_loop; i++) { | 202 | desc = dmaengine_prep_dma_cyclic(dma->chan, |
| 221 | 203 | (dma->addr) ? dma->addr : | |
| 222 | buf = runtime->dma_addr + | 204 | substream->runtime->dma_addr, |
| 223 | rsnd_dai_pointer_offset(io, dma->offset + len); | 205 | snd_pcm_lib_buffer_bytes(substream), |
| 224 | dma->offset = len; | 206 | snd_pcm_lib_period_bytes(substream), |
| 225 | 207 | dma->dir, | |
| 226 | desc = dmaengine_prep_slave_single( | 208 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); |
| 227 | dma->chan, buf, len, dma->dir, | ||
| 228 | DMA_PREP_INTERRUPT | DMA_CTRL_ACK); | ||
| 229 | if (!desc) { | ||
| 230 | dev_err(dev, "dmaengine_prep_slave_sg() fail\n"); | ||
| 231 | return; | ||
| 232 | } | ||
| 233 | 209 | ||
| 234 | desc->callback = rsnd_dma_complete; | 210 | if (!desc) { |
| 235 | desc->callback_param = dma; | 211 | dev_err(dev, "dmaengine_prep_slave_sg() fail\n"); |
| 212 | return; | ||
| 213 | } | ||
| 236 | 214 | ||
| 237 | if (dmaengine_submit(desc) < 0) { | 215 | desc->callback = rsnd_dma_complete; |
| 238 | dev_err(dev, "dmaengine_submit() fail\n"); | 216 | desc->callback_param = dma; |
| 239 | return; | ||
| 240 | } | ||
| 241 | 217 | ||
| 242 | dma_async_issue_pending(dma->chan); | 218 | if (dmaengine_submit(desc) < 0) { |
| 219 | dev_err(dev, "dmaengine_submit() fail\n"); | ||
| 220 | return; | ||
| 243 | } | 221 | } |
| 244 | } | ||
| 245 | |||
| 246 | static void rsnd_dma_do_work(struct work_struct *work) | ||
| 247 | { | ||
| 248 | struct rsnd_dma *dma = container_of(work, struct rsnd_dma, work); | ||
| 249 | 222 | ||
| 250 | __rsnd_dma_start(dma); | 223 | dma_async_issue_pending(dma->chan); |
| 251 | } | 224 | } |
| 252 | 225 | ||
| 253 | int rsnd_dma_available(struct rsnd_dma *dma) | 226 | int rsnd_dma_available(struct rsnd_dma *dma) |
| @@ -261,14 +234,27 @@ static int _rsnd_dma_of_name(char *dma_name, struct rsnd_mod *mod) | |||
| 261 | { | 234 | { |
| 262 | if (mod) | 235 | if (mod) |
| 263 | return snprintf(dma_name, DMA_NAME_SIZE / 2, "%s%d", | 236 | return snprintf(dma_name, DMA_NAME_SIZE / 2, "%s%d", |
| 264 | rsnd_mod_name(mod), rsnd_mod_id(mod)); | 237 | rsnd_mod_dma_name(mod), rsnd_mod_id(mod)); |
| 265 | else | 238 | else |
| 266 | return snprintf(dma_name, DMA_NAME_SIZE / 2, "mem"); | 239 | return snprintf(dma_name, DMA_NAME_SIZE / 2, "mem"); |
| 267 | 240 | ||
| 268 | } | 241 | } |
| 269 | 242 | ||
| 270 | static void rsnd_dma_of_name(struct rsnd_dma *dma, | 243 | static void rsnd_dma_of_name(struct rsnd_mod *mod_from, |
| 271 | int is_play, char *dma_name) | 244 | struct rsnd_mod *mod_to, |
| 245 | char *dma_name) | ||
| 246 | { | ||
| 247 | int index = 0; | ||
| 248 | |||
| 249 | index = _rsnd_dma_of_name(dma_name + index, mod_from); | ||
| 250 | *(dma_name + index++) = '_'; | ||
| 251 | index = _rsnd_dma_of_name(dma_name + index, mod_to); | ||
| 252 | } | ||
| 253 | |||
| 254 | static void rsnd_dma_of_path(struct rsnd_dma *dma, | ||
| 255 | int is_play, | ||
| 256 | struct rsnd_mod **mod_from, | ||
| 257 | struct rsnd_mod **mod_to) | ||
| 272 | { | 258 | { |
| 273 | struct rsnd_mod *this = rsnd_dma_to_mod(dma); | 259 | struct rsnd_mod *this = rsnd_dma_to_mod(dma); |
| 274 | struct rsnd_dai_stream *io = rsnd_mod_to_io(this); | 260 | struct rsnd_dai_stream *io = rsnd_mod_to_io(this); |
| @@ -276,7 +262,6 @@ static void rsnd_dma_of_name(struct rsnd_dma *dma, | |||
| 276 | struct rsnd_mod *src = rsnd_io_to_mod_src(io); | 262 | struct rsnd_mod *src = rsnd_io_to_mod_src(io); |
| 277 | struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io); | 263 | struct rsnd_mod *dvc = rsnd_io_to_mod_dvc(io); |
| 278 | struct rsnd_mod *mod[MOD_MAX]; | 264 | struct rsnd_mod *mod[MOD_MAX]; |
| 279 | struct rsnd_mod *src_mod, *dst_mod; | ||
| 280 | int i, index; | 265 | int i, index; |
| 281 | 266 | ||
| 282 | 267 | ||
| @@ -297,31 +282,34 @@ static void rsnd_dma_of_name(struct rsnd_dma *dma, | |||
| 297 | for (i = 1; i < MOD_MAX; i++) { | 282 | for (i = 1; i < MOD_MAX; i++) { |
| 298 | if (!src) { | 283 | if (!src) { |
| 299 | mod[i] = ssi; | 284 | mod[i] = ssi; |
| 300 | break; | ||
| 301 | } else if (!dvc) { | 285 | } else if (!dvc) { |
| 302 | mod[i] = src; | 286 | mod[i] = src; |
| 303 | src = NULL; | 287 | src = NULL; |
| 304 | } else { | 288 | } else { |
| 305 | mod[i] = dvc; | 289 | if ((!is_play) && (this == src)) |
| 290 | this = dvc; | ||
| 291 | |||
| 292 | mod[i] = (is_play) ? src : dvc; | ||
| 293 | i++; | ||
| 294 | mod[i] = (is_play) ? dvc : src; | ||
| 295 | src = NULL; | ||
| 306 | dvc = NULL; | 296 | dvc = NULL; |
| 307 | } | 297 | } |
| 308 | 298 | ||
| 309 | if (mod[i] == this) | 299 | if (mod[i] == this) |
| 310 | index = i; | 300 | index = i; |
| 301 | |||
| 302 | if (mod[i] == ssi) | ||
| 303 | break; | ||
| 311 | } | 304 | } |
| 312 | 305 | ||
| 313 | if (is_play) { | 306 | if (is_play) { |
| 314 | src_mod = mod[index - 1]; | 307 | *mod_from = mod[index - 1]; |
| 315 | dst_mod = mod[index]; | 308 | *mod_to = mod[index]; |
| 316 | } else { | 309 | } else { |
| 317 | src_mod = mod[index]; | 310 | *mod_from = mod[index]; |
| 318 | dst_mod = mod[index - 1]; | 311 | *mod_to = mod[index - 1]; |
| 319 | } | 312 | } |
| 320 | |||
| 321 | index = 0; | ||
| 322 | index = _rsnd_dma_of_name(dma_name + index, src_mod); | ||
| 323 | *(dma_name + index++) = '_'; | ||
| 324 | index = _rsnd_dma_of_name(dma_name + index, dst_mod); | ||
| 325 | } | 313 | } |
| 326 | 314 | ||
| 327 | int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | 315 | int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, |
| @@ -329,6 +317,8 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | |||
| 329 | { | 317 | { |
| 330 | struct device *dev = rsnd_priv_to_dev(priv); | 318 | struct device *dev = rsnd_priv_to_dev(priv); |
| 331 | struct dma_slave_config cfg; | 319 | struct dma_slave_config cfg; |
| 320 | struct rsnd_mod *mod_from; | ||
| 321 | struct rsnd_mod *mod_to; | ||
| 332 | char dma_name[DMA_NAME_SIZE]; | 322 | char dma_name[DMA_NAME_SIZE]; |
| 333 | dma_cap_mask_t mask; | 323 | dma_cap_mask_t mask; |
| 334 | int ret; | 324 | int ret; |
| @@ -341,13 +331,18 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | |||
| 341 | dma_cap_zero(mask); | 331 | dma_cap_zero(mask); |
| 342 | dma_cap_set(DMA_SLAVE, mask); | 332 | dma_cap_set(DMA_SLAVE, mask); |
| 343 | 333 | ||
| 344 | if (dev->of_node) | 334 | rsnd_dma_of_path(dma, is_play, &mod_from, &mod_to); |
| 345 | rsnd_dma_of_name(dma, is_play, dma_name); | 335 | rsnd_dma_of_name(mod_from, mod_to, dma_name); |
| 346 | else | ||
| 347 | snprintf(dma_name, DMA_NAME_SIZE, | ||
| 348 | is_play ? "tx" : "rx"); | ||
| 349 | 336 | ||
| 350 | dev_dbg(dev, "dma name : %s\n", dma_name); | 337 | cfg.slave_id = id; |
| 338 | cfg.direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | ||
| 339 | cfg.src_addr = rsnd_gen_dma_addr(priv, mod_from, is_play, 1); | ||
| 340 | cfg.dst_addr = rsnd_gen_dma_addr(priv, mod_to, is_play, 0); | ||
| 341 | cfg.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
| 342 | cfg.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | ||
| 343 | |||
| 344 | dev_dbg(dev, "dma : %s %pad -> %pad\n", | ||
| 345 | dma_name, &cfg.src_addr, &cfg.dst_addr); | ||
| 351 | 346 | ||
| 352 | dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, | 347 | dma->chan = dma_request_slave_channel_compat(mask, shdma_chan_filter, |
| 353 | (void *)id, dev, | 348 | (void *)id, dev, |
| @@ -357,14 +352,12 @@ int rsnd_dma_init(struct rsnd_priv *priv, struct rsnd_dma *dma, | |||
| 357 | return -EIO; | 352 | return -EIO; |
| 358 | } | 353 | } |
| 359 | 354 | ||
| 360 | rsnd_gen_dma_addr(priv, dma, &cfg, is_play, id); | ||
| 361 | |||
| 362 | ret = dmaengine_slave_config(dma->chan, &cfg); | 355 | ret = dmaengine_slave_config(dma->chan, &cfg); |
| 363 | if (ret < 0) | 356 | if (ret < 0) |
| 364 | goto rsnd_dma_init_err; | 357 | goto rsnd_dma_init_err; |
| 365 | 358 | ||
| 366 | dma->dir = is_play ? DMA_TO_DEVICE : DMA_FROM_DEVICE; | 359 | dma->addr = is_play ? cfg.src_addr : cfg.dst_addr; |
| 367 | INIT_WORK(&dma->work, rsnd_dma_do_work); | 360 | dma->dir = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; |
| 368 | 361 | ||
| 369 | return 0; | 362 | return 0; |
| 370 | 363 | ||
| @@ -631,40 +624,41 @@ static int rsnd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
| 631 | return -EINVAL; | 624 | return -EINVAL; |
| 632 | } | 625 | } |
| 633 | 626 | ||
| 634 | /* set clock inversion */ | ||
| 635 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
| 636 | case SND_SOC_DAIFMT_NB_IF: | ||
| 637 | rdai->bit_clk_inv = 0; | ||
| 638 | rdai->frm_clk_inv = 1; | ||
| 639 | break; | ||
| 640 | case SND_SOC_DAIFMT_IB_NF: | ||
| 641 | rdai->bit_clk_inv = 1; | ||
| 642 | rdai->frm_clk_inv = 0; | ||
| 643 | break; | ||
| 644 | case SND_SOC_DAIFMT_IB_IF: | ||
| 645 | rdai->bit_clk_inv = 1; | ||
| 646 | rdai->frm_clk_inv = 1; | ||
| 647 | break; | ||
| 648 | case SND_SOC_DAIFMT_NB_NF: | ||
| 649 | default: | ||
| 650 | rdai->bit_clk_inv = 0; | ||
| 651 | rdai->frm_clk_inv = 0; | ||
| 652 | break; | ||
| 653 | } | ||
| 654 | |||
| 655 | /* set format */ | 627 | /* set format */ |
| 656 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | 628 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { |
| 657 | case SND_SOC_DAIFMT_I2S: | 629 | case SND_SOC_DAIFMT_I2S: |
| 658 | rdai->sys_delay = 0; | 630 | rdai->sys_delay = 0; |
| 659 | rdai->data_alignment = 0; | 631 | rdai->data_alignment = 0; |
| 632 | rdai->frm_clk_inv = 0; | ||
| 660 | break; | 633 | break; |
| 661 | case SND_SOC_DAIFMT_LEFT_J: | 634 | case SND_SOC_DAIFMT_LEFT_J: |
| 662 | rdai->sys_delay = 1; | 635 | rdai->sys_delay = 1; |
| 663 | rdai->data_alignment = 0; | 636 | rdai->data_alignment = 0; |
| 637 | rdai->frm_clk_inv = 1; | ||
| 664 | break; | 638 | break; |
| 665 | case SND_SOC_DAIFMT_RIGHT_J: | 639 | case SND_SOC_DAIFMT_RIGHT_J: |
| 666 | rdai->sys_delay = 1; | 640 | rdai->sys_delay = 1; |
| 667 | rdai->data_alignment = 1; | 641 | rdai->data_alignment = 1; |
| 642 | rdai->frm_clk_inv = 1; | ||
| 643 | break; | ||
| 644 | } | ||
| 645 | |||
| 646 | /* set clock inversion */ | ||
| 647 | switch (fmt & SND_SOC_DAIFMT_INV_MASK) { | ||
| 648 | case SND_SOC_DAIFMT_NB_IF: | ||
| 649 | rdai->bit_clk_inv = rdai->bit_clk_inv; | ||
| 650 | rdai->frm_clk_inv = !rdai->frm_clk_inv; | ||
| 651 | break; | ||
| 652 | case SND_SOC_DAIFMT_IB_NF: | ||
| 653 | rdai->bit_clk_inv = !rdai->bit_clk_inv; | ||
| 654 | rdai->frm_clk_inv = rdai->frm_clk_inv; | ||
| 655 | break; | ||
| 656 | case SND_SOC_DAIFMT_IB_IF: | ||
| 657 | rdai->bit_clk_inv = !rdai->bit_clk_inv; | ||
| 658 | rdai->frm_clk_inv = !rdai->frm_clk_inv; | ||
| 659 | break; | ||
| 660 | case SND_SOC_DAIFMT_NB_NF: | ||
| 661 | default: | ||
| 668 | break; | 662 | break; |
| 669 | } | 663 | } |
| 670 | 664 | ||
| @@ -734,12 +728,13 @@ static void rsnd_of_parse_dai(struct platform_device *pdev, | |||
| 734 | struct device_node *dai_node, *dai_np; | 728 | struct device_node *dai_node, *dai_np; |
| 735 | struct device_node *ssi_node, *ssi_np; | 729 | struct device_node *ssi_node, *ssi_np; |
| 736 | struct device_node *src_node, *src_np; | 730 | struct device_node *src_node, *src_np; |
| 731 | struct device_node *dvc_node, *dvc_np; | ||
| 737 | struct device_node *playback, *capture; | 732 | struct device_node *playback, *capture; |
| 738 | struct rsnd_dai_platform_info *dai_info; | 733 | struct rsnd_dai_platform_info *dai_info; |
| 739 | struct rcar_snd_info *info = rsnd_priv_to_info(priv); | 734 | struct rcar_snd_info *info = rsnd_priv_to_info(priv); |
| 740 | struct device *dev = &pdev->dev; | 735 | struct device *dev = &pdev->dev; |
| 741 | int nr, i; | 736 | int nr, i; |
| 742 | int dai_i, ssi_i, src_i; | 737 | int dai_i, ssi_i, src_i, dvc_i; |
| 743 | 738 | ||
| 744 | if (!of_data) | 739 | if (!of_data) |
| 745 | return; | 740 | return; |
| @@ -765,6 +760,7 @@ static void rsnd_of_parse_dai(struct platform_device *pdev, | |||
| 765 | 760 | ||
| 766 | ssi_node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi"); | 761 | ssi_node = of_get_child_by_name(dev->of_node, "rcar_sound,ssi"); |
| 767 | src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src"); | 762 | src_node = of_get_child_by_name(dev->of_node, "rcar_sound,src"); |
| 763 | dvc_node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc"); | ||
| 768 | 764 | ||
| 769 | #define mod_parse(name) \ | 765 | #define mod_parse(name) \ |
| 770 | if (name##_node) { \ | 766 | if (name##_node) { \ |
| @@ -800,6 +796,7 @@ if (name##_node) { \ | |||
| 800 | 796 | ||
| 801 | mod_parse(ssi); | 797 | mod_parse(ssi); |
| 802 | mod_parse(src); | 798 | mod_parse(src); |
| 799 | mod_parse(dvc); | ||
| 803 | 800 | ||
| 804 | if (playback) | 801 | if (playback) |
| 805 | of_node_put(playback); | 802 | of_node_put(playback); |
| @@ -948,19 +945,17 @@ static struct snd_pcm_ops rsnd_pcm_ops = { | |||
| 948 | 945 | ||
| 949 | static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) | 946 | static int rsnd_pcm_new(struct snd_soc_pcm_runtime *rtd) |
| 950 | { | 947 | { |
| 951 | struct rsnd_priv *priv = snd_soc_dai_get_drvdata(rtd->cpu_dai); | 948 | struct snd_soc_dai *dai = rtd->cpu_dai; |
| 952 | struct rsnd_dai *rdai; | 949 | struct rsnd_dai *rdai = rsnd_dai_to_rdai(dai); |
| 953 | int i, ret; | 950 | int ret; |
| 954 | 951 | ||
| 955 | for_each_rsnd_dai(rdai, priv, i) { | 952 | ret = rsnd_dai_call(pcm_new, &rdai->playback, rdai, rtd); |
| 956 | ret = rsnd_dai_call(pcm_new, &rdai->playback, rdai, rtd); | 953 | if (ret) |
| 957 | if (ret) | 954 | return ret; |
| 958 | return ret; | ||
| 959 | 955 | ||
| 960 | ret = rsnd_dai_call(pcm_new, &rdai->capture, rdai, rtd); | 956 | ret = rsnd_dai_call(pcm_new, &rdai->capture, rdai, rtd); |
| 961 | if (ret) | 957 | if (ret) |
| 962 | return ret; | 958 | return ret; |
| 963 | } | ||
| 964 | 959 | ||
| 965 | return snd_pcm_lib_preallocate_pages_for_all( | 960 | return snd_pcm_lib_preallocate_pages_for_all( |
| 966 | rtd->pcm, | 961 | rtd->pcm, |
| @@ -1047,11 +1042,11 @@ static int rsnd_probe(struct platform_device *pdev) | |||
| 1047 | for_each_rsnd_dai(rdai, priv, i) { | 1042 | for_each_rsnd_dai(rdai, priv, i) { |
| 1048 | ret = rsnd_dai_call(probe, &rdai->playback, rdai); | 1043 | ret = rsnd_dai_call(probe, &rdai->playback, rdai); |
| 1049 | if (ret) | 1044 | if (ret) |
| 1050 | return ret; | 1045 | goto exit_snd_probe; |
| 1051 | 1046 | ||
| 1052 | ret = rsnd_dai_call(probe, &rdai->capture, rdai); | 1047 | ret = rsnd_dai_call(probe, &rdai->capture, rdai); |
| 1053 | if (ret) | 1048 | if (ret) |
| 1054 | return ret; | 1049 | goto exit_snd_probe; |
| 1055 | } | 1050 | } |
| 1056 | 1051 | ||
| 1057 | /* | 1052 | /* |
| @@ -1079,6 +1074,11 @@ static int rsnd_probe(struct platform_device *pdev) | |||
| 1079 | 1074 | ||
| 1080 | exit_snd_soc: | 1075 | exit_snd_soc: |
| 1081 | snd_soc_unregister_platform(dev); | 1076 | snd_soc_unregister_platform(dev); |
| 1077 | exit_snd_probe: | ||
| 1078 | for_each_rsnd_dai(rdai, priv, i) { | ||
| 1079 | rsnd_dai_call(remove, &rdai->playback, rdai); | ||
| 1080 | rsnd_dai_call(remove, &rdai->capture, rdai); | ||
| 1081 | } | ||
| 1082 | 1082 | ||
| 1083 | return ret; | 1083 | return ret; |
| 1084 | } | 1084 | } |
| @@ -1087,21 +1087,16 @@ static int rsnd_remove(struct platform_device *pdev) | |||
| 1087 | { | 1087 | { |
| 1088 | struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev); | 1088 | struct rsnd_priv *priv = dev_get_drvdata(&pdev->dev); |
| 1089 | struct rsnd_dai *rdai; | 1089 | struct rsnd_dai *rdai; |
| 1090 | int ret, i; | 1090 | int ret = 0, i; |
| 1091 | 1091 | ||
| 1092 | pm_runtime_disable(&pdev->dev); | 1092 | pm_runtime_disable(&pdev->dev); |
| 1093 | 1093 | ||
| 1094 | for_each_rsnd_dai(rdai, priv, i) { | 1094 | for_each_rsnd_dai(rdai, priv, i) { |
| 1095 | ret = rsnd_dai_call(remove, &rdai->playback, rdai); | 1095 | ret |= rsnd_dai_call(remove, &rdai->playback, rdai); |
| 1096 | if (ret) | 1096 | ret |= rsnd_dai_call(remove, &rdai->capture, rdai); |
| 1097 | return ret; | ||
| 1098 | |||
| 1099 | ret = rsnd_dai_call(remove, &rdai->capture, rdai); | ||
| 1100 | if (ret) | ||
| 1101 | return ret; | ||
| 1102 | } | 1097 | } |
| 1103 | 1098 | ||
| 1104 | return 0; | 1099 | return ret; |
| 1105 | } | 1100 | } |
| 1106 | 1101 | ||
| 1107 | static struct platform_driver rsnd_driver = { | 1102 | static struct platform_driver rsnd_driver = { |
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index ed0007006899..3f443930c2b1 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c | |||
| @@ -20,7 +20,8 @@ struct rsnd_dvc { | |||
| 20 | struct rsnd_dvc_platform_info *info; /* rcar_snd.h */ | 20 | struct rsnd_dvc_platform_info *info; /* rcar_snd.h */ |
| 21 | struct rsnd_mod mod; | 21 | struct rsnd_mod mod; |
| 22 | struct clk *clk; | 22 | struct clk *clk; |
| 23 | long volume[RSND_DVC_VOLUME_NUM]; | 23 | u8 volume[RSND_DVC_VOLUME_NUM]; |
| 24 | u8 mute[RSND_DVC_VOLUME_NUM]; | ||
| 24 | }; | 25 | }; |
| 25 | 26 | ||
| 26 | #define rsnd_mod_to_dvc(_mod) \ | 27 | #define rsnd_mod_to_dvc(_mod) \ |
| @@ -37,13 +38,18 @@ static void rsnd_dvc_volume_update(struct rsnd_mod *mod) | |||
| 37 | struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); | 38 | struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); |
| 38 | u32 max = (0x00800000 - 1); | 39 | u32 max = (0x00800000 - 1); |
| 39 | u32 vol[RSND_DVC_VOLUME_NUM]; | 40 | u32 vol[RSND_DVC_VOLUME_NUM]; |
| 41 | u32 mute = 0; | ||
| 40 | int i; | 42 | int i; |
| 41 | 43 | ||
| 42 | for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) | 44 | for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) { |
| 43 | vol[i] = max / RSND_DVC_VOLUME_MAX * dvc->volume[i]; | 45 | vol[i] = max / RSND_DVC_VOLUME_MAX * dvc->volume[i]; |
| 46 | mute |= (!!dvc->mute[i]) << i; | ||
| 47 | } | ||
| 44 | 48 | ||
| 45 | rsnd_mod_write(mod, DVC_VOL0R, vol[0]); | 49 | rsnd_mod_write(mod, DVC_VOL0R, vol[0]); |
| 46 | rsnd_mod_write(mod, DVC_VOL1R, vol[1]); | 50 | rsnd_mod_write(mod, DVC_VOL1R, vol[1]); |
| 51 | |||
| 52 | rsnd_mod_write(mod, DVC_ZCMCR, mute); | ||
| 47 | } | 53 | } |
| 48 | 54 | ||
| 49 | static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, | 55 | static int rsnd_dvc_probe_gen2(struct rsnd_mod *mod, |
| @@ -96,8 +102,8 @@ static int rsnd_dvc_init(struct rsnd_mod *dvc_mod, | |||
| 96 | 102 | ||
| 97 | rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod)); | 103 | rsnd_mod_write(dvc_mod, DVC_ADINR, rsnd_get_adinr(dvc_mod)); |
| 98 | 104 | ||
| 99 | /* enable Volume */ | 105 | /* enable Volume / Mute */ |
| 100 | rsnd_mod_write(dvc_mod, DVC_DVUCR, 0x100); | 106 | rsnd_mod_write(dvc_mod, DVC_DVUCR, 0x101); |
| 101 | 107 | ||
| 102 | /* ch0/ch1 Volume */ | 108 | /* ch0/ch1 Volume */ |
| 103 | rsnd_dvc_volume_update(dvc_mod); | 109 | rsnd_dvc_volume_update(dvc_mod); |
| @@ -140,10 +146,20 @@ static int rsnd_dvc_stop(struct rsnd_mod *mod, | |||
| 140 | static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl, | 146 | static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl, |
| 141 | struct snd_ctl_elem_info *uinfo) | 147 | struct snd_ctl_elem_info *uinfo) |
| 142 | { | 148 | { |
| 143 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 149 | struct rsnd_mod *mod = snd_kcontrol_chip(kctrl); |
| 150 | struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); | ||
| 151 | u8 *val = (u8 *)kctrl->private_value; | ||
| 152 | |||
| 144 | uinfo->count = RSND_DVC_VOLUME_NUM; | 153 | uinfo->count = RSND_DVC_VOLUME_NUM; |
| 145 | uinfo->value.integer.min = 0; | 154 | uinfo->value.integer.min = 0; |
| 146 | uinfo->value.integer.max = RSND_DVC_VOLUME_MAX; | 155 | |
| 156 | if (val == dvc->volume) { | ||
| 157 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | ||
| 158 | uinfo->value.integer.max = RSND_DVC_VOLUME_MAX; | ||
| 159 | } else { | ||
| 160 | uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; | ||
| 161 | uinfo->value.integer.max = 1; | ||
| 162 | } | ||
| 147 | 163 | ||
| 148 | return 0; | 164 | return 0; |
| 149 | } | 165 | } |
| @@ -151,12 +167,11 @@ static int rsnd_dvc_volume_info(struct snd_kcontrol *kctrl, | |||
| 151 | static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl, | 167 | static int rsnd_dvc_volume_get(struct snd_kcontrol *kctrl, |
| 152 | struct snd_ctl_elem_value *ucontrol) | 168 | struct snd_ctl_elem_value *ucontrol) |
| 153 | { | 169 | { |
| 154 | struct rsnd_mod *mod = snd_kcontrol_chip(kctrl); | 170 | u8 *val = (u8 *)kctrl->private_value; |
| 155 | struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); | ||
| 156 | int i; | 171 | int i; |
| 157 | 172 | ||
| 158 | for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) | 173 | for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) |
| 159 | ucontrol->value.integer.value[i] = dvc->volume[i]; | 174 | ucontrol->value.integer.value[i] = val[i]; |
| 160 | 175 | ||
| 161 | return 0; | 176 | return 0; |
| 162 | } | 177 | } |
| @@ -165,51 +180,38 @@ static int rsnd_dvc_volume_put(struct snd_kcontrol *kctrl, | |||
| 165 | struct snd_ctl_elem_value *ucontrol) | 180 | struct snd_ctl_elem_value *ucontrol) |
| 166 | { | 181 | { |
| 167 | struct rsnd_mod *mod = snd_kcontrol_chip(kctrl); | 182 | struct rsnd_mod *mod = snd_kcontrol_chip(kctrl); |
| 168 | struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); | 183 | u8 *val = (u8 *)kctrl->private_value; |
| 169 | int i, change = 0; | 184 | int i, change = 0; |
| 170 | 185 | ||
| 171 | for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) { | 186 | for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) { |
| 172 | if (ucontrol->value.integer.value[i] < 0 || | 187 | change |= (ucontrol->value.integer.value[i] != val[i]); |
| 173 | ucontrol->value.integer.value[i] > RSND_DVC_VOLUME_MAX) | 188 | val[i] = ucontrol->value.integer.value[i]; |
| 174 | return -EINVAL; | ||
| 175 | |||
| 176 | change |= (ucontrol->value.integer.value[i] != dvc->volume[i]); | ||
| 177 | } | 189 | } |
| 178 | 190 | ||
| 179 | if (change) { | 191 | if (change) |
| 180 | for (i = 0; i < RSND_DVC_VOLUME_NUM; i++) | ||
| 181 | dvc->volume[i] = ucontrol->value.integer.value[i]; | ||
| 182 | |||
| 183 | rsnd_dvc_volume_update(mod); | 192 | rsnd_dvc_volume_update(mod); |
| 184 | } | ||
| 185 | 193 | ||
| 186 | return change; | 194 | return change; |
| 187 | } | 195 | } |
| 188 | 196 | ||
| 189 | static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, | 197 | static int __rsnd_dvc_pcm_new(struct rsnd_mod *mod, |
| 190 | struct rsnd_dai *rdai, | 198 | struct rsnd_dai *rdai, |
| 191 | struct snd_soc_pcm_runtime *rtd) | 199 | struct snd_soc_pcm_runtime *rtd, |
| 200 | const unsigned char *name, | ||
| 201 | u8 *private) | ||
| 192 | { | 202 | { |
| 193 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | ||
| 194 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
| 195 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 196 | struct snd_card *card = rtd->card->snd_card; | 203 | struct snd_card *card = rtd->card->snd_card; |
| 197 | struct snd_kcontrol *kctrl; | 204 | struct snd_kcontrol *kctrl; |
| 198 | static struct snd_kcontrol_new knew = { | 205 | struct snd_kcontrol_new knew = { |
| 199 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 206 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
| 200 | .name = "Playback Volume", | 207 | .name = name, |
| 201 | .info = rsnd_dvc_volume_info, | 208 | .info = rsnd_dvc_volume_info, |
| 202 | .get = rsnd_dvc_volume_get, | 209 | .get = rsnd_dvc_volume_get, |
| 203 | .put = rsnd_dvc_volume_put, | 210 | .put = rsnd_dvc_volume_put, |
| 211 | .private_value = (unsigned long)private, | ||
| 204 | }; | 212 | }; |
| 205 | int ret; | 213 | int ret; |
| 206 | 214 | ||
| 207 | if (!rsnd_dai_is_play(rdai, io)) { | ||
| 208 | dev_err(dev, "DVC%d is connected to Capture DAI\n", | ||
| 209 | rsnd_mod_id(mod)); | ||
| 210 | return -EINVAL; | ||
| 211 | } | ||
| 212 | |||
| 213 | kctrl = snd_ctl_new1(&knew, mod); | 215 | kctrl = snd_ctl_new1(&knew, mod); |
| 214 | if (!kctrl) | 216 | if (!kctrl) |
| 215 | return -ENOMEM; | 217 | return -ENOMEM; |
| @@ -221,6 +223,33 @@ static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, | |||
| 221 | return 0; | 223 | return 0; |
| 222 | } | 224 | } |
| 223 | 225 | ||
| 226 | static int rsnd_dvc_pcm_new(struct rsnd_mod *mod, | ||
| 227 | struct rsnd_dai *rdai, | ||
| 228 | struct snd_soc_pcm_runtime *rtd) | ||
| 229 | { | ||
| 230 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | ||
| 231 | struct rsnd_dvc *dvc = rsnd_mod_to_dvc(mod); | ||
| 232 | int ret; | ||
| 233 | |||
| 234 | /* Volume */ | ||
| 235 | ret = __rsnd_dvc_pcm_new(mod, rdai, rtd, | ||
| 236 | rsnd_dai_is_play(rdai, io) ? | ||
| 237 | "DVC Out Playback Volume" : "DVC In Capture Volume", | ||
| 238 | dvc->volume); | ||
| 239 | if (ret < 0) | ||
| 240 | return ret; | ||
| 241 | |||
| 242 | /* Mute */ | ||
| 243 | ret = __rsnd_dvc_pcm_new(mod, rdai, rtd, | ||
| 244 | rsnd_dai_is_play(rdai, io) ? | ||
| 245 | "DVC Out Mute Switch" : "DVC In Mute Switch", | ||
| 246 | dvc->mute); | ||
| 247 | if (ret < 0) | ||
| 248 | return ret; | ||
| 249 | |||
| 250 | return 0; | ||
| 251 | } | ||
| 252 | |||
| 224 | static struct rsnd_mod_ops rsnd_dvc_ops = { | 253 | static struct rsnd_mod_ops rsnd_dvc_ops = { |
| 225 | .name = DVC_NAME, | 254 | .name = DVC_NAME, |
| 226 | .probe = rsnd_dvc_probe_gen2, | 255 | .probe = rsnd_dvc_probe_gen2, |
| @@ -239,6 +268,42 @@ struct rsnd_mod *rsnd_dvc_mod_get(struct rsnd_priv *priv, int id) | |||
| 239 | return &((struct rsnd_dvc *)(priv->dvc) + id)->mod; | 268 | return &((struct rsnd_dvc *)(priv->dvc) + id)->mod; |
| 240 | } | 269 | } |
| 241 | 270 | ||
| 271 | static void rsnd_of_parse_dvc(struct platform_device *pdev, | ||
| 272 | const struct rsnd_of_data *of_data, | ||
| 273 | struct rsnd_priv *priv) | ||
| 274 | { | ||
| 275 | struct device_node *node; | ||
| 276 | struct rsnd_dvc_platform_info *dvc_info; | ||
| 277 | struct rcar_snd_info *info = rsnd_priv_to_info(priv); | ||
| 278 | struct device *dev = &pdev->dev; | ||
| 279 | int nr; | ||
| 280 | |||
| 281 | if (!of_data) | ||
| 282 | return; | ||
| 283 | |||
| 284 | node = of_get_child_by_name(dev->of_node, "rcar_sound,dvc"); | ||
| 285 | if (!node) | ||
| 286 | return; | ||
| 287 | |||
| 288 | nr = of_get_child_count(node); | ||
| 289 | if (!nr) | ||
| 290 | goto rsnd_of_parse_dvc_end; | ||
| 291 | |||
| 292 | dvc_info = devm_kzalloc(dev, | ||
| 293 | sizeof(struct rsnd_dvc_platform_info) * nr, | ||
| 294 | GFP_KERNEL); | ||
| 295 | if (!dvc_info) { | ||
| 296 | dev_err(dev, "dvc info allocation error\n"); | ||
| 297 | goto rsnd_of_parse_dvc_end; | ||
| 298 | } | ||
| 299 | |||
| 300 | info->dvc_info = dvc_info; | ||
| 301 | info->dvc_info_nr = nr; | ||
| 302 | |||
| 303 | rsnd_of_parse_dvc_end: | ||
| 304 | of_node_put(node); | ||
| 305 | } | ||
| 306 | |||
| 242 | int rsnd_dvc_probe(struct platform_device *pdev, | 307 | int rsnd_dvc_probe(struct platform_device *pdev, |
| 243 | const struct rsnd_of_data *of_data, | 308 | const struct rsnd_of_data *of_data, |
| 244 | struct rsnd_priv *priv) | 309 | struct rsnd_priv *priv) |
| @@ -250,6 +315,8 @@ int rsnd_dvc_probe(struct platform_device *pdev, | |||
| 250 | char name[RSND_DVC_NAME_SIZE]; | 315 | char name[RSND_DVC_NAME_SIZE]; |
| 251 | int i, nr; | 316 | int i, nr; |
| 252 | 317 | ||
| 318 | rsnd_of_parse_dvc(pdev, of_data, priv); | ||
| 319 | |||
| 253 | nr = info->dvc_info_nr; | 320 | nr = info->dvc_info_nr; |
| 254 | if (!nr) | 321 | if (!nr) |
| 255 | return 0; | 322 | return 0; |
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 1dd2b7d38c2c..3fdf3be7b99a 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c | |||
| @@ -15,63 +15,35 @@ struct rsnd_gen { | |||
| 15 | 15 | ||
| 16 | struct rsnd_gen_ops *ops; | 16 | struct rsnd_gen_ops *ops; |
| 17 | 17 | ||
| 18 | struct regmap *regmap; | 18 | struct regmap *regmap[RSND_BASE_MAX]; |
| 19 | struct regmap_field *regs[RSND_REG_MAX]; | 19 | struct regmap_field *regs[RSND_REG_MAX]; |
| 20 | }; | 20 | }; |
| 21 | 21 | ||
| 22 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) | 22 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) |
| 23 | 23 | ||
| 24 | #define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size) \ | 24 | struct rsnd_regmap_field_conf { |
| 25 | [id] = { \ | 25 | int idx; |
| 26 | .reg = (unsigned int)gen->base[reg_id] + offset, \ | 26 | unsigned int reg_offset; |
| 27 | .lsb = 0, \ | 27 | unsigned int id_offset; |
| 28 | .msb = 31, \ | 28 | }; |
| 29 | .id_size = _id_size, \ | ||
| 30 | .id_offset = _id_offset, \ | ||
| 31 | } | ||
| 32 | |||
| 33 | /* | ||
| 34 | * basic function | ||
| 35 | */ | ||
| 36 | static int rsnd_regmap_write32(void *context, const void *_data, size_t count) | ||
| 37 | { | ||
| 38 | struct rsnd_priv *priv = context; | ||
| 39 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 40 | u32 *data = (u32 *)_data; | ||
| 41 | u32 val = data[1]; | ||
| 42 | void __iomem *reg = (void *)data[0]; | ||
| 43 | |||
| 44 | iowrite32(val, reg); | ||
| 45 | |||
| 46 | dev_dbg(dev, "w %p : %08x\n", reg, val); | ||
| 47 | |||
| 48 | return 0; | ||
| 49 | } | ||
| 50 | |||
| 51 | static int rsnd_regmap_read32(void *context, | ||
| 52 | const void *_data, size_t reg_size, | ||
| 53 | void *_val, size_t val_size) | ||
| 54 | { | ||
| 55 | struct rsnd_priv *priv = context; | ||
| 56 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 57 | u32 *data = (u32 *)_data; | ||
| 58 | u32 *val = (u32 *)_val; | ||
| 59 | void __iomem *reg = (void *)data[0]; | ||
| 60 | |||
| 61 | *val = ioread32(reg); | ||
| 62 | |||
| 63 | dev_dbg(dev, "r %p : %08x\n", reg, *val); | ||
| 64 | 29 | ||
| 65 | return 0; | 30 | #define RSND_REG_SET(id, offset, _id_offset) \ |
| 31 | { \ | ||
| 32 | .idx = id, \ | ||
| 33 | .reg_offset = offset, \ | ||
| 34 | .id_offset = _id_offset, \ | ||
| 66 | } | 35 | } |
| 36 | /* single address mapping */ | ||
| 37 | #define RSND_GEN_S_REG(id, offset) \ | ||
| 38 | RSND_REG_SET(RSND_REG_##id, offset, 0) | ||
| 67 | 39 | ||
| 68 | static struct regmap_bus rsnd_regmap_bus = { | 40 | /* multi address mapping */ |
| 69 | .write = rsnd_regmap_write32, | 41 | #define RSND_GEN_M_REG(id, offset, _id_offset) \ |
| 70 | .read = rsnd_regmap_read32, | 42 | RSND_REG_SET(RSND_REG_##id, offset, _id_offset) |
| 71 | .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
| 72 | .val_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
| 73 | }; | ||
| 74 | 43 | ||
| 44 | /* | ||
| 45 | * basic function | ||
| 46 | */ | ||
| 75 | static int rsnd_is_accessible_reg(struct rsnd_priv *priv, | 47 | static int rsnd_is_accessible_reg(struct rsnd_priv *priv, |
| 76 | struct rsnd_gen *gen, enum rsnd_reg reg) | 48 | struct rsnd_gen *gen, enum rsnd_reg reg) |
| 77 | { | 49 | { |
| @@ -88,6 +60,7 @@ static int rsnd_is_accessible_reg(struct rsnd_priv *priv, | |||
| 88 | u32 rsnd_read(struct rsnd_priv *priv, | 60 | u32 rsnd_read(struct rsnd_priv *priv, |
| 89 | struct rsnd_mod *mod, enum rsnd_reg reg) | 61 | struct rsnd_mod *mod, enum rsnd_reg reg) |
| 90 | { | 62 | { |
| 63 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 91 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 64 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
| 92 | u32 val; | 65 | u32 val; |
| 93 | 66 | ||
| @@ -96,6 +69,8 @@ u32 rsnd_read(struct rsnd_priv *priv, | |||
| 96 | 69 | ||
| 97 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); | 70 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); |
| 98 | 71 | ||
| 72 | dev_dbg(dev, "r %s - 0x%04d : %08x\n", rsnd_mod_name(mod), reg, val); | ||
| 73 | |||
| 99 | return val; | 74 | return val; |
| 100 | } | 75 | } |
| 101 | 76 | ||
| @@ -103,17 +78,21 @@ void rsnd_write(struct rsnd_priv *priv, | |||
| 103 | struct rsnd_mod *mod, | 78 | struct rsnd_mod *mod, |
| 104 | enum rsnd_reg reg, u32 data) | 79 | enum rsnd_reg reg, u32 data) |
| 105 | { | 80 | { |
| 81 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 106 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 82 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
| 107 | 83 | ||
| 108 | if (!rsnd_is_accessible_reg(priv, gen, reg)) | 84 | if (!rsnd_is_accessible_reg(priv, gen, reg)) |
| 109 | return; | 85 | return; |
| 110 | 86 | ||
| 111 | regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); | 87 | regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); |
| 88 | |||
| 89 | dev_dbg(dev, "w %s - 0x%04d : %08x\n", rsnd_mod_name(mod), reg, data); | ||
| 112 | } | 90 | } |
| 113 | 91 | ||
| 114 | void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, | 92 | void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, |
| 115 | enum rsnd_reg reg, u32 mask, u32 data) | 93 | enum rsnd_reg reg, u32 mask, u32 data) |
| 116 | { | 94 | { |
| 95 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 117 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 96 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
| 118 | 97 | ||
| 119 | if (!rsnd_is_accessible_reg(priv, gen, reg)) | 98 | if (!rsnd_is_accessible_reg(priv, gen, reg)) |
| @@ -121,35 +100,63 @@ void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, | |||
| 121 | 100 | ||
| 122 | regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), | 101 | regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), |
| 123 | mask, data); | 102 | mask, data); |
| 103 | |||
| 104 | dev_dbg(dev, "b %s - 0x%04d : %08x/%08x\n", | ||
| 105 | rsnd_mod_name(mod), reg, data, mask); | ||
| 124 | } | 106 | } |
| 125 | 107 | ||
| 126 | static int rsnd_gen_regmap_init(struct rsnd_priv *priv, | 108 | #define rsnd_gen_regmap_init(priv, id_size, reg_id, conf) \ |
| 127 | struct rsnd_gen *gen, | 109 | _rsnd_gen_regmap_init(priv, id_size, reg_id, conf, ARRAY_SIZE(conf)) |
| 128 | struct reg_field *regf) | 110 | static int _rsnd_gen_regmap_init(struct rsnd_priv *priv, |
| 111 | int id_size, | ||
| 112 | int reg_id, | ||
| 113 | struct rsnd_regmap_field_conf *conf, | ||
| 114 | int conf_size) | ||
| 129 | { | 115 | { |
| 130 | int i; | 116 | struct platform_device *pdev = rsnd_priv_to_pdev(priv); |
| 117 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
| 131 | struct device *dev = rsnd_priv_to_dev(priv); | 118 | struct device *dev = rsnd_priv_to_dev(priv); |
| 119 | struct resource *res; | ||
| 132 | struct regmap_config regc; | 120 | struct regmap_config regc; |
| 121 | struct regmap_field *regs; | ||
| 122 | struct regmap *regmap; | ||
| 123 | struct reg_field regf; | ||
| 124 | void __iomem *base; | ||
| 125 | int i; | ||
| 133 | 126 | ||
| 134 | memset(®c, 0, sizeof(regc)); | 127 | memset(®c, 0, sizeof(regc)); |
| 135 | regc.reg_bits = 32; | 128 | regc.reg_bits = 32; |
| 136 | regc.val_bits = 32; | 129 | regc.val_bits = 32; |
| 130 | regc.reg_stride = 4; | ||
| 137 | 131 | ||
| 138 | gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, ®c); | 132 | res = platform_get_resource(pdev, IORESOURCE_MEM, reg_id); |
| 139 | if (IS_ERR(gen->regmap)) { | 133 | if (!res) |
| 140 | dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); | 134 | return -ENODEV; |
| 141 | return PTR_ERR(gen->regmap); | ||
| 142 | } | ||
| 143 | 135 | ||
| 144 | for (i = 0; i < RSND_REG_MAX; i++) { | 136 | base = devm_ioremap_resource(dev, res); |
| 145 | gen->regs[i] = NULL; | 137 | if (IS_ERR(base)) |
| 146 | if (!regf[i].reg) | 138 | return PTR_ERR(base); |
| 147 | continue; | ||
| 148 | 139 | ||
| 149 | gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); | 140 | regmap = devm_regmap_init_mmio(dev, base, ®c); |
| 150 | if (IS_ERR(gen->regs[i])) | 141 | if (IS_ERR(regmap)) |
| 151 | return PTR_ERR(gen->regs[i]); | 142 | return PTR_ERR(regmap); |
| 152 | 143 | ||
| 144 | gen->base[reg_id] = base; | ||
| 145 | gen->regmap[reg_id] = regmap; | ||
| 146 | |||
| 147 | for (i = 0; i < conf_size; i++) { | ||
| 148 | |||
| 149 | regf.reg = conf[i].reg_offset; | ||
| 150 | regf.id_offset = conf[i].id_offset; | ||
| 151 | regf.lsb = 0; | ||
| 152 | regf.msb = 31; | ||
| 153 | regf.id_size = id_size; | ||
| 154 | |||
| 155 | regs = devm_regmap_field_alloc(dev, regmap, regf); | ||
| 156 | if (IS_ERR(regs)) | ||
| 157 | return PTR_ERR(regs); | ||
| 158 | |||
| 159 | gen->regs[conf[i].idx] = regs; | ||
| 153 | } | 160 | } |
| 154 | 161 | ||
| 155 | return 0; | 162 | return 0; |
| @@ -165,15 +172,19 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv, | |||
| 165 | * | 172 | * |
| 166 | * ex) R-Car H2 case | 173 | * ex) R-Car H2 case |
| 167 | * mod / DMAC in / DMAC out / DMAC PP in / DMAC pp out | 174 | * mod / DMAC in / DMAC out / DMAC PP in / DMAC pp out |
| 168 | * SSI : 0xec541000 / 0xec241008 / 0xec24100c / 0xec400000 / 0xec400000 | 175 | * SSI : 0xec541000 / 0xec241008 / 0xec24100c |
| 176 | * SSIU: 0xec541000 / 0xec100000 / 0xec100000 / 0xec400000 / 0xec400000 | ||
| 169 | * SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000 | 177 | * SCU : 0xec500000 / 0xec000000 / 0xec004000 / 0xec300000 / 0xec304000 |
| 170 | * CMD : 0xec500000 / 0xec008000 0xec308000 | 178 | * CMD : 0xec500000 / / 0xec008000 0xec308000 |
| 171 | */ | 179 | */ |
| 172 | #define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8) | 180 | #define RDMA_SSI_I_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0x8) |
| 173 | #define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc) | 181 | #define RDMA_SSI_O_N(addr, i) (addr ##_reg - 0x00300000 + (0x40 * i) + 0xc) |
| 174 | 182 | ||
| 175 | #define RDMA_SSI_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | 183 | #define RDMA_SSIU_I_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i)) |
| 176 | #define RDMA_SSI_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | 184 | #define RDMA_SSIU_O_N(addr, i) (addr ##_reg - 0x00441000 + (0x1000 * i)) |
| 185 | |||
| 186 | #define RDMA_SSIU_I_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | ||
| 187 | #define RDMA_SSIU_O_P(addr, i) (addr ##_reg - 0x00141000 + (0x1000 * i)) | ||
| 177 | 188 | ||
| 178 | #define RDMA_SRC_I_N(addr, i) (addr ##_reg - 0x00500000 + (0x400 * i)) | 189 | #define RDMA_SRC_I_N(addr, i) (addr ##_reg - 0x00500000 + (0x400 * i)) |
| 179 | #define RDMA_SRC_O_N(addr, i) (addr ##_reg - 0x004fc000 + (0x400 * i)) | 190 | #define RDMA_SRC_O_N(addr, i) (addr ##_reg - 0x004fc000 + (0x400 * i)) |
| @@ -184,14 +195,13 @@ static int rsnd_gen_regmap_init(struct rsnd_priv *priv, | |||
| 184 | #define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i)) | 195 | #define RDMA_CMD_O_N(addr, i) (addr ##_reg - 0x004f8000 + (0x400 * i)) |
| 185 | #define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i)) | 196 | #define RDMA_CMD_O_P(addr, i) (addr ##_reg - 0x001f8000 + (0x400 * i)) |
| 186 | 197 | ||
| 187 | void rsnd_gen_dma_addr(struct rsnd_priv *priv, | 198 | static dma_addr_t |
| 188 | struct rsnd_dma *dma, | 199 | rsnd_gen2_dma_addr(struct rsnd_priv *priv, |
| 189 | struct dma_slave_config *cfg, | 200 | struct rsnd_mod *mod, |
| 190 | int is_play, int slave_id) | 201 | int is_play, int is_from) |
| 191 | { | 202 | { |
| 192 | struct platform_device *pdev = rsnd_priv_to_pdev(priv); | 203 | struct platform_device *pdev = rsnd_priv_to_pdev(priv); |
| 193 | struct device *dev = rsnd_priv_to_dev(priv); | 204 | struct device *dev = rsnd_priv_to_dev(priv); |
| 194 | struct rsnd_mod *mod = rsnd_dma_to_mod(dma); | ||
| 195 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | 205 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); |
| 196 | dma_addr_t ssi_reg = platform_get_resource(pdev, | 206 | dma_addr_t ssi_reg = platform_get_resource(pdev, |
| 197 | IORESOURCE_MEM, RSND_GEN2_SSI)->start; | 207 | IORESOURCE_MEM, RSND_GEN2_SSI)->start; |
| @@ -202,170 +212,152 @@ void rsnd_gen_dma_addr(struct rsnd_priv *priv, | |||
| 202 | int use_dvc = !!rsnd_io_to_mod_dvc(io); | 212 | int use_dvc = !!rsnd_io_to_mod_dvc(io); |
| 203 | int id = rsnd_mod_id(mod); | 213 | int id = rsnd_mod_id(mod); |
| 204 | struct dma_addr { | 214 | struct dma_addr { |
| 205 | dma_addr_t src_addr; | 215 | dma_addr_t out_addr; |
| 206 | dma_addr_t dst_addr; | 216 | dma_addr_t in_addr; |
| 207 | } dma_addrs[2][2][3] = { | 217 | } dma_addrs[3][2][3] = { |
| 208 | { /* SRC */ | 218 | /* SRC */ |
| 209 | /* Capture */ | 219 | {{{ 0, 0 }, |
| 210 | {{ 0, 0 }, | 220 | /* Capture */ |
| 211 | { RDMA_SRC_O_N(src, id), 0 }, | 221 | { RDMA_SRC_O_N(src, id), RDMA_SRC_I_P(src, id) }, |
| 212 | { RDMA_CMD_O_N(src, id), 0 }}, | 222 | { RDMA_CMD_O_N(src, id), RDMA_SRC_I_P(src, id) } }, |
| 213 | /* Playback */ | 223 | /* Playback */ |
| 214 | {{ 0, 0, }, | 224 | {{ 0, 0, }, |
| 215 | { 0, RDMA_SRC_I_N(src, id) }, | 225 | { RDMA_SRC_O_P(src, id), RDMA_SRC_I_N(src, id) }, |
| 216 | { 0, RDMA_SRC_I_N(src, id) }} | 226 | { RDMA_CMD_O_P(src, id), RDMA_SRC_I_N(src, id) } } |
| 217 | }, { /* SSI */ | 227 | }, |
| 218 | /* Capture */ | 228 | /* SSI */ |
| 219 | {{ RDMA_SSI_O_N(ssi, id), 0 }, | 229 | /* Capture */ |
| 220 | { RDMA_SSI_O_P(ssi, id), RDMA_SRC_I_P(src, id) }, | 230 | {{{ RDMA_SSI_O_N(ssi, id), 0 }, |
| 221 | { RDMA_SSI_O_P(ssi, id), RDMA_SRC_I_P(src, id) }}, | 231 | { RDMA_SSIU_O_P(ssi, id), 0 }, |
| 222 | /* Playback */ | 232 | { RDMA_SSIU_O_P(ssi, id), 0 } }, |
| 223 | {{ 0, RDMA_SSI_I_N(ssi, id) }, | 233 | /* Playback */ |
| 224 | { RDMA_SRC_O_P(src, id), RDMA_SSI_I_P(ssi, id) }, | 234 | {{ 0, RDMA_SSI_I_N(ssi, id) }, |
| 225 | { RDMA_CMD_O_P(src, id), RDMA_SSI_I_P(ssi, id) }} | 235 | { 0, RDMA_SSIU_I_P(ssi, id) }, |
| 226 | } | 236 | { 0, RDMA_SSIU_I_P(ssi, id) } } |
| 237 | }, | ||
| 238 | /* SSIU */ | ||
| 239 | /* Capture */ | ||
| 240 | {{{ RDMA_SSIU_O_N(ssi, id), 0 }, | ||
| 241 | { RDMA_SSIU_O_P(ssi, id), 0 }, | ||
| 242 | { RDMA_SSIU_O_P(ssi, id), 0 } }, | ||
| 243 | /* Playback */ | ||
| 244 | {{ 0, RDMA_SSIU_I_N(ssi, id) }, | ||
| 245 | { 0, RDMA_SSIU_I_P(ssi, id) }, | ||
| 246 | { 0, RDMA_SSIU_I_P(ssi, id) } } }, | ||
| 227 | }; | 247 | }; |
| 228 | 248 | ||
| 229 | cfg->slave_id = slave_id; | 249 | /* it shouldn't happen */ |
| 230 | cfg->src_addr = 0; | 250 | if (use_dvc & !use_src) |
| 231 | cfg->dst_addr = 0; | 251 | dev_err(dev, "DVC is selected without SRC\n"); |
| 232 | cfg->direction = is_play ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM; | 252 | |
| 253 | /* use SSIU or SSI ? */ | ||
| 254 | if (is_ssi && (0 == strcmp(rsnd_mod_dma_name(mod), "ssiu"))) | ||
| 255 | is_ssi++; | ||
| 256 | |||
| 257 | return (is_from) ? | ||
| 258 | dma_addrs[is_ssi][is_play][use_src + use_dvc].out_addr : | ||
| 259 | dma_addrs[is_ssi][is_play][use_src + use_dvc].in_addr; | ||
| 260 | } | ||
| 233 | 261 | ||
| 262 | dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv, | ||
| 263 | struct rsnd_mod *mod, | ||
| 264 | int is_play, int is_from) | ||
| 265 | { | ||
| 234 | /* | 266 | /* |
| 235 | * gen1 uses default DMA addr | 267 | * gen1 uses default DMA addr |
| 236 | */ | 268 | */ |
| 237 | if (rsnd_is_gen1(priv)) | 269 | if (rsnd_is_gen1(priv)) |
| 238 | return; | 270 | return 0; |
| 239 | |||
| 240 | /* it shouldn't happen */ | ||
| 241 | if (use_dvc & !use_src) { | ||
| 242 | dev_err(dev, "DVC is selected without SRC\n"); | ||
| 243 | return; | ||
| 244 | } | ||
| 245 | 271 | ||
| 246 | cfg->src_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].src_addr; | 272 | if (!mod) |
| 247 | cfg->dst_addr = dma_addrs[is_ssi][is_play][use_src + use_dvc].dst_addr; | 273 | return 0; |
| 248 | 274 | ||
| 249 | dev_dbg(dev, "dma%d addr - src : %x / dst : %x\n", | 275 | return rsnd_gen2_dma_addr(priv, mod, is_play, is_from); |
| 250 | id, cfg->src_addr, cfg->dst_addr); | ||
| 251 | } | 276 | } |
| 252 | 277 | ||
| 253 | /* | 278 | /* |
| 254 | * Gen2 | 279 | * Gen2 |
| 255 | */ | 280 | */ |
| 256 | |||
| 257 | /* single address mapping */ | ||
| 258 | #define RSND_GEN2_S_REG(gen, reg, id, offset) \ | ||
| 259 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, 0, 10) | ||
| 260 | |||
| 261 | /* multi address mapping */ | ||
| 262 | #define RSND_GEN2_M_REG(gen, reg, id, offset, _id_offset) \ | ||
| 263 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN2_##reg, offset, _id_offset, 10) | ||
| 264 | |||
| 265 | static int rsnd_gen2_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) | ||
| 266 | { | ||
| 267 | struct reg_field regf[RSND_REG_MAX] = { | ||
| 268 | RSND_GEN2_S_REG(gen, SSIU, SSI_MODE0, 0x800), | ||
| 269 | RSND_GEN2_S_REG(gen, SSIU, SSI_MODE1, 0x804), | ||
| 270 | /* FIXME: it needs SSI_MODE2/3 in the future */ | ||
| 271 | RSND_GEN2_M_REG(gen, SSIU, SSI_BUSIF_MODE, 0x0, 0x80), | ||
| 272 | RSND_GEN2_M_REG(gen, SSIU, SSI_BUSIF_ADINR,0x4, 0x80), | ||
| 273 | RSND_GEN2_M_REG(gen, SSIU, SSI_CTRL, 0x10, 0x80), | ||
| 274 | RSND_GEN2_M_REG(gen, SSIU, INT_ENABLE, 0x18, 0x80), | ||
| 275 | |||
| 276 | RSND_GEN2_M_REG(gen, SCU, SRC_BUSIF_MODE, 0x0, 0x20), | ||
| 277 | RSND_GEN2_M_REG(gen, SCU, SRC_ROUTE_MODE0,0xc, 0x20), | ||
| 278 | RSND_GEN2_M_REG(gen, SCU, SRC_CTRL, 0x10, 0x20), | ||
| 279 | RSND_GEN2_M_REG(gen, SCU, CMD_ROUTE_SLCT, 0x18c, 0x20), | ||
| 280 | RSND_GEN2_M_REG(gen, SCU, CMD_CTRL, 0x190, 0x20), | ||
| 281 | RSND_GEN2_M_REG(gen, SCU, SRC_SWRSR, 0x200, 0x40), | ||
| 282 | RSND_GEN2_M_REG(gen, SCU, SRC_SRCIR, 0x204, 0x40), | ||
| 283 | RSND_GEN2_M_REG(gen, SCU, SRC_ADINR, 0x214, 0x40), | ||
| 284 | RSND_GEN2_M_REG(gen, SCU, SRC_IFSCR, 0x21c, 0x40), | ||
| 285 | RSND_GEN2_M_REG(gen, SCU, SRC_IFSVR, 0x220, 0x40), | ||
| 286 | RSND_GEN2_M_REG(gen, SCU, SRC_SRCCR, 0x224, 0x40), | ||
| 287 | RSND_GEN2_M_REG(gen, SCU, SRC_BSDSR, 0x22c, 0x40), | ||
| 288 | RSND_GEN2_M_REG(gen, SCU, SRC_BSISR, 0x238, 0x40), | ||
| 289 | RSND_GEN2_M_REG(gen, SCU, DVC_SWRSR, 0xe00, 0x100), | ||
| 290 | RSND_GEN2_M_REG(gen, SCU, DVC_DVUIR, 0xe04, 0x100), | ||
| 291 | RSND_GEN2_M_REG(gen, SCU, DVC_ADINR, 0xe08, 0x100), | ||
| 292 | RSND_GEN2_M_REG(gen, SCU, DVC_DVUCR, 0xe10, 0x100), | ||
| 293 | RSND_GEN2_M_REG(gen, SCU, DVC_ZCMCR, 0xe14, 0x100), | ||
| 294 | RSND_GEN2_M_REG(gen, SCU, DVC_VOL0R, 0xe28, 0x100), | ||
| 295 | RSND_GEN2_M_REG(gen, SCU, DVC_VOL1R, 0xe2c, 0x100), | ||
| 296 | RSND_GEN2_M_REG(gen, SCU, DVC_DVUER, 0xe48, 0x100), | ||
| 297 | |||
| 298 | RSND_GEN2_S_REG(gen, ADG, BRRA, 0x00), | ||
| 299 | RSND_GEN2_S_REG(gen, ADG, BRRB, 0x04), | ||
| 300 | RSND_GEN2_S_REG(gen, ADG, SSICKR, 0x08), | ||
| 301 | RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL0, 0x0c), | ||
| 302 | RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL1, 0x10), | ||
| 303 | RSND_GEN2_S_REG(gen, ADG, AUDIO_CLK_SEL2, 0x14), | ||
| 304 | RSND_GEN2_S_REG(gen, ADG, DIV_EN, 0x30), | ||
| 305 | RSND_GEN2_S_REG(gen, ADG, SRCIN_TIMSEL0, 0x34), | ||
| 306 | RSND_GEN2_S_REG(gen, ADG, SRCIN_TIMSEL1, 0x38), | ||
| 307 | RSND_GEN2_S_REG(gen, ADG, SRCIN_TIMSEL2, 0x3c), | ||
| 308 | RSND_GEN2_S_REG(gen, ADG, SRCIN_TIMSEL3, 0x40), | ||
| 309 | RSND_GEN2_S_REG(gen, ADG, SRCIN_TIMSEL4, 0x44), | ||
| 310 | RSND_GEN2_S_REG(gen, ADG, SRCOUT_TIMSEL0, 0x48), | ||
| 311 | RSND_GEN2_S_REG(gen, ADG, SRCOUT_TIMSEL1, 0x4c), | ||
| 312 | RSND_GEN2_S_REG(gen, ADG, SRCOUT_TIMSEL2, 0x50), | ||
| 313 | RSND_GEN2_S_REG(gen, ADG, SRCOUT_TIMSEL3, 0x54), | ||
| 314 | RSND_GEN2_S_REG(gen, ADG, SRCOUT_TIMSEL4, 0x58), | ||
| 315 | RSND_GEN2_S_REG(gen, ADG, CMDOUT_TIMSEL, 0x5c), | ||
| 316 | |||
| 317 | RSND_GEN2_M_REG(gen, SSI, SSICR, 0x00, 0x40), | ||
| 318 | RSND_GEN2_M_REG(gen, SSI, SSISR, 0x04, 0x40), | ||
| 319 | RSND_GEN2_M_REG(gen, SSI, SSITDR, 0x08, 0x40), | ||
| 320 | RSND_GEN2_M_REG(gen, SSI, SSIRDR, 0x0c, 0x40), | ||
| 321 | RSND_GEN2_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), | ||
| 322 | }; | ||
| 323 | |||
| 324 | return rsnd_gen_regmap_init(priv, gen, regf); | ||
| 325 | } | ||
| 326 | |||
| 327 | static int rsnd_gen2_probe(struct platform_device *pdev, | 281 | static int rsnd_gen2_probe(struct platform_device *pdev, |
| 328 | struct rsnd_priv *priv) | 282 | struct rsnd_priv *priv) |
| 329 | { | 283 | { |
| 330 | struct device *dev = rsnd_priv_to_dev(priv); | 284 | struct device *dev = rsnd_priv_to_dev(priv); |
| 331 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 285 | struct rsnd_regmap_field_conf conf_ssiu[] = { |
| 332 | struct resource *scu_res; | 286 | RSND_GEN_S_REG(SSI_MODE0, 0x800), |
| 333 | struct resource *adg_res; | 287 | RSND_GEN_S_REG(SSI_MODE1, 0x804), |
| 334 | struct resource *ssiu_res; | 288 | /* FIXME: it needs SSI_MODE2/3 in the future */ |
| 335 | struct resource *ssi_res; | 289 | RSND_GEN_M_REG(SSI_BUSIF_MODE, 0x0, 0x80), |
| 336 | int ret; | 290 | RSND_GEN_M_REG(SSI_BUSIF_ADINR, 0x4, 0x80), |
| 337 | 291 | RSND_GEN_M_REG(BUSIF_DALIGN, 0x8, 0x80), | |
| 338 | /* | 292 | RSND_GEN_M_REG(SSI_CTRL, 0x10, 0x80), |
| 339 | * map address | 293 | RSND_GEN_M_REG(INT_ENABLE, 0x18, 0x80), |
| 340 | */ | 294 | }; |
| 341 | scu_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SCU); | 295 | struct rsnd_regmap_field_conf conf_scu[] = { |
| 342 | adg_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_ADG); | 296 | RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x0, 0x20), |
| 343 | ssiu_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSIU); | 297 | RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0xc, 0x20), |
| 344 | ssi_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN2_SSI); | 298 | RSND_GEN_M_REG(SRC_CTRL, 0x10, 0x20), |
| 345 | 299 | RSND_GEN_M_REG(CMD_ROUTE_SLCT, 0x18c, 0x20), | |
| 346 | gen->base[RSND_GEN2_SCU] = devm_ioremap_resource(dev, scu_res); | 300 | RSND_GEN_M_REG(CMD_CTRL, 0x190, 0x20), |
| 347 | gen->base[RSND_GEN2_ADG] = devm_ioremap_resource(dev, adg_res); | 301 | RSND_GEN_M_REG(SRC_SWRSR, 0x200, 0x40), |
| 348 | gen->base[RSND_GEN2_SSIU] = devm_ioremap_resource(dev, ssiu_res); | 302 | RSND_GEN_M_REG(SRC_SRCIR, 0x204, 0x40), |
| 349 | gen->base[RSND_GEN2_SSI] = devm_ioremap_resource(dev, ssi_res); | 303 | RSND_GEN_M_REG(SRC_ADINR, 0x214, 0x40), |
| 350 | if (IS_ERR(gen->base[RSND_GEN2_SCU]) || | 304 | RSND_GEN_M_REG(SRC_IFSCR, 0x21c, 0x40), |
| 351 | IS_ERR(gen->base[RSND_GEN2_ADG]) || | 305 | RSND_GEN_M_REG(SRC_IFSVR, 0x220, 0x40), |
| 352 | IS_ERR(gen->base[RSND_GEN2_SSIU]) || | 306 | RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40), |
| 353 | IS_ERR(gen->base[RSND_GEN2_SSI])) | 307 | RSND_GEN_M_REG(SRC_BSDSR, 0x22c, 0x40), |
| 354 | return -ENODEV; | 308 | RSND_GEN_M_REG(SRC_BSISR, 0x238, 0x40), |
| 355 | 309 | RSND_GEN_M_REG(DVC_SWRSR, 0xe00, 0x100), | |
| 356 | ret = rsnd_gen2_regmap_init(priv, gen); | 310 | RSND_GEN_M_REG(DVC_DVUIR, 0xe04, 0x100), |
| 357 | if (ret < 0) | 311 | RSND_GEN_M_REG(DVC_ADINR, 0xe08, 0x100), |
| 358 | return ret; | 312 | RSND_GEN_M_REG(DVC_DVUCR, 0xe10, 0x100), |
| 359 | 313 | RSND_GEN_M_REG(DVC_ZCMCR, 0xe14, 0x100), | |
| 360 | dev_dbg(dev, "Gen2 device probed\n"); | 314 | RSND_GEN_M_REG(DVC_VOL0R, 0xe28, 0x100), |
| 361 | dev_dbg(dev, "SCU : %pap => %p\n", &scu_res->start, | 315 | RSND_GEN_M_REG(DVC_VOL1R, 0xe2c, 0x100), |
| 362 | gen->base[RSND_GEN2_SCU]); | 316 | RSND_GEN_M_REG(DVC_DVUER, 0xe48, 0x100), |
| 363 | dev_dbg(dev, "ADG : %pap => %p\n", &adg_res->start, | 317 | }; |
| 364 | gen->base[RSND_GEN2_ADG]); | 318 | struct rsnd_regmap_field_conf conf_adg[] = { |
| 365 | dev_dbg(dev, "SSIU : %pap => %p\n", &ssiu_res->start, | 319 | RSND_GEN_S_REG(BRRA, 0x00), |
| 366 | gen->base[RSND_GEN2_SSIU]); | 320 | RSND_GEN_S_REG(BRRB, 0x04), |
| 367 | dev_dbg(dev, "SSI : %pap => %p\n", &ssi_res->start, | 321 | RSND_GEN_S_REG(SSICKR, 0x08), |
| 368 | gen->base[RSND_GEN2_SSI]); | 322 | RSND_GEN_S_REG(AUDIO_CLK_SEL0, 0x0c), |
| 323 | RSND_GEN_S_REG(AUDIO_CLK_SEL1, 0x10), | ||
| 324 | RSND_GEN_S_REG(AUDIO_CLK_SEL2, 0x14), | ||
| 325 | RSND_GEN_S_REG(DIV_EN, 0x30), | ||
| 326 | RSND_GEN_S_REG(SRCIN_TIMSEL0, 0x34), | ||
| 327 | RSND_GEN_S_REG(SRCIN_TIMSEL1, 0x38), | ||
| 328 | RSND_GEN_S_REG(SRCIN_TIMSEL2, 0x3c), | ||
| 329 | RSND_GEN_S_REG(SRCIN_TIMSEL3, 0x40), | ||
| 330 | RSND_GEN_S_REG(SRCIN_TIMSEL4, 0x44), | ||
| 331 | RSND_GEN_S_REG(SRCOUT_TIMSEL0, 0x48), | ||
| 332 | RSND_GEN_S_REG(SRCOUT_TIMSEL1, 0x4c), | ||
| 333 | RSND_GEN_S_REG(SRCOUT_TIMSEL2, 0x50), | ||
| 334 | RSND_GEN_S_REG(SRCOUT_TIMSEL3, 0x54), | ||
| 335 | RSND_GEN_S_REG(SRCOUT_TIMSEL4, 0x58), | ||
| 336 | RSND_GEN_S_REG(CMDOUT_TIMSEL, 0x5c), | ||
| 337 | }; | ||
| 338 | struct rsnd_regmap_field_conf conf_ssi[] = { | ||
| 339 | RSND_GEN_M_REG(SSICR, 0x00, 0x40), | ||
| 340 | RSND_GEN_M_REG(SSISR, 0x04, 0x40), | ||
| 341 | RSND_GEN_M_REG(SSITDR, 0x08, 0x40), | ||
| 342 | RSND_GEN_M_REG(SSIRDR, 0x0c, 0x40), | ||
| 343 | RSND_GEN_M_REG(SSIWSR, 0x20, 0x40), | ||
| 344 | }; | ||
| 345 | int ret_ssiu; | ||
| 346 | int ret_scu; | ||
| 347 | int ret_adg; | ||
| 348 | int ret_ssi; | ||
| 349 | |||
| 350 | ret_ssiu = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSIU, conf_ssiu); | ||
| 351 | ret_scu = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SCU, conf_scu); | ||
| 352 | ret_adg = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_ADG, conf_adg); | ||
| 353 | ret_ssi = rsnd_gen_regmap_init(priv, 10, RSND_GEN2_SSI, conf_ssi); | ||
| 354 | if (ret_ssiu < 0 || | ||
| 355 | ret_scu < 0 || | ||
| 356 | ret_adg < 0 || | ||
| 357 | ret_ssi < 0) | ||
| 358 | return ret_ssiu | ret_scu | ret_adg | ret_ssi; | ||
| 359 | |||
| 360 | dev_dbg(dev, "Gen2 is probed\n"); | ||
| 369 | 361 | ||
| 370 | return 0; | 362 | return 0; |
| 371 | } | 363 | } |
| @@ -374,92 +366,60 @@ static int rsnd_gen2_probe(struct platform_device *pdev, | |||
| 374 | * Gen1 | 366 | * Gen1 |
| 375 | */ | 367 | */ |
| 376 | 368 | ||
| 377 | /* single address mapping */ | ||
| 378 | #define RSND_GEN1_S_REG(gen, reg, id, offset) \ | ||
| 379 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9) | ||
| 380 | |||
| 381 | /* multi address mapping */ | ||
| 382 | #define RSND_GEN1_M_REG(gen, reg, id, offset, _id_offset) \ | ||
| 383 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, _id_offset, 9) | ||
| 384 | |||
| 385 | static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) | ||
| 386 | { | ||
| 387 | struct reg_field regf[RSND_REG_MAX] = { | ||
| 388 | RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_SEL, 0x00), | ||
| 389 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL0, 0x08), | ||
| 390 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL1, 0x0c), | ||
| 391 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL2, 0x10), | ||
| 392 | RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_CTRL, 0xc0), | ||
| 393 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE0, 0xD0), | ||
| 394 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE1, 0xD4), | ||
| 395 | RSND_GEN1_M_REG(gen, SRU, SRC_BUSIF_MODE, 0x20, 0x4), | ||
| 396 | RSND_GEN1_M_REG(gen, SRU, SRC_ROUTE_MODE0,0x50, 0x8), | ||
| 397 | RSND_GEN1_M_REG(gen, SRU, SRC_SWRSR, 0x200, 0x40), | ||
| 398 | RSND_GEN1_M_REG(gen, SRU, SRC_SRCIR, 0x204, 0x40), | ||
| 399 | RSND_GEN1_M_REG(gen, SRU, SRC_ADINR, 0x214, 0x40), | ||
| 400 | RSND_GEN1_M_REG(gen, SRU, SRC_IFSCR, 0x21c, 0x40), | ||
| 401 | RSND_GEN1_M_REG(gen, SRU, SRC_IFSVR, 0x220, 0x40), | ||
| 402 | RSND_GEN1_M_REG(gen, SRU, SRC_SRCCR, 0x224, 0x40), | ||
| 403 | RSND_GEN1_M_REG(gen, SRU, SRC_MNFSR, 0x228, 0x40), | ||
| 404 | |||
| 405 | RSND_GEN1_S_REG(gen, ADG, BRRA, 0x00), | ||
| 406 | RSND_GEN1_S_REG(gen, ADG, BRRB, 0x04), | ||
| 407 | RSND_GEN1_S_REG(gen, ADG, SSICKR, 0x08), | ||
| 408 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL0, 0x0c), | ||
| 409 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL1, 0x10), | ||
| 410 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL3, 0x18), | ||
| 411 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL4, 0x1c), | ||
| 412 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL5, 0x20), | ||
| 413 | |||
| 414 | RSND_GEN1_M_REG(gen, SSI, SSICR, 0x00, 0x40), | ||
| 415 | RSND_GEN1_M_REG(gen, SSI, SSISR, 0x04, 0x40), | ||
| 416 | RSND_GEN1_M_REG(gen, SSI, SSITDR, 0x08, 0x40), | ||
| 417 | RSND_GEN1_M_REG(gen, SSI, SSIRDR, 0x0c, 0x40), | ||
| 418 | RSND_GEN1_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), | ||
| 419 | }; | ||
| 420 | |||
| 421 | return rsnd_gen_regmap_init(priv, gen, regf); | ||
| 422 | } | ||
| 423 | |||
| 424 | static int rsnd_gen1_probe(struct platform_device *pdev, | 369 | static int rsnd_gen1_probe(struct platform_device *pdev, |
| 425 | struct rsnd_priv *priv) | 370 | struct rsnd_priv *priv) |
| 426 | { | 371 | { |
| 427 | struct device *dev = rsnd_priv_to_dev(priv); | 372 | struct device *dev = rsnd_priv_to_dev(priv); |
| 428 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | 373 | struct rsnd_regmap_field_conf conf_sru[] = { |
| 429 | struct resource *sru_res; | 374 | RSND_GEN_S_REG(SRC_ROUTE_SEL, 0x00), |
| 430 | struct resource *adg_res; | 375 | RSND_GEN_S_REG(SRC_TMG_SEL0, 0x08), |
| 431 | struct resource *ssi_res; | 376 | RSND_GEN_S_REG(SRC_TMG_SEL1, 0x0c), |
| 432 | int ret; | 377 | RSND_GEN_S_REG(SRC_TMG_SEL2, 0x10), |
| 433 | 378 | RSND_GEN_S_REG(SRC_ROUTE_CTRL, 0xc0), | |
| 434 | /* | 379 | RSND_GEN_S_REG(SSI_MODE0, 0xD0), |
| 435 | * map address | 380 | RSND_GEN_S_REG(SSI_MODE1, 0xD4), |
| 436 | */ | 381 | RSND_GEN_M_REG(SRC_BUSIF_MODE, 0x20, 0x4), |
| 437 | sru_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SRU); | 382 | RSND_GEN_M_REG(SRC_ROUTE_MODE0, 0x50, 0x8), |
| 438 | adg_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_ADG); | 383 | RSND_GEN_M_REG(SRC_SWRSR, 0x200, 0x40), |
| 439 | ssi_res = platform_get_resource(pdev, IORESOURCE_MEM, RSND_GEN1_SSI); | 384 | RSND_GEN_M_REG(SRC_SRCIR, 0x204, 0x40), |
| 440 | 385 | RSND_GEN_M_REG(SRC_ADINR, 0x214, 0x40), | |
| 441 | gen->base[RSND_GEN1_SRU] = devm_ioremap_resource(dev, sru_res); | 386 | RSND_GEN_M_REG(SRC_IFSCR, 0x21c, 0x40), |
| 442 | gen->base[RSND_GEN1_ADG] = devm_ioremap_resource(dev, adg_res); | 387 | RSND_GEN_M_REG(SRC_IFSVR, 0x220, 0x40), |
| 443 | gen->base[RSND_GEN1_SSI] = devm_ioremap_resource(dev, ssi_res); | 388 | RSND_GEN_M_REG(SRC_SRCCR, 0x224, 0x40), |
| 444 | if (IS_ERR(gen->base[RSND_GEN1_SRU]) || | 389 | RSND_GEN_M_REG(SRC_MNFSR, 0x228, 0x40), |
| 445 | IS_ERR(gen->base[RSND_GEN1_ADG]) || | 390 | }; |
| 446 | IS_ERR(gen->base[RSND_GEN1_SSI])) | 391 | struct rsnd_regmap_field_conf conf_adg[] = { |
| 447 | return -ENODEV; | 392 | RSND_GEN_S_REG(BRRA, 0x00), |
| 393 | RSND_GEN_S_REG(BRRB, 0x04), | ||
| 394 | RSND_GEN_S_REG(SSICKR, 0x08), | ||
| 395 | RSND_GEN_S_REG(AUDIO_CLK_SEL0, 0x0c), | ||
| 396 | RSND_GEN_S_REG(AUDIO_CLK_SEL1, 0x10), | ||
| 397 | RSND_GEN_S_REG(AUDIO_CLK_SEL3, 0x18), | ||
| 398 | RSND_GEN_S_REG(AUDIO_CLK_SEL4, 0x1c), | ||
| 399 | RSND_GEN_S_REG(AUDIO_CLK_SEL5, 0x20), | ||
| 400 | }; | ||
| 401 | struct rsnd_regmap_field_conf conf_ssi[] = { | ||
| 402 | RSND_GEN_M_REG(SSICR, 0x00, 0x40), | ||
| 403 | RSND_GEN_M_REG(SSISR, 0x04, 0x40), | ||
| 404 | RSND_GEN_M_REG(SSITDR, 0x08, 0x40), | ||
| 405 | RSND_GEN_M_REG(SSIRDR, 0x0c, 0x40), | ||
| 406 | RSND_GEN_M_REG(SSIWSR, 0x20, 0x40), | ||
| 407 | }; | ||
| 408 | int ret_sru; | ||
| 409 | int ret_adg; | ||
| 410 | int ret_ssi; | ||
| 448 | 411 | ||
| 449 | ret = rsnd_gen1_regmap_init(priv, gen); | 412 | ret_sru = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SRU, conf_sru); |
| 450 | if (ret < 0) | 413 | ret_adg = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_ADG, conf_adg); |
| 451 | return ret; | 414 | ret_ssi = rsnd_gen_regmap_init(priv, 9, RSND_GEN1_SSI, conf_ssi); |
| 415 | if (ret_sru < 0 || | ||
| 416 | ret_adg < 0 || | ||
| 417 | ret_ssi < 0) | ||
| 418 | return ret_sru | ret_adg | ret_ssi; | ||
| 452 | 419 | ||
| 453 | dev_dbg(dev, "Gen1 device probed\n"); | 420 | dev_dbg(dev, "Gen1 is probed\n"); |
| 454 | dev_dbg(dev, "SRU : %pap => %p\n", &sru_res->start, | ||
| 455 | gen->base[RSND_GEN1_SRU]); | ||
| 456 | dev_dbg(dev, "ADG : %pap => %p\n", &adg_res->start, | ||
| 457 | gen->base[RSND_GEN1_ADG]); | ||
| 458 | dev_dbg(dev, "SSI : %pap => %p\n", &ssi_res->start, | ||
| 459 | gen->base[RSND_GEN1_SSI]); | ||
| 460 | 421 | ||
| 461 | return 0; | 422 | return 0; |
| 462 | |||
| 463 | } | 423 | } |
| 464 | 424 | ||
| 465 | /* | 425 | /* |
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 39d98af5ee05..d119adf97c9c 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
| @@ -90,6 +90,7 @@ enum rsnd_reg { | |||
| 90 | RSND_REG_SHARE19, | 90 | RSND_REG_SHARE19, |
| 91 | RSND_REG_SHARE20, | 91 | RSND_REG_SHARE20, |
| 92 | RSND_REG_SHARE21, | 92 | RSND_REG_SHARE21, |
| 93 | RSND_REG_SHARE22, | ||
| 93 | 94 | ||
| 94 | RSND_REG_MAX, | 95 | RSND_REG_MAX, |
| 95 | }; | 96 | }; |
| @@ -127,6 +128,7 @@ enum rsnd_reg { | |||
| 127 | #define RSND_REG_AUDIO_CLK_SEL2 RSND_REG_SHARE19 | 128 | #define RSND_REG_AUDIO_CLK_SEL2 RSND_REG_SHARE19 |
| 128 | #define RSND_REG_CMD_CTRL RSND_REG_SHARE20 | 129 | #define RSND_REG_CMD_CTRL RSND_REG_SHARE20 |
| 129 | #define RSND_REG_CMDOUT_TIMSEL RSND_REG_SHARE21 | 130 | #define RSND_REG_CMDOUT_TIMSEL RSND_REG_SHARE21 |
| 131 | #define RSND_REG_BUSIF_DALIGN RSND_REG_SHARE22 | ||
| 130 | 132 | ||
| 131 | struct rsnd_of_data; | 133 | struct rsnd_of_data; |
| 132 | struct rsnd_priv; | 134 | struct rsnd_priv; |
| @@ -156,12 +158,9 @@ u32 rsnd_get_adinr(struct rsnd_mod *mod); | |||
| 156 | */ | 158 | */ |
| 157 | struct rsnd_dma { | 159 | struct rsnd_dma { |
| 158 | struct sh_dmae_slave slave; | 160 | struct sh_dmae_slave slave; |
| 159 | struct work_struct work; | ||
| 160 | struct dma_chan *chan; | 161 | struct dma_chan *chan; |
| 161 | enum dma_data_direction dir; | 162 | enum dma_transfer_direction dir; |
| 162 | 163 | dma_addr_t addr; | |
| 163 | int submit_loop; | ||
| 164 | int offset; /* it cares A/B plane */ | ||
| 165 | }; | 164 | }; |
| 166 | 165 | ||
| 167 | void rsnd_dma_start(struct rsnd_dma *dma); | 166 | void rsnd_dma_start(struct rsnd_dma *dma); |
| @@ -185,6 +184,7 @@ enum rsnd_mod_type { | |||
| 185 | 184 | ||
| 186 | struct rsnd_mod_ops { | 185 | struct rsnd_mod_ops { |
| 187 | char *name; | 186 | char *name; |
| 187 | char* (*dma_name)(struct rsnd_mod *mod); | ||
| 188 | int (*probe)(struct rsnd_mod *mod, | 188 | int (*probe)(struct rsnd_mod *mod, |
| 189 | struct rsnd_dai *rdai); | 189 | struct rsnd_dai *rdai); |
| 190 | int (*remove)(struct rsnd_mod *mod, | 190 | int (*remove)(struct rsnd_mod *mod, |
| @@ -224,6 +224,7 @@ void rsnd_mod_init(struct rsnd_priv *priv, | |||
| 224 | enum rsnd_mod_type type, | 224 | enum rsnd_mod_type type, |
| 225 | int id); | 225 | int id); |
| 226 | char *rsnd_mod_name(struct rsnd_mod *mod); | 226 | char *rsnd_mod_name(struct rsnd_mod *mod); |
| 227 | char *rsnd_mod_dma_name(struct rsnd_mod *mod); | ||
| 227 | 228 | ||
| 228 | /* | 229 | /* |
| 229 | * R-Car sound DAI | 230 | * R-Car sound DAI |
| @@ -281,10 +282,9 @@ int rsnd_gen_probe(struct platform_device *pdev, | |||
| 281 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, | 282 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, |
| 282 | struct rsnd_mod *mod, | 283 | struct rsnd_mod *mod, |
| 283 | enum rsnd_reg reg); | 284 | enum rsnd_reg reg); |
| 284 | void rsnd_gen_dma_addr(struct rsnd_priv *priv, | 285 | dma_addr_t rsnd_gen_dma_addr(struct rsnd_priv *priv, |
| 285 | struct rsnd_dma *dma, | 286 | struct rsnd_mod *mod, |
| 286 | struct dma_slave_config *cfg, | 287 | int is_play, int is_from); |
| 287 | int is_play, int slave_id); | ||
| 288 | 288 | ||
| 289 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) | 289 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) |
| 290 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) | 290 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) |
| @@ -391,8 +391,12 @@ struct rsnd_mod *rsnd_src_mod_get(struct rsnd_priv *priv, int id); | |||
| 391 | unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, | 391 | unsigned int rsnd_src_get_ssi_rate(struct rsnd_priv *priv, |
| 392 | struct rsnd_dai_stream *io, | 392 | struct rsnd_dai_stream *io, |
| 393 | struct snd_pcm_runtime *runtime); | 393 | struct snd_pcm_runtime *runtime); |
| 394 | int rsnd_src_ssi_mode_init(struct rsnd_mod *ssi_mod, | 394 | int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, |
| 395 | struct rsnd_dai *rdai); | 395 | struct rsnd_dai *rdai, |
| 396 | int use_busif); | ||
| 397 | int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod, | ||
| 398 | struct rsnd_dai *rdai, | ||
| 399 | int use_busif); | ||
| 396 | int rsnd_src_enable_ssi_irq(struct rsnd_mod *ssi_mod, | 400 | int rsnd_src_enable_ssi_irq(struct rsnd_mod *ssi_mod, |
| 397 | struct rsnd_dai *rdai); | 401 | struct rsnd_dai *rdai); |
| 398 | 402 | ||
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 200eda019bc7..9183e0145503 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c | |||
| @@ -106,18 +106,19 @@ struct rsnd_src { | |||
| 106 | /* | 106 | /* |
| 107 | * Gen1/Gen2 common functions | 107 | * Gen1/Gen2 common functions |
| 108 | */ | 108 | */ |
| 109 | int rsnd_src_ssi_mode_init(struct rsnd_mod *ssi_mod, | 109 | int rsnd_src_ssiu_start(struct rsnd_mod *ssi_mod, |
| 110 | struct rsnd_dai *rdai) | 110 | struct rsnd_dai *rdai, |
| 111 | int use_busif) | ||
| 111 | { | 112 | { |
| 112 | struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod); | 113 | struct rsnd_dai_stream *io = rsnd_mod_to_io(ssi_mod); |
| 113 | struct rsnd_mod *src_mod = rsnd_io_to_mod_src(io); | 114 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); |
| 114 | int ssi_id = rsnd_mod_id(ssi_mod); | 115 | int ssi_id = rsnd_mod_id(ssi_mod); |
| 115 | 116 | ||
| 116 | /* | 117 | /* |
| 117 | * SSI_MODE0 | 118 | * SSI_MODE0 |
| 118 | */ | 119 | */ |
| 119 | rsnd_mod_bset(ssi_mod, SSI_MODE0, (1 << ssi_id), | 120 | rsnd_mod_bset(ssi_mod, SSI_MODE0, (1 << ssi_id), |
| 120 | src_mod ? 0 : (1 << ssi_id)); | 121 | !use_busif << ssi_id); |
| 121 | 122 | ||
| 122 | /* | 123 | /* |
| 123 | * SSI_MODE1 | 124 | * SSI_MODE1 |
| @@ -143,6 +144,46 @@ int rsnd_src_ssi_mode_init(struct rsnd_mod *ssi_mod, | |||
| 143 | 0x2 << shift : 0x1 << shift); | 144 | 0x2 << shift : 0x1 << shift); |
| 144 | } | 145 | } |
| 145 | 146 | ||
| 147 | /* | ||
| 148 | * DMA settings for SSIU | ||
| 149 | */ | ||
| 150 | if (use_busif) { | ||
| 151 | u32 val = 0x76543210; | ||
| 152 | u32 mask = ~0; | ||
| 153 | |||
| 154 | rsnd_mod_write(ssi_mod, SSI_BUSIF_ADINR, | ||
| 155 | rsnd_get_adinr(ssi_mod)); | ||
| 156 | rsnd_mod_write(ssi_mod, SSI_BUSIF_MODE, 1); | ||
| 157 | rsnd_mod_write(ssi_mod, SSI_CTRL, 0x1); | ||
| 158 | |||
| 159 | mask <<= runtime->channels * 4; | ||
| 160 | val = val & mask; | ||
| 161 | |||
| 162 | switch (runtime->sample_bits) { | ||
| 163 | case 16: | ||
| 164 | val |= 0x67452301 & ~mask; | ||
| 165 | break; | ||
| 166 | case 32: | ||
| 167 | val |= 0x76543210 & ~mask; | ||
| 168 | break; | ||
| 169 | } | ||
| 170 | rsnd_mod_write(ssi_mod, BUSIF_DALIGN, val); | ||
| 171 | |||
| 172 | } | ||
| 173 | |||
| 174 | return 0; | ||
| 175 | } | ||
| 176 | |||
| 177 | int rsnd_src_ssiu_stop(struct rsnd_mod *ssi_mod, | ||
| 178 | struct rsnd_dai *rdai, | ||
| 179 | int use_busif) | ||
| 180 | { | ||
| 181 | /* | ||
| 182 | * DMA settings for SSIU | ||
| 183 | */ | ||
| 184 | if (use_busif) | ||
| 185 | rsnd_mod_write(ssi_mod, SSI_CTRL, 0); | ||
| 186 | |||
| 146 | return 0; | 187 | return 0; |
| 147 | } | 188 | } |
| 148 | 189 | ||
| @@ -461,18 +502,45 @@ static struct rsnd_mod_ops rsnd_src_gen1_ops = { | |||
| 461 | static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod, | 502 | static int rsnd_src_set_convert_rate_gen2(struct rsnd_mod *mod, |
| 462 | struct rsnd_dai *rdai) | 503 | struct rsnd_dai *rdai) |
| 463 | { | 504 | { |
| 505 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | ||
| 506 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 507 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | ||
| 508 | struct snd_pcm_runtime *runtime = rsnd_io_to_runtime(io); | ||
| 509 | struct rsnd_src *src = rsnd_mod_to_src(mod); | ||
| 510 | uint ratio; | ||
| 464 | int ret; | 511 | int ret; |
| 465 | 512 | ||
| 513 | /* 6 - 1/6 are very enough ratio for SRC_BSDSR */ | ||
| 514 | if (!rsnd_src_convert_rate(src)) | ||
| 515 | ratio = 0; | ||
| 516 | else if (rsnd_src_convert_rate(src) > runtime->rate) | ||
| 517 | ratio = 100 * rsnd_src_convert_rate(src) / runtime->rate; | ||
| 518 | else | ||
| 519 | ratio = 100 * runtime->rate / rsnd_src_convert_rate(src); | ||
| 520 | |||
| 521 | if (ratio > 600) { | ||
| 522 | dev_err(dev, "FSO/FSI ratio error\n"); | ||
| 523 | return -EINVAL; | ||
| 524 | } | ||
| 525 | |||
| 466 | ret = rsnd_src_set_convert_rate(mod, rdai); | 526 | ret = rsnd_src_set_convert_rate(mod, rdai); |
| 467 | if (ret < 0) | 527 | if (ret < 0) |
| 468 | return ret; | 528 | return ret; |
| 469 | 529 | ||
| 470 | rsnd_mod_write(mod, SSI_BUSIF_ADINR, rsnd_get_adinr(mod)); | ||
| 471 | rsnd_mod_write(mod, SSI_BUSIF_MODE, 1); | ||
| 472 | |||
| 473 | rsnd_mod_write(mod, SRC_SRCCR, 0x00011110); | 530 | rsnd_mod_write(mod, SRC_SRCCR, 0x00011110); |
| 474 | 531 | ||
| 475 | rsnd_mod_write(mod, SRC_BSDSR, 0x01800000); | 532 | switch (rsnd_mod_id(mod)) { |
| 533 | case 5: | ||
| 534 | case 6: | ||
| 535 | case 7: | ||
| 536 | case 8: | ||
| 537 | rsnd_mod_write(mod, SRC_BSDSR, 0x02400000); | ||
| 538 | break; | ||
| 539 | default: | ||
| 540 | rsnd_mod_write(mod, SRC_BSDSR, 0x01800000); | ||
| 541 | break; | ||
| 542 | } | ||
| 543 | |||
| 476 | rsnd_mod_write(mod, SRC_BSISR, 0x00100060); | 544 | rsnd_mod_write(mod, SRC_BSISR, 0x00100060); |
| 477 | 545 | ||
| 478 | return 0; | 546 | return 0; |
| @@ -554,7 +622,6 @@ static int rsnd_src_start_gen2(struct rsnd_mod *mod, | |||
| 554 | 622 | ||
| 555 | rsnd_dma_start(rsnd_mod_to_dma(&src->mod)); | 623 | rsnd_dma_start(rsnd_mod_to_dma(&src->mod)); |
| 556 | 624 | ||
| 557 | rsnd_mod_write(mod, SSI_CTRL, 0x1); | ||
| 558 | rsnd_mod_write(mod, SRC_CTRL, val); | 625 | rsnd_mod_write(mod, SRC_CTRL, val); |
| 559 | 626 | ||
| 560 | return rsnd_src_start(mod, rdai); | 627 | return rsnd_src_start(mod, rdai); |
| @@ -565,7 +632,6 @@ static int rsnd_src_stop_gen2(struct rsnd_mod *mod, | |||
| 565 | { | 632 | { |
| 566 | struct rsnd_src *src = rsnd_mod_to_src(mod); | 633 | struct rsnd_src *src = rsnd_mod_to_src(mod); |
| 567 | 634 | ||
| 568 | rsnd_mod_write(mod, SSI_CTRL, 0); | ||
| 569 | rsnd_mod_write(mod, SRC_CTRL, 0); | 635 | rsnd_mod_write(mod, SRC_CTRL, 0); |
| 570 | 636 | ||
| 571 | rsnd_dma_stop(rsnd_mod_to_dma(&src->mod)); | 637 | rsnd_dma_stop(rsnd_mod_to_dma(&src->mod)); |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 2df723df5d19..34e84009162b 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
| @@ -90,6 +90,20 @@ struct rsnd_ssi { | |||
| 90 | #define rsnd_ssi_mode_flags(p) ((p)->info->flags) | 90 | #define rsnd_ssi_mode_flags(p) ((p)->info->flags) |
| 91 | #define rsnd_ssi_dai_id(ssi) ((ssi)->info->dai_id) | 91 | #define rsnd_ssi_dai_id(ssi) ((ssi)->info->dai_id) |
| 92 | 92 | ||
| 93 | static int rsnd_ssi_use_busif(struct rsnd_mod *mod) | ||
| 94 | { | ||
| 95 | struct rsnd_ssi *ssi = rsnd_mod_to_ssi(mod); | ||
| 96 | struct rsnd_dai_stream *io = rsnd_mod_to_io(mod); | ||
| 97 | int use_busif = 0; | ||
| 98 | |||
| 99 | if (!(rsnd_ssi_mode_flags(ssi) & RSND_SSI_NO_BUSIF)) | ||
| 100 | use_busif = 1; | ||
| 101 | if (rsnd_io_to_mod_src(io)) | ||
| 102 | use_busif = 1; | ||
| 103 | |||
| 104 | return use_busif; | ||
| 105 | } | ||
| 106 | |||
| 93 | static void rsnd_ssi_status_check(struct rsnd_mod *mod, | 107 | static void rsnd_ssi_status_check(struct rsnd_mod *mod, |
| 94 | u32 bit) | 108 | u32 bit) |
| 95 | { | 109 | { |
| @@ -289,8 +303,6 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, | |||
| 289 | ssi->cr_own = cr; | 303 | ssi->cr_own = cr; |
| 290 | ssi->err = -1; /* ignore 1st error */ | 304 | ssi->err = -1; /* ignore 1st error */ |
| 291 | 305 | ||
| 292 | rsnd_src_ssi_mode_init(mod, rdai); | ||
| 293 | |||
| 294 | return 0; | 306 | return 0; |
| 295 | } | 307 | } |
| 296 | 308 | ||
| @@ -389,6 +401,8 @@ static int rsnd_ssi_pio_start(struct rsnd_mod *mod, | |||
| 389 | /* enable PIO IRQ */ | 401 | /* enable PIO IRQ */ |
| 390 | ssi->cr_etc = UIEN | OIEN | DIEN; | 402 | ssi->cr_etc = UIEN | OIEN | DIEN; |
| 391 | 403 | ||
| 404 | rsnd_src_ssiu_start(mod, rdai, 0); | ||
| 405 | |||
| 392 | rsnd_src_enable_ssi_irq(mod, rdai); | 406 | rsnd_src_enable_ssi_irq(mod, rdai); |
| 393 | 407 | ||
| 394 | rsnd_ssi_hw_start(ssi, rdai, io); | 408 | rsnd_ssi_hw_start(ssi, rdai, io); |
| @@ -405,6 +419,8 @@ static int rsnd_ssi_pio_stop(struct rsnd_mod *mod, | |||
| 405 | 419 | ||
| 406 | rsnd_ssi_hw_stop(ssi, rdai); | 420 | rsnd_ssi_hw_stop(ssi, rdai); |
| 407 | 421 | ||
| 422 | rsnd_src_ssiu_stop(mod, rdai, 0); | ||
| 423 | |||
| 408 | return 0; | 424 | return 0; |
| 409 | } | 425 | } |
| 410 | 426 | ||
| @@ -457,6 +473,8 @@ static int rsnd_ssi_dma_start(struct rsnd_mod *mod, | |||
| 457 | /* enable DMA transfer */ | 473 | /* enable DMA transfer */ |
| 458 | ssi->cr_etc = DMEN; | 474 | ssi->cr_etc = DMEN; |
| 459 | 475 | ||
| 476 | rsnd_src_ssiu_start(mod, rdai, rsnd_ssi_use_busif(mod)); | ||
| 477 | |||
| 460 | rsnd_dma_start(dma); | 478 | rsnd_dma_start(dma); |
| 461 | 479 | ||
| 462 | rsnd_ssi_hw_start(ssi, ssi->rdai, io); | 480 | rsnd_ssi_hw_start(ssi, ssi->rdai, io); |
| @@ -482,11 +500,19 @@ static int rsnd_ssi_dma_stop(struct rsnd_mod *mod, | |||
| 482 | 500 | ||
| 483 | rsnd_dma_stop(dma); | 501 | rsnd_dma_stop(dma); |
| 484 | 502 | ||
| 503 | rsnd_src_ssiu_stop(mod, rdai, 1); | ||
| 504 | |||
| 485 | return 0; | 505 | return 0; |
| 486 | } | 506 | } |
| 487 | 507 | ||
| 508 | static char *rsnd_ssi_dma_name(struct rsnd_mod *mod) | ||
| 509 | { | ||
| 510 | return rsnd_ssi_use_busif(mod) ? "ssiu" : SSI_NAME; | ||
| 511 | } | ||
| 512 | |||
| 488 | static struct rsnd_mod_ops rsnd_ssi_dma_ops = { | 513 | static struct rsnd_mod_ops rsnd_ssi_dma_ops = { |
| 489 | .name = SSI_NAME, | 514 | .name = SSI_NAME, |
| 515 | .dma_name = rsnd_ssi_dma_name, | ||
| 490 | .probe = rsnd_ssi_dma_probe, | 516 | .probe = rsnd_ssi_dma_probe, |
| 491 | .remove = rsnd_ssi_dma_remove, | 517 | .remove = rsnd_ssi_dma_remove, |
| 492 | .init = rsnd_ssi_init, | 518 | .init = rsnd_ssi_init, |
| @@ -595,6 +621,9 @@ static void rsnd_of_parse_ssi(struct platform_device *pdev, | |||
| 595 | */ | 621 | */ |
| 596 | ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ? | 622 | ssi_info->dma_id = of_get_property(np, "pio-transfer", NULL) ? |
| 597 | 0 : 1; | 623 | 0 : 1; |
| 624 | |||
| 625 | if (of_get_property(np, "no-busif", NULL)) | ||
| 626 | ssi_info->flags |= RSND_SSI_NO_BUSIF; | ||
| 598 | } | 627 | } |
| 599 | 628 | ||
| 600 | rsnd_of_parse_ssi_end: | 629 | rsnd_of_parse_ssi_end: |
diff --git a/sound/soc/sirf/Kconfig b/sound/soc/sirf/Kconfig index 89e89429b04a..840058dcad09 100644 --- a/sound/soc/sirf/Kconfig +++ b/sound/soc/sirf/Kconfig | |||
| @@ -12,3 +12,9 @@ config SND_SOC_SIRF_AUDIO | |||
| 12 | config SND_SOC_SIRF_AUDIO_PORT | 12 | config SND_SOC_SIRF_AUDIO_PORT |
| 13 | select REGMAP_MMIO | 13 | select REGMAP_MMIO |
| 14 | tristate | 14 | tristate |
| 15 | |||
| 16 | config SND_SOC_SIRF_USP | ||
| 17 | tristate "SoC Audio (I2S protocol) for SiRF SoC USP interface" | ||
| 18 | depends on SND_SOC_SIRF | ||
| 19 | select REGMAP_MMIO | ||
| 20 | tristate | ||
diff --git a/sound/soc/sirf/Makefile b/sound/soc/sirf/Makefile index 913b93231d4e..dd917f20f12f 100644 --- a/sound/soc/sirf/Makefile +++ b/sound/soc/sirf/Makefile | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | snd-soc-sirf-audio-objs := sirf-audio.o | 1 | snd-soc-sirf-audio-objs := sirf-audio.o |
| 2 | snd-soc-sirf-audio-port-objs := sirf-audio-port.o | 2 | snd-soc-sirf-audio-port-objs := sirf-audio-port.o |
| 3 | snd-soc-sirf-usp-objs := sirf-usp.o | ||
| 3 | 4 | ||
| 4 | obj-$(CONFIG_SND_SOC_SIRF_AUDIO) += snd-soc-sirf-audio.o | 5 | obj-$(CONFIG_SND_SOC_SIRF_AUDIO) += snd-soc-sirf-audio.o |
| 5 | obj-$(CONFIG_SND_SOC_SIRF_AUDIO_PORT) += snd-soc-sirf-audio-port.o | 6 | obj-$(CONFIG_SND_SOC_SIRF_AUDIO_PORT) += snd-soc-sirf-audio-port.o |
| 7 | obj-$(CONFIG_SND_SOC_SIRF_USP) += snd-soc-sirf-usp.o | ||
diff --git a/sound/soc/sirf/sirf-usp.c b/sound/soc/sirf/sirf-usp.c new file mode 100644 index 000000000000..3a730374e259 --- /dev/null +++ b/sound/soc/sirf/sirf-usp.c | |||
| @@ -0,0 +1,415 @@ | |||
| 1 | /* | ||
| 2 | * SiRF USP in I2S/DSP mode | ||
| 3 | * | ||
| 4 | * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
| 5 | * | ||
| 6 | * Licensed under GPLv2 or later. | ||
| 7 | */ | ||
| 8 | #include <linux/module.h> | ||
| 9 | #include <linux/io.h> | ||
| 10 | #include <linux/of.h> | ||
| 11 | #include <linux/clk.h> | ||
| 12 | #include <linux/pm_runtime.h> | ||
| 13 | #include <sound/soc.h> | ||
| 14 | #include <sound/pcm_params.h> | ||
| 15 | #include <sound/dmaengine_pcm.h> | ||
| 16 | |||
| 17 | #include "sirf-usp.h" | ||
| 18 | |||
| 19 | struct sirf_usp { | ||
| 20 | struct regmap *regmap; | ||
| 21 | struct clk *clk; | ||
| 22 | u32 mode1_reg; | ||
| 23 | u32 mode2_reg; | ||
| 24 | int daifmt_format; | ||
| 25 | struct snd_dmaengine_dai_dma_data playback_dma_data; | ||
| 26 | struct snd_dmaengine_dai_dma_data capture_dma_data; | ||
| 27 | }; | ||
| 28 | |||
| 29 | static void sirf_usp_tx_enable(struct sirf_usp *usp) | ||
| 30 | { | ||
| 31 | regmap_update_bits(usp->regmap, USP_TX_FIFO_OP, | ||
| 32 | USP_TX_FIFO_RESET, USP_TX_FIFO_RESET); | ||
| 33 | regmap_write(usp->regmap, USP_TX_FIFO_OP, 0); | ||
| 34 | |||
| 35 | regmap_update_bits(usp->regmap, USP_TX_FIFO_OP, | ||
| 36 | USP_TX_FIFO_START, USP_TX_FIFO_START); | ||
| 37 | |||
| 38 | regmap_update_bits(usp->regmap, USP_TX_RX_ENABLE, | ||
| 39 | USP_TX_ENA, USP_TX_ENA); | ||
| 40 | } | ||
| 41 | |||
| 42 | static void sirf_usp_tx_disable(struct sirf_usp *usp) | ||
| 43 | { | ||
| 44 | regmap_update_bits(usp->regmap, USP_TX_RX_ENABLE, | ||
| 45 | USP_TX_ENA, ~USP_TX_ENA); | ||
| 46 | /* FIFO stop */ | ||
| 47 | regmap_write(usp->regmap, USP_TX_FIFO_OP, 0); | ||
| 48 | } | ||
| 49 | |||
| 50 | static void sirf_usp_rx_enable(struct sirf_usp *usp) | ||
| 51 | { | ||
| 52 | regmap_update_bits(usp->regmap, USP_RX_FIFO_OP, | ||
| 53 | USP_RX_FIFO_RESET, USP_RX_FIFO_RESET); | ||
| 54 | regmap_write(usp->regmap, USP_RX_FIFO_OP, 0); | ||
| 55 | |||
| 56 | regmap_update_bits(usp->regmap, USP_RX_FIFO_OP, | ||
| 57 | USP_RX_FIFO_START, USP_RX_FIFO_START); | ||
| 58 | |||
| 59 | regmap_update_bits(usp->regmap, USP_TX_RX_ENABLE, | ||
| 60 | USP_RX_ENA, USP_RX_ENA); | ||
| 61 | } | ||
| 62 | |||
| 63 | static void sirf_usp_rx_disable(struct sirf_usp *usp) | ||
| 64 | { | ||
| 65 | regmap_update_bits(usp->regmap, USP_TX_RX_ENABLE, | ||
| 66 | USP_RX_ENA, ~USP_RX_ENA); | ||
| 67 | /* FIFO stop */ | ||
| 68 | regmap_write(usp->regmap, USP_RX_FIFO_OP, 0); | ||
| 69 | } | ||
| 70 | |||
| 71 | static int sirf_usp_pcm_dai_probe(struct snd_soc_dai *dai) | ||
| 72 | { | ||
| 73 | struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); | ||
| 74 | snd_soc_dai_init_dma_data(dai, &usp->playback_dma_data, | ||
| 75 | &usp->capture_dma_data); | ||
| 76 | return 0; | ||
| 77 | } | ||
| 78 | |||
| 79 | static int sirf_usp_pcm_set_dai_fmt(struct snd_soc_dai *dai, | ||
| 80 | unsigned int fmt) | ||
| 81 | { | ||
| 82 | struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); | ||
| 83 | |||
| 84 | /* set master/slave audio interface */ | ||
| 85 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | ||
| 86 | case SND_SOC_DAIFMT_CBM_CFM: | ||
| 87 | break; | ||
| 88 | default: | ||
| 89 | dev_err(dai->dev, "Only CBM and CFM supported\n"); | ||
| 90 | return -EINVAL; | ||
| 91 | } | ||
| 92 | |||
| 93 | switch (fmt & SND_SOC_DAIFMT_FORMAT_MASK) { | ||
| 94 | case SND_SOC_DAIFMT_I2S: | ||
| 95 | case SND_SOC_DAIFMT_DSP_A: | ||
| 96 | usp->daifmt_format = (fmt & SND_SOC_DAIFMT_FORMAT_MASK); | ||
| 97 | break; | ||
| 98 | default: | ||
| 99 | dev_err(dai->dev, "Only I2S and DSP_A format supported\n"); | ||
| 100 | return -EINVAL; | ||
| 101 | } | ||
| 102 | |||
| 103 | return 0; | ||
| 104 | } | ||
| 105 | |||
| 106 | static void sirf_usp_i2s_init(struct sirf_usp *usp) | ||
| 107 | { | ||
| 108 | /* Configure RISC mode */ | ||
| 109 | regmap_update_bits(usp->regmap, USP_RISC_DSP_MODE, | ||
| 110 | USP_RISC_DSP_SEL, ~USP_RISC_DSP_SEL); | ||
| 111 | |||
| 112 | /* | ||
| 113 | * Configure DMA IO Length register | ||
| 114 | * Set no limit, USP can receive data continuously until it is diabled | ||
| 115 | */ | ||
| 116 | regmap_write(usp->regmap, USP_TX_DMA_IO_LEN, 0); | ||
| 117 | regmap_write(usp->regmap, USP_RX_DMA_IO_LEN, 0); | ||
| 118 | |||
| 119 | /* Configure Mode2 register */ | ||
| 120 | regmap_write(usp->regmap, USP_MODE2, (1 << USP_RXD_DELAY_LEN_OFFSET) | | ||
| 121 | (0 << USP_TXD_DELAY_LEN_OFFSET) | | ||
| 122 | USP_TFS_CLK_SLAVE_MODE | USP_RFS_CLK_SLAVE_MODE); | ||
| 123 | |||
| 124 | /* Configure Mode1 register */ | ||
| 125 | regmap_write(usp->regmap, USP_MODE1, | ||
| 126 | USP_SYNC_MODE | USP_EN | USP_TXD_ACT_EDGE_FALLING | | ||
| 127 | USP_RFS_ACT_LEVEL_LOGIC1 | USP_TFS_ACT_LEVEL_LOGIC1 | | ||
| 128 | USP_TX_UFLOW_REPEAT_ZERO | USP_CLOCK_MODE_SLAVE); | ||
| 129 | |||
| 130 | /* Configure RX DMA IO Control register */ | ||
| 131 | regmap_write(usp->regmap, USP_RX_DMA_IO_CTRL, 0); | ||
| 132 | |||
| 133 | /* Congiure RX FIFO Control register */ | ||
| 134 | regmap_write(usp->regmap, USP_RX_FIFO_CTRL, | ||
| 135 | (USP_RX_FIFO_THRESHOLD << USP_RX_FIFO_THD_OFFSET) | | ||
| 136 | (USP_TX_RX_FIFO_WIDTH_DWORD << USP_RX_FIFO_WIDTH_OFFSET)); | ||
| 137 | |||
| 138 | /* Congiure RX FIFO Level Check register */ | ||
| 139 | regmap_write(usp->regmap, USP_RX_FIFO_LEVEL_CHK, | ||
| 140 | RX_FIFO_SC(0x04) | RX_FIFO_LC(0x0E) | RX_FIFO_HC(0x1B)); | ||
| 141 | |||
| 142 | /* Configure TX DMA IO Control register*/ | ||
| 143 | regmap_write(usp->regmap, USP_TX_DMA_IO_CTRL, 0); | ||
| 144 | |||
| 145 | /* Configure TX FIFO Control register */ | ||
| 146 | regmap_write(usp->regmap, USP_TX_FIFO_CTRL, | ||
| 147 | (USP_TX_FIFO_THRESHOLD << USP_TX_FIFO_THD_OFFSET) | | ||
| 148 | (USP_TX_RX_FIFO_WIDTH_DWORD << USP_TX_FIFO_WIDTH_OFFSET)); | ||
| 149 | /* Congiure TX FIFO Level Check register */ | ||
| 150 | regmap_write(usp->regmap, USP_TX_FIFO_LEVEL_CHK, | ||
| 151 | TX_FIFO_SC(0x1B) | TX_FIFO_LC(0x0E) | TX_FIFO_HC(0x04)); | ||
| 152 | } | ||
| 153 | |||
| 154 | static int sirf_usp_pcm_hw_params(struct snd_pcm_substream *substream, | ||
| 155 | struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) | ||
| 156 | { | ||
| 157 | struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); | ||
| 158 | u32 data_len, frame_len, shifter_len; | ||
| 159 | |||
| 160 | switch (params_format(params)) { | ||
| 161 | case SNDRV_PCM_FORMAT_S16_LE: | ||
| 162 | data_len = 16; | ||
| 163 | frame_len = 16; | ||
| 164 | break; | ||
| 165 | case SNDRV_PCM_FORMAT_S24_LE: | ||
| 166 | data_len = 24; | ||
| 167 | frame_len = 32; | ||
| 168 | break; | ||
| 169 | case SNDRV_PCM_FORMAT_S24_3LE: | ||
| 170 | data_len = 24; | ||
| 171 | frame_len = 24; | ||
| 172 | break; | ||
| 173 | default: | ||
| 174 | dev_err(dai->dev, "Format unsupported\n"); | ||
| 175 | return -EINVAL; | ||
| 176 | } | ||
| 177 | |||
| 178 | shifter_len = data_len; | ||
| 179 | |||
| 180 | switch (usp->daifmt_format) { | ||
| 181 | case SND_SOC_DAIFMT_I2S: | ||
| 182 | regmap_update_bits(usp->regmap, USP_RX_FRAME_CTRL, | ||
| 183 | USP_I2S_SYNC_CHG, USP_I2S_SYNC_CHG); | ||
| 184 | break; | ||
| 185 | case SND_SOC_DAIFMT_DSP_A: | ||
| 186 | regmap_update_bits(usp->regmap, USP_RX_FRAME_CTRL, | ||
| 187 | USP_I2S_SYNC_CHG, 0); | ||
| 188 | frame_len = data_len * params_channels(params); | ||
| 189 | data_len = frame_len; | ||
| 190 | break; | ||
| 191 | default: | ||
| 192 | dev_err(dai->dev, "Only support I2S and DSP_A mode\n"); | ||
| 193 | return -EINVAL; | ||
| 194 | } | ||
| 195 | |||
| 196 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 197 | regmap_update_bits(usp->regmap, USP_TX_FRAME_CTRL, | ||
| 198 | USP_TXC_DATA_LEN_MASK | USP_TXC_FRAME_LEN_MASK | ||
| 199 | | USP_TXC_SHIFTER_LEN_MASK | USP_TXC_SLAVE_CLK_SAMPLE, | ||
| 200 | ((data_len - 1) << USP_TXC_DATA_LEN_OFFSET) | ||
| 201 | | ((frame_len - 1) << USP_TXC_FRAME_LEN_OFFSET) | ||
| 202 | | ((shifter_len - 1) << USP_TXC_SHIFTER_LEN_OFFSET) | ||
| 203 | | USP_TXC_SLAVE_CLK_SAMPLE); | ||
| 204 | else | ||
| 205 | regmap_update_bits(usp->regmap, USP_RX_FRAME_CTRL, | ||
| 206 | USP_RXC_DATA_LEN_MASK | USP_RXC_FRAME_LEN_MASK | ||
| 207 | | USP_RXC_SHIFTER_LEN_MASK | USP_SINGLE_SYNC_MODE, | ||
| 208 | ((data_len - 1) << USP_RXC_DATA_LEN_OFFSET) | ||
| 209 | | ((frame_len - 1) << USP_RXC_FRAME_LEN_OFFSET) | ||
| 210 | | ((shifter_len - 1) << USP_RXC_SHIFTER_LEN_OFFSET) | ||
| 211 | | USP_SINGLE_SYNC_MODE); | ||
| 212 | |||
| 213 | return 0; | ||
| 214 | } | ||
| 215 | |||
| 216 | static int sirf_usp_pcm_trigger(struct snd_pcm_substream *substream, int cmd, | ||
| 217 | struct snd_soc_dai *dai) | ||
| 218 | { | ||
| 219 | struct sirf_usp *usp = snd_soc_dai_get_drvdata(dai); | ||
| 220 | |||
| 221 | switch (cmd) { | ||
| 222 | case SNDRV_PCM_TRIGGER_START: | ||
| 223 | case SNDRV_PCM_TRIGGER_RESUME: | ||
| 224 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | ||
| 225 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 226 | sirf_usp_tx_enable(usp); | ||
| 227 | else | ||
| 228 | sirf_usp_rx_enable(usp); | ||
| 229 | break; | ||
| 230 | case SNDRV_PCM_TRIGGER_STOP: | ||
| 231 | case SNDRV_PCM_TRIGGER_SUSPEND: | ||
| 232 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | ||
| 233 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 234 | sirf_usp_tx_disable(usp); | ||
| 235 | else | ||
| 236 | sirf_usp_rx_disable(usp); | ||
| 237 | break; | ||
| 238 | } | ||
| 239 | |||
| 240 | return 0; | ||
| 241 | } | ||
| 242 | |||
| 243 | static const struct snd_soc_dai_ops sirf_usp_pcm_dai_ops = { | ||
| 244 | .trigger = sirf_usp_pcm_trigger, | ||
| 245 | .set_fmt = sirf_usp_pcm_set_dai_fmt, | ||
| 246 | .hw_params = sirf_usp_pcm_hw_params, | ||
| 247 | }; | ||
| 248 | |||
| 249 | static struct snd_soc_dai_driver sirf_usp_pcm_dai = { | ||
| 250 | .probe = sirf_usp_pcm_dai_probe, | ||
| 251 | .name = "sirf-usp-pcm", | ||
| 252 | .id = 0, | ||
| 253 | .playback = { | ||
| 254 | .stream_name = "SiRF USP PCM Playback", | ||
| 255 | .channels_min = 1, | ||
| 256 | .channels_max = 2, | ||
| 257 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
| 258 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | | ||
| 259 | SNDRV_PCM_FMTBIT_S24_3LE, | ||
| 260 | }, | ||
| 261 | .capture = { | ||
| 262 | .stream_name = "SiRF USP PCM Capture", | ||
| 263 | .channels_min = 1, | ||
| 264 | .channels_max = 2, | ||
| 265 | .rates = SNDRV_PCM_RATE_8000_192000, | ||
| 266 | .formats = SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S24_LE | | ||
| 267 | SNDRV_PCM_FMTBIT_S24_3LE, | ||
| 268 | }, | ||
| 269 | .ops = &sirf_usp_pcm_dai_ops, | ||
| 270 | }; | ||
| 271 | |||
| 272 | static int sirf_usp_pcm_runtime_suspend(struct device *dev) | ||
| 273 | { | ||
| 274 | struct sirf_usp *usp = dev_get_drvdata(dev); | ||
| 275 | clk_disable_unprepare(usp->clk); | ||
| 276 | return 0; | ||
| 277 | } | ||
| 278 | |||
| 279 | static int sirf_usp_pcm_runtime_resume(struct device *dev) | ||
| 280 | { | ||
| 281 | struct sirf_usp *usp = dev_get_drvdata(dev); | ||
| 282 | int ret; | ||
| 283 | ret = clk_prepare_enable(usp->clk); | ||
| 284 | if (ret) { | ||
| 285 | dev_err(dev, "clk_enable failed: %d\n", ret); | ||
| 286 | return ret; | ||
| 287 | } | ||
| 288 | sirf_usp_i2s_init(usp); | ||
| 289 | return 0; | ||
| 290 | } | ||
| 291 | |||
| 292 | #ifdef CONFIG_PM_SLEEP | ||
| 293 | static int sirf_usp_pcm_suspend(struct device *dev) | ||
| 294 | { | ||
| 295 | struct sirf_usp *usp = dev_get_drvdata(dev); | ||
| 296 | |||
| 297 | if (!pm_runtime_status_suspended(dev)) { | ||
| 298 | regmap_read(usp->regmap, USP_MODE1, &usp->mode1_reg); | ||
| 299 | regmap_read(usp->regmap, USP_MODE2, &usp->mode2_reg); | ||
| 300 | sirf_usp_pcm_runtime_suspend(dev); | ||
| 301 | } | ||
| 302 | return 0; | ||
| 303 | } | ||
| 304 | |||
| 305 | static int sirf_usp_pcm_resume(struct device *dev) | ||
| 306 | { | ||
| 307 | struct sirf_usp *usp = dev_get_drvdata(dev); | ||
| 308 | int ret; | ||
| 309 | |||
| 310 | if (!pm_runtime_status_suspended(dev)) { | ||
| 311 | ret = sirf_usp_pcm_runtime_resume(dev); | ||
| 312 | if (ret) | ||
| 313 | return ret; | ||
| 314 | regmap_write(usp->regmap, USP_MODE1, usp->mode1_reg); | ||
| 315 | regmap_write(usp->regmap, USP_MODE2, usp->mode2_reg); | ||
| 316 | } | ||
| 317 | return 0; | ||
| 318 | } | ||
| 319 | #endif | ||
| 320 | |||
| 321 | static const struct snd_soc_component_driver sirf_usp_component = { | ||
| 322 | .name = "sirf-usp", | ||
| 323 | }; | ||
| 324 | |||
| 325 | static const struct regmap_config sirf_usp_regmap_config = { | ||
| 326 | .reg_bits = 32, | ||
| 327 | .reg_stride = 4, | ||
| 328 | .val_bits = 32, | ||
| 329 | .max_register = USP_RX_FIFO_DATA, | ||
| 330 | .cache_type = REGCACHE_NONE, | ||
| 331 | }; | ||
| 332 | |||
| 333 | static int sirf_usp_pcm_probe(struct platform_device *pdev) | ||
| 334 | { | ||
| 335 | int ret; | ||
| 336 | struct sirf_usp *usp; | ||
| 337 | void __iomem *base; | ||
| 338 | struct resource *mem_res; | ||
| 339 | |||
| 340 | usp = devm_kzalloc(&pdev->dev, sizeof(struct sirf_usp), | ||
| 341 | GFP_KERNEL); | ||
| 342 | if (!usp) | ||
| 343 | return -ENOMEM; | ||
| 344 | |||
| 345 | platform_set_drvdata(pdev, usp); | ||
| 346 | |||
| 347 | mem_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 348 | base = devm_ioremap(&pdev->dev, mem_res->start, | ||
| 349 | resource_size(mem_res)); | ||
| 350 | if (base == NULL) | ||
| 351 | return -ENOMEM; | ||
| 352 | usp->regmap = devm_regmap_init_mmio(&pdev->dev, base, | ||
| 353 | &sirf_usp_regmap_config); | ||
| 354 | if (IS_ERR(usp->regmap)) | ||
| 355 | return PTR_ERR(usp->regmap); | ||
| 356 | |||
| 357 | usp->clk = devm_clk_get(&pdev->dev, NULL); | ||
| 358 | if (IS_ERR(usp->clk)) { | ||
| 359 | dev_err(&pdev->dev, "Get clock failed.\n"); | ||
| 360 | return PTR_ERR(usp->clk); | ||
| 361 | } | ||
| 362 | |||
| 363 | pm_runtime_enable(&pdev->dev); | ||
| 364 | if (!pm_runtime_enabled(&pdev->dev)) { | ||
| 365 | ret = sirf_usp_pcm_runtime_resume(&pdev->dev); | ||
| 366 | if (ret) | ||
| 367 | return ret; | ||
| 368 | } | ||
| 369 | |||
| 370 | ret = devm_snd_soc_register_component(&pdev->dev, &sirf_usp_component, | ||
| 371 | &sirf_usp_pcm_dai, 1); | ||
| 372 | if (ret) { | ||
| 373 | dev_err(&pdev->dev, "Register Audio SoC dai failed.\n"); | ||
| 374 | return ret; | ||
| 375 | } | ||
| 376 | return devm_snd_dmaengine_pcm_register(&pdev->dev, NULL, 0); | ||
| 377 | } | ||
| 378 | |||
| 379 | static int sirf_usp_pcm_remove(struct platform_device *pdev) | ||
| 380 | { | ||
| 381 | if (!pm_runtime_enabled(&pdev->dev)) | ||
| 382 | sirf_usp_pcm_runtime_suspend(&pdev->dev); | ||
| 383 | else | ||
| 384 | pm_runtime_disable(&pdev->dev); | ||
| 385 | return 0; | ||
| 386 | } | ||
| 387 | |||
| 388 | static const struct of_device_id sirf_usp_pcm_of_match[] = { | ||
| 389 | { .compatible = "sirf,prima2-usp-pcm", }, | ||
| 390 | {} | ||
| 391 | }; | ||
| 392 | MODULE_DEVICE_TABLE(of, sirf_usp_pcm_of_match); | ||
| 393 | |||
| 394 | static const struct dev_pm_ops sirf_usp_pcm_pm_ops = { | ||
| 395 | SET_RUNTIME_PM_OPS(sirf_usp_pcm_runtime_suspend, | ||
| 396 | sirf_usp_pcm_runtime_resume, NULL) | ||
| 397 | SET_SYSTEM_SLEEP_PM_OPS(sirf_usp_pcm_suspend, sirf_usp_pcm_resume) | ||
| 398 | }; | ||
| 399 | |||
| 400 | static struct platform_driver sirf_usp_pcm_driver = { | ||
| 401 | .driver = { | ||
| 402 | .name = "sirf-usp-pcm", | ||
| 403 | .owner = THIS_MODULE, | ||
| 404 | .of_match_table = sirf_usp_pcm_of_match, | ||
| 405 | .pm = &sirf_usp_pcm_pm_ops, | ||
| 406 | }, | ||
| 407 | .probe = sirf_usp_pcm_probe, | ||
| 408 | .remove = sirf_usp_pcm_remove, | ||
| 409 | }; | ||
| 410 | |||
| 411 | module_platform_driver(sirf_usp_pcm_driver); | ||
| 412 | |||
| 413 | MODULE_DESCRIPTION("SiRF SoC USP PCM bus driver"); | ||
| 414 | MODULE_AUTHOR("RongJun Ying <Rongjun.Ying@csr.com>"); | ||
| 415 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/sound/soc/sirf/sirf-usp.h b/sound/soc/sirf/sirf-usp.h new file mode 100644 index 000000000000..bf0201cb15bc --- /dev/null +++ b/sound/soc/sirf/sirf-usp.h | |||
| @@ -0,0 +1,293 @@ | |||
| 1 | /* | ||
| 2 | * arch/arm/mach-prima2/include/mach/sirfsoc_usp.h | ||
| 3 | * | ||
| 4 | * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. | ||
| 5 | * | ||
| 6 | * Licensed under GPLv2 or later. | ||
| 7 | */ | ||
| 8 | |||
| 9 | #ifndef _SIRF_USP_H | ||
| 10 | #define _SIRF_USP_H | ||
| 11 | |||
| 12 | /* USP Registers */ | ||
| 13 | #define USP_MODE1 0x00 | ||
| 14 | #define USP_MODE2 0x04 | ||
| 15 | #define USP_TX_FRAME_CTRL 0x08 | ||
| 16 | #define USP_RX_FRAME_CTRL 0x0C | ||
| 17 | #define USP_TX_RX_ENABLE 0x10 | ||
| 18 | #define USP_INT_ENABLE 0x14 | ||
| 19 | #define USP_INT_STATUS 0x18 | ||
| 20 | #define USP_PIN_IO_DATA 0x1C | ||
| 21 | #define USP_RISC_DSP_MODE 0x20 | ||
| 22 | #define USP_AYSNC_PARAM_REG 0x24 | ||
| 23 | #define USP_IRDA_X_MODE_DIV 0x28 | ||
| 24 | #define USP_SM_CFG 0x2C | ||
| 25 | #define USP_TX_DMA_IO_CTRL 0x100 | ||
| 26 | #define USP_TX_DMA_IO_LEN 0x104 | ||
| 27 | #define USP_TX_FIFO_CTRL 0x108 | ||
| 28 | #define USP_TX_FIFO_LEVEL_CHK 0x10C | ||
| 29 | #define USP_TX_FIFO_OP 0x110 | ||
| 30 | #define USP_TX_FIFO_STATUS 0x114 | ||
| 31 | #define USP_TX_FIFO_DATA 0x118 | ||
| 32 | #define USP_RX_DMA_IO_CTRL 0x120 | ||
| 33 | #define USP_RX_DMA_IO_LEN 0x124 | ||
| 34 | #define USP_RX_FIFO_CTRL 0x128 | ||
| 35 | #define USP_RX_FIFO_LEVEL_CHK 0x12C | ||
| 36 | #define USP_RX_FIFO_OP 0x130 | ||
| 37 | #define USP_RX_FIFO_STATUS 0x134 | ||
| 38 | #define USP_RX_FIFO_DATA 0x138 | ||
| 39 | |||
| 40 | /* USP MODE register-1 */ | ||
| 41 | #define USP_SYNC_MODE 0x00000001 | ||
| 42 | #define USP_CLOCK_MODE_SLAVE 0x00000002 | ||
| 43 | #define USP_LOOP_BACK_EN 0x00000004 | ||
| 44 | #define USP_HPSIR_EN 0x00000008 | ||
| 45 | #define USP_ENDIAN_CTRL_LSBF 0x00000010 | ||
| 46 | #define USP_EN 0x00000020 | ||
| 47 | #define USP_RXD_ACT_EDGE_FALLING 0x00000040 | ||
| 48 | #define USP_TXD_ACT_EDGE_FALLING 0x00000080 | ||
| 49 | #define USP_RFS_ACT_LEVEL_LOGIC1 0x00000100 | ||
| 50 | #define USP_TFS_ACT_LEVEL_LOGIC1 0x00000200 | ||
| 51 | #define USP_SCLK_IDLE_MODE_TOGGLE 0x00000400 | ||
| 52 | #define USP_SCLK_IDLE_LEVEL_LOGIC1 0x00000800 | ||
| 53 | #define USP_SCLK_PIN_MODE_IO 0x00001000 | ||
| 54 | #define USP_RFS_PIN_MODE_IO 0x00002000 | ||
| 55 | #define USP_TFS_PIN_MODE_IO 0x00004000 | ||
| 56 | #define USP_RXD_PIN_MODE_IO 0x00008000 | ||
| 57 | #define USP_TXD_PIN_MODE_IO 0x00010000 | ||
| 58 | #define USP_SCLK_IO_MODE_INPUT 0x00020000 | ||
| 59 | #define USP_RFS_IO_MODE_INPUT 0x00040000 | ||
| 60 | #define USP_TFS_IO_MODE_INPUT 0x00080000 | ||
| 61 | #define USP_RXD_IO_MODE_INPUT 0x00100000 | ||
| 62 | #define USP_TXD_IO_MODE_INPUT 0x00200000 | ||
| 63 | #define USP_IRDA_WIDTH_DIV_MASK 0x3FC00000 | ||
| 64 | #define USP_IRDA_WIDTH_DIV_OFFSET 0 | ||
| 65 | #define USP_IRDA_IDLE_LEVEL_HIGH 0x40000000 | ||
| 66 | #define USP_TX_UFLOW_REPEAT_ZERO 0x80000000 | ||
| 67 | #define USP_TX_ENDIAN_MODE 0x00000020 | ||
| 68 | #define USP_RX_ENDIAN_MODE 0x00000020 | ||
| 69 | |||
| 70 | /* USP Mode Register-2 */ | ||
| 71 | #define USP_RXD_DELAY_LEN_MASK 0x000000FF | ||
| 72 | #define USP_RXD_DELAY_LEN_OFFSET 0 | ||
| 73 | |||
| 74 | #define USP_TXD_DELAY_LEN_MASK 0x0000FF00 | ||
| 75 | #define USP_TXD_DELAY_LEN_OFFSET 8 | ||
| 76 | |||
| 77 | #define USP_ENA_CTRL_MODE 0x00010000 | ||
| 78 | #define USP_FRAME_CTRL_MODE 0x00020000 | ||
| 79 | #define USP_TFS_SOURCE_MODE 0x00040000 | ||
| 80 | #define USP_TFS_MS_MODE 0x00080000 | ||
| 81 | #define USP_CLK_DIVISOR_MASK 0x7FE00000 | ||
| 82 | #define USP_CLK_DIVISOR_OFFSET 21 | ||
| 83 | |||
| 84 | #define USP_TFS_CLK_SLAVE_MODE (1<<20) | ||
| 85 | #define USP_RFS_CLK_SLAVE_MODE (1<<19) | ||
| 86 | |||
| 87 | #define USP_IRDA_DATA_WIDTH 0x80000000 | ||
| 88 | |||
| 89 | /* USP Transmit Frame Control Register */ | ||
| 90 | |||
| 91 | #define USP_TXC_DATA_LEN_MASK 0x000000FF | ||
| 92 | #define USP_TXC_DATA_LEN_OFFSET 0 | ||
| 93 | |||
| 94 | #define USP_TXC_SYNC_LEN_MASK 0x0000FF00 | ||
| 95 | #define USP_TXC_SYNC_LEN_OFFSET 8 | ||
| 96 | |||
| 97 | #define USP_TXC_FRAME_LEN_MASK 0x00FF0000 | ||
| 98 | #define USP_TXC_FRAME_LEN_OFFSET 16 | ||
| 99 | |||
| 100 | #define USP_TXC_SHIFTER_LEN_MASK 0x1F000000 | ||
| 101 | #define USP_TXC_SHIFTER_LEN_OFFSET 24 | ||
| 102 | |||
| 103 | #define USP_TXC_SLAVE_CLK_SAMPLE 0x20000000 | ||
| 104 | |||
| 105 | #define USP_TXC_CLK_DIVISOR_MASK 0xC0000000 | ||
| 106 | #define USP_TXC_CLK_DIVISOR_OFFSET 30 | ||
| 107 | |||
| 108 | /* USP Receive Frame Control Register */ | ||
| 109 | |||
| 110 | #define USP_RXC_DATA_LEN_MASK 0x000000FF | ||
| 111 | #define USP_RXC_DATA_LEN_OFFSET 0 | ||
| 112 | |||
| 113 | #define USP_RXC_FRAME_LEN_MASK 0x0000FF00 | ||
| 114 | #define USP_RXC_FRAME_LEN_OFFSET 8 | ||
| 115 | |||
| 116 | #define USP_RXC_SHIFTER_LEN_MASK 0x001F0000 | ||
| 117 | #define USP_RXC_SHIFTER_LEN_OFFSET 16 | ||
| 118 | |||
| 119 | #define USP_START_EDGE_MODE 0x00800000 | ||
| 120 | #define USP_I2S_SYNC_CHG 0x00200000 | ||
| 121 | |||
| 122 | #define USP_RXC_CLK_DIVISOR_MASK 0x0F000000 | ||
| 123 | #define USP_RXC_CLK_DIVISOR_OFFSET 24 | ||
| 124 | #define USP_SINGLE_SYNC_MODE 0x00400000 | ||
| 125 | |||
| 126 | /* Tx - RX Enable Register */ | ||
| 127 | |||
| 128 | #define USP_RX_ENA 0x00000001 | ||
| 129 | #define USP_TX_ENA 0x00000002 | ||
| 130 | |||
| 131 | /* USP Interrupt Enable and status Register */ | ||
| 132 | #define USP_RX_DONE_INT 0x00000001 | ||
| 133 | #define USP_TX_DONE_INT 0x00000002 | ||
| 134 | #define USP_RX_OFLOW_INT 0x00000004 | ||
| 135 | #define USP_TX_UFLOW_INT 0x00000008 | ||
| 136 | #define USP_RX_IO_DMA_INT 0x00000010 | ||
| 137 | #define USP_TX_IO_DMA_INT 0x00000020 | ||
| 138 | #define USP_RXFIFO_FULL_INT 0x00000040 | ||
| 139 | #define USP_TXFIFO_EMPTY_INT 0x00000080 | ||
| 140 | #define USP_RXFIFO_THD_INT 0x00000100 | ||
| 141 | #define USP_TXFIFO_THD_INT 0x00000200 | ||
| 142 | #define USP_UART_FRM_ERR_INT 0x00000400 | ||
| 143 | #define USP_RX_TIMEOUT_INT 0x00000800 | ||
| 144 | #define USP_TX_ALLOUT_INT 0x00001000 | ||
| 145 | #define USP_RXD_BREAK_INT 0x00008000 | ||
| 146 | |||
| 147 | /* All possible TX interruots */ | ||
| 148 | #define USP_TX_INTERRUPT (USP_TX_DONE_INT|USP_TX_UFLOW_INT|\ | ||
| 149 | USP_TX_IO_DMA_INT|\ | ||
| 150 | USP_TXFIFO_EMPTY_INT|\ | ||
| 151 | USP_TXFIFO_THD_INT) | ||
| 152 | /* All possible RX interruots */ | ||
| 153 | #define USP_RX_INTERRUPT (USP_RX_DONE_INT|USP_RX_OFLOW_INT|\ | ||
| 154 | USP_RX_IO_DMA_INT|\ | ||
| 155 | USP_RXFIFO_FULL_INT|\ | ||
| 156 | USP_RXFIFO_THD_INT|\ | ||
| 157 | USP_RXFIFO_THD_INT|USP_RX_TIMEOUT_INT) | ||
| 158 | |||
| 159 | #define USP_INT_ALL 0x1FFF | ||
| 160 | |||
| 161 | /* USP Pin I/O Data Register */ | ||
| 162 | |||
| 163 | #define USP_RFS_PIN_VALUE_MASK 0x00000001 | ||
| 164 | #define USP_TFS_PIN_VALUE_MASK 0x00000002 | ||
| 165 | #define USP_RXD_PIN_VALUE_MASK 0x00000004 | ||
| 166 | #define USP_TXD_PIN_VALUE_MASK 0x00000008 | ||
| 167 | #define USP_SCLK_PIN_VALUE_MASK 0x00000010 | ||
| 168 | |||
| 169 | /* USP RISC/DSP Mode Register */ | ||
| 170 | #define USP_RISC_DSP_SEL 0x00000001 | ||
| 171 | |||
| 172 | /* USP ASYNC PARAMETER Register*/ | ||
| 173 | |||
| 174 | #define USP_ASYNC_TIMEOUT_MASK 0x0000FFFF | ||
| 175 | #define USP_ASYNC_TIMEOUT_OFFSET 0 | ||
| 176 | #define USP_ASYNC_TIMEOUT(x) (((x)&USP_ASYNC_TIMEOUT_MASK) \ | ||
| 177 | <<USP_ASYNC_TIMEOUT_OFFSET) | ||
| 178 | |||
| 179 | #define USP_ASYNC_DIV2_MASK 0x003F0000 | ||
| 180 | #define USP_ASYNC_DIV2_OFFSET 16 | ||
| 181 | |||
| 182 | /* USP TX DMA I/O MODE Register */ | ||
| 183 | #define USP_TX_MODE_IO 0x00000001 | ||
| 184 | |||
| 185 | /* USP TX DMA I/O Length Register */ | ||
| 186 | #define USP_TX_DATA_LEN_MASK 0xFFFFFFFF | ||
| 187 | #define USP_TX_DATA_LEN_OFFSET 0 | ||
| 188 | |||
| 189 | /* USP TX FIFO Control Register */ | ||
| 190 | #define USP_TX_FIFO_WIDTH_MASK 0x00000003 | ||
| 191 | #define USP_TX_FIFO_WIDTH_OFFSET 0 | ||
| 192 | |||
| 193 | #define USP_TX_FIFO_THD_MASK 0x000001FC | ||
| 194 | #define USP_TX_FIFO_THD_OFFSET 2 | ||
| 195 | |||
| 196 | /* USP TX FIFO Level Check Register */ | ||
| 197 | #define USP_TX_FIFO_LEVEL_CHECK_MASK 0x1F | ||
| 198 | #define USP_TX_FIFO_SC_OFFSET 0 | ||
| 199 | #define USP_TX_FIFO_LC_OFFSET 10 | ||
| 200 | #define USP_TX_FIFO_HC_OFFSET 20 | ||
| 201 | |||
| 202 | #define TX_FIFO_SC(x) (((x) & USP_TX_FIFO_LEVEL_CHECK_MASK) \ | ||
| 203 | << USP_TX_FIFO_SC_OFFSET) | ||
| 204 | #define TX_FIFO_LC(x) (((x) & USP_TX_FIFO_LEVEL_CHECK_MASK) \ | ||
| 205 | << USP_TX_FIFO_LC_OFFSET) | ||
| 206 | #define TX_FIFO_HC(x) (((x) & USP_TX_FIFO_LEVEL_CHECK_MASK) \ | ||
| 207 | << USP_TX_FIFO_HC_OFFSET) | ||
| 208 | |||
| 209 | /* USP TX FIFO Operation Register */ | ||
| 210 | #define USP_TX_FIFO_RESET 0x00000001 | ||
| 211 | #define USP_TX_FIFO_START 0x00000002 | ||
| 212 | |||
| 213 | /* USP TX FIFO Status Register */ | ||
| 214 | #define USP_TX_FIFO_LEVEL_MASK 0x0000007F | ||
| 215 | #define USP_TX_FIFO_LEVEL_OFFSET 0 | ||
| 216 | |||
| 217 | #define USP_TX_FIFO_FULL 0x00000080 | ||
| 218 | #define USP_TX_FIFO_EMPTY 0x00000100 | ||
| 219 | |||
| 220 | /* USP TX FIFO Data Register */ | ||
| 221 | #define USP_TX_FIFO_DATA_MASK 0xFFFFFFFF | ||
| 222 | #define USP_TX_FIFO_DATA_OFFSET 0 | ||
| 223 | |||
| 224 | /* USP RX DMA I/O MODE Register */ | ||
| 225 | #define USP_RX_MODE_IO 0x00000001 | ||
| 226 | #define USP_RX_DMA_FLUSH 0x00000004 | ||
| 227 | |||
| 228 | /* USP RX DMA I/O Length Register */ | ||
| 229 | #define USP_RX_DATA_LEN_MASK 0xFFFFFFFF | ||
| 230 | #define USP_RX_DATA_LEN_OFFSET 0 | ||
| 231 | |||
| 232 | /* USP RX FIFO Control Register */ | ||
| 233 | #define USP_RX_FIFO_WIDTH_MASK 0x00000003 | ||
| 234 | #define USP_RX_FIFO_WIDTH_OFFSET 0 | ||
| 235 | |||
| 236 | #define USP_RX_FIFO_THD_MASK 0x000001FC | ||
| 237 | #define USP_RX_FIFO_THD_OFFSET 2 | ||
| 238 | |||
| 239 | /* USP RX FIFO Level Check Register */ | ||
| 240 | |||
| 241 | #define USP_RX_FIFO_LEVEL_CHECK_MASK 0x1F | ||
| 242 | #define USP_RX_FIFO_SC_OFFSET 0 | ||
| 243 | #define USP_RX_FIFO_LC_OFFSET 10 | ||
| 244 | #define USP_RX_FIFO_HC_OFFSET 20 | ||
| 245 | |||
| 246 | #define RX_FIFO_SC(x) (((x) & USP_RX_FIFO_LEVEL_CHECK_MASK) \ | ||
| 247 | << USP_RX_FIFO_SC_OFFSET) | ||
| 248 | #define RX_FIFO_LC(x) (((x) & USP_RX_FIFO_LEVEL_CHECK_MASK) \ | ||
| 249 | << USP_RX_FIFO_LC_OFFSET) | ||
| 250 | #define RX_FIFO_HC(x) (((x) & USP_RX_FIFO_LEVEL_CHECK_MASK) \ | ||
| 251 | << USP_RX_FIFO_HC_OFFSET) | ||
| 252 | |||
| 253 | /* USP RX FIFO Operation Register */ | ||
| 254 | #define USP_RX_FIFO_RESET 0x00000001 | ||
| 255 | #define USP_RX_FIFO_START 0x00000002 | ||
| 256 | |||
| 257 | /* USP RX FIFO Status Register */ | ||
| 258 | |||
| 259 | #define USP_RX_FIFO_LEVEL_MASK 0x0000007F | ||
| 260 | #define USP_RX_FIFO_LEVEL_OFFSET 0 | ||
| 261 | |||
| 262 | #define USP_RX_FIFO_FULL 0x00000080 | ||
| 263 | #define USP_RX_FIFO_EMPTY 0x00000100 | ||
| 264 | |||
| 265 | /* USP RX FIFO Data Register */ | ||
| 266 | |||
| 267 | #define USP_RX_FIFO_DATA_MASK 0xFFFFFFFF | ||
| 268 | #define USP_RX_FIFO_DATA_OFFSET 0 | ||
| 269 | |||
| 270 | /* | ||
| 271 | * When rx thd irq occur, sender just disable tx empty irq, | ||
| 272 | * Remaining data in tx fifo wil also be sent out. | ||
| 273 | */ | ||
| 274 | #define USP_FIFO_SIZE 128 | ||
| 275 | #define USP_TX_FIFO_THRESHOLD (USP_FIFO_SIZE/2) | ||
| 276 | #define USP_RX_FIFO_THRESHOLD (USP_FIFO_SIZE/2) | ||
| 277 | |||
| 278 | /* FIFO_WIDTH for the USP_TX_FIFO_CTRL and USP_RX_FIFO_CTRL registers */ | ||
| 279 | #define USP_FIFO_WIDTH_BYTE 0x00 | ||
| 280 | #define USP_FIFO_WIDTH_WORD 0x01 | ||
| 281 | #define USP_FIFO_WIDTH_DWORD 0x02 | ||
| 282 | |||
| 283 | #define USP_ASYNC_DIV2 16 | ||
| 284 | |||
| 285 | #define USP_PLUGOUT_RETRY_CNT 2 | ||
| 286 | |||
| 287 | #define USP_TX_RX_FIFO_WIDTH_DWORD 2 | ||
| 288 | |||
| 289 | #define SIRF_USP_DIV_MCLK 0 | ||
| 290 | |||
| 291 | #define SIRF_USP_I2S_TFS_SYNC 0 | ||
| 292 | #define SIRF_USP_I2S_RFS_SYNC 1 | ||
| 293 | #endif | ||
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index 00e70b6c7da2..a9f82b5aba9d 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c | |||
| @@ -78,7 +78,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec) | |||
| 78 | mutex_init(&codec->cache_rw_mutex); | 78 | mutex_init(&codec->cache_rw_mutex); |
| 79 | 79 | ||
| 80 | dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", | 80 | dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", |
| 81 | codec->name); | 81 | codec->component.name); |
| 82 | 82 | ||
| 83 | if (codec_drv->reg_cache_default) | 83 | if (codec_drv->reg_cache_default) |
| 84 | codec->reg_cache = kmemdup(codec_drv->reg_cache_default, | 84 | codec->reg_cache = kmemdup(codec_drv->reg_cache_default, |
| @@ -98,8 +98,7 @@ int snd_soc_cache_init(struct snd_soc_codec *codec) | |||
| 98 | int snd_soc_cache_exit(struct snd_soc_codec *codec) | 98 | int snd_soc_cache_exit(struct snd_soc_codec *codec) |
| 99 | { | 99 | { |
| 100 | dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n", | 100 | dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n", |
| 101 | codec->name); | 101 | codec->component.name); |
| 102 | |||
| 103 | kfree(codec->reg_cache); | 102 | kfree(codec->reg_cache); |
| 104 | codec->reg_cache = NULL; | 103 | codec->reg_cache = NULL; |
| 105 | return 0; | 104 | return 0; |
| @@ -192,7 +191,7 @@ int snd_soc_cache_sync(struct snd_soc_codec *codec) | |||
| 192 | return 0; | 191 | return 0; |
| 193 | 192 | ||
| 194 | dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n", | 193 | dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n", |
| 195 | codec->name); | 194 | codec->component.name); |
| 196 | trace_snd_soc_cache_sync(codec, name, "start"); | 195 | trace_snd_soc_cache_sync(codec, name, "start"); |
| 197 | ret = snd_soc_flat_cache_sync(codec); | 196 | ret = snd_soc_flat_cache_sync(codec); |
| 198 | if (!ret) | 197 | if (!ret) |
diff --git a/sound/soc/soc-compress.c b/sound/soc/soc-compress.c index 10f7f1da2aca..27c06acce205 100644 --- a/sound/soc/soc-compress.c +++ b/sound/soc/soc-compress.c | |||
| @@ -37,7 +37,8 @@ static int soc_compr_open(struct snd_compr_stream *cstream) | |||
| 37 | if (platform->driver->compr_ops && platform->driver->compr_ops->open) { | 37 | if (platform->driver->compr_ops && platform->driver->compr_ops->open) { |
| 38 | ret = platform->driver->compr_ops->open(cstream); | 38 | ret = platform->driver->compr_ops->open(cstream); |
| 39 | if (ret < 0) { | 39 | if (ret < 0) { |
| 40 | pr_err("compress asoc: can't open platform %s\n", platform->name); | 40 | pr_err("compress asoc: can't open platform %s\n", |
| 41 | platform->component.name); | ||
| 41 | goto out; | 42 | goto out; |
| 42 | } | 43 | } |
| 43 | } | 44 | } |
| @@ -84,7 +85,8 @@ static int soc_compr_open_fe(struct snd_compr_stream *cstream) | |||
| 84 | if (platform->driver->compr_ops && platform->driver->compr_ops->open) { | 85 | if (platform->driver->compr_ops && platform->driver->compr_ops->open) { |
| 85 | ret = platform->driver->compr_ops->open(cstream); | 86 | ret = platform->driver->compr_ops->open(cstream); |
| 86 | if (ret < 0) { | 87 | if (ret < 0) { |
| 87 | pr_err("compress asoc: can't open platform %s\n", platform->name); | 88 | pr_err("compress asoc: can't open platform %s\n", |
| 89 | platform->component.name); | ||
| 88 | goto out; | 90 | goto out; |
| 89 | } | 91 | } |
| 90 | } | 92 | } |
| @@ -627,6 +629,11 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | |||
| 627 | char new_name[64]; | 629 | char new_name[64]; |
| 628 | int ret = 0, direction = 0; | 630 | int ret = 0, direction = 0; |
| 629 | 631 | ||
| 632 | if (rtd->num_codecs > 1) { | ||
| 633 | dev_err(rtd->card->dev, "Multicodec not supported for compressed stream\n"); | ||
| 634 | return -EINVAL; | ||
| 635 | } | ||
| 636 | |||
| 630 | /* check client and interface hw capabilities */ | 637 | /* check client and interface hw capabilities */ |
| 631 | snprintf(new_name, sizeof(new_name), "%s %s-%d", | 638 | snprintf(new_name, sizeof(new_name), "%s %s-%d", |
| 632 | rtd->dai_link->stream_name, codec_dai->name, num); | 639 | rtd->dai_link->stream_name, codec_dai->name, num); |
| @@ -680,7 +687,7 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num) | |||
| 680 | ret = snd_compress_new(rtd->card->snd_card, num, direction, compr); | 687 | ret = snd_compress_new(rtd->card->snd_card, num, direction, compr); |
| 681 | if (ret < 0) { | 688 | if (ret < 0) { |
| 682 | pr_err("compress asoc: can't create compress for codec %s\n", | 689 | pr_err("compress asoc: can't create compress for codec %s\n", |
| 683 | codec->name); | 690 | codec->component.name); |
| 684 | goto compr_err; | 691 | goto compr_err; |
| 685 | } | 692 | } |
| 686 | 693 | ||
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index b87d7d882e6d..d4bfd4a9076f 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
| @@ -270,12 +270,33 @@ static const struct file_operations codec_reg_fops = { | |||
| 270 | .llseek = default_llseek, | 270 | .llseek = default_llseek, |
| 271 | }; | 271 | }; |
| 272 | 272 | ||
| 273 | static struct dentry *soc_debugfs_create_dir(struct dentry *parent, | ||
| 274 | const char *fmt, ...) | ||
| 275 | { | ||
| 276 | struct dentry *de; | ||
| 277 | va_list ap; | ||
| 278 | char *s; | ||
| 279 | |||
| 280 | va_start(ap, fmt); | ||
| 281 | s = kvasprintf(GFP_KERNEL, fmt, ap); | ||
| 282 | va_end(ap); | ||
| 283 | |||
| 284 | if (!s) | ||
| 285 | return NULL; | ||
| 286 | |||
| 287 | de = debugfs_create_dir(s, parent); | ||
| 288 | kfree(s); | ||
| 289 | |||
| 290 | return de; | ||
| 291 | } | ||
| 292 | |||
| 273 | static void soc_init_codec_debugfs(struct snd_soc_codec *codec) | 293 | static void soc_init_codec_debugfs(struct snd_soc_codec *codec) |
| 274 | { | 294 | { |
| 275 | struct dentry *debugfs_card_root = codec->card->debugfs_card_root; | 295 | struct dentry *debugfs_card_root = codec->component.card->debugfs_card_root; |
| 276 | 296 | ||
| 277 | codec->debugfs_codec_root = debugfs_create_dir(codec->name, | 297 | codec->debugfs_codec_root = soc_debugfs_create_dir(debugfs_card_root, |
| 278 | debugfs_card_root); | 298 | "codec:%s", |
| 299 | codec->component.name); | ||
| 279 | if (!codec->debugfs_codec_root) { | 300 | if (!codec->debugfs_codec_root) { |
| 280 | dev_warn(codec->dev, | 301 | dev_warn(codec->dev, |
| 281 | "ASoC: Failed to create codec debugfs directory\n"); | 302 | "ASoC: Failed to create codec debugfs directory\n"); |
| @@ -304,17 +325,18 @@ static void soc_cleanup_codec_debugfs(struct snd_soc_codec *codec) | |||
| 304 | 325 | ||
| 305 | static void soc_init_platform_debugfs(struct snd_soc_platform *platform) | 326 | static void soc_init_platform_debugfs(struct snd_soc_platform *platform) |
| 306 | { | 327 | { |
| 307 | struct dentry *debugfs_card_root = platform->card->debugfs_card_root; | 328 | struct dentry *debugfs_card_root = platform->component.card->debugfs_card_root; |
| 308 | 329 | ||
| 309 | platform->debugfs_platform_root = debugfs_create_dir(platform->name, | 330 | platform->debugfs_platform_root = soc_debugfs_create_dir(debugfs_card_root, |
| 310 | debugfs_card_root); | 331 | "platform:%s", |
| 332 | platform->component.name); | ||
| 311 | if (!platform->debugfs_platform_root) { | 333 | if (!platform->debugfs_platform_root) { |
| 312 | dev_warn(platform->dev, | 334 | dev_warn(platform->dev, |
| 313 | "ASoC: Failed to create platform debugfs directory\n"); | 335 | "ASoC: Failed to create platform debugfs directory\n"); |
| 314 | return; | 336 | return; |
| 315 | } | 337 | } |
| 316 | 338 | ||
| 317 | snd_soc_dapm_debugfs_init(&platform->dapm, | 339 | snd_soc_dapm_debugfs_init(&platform->component.dapm, |
| 318 | platform->debugfs_platform_root); | 340 | platform->debugfs_platform_root); |
| 319 | } | 341 | } |
| 320 | 342 | ||
| @@ -335,7 +357,7 @@ static ssize_t codec_list_read_file(struct file *file, char __user *user_buf, | |||
| 335 | 357 | ||
| 336 | list_for_each_entry(codec, &codec_list, list) { | 358 | list_for_each_entry(codec, &codec_list, list) { |
| 337 | len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", | 359 | len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", |
| 338 | codec->name); | 360 | codec->component.name); |
| 339 | if (len >= 0) | 361 | if (len >= 0) |
| 340 | ret += len; | 362 | ret += len; |
| 341 | if (ret > PAGE_SIZE) { | 363 | if (ret > PAGE_SIZE) { |
| @@ -406,7 +428,7 @@ static ssize_t platform_list_read_file(struct file *file, | |||
| 406 | 428 | ||
| 407 | list_for_each_entry(platform, &platform_list, list) { | 429 | list_for_each_entry(platform, &platform_list, list) { |
| 408 | len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", | 430 | len = snprintf(buf + ret, PAGE_SIZE - ret, "%s\n", |
| 409 | platform->name); | 431 | platform->component.name); |
| 410 | if (len >= 0) | 432 | if (len >= 0) |
| 411 | ret += len; | 433 | ret += len; |
| 412 | if (ret > PAGE_SIZE) { | 434 | if (ret > PAGE_SIZE) { |
| @@ -524,11 +546,12 @@ static int soc_ac97_dev_register(struct snd_soc_codec *codec) | |||
| 524 | int err; | 546 | int err; |
| 525 | 547 | ||
| 526 | codec->ac97->dev.bus = &ac97_bus_type; | 548 | codec->ac97->dev.bus = &ac97_bus_type; |
| 527 | codec->ac97->dev.parent = codec->card->dev; | 549 | codec->ac97->dev.parent = codec->component.card->dev; |
| 528 | codec->ac97->dev.release = soc_ac97_device_release; | 550 | codec->ac97->dev.release = soc_ac97_device_release; |
| 529 | 551 | ||
| 530 | dev_set_name(&codec->ac97->dev, "%d-%d:%s", | 552 | dev_set_name(&codec->ac97->dev, "%d-%d:%s", |
| 531 | codec->card->snd_card->number, 0, codec->name); | 553 | codec->component.card->snd_card->number, 0, |
| 554 | codec->component.name); | ||
| 532 | err = device_register(&codec->ac97->dev); | 555 | err = device_register(&codec->ac97->dev); |
| 533 | if (err < 0) { | 556 | if (err < 0) { |
| 534 | dev_err(codec->dev, "ASoC: Can't register ac97 bus\n"); | 557 | dev_err(codec->dev, "ASoC: Can't register ac97 bus\n"); |
| @@ -554,7 +577,7 @@ int snd_soc_suspend(struct device *dev) | |||
| 554 | { | 577 | { |
| 555 | struct snd_soc_card *card = dev_get_drvdata(dev); | 578 | struct snd_soc_card *card = dev_get_drvdata(dev); |
| 556 | struct snd_soc_codec *codec; | 579 | struct snd_soc_codec *codec; |
| 557 | int i; | 580 | int i, j; |
| 558 | 581 | ||
| 559 | /* If the initialization of this soc device failed, there is no codec | 582 | /* If the initialization of this soc device failed, there is no codec |
| 560 | * associated with it. Just bail out in this case. | 583 | * associated with it. Just bail out in this case. |
| @@ -574,14 +597,17 @@ int snd_soc_suspend(struct device *dev) | |||
| 574 | 597 | ||
| 575 | /* mute any active DACs */ | 598 | /* mute any active DACs */ |
| 576 | for (i = 0; i < card->num_rtd; i++) { | 599 | for (i = 0; i < card->num_rtd; i++) { |
| 577 | struct snd_soc_dai *dai = card->rtd[i].codec_dai; | ||
| 578 | struct snd_soc_dai_driver *drv = dai->driver; | ||
| 579 | 600 | ||
| 580 | if (card->rtd[i].dai_link->ignore_suspend) | 601 | if (card->rtd[i].dai_link->ignore_suspend) |
| 581 | continue; | 602 | continue; |
| 582 | 603 | ||
| 583 | if (drv->ops->digital_mute && dai->playback_active) | 604 | for (j = 0; j < card->rtd[i].num_codecs; j++) { |
| 584 | drv->ops->digital_mute(dai, 1); | 605 | struct snd_soc_dai *dai = card->rtd[i].codec_dais[j]; |
| 606 | struct snd_soc_dai_driver *drv = dai->driver; | ||
| 607 | |||
| 608 | if (drv->ops->digital_mute && dai->playback_active) | ||
| 609 | drv->ops->digital_mute(dai, 1); | ||
| 610 | } | ||
| 585 | } | 611 | } |
| 586 | 612 | ||
| 587 | /* suspend all pcms */ | 613 | /* suspend all pcms */ |
| @@ -612,8 +638,12 @@ int snd_soc_suspend(struct device *dev) | |||
| 612 | 638 | ||
| 613 | /* close any waiting streams and save state */ | 639 | /* close any waiting streams and save state */ |
| 614 | for (i = 0; i < card->num_rtd; i++) { | 640 | for (i = 0; i < card->num_rtd; i++) { |
| 641 | struct snd_soc_dai **codec_dais = card->rtd[i].codec_dais; | ||
| 615 | flush_delayed_work(&card->rtd[i].delayed_work); | 642 | flush_delayed_work(&card->rtd[i].delayed_work); |
| 616 | card->rtd[i].codec->dapm.suspend_bias_level = card->rtd[i].codec->dapm.bias_level; | 643 | for (j = 0; j < card->rtd[i].num_codecs; j++) { |
| 644 | codec_dais[j]->codec->dapm.suspend_bias_level = | ||
| 645 | codec_dais[j]->codec->dapm.bias_level; | ||
| 646 | } | ||
| 617 | } | 647 | } |
| 618 | 648 | ||
| 619 | for (i = 0; i < card->num_rtd; i++) { | 649 | for (i = 0; i < card->num_rtd; i++) { |
| @@ -697,7 +727,7 @@ static void soc_resume_deferred(struct work_struct *work) | |||
| 697 | struct snd_soc_card *card = | 727 | struct snd_soc_card *card = |
| 698 | container_of(work, struct snd_soc_card, deferred_resume_work); | 728 | container_of(work, struct snd_soc_card, deferred_resume_work); |
| 699 | struct snd_soc_codec *codec; | 729 | struct snd_soc_codec *codec; |
| 700 | int i; | 730 | int i, j; |
| 701 | 731 | ||
| 702 | /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time, | 732 | /* our power state is still SNDRV_CTL_POWER_D3hot from suspend time, |
| 703 | * so userspace apps are blocked from touching us | 733 | * so userspace apps are blocked from touching us |
| @@ -758,14 +788,17 @@ static void soc_resume_deferred(struct work_struct *work) | |||
| 758 | 788 | ||
| 759 | /* unmute any active DACs */ | 789 | /* unmute any active DACs */ |
| 760 | for (i = 0; i < card->num_rtd; i++) { | 790 | for (i = 0; i < card->num_rtd; i++) { |
| 761 | struct snd_soc_dai *dai = card->rtd[i].codec_dai; | ||
| 762 | struct snd_soc_dai_driver *drv = dai->driver; | ||
| 763 | 791 | ||
| 764 | if (card->rtd[i].dai_link->ignore_suspend) | 792 | if (card->rtd[i].dai_link->ignore_suspend) |
| 765 | continue; | 793 | continue; |
| 766 | 794 | ||
| 767 | if (drv->ops->digital_mute && dai->playback_active) | 795 | for (j = 0; j < card->rtd[i].num_codecs; j++) { |
| 768 | drv->ops->digital_mute(dai, 0); | 796 | struct snd_soc_dai *dai = card->rtd[i].codec_dais[j]; |
| 797 | struct snd_soc_dai_driver *drv = dai->driver; | ||
| 798 | |||
| 799 | if (drv->ops->digital_mute && dai->playback_active) | ||
| 800 | drv->ops->digital_mute(dai, 0); | ||
| 801 | } | ||
| 769 | } | 802 | } |
| 770 | 803 | ||
| 771 | for (i = 0; i < card->num_rtd; i++) { | 804 | for (i = 0; i < card->num_rtd; i++) { |
| @@ -810,12 +843,19 @@ int snd_soc_resume(struct device *dev) | |||
| 810 | 843 | ||
| 811 | /* activate pins from sleep state */ | 844 | /* activate pins from sleep state */ |
| 812 | for (i = 0; i < card->num_rtd; i++) { | 845 | for (i = 0; i < card->num_rtd; i++) { |
| 813 | struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; | 846 | struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; |
| 814 | struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; | 847 | struct snd_soc_dai **codec_dais = rtd->codec_dais; |
| 848 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
| 849 | int j; | ||
| 850 | |||
| 815 | if (cpu_dai->active) | 851 | if (cpu_dai->active) |
| 816 | pinctrl_pm_select_default_state(cpu_dai->dev); | 852 | pinctrl_pm_select_default_state(cpu_dai->dev); |
| 817 | if (codec_dai->active) | 853 | |
| 818 | pinctrl_pm_select_default_state(codec_dai->dev); | 854 | for (j = 0; j < rtd->num_codecs; j++) { |
| 855 | struct snd_soc_dai *codec_dai = codec_dais[j]; | ||
| 856 | if (codec_dai->active) | ||
| 857 | pinctrl_pm_select_default_state(codec_dai->dev); | ||
| 858 | } | ||
| 819 | } | 859 | } |
| 820 | 860 | ||
| 821 | /* AC97 devices might have other drivers hanging off them so | 861 | /* AC97 devices might have other drivers hanging off them so |
| @@ -847,8 +887,9 @@ EXPORT_SYMBOL_GPL(snd_soc_resume); | |||
| 847 | static const struct snd_soc_dai_ops null_dai_ops = { | 887 | static const struct snd_soc_dai_ops null_dai_ops = { |
| 848 | }; | 888 | }; |
| 849 | 889 | ||
| 850 | static struct snd_soc_codec *soc_find_codec(const struct device_node *codec_of_node, | 890 | static struct snd_soc_codec *soc_find_codec( |
| 851 | const char *codec_name) | 891 | const struct device_node *codec_of_node, |
| 892 | const char *codec_name) | ||
| 852 | { | 893 | { |
| 853 | struct snd_soc_codec *codec; | 894 | struct snd_soc_codec *codec; |
| 854 | 895 | ||
| @@ -857,7 +898,7 @@ static struct snd_soc_codec *soc_find_codec(const struct device_node *codec_of_n | |||
| 857 | if (codec->dev->of_node != codec_of_node) | 898 | if (codec->dev->of_node != codec_of_node) |
| 858 | continue; | 899 | continue; |
| 859 | } else { | 900 | } else { |
| 860 | if (strcmp(codec->name, codec_name)) | 901 | if (strcmp(codec->component.name, codec_name)) |
| 861 | continue; | 902 | continue; |
| 862 | } | 903 | } |
| 863 | 904 | ||
| @@ -886,9 +927,12 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) | |||
| 886 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; | 927 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; |
| 887 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | 928 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; |
| 888 | struct snd_soc_component *component; | 929 | struct snd_soc_component *component; |
| 930 | struct snd_soc_dai_link_component *codecs = dai_link->codecs; | ||
| 931 | struct snd_soc_dai **codec_dais = rtd->codec_dais; | ||
| 889 | struct snd_soc_platform *platform; | 932 | struct snd_soc_platform *platform; |
| 890 | struct snd_soc_dai *cpu_dai; | 933 | struct snd_soc_dai *cpu_dai; |
| 891 | const char *platform_name; | 934 | const char *platform_name; |
| 935 | int i; | ||
| 892 | 936 | ||
| 893 | dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); | 937 | dev_dbg(card->dev, "ASoC: binding %s at idx %d\n", dai_link->name, num); |
| 894 | 938 | ||
| @@ -915,24 +959,30 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) | |||
| 915 | return -EPROBE_DEFER; | 959 | return -EPROBE_DEFER; |
| 916 | } | 960 | } |
| 917 | 961 | ||
| 918 | /* Find CODEC from registered list */ | 962 | rtd->num_codecs = dai_link->num_codecs; |
| 919 | rtd->codec = soc_find_codec(dai_link->codec_of_node, | ||
| 920 | dai_link->codec_name); | ||
| 921 | if (!rtd->codec) { | ||
| 922 | dev_err(card->dev, "ASoC: CODEC %s not registered\n", | ||
| 923 | dai_link->codec_name); | ||
| 924 | return -EPROBE_DEFER; | ||
| 925 | } | ||
| 926 | 963 | ||
| 927 | /* Find CODEC DAI from registered list */ | 964 | /* Find CODEC from registered CODECs */ |
| 928 | rtd->codec_dai = soc_find_codec_dai(rtd->codec, | 965 | for (i = 0; i < rtd->num_codecs; i++) { |
| 929 | dai_link->codec_dai_name); | 966 | struct snd_soc_codec *codec; |
| 930 | if (!rtd->codec_dai) { | 967 | codec = soc_find_codec(codecs[i].of_node, codecs[i].name); |
| 931 | dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", | 968 | if (!codec) { |
| 932 | dai_link->codec_dai_name); | 969 | dev_err(card->dev, "ASoC: CODEC %s not registered\n", |
| 933 | return -EPROBE_DEFER; | 970 | codecs[i].name); |
| 971 | return -EPROBE_DEFER; | ||
| 972 | } | ||
| 973 | |||
| 974 | codec_dais[i] = soc_find_codec_dai(codec, codecs[i].dai_name); | ||
| 975 | if (!codec_dais[i]) { | ||
| 976 | dev_err(card->dev, "ASoC: CODEC DAI %s not registered\n", | ||
| 977 | codecs[i].dai_name); | ||
| 978 | return -EPROBE_DEFER; | ||
| 979 | } | ||
| 934 | } | 980 | } |
| 935 | 981 | ||
| 982 | /* Single codec links expect codec and codec_dai in runtime data */ | ||
| 983 | rtd->codec_dai = codec_dais[0]; | ||
| 984 | rtd->codec = rtd->codec_dai->codec; | ||
| 985 | |||
| 936 | /* if there's no platform we match on the empty platform */ | 986 | /* if there's no platform we match on the empty platform */ |
| 937 | platform_name = dai_link->platform_name; | 987 | platform_name = dai_link->platform_name; |
| 938 | if (!platform_name && !dai_link->platform_of_node) | 988 | if (!platform_name && !dai_link->platform_of_node) |
| @@ -945,7 +995,7 @@ static int soc_bind_dai_link(struct snd_soc_card *card, int num) | |||
| 945 | dai_link->platform_of_node) | 995 | dai_link->platform_of_node) |
| 946 | continue; | 996 | continue; |
| 947 | } else { | 997 | } else { |
| 948 | if (strcmp(platform->name, platform_name)) | 998 | if (strcmp(platform->component.name, platform_name)) |
| 949 | continue; | 999 | continue; |
| 950 | } | 1000 | } |
| 951 | 1001 | ||
| @@ -974,11 +1024,10 @@ static int soc_remove_platform(struct snd_soc_platform *platform) | |||
| 974 | } | 1024 | } |
| 975 | 1025 | ||
| 976 | /* Make sure all DAPM widgets are freed */ | 1026 | /* Make sure all DAPM widgets are freed */ |
| 977 | snd_soc_dapm_free(&platform->dapm); | 1027 | snd_soc_dapm_free(&platform->component.dapm); |
| 978 | 1028 | ||
| 979 | soc_cleanup_platform_debugfs(platform); | 1029 | soc_cleanup_platform_debugfs(platform); |
| 980 | platform->probed = 0; | 1030 | platform->probed = 0; |
| 981 | list_del(&platform->card_list); | ||
| 982 | module_put(platform->dev->driver->owner); | 1031 | module_put(platform->dev->driver->owner); |
| 983 | 1032 | ||
| 984 | return 0; | 1033 | return 0; |
| @@ -1023,8 +1072,8 @@ static void soc_remove_codec_dai(struct snd_soc_dai *codec_dai, int order) | |||
| 1023 | static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) | 1072 | static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) |
| 1024 | { | 1073 | { |
| 1025 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | 1074 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; |
| 1026 | struct snd_soc_dai *codec_dai = rtd->codec_dai, *cpu_dai = rtd->cpu_dai; | 1075 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 1027 | int err; | 1076 | int i, err; |
| 1028 | 1077 | ||
| 1029 | /* unregister the rtd device */ | 1078 | /* unregister the rtd device */ |
| 1030 | if (rtd->dev_registered) { | 1079 | if (rtd->dev_registered) { |
| @@ -1035,7 +1084,8 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) | |||
| 1035 | } | 1084 | } |
| 1036 | 1085 | ||
| 1037 | /* remove the CODEC DAI */ | 1086 | /* remove the CODEC DAI */ |
| 1038 | soc_remove_codec_dai(codec_dai, order); | 1087 | for (i = 0; i < rtd->num_codecs; i++) |
| 1088 | soc_remove_codec_dai(rtd->codec_dais[i], order); | ||
| 1039 | 1089 | ||
| 1040 | /* remove the cpu_dai */ | 1090 | /* remove the cpu_dai */ |
| 1041 | if (cpu_dai && cpu_dai->probed && | 1091 | if (cpu_dai && cpu_dai->probed && |
| @@ -1048,11 +1098,8 @@ static void soc_remove_link_dais(struct snd_soc_card *card, int num, int order) | |||
| 1048 | cpu_dai->name, err); | 1098 | cpu_dai->name, err); |
| 1049 | } | 1099 | } |
| 1050 | cpu_dai->probed = 0; | 1100 | cpu_dai->probed = 0; |
| 1051 | 1101 | if (!cpu_dai->codec) | |
| 1052 | if (!cpu_dai->codec) { | ||
| 1053 | snd_soc_dapm_free(&cpu_dai->dapm); | ||
| 1054 | module_put(cpu_dai->dev->driver->owner); | 1102 | module_put(cpu_dai->dev->driver->owner); |
| 1055 | } | ||
| 1056 | } | 1103 | } |
| 1057 | } | 1104 | } |
| 1058 | 1105 | ||
| @@ -1061,9 +1108,9 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num, | |||
| 1061 | { | 1108 | { |
| 1062 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | 1109 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; |
| 1063 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1110 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 1064 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
| 1065 | struct snd_soc_platform *platform = rtd->platform; | 1111 | struct snd_soc_platform *platform = rtd->platform; |
| 1066 | struct snd_soc_codec *codec; | 1112 | struct snd_soc_codec *codec; |
| 1113 | int i; | ||
| 1067 | 1114 | ||
| 1068 | /* remove the platform */ | 1115 | /* remove the platform */ |
| 1069 | if (platform && platform->probed && | 1116 | if (platform && platform->probed && |
| @@ -1072,8 +1119,8 @@ static void soc_remove_link_components(struct snd_soc_card *card, int num, | |||
| 1072 | } | 1119 | } |
| 1073 | 1120 | ||
| 1074 | /* remove the CODEC-side CODEC */ | 1121 | /* remove the CODEC-side CODEC */ |
| 1075 | if (codec_dai) { | 1122 | for (i = 0; i < rtd->num_codecs; i++) { |
| 1076 | codec = codec_dai->codec; | 1123 | codec = rtd->codec_dais[i]->codec; |
| 1077 | if (codec && codec->probed && | 1124 | if (codec && codec->probed && |
| 1078 | codec->driver->remove_order == order) | 1125 | codec->driver->remove_order == order) |
| 1079 | soc_remove_codec(codec); | 1126 | soc_remove_codec(codec); |
| @@ -1108,7 +1155,7 @@ static void soc_remove_dai_links(struct snd_soc_card *card) | |||
| 1108 | } | 1155 | } |
| 1109 | 1156 | ||
| 1110 | static void soc_set_name_prefix(struct snd_soc_card *card, | 1157 | static void soc_set_name_prefix(struct snd_soc_card *card, |
| 1111 | struct snd_soc_codec *codec) | 1158 | struct snd_soc_component *component) |
| 1112 | { | 1159 | { |
| 1113 | int i; | 1160 | int i; |
| 1114 | 1161 | ||
| @@ -1117,11 +1164,11 @@ static void soc_set_name_prefix(struct snd_soc_card *card, | |||
| 1117 | 1164 | ||
| 1118 | for (i = 0; i < card->num_configs; i++) { | 1165 | for (i = 0; i < card->num_configs; i++) { |
| 1119 | struct snd_soc_codec_conf *map = &card->codec_conf[i]; | 1166 | struct snd_soc_codec_conf *map = &card->codec_conf[i]; |
| 1120 | if (map->of_node && codec->dev->of_node != map->of_node) | 1167 | if (map->of_node && component->dev->of_node != map->of_node) |
| 1121 | continue; | 1168 | continue; |
| 1122 | if (map->dev_name && strcmp(codec->name, map->dev_name)) | 1169 | if (map->dev_name && strcmp(component->name, map->dev_name)) |
| 1123 | continue; | 1170 | continue; |
| 1124 | codec->name_prefix = map->name_prefix; | 1171 | component->name_prefix = map->name_prefix; |
| 1125 | break; | 1172 | break; |
| 1126 | } | 1173 | } |
| 1127 | } | 1174 | } |
| @@ -1133,9 +1180,9 @@ static int soc_probe_codec(struct snd_soc_card *card, | |||
| 1133 | const struct snd_soc_codec_driver *driver = codec->driver; | 1180 | const struct snd_soc_codec_driver *driver = codec->driver; |
| 1134 | struct snd_soc_dai *dai; | 1181 | struct snd_soc_dai *dai; |
| 1135 | 1182 | ||
| 1136 | codec->card = card; | 1183 | codec->component.card = card; |
| 1137 | codec->dapm.card = card; | 1184 | codec->dapm.card = card; |
| 1138 | soc_set_name_prefix(card, codec); | 1185 | soc_set_name_prefix(card, &codec->component); |
| 1139 | 1186 | ||
| 1140 | if (!try_module_get(codec->dev->driver->owner)) | 1187 | if (!try_module_get(codec->dev->driver->owner)) |
| 1141 | return -ENODEV; | 1188 | return -ENODEV; |
| @@ -1177,7 +1224,7 @@ static int soc_probe_codec(struct snd_soc_card *card, | |||
| 1177 | WARN(codec->dapm.idle_bias_off && | 1224 | WARN(codec->dapm.idle_bias_off && |
| 1178 | codec->dapm.bias_level != SND_SOC_BIAS_OFF, | 1225 | codec->dapm.bias_level != SND_SOC_BIAS_OFF, |
| 1179 | "codec %s can not start from non-off bias with idle_bias_off==1\n", | 1226 | "codec %s can not start from non-off bias with idle_bias_off==1\n", |
| 1180 | codec->name); | 1227 | codec->component.name); |
| 1181 | } | 1228 | } |
| 1182 | 1229 | ||
| 1183 | if (driver->controls) | 1230 | if (driver->controls) |
| @@ -1209,8 +1256,8 @@ static int soc_probe_platform(struct snd_soc_card *card, | |||
| 1209 | struct snd_soc_component *component; | 1256 | struct snd_soc_component *component; |
| 1210 | struct snd_soc_dai *dai; | 1257 | struct snd_soc_dai *dai; |
| 1211 | 1258 | ||
| 1212 | platform->card = card; | 1259 | platform->component.card = card; |
| 1213 | platform->dapm.card = card; | 1260 | platform->component.dapm.card = card; |
| 1214 | 1261 | ||
| 1215 | if (!try_module_get(platform->dev->driver->owner)) | 1262 | if (!try_module_get(platform->dev->driver->owner)) |
| 1216 | return -ENODEV; | 1263 | return -ENODEV; |
| @@ -1218,7 +1265,7 @@ static int soc_probe_platform(struct snd_soc_card *card, | |||
| 1218 | soc_init_platform_debugfs(platform); | 1265 | soc_init_platform_debugfs(platform); |
| 1219 | 1266 | ||
| 1220 | if (driver->dapm_widgets) | 1267 | if (driver->dapm_widgets) |
| 1221 | snd_soc_dapm_new_controls(&platform->dapm, | 1268 | snd_soc_dapm_new_controls(&platform->component.dapm, |
| 1222 | driver->dapm_widgets, driver->num_dapm_widgets); | 1269 | driver->dapm_widgets, driver->num_dapm_widgets); |
| 1223 | 1270 | ||
| 1224 | /* Create DAPM widgets for each DAI stream */ | 1271 | /* Create DAPM widgets for each DAI stream */ |
| @@ -1226,10 +1273,11 @@ static int soc_probe_platform(struct snd_soc_card *card, | |||
| 1226 | if (component->dev != platform->dev) | 1273 | if (component->dev != platform->dev) |
| 1227 | continue; | 1274 | continue; |
| 1228 | list_for_each_entry(dai, &component->dai_list, list) | 1275 | list_for_each_entry(dai, &component->dai_list, list) |
| 1229 | snd_soc_dapm_new_dai_widgets(&platform->dapm, dai); | 1276 | snd_soc_dapm_new_dai_widgets(&platform->component.dapm, |
| 1277 | dai); | ||
| 1230 | } | 1278 | } |
| 1231 | 1279 | ||
| 1232 | platform->dapm.idle_bias_off = 1; | 1280 | platform->component.dapm.idle_bias_off = 1; |
| 1233 | 1281 | ||
| 1234 | if (driver->probe) { | 1282 | if (driver->probe) { |
| 1235 | ret = driver->probe(platform); | 1283 | ret = driver->probe(platform); |
| @@ -1244,13 +1292,12 @@ static int soc_probe_platform(struct snd_soc_card *card, | |||
| 1244 | snd_soc_add_platform_controls(platform, driver->controls, | 1292 | snd_soc_add_platform_controls(platform, driver->controls, |
| 1245 | driver->num_controls); | 1293 | driver->num_controls); |
| 1246 | if (driver->dapm_routes) | 1294 | if (driver->dapm_routes) |
| 1247 | snd_soc_dapm_add_routes(&platform->dapm, driver->dapm_routes, | 1295 | snd_soc_dapm_add_routes(&platform->component.dapm, |
| 1248 | driver->num_dapm_routes); | 1296 | driver->dapm_routes, driver->num_dapm_routes); |
| 1249 | 1297 | ||
| 1250 | /* mark platform as probed and add to card platform list */ | 1298 | /* mark platform as probed and add to card platform list */ |
| 1251 | platform->probed = 1; | 1299 | platform->probed = 1; |
| 1252 | list_add(&platform->card_list, &card->platform_dev_list); | 1300 | list_add(&platform->component.dapm.list, &card->dapm_list); |
| 1253 | list_add(&platform->dapm.list, &card->dapm_list); | ||
| 1254 | 1301 | ||
| 1255 | return 0; | 1302 | return 0; |
| 1256 | 1303 | ||
| @@ -1266,83 +1313,17 @@ static void rtd_release(struct device *dev) | |||
| 1266 | kfree(dev); | 1313 | kfree(dev); |
| 1267 | } | 1314 | } |
| 1268 | 1315 | ||
| 1269 | static int soc_aux_dev_init(struct snd_soc_card *card, | 1316 | static int soc_post_component_init(struct snd_soc_pcm_runtime *rtd, |
| 1270 | struct snd_soc_codec *codec, | 1317 | const char *name) |
| 1271 | int num) | ||
| 1272 | { | ||
| 1273 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; | ||
| 1274 | struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; | ||
| 1275 | int ret; | ||
| 1276 | |||
| 1277 | rtd->card = card; | ||
| 1278 | |||
| 1279 | /* do machine specific initialization */ | ||
| 1280 | if (aux_dev->init) { | ||
| 1281 | ret = aux_dev->init(&codec->dapm); | ||
| 1282 | if (ret < 0) | ||
| 1283 | return ret; | ||
| 1284 | } | ||
| 1285 | |||
| 1286 | rtd->codec = codec; | ||
| 1287 | |||
| 1288 | return 0; | ||
| 1289 | } | ||
| 1290 | |||
| 1291 | static int soc_dai_link_init(struct snd_soc_card *card, | ||
| 1292 | struct snd_soc_codec *codec, | ||
| 1293 | int num) | ||
| 1294 | { | 1318 | { |
| 1295 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; | ||
| 1296 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | ||
| 1297 | int ret; | ||
| 1298 | |||
| 1299 | rtd->card = card; | ||
| 1300 | |||
| 1301 | /* do machine specific initialization */ | ||
| 1302 | if (dai_link->init) { | ||
| 1303 | ret = dai_link->init(rtd); | ||
| 1304 | if (ret < 0) | ||
| 1305 | return ret; | ||
| 1306 | } | ||
| 1307 | |||
| 1308 | rtd->codec = codec; | ||
| 1309 | |||
| 1310 | return 0; | ||
| 1311 | } | ||
| 1312 | |||
| 1313 | static int soc_post_component_init(struct snd_soc_card *card, | ||
| 1314 | struct snd_soc_codec *codec, | ||
| 1315 | int num, int dailess) | ||
| 1316 | { | ||
| 1317 | struct snd_soc_dai_link *dai_link = NULL; | ||
| 1318 | struct snd_soc_aux_dev *aux_dev = NULL; | ||
| 1319 | struct snd_soc_pcm_runtime *rtd; | ||
| 1320 | const char *name; | ||
| 1321 | int ret = 0; | 1319 | int ret = 0; |
| 1322 | 1320 | ||
| 1323 | if (!dailess) { | ||
| 1324 | dai_link = &card->dai_link[num]; | ||
| 1325 | rtd = &card->rtd[num]; | ||
| 1326 | name = dai_link->name; | ||
| 1327 | ret = soc_dai_link_init(card, codec, num); | ||
| 1328 | } else { | ||
| 1329 | aux_dev = &card->aux_dev[num]; | ||
| 1330 | rtd = &card->rtd_aux[num]; | ||
| 1331 | name = aux_dev->name; | ||
| 1332 | ret = soc_aux_dev_init(card, codec, num); | ||
| 1333 | } | ||
| 1334 | |||
| 1335 | if (ret < 0) { | ||
| 1336 | dev_err(card->dev, "ASoC: failed to init %s: %d\n", name, ret); | ||
| 1337 | return ret; | ||
| 1338 | } | ||
| 1339 | |||
| 1340 | /* register the rtd device */ | 1321 | /* register the rtd device */ |
| 1341 | rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL); | 1322 | rtd->dev = kzalloc(sizeof(struct device), GFP_KERNEL); |
| 1342 | if (!rtd->dev) | 1323 | if (!rtd->dev) |
| 1343 | return -ENOMEM; | 1324 | return -ENOMEM; |
| 1344 | device_initialize(rtd->dev); | 1325 | device_initialize(rtd->dev); |
| 1345 | rtd->dev->parent = card->dev; | 1326 | rtd->dev->parent = rtd->card->dev; |
| 1346 | rtd->dev->release = rtd_release; | 1327 | rtd->dev->release = rtd_release; |
| 1347 | rtd->dev->init_name = name; | 1328 | rtd->dev->init_name = name; |
| 1348 | dev_set_drvdata(rtd->dev, rtd); | 1329 | dev_set_drvdata(rtd->dev, rtd); |
| @@ -1355,7 +1336,7 @@ static int soc_post_component_init(struct snd_soc_card *card, | |||
| 1355 | if (ret < 0) { | 1336 | if (ret < 0) { |
| 1356 | /* calling put_device() here to free the rtd->dev */ | 1337 | /* calling put_device() here to free the rtd->dev */ |
| 1357 | put_device(rtd->dev); | 1338 | put_device(rtd->dev); |
| 1358 | dev_err(card->dev, | 1339 | dev_err(rtd->card->dev, |
| 1359 | "ASoC: failed to register runtime device: %d\n", ret); | 1340 | "ASoC: failed to register runtime device: %d\n", ret); |
| 1360 | return ret; | 1341 | return ret; |
| 1361 | } | 1342 | } |
| @@ -1364,26 +1345,15 @@ static int soc_post_component_init(struct snd_soc_card *card, | |||
| 1364 | /* add DAPM sysfs entries for this codec */ | 1345 | /* add DAPM sysfs entries for this codec */ |
| 1365 | ret = snd_soc_dapm_sys_add(rtd->dev); | 1346 | ret = snd_soc_dapm_sys_add(rtd->dev); |
| 1366 | if (ret < 0) | 1347 | if (ret < 0) |
| 1367 | dev_err(codec->dev, | 1348 | dev_err(rtd->dev, |
| 1368 | "ASoC: failed to add codec dapm sysfs entries: %d\n", ret); | 1349 | "ASoC: failed to add codec dapm sysfs entries: %d\n", ret); |
| 1369 | 1350 | ||
| 1370 | /* add codec sysfs entries */ | 1351 | /* add codec sysfs entries */ |
| 1371 | ret = device_create_file(rtd->dev, &dev_attr_codec_reg); | 1352 | ret = device_create_file(rtd->dev, &dev_attr_codec_reg); |
| 1372 | if (ret < 0) | 1353 | if (ret < 0) |
| 1373 | dev_err(codec->dev, | 1354 | dev_err(rtd->dev, |
| 1374 | "ASoC: failed to add codec sysfs files: %d\n", ret); | 1355 | "ASoC: failed to add codec sysfs files: %d\n", ret); |
| 1375 | 1356 | ||
| 1376 | #ifdef CONFIG_DEBUG_FS | ||
| 1377 | /* add DPCM sysfs entries */ | ||
| 1378 | if (!dailess && !dai_link->dynamic) | ||
| 1379 | goto out; | ||
| 1380 | |||
| 1381 | ret = soc_dpcm_debugfs_add(rtd); | ||
| 1382 | if (ret < 0) | ||
| 1383 | dev_err(rtd->dev, "ASoC: failed to add dpcm sysfs entries: %d\n", ret); | ||
| 1384 | |||
| 1385 | out: | ||
| 1386 | #endif | ||
| 1387 | return 0; | 1357 | return 0; |
| 1388 | } | 1358 | } |
| 1389 | 1359 | ||
| @@ -1392,9 +1362,8 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, | |||
| 1392 | { | 1362 | { |
| 1393 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | 1363 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; |
| 1394 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1364 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 1395 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
| 1396 | struct snd_soc_platform *platform = rtd->platform; | 1365 | struct snd_soc_platform *platform = rtd->platform; |
| 1397 | int ret; | 1366 | int i, ret; |
| 1398 | 1367 | ||
| 1399 | /* probe the CPU-side component, if it is a CODEC */ | 1368 | /* probe the CPU-side component, if it is a CODEC */ |
| 1400 | if (cpu_dai->codec && | 1369 | if (cpu_dai->codec && |
| @@ -1405,12 +1374,14 @@ static int soc_probe_link_components(struct snd_soc_card *card, int num, | |||
| 1405 | return ret; | 1374 | return ret; |
| 1406 | } | 1375 | } |
| 1407 | 1376 | ||
| 1408 | /* probe the CODEC-side component */ | 1377 | /* probe the CODEC-side components */ |
| 1409 | if (!codec_dai->codec->probed && | 1378 | for (i = 0; i < rtd->num_codecs; i++) { |
| 1410 | codec_dai->codec->driver->probe_order == order) { | 1379 | if (!rtd->codec_dais[i]->codec->probed && |
| 1411 | ret = soc_probe_codec(card, codec_dai->codec); | 1380 | rtd->codec_dais[i]->codec->driver->probe_order == order) { |
| 1412 | if (ret < 0) | 1381 | ret = soc_probe_codec(card, rtd->codec_dais[i]->codec); |
| 1413 | return ret; | 1382 | if (ret < 0) |
| 1383 | return ret; | ||
| 1384 | } | ||
| 1414 | } | 1385 | } |
| 1415 | 1386 | ||
| 1416 | /* probe the platform */ | 1387 | /* probe the platform */ |
| @@ -1450,12 +1421,16 @@ static int soc_probe_codec_dai(struct snd_soc_card *card, | |||
| 1450 | 1421 | ||
| 1451 | static int soc_link_dai_widgets(struct snd_soc_card *card, | 1422 | static int soc_link_dai_widgets(struct snd_soc_card *card, |
| 1452 | struct snd_soc_dai_link *dai_link, | 1423 | struct snd_soc_dai_link *dai_link, |
| 1453 | struct snd_soc_dai *cpu_dai, | 1424 | struct snd_soc_pcm_runtime *rtd) |
| 1454 | struct snd_soc_dai *codec_dai) | ||
| 1455 | { | 1425 | { |
| 1426 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
| 1427 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
| 1456 | struct snd_soc_dapm_widget *play_w, *capture_w; | 1428 | struct snd_soc_dapm_widget *play_w, *capture_w; |
| 1457 | int ret; | 1429 | int ret; |
| 1458 | 1430 | ||
| 1431 | if (rtd->num_codecs > 1) | ||
| 1432 | dev_warn(card->dev, "ASoC: Multiple codecs not supported yet\n"); | ||
| 1433 | |||
| 1459 | /* link the DAI widgets */ | 1434 | /* link the DAI widgets */ |
| 1460 | play_w = codec_dai->playback_widget; | 1435 | play_w = codec_dai->playback_widget; |
| 1461 | capture_w = cpu_dai->capture_widget; | 1436 | capture_w = cpu_dai->capture_widget; |
| @@ -1488,19 +1463,18 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
| 1488 | { | 1463 | { |
| 1489 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; | 1464 | struct snd_soc_dai_link *dai_link = &card->dai_link[num]; |
| 1490 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; | 1465 | struct snd_soc_pcm_runtime *rtd = &card->rtd[num]; |
| 1491 | struct snd_soc_codec *codec = rtd->codec; | ||
| 1492 | struct snd_soc_platform *platform = rtd->platform; | 1466 | struct snd_soc_platform *platform = rtd->platform; |
| 1493 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | ||
| 1494 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1467 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 1495 | int ret; | 1468 | int i, ret; |
| 1496 | 1469 | ||
| 1497 | dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", | 1470 | dev_dbg(card->dev, "ASoC: probe %s dai link %d late %d\n", |
| 1498 | card->name, num, order); | 1471 | card->name, num, order); |
| 1499 | 1472 | ||
| 1500 | /* config components */ | 1473 | /* config components */ |
| 1501 | cpu_dai->platform = platform; | 1474 | cpu_dai->platform = platform; |
| 1502 | codec_dai->card = card; | ||
| 1503 | cpu_dai->card = card; | 1475 | cpu_dai->card = card; |
| 1476 | for (i = 0; i < rtd->num_codecs; i++) | ||
| 1477 | rtd->codec_dais[i]->card = card; | ||
| 1504 | 1478 | ||
| 1505 | /* set default power off timeout */ | 1479 | /* set default power off timeout */ |
| 1506 | rtd->pmdown_time = pmdown_time; | 1480 | rtd->pmdown_time = pmdown_time; |
| @@ -1509,11 +1483,8 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
| 1509 | if (!cpu_dai->probed && | 1483 | if (!cpu_dai->probed && |
| 1510 | cpu_dai->driver->probe_order == order) { | 1484 | cpu_dai->driver->probe_order == order) { |
| 1511 | if (!cpu_dai->codec) { | 1485 | if (!cpu_dai->codec) { |
| 1512 | cpu_dai->dapm.card = card; | ||
| 1513 | if (!try_module_get(cpu_dai->dev->driver->owner)) | 1486 | if (!try_module_get(cpu_dai->dev->driver->owner)) |
| 1514 | return -ENODEV; | 1487 | return -ENODEV; |
| 1515 | |||
| 1516 | list_add(&cpu_dai->dapm.list, &card->dapm_list); | ||
| 1517 | } | 1488 | } |
| 1518 | 1489 | ||
| 1519 | if (cpu_dai->driver->probe) { | 1490 | if (cpu_dai->driver->probe) { |
| @@ -1530,18 +1501,43 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
| 1530 | } | 1501 | } |
| 1531 | 1502 | ||
| 1532 | /* probe the CODEC DAI */ | 1503 | /* probe the CODEC DAI */ |
| 1533 | ret = soc_probe_codec_dai(card, codec_dai, order); | 1504 | for (i = 0; i < rtd->num_codecs; i++) { |
| 1534 | if (ret) | 1505 | ret = soc_probe_codec_dai(card, rtd->codec_dais[i], order); |
| 1535 | return ret; | 1506 | if (ret) |
| 1507 | return ret; | ||
| 1508 | } | ||
| 1536 | 1509 | ||
| 1537 | /* complete DAI probe during last probe */ | 1510 | /* complete DAI probe during last probe */ |
| 1538 | if (order != SND_SOC_COMP_ORDER_LAST) | 1511 | if (order != SND_SOC_COMP_ORDER_LAST) |
| 1539 | return 0; | 1512 | return 0; |
| 1540 | 1513 | ||
| 1541 | ret = soc_post_component_init(card, codec, num, 0); | 1514 | /* do machine specific initialization */ |
| 1515 | if (dai_link->init) { | ||
| 1516 | ret = dai_link->init(rtd); | ||
| 1517 | if (ret < 0) { | ||
| 1518 | dev_err(card->dev, "ASoC: failed to init %s: %d\n", | ||
| 1519 | dai_link->name, ret); | ||
| 1520 | return ret; | ||
| 1521 | } | ||
| 1522 | } | ||
| 1523 | |||
| 1524 | ret = soc_post_component_init(rtd, dai_link->name); | ||
| 1542 | if (ret) | 1525 | if (ret) |
| 1543 | return ret; | 1526 | return ret; |
| 1544 | 1527 | ||
| 1528 | #ifdef CONFIG_DEBUG_FS | ||
| 1529 | /* add DPCM sysfs entries */ | ||
| 1530 | if (dai_link->dynamic) { | ||
| 1531 | ret = soc_dpcm_debugfs_add(rtd); | ||
| 1532 | if (ret < 0) { | ||
| 1533 | dev_err(rtd->dev, | ||
| 1534 | "ASoC: failed to add dpcm sysfs entries: %d\n", | ||
| 1535 | ret); | ||
| 1536 | return ret; | ||
| 1537 | } | ||
| 1538 | } | ||
| 1539 | #endif | ||
| 1540 | |||
| 1545 | ret = device_create_file(rtd->dev, &dev_attr_pmdown_time); | 1541 | ret = device_create_file(rtd->dev, &dev_attr_pmdown_time); |
| 1546 | if (ret < 0) | 1542 | if (ret < 0) |
| 1547 | dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n", | 1543 | dev_warn(rtd->dev, "ASoC: failed to add pmdown_time sysfs: %d\n", |
| @@ -1570,16 +1566,18 @@ static int soc_probe_link_dais(struct snd_soc_card *card, int num, int order) | |||
| 1570 | codec2codec_close_delayed_work); | 1566 | codec2codec_close_delayed_work); |
| 1571 | 1567 | ||
| 1572 | /* link the DAI widgets */ | 1568 | /* link the DAI widgets */ |
| 1573 | ret = soc_link_dai_widgets(card, dai_link, | 1569 | ret = soc_link_dai_widgets(card, dai_link, rtd); |
| 1574 | cpu_dai, codec_dai); | ||
| 1575 | if (ret) | 1570 | if (ret) |
| 1576 | return ret; | 1571 | return ret; |
| 1577 | } | 1572 | } |
| 1578 | } | 1573 | } |
| 1579 | 1574 | ||
| 1580 | /* add platform data for AC97 devices */ | 1575 | /* add platform data for AC97 devices */ |
| 1581 | if (rtd->codec_dai->driver->ac97_control) | 1576 | for (i = 0; i < rtd->num_codecs; i++) { |
| 1582 | snd_ac97_dev_add_pdata(codec->ac97, rtd->cpu_dai->ac97_pdata); | 1577 | if (rtd->codec_dais[i]->driver->ac97_control) |
| 1578 | snd_ac97_dev_add_pdata(rtd->codec_dais[i]->codec->ac97, | ||
| 1579 | rtd->cpu_dai->ac97_pdata); | ||
| 1580 | } | ||
| 1583 | 1581 | ||
| 1584 | return 0; | 1582 | return 0; |
| 1585 | } | 1583 | } |
| @@ -1617,11 +1615,6 @@ static int soc_register_ac97_codec(struct snd_soc_codec *codec, | |||
| 1617 | return 0; | 1615 | return 0; |
| 1618 | } | 1616 | } |
| 1619 | 1617 | ||
| 1620 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | ||
| 1621 | { | ||
| 1622 | return soc_register_ac97_codec(rtd->codec, rtd->codec_dai); | ||
| 1623 | } | ||
| 1624 | |||
| 1625 | static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) | 1618 | static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) |
| 1626 | { | 1619 | { |
| 1627 | if (codec->ac97_registered) { | 1620 | if (codec->ac97_registered) { |
| @@ -1630,74 +1623,77 @@ static void soc_unregister_ac97_codec(struct snd_soc_codec *codec) | |||
| 1630 | } | 1623 | } |
| 1631 | } | 1624 | } |
| 1632 | 1625 | ||
| 1633 | static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) | 1626 | static int soc_register_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) |
| 1634 | { | 1627 | { |
| 1635 | soc_unregister_ac97_codec(rtd->codec); | 1628 | int i, ret; |
| 1636 | } | ||
| 1637 | #endif | ||
| 1638 | 1629 | ||
| 1639 | static struct snd_soc_codec *soc_find_matching_codec(struct snd_soc_card *card, | 1630 | for (i = 0; i < rtd->num_codecs; i++) { |
| 1640 | int num) | 1631 | struct snd_soc_dai *codec_dai = rtd->codec_dais[i]; |
| 1641 | { | ||
| 1642 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; | ||
| 1643 | struct snd_soc_codec *codec; | ||
| 1644 | 1632 | ||
| 1645 | /* find CODEC from registered CODECs */ | 1633 | ret = soc_register_ac97_codec(codec_dai->codec, codec_dai); |
| 1646 | list_for_each_entry(codec, &codec_list, list) { | 1634 | if (ret) { |
| 1647 | if (aux_dev->codec_of_node && | 1635 | while (--i >= 0) |
| 1648 | (codec->dev->of_node != aux_dev->codec_of_node)) | 1636 | soc_unregister_ac97_codec(codec_dai->codec); |
| 1649 | continue; | 1637 | return ret; |
| 1650 | if (aux_dev->codec_name && strcmp(codec->name, aux_dev->codec_name)) | 1638 | } |
| 1651 | continue; | ||
| 1652 | return codec; | ||
| 1653 | } | 1639 | } |
| 1654 | 1640 | ||
| 1655 | return NULL; | 1641 | return 0; |
| 1656 | } | 1642 | } |
| 1657 | 1643 | ||
| 1658 | static int soc_check_aux_dev(struct snd_soc_card *card, int num) | 1644 | static void soc_unregister_ac97_dai_link(struct snd_soc_pcm_runtime *rtd) |
| 1659 | { | 1645 | { |
| 1660 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; | 1646 | int i; |
| 1661 | const char *codecname = aux_dev->codec_name; | ||
| 1662 | struct snd_soc_codec *codec = soc_find_matching_codec(card, num); | ||
| 1663 | |||
| 1664 | if (codec) | ||
| 1665 | return 0; | ||
| 1666 | if (aux_dev->codec_of_node) | ||
| 1667 | codecname = of_node_full_name(aux_dev->codec_of_node); | ||
| 1668 | 1647 | ||
| 1669 | dev_err(card->dev, "ASoC: %s not registered\n", codecname); | 1648 | for (i = 0; i < rtd->num_codecs; i++) |
| 1670 | return -EPROBE_DEFER; | 1649 | soc_unregister_ac97_codec(rtd->codec_dais[i]->codec); |
| 1671 | } | 1650 | } |
| 1651 | #endif | ||
| 1672 | 1652 | ||
| 1673 | static int soc_probe_aux_dev(struct snd_soc_card *card, int num) | 1653 | static int soc_bind_aux_dev(struct snd_soc_card *card, int num) |
| 1674 | { | 1654 | { |
| 1655 | struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; | ||
| 1675 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; | 1656 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; |
| 1676 | const char *codecname = aux_dev->codec_name; | 1657 | const char *codecname = aux_dev->codec_name; |
| 1677 | int ret = -ENODEV; | ||
| 1678 | struct snd_soc_codec *codec = soc_find_matching_codec(card, num); | ||
| 1679 | 1658 | ||
| 1680 | if (!codec) { | 1659 | rtd->codec = soc_find_codec(aux_dev->codec_of_node, codecname); |
| 1660 | if (!rtd->codec) { | ||
| 1681 | if (aux_dev->codec_of_node) | 1661 | if (aux_dev->codec_of_node) |
| 1682 | codecname = of_node_full_name(aux_dev->codec_of_node); | 1662 | codecname = of_node_full_name(aux_dev->codec_of_node); |
| 1683 | 1663 | ||
| 1684 | /* codec not found */ | 1664 | dev_err(card->dev, "ASoC: %s not registered\n", codecname); |
| 1685 | dev_err(card->dev, "ASoC: codec %s not found", codecname); | ||
| 1686 | return -EPROBE_DEFER; | 1665 | return -EPROBE_DEFER; |
| 1687 | } | 1666 | } |
| 1688 | 1667 | ||
| 1689 | if (codec->probed) { | 1668 | return 0; |
| 1690 | dev_err(codec->dev, "ASoC: codec already probed"); | 1669 | } |
| 1670 | |||
| 1671 | static int soc_probe_aux_dev(struct snd_soc_card *card, int num) | ||
| 1672 | { | ||
| 1673 | struct snd_soc_pcm_runtime *rtd = &card->rtd_aux[num]; | ||
| 1674 | struct snd_soc_aux_dev *aux_dev = &card->aux_dev[num]; | ||
| 1675 | int ret; | ||
| 1676 | |||
| 1677 | if (rtd->codec->probed) { | ||
| 1678 | dev_err(rtd->codec->dev, "ASoC: codec already probed\n"); | ||
| 1691 | return -EBUSY; | 1679 | return -EBUSY; |
| 1692 | } | 1680 | } |
| 1693 | 1681 | ||
| 1694 | ret = soc_probe_codec(card, codec); | 1682 | ret = soc_probe_codec(card, rtd->codec); |
| 1695 | if (ret < 0) | 1683 | if (ret < 0) |
| 1696 | return ret; | 1684 | return ret; |
| 1697 | 1685 | ||
| 1698 | ret = soc_post_component_init(card, codec, num, 1); | 1686 | /* do machine specific initialization */ |
| 1687 | if (aux_dev->init) { | ||
| 1688 | ret = aux_dev->init(&rtd->codec->dapm); | ||
| 1689 | if (ret < 0) { | ||
| 1690 | dev_err(card->dev, "ASoC: failed to init %s: %d\n", | ||
| 1691 | aux_dev->name, ret); | ||
| 1692 | return ret; | ||
| 1693 | } | ||
| 1694 | } | ||
| 1699 | 1695 | ||
| 1700 | return ret; | 1696 | return soc_post_component_init(rtd, aux_dev->name); |
| 1701 | } | 1697 | } |
| 1702 | 1698 | ||
| 1703 | static void soc_remove_aux_dev(struct snd_soc_card *card, int num) | 1699 | static void soc_remove_aux_dev(struct snd_soc_card *card, int num) |
| @@ -1749,9 +1745,9 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) | |||
| 1749 | goto base_error; | 1745 | goto base_error; |
| 1750 | } | 1746 | } |
| 1751 | 1747 | ||
| 1752 | /* check aux_devs too */ | 1748 | /* bind aux_devs too */ |
| 1753 | for (i = 0; i < card->num_aux_devs; i++) { | 1749 | for (i = 0; i < card->num_aux_devs; i++) { |
| 1754 | ret = soc_check_aux_dev(card, i); | 1750 | ret = soc_bind_aux_dev(card, i); |
| 1755 | if (ret != 0) | 1751 | if (ret != 0) |
| 1756 | goto base_error; | 1752 | goto base_error; |
| 1757 | } | 1753 | } |
| @@ -1849,16 +1845,23 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) | |||
| 1849 | card->num_dapm_routes); | 1845 | card->num_dapm_routes); |
| 1850 | 1846 | ||
| 1851 | for (i = 0; i < card->num_links; i++) { | 1847 | for (i = 0; i < card->num_links; i++) { |
| 1848 | struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; | ||
| 1852 | dai_link = &card->dai_link[i]; | 1849 | dai_link = &card->dai_link[i]; |
| 1853 | dai_fmt = dai_link->dai_fmt; | 1850 | dai_fmt = dai_link->dai_fmt; |
| 1854 | 1851 | ||
| 1855 | if (dai_fmt) { | 1852 | if (dai_fmt) { |
| 1856 | ret = snd_soc_dai_set_fmt(card->rtd[i].codec_dai, | 1853 | struct snd_soc_dai **codec_dais = rtd->codec_dais; |
| 1857 | dai_fmt); | 1854 | int j; |
| 1858 | if (ret != 0 && ret != -ENOTSUPP) | 1855 | |
| 1859 | dev_warn(card->rtd[i].codec_dai->dev, | 1856 | for (j = 0; j < rtd->num_codecs; j++) { |
| 1860 | "ASoC: Failed to set DAI format: %d\n", | 1857 | struct snd_soc_dai *codec_dai = codec_dais[j]; |
| 1861 | ret); | 1858 | |
| 1859 | ret = snd_soc_dai_set_fmt(codec_dai, dai_fmt); | ||
| 1860 | if (ret != 0 && ret != -ENOTSUPP) | ||
| 1861 | dev_warn(codec_dai->dev, | ||
| 1862 | "ASoC: Failed to set DAI format: %d\n", | ||
| 1863 | ret); | ||
| 1864 | } | ||
| 1862 | } | 1865 | } |
| 1863 | 1866 | ||
| 1864 | /* If this is a regular CPU link there will be a platform */ | 1867 | /* If this is a regular CPU link there will be a platform */ |
| @@ -1927,8 +1930,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) | |||
| 1927 | } | 1930 | } |
| 1928 | 1931 | ||
| 1929 | if (card->fully_routed) | 1932 | if (card->fully_routed) |
| 1930 | list_for_each_entry(codec, &card->codec_dev_list, card_list) | 1933 | snd_soc_dapm_auto_nc_pins(card); |
| 1931 | snd_soc_dapm_auto_nc_codec_pins(codec); | ||
| 1932 | 1934 | ||
| 1933 | snd_soc_dapm_new_widgets(card); | 1935 | snd_soc_dapm_new_widgets(card); |
| 1934 | 1936 | ||
| @@ -2058,10 +2060,15 @@ int snd_soc_poweroff(struct device *dev) | |||
| 2058 | 2060 | ||
| 2059 | /* deactivate pins to sleep state */ | 2061 | /* deactivate pins to sleep state */ |
| 2060 | for (i = 0; i < card->num_rtd; i++) { | 2062 | for (i = 0; i < card->num_rtd; i++) { |
| 2061 | struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; | 2063 | struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; |
| 2062 | struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; | 2064 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 2063 | pinctrl_pm_select_sleep_state(codec_dai->dev); | 2065 | int j; |
| 2066 | |||
| 2064 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | 2067 | pinctrl_pm_select_sleep_state(cpu_dai->dev); |
| 2068 | for (j = 0; j < rtd->num_codecs; j++) { | ||
| 2069 | struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; | ||
| 2070 | pinctrl_pm_select_sleep_state(codec_dai->dev); | ||
| 2071 | } | ||
| 2065 | } | 2072 | } |
| 2066 | 2073 | ||
| 2067 | return 0; | 2074 | return 0; |
| @@ -2387,6 +2394,25 @@ struct snd_kcontrol *snd_soc_card_get_kcontrol(struct snd_soc_card *soc_card, | |||
| 2387 | EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); | 2394 | EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); |
| 2388 | 2395 | ||
| 2389 | /** | 2396 | /** |
| 2397 | * snd_soc_add_component_controls - Add an array of controls to a component. | ||
| 2398 | * | ||
| 2399 | * @component: Component to add controls to | ||
| 2400 | * @controls: Array of controls to add | ||
| 2401 | * @num_controls: Number of elements in the array | ||
| 2402 | * | ||
| 2403 | * Return: 0 for success, else error. | ||
| 2404 | */ | ||
| 2405 | int snd_soc_add_component_controls(struct snd_soc_component *component, | ||
| 2406 | const struct snd_kcontrol_new *controls, unsigned int num_controls) | ||
| 2407 | { | ||
| 2408 | struct snd_card *card = component->card->snd_card; | ||
| 2409 | |||
| 2410 | return snd_soc_add_controls(card, component->dev, controls, | ||
| 2411 | num_controls, component->name_prefix, component); | ||
| 2412 | } | ||
| 2413 | EXPORT_SYMBOL_GPL(snd_soc_add_component_controls); | ||
| 2414 | |||
| 2415 | /** | ||
| 2390 | * snd_soc_add_codec_controls - add an array of controls to a codec. | 2416 | * snd_soc_add_codec_controls - add an array of controls to a codec. |
| 2391 | * Convenience function to add a list of controls. Many codecs were | 2417 | * Convenience function to add a list of controls. Many codecs were |
| 2392 | * duplicating this code. | 2418 | * duplicating this code. |
| @@ -2398,12 +2424,10 @@ EXPORT_SYMBOL_GPL(snd_soc_card_get_kcontrol); | |||
| 2398 | * Return 0 for success, else error. | 2424 | * Return 0 for success, else error. |
| 2399 | */ | 2425 | */ |
| 2400 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, | 2426 | int snd_soc_add_codec_controls(struct snd_soc_codec *codec, |
| 2401 | const struct snd_kcontrol_new *controls, int num_controls) | 2427 | const struct snd_kcontrol_new *controls, unsigned int num_controls) |
| 2402 | { | 2428 | { |
| 2403 | struct snd_card *card = codec->card->snd_card; | 2429 | return snd_soc_add_component_controls(&codec->component, controls, |
| 2404 | 2430 | num_controls); | |
| 2405 | return snd_soc_add_controls(card, codec->dev, controls, num_controls, | ||
| 2406 | codec->name_prefix, &codec->component); | ||
| 2407 | } | 2431 | } |
| 2408 | EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); | 2432 | EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); |
| 2409 | 2433 | ||
| @@ -2418,12 +2442,10 @@ EXPORT_SYMBOL_GPL(snd_soc_add_codec_controls); | |||
| 2418 | * Return 0 for success, else error. | 2442 | * Return 0 for success, else error. |
| 2419 | */ | 2443 | */ |
| 2420 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, | 2444 | int snd_soc_add_platform_controls(struct snd_soc_platform *platform, |
| 2421 | const struct snd_kcontrol_new *controls, int num_controls) | 2445 | const struct snd_kcontrol_new *controls, unsigned int num_controls) |
| 2422 | { | 2446 | { |
| 2423 | struct snd_card *card = platform->card->snd_card; | 2447 | return snd_soc_add_component_controls(&platform->component, controls, |
| 2424 | 2448 | num_controls); | |
| 2425 | return snd_soc_add_controls(card, platform->dev, controls, num_controls, | ||
| 2426 | NULL, &platform->component); | ||
| 2427 | } | 2449 | } |
| 2428 | EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); | 2450 | EXPORT_SYMBOL_GPL(snd_soc_add_platform_controls); |
| 2429 | 2451 | ||
| @@ -3095,7 +3117,7 @@ EXPORT_SYMBOL_GPL(snd_soc_get_volsw_range); | |||
| 3095 | int snd_soc_limit_volume(struct snd_soc_codec *codec, | 3117 | int snd_soc_limit_volume(struct snd_soc_codec *codec, |
| 3096 | const char *name, int max) | 3118 | const char *name, int max) |
| 3097 | { | 3119 | { |
| 3098 | struct snd_card *card = codec->card->snd_card; | 3120 | struct snd_card *card = codec->component.card->snd_card; |
| 3099 | struct snd_kcontrol *kctl; | 3121 | struct snd_kcontrol *kctl; |
| 3100 | struct soc_mixer_control *mc; | 3122 | struct soc_mixer_control *mc; |
| 3101 | int found = 0; | 3123 | int found = 0; |
| @@ -3267,6 +3289,27 @@ int snd_soc_bytes_info_ext(struct snd_kcontrol *kcontrol, | |||
| 3267 | } | 3289 | } |
| 3268 | EXPORT_SYMBOL_GPL(snd_soc_bytes_info_ext); | 3290 | EXPORT_SYMBOL_GPL(snd_soc_bytes_info_ext); |
| 3269 | 3291 | ||
| 3292 | int snd_soc_bytes_tlv_callback(struct snd_kcontrol *kcontrol, int op_flag, | ||
| 3293 | unsigned int size, unsigned int __user *tlv) | ||
| 3294 | { | ||
| 3295 | struct soc_bytes_ext *params = (void *)kcontrol->private_value; | ||
| 3296 | unsigned int count = size < params->max ? size : params->max; | ||
| 3297 | int ret = -ENXIO; | ||
| 3298 | |||
| 3299 | switch (op_flag) { | ||
| 3300 | case SNDRV_CTL_TLV_OP_READ: | ||
| 3301 | if (params->get) | ||
| 3302 | ret = params->get(tlv, count); | ||
| 3303 | break; | ||
| 3304 | case SNDRV_CTL_TLV_OP_WRITE: | ||
| 3305 | if (params->put) | ||
| 3306 | ret = params->put(tlv, count); | ||
| 3307 | break; | ||
| 3308 | } | ||
| 3309 | return ret; | ||
| 3310 | } | ||
| 3311 | EXPORT_SYMBOL_GPL(snd_soc_bytes_tlv_callback); | ||
| 3312 | |||
| 3270 | /** | 3313 | /** |
| 3271 | * snd_soc_info_xr_sx - signed multi register info callback | 3314 | * snd_soc_info_xr_sx - signed multi register info callback |
| 3272 | * @kcontrol: mreg control | 3315 | * @kcontrol: mreg control |
| @@ -3641,6 +3684,9 @@ int snd_soc_dai_set_tdm_slot(struct snd_soc_dai *dai, | |||
| 3641 | else | 3684 | else |
| 3642 | snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask); | 3685 | snd_soc_xlate_tdm_slot_mask(slots, &tx_mask, &rx_mask); |
| 3643 | 3686 | ||
| 3687 | dai->tx_mask = tx_mask; | ||
| 3688 | dai->rx_mask = rx_mask; | ||
| 3689 | |||
| 3644 | if (dai->driver && dai->driver->ops->set_tdm_slot) | 3690 | if (dai->driver && dai->driver->ops->set_tdm_slot) |
| 3645 | return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask, | 3691 | return dai->driver->ops->set_tdm_slot(dai, tx_mask, rx_mask, |
| 3646 | slots, slot_width); | 3692 | slots, slot_width); |
| @@ -3713,6 +3759,33 @@ int snd_soc_dai_digital_mute(struct snd_soc_dai *dai, int mute, | |||
| 3713 | } | 3759 | } |
| 3714 | EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); | 3760 | EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); |
| 3715 | 3761 | ||
| 3762 | static int snd_soc_init_multicodec(struct snd_soc_card *card, | ||
| 3763 | struct snd_soc_dai_link *dai_link) | ||
| 3764 | { | ||
| 3765 | /* Legacy codec/codec_dai link is a single entry in multicodec */ | ||
| 3766 | if (dai_link->codec_name || dai_link->codec_of_node || | ||
| 3767 | dai_link->codec_dai_name) { | ||
| 3768 | dai_link->num_codecs = 1; | ||
| 3769 | |||
| 3770 | dai_link->codecs = devm_kzalloc(card->dev, | ||
| 3771 | sizeof(struct snd_soc_dai_link_component), | ||
| 3772 | GFP_KERNEL); | ||
| 3773 | if (!dai_link->codecs) | ||
| 3774 | return -ENOMEM; | ||
| 3775 | |||
| 3776 | dai_link->codecs[0].name = dai_link->codec_name; | ||
| 3777 | dai_link->codecs[0].of_node = dai_link->codec_of_node; | ||
| 3778 | dai_link->codecs[0].dai_name = dai_link->codec_dai_name; | ||
| 3779 | } | ||
| 3780 | |||
| 3781 | if (!dai_link->codecs) { | ||
| 3782 | dev_err(card->dev, "ASoC: DAI link has no CODECs\n"); | ||
| 3783 | return -EINVAL; | ||
| 3784 | } | ||
| 3785 | |||
| 3786 | return 0; | ||
| 3787 | } | ||
| 3788 | |||
| 3716 | /** | 3789 | /** |
| 3717 | * snd_soc_register_card - Register a card with the ASoC core | 3790 | * snd_soc_register_card - Register a card with the ASoC core |
| 3718 | * | 3791 | * |
| @@ -3721,7 +3794,7 @@ EXPORT_SYMBOL_GPL(snd_soc_dai_digital_mute); | |||
| 3721 | */ | 3794 | */ |
| 3722 | int snd_soc_register_card(struct snd_soc_card *card) | 3795 | int snd_soc_register_card(struct snd_soc_card *card) |
| 3723 | { | 3796 | { |
| 3724 | int i, ret; | 3797 | int i, j, ret; |
| 3725 | 3798 | ||
| 3726 | if (!card->name || !card->dev) | 3799 | if (!card->name || !card->dev) |
| 3727 | return -EINVAL; | 3800 | return -EINVAL; |
| @@ -3729,22 +3802,29 @@ int snd_soc_register_card(struct snd_soc_card *card) | |||
| 3729 | for (i = 0; i < card->num_links; i++) { | 3802 | for (i = 0; i < card->num_links; i++) { |
| 3730 | struct snd_soc_dai_link *link = &card->dai_link[i]; | 3803 | struct snd_soc_dai_link *link = &card->dai_link[i]; |
| 3731 | 3804 | ||
| 3732 | /* | 3805 | ret = snd_soc_init_multicodec(card, link); |
| 3733 | * Codec must be specified by 1 of name or OF node, | 3806 | if (ret) { |
| 3734 | * not both or neither. | 3807 | dev_err(card->dev, "ASoC: failed to init multicodec\n"); |
| 3735 | */ | 3808 | return ret; |
| 3736 | if (!!link->codec_name == !!link->codec_of_node) { | ||
| 3737 | dev_err(card->dev, | ||
| 3738 | "ASoC: Neither/both codec name/of_node are set for %s\n", | ||
| 3739 | link->name); | ||
| 3740 | return -EINVAL; | ||
| 3741 | } | 3809 | } |
| 3742 | /* Codec DAI name must be specified */ | 3810 | |
| 3743 | if (!link->codec_dai_name) { | 3811 | for (j = 0; j < link->num_codecs; j++) { |
| 3744 | dev_err(card->dev, | 3812 | /* |
| 3745 | "ASoC: codec_dai_name not set for %s\n", | 3813 | * Codec must be specified by 1 of name or OF node, |
| 3746 | link->name); | 3814 | * not both or neither. |
| 3747 | return -EINVAL; | 3815 | */ |
| 3816 | if (!!link->codecs[j].name == | ||
| 3817 | !!link->codecs[j].of_node) { | ||
| 3818 | dev_err(card->dev, "ASoC: Neither/both codec name/of_node are set for %s\n", | ||
| 3819 | link->name); | ||
| 3820 | return -EINVAL; | ||
| 3821 | } | ||
| 3822 | /* Codec DAI name must be specified */ | ||
| 3823 | if (!link->codecs[j].dai_name) { | ||
| 3824 | dev_err(card->dev, "ASoC: codec_dai_name not set for %s\n", | ||
| 3825 | link->name); | ||
| 3826 | return -EINVAL; | ||
| 3827 | } | ||
| 3748 | } | 3828 | } |
| 3749 | 3829 | ||
| 3750 | /* | 3830 | /* |
| @@ -3797,8 +3877,19 @@ int snd_soc_register_card(struct snd_soc_card *card) | |||
| 3797 | card->num_rtd = 0; | 3877 | card->num_rtd = 0; |
| 3798 | card->rtd_aux = &card->rtd[card->num_links]; | 3878 | card->rtd_aux = &card->rtd[card->num_links]; |
| 3799 | 3879 | ||
| 3800 | for (i = 0; i < card->num_links; i++) | 3880 | for (i = 0; i < card->num_links; i++) { |
| 3881 | card->rtd[i].card = card; | ||
| 3801 | card->rtd[i].dai_link = &card->dai_link[i]; | 3882 | card->rtd[i].dai_link = &card->dai_link[i]; |
| 3883 | card->rtd[i].codec_dais = devm_kzalloc(card->dev, | ||
| 3884 | sizeof(struct snd_soc_dai *) * | ||
| 3885 | (card->rtd[i].dai_link->num_codecs), | ||
| 3886 | GFP_KERNEL); | ||
| 3887 | if (card->rtd[i].codec_dais == NULL) | ||
| 3888 | return -ENOMEM; | ||
| 3889 | } | ||
| 3890 | |||
| 3891 | for (i = 0; i < card->num_aux_devs; i++) | ||
| 3892 | card->rtd_aux[i].card = card; | ||
| 3802 | 3893 | ||
| 3803 | INIT_LIST_HEAD(&card->dapm_dirty); | 3894 | INIT_LIST_HEAD(&card->dapm_dirty); |
| 3804 | card->instantiated = 0; | 3895 | card->instantiated = 0; |
| @@ -3811,10 +3902,16 @@ int snd_soc_register_card(struct snd_soc_card *card) | |||
| 3811 | 3902 | ||
| 3812 | /* deactivate pins to sleep state */ | 3903 | /* deactivate pins to sleep state */ |
| 3813 | for (i = 0; i < card->num_rtd; i++) { | 3904 | for (i = 0; i < card->num_rtd; i++) { |
| 3814 | struct snd_soc_dai *cpu_dai = card->rtd[i].cpu_dai; | 3905 | struct snd_soc_pcm_runtime *rtd = &card->rtd[i]; |
| 3815 | struct snd_soc_dai *codec_dai = card->rtd[i].codec_dai; | 3906 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 3816 | if (!codec_dai->active) | 3907 | int j; |
| 3817 | pinctrl_pm_select_sleep_state(codec_dai->dev); | 3908 | |
| 3909 | for (j = 0; j < rtd->num_codecs; j++) { | ||
| 3910 | struct snd_soc_dai *codec_dai = rtd->codec_dais[j]; | ||
| 3911 | if (!codec_dai->active) | ||
| 3912 | pinctrl_pm_select_sleep_state(codec_dai->dev); | ||
| 3913 | } | ||
| 3914 | |||
| 3818 | if (!cpu_dai->active) | 3915 | if (!cpu_dai->active) |
| 3819 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | 3916 | pinctrl_pm_select_sleep_state(cpu_dai->dev); |
| 3820 | } | 3917 | } |
| @@ -3921,16 +4018,14 @@ static void snd_soc_unregister_dais(struct snd_soc_component *component) | |||
| 3921 | * snd_soc_register_dais - Register a DAI with the ASoC core | 4018 | * snd_soc_register_dais - Register a DAI with the ASoC core |
| 3922 | * | 4019 | * |
| 3923 | * @component: The component the DAIs are registered for | 4020 | * @component: The component the DAIs are registered for |
| 3924 | * @codec: The CODEC that the DAIs are registered for, NULL if the component is | ||
| 3925 | * not a CODEC. | ||
| 3926 | * @dai_drv: DAI driver to use for the DAIs | 4021 | * @dai_drv: DAI driver to use for the DAIs |
| 3927 | * @count: Number of DAIs | 4022 | * @count: Number of DAIs |
| 3928 | * @legacy_dai_naming: Use the legacy naming scheme and let the DAI inherit the | 4023 | * @legacy_dai_naming: Use the legacy naming scheme and let the DAI inherit the |
| 3929 | * parent's name. | 4024 | * parent's name. |
| 3930 | */ | 4025 | */ |
| 3931 | static int snd_soc_register_dais(struct snd_soc_component *component, | 4026 | static int snd_soc_register_dais(struct snd_soc_component *component, |
| 3932 | struct snd_soc_codec *codec, struct snd_soc_dai_driver *dai_drv, | 4027 | struct snd_soc_dai_driver *dai_drv, size_t count, |
| 3933 | size_t count, bool legacy_dai_naming) | 4028 | bool legacy_dai_naming) |
| 3934 | { | 4029 | { |
| 3935 | struct device *dev = component->dev; | 4030 | struct device *dev = component->dev; |
| 3936 | struct snd_soc_dai *dai; | 4031 | struct snd_soc_dai *dai; |
| @@ -3939,6 +4034,9 @@ static int snd_soc_register_dais(struct snd_soc_component *component, | |||
| 3939 | 4034 | ||
| 3940 | dev_dbg(dev, "ASoC: dai register %s #%Zu\n", dev_name(dev), count); | 4035 | dev_dbg(dev, "ASoC: dai register %s #%Zu\n", dev_name(dev), count); |
| 3941 | 4036 | ||
| 4037 | component->dai_drv = dai_drv; | ||
| 4038 | component->num_dai = count; | ||
| 4039 | |||
| 3942 | for (i = 0; i < count; i++) { | 4040 | for (i = 0; i < count; i++) { |
| 3943 | 4041 | ||
| 3944 | dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL); | 4042 | dai = kzalloc(sizeof(struct snd_soc_dai), GFP_KERNEL); |
| @@ -3971,16 +4069,11 @@ static int snd_soc_register_dais(struct snd_soc_component *component, | |||
| 3971 | } | 4069 | } |
| 3972 | 4070 | ||
| 3973 | dai->component = component; | 4071 | dai->component = component; |
| 3974 | dai->codec = codec; | ||
| 3975 | dai->dev = dev; | 4072 | dai->dev = dev; |
| 3976 | dai->driver = &dai_drv[i]; | 4073 | dai->driver = &dai_drv[i]; |
| 3977 | dai->dapm.dev = dev; | ||
| 3978 | if (!dai->driver->ops) | 4074 | if (!dai->driver->ops) |
| 3979 | dai->driver->ops = &null_dai_ops; | 4075 | dai->driver->ops = &null_dai_ops; |
| 3980 | 4076 | ||
| 3981 | if (!dai->codec) | ||
| 3982 | dai->dapm.idle_bias_off = 1; | ||
| 3983 | |||
| 3984 | list_add(&dai->list, &component->dai_list); | 4077 | list_add(&dai->list, &component->dai_list); |
| 3985 | 4078 | ||
| 3986 | dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); | 4079 | dev_dbg(dev, "ASoC: Registered DAI '%s'\n", dai->name); |
| @@ -3994,60 +4087,82 @@ err: | |||
| 3994 | return ret; | 4087 | return ret; |
| 3995 | } | 4088 | } |
| 3996 | 4089 | ||
| 3997 | /** | 4090 | static void snd_soc_component_seq_notifier(struct snd_soc_dapm_context *dapm, |
| 3998 | * snd_soc_register_component - Register a component with the ASoC core | 4091 | enum snd_soc_dapm_type type, int subseq) |
| 3999 | * | ||
| 4000 | */ | ||
| 4001 | static int | ||
| 4002 | __snd_soc_register_component(struct device *dev, | ||
| 4003 | struct snd_soc_component *cmpnt, | ||
| 4004 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 4005 | struct snd_soc_codec *codec, | ||
| 4006 | struct snd_soc_dai_driver *dai_drv, | ||
| 4007 | int num_dai, bool allow_single_dai) | ||
| 4008 | { | 4092 | { |
| 4009 | int ret; | 4093 | struct snd_soc_component *component = dapm->component; |
| 4010 | 4094 | ||
| 4011 | dev_dbg(dev, "component register %s\n", dev_name(dev)); | 4095 | component->driver->seq_notifier(component, type, subseq); |
| 4096 | } | ||
| 4012 | 4097 | ||
| 4013 | if (!cmpnt) { | 4098 | static int snd_soc_component_stream_event(struct snd_soc_dapm_context *dapm, |
| 4014 | dev_err(dev, "ASoC: Failed to connecting component\n"); | 4099 | int event) |
| 4015 | return -ENOMEM; | 4100 | { |
| 4016 | } | 4101 | struct snd_soc_component *component = dapm->component; |
| 4017 | 4102 | ||
| 4018 | mutex_init(&cmpnt->io_mutex); | 4103 | return component->driver->stream_event(component, event); |
| 4104 | } | ||
| 4105 | |||
| 4106 | static int snd_soc_component_initialize(struct snd_soc_component *component, | ||
| 4107 | const struct snd_soc_component_driver *driver, struct device *dev) | ||
| 4108 | { | ||
| 4109 | struct snd_soc_dapm_context *dapm; | ||
| 4019 | 4110 | ||
| 4020 | cmpnt->name = fmt_single_name(dev, &cmpnt->id); | 4111 | component->name = fmt_single_name(dev, &component->id); |
| 4021 | if (!cmpnt->name) { | 4112 | if (!component->name) { |
| 4022 | dev_err(dev, "ASoC: Failed to simplifying name\n"); | 4113 | dev_err(dev, "ASoC: Failed to allocate name\n"); |
| 4023 | return -ENOMEM; | 4114 | return -ENOMEM; |
| 4024 | } | 4115 | } |
| 4025 | 4116 | ||
| 4026 | cmpnt->dev = dev; | 4117 | component->dev = dev; |
| 4027 | cmpnt->driver = cmpnt_drv; | 4118 | component->driver = driver; |
| 4028 | cmpnt->dai_drv = dai_drv; | ||
| 4029 | cmpnt->num_dai = num_dai; | ||
| 4030 | INIT_LIST_HEAD(&cmpnt->dai_list); | ||
| 4031 | 4119 | ||
| 4032 | ret = snd_soc_register_dais(cmpnt, codec, dai_drv, num_dai, | 4120 | if (!component->dapm_ptr) |
| 4033 | allow_single_dai); | 4121 | component->dapm_ptr = &component->dapm; |
| 4034 | if (ret < 0) { | 4122 | |
| 4035 | dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); | 4123 | dapm = component->dapm_ptr; |
| 4036 | goto error_component_name; | 4124 | dapm->dev = dev; |
| 4037 | } | 4125 | dapm->component = component; |
| 4126 | dapm->bias_level = SND_SOC_BIAS_OFF; | ||
| 4127 | if (driver->seq_notifier) | ||
| 4128 | dapm->seq_notifier = snd_soc_component_seq_notifier; | ||
| 4129 | if (driver->stream_event) | ||
| 4130 | dapm->stream_event = snd_soc_component_stream_event; | ||
| 4131 | |||
| 4132 | INIT_LIST_HEAD(&component->dai_list); | ||
| 4133 | mutex_init(&component->io_mutex); | ||
| 4038 | 4134 | ||
| 4135 | return 0; | ||
| 4136 | } | ||
| 4137 | |||
| 4138 | static void snd_soc_component_add_unlocked(struct snd_soc_component *component) | ||
| 4139 | { | ||
| 4140 | list_add(&component->list, &component_list); | ||
| 4141 | } | ||
| 4142 | |||
| 4143 | static void snd_soc_component_add(struct snd_soc_component *component) | ||
| 4144 | { | ||
| 4039 | mutex_lock(&client_mutex); | 4145 | mutex_lock(&client_mutex); |
| 4040 | list_add(&cmpnt->list, &component_list); | 4146 | snd_soc_component_add_unlocked(component); |
| 4041 | mutex_unlock(&client_mutex); | 4147 | mutex_unlock(&client_mutex); |
| 4148 | } | ||
| 4042 | 4149 | ||
| 4043 | dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name); | 4150 | static void snd_soc_component_cleanup(struct snd_soc_component *component) |
| 4044 | 4151 | { | |
| 4045 | return ret; | 4152 | snd_soc_unregister_dais(component); |
| 4153 | kfree(component->name); | ||
| 4154 | } | ||
| 4046 | 4155 | ||
| 4047 | error_component_name: | 4156 | static void snd_soc_component_del_unlocked(struct snd_soc_component *component) |
| 4048 | kfree(cmpnt->name); | 4157 | { |
| 4158 | list_del(&component->list); | ||
| 4159 | } | ||
| 4049 | 4160 | ||
| 4050 | return ret; | 4161 | static void snd_soc_component_del(struct snd_soc_component *component) |
| 4162 | { | ||
| 4163 | mutex_lock(&client_mutex); | ||
| 4164 | snd_soc_component_del_unlocked(component); | ||
| 4165 | mutex_unlock(&client_mutex); | ||
| 4051 | } | 4166 | } |
| 4052 | 4167 | ||
| 4053 | int snd_soc_register_component(struct device *dev, | 4168 | int snd_soc_register_component(struct device *dev, |
| @@ -4056,32 +4171,38 @@ int snd_soc_register_component(struct device *dev, | |||
| 4056 | int num_dai) | 4171 | int num_dai) |
| 4057 | { | 4172 | { |
| 4058 | struct snd_soc_component *cmpnt; | 4173 | struct snd_soc_component *cmpnt; |
| 4174 | int ret; | ||
| 4059 | 4175 | ||
| 4060 | cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL); | 4176 | cmpnt = kzalloc(sizeof(*cmpnt), GFP_KERNEL); |
| 4061 | if (!cmpnt) { | 4177 | if (!cmpnt) { |
| 4062 | dev_err(dev, "ASoC: Failed to allocate memory\n"); | 4178 | dev_err(dev, "ASoC: Failed to allocate memory\n"); |
| 4063 | return -ENOMEM; | 4179 | return -ENOMEM; |
| 4064 | } | 4180 | } |
| 4065 | 4181 | ||
| 4182 | ret = snd_soc_component_initialize(cmpnt, cmpnt_drv, dev); | ||
| 4183 | if (ret) | ||
| 4184 | goto err_free; | ||
| 4185 | |||
| 4066 | cmpnt->ignore_pmdown_time = true; | 4186 | cmpnt->ignore_pmdown_time = true; |
| 4067 | cmpnt->registered_as_component = true; | 4187 | cmpnt->registered_as_component = true; |
| 4068 | 4188 | ||
| 4069 | return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, NULL, | 4189 | ret = snd_soc_register_dais(cmpnt, dai_drv, num_dai, true); |
| 4070 | dai_drv, num_dai, true); | 4190 | if (ret < 0) { |
| 4071 | } | 4191 | dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); |
| 4072 | EXPORT_SYMBOL_GPL(snd_soc_register_component); | 4192 | goto err_cleanup; |
| 4193 | } | ||
| 4073 | 4194 | ||
| 4074 | static void __snd_soc_unregister_component(struct snd_soc_component *cmpnt) | 4195 | snd_soc_component_add(cmpnt); |
| 4075 | { | ||
| 4076 | snd_soc_unregister_dais(cmpnt); | ||
| 4077 | 4196 | ||
| 4078 | mutex_lock(&client_mutex); | 4197 | return 0; |
| 4079 | list_del(&cmpnt->list); | ||
| 4080 | mutex_unlock(&client_mutex); | ||
| 4081 | 4198 | ||
| 4082 | dev_dbg(cmpnt->dev, "ASoC: Unregistered component '%s'\n", cmpnt->name); | 4199 | err_cleanup: |
| 4083 | kfree(cmpnt->name); | 4200 | snd_soc_component_cleanup(cmpnt); |
| 4201 | err_free: | ||
| 4202 | kfree(cmpnt); | ||
| 4203 | return ret; | ||
| 4084 | } | 4204 | } |
| 4205 | EXPORT_SYMBOL_GPL(snd_soc_register_component); | ||
| 4085 | 4206 | ||
| 4086 | /** | 4207 | /** |
| 4087 | * snd_soc_unregister_component - Unregister a component from the ASoC core | 4208 | * snd_soc_unregister_component - Unregister a component from the ASoC core |
| @@ -4098,7 +4219,9 @@ void snd_soc_unregister_component(struct device *dev) | |||
| 4098 | return; | 4219 | return; |
| 4099 | 4220 | ||
| 4100 | found: | 4221 | found: |
| 4101 | __snd_soc_unregister_component(cmpnt); | 4222 | snd_soc_component_del(cmpnt); |
| 4223 | snd_soc_component_cleanup(cmpnt); | ||
| 4224 | kfree(cmpnt); | ||
| 4102 | } | 4225 | } |
| 4103 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); | 4226 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); |
| 4104 | 4227 | ||
| @@ -4131,37 +4254,25 @@ int snd_soc_add_platform(struct device *dev, struct snd_soc_platform *platform, | |||
| 4131 | { | 4254 | { |
| 4132 | int ret; | 4255 | int ret; |
| 4133 | 4256 | ||
| 4134 | /* create platform component name */ | 4257 | ret = snd_soc_component_initialize(&platform->component, |
| 4135 | platform->name = fmt_single_name(dev, &platform->id); | 4258 | &platform_drv->component_driver, dev); |
| 4136 | if (platform->name == NULL) | 4259 | if (ret) |
| 4137 | return -ENOMEM; | 4260 | return ret; |
| 4138 | 4261 | ||
| 4139 | platform->dev = dev; | 4262 | platform->dev = dev; |
| 4140 | platform->driver = platform_drv; | 4263 | platform->driver = platform_drv; |
| 4141 | platform->dapm.dev = dev; | ||
| 4142 | platform->dapm.platform = platform; | ||
| 4143 | platform->dapm.component = &platform->component; | ||
| 4144 | platform->dapm.stream_event = platform_drv->stream_event; | ||
| 4145 | if (platform_drv->write) | 4264 | if (platform_drv->write) |
| 4146 | platform->component.write = snd_soc_platform_drv_write; | 4265 | platform->component.write = snd_soc_platform_drv_write; |
| 4147 | if (platform_drv->read) | 4266 | if (platform_drv->read) |
| 4148 | platform->component.read = snd_soc_platform_drv_read; | 4267 | platform->component.read = snd_soc_platform_drv_read; |
| 4149 | 4268 | ||
| 4150 | /* register component */ | ||
| 4151 | ret = __snd_soc_register_component(dev, &platform->component, | ||
| 4152 | &platform_drv->component_driver, | ||
| 4153 | NULL, NULL, 0, false); | ||
| 4154 | if (ret < 0) { | ||
| 4155 | dev_err(platform->component.dev, | ||
| 4156 | "ASoC: Failed to register component: %d\n", ret); | ||
| 4157 | return ret; | ||
| 4158 | } | ||
| 4159 | |||
| 4160 | mutex_lock(&client_mutex); | 4269 | mutex_lock(&client_mutex); |
| 4270 | snd_soc_component_add_unlocked(&platform->component); | ||
| 4161 | list_add(&platform->list, &platform_list); | 4271 | list_add(&platform->list, &platform_list); |
| 4162 | mutex_unlock(&client_mutex); | 4272 | mutex_unlock(&client_mutex); |
| 4163 | 4273 | ||
| 4164 | dev_dbg(dev, "ASoC: Registered platform '%s'\n", platform->name); | 4274 | dev_dbg(dev, "ASoC: Registered platform '%s'\n", |
| 4275 | platform->component.name); | ||
| 4165 | 4276 | ||
| 4166 | return 0; | 4277 | return 0; |
| 4167 | } | 4278 | } |
| @@ -4198,15 +4309,16 @@ EXPORT_SYMBOL_GPL(snd_soc_register_platform); | |||
| 4198 | */ | 4309 | */ |
| 4199 | void snd_soc_remove_platform(struct snd_soc_platform *platform) | 4310 | void snd_soc_remove_platform(struct snd_soc_platform *platform) |
| 4200 | { | 4311 | { |
| 4201 | __snd_soc_unregister_component(&platform->component); | ||
| 4202 | 4312 | ||
| 4203 | mutex_lock(&client_mutex); | 4313 | mutex_lock(&client_mutex); |
| 4204 | list_del(&platform->list); | 4314 | list_del(&platform->list); |
| 4315 | snd_soc_component_del_unlocked(&platform->component); | ||
| 4205 | mutex_unlock(&client_mutex); | 4316 | mutex_unlock(&client_mutex); |
| 4206 | 4317 | ||
| 4318 | snd_soc_component_cleanup(&platform->component); | ||
| 4319 | |||
| 4207 | dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n", | 4320 | dev_dbg(platform->dev, "ASoC: Unregistered platform '%s'\n", |
| 4208 | platform->name); | 4321 | platform->component.name); |
| 4209 | kfree(platform->name); | ||
| 4210 | } | 4322 | } |
| 4211 | EXPORT_SYMBOL_GPL(snd_soc_remove_platform); | 4323 | EXPORT_SYMBOL_GPL(snd_soc_remove_platform); |
| 4212 | 4324 | ||
| @@ -4292,6 +4404,14 @@ static int snd_soc_codec_drv_read(struct snd_soc_component *component, | |||
| 4292 | return 0; | 4404 | return 0; |
| 4293 | } | 4405 | } |
| 4294 | 4406 | ||
| 4407 | static int snd_soc_codec_set_bias_level(struct snd_soc_dapm_context *dapm, | ||
| 4408 | enum snd_soc_bias_level level) | ||
| 4409 | { | ||
| 4410 | struct snd_soc_codec *codec = snd_soc_dapm_to_codec(dapm); | ||
| 4411 | |||
| 4412 | return codec->driver->set_bias_level(codec, level); | ||
| 4413 | } | ||
| 4414 | |||
| 4295 | /** | 4415 | /** |
| 4296 | * snd_soc_register_codec - Register a codec with the ASoC core | 4416 | * snd_soc_register_codec - Register a codec with the ASoC core |
| 4297 | * | 4417 | * |
| @@ -4303,6 +4423,7 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4303 | int num_dai) | 4423 | int num_dai) |
| 4304 | { | 4424 | { |
| 4305 | struct snd_soc_codec *codec; | 4425 | struct snd_soc_codec *codec; |
| 4426 | struct snd_soc_dai *dai; | ||
| 4306 | struct regmap *regmap; | 4427 | struct regmap *regmap; |
| 4307 | int ret, i; | 4428 | int ret, i; |
| 4308 | 4429 | ||
| @@ -4312,24 +4433,23 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4312 | if (codec == NULL) | 4433 | if (codec == NULL) |
| 4313 | return -ENOMEM; | 4434 | return -ENOMEM; |
| 4314 | 4435 | ||
| 4315 | /* create CODEC component name */ | 4436 | codec->component.dapm_ptr = &codec->dapm; |
| 4316 | codec->name = fmt_single_name(dev, &codec->id); | 4437 | |
| 4317 | if (codec->name == NULL) { | 4438 | ret = snd_soc_component_initialize(&codec->component, |
| 4318 | ret = -ENOMEM; | 4439 | &codec_drv->component_driver, dev); |
| 4319 | goto fail_codec; | 4440 | if (ret) |
| 4320 | } | 4441 | goto err_free; |
| 4321 | 4442 | ||
| 4322 | if (codec_drv->write) | 4443 | if (codec_drv->write) |
| 4323 | codec->component.write = snd_soc_codec_drv_write; | 4444 | codec->component.write = snd_soc_codec_drv_write; |
| 4324 | if (codec_drv->read) | 4445 | if (codec_drv->read) |
| 4325 | codec->component.read = snd_soc_codec_drv_read; | 4446 | codec->component.read = snd_soc_codec_drv_read; |
| 4326 | codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; | 4447 | codec->component.ignore_pmdown_time = codec_drv->ignore_pmdown_time; |
| 4327 | codec->dapm.bias_level = SND_SOC_BIAS_OFF; | ||
| 4328 | codec->dapm.dev = dev; | ||
| 4329 | codec->dapm.codec = codec; | 4448 | codec->dapm.codec = codec; |
| 4330 | codec->dapm.component = &codec->component; | 4449 | if (codec_drv->seq_notifier) |
| 4331 | codec->dapm.seq_notifier = codec_drv->seq_notifier; | 4450 | codec->dapm.seq_notifier = codec_drv->seq_notifier; |
| 4332 | codec->dapm.stream_event = codec_drv->stream_event; | 4451 | if (codec_drv->set_bias_level) |
| 4452 | codec->dapm.set_bias_level = snd_soc_codec_set_bias_level; | ||
| 4333 | codec->dev = dev; | 4453 | codec->dev = dev; |
| 4334 | codec->driver = codec_drv; | 4454 | codec->driver = codec_drv; |
| 4335 | codec->component.val_bytes = codec_drv->reg_word_size; | 4455 | codec->component.val_bytes = codec_drv->reg_word_size; |
| @@ -4348,7 +4468,7 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4348 | dev_err(codec->dev, | 4468 | dev_err(codec->dev, |
| 4349 | "Failed to set cache I/O:%d\n", | 4469 | "Failed to set cache I/O:%d\n", |
| 4350 | ret); | 4470 | ret); |
| 4351 | return ret; | 4471 | goto err_cleanup; |
| 4352 | } | 4472 | } |
| 4353 | } | 4473 | } |
| 4354 | } | 4474 | } |
| @@ -4358,29 +4478,27 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4358 | fixup_codec_formats(&dai_drv[i].capture); | 4478 | fixup_codec_formats(&dai_drv[i].capture); |
| 4359 | } | 4479 | } |
| 4360 | 4480 | ||
| 4361 | mutex_lock(&client_mutex); | 4481 | ret = snd_soc_register_dais(&codec->component, dai_drv, num_dai, false); |
| 4362 | list_add(&codec->list, &codec_list); | ||
| 4363 | mutex_unlock(&client_mutex); | ||
| 4364 | |||
| 4365 | /* register component */ | ||
| 4366 | ret = __snd_soc_register_component(dev, &codec->component, | ||
| 4367 | &codec_drv->component_driver, | ||
| 4368 | codec, dai_drv, num_dai, false); | ||
| 4369 | if (ret < 0) { | 4482 | if (ret < 0) { |
| 4370 | dev_err(codec->dev, "ASoC: Failed to regster component: %d\n", ret); | 4483 | dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); |
| 4371 | goto fail_codec_name; | 4484 | goto err_cleanup; |
| 4372 | } | 4485 | } |
| 4373 | 4486 | ||
| 4374 | dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", codec->name); | 4487 | list_for_each_entry(dai, &codec->component.dai_list, list) |
| 4375 | return 0; | 4488 | dai->codec = codec; |
| 4376 | 4489 | ||
| 4377 | fail_codec_name: | ||
| 4378 | mutex_lock(&client_mutex); | 4490 | mutex_lock(&client_mutex); |
| 4379 | list_del(&codec->list); | 4491 | snd_soc_component_add_unlocked(&codec->component); |
| 4492 | list_add(&codec->list, &codec_list); | ||
| 4380 | mutex_unlock(&client_mutex); | 4493 | mutex_unlock(&client_mutex); |
| 4381 | 4494 | ||
| 4382 | kfree(codec->name); | 4495 | dev_dbg(codec->dev, "ASoC: Registered codec '%s'\n", |
| 4383 | fail_codec: | 4496 | codec->component.name); |
| 4497 | return 0; | ||
| 4498 | |||
| 4499 | err_cleanup: | ||
| 4500 | snd_soc_component_cleanup(&codec->component); | ||
| 4501 | err_free: | ||
| 4384 | kfree(codec); | 4502 | kfree(codec); |
| 4385 | return ret; | 4503 | return ret; |
| 4386 | } | 4504 | } |
| @@ -4402,16 +4520,17 @@ void snd_soc_unregister_codec(struct device *dev) | |||
| 4402 | return; | 4520 | return; |
| 4403 | 4521 | ||
| 4404 | found: | 4522 | found: |
| 4405 | __snd_soc_unregister_component(&codec->component); | ||
| 4406 | 4523 | ||
| 4407 | mutex_lock(&client_mutex); | 4524 | mutex_lock(&client_mutex); |
| 4408 | list_del(&codec->list); | 4525 | list_del(&codec->list); |
| 4526 | snd_soc_component_del_unlocked(&codec->component); | ||
| 4409 | mutex_unlock(&client_mutex); | 4527 | mutex_unlock(&client_mutex); |
| 4410 | 4528 | ||
| 4411 | dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name); | 4529 | dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", |
| 4530 | codec->component.name); | ||
| 4412 | 4531 | ||
| 4532 | snd_soc_component_cleanup(&codec->component); | ||
| 4413 | snd_soc_cache_exit(codec); | 4533 | snd_soc_cache_exit(codec); |
| 4414 | kfree(codec->name); | ||
| 4415 | kfree(codec); | 4534 | kfree(codec); |
| 4416 | } | 4535 | } |
| 4417 | EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); | 4536 | EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); |
| @@ -4420,9 +4539,16 @@ EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); | |||
| 4420 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, | 4539 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, |
| 4421 | const char *propname) | 4540 | const char *propname) |
| 4422 | { | 4541 | { |
| 4423 | struct device_node *np = card->dev->of_node; | 4542 | struct device_node *np; |
| 4424 | int ret; | 4543 | int ret; |
| 4425 | 4544 | ||
| 4545 | if (!card->dev) { | ||
| 4546 | pr_err("card->dev is not set before calling %s\n", __func__); | ||
| 4547 | return -EINVAL; | ||
| 4548 | } | ||
| 4549 | |||
| 4550 | np = card->dev->of_node; | ||
| 4551 | |||
| 4426 | ret = of_property_read_string_index(np, propname, 0, &card->name); | 4552 | ret = of_property_read_string_index(np, propname, 0, &card->name); |
| 4427 | /* | 4553 | /* |
| 4428 | * EINVAL means the property does not exist. This is fine providing | 4554 | * EINVAL means the property does not exist. This is fine providing |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index cdc837ed144d..8348352dc2c6 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -350,12 +350,27 @@ static bool dapm_kcontrol_set_value(const struct snd_kcontrol *kcontrol, | |||
| 350 | } | 350 | } |
| 351 | 351 | ||
| 352 | /** | 352 | /** |
| 353 | * snd_soc_dapm_kcontrol_dapm() - Returns the dapm context associated to a | ||
| 354 | * kcontrol | ||
| 355 | * @kcontrol: The kcontrol | ||
| 356 | * | ||
| 357 | * Note: This function must only be used on kcontrols that are known to have | ||
| 358 | * been registered for a CODEC. Otherwise the behaviour is undefined. | ||
| 359 | */ | ||
| 360 | struct snd_soc_dapm_context *snd_soc_dapm_kcontrol_dapm( | ||
| 361 | struct snd_kcontrol *kcontrol) | ||
| 362 | { | ||
| 363 | return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->dapm; | ||
| 364 | } | ||
| 365 | EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_dapm); | ||
| 366 | |||
| 367 | /** | ||
| 353 | * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol | 368 | * snd_soc_dapm_kcontrol_codec() - Returns the codec associated to a kcontrol |
| 354 | * @kcontrol: The kcontrol | 369 | * @kcontrol: The kcontrol |
| 355 | */ | 370 | */ |
| 356 | struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol) | 371 | struct snd_soc_codec *snd_soc_dapm_kcontrol_codec(struct snd_kcontrol *kcontrol) |
| 357 | { | 372 | { |
| 358 | return dapm_kcontrol_get_wlist(kcontrol)->widgets[0]->codec; | 373 | return snd_soc_dapm_to_codec(snd_soc_dapm_kcontrol_dapm(kcontrol)); |
| 359 | } | 374 | } |
| 360 | EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_codec); | 375 | EXPORT_SYMBOL_GPL(snd_soc_dapm_kcontrol_codec); |
| 361 | 376 | ||
| @@ -375,23 +390,38 @@ static void dapm_reset(struct snd_soc_card *card) | |||
| 375 | } | 390 | } |
| 376 | } | 391 | } |
| 377 | 392 | ||
| 378 | static int soc_widget_read(struct snd_soc_dapm_widget *w, int reg, | 393 | static const char *soc_dapm_prefix(struct snd_soc_dapm_context *dapm) |
| 394 | { | ||
| 395 | if (!dapm->component) | ||
| 396 | return NULL; | ||
| 397 | return dapm->component->name_prefix; | ||
| 398 | } | ||
| 399 | |||
| 400 | static int soc_dapm_read(struct snd_soc_dapm_context *dapm, int reg, | ||
| 379 | unsigned int *value) | 401 | unsigned int *value) |
| 380 | { | 402 | { |
| 381 | if (!w->dapm->component) | 403 | if (!dapm->component) |
| 382 | return -EIO; | 404 | return -EIO; |
| 383 | return snd_soc_component_read(w->dapm->component, reg, value); | 405 | return snd_soc_component_read(dapm->component, reg, value); |
| 384 | } | 406 | } |
| 385 | 407 | ||
| 386 | static int soc_widget_update_bits(struct snd_soc_dapm_widget *w, | 408 | static int soc_dapm_update_bits(struct snd_soc_dapm_context *dapm, |
| 387 | int reg, unsigned int mask, unsigned int value) | 409 | int reg, unsigned int mask, unsigned int value) |
| 388 | { | 410 | { |
| 389 | if (!w->dapm->component) | 411 | if (!dapm->component) |
| 390 | return -EIO; | 412 | return -EIO; |
| 391 | return snd_soc_component_update_bits_async(w->dapm->component, reg, | 413 | return snd_soc_component_update_bits_async(dapm->component, reg, |
| 392 | mask, value); | 414 | mask, value); |
| 393 | } | 415 | } |
| 394 | 416 | ||
| 417 | static int soc_dapm_test_bits(struct snd_soc_dapm_context *dapm, | ||
| 418 | int reg, unsigned int mask, unsigned int value) | ||
| 419 | { | ||
| 420 | if (!dapm->component) | ||
| 421 | return -EIO; | ||
| 422 | return snd_soc_component_test_bits(dapm->component, reg, mask, value); | ||
| 423 | } | ||
| 424 | |||
| 395 | static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) | 425 | static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) |
| 396 | { | 426 | { |
| 397 | if (dapm->component) | 427 | if (dapm->component) |
| @@ -420,15 +450,10 @@ static int snd_soc_dapm_set_bias_level(struct snd_soc_dapm_context *dapm, | |||
| 420 | if (ret != 0) | 450 | if (ret != 0) |
| 421 | goto out; | 451 | goto out; |
| 422 | 452 | ||
| 423 | if (dapm->codec) { | 453 | if (dapm->set_bias_level) |
| 424 | if (dapm->codec->driver->set_bias_level) | 454 | ret = dapm->set_bias_level(dapm, level); |
| 425 | ret = dapm->codec->driver->set_bias_level(dapm->codec, | 455 | else if (!card || dapm != &card->dapm) |
| 426 | level); | ||
| 427 | else | ||
| 428 | dapm->bias_level = level; | ||
| 429 | } else if (!card || dapm != &card->dapm) { | ||
| 430 | dapm->bias_level = level; | 456 | dapm->bias_level = level; |
| 431 | } | ||
| 432 | 457 | ||
| 433 | if (ret != 0) | 458 | if (ret != 0) |
| 434 | goto out; | 459 | goto out; |
| @@ -452,7 +477,7 @@ static int dapm_connect_mux(struct snd_soc_dapm_context *dapm, | |||
| 452 | int i; | 477 | int i; |
| 453 | 478 | ||
| 454 | if (e->reg != SND_SOC_NOPM) { | 479 | if (e->reg != SND_SOC_NOPM) { |
| 455 | soc_widget_read(dest, e->reg, &val); | 480 | soc_dapm_read(dapm, e->reg, &val); |
| 456 | val = (val >> e->shift_l) & e->mask; | 481 | val = (val >> e->shift_l) & e->mask; |
| 457 | item = snd_soc_enum_val_to_item(e, val); | 482 | item = snd_soc_enum_val_to_item(e, val); |
| 458 | } else { | 483 | } else { |
| @@ -496,7 +521,7 @@ static void dapm_set_mixer_path_status(struct snd_soc_dapm_widget *w, | |||
| 496 | unsigned int val; | 521 | unsigned int val; |
| 497 | 522 | ||
| 498 | if (reg != SND_SOC_NOPM) { | 523 | if (reg != SND_SOC_NOPM) { |
| 499 | soc_widget_read(w, reg, &val); | 524 | soc_dapm_read(w->dapm, reg, &val); |
| 500 | val = (val >> shift) & mask; | 525 | val = (val >> shift) & mask; |
| 501 | if (invert) | 526 | if (invert) |
| 502 | val = max - val; | 527 | val = max - val; |
| @@ -570,11 +595,7 @@ static int dapm_create_or_share_mixmux_kcontrol(struct snd_soc_dapm_widget *w, | |||
| 570 | const char *name; | 595 | const char *name; |
| 571 | int ret; | 596 | int ret; |
| 572 | 597 | ||
| 573 | if (dapm->codec) | 598 | prefix = soc_dapm_prefix(dapm); |
| 574 | prefix = dapm->codec->name_prefix; | ||
| 575 | else | ||
| 576 | prefix = NULL; | ||
| 577 | |||
| 578 | if (prefix) | 599 | if (prefix) |
| 579 | prefix_len = strlen(prefix) + 1; | 600 | prefix_len = strlen(prefix) + 1; |
| 580 | else | 601 | else |
| @@ -1308,16 +1329,18 @@ static void dapm_seq_check_event(struct snd_soc_card *card, | |||
| 1308 | static void dapm_seq_run_coalesced(struct snd_soc_card *card, | 1329 | static void dapm_seq_run_coalesced(struct snd_soc_card *card, |
| 1309 | struct list_head *pending) | 1330 | struct list_head *pending) |
| 1310 | { | 1331 | { |
| 1332 | struct snd_soc_dapm_context *dapm; | ||
| 1311 | struct snd_soc_dapm_widget *w; | 1333 | struct snd_soc_dapm_widget *w; |
| 1312 | int reg; | 1334 | int reg; |
| 1313 | unsigned int value = 0; | 1335 | unsigned int value = 0; |
| 1314 | unsigned int mask = 0; | 1336 | unsigned int mask = 0; |
| 1315 | 1337 | ||
| 1316 | reg = list_first_entry(pending, struct snd_soc_dapm_widget, | 1338 | w = list_first_entry(pending, struct snd_soc_dapm_widget, power_list); |
| 1317 | power_list)->reg; | 1339 | reg = w->reg; |
| 1340 | dapm = w->dapm; | ||
| 1318 | 1341 | ||
| 1319 | list_for_each_entry(w, pending, power_list) { | 1342 | list_for_each_entry(w, pending, power_list) { |
| 1320 | WARN_ON(reg != w->reg); | 1343 | WARN_ON(reg != w->reg || dapm != w->dapm); |
| 1321 | w->power = w->new_power; | 1344 | w->power = w->new_power; |
| 1322 | 1345 | ||
| 1323 | mask |= w->mask << w->shift; | 1346 | mask |= w->mask << w->shift; |
| @@ -1326,7 +1349,7 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card, | |||
| 1326 | else | 1349 | else |
| 1327 | value |= w->off_val << w->shift; | 1350 | value |= w->off_val << w->shift; |
| 1328 | 1351 | ||
| 1329 | pop_dbg(w->dapm->dev, card->pop_time, | 1352 | pop_dbg(dapm->dev, card->pop_time, |
| 1330 | "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n", | 1353 | "pop test : Queue %s: reg=0x%x, 0x%x/0x%x\n", |
| 1331 | w->name, reg, value, mask); | 1354 | w->name, reg, value, mask); |
| 1332 | 1355 | ||
| @@ -1339,14 +1362,12 @@ static void dapm_seq_run_coalesced(struct snd_soc_card *card, | |||
| 1339 | /* Any widget will do, they should all be updating the | 1362 | /* Any widget will do, they should all be updating the |
| 1340 | * same register. | 1363 | * same register. |
| 1341 | */ | 1364 | */ |
| 1342 | w = list_first_entry(pending, struct snd_soc_dapm_widget, | ||
| 1343 | power_list); | ||
| 1344 | 1365 | ||
| 1345 | pop_dbg(w->dapm->dev, card->pop_time, | 1366 | pop_dbg(dapm->dev, card->pop_time, |
| 1346 | "pop test : Applying 0x%x/0x%x to %x in %dms\n", | 1367 | "pop test : Applying 0x%x/0x%x to %x in %dms\n", |
| 1347 | value, mask, reg, card->pop_time); | 1368 | value, mask, reg, card->pop_time); |
| 1348 | pop_wait(card->pop_time); | 1369 | pop_wait(card->pop_time); |
| 1349 | soc_widget_update_bits(w, reg, mask, value); | 1370 | soc_dapm_update_bits(dapm, reg, mask, value); |
| 1350 | } | 1371 | } |
| 1351 | 1372 | ||
| 1352 | list_for_each_entry(w, pending, power_list) { | 1373 | list_for_each_entry(w, pending, power_list) { |
| @@ -1492,7 +1513,8 @@ static void dapm_widget_update(struct snd_soc_card *card) | |||
| 1492 | if (!w) | 1513 | if (!w) |
| 1493 | return; | 1514 | return; |
| 1494 | 1515 | ||
| 1495 | ret = soc_widget_update_bits(w, update->reg, update->mask, update->val); | 1516 | ret = soc_dapm_update_bits(w->dapm, update->reg, update->mask, |
| 1517 | update->val); | ||
| 1496 | if (ret < 0) | 1518 | if (ret < 0) |
| 1497 | dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", | 1519 | dev_err(w->dapm->dev, "ASoC: %s DAPM update failed: %d\n", |
| 1498 | w->name, ret); | 1520 | w->name, ret); |
| @@ -2062,17 +2084,13 @@ int snd_soc_dapm_mixer_update_power(struct snd_soc_dapm_context *dapm, | |||
| 2062 | } | 2084 | } |
| 2063 | EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power); | 2085 | EXPORT_SYMBOL_GPL(snd_soc_dapm_mixer_update_power); |
| 2064 | 2086 | ||
| 2065 | /* show dapm widget status in sys fs */ | 2087 | static ssize_t dapm_widget_show_codec(struct snd_soc_codec *codec, char *buf) |
| 2066 | static ssize_t dapm_widget_show(struct device *dev, | ||
| 2067 | struct device_attribute *attr, char *buf) | ||
| 2068 | { | 2088 | { |
| 2069 | struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); | ||
| 2070 | struct snd_soc_codec *codec =rtd->codec; | ||
| 2071 | struct snd_soc_dapm_widget *w; | 2089 | struct snd_soc_dapm_widget *w; |
| 2072 | int count = 0; | 2090 | int count = 0; |
| 2073 | char *state = "not set"; | 2091 | char *state = "not set"; |
| 2074 | 2092 | ||
| 2075 | list_for_each_entry(w, &codec->card->widgets, list) { | 2093 | list_for_each_entry(w, &codec->component.card->widgets, list) { |
| 2076 | if (w->dapm != &codec->dapm) | 2094 | if (w->dapm != &codec->dapm) |
| 2077 | continue; | 2095 | continue; |
| 2078 | 2096 | ||
| @@ -2120,6 +2138,21 @@ static ssize_t dapm_widget_show(struct device *dev, | |||
| 2120 | return count; | 2138 | return count; |
| 2121 | } | 2139 | } |
| 2122 | 2140 | ||
| 2141 | /* show dapm widget status in sys fs */ | ||
| 2142 | static ssize_t dapm_widget_show(struct device *dev, | ||
| 2143 | struct device_attribute *attr, char *buf) | ||
| 2144 | { | ||
| 2145 | struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); | ||
| 2146 | int i, count = 0; | ||
| 2147 | |||
| 2148 | for (i = 0; i < rtd->num_codecs; i++) { | ||
| 2149 | struct snd_soc_codec *codec = rtd->codec_dais[i]->codec; | ||
| 2150 | count += dapm_widget_show_codec(codec, buf + count); | ||
| 2151 | } | ||
| 2152 | |||
| 2153 | return count; | ||
| 2154 | } | ||
| 2155 | |||
| 2123 | static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); | 2156 | static DEVICE_ATTR(dapm_widget, 0444, dapm_widget_show, NULL); |
| 2124 | 2157 | ||
| 2125 | int snd_soc_dapm_sys_add(struct device *dev) | 2158 | int snd_soc_dapm_sys_add(struct device *dev) |
| @@ -2371,14 +2404,16 @@ static int snd_soc_dapm_add_route(struct snd_soc_dapm_context *dapm, | |||
| 2371 | const char *source; | 2404 | const char *source; |
| 2372 | char prefixed_sink[80]; | 2405 | char prefixed_sink[80]; |
| 2373 | char prefixed_source[80]; | 2406 | char prefixed_source[80]; |
| 2407 | const char *prefix; | ||
| 2374 | int ret; | 2408 | int ret; |
| 2375 | 2409 | ||
| 2376 | if (dapm->codec && dapm->codec->name_prefix) { | 2410 | prefix = soc_dapm_prefix(dapm); |
| 2411 | if (prefix) { | ||
| 2377 | snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", | 2412 | snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", |
| 2378 | dapm->codec->name_prefix, route->sink); | 2413 | prefix, route->sink); |
| 2379 | sink = prefixed_sink; | 2414 | sink = prefixed_sink; |
| 2380 | snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", | 2415 | snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", |
| 2381 | dapm->codec->name_prefix, route->source); | 2416 | prefix, route->source); |
| 2382 | source = prefixed_source; | 2417 | source = prefixed_source; |
| 2383 | } else { | 2418 | } else { |
| 2384 | sink = route->sink; | 2419 | sink = route->sink; |
| @@ -2439,6 +2474,7 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, | |||
| 2439 | const char *source; | 2474 | const char *source; |
| 2440 | char prefixed_sink[80]; | 2475 | char prefixed_sink[80]; |
| 2441 | char prefixed_source[80]; | 2476 | char prefixed_source[80]; |
| 2477 | const char *prefix; | ||
| 2442 | 2478 | ||
| 2443 | if (route->control) { | 2479 | if (route->control) { |
| 2444 | dev_err(dapm->dev, | 2480 | dev_err(dapm->dev, |
| @@ -2446,12 +2482,13 @@ static int snd_soc_dapm_del_route(struct snd_soc_dapm_context *dapm, | |||
| 2446 | return -EINVAL; | 2482 | return -EINVAL; |
| 2447 | } | 2483 | } |
| 2448 | 2484 | ||
| 2449 | if (dapm->codec && dapm->codec->name_prefix) { | 2485 | prefix = soc_dapm_prefix(dapm); |
| 2486 | if (prefix) { | ||
| 2450 | snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", | 2487 | snprintf(prefixed_sink, sizeof(prefixed_sink), "%s %s", |
| 2451 | dapm->codec->name_prefix, route->sink); | 2488 | prefix, route->sink); |
| 2452 | sink = prefixed_sink; | 2489 | sink = prefixed_sink; |
| 2453 | snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", | 2490 | snprintf(prefixed_source, sizeof(prefixed_source), "%s %s", |
| 2454 | dapm->codec->name_prefix, route->source); | 2491 | prefix, route->source); |
| 2455 | source = prefixed_source; | 2492 | source = prefixed_source; |
| 2456 | } else { | 2493 | } else { |
| 2457 | sink = route->sink; | 2494 | sink = route->sink; |
| @@ -2670,7 +2707,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) | |||
| 2670 | 2707 | ||
| 2671 | /* Read the initial power state from the device */ | 2708 | /* Read the initial power state from the device */ |
| 2672 | if (w->reg >= 0) { | 2709 | if (w->reg >= 0) { |
| 2673 | soc_widget_read(w, w->reg, &val); | 2710 | soc_dapm_read(w->dapm, w->reg, &val); |
| 2674 | val = val >> w->shift; | 2711 | val = val >> w->shift; |
| 2675 | val &= w->mask; | 2712 | val &= w->mask; |
| 2676 | if (val == w->on_val) | 2713 | if (val == w->on_val) |
| @@ -2701,8 +2738,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_new_widgets); | |||
| 2701 | int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | 2738 | int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, |
| 2702 | struct snd_ctl_elem_value *ucontrol) | 2739 | struct snd_ctl_elem_value *ucontrol) |
| 2703 | { | 2740 | { |
| 2704 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | 2741 | struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); |
| 2705 | struct snd_soc_card *card = codec->card; | 2742 | struct snd_soc_card *card = dapm->card; |
| 2706 | struct soc_mixer_control *mc = | 2743 | struct soc_mixer_control *mc = |
| 2707 | (struct soc_mixer_control *)kcontrol->private_value; | 2744 | (struct soc_mixer_control *)kcontrol->private_value; |
| 2708 | int reg = mc->reg; | 2745 | int reg = mc->reg; |
| @@ -2711,17 +2748,20 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |||
| 2711 | unsigned int mask = (1 << fls(max)) - 1; | 2748 | unsigned int mask = (1 << fls(max)) - 1; |
| 2712 | unsigned int invert = mc->invert; | 2749 | unsigned int invert = mc->invert; |
| 2713 | unsigned int val; | 2750 | unsigned int val; |
| 2751 | int ret = 0; | ||
| 2714 | 2752 | ||
| 2715 | if (snd_soc_volsw_is_stereo(mc)) | 2753 | if (snd_soc_volsw_is_stereo(mc)) |
| 2716 | dev_warn(codec->dapm.dev, | 2754 | dev_warn(dapm->dev, |
| 2717 | "ASoC: Control '%s' is stereo, which is not supported\n", | 2755 | "ASoC: Control '%s' is stereo, which is not supported\n", |
| 2718 | kcontrol->id.name); | 2756 | kcontrol->id.name); |
| 2719 | 2757 | ||
| 2720 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); | 2758 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); |
| 2721 | if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) | 2759 | if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) { |
| 2722 | val = (snd_soc_read(codec, reg) >> shift) & mask; | 2760 | ret = soc_dapm_read(dapm, reg, &val); |
| 2723 | else | 2761 | val = (val >> shift) & mask; |
| 2762 | } else { | ||
| 2724 | val = dapm_kcontrol_get_value(kcontrol); | 2763 | val = dapm_kcontrol_get_value(kcontrol); |
| 2764 | } | ||
| 2725 | mutex_unlock(&card->dapm_mutex); | 2765 | mutex_unlock(&card->dapm_mutex); |
| 2726 | 2766 | ||
| 2727 | if (invert) | 2767 | if (invert) |
| @@ -2729,7 +2769,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |||
| 2729 | else | 2769 | else |
| 2730 | ucontrol->value.integer.value[0] = val; | 2770 | ucontrol->value.integer.value[0] = val; |
| 2731 | 2771 | ||
| 2732 | return 0; | 2772 | return ret; |
| 2733 | } | 2773 | } |
| 2734 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); | 2774 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); |
| 2735 | 2775 | ||
| @@ -2745,8 +2785,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_volsw); | |||
| 2745 | int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | 2785 | int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, |
| 2746 | struct snd_ctl_elem_value *ucontrol) | 2786 | struct snd_ctl_elem_value *ucontrol) |
| 2747 | { | 2787 | { |
| 2748 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | 2788 | struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); |
| 2749 | struct snd_soc_card *card = codec->card; | 2789 | struct snd_soc_card *card = dapm->card; |
| 2750 | struct soc_mixer_control *mc = | 2790 | struct soc_mixer_control *mc = |
| 2751 | (struct soc_mixer_control *)kcontrol->private_value; | 2791 | (struct soc_mixer_control *)kcontrol->private_value; |
| 2752 | int reg = mc->reg; | 2792 | int reg = mc->reg; |
| @@ -2760,7 +2800,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
| 2760 | int ret = 0; | 2800 | int ret = 0; |
| 2761 | 2801 | ||
| 2762 | if (snd_soc_volsw_is_stereo(mc)) | 2802 | if (snd_soc_volsw_is_stereo(mc)) |
| 2763 | dev_warn(codec->dapm.dev, | 2803 | dev_warn(dapm->dev, |
| 2764 | "ASoC: Control '%s' is stereo, which is not supported\n", | 2804 | "ASoC: Control '%s' is stereo, which is not supported\n", |
| 2765 | kcontrol->id.name); | 2805 | kcontrol->id.name); |
| 2766 | 2806 | ||
| @@ -2778,7 +2818,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
| 2778 | mask = mask << shift; | 2818 | mask = mask << shift; |
| 2779 | val = val << shift; | 2819 | val = val << shift; |
| 2780 | 2820 | ||
| 2781 | reg_change = snd_soc_test_bits(codec, reg, mask, val); | 2821 | reg_change = soc_dapm_test_bits(dapm, reg, mask, val); |
| 2782 | } | 2822 | } |
| 2783 | 2823 | ||
| 2784 | if (change || reg_change) { | 2824 | if (change || reg_change) { |
| @@ -2817,12 +2857,13 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_put_volsw); | |||
| 2817 | int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, | 2857 | int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, |
| 2818 | struct snd_ctl_elem_value *ucontrol) | 2858 | struct snd_ctl_elem_value *ucontrol) |
| 2819 | { | 2859 | { |
| 2820 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | 2860 | struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); |
| 2821 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 2861 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
| 2822 | unsigned int reg_val, val; | 2862 | unsigned int reg_val, val; |
| 2863 | int ret = 0; | ||
| 2823 | 2864 | ||
| 2824 | if (e->reg != SND_SOC_NOPM) | 2865 | if (e->reg != SND_SOC_NOPM) |
| 2825 | reg_val = snd_soc_read(codec, e->reg); | 2866 | ret = soc_dapm_read(dapm, e->reg, ®_val); |
| 2826 | else | 2867 | else |
| 2827 | reg_val = dapm_kcontrol_get_value(kcontrol); | 2868 | reg_val = dapm_kcontrol_get_value(kcontrol); |
| 2828 | 2869 | ||
| @@ -2834,7 +2875,7 @@ int snd_soc_dapm_get_enum_double(struct snd_kcontrol *kcontrol, | |||
| 2834 | ucontrol->value.enumerated.item[1] = val; | 2875 | ucontrol->value.enumerated.item[1] = val; |
| 2835 | } | 2876 | } |
| 2836 | 2877 | ||
| 2837 | return 0; | 2878 | return ret; |
| 2838 | } | 2879 | } |
| 2839 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); | 2880 | EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); |
| 2840 | 2881 | ||
| @@ -2850,8 +2891,8 @@ EXPORT_SYMBOL_GPL(snd_soc_dapm_get_enum_double); | |||
| 2850 | int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, | 2891 | int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, |
| 2851 | struct snd_ctl_elem_value *ucontrol) | 2892 | struct snd_ctl_elem_value *ucontrol) |
| 2852 | { | 2893 | { |
| 2853 | struct snd_soc_codec *codec = snd_soc_dapm_kcontrol_codec(kcontrol); | 2894 | struct snd_soc_dapm_context *dapm = snd_soc_dapm_kcontrol_dapm(kcontrol); |
| 2854 | struct snd_soc_card *card = codec->card; | 2895 | struct snd_soc_card *card = dapm->card; |
| 2855 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; | 2896 | struct soc_enum *e = (struct soc_enum *)kcontrol->private_value; |
| 2856 | unsigned int *item = ucontrol->value.enumerated.item; | 2897 | unsigned int *item = ucontrol->value.enumerated.item; |
| 2857 | unsigned int val, change; | 2898 | unsigned int val, change; |
| @@ -2874,7 +2915,7 @@ int snd_soc_dapm_put_enum_double(struct snd_kcontrol *kcontrol, | |||
| 2874 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); | 2915 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); |
| 2875 | 2916 | ||
| 2876 | if (e->reg != SND_SOC_NOPM) | 2917 | if (e->reg != SND_SOC_NOPM) |
| 2877 | change = snd_soc_test_bits(codec, e->reg, mask, val); | 2918 | change = soc_dapm_test_bits(dapm, e->reg, mask, val); |
| 2878 | else | 2919 | else |
| 2879 | change = dapm_kcontrol_set_value(kcontrol, val); | 2920 | change = dapm_kcontrol_set_value(kcontrol, val); |
| 2880 | 2921 | ||
| @@ -2971,6 +3012,7 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, | |||
| 2971 | const struct snd_soc_dapm_widget *widget) | 3012 | const struct snd_soc_dapm_widget *widget) |
| 2972 | { | 3013 | { |
| 2973 | struct snd_soc_dapm_widget *w; | 3014 | struct snd_soc_dapm_widget *w; |
| 3015 | const char *prefix; | ||
| 2974 | int ret; | 3016 | int ret; |
| 2975 | 3017 | ||
| 2976 | if ((w = dapm_cnew_widget(widget)) == NULL) | 3018 | if ((w = dapm_cnew_widget(widget)) == NULL) |
| @@ -3011,9 +3053,9 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, | |||
| 3011 | break; | 3053 | break; |
| 3012 | } | 3054 | } |
| 3013 | 3055 | ||
| 3014 | if (dapm->codec && dapm->codec->name_prefix) | 3056 | prefix = soc_dapm_prefix(dapm); |
| 3015 | w->name = kasprintf(GFP_KERNEL, "%s %s", | 3057 | if (prefix) |
| 3016 | dapm->codec->name_prefix, widget->name); | 3058 | w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name); |
| 3017 | else | 3059 | else |
| 3018 | w->name = kasprintf(GFP_KERNEL, "%s", widget->name); | 3060 | w->name = kasprintf(GFP_KERNEL, "%s", widget->name); |
| 3019 | 3061 | ||
| @@ -3066,7 +3108,6 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, | |||
| 3066 | 3108 | ||
| 3067 | w->dapm = dapm; | 3109 | w->dapm = dapm; |
| 3068 | w->codec = dapm->codec; | 3110 | w->codec = dapm->codec; |
| 3069 | w->platform = dapm->platform; | ||
| 3070 | INIT_LIST_HEAD(&w->sources); | 3111 | INIT_LIST_HEAD(&w->sources); |
| 3071 | INIT_LIST_HEAD(&w->sinks); | 3112 | INIT_LIST_HEAD(&w->sinks); |
| 3072 | INIT_LIST_HEAD(&w->list); | 3113 | INIT_LIST_HEAD(&w->list); |
| @@ -3173,27 +3214,15 @@ static int snd_soc_dai_link_event(struct snd_soc_dapm_widget *w, | |||
| 3173 | 3214 | ||
| 3174 | switch (event) { | 3215 | switch (event) { |
| 3175 | case SND_SOC_DAPM_PRE_PMU: | 3216 | case SND_SOC_DAPM_PRE_PMU: |
| 3176 | if (source->driver->ops && source->driver->ops->hw_params) { | 3217 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; |
| 3177 | substream.stream = SNDRV_PCM_STREAM_CAPTURE; | 3218 | ret = soc_dai_hw_params(&substream, params, source); |
| 3178 | ret = source->driver->ops->hw_params(&substream, | 3219 | if (ret < 0) |
| 3179 | params, source); | 3220 | goto out; |
| 3180 | if (ret != 0) { | ||
| 3181 | dev_err(source->dev, | ||
| 3182 | "ASoC: hw_params() failed: %d\n", ret); | ||
| 3183 | goto out; | ||
| 3184 | } | ||
| 3185 | } | ||
| 3186 | 3221 | ||
| 3187 | if (sink->driver->ops && sink->driver->ops->hw_params) { | 3222 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; |
| 3188 | substream.stream = SNDRV_PCM_STREAM_PLAYBACK; | 3223 | ret = soc_dai_hw_params(&substream, params, sink); |
| 3189 | ret = sink->driver->ops->hw_params(&substream, params, | 3224 | if (ret < 0) |
| 3190 | sink); | 3225 | goto out; |
| 3191 | if (ret != 0) { | ||
| 3192 | dev_err(sink->dev, | ||
| 3193 | "ASoC: hw_params() failed: %d\n", ret); | ||
| 3194 | goto out; | ||
| 3195 | } | ||
| 3196 | } | ||
| 3197 | break; | 3226 | break; |
| 3198 | 3227 | ||
| 3199 | case SND_SOC_DAPM_POST_PMU: | 3228 | case SND_SOC_DAPM_POST_PMU: |
| @@ -3365,25 +3394,15 @@ int snd_soc_dapm_link_dai_widgets(struct snd_soc_card *card) | |||
| 3365 | return 0; | 3394 | return 0; |
| 3366 | } | 3395 | } |
| 3367 | 3396 | ||
| 3368 | void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) | 3397 | static void dapm_connect_dai_link_widgets(struct snd_soc_card *card, |
| 3398 | struct snd_soc_pcm_runtime *rtd) | ||
| 3369 | { | 3399 | { |
| 3370 | struct snd_soc_pcm_runtime *rtd = card->rtd; | 3400 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 3371 | struct snd_soc_dapm_widget *sink, *source; | 3401 | struct snd_soc_dapm_widget *sink, *source; |
| 3372 | struct snd_soc_dai *cpu_dai, *codec_dai; | ||
| 3373 | int i; | 3402 | int i; |
| 3374 | 3403 | ||
| 3375 | /* for each BE DAI link... */ | 3404 | for (i = 0; i < rtd->num_codecs; i++) { |
| 3376 | for (i = 0; i < card->num_rtd; i++) { | 3405 | struct snd_soc_dai *codec_dai = rtd->codec_dais[i]; |
| 3377 | rtd = &card->rtd[i]; | ||
| 3378 | cpu_dai = rtd->cpu_dai; | ||
| 3379 | codec_dai = rtd->codec_dai; | ||
| 3380 | |||
| 3381 | /* | ||
| 3382 | * dynamic FE links have no fixed DAI mapping. | ||
| 3383 | * CODEC<->CODEC links have no direct connection. | ||
| 3384 | */ | ||
| 3385 | if (rtd->dai_link->dynamic || rtd->dai_link->params) | ||
| 3386 | continue; | ||
| 3387 | 3406 | ||
| 3388 | /* there is no point in connecting BE DAI links with dummies */ | 3407 | /* there is no point in connecting BE DAI links with dummies */ |
| 3389 | if (snd_soc_dai_is_dummy(codec_dai) || | 3408 | if (snd_soc_dai_is_dummy(codec_dai) || |
| @@ -3395,8 +3414,8 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) | |||
| 3395 | source = cpu_dai->playback_widget; | 3414 | source = cpu_dai->playback_widget; |
| 3396 | sink = codec_dai->playback_widget; | 3415 | sink = codec_dai->playback_widget; |
| 3397 | dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n", | 3416 | dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n", |
| 3398 | cpu_dai->codec->name, source->name, | 3417 | cpu_dai->component->name, source->name, |
| 3399 | codec_dai->platform->name, sink->name); | 3418 | codec_dai->component->name, sink->name); |
| 3400 | 3419 | ||
| 3401 | snd_soc_dapm_add_path(&card->dapm, source, sink, | 3420 | snd_soc_dapm_add_path(&card->dapm, source, sink, |
| 3402 | NULL, NULL); | 3421 | NULL, NULL); |
| @@ -3407,8 +3426,8 @@ void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) | |||
| 3407 | source = codec_dai->capture_widget; | 3426 | source = codec_dai->capture_widget; |
| 3408 | sink = cpu_dai->capture_widget; | 3427 | sink = cpu_dai->capture_widget; |
| 3409 | dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n", | 3428 | dev_dbg(rtd->dev, "connected DAI link %s:%s -> %s:%s\n", |
| 3410 | codec_dai->codec->name, source->name, | 3429 | codec_dai->component->name, source->name, |
| 3411 | cpu_dai->platform->name, sink->name); | 3430 | cpu_dai->component->name, sink->name); |
| 3412 | 3431 | ||
| 3413 | snd_soc_dapm_add_path(&card->dapm, source, sink, | 3432 | snd_soc_dapm_add_path(&card->dapm, source, sink, |
| 3414 | NULL, NULL); | 3433 | NULL, NULL); |
| @@ -3445,11 +3464,34 @@ static void soc_dapm_dai_stream_event(struct snd_soc_dai *dai, int stream, | |||
| 3445 | } | 3464 | } |
| 3446 | } | 3465 | } |
| 3447 | 3466 | ||
| 3467 | void snd_soc_dapm_connect_dai_link_widgets(struct snd_soc_card *card) | ||
| 3468 | { | ||
| 3469 | struct snd_soc_pcm_runtime *rtd = card->rtd; | ||
| 3470 | int i; | ||
| 3471 | |||
| 3472 | /* for each BE DAI link... */ | ||
| 3473 | for (i = 0; i < card->num_rtd; i++) { | ||
| 3474 | rtd = &card->rtd[i]; | ||
| 3475 | |||
| 3476 | /* | ||
| 3477 | * dynamic FE links have no fixed DAI mapping. | ||
| 3478 | * CODEC<->CODEC links have no direct connection. | ||
| 3479 | */ | ||
| 3480 | if (rtd->dai_link->dynamic || rtd->dai_link->params) | ||
| 3481 | continue; | ||
| 3482 | |||
| 3483 | dapm_connect_dai_link_widgets(card, rtd); | ||
| 3484 | } | ||
| 3485 | } | ||
| 3486 | |||
| 3448 | static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, | 3487 | static void soc_dapm_stream_event(struct snd_soc_pcm_runtime *rtd, int stream, |
| 3449 | int event) | 3488 | int event) |
| 3450 | { | 3489 | { |
| 3490 | int i; | ||
| 3491 | |||
| 3451 | soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event); | 3492 | soc_dapm_dai_stream_event(rtd->cpu_dai, stream, event); |
| 3452 | soc_dapm_dai_stream_event(rtd->codec_dai, stream, event); | 3493 | for (i = 0; i < rtd->num_codecs; i++) |
| 3494 | soc_dapm_dai_stream_event(rtd->codec_dais[i], stream, event); | ||
| 3453 | 3495 | ||
| 3454 | dapm_power_widgets(rtd->card, event); | 3496 | dapm_power_widgets(rtd->card, event); |
| 3455 | } | 3497 | } |
| @@ -3758,36 +3800,31 @@ static bool snd_soc_dapm_widget_in_card_paths(struct snd_soc_card *card, | |||
| 3758 | } | 3800 | } |
| 3759 | 3801 | ||
| 3760 | /** | 3802 | /** |
| 3761 | * snd_soc_dapm_auto_nc_codec_pins - call snd_soc_dapm_nc_pin for unused pins | 3803 | * snd_soc_dapm_auto_nc_pins - call snd_soc_dapm_nc_pin for unused pins |
| 3762 | * @codec: The codec whose pins should be processed | 3804 | * @card: The card whose pins should be processed |
| 3763 | * | 3805 | * |
| 3764 | * Automatically call snd_soc_dapm_nc_pin() for any external pins in the codec | 3806 | * Automatically call snd_soc_dapm_nc_pin() for any external pins in the card |
| 3765 | * which are unused. Pins are used if they are connected externally to the | 3807 | * which are unused. Pins are used if they are connected externally to a |
| 3766 | * codec, whether that be to some other device, or a loop-back connection to | 3808 | * component, whether that be to some other device, or a loop-back connection to |
| 3767 | * the codec itself. | 3809 | * the component itself. |
| 3768 | */ | 3810 | */ |
| 3769 | void snd_soc_dapm_auto_nc_codec_pins(struct snd_soc_codec *codec) | 3811 | void snd_soc_dapm_auto_nc_pins(struct snd_soc_card *card) |
| 3770 | { | 3812 | { |
| 3771 | struct snd_soc_card *card = codec->card; | ||
| 3772 | struct snd_soc_dapm_context *dapm = &codec->dapm; | ||
| 3773 | struct snd_soc_dapm_widget *w; | 3813 | struct snd_soc_dapm_widget *w; |
| 3774 | 3814 | ||
| 3775 | dev_dbg(codec->dev, "ASoC: Auto NC: DAPMs: card:%p codec:%p\n", | 3815 | dev_dbg(card->dev, "ASoC: Auto NC: DAPMs: card:%p\n", &card->dapm); |
| 3776 | &card->dapm, &codec->dapm); | ||
| 3777 | 3816 | ||
| 3778 | list_for_each_entry(w, &card->widgets, list) { | 3817 | list_for_each_entry(w, &card->widgets, list) { |
| 3779 | if (w->dapm != dapm) | ||
| 3780 | continue; | ||
| 3781 | switch (w->id) { | 3818 | switch (w->id) { |
| 3782 | case snd_soc_dapm_input: | 3819 | case snd_soc_dapm_input: |
| 3783 | case snd_soc_dapm_output: | 3820 | case snd_soc_dapm_output: |
| 3784 | case snd_soc_dapm_micbias: | 3821 | case snd_soc_dapm_micbias: |
| 3785 | dev_dbg(codec->dev, "ASoC: Auto NC: Checking widget %s\n", | 3822 | dev_dbg(card->dev, "ASoC: Auto NC: Checking widget %s\n", |
| 3786 | w->name); | 3823 | w->name); |
| 3787 | if (!snd_soc_dapm_widget_in_card_paths(card, w)) { | 3824 | if (!snd_soc_dapm_widget_in_card_paths(card, w)) { |
| 3788 | dev_dbg(codec->dev, | 3825 | dev_dbg(card->dev, |
| 3789 | "... Not in map; disabling\n"); | 3826 | "... Not in map; disabling\n"); |
| 3790 | snd_soc_dapm_nc_pin(dapm, w->name); | 3827 | snd_soc_dapm_nc_pin(w->dapm, w->name); |
| 3791 | } | 3828 | } |
| 3792 | break; | 3829 | break; |
| 3793 | default: | 3830 | default: |
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index 5bace124ef43..6307f85e871b 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c | |||
| @@ -119,7 +119,10 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea | |||
| 119 | struct snd_dmaengine_dai_dma_data *dma_data; | 119 | struct snd_dmaengine_dai_dma_data *dma_data; |
| 120 | struct dma_slave_caps dma_caps; | 120 | struct dma_slave_caps dma_caps; |
| 121 | struct snd_pcm_hardware hw; | 121 | struct snd_pcm_hardware hw; |
| 122 | int ret; | 122 | u32 addr_widths = BIT(DMA_SLAVE_BUSWIDTH_1_BYTE) | |
| 123 | BIT(DMA_SLAVE_BUSWIDTH_2_BYTES) | | ||
| 124 | BIT(DMA_SLAVE_BUSWIDTH_4_BYTES); | ||
| 125 | int i, ret; | ||
| 123 | 126 | ||
| 124 | if (pcm->config && pcm->config->pcm_hardware) | 127 | if (pcm->config && pcm->config->pcm_hardware) |
| 125 | return snd_soc_set_runtime_hwparams(substream, | 128 | return snd_soc_set_runtime_hwparams(substream, |
| @@ -146,6 +149,38 @@ static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substrea | |||
| 146 | hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; | 149 | hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; |
| 147 | if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT) | 150 | if (dma_caps.residue_granularity <= DMA_RESIDUE_GRANULARITY_SEGMENT) |
| 148 | hw.info |= SNDRV_PCM_INFO_BATCH; | 151 | hw.info |= SNDRV_PCM_INFO_BATCH; |
| 152 | |||
| 153 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 154 | addr_widths = dma_caps.dstn_addr_widths; | ||
| 155 | else | ||
| 156 | addr_widths = dma_caps.src_addr_widths; | ||
| 157 | } | ||
| 158 | |||
| 159 | /* | ||
| 160 | * Prepare formats mask for valid/allowed sample types. If the dma does | ||
| 161 | * not have support for the given physical word size, it needs to be | ||
| 162 | * masked out so user space can not use the format which produces | ||
| 163 | * corrupted audio. | ||
| 164 | * In case the dma driver does not implement the slave_caps the default | ||
| 165 | * assumption is that it supports 1, 2 and 4 bytes widths. | ||
| 166 | */ | ||
| 167 | for (i = 0; i <= SNDRV_PCM_FORMAT_LAST; i++) { | ||
| 168 | int bits = snd_pcm_format_physical_width(i); | ||
| 169 | |||
| 170 | /* Enable only samples with DMA supported physical widths */ | ||
| 171 | switch (bits) { | ||
| 172 | case 8: | ||
| 173 | case 16: | ||
| 174 | case 24: | ||
| 175 | case 32: | ||
| 176 | case 64: | ||
| 177 | if (addr_widths & (1 << (bits / 8))) | ||
| 178 | hw.formats |= (1LL << i); | ||
| 179 | break; | ||
| 180 | default: | ||
| 181 | /* Unsupported types */ | ||
| 182 | break; | ||
| 183 | } | ||
| 149 | } | 184 | } |
| 150 | 185 | ||
| 151 | return snd_soc_set_runtime_hwparams(substream, &hw); | 186 | return snd_soc_set_runtime_hwparams(substream, &hw); |
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index d0d98810af91..ab47fea997a3 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c | |||
| @@ -43,7 +43,7 @@ int snd_soc_jack_new(struct snd_soc_codec *codec, const char *id, int type, | |||
| 43 | INIT_LIST_HEAD(&jack->jack_zones); | 43 | INIT_LIST_HEAD(&jack->jack_zones); |
| 44 | BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); | 44 | BLOCKING_INIT_NOTIFIER_HEAD(&jack->notifier); |
| 45 | 45 | ||
| 46 | return snd_jack_new(codec->card->snd_card, id, type, &jack->jack); | 46 | return snd_jack_new(codec->component.card->snd_card, id, type, &jack->jack); |
| 47 | } | 47 | } |
| 48 | EXPORT_SYMBOL_GPL(snd_soc_jack_new); | 48 | EXPORT_SYMBOL_GPL(snd_soc_jack_new); |
| 49 | 49 | ||
| @@ -260,7 +260,7 @@ static void snd_soc_jack_gpio_detect(struct snd_soc_jack_gpio *gpio) | |||
| 260 | static irqreturn_t gpio_handler(int irq, void *data) | 260 | static irqreturn_t gpio_handler(int irq, void *data) |
| 261 | { | 261 | { |
| 262 | struct snd_soc_jack_gpio *gpio = data; | 262 | struct snd_soc_jack_gpio *gpio = data; |
| 263 | struct device *dev = gpio->jack->codec->card->dev; | 263 | struct device *dev = gpio->jack->codec->component.card->dev; |
| 264 | 264 | ||
| 265 | trace_snd_soc_jack_irq(gpio->name); | 265 | trace_snd_soc_jack_irq(gpio->name); |
| 266 | 266 | ||
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 54d18f22a33e..731fdb5b5f9b 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | * Copyright (C) 2010 Texas Instruments Inc. | 7 | * Copyright (C) 2010 Texas Instruments Inc. |
| 8 | * | 8 | * |
| 9 | * Authors: Liam Girdwood <lrg@ti.com> | 9 | * Authors: Liam Girdwood <lrg@ti.com> |
| 10 | * Mark Brown <broonie@opensource.wolfsonmicro.com> | 10 | * Mark Brown <broonie@opensource.wolfsonmicro.com> |
| 11 | * | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify it | 12 | * This program is free software; you can redistribute it and/or modify it |
| 13 | * under the terms of the GNU General Public License as published by the | 13 | * under the terms of the GNU General Public License as published by the |
| @@ -47,22 +47,26 @@ | |||
| 47 | void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream) | 47 | void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream) |
| 48 | { | 48 | { |
| 49 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 49 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 50 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 50 | int i; |
| 51 | 51 | ||
| 52 | lockdep_assert_held(&rtd->pcm_mutex); | 52 | lockdep_assert_held(&rtd->pcm_mutex); |
| 53 | 53 | ||
| 54 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 54 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 55 | cpu_dai->playback_active++; | 55 | cpu_dai->playback_active++; |
| 56 | codec_dai->playback_active++; | 56 | for (i = 0; i < rtd->num_codecs; i++) |
| 57 | rtd->codec_dais[i]->playback_active++; | ||
| 57 | } else { | 58 | } else { |
| 58 | cpu_dai->capture_active++; | 59 | cpu_dai->capture_active++; |
| 59 | codec_dai->capture_active++; | 60 | for (i = 0; i < rtd->num_codecs; i++) |
| 61 | rtd->codec_dais[i]->capture_active++; | ||
| 60 | } | 62 | } |
| 61 | 63 | ||
| 62 | cpu_dai->active++; | 64 | cpu_dai->active++; |
| 63 | codec_dai->active++; | ||
| 64 | cpu_dai->component->active++; | 65 | cpu_dai->component->active++; |
| 65 | codec_dai->component->active++; | 66 | for (i = 0; i < rtd->num_codecs; i++) { |
| 67 | rtd->codec_dais[i]->active++; | ||
| 68 | rtd->codec_dais[i]->component->active++; | ||
| 69 | } | ||
| 66 | } | 70 | } |
| 67 | 71 | ||
| 68 | /** | 72 | /** |
| @@ -78,22 +82,26 @@ void snd_soc_runtime_activate(struct snd_soc_pcm_runtime *rtd, int stream) | |||
| 78 | void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) | 82 | void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) |
| 79 | { | 83 | { |
| 80 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 84 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 81 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 85 | int i; |
| 82 | 86 | ||
| 83 | lockdep_assert_held(&rtd->pcm_mutex); | 87 | lockdep_assert_held(&rtd->pcm_mutex); |
| 84 | 88 | ||
| 85 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 89 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 86 | cpu_dai->playback_active--; | 90 | cpu_dai->playback_active--; |
| 87 | codec_dai->playback_active--; | 91 | for (i = 0; i < rtd->num_codecs; i++) |
| 92 | rtd->codec_dais[i]->playback_active--; | ||
| 88 | } else { | 93 | } else { |
| 89 | cpu_dai->capture_active--; | 94 | cpu_dai->capture_active--; |
| 90 | codec_dai->capture_active--; | 95 | for (i = 0; i < rtd->num_codecs; i++) |
| 96 | rtd->codec_dais[i]->capture_active--; | ||
| 91 | } | 97 | } |
| 92 | 98 | ||
| 93 | cpu_dai->active--; | 99 | cpu_dai->active--; |
| 94 | codec_dai->active--; | ||
| 95 | cpu_dai->component->active--; | 100 | cpu_dai->component->active--; |
| 96 | codec_dai->component->active--; | 101 | for (i = 0; i < rtd->num_codecs; i++) { |
| 102 | rtd->codec_dais[i]->component->active--; | ||
| 103 | rtd->codec_dais[i]->active--; | ||
| 104 | } | ||
| 97 | } | 105 | } |
| 98 | 106 | ||
| 99 | /** | 107 | /** |
| @@ -107,11 +115,16 @@ void snd_soc_runtime_deactivate(struct snd_soc_pcm_runtime *rtd, int stream) | |||
| 107 | */ | 115 | */ |
| 108 | bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) | 116 | bool snd_soc_runtime_ignore_pmdown_time(struct snd_soc_pcm_runtime *rtd) |
| 109 | { | 117 | { |
| 118 | int i; | ||
| 119 | bool ignore = true; | ||
| 120 | |||
| 110 | if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) | 121 | if (!rtd->pmdown_time || rtd->dai_link->ignore_pmdown_time) |
| 111 | return true; | 122 | return true; |
| 112 | 123 | ||
| 113 | return rtd->cpu_dai->component->ignore_pmdown_time && | 124 | for (i = 0; i < rtd->num_codecs; i++) |
| 114 | rtd->codec_dai->component->ignore_pmdown_time; | 125 | ignore &= rtd->codec_dais[i]->component->ignore_pmdown_time; |
| 126 | |||
| 127 | return rtd->cpu_dai->component->ignore_pmdown_time && ignore; | ||
| 115 | } | 128 | } |
| 116 | 129 | ||
| 117 | /** | 130 | /** |
| @@ -222,8 +235,7 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, | |||
| 222 | { | 235 | { |
| 223 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 236 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 224 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 237 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 225 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 238 | unsigned int rate, channels, sample_bits, symmetry, i; |
| 226 | unsigned int rate, channels, sample_bits, symmetry; | ||
| 227 | 239 | ||
| 228 | rate = params_rate(params); | 240 | rate = params_rate(params); |
| 229 | channels = params_channels(params); | 241 | channels = params_channels(params); |
| @@ -231,8 +243,11 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, | |||
| 231 | 243 | ||
| 232 | /* reject unmatched parameters when applying symmetry */ | 244 | /* reject unmatched parameters when applying symmetry */ |
| 233 | symmetry = cpu_dai->driver->symmetric_rates || | 245 | symmetry = cpu_dai->driver->symmetric_rates || |
| 234 | codec_dai->driver->symmetric_rates || | ||
| 235 | rtd->dai_link->symmetric_rates; | 246 | rtd->dai_link->symmetric_rates; |
| 247 | |||
| 248 | for (i = 0; i < rtd->num_codecs; i++) | ||
| 249 | symmetry |= rtd->codec_dais[i]->driver->symmetric_rates; | ||
| 250 | |||
| 236 | if (symmetry && cpu_dai->rate && cpu_dai->rate != rate) { | 251 | if (symmetry && cpu_dai->rate && cpu_dai->rate != rate) { |
| 237 | dev_err(rtd->dev, "ASoC: unmatched rate symmetry: %d - %d\n", | 252 | dev_err(rtd->dev, "ASoC: unmatched rate symmetry: %d - %d\n", |
| 238 | cpu_dai->rate, rate); | 253 | cpu_dai->rate, rate); |
| @@ -240,8 +255,11 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, | |||
| 240 | } | 255 | } |
| 241 | 256 | ||
| 242 | symmetry = cpu_dai->driver->symmetric_channels || | 257 | symmetry = cpu_dai->driver->symmetric_channels || |
| 243 | codec_dai->driver->symmetric_channels || | ||
| 244 | rtd->dai_link->symmetric_channels; | 258 | rtd->dai_link->symmetric_channels; |
| 259 | |||
| 260 | for (i = 0; i < rtd->num_codecs; i++) | ||
| 261 | symmetry |= rtd->codec_dais[i]->driver->symmetric_channels; | ||
| 262 | |||
| 245 | if (symmetry && cpu_dai->channels && cpu_dai->channels != channels) { | 263 | if (symmetry && cpu_dai->channels && cpu_dai->channels != channels) { |
| 246 | dev_err(rtd->dev, "ASoC: unmatched channel symmetry: %d - %d\n", | 264 | dev_err(rtd->dev, "ASoC: unmatched channel symmetry: %d - %d\n", |
| 247 | cpu_dai->channels, channels); | 265 | cpu_dai->channels, channels); |
| @@ -249,8 +267,11 @@ static int soc_pcm_params_symmetry(struct snd_pcm_substream *substream, | |||
| 249 | } | 267 | } |
| 250 | 268 | ||
| 251 | symmetry = cpu_dai->driver->symmetric_samplebits || | 269 | symmetry = cpu_dai->driver->symmetric_samplebits || |
| 252 | codec_dai->driver->symmetric_samplebits || | ||
| 253 | rtd->dai_link->symmetric_samplebits; | 270 | rtd->dai_link->symmetric_samplebits; |
| 271 | |||
| 272 | for (i = 0; i < rtd->num_codecs; i++) | ||
| 273 | symmetry |= rtd->codec_dais[i]->driver->symmetric_samplebits; | ||
| 274 | |||
| 254 | if (symmetry && cpu_dai->sample_bits && cpu_dai->sample_bits != sample_bits) { | 275 | if (symmetry && cpu_dai->sample_bits && cpu_dai->sample_bits != sample_bits) { |
| 255 | dev_err(rtd->dev, "ASoC: unmatched sample bits symmetry: %d - %d\n", | 276 | dev_err(rtd->dev, "ASoC: unmatched sample bits symmetry: %d - %d\n", |
| 256 | cpu_dai->sample_bits, sample_bits); | 277 | cpu_dai->sample_bits, sample_bits); |
| @@ -264,15 +285,20 @@ static bool soc_pcm_has_symmetry(struct snd_pcm_substream *substream) | |||
| 264 | { | 285 | { |
| 265 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 286 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 266 | struct snd_soc_dai_driver *cpu_driver = rtd->cpu_dai->driver; | 287 | struct snd_soc_dai_driver *cpu_driver = rtd->cpu_dai->driver; |
| 267 | struct snd_soc_dai_driver *codec_driver = rtd->codec_dai->driver; | ||
| 268 | struct snd_soc_dai_link *link = rtd->dai_link; | 288 | struct snd_soc_dai_link *link = rtd->dai_link; |
| 289 | unsigned int symmetry, i; | ||
| 269 | 290 | ||
| 270 | return cpu_driver->symmetric_rates || codec_driver->symmetric_rates || | 291 | symmetry = cpu_driver->symmetric_rates || link->symmetric_rates || |
| 271 | link->symmetric_rates || cpu_driver->symmetric_channels || | 292 | cpu_driver->symmetric_channels || link->symmetric_channels || |
| 272 | codec_driver->symmetric_channels || link->symmetric_channels || | 293 | cpu_driver->symmetric_samplebits || link->symmetric_samplebits; |
| 273 | cpu_driver->symmetric_samplebits || | 294 | |
| 274 | codec_driver->symmetric_samplebits || | 295 | for (i = 0; i < rtd->num_codecs; i++) |
| 275 | link->symmetric_samplebits; | 296 | symmetry = symmetry || |
| 297 | rtd->codec_dais[i]->driver->symmetric_rates || | ||
| 298 | rtd->codec_dais[i]->driver->symmetric_channels || | ||
| 299 | rtd->codec_dais[i]->driver->symmetric_samplebits; | ||
| 300 | |||
| 301 | return symmetry; | ||
| 276 | } | 302 | } |
| 277 | 303 | ||
| 278 | /* | 304 | /* |
| @@ -284,15 +310,10 @@ static int sample_sizes[] = { | |||
| 284 | 24, 32, | 310 | 24, 32, |
| 285 | }; | 311 | }; |
| 286 | 312 | ||
| 287 | static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, | 313 | static void soc_pcm_set_msb(struct snd_pcm_substream *substream, int bits) |
| 288 | struct snd_soc_dai *dai) | ||
| 289 | { | 314 | { |
| 290 | int ret, i, bits; | 315 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 291 | 316 | int ret, i; | |
| 292 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 293 | bits = dai->driver->playback.sig_bits; | ||
| 294 | else | ||
| 295 | bits = dai->driver->capture.sig_bits; | ||
| 296 | 317 | ||
| 297 | if (!bits) | 318 | if (!bits) |
| 298 | return; | 319 | return; |
| @@ -304,38 +325,105 @@ static void soc_pcm_apply_msb(struct snd_pcm_substream *substream, | |||
| 304 | ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, | 325 | ret = snd_pcm_hw_constraint_msbits(substream->runtime, 0, |
| 305 | sample_sizes[i], bits); | 326 | sample_sizes[i], bits); |
| 306 | if (ret != 0) | 327 | if (ret != 0) |
| 307 | dev_warn(dai->dev, | 328 | dev_warn(rtd->dev, |
| 308 | "ASoC: Failed to set MSB %d/%d: %d\n", | 329 | "ASoC: Failed to set MSB %d/%d: %d\n", |
| 309 | bits, sample_sizes[i], ret); | 330 | bits, sample_sizes[i], ret); |
| 310 | } | 331 | } |
| 311 | } | 332 | } |
| 312 | 333 | ||
| 313 | static void soc_pcm_init_runtime_hw(struct snd_pcm_runtime *runtime, | 334 | static void soc_pcm_apply_msb(struct snd_pcm_substream *substream) |
| 314 | struct snd_soc_pcm_stream *codec_stream, | 335 | { |
| 315 | struct snd_soc_pcm_stream *cpu_stream) | 336 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 337 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | ||
| 338 | struct snd_soc_dai *codec_dai; | ||
| 339 | int i; | ||
| 340 | unsigned int bits = 0, cpu_bits; | ||
| 341 | |||
| 342 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | ||
| 343 | for (i = 0; i < rtd->num_codecs; i++) { | ||
| 344 | codec_dai = rtd->codec_dais[i]; | ||
| 345 | if (codec_dai->driver->playback.sig_bits == 0) { | ||
| 346 | bits = 0; | ||
| 347 | break; | ||
| 348 | } | ||
| 349 | bits = max(codec_dai->driver->playback.sig_bits, bits); | ||
| 350 | } | ||
| 351 | cpu_bits = cpu_dai->driver->playback.sig_bits; | ||
| 352 | } else { | ||
| 353 | for (i = 0; i < rtd->num_codecs; i++) { | ||
| 354 | codec_dai = rtd->codec_dais[i]; | ||
| 355 | if (codec_dai->driver->playback.sig_bits == 0) { | ||
| 356 | bits = 0; | ||
| 357 | break; | ||
| 358 | } | ||
| 359 | bits = max(codec_dai->driver->capture.sig_bits, bits); | ||
| 360 | } | ||
| 361 | cpu_bits = cpu_dai->driver->capture.sig_bits; | ||
| 362 | } | ||
| 363 | |||
| 364 | soc_pcm_set_msb(substream, bits); | ||
| 365 | soc_pcm_set_msb(substream, cpu_bits); | ||
| 366 | } | ||
| 367 | |||
| 368 | static void soc_pcm_init_runtime_hw(struct snd_pcm_substream *substream) | ||
| 316 | { | 369 | { |
| 370 | struct snd_pcm_runtime *runtime = substream->runtime; | ||
| 317 | struct snd_pcm_hardware *hw = &runtime->hw; | 371 | struct snd_pcm_hardware *hw = &runtime->hw; |
| 372 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | ||
| 373 | struct snd_soc_dai_driver *cpu_dai_drv = rtd->cpu_dai->driver; | ||
| 374 | struct snd_soc_dai_driver *codec_dai_drv; | ||
| 375 | struct snd_soc_pcm_stream *codec_stream; | ||
| 376 | struct snd_soc_pcm_stream *cpu_stream; | ||
| 377 | unsigned int chan_min = 0, chan_max = UINT_MAX; | ||
| 378 | unsigned int rate_min = 0, rate_max = UINT_MAX; | ||
| 379 | unsigned int rates = UINT_MAX; | ||
| 380 | u64 formats = ULLONG_MAX; | ||
| 381 | int i; | ||
| 318 | 382 | ||
| 319 | hw->channels_min = max(codec_stream->channels_min, | 383 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 320 | cpu_stream->channels_min); | 384 | cpu_stream = &cpu_dai_drv->playback; |
| 321 | hw->channels_max = min(codec_stream->channels_max, | ||
| 322 | cpu_stream->channels_max); | ||
| 323 | if (hw->formats) | ||
| 324 | hw->formats &= codec_stream->formats & cpu_stream->formats; | ||
| 325 | else | 385 | else |
| 326 | hw->formats = codec_stream->formats & cpu_stream->formats; | 386 | cpu_stream = &cpu_dai_drv->capture; |
| 327 | hw->rates = snd_pcm_rate_mask_intersect(codec_stream->rates, | ||
| 328 | cpu_stream->rates); | ||
| 329 | 387 | ||
| 330 | hw->rate_min = 0; | 388 | /* first calculate min/max only for CODECs in the DAI link */ |
| 331 | hw->rate_max = UINT_MAX; | 389 | for (i = 0; i < rtd->num_codecs; i++) { |
| 390 | codec_dai_drv = rtd->codec_dais[i]->driver; | ||
| 391 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 392 | codec_stream = &codec_dai_drv->playback; | ||
| 393 | else | ||
| 394 | codec_stream = &codec_dai_drv->capture; | ||
| 395 | chan_min = max(chan_min, codec_stream->channels_min); | ||
| 396 | chan_max = min(chan_max, codec_stream->channels_max); | ||
| 397 | rate_min = max(rate_min, codec_stream->rate_min); | ||
| 398 | rate_max = min_not_zero(rate_max, codec_stream->rate_max); | ||
| 399 | formats &= codec_stream->formats; | ||
| 400 | rates = snd_pcm_rate_mask_intersect(codec_stream->rates, rates); | ||
| 401 | } | ||
| 402 | |||
| 403 | /* | ||
| 404 | * chan min/max cannot be enforced if there are multiple CODEC DAIs | ||
| 405 | * connected to a single CPU DAI, use CPU DAI's directly and let | ||
| 406 | * channel allocation be fixed up later | ||
| 407 | */ | ||
| 408 | if (rtd->num_codecs > 1) { | ||
| 409 | chan_min = cpu_stream->channels_min; | ||
| 410 | chan_max = cpu_stream->channels_max; | ||
| 411 | } | ||
| 412 | |||
| 413 | hw->channels_min = max(chan_min, cpu_stream->channels_min); | ||
| 414 | hw->channels_max = min(chan_max, cpu_stream->channels_max); | ||
| 415 | if (hw->formats) | ||
| 416 | hw->formats &= formats & cpu_stream->formats; | ||
| 417 | else | ||
| 418 | hw->formats = formats & cpu_stream->formats; | ||
| 419 | hw->rates = snd_pcm_rate_mask_intersect(rates, cpu_stream->rates); | ||
| 332 | 420 | ||
| 333 | snd_pcm_limit_hw_rates(runtime); | 421 | snd_pcm_limit_hw_rates(runtime); |
| 334 | 422 | ||
| 335 | hw->rate_min = max(hw->rate_min, cpu_stream->rate_min); | 423 | hw->rate_min = max(hw->rate_min, cpu_stream->rate_min); |
| 336 | hw->rate_min = max(hw->rate_min, codec_stream->rate_min); | 424 | hw->rate_min = max(hw->rate_min, rate_min); |
| 337 | hw->rate_max = min_not_zero(hw->rate_max, cpu_stream->rate_max); | 425 | hw->rate_max = min_not_zero(hw->rate_max, cpu_stream->rate_max); |
| 338 | hw->rate_max = min_not_zero(hw->rate_max, codec_stream->rate_max); | 426 | hw->rate_max = min_not_zero(hw->rate_max, rate_max); |
| 339 | } | 427 | } |
| 340 | 428 | ||
| 341 | /* | 429 | /* |
| @@ -349,15 +437,16 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
| 349 | struct snd_pcm_runtime *runtime = substream->runtime; | 437 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 350 | struct snd_soc_platform *platform = rtd->platform; | 438 | struct snd_soc_platform *platform = rtd->platform; |
| 351 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 439 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 352 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 440 | struct snd_soc_dai *codec_dai; |
| 353 | struct snd_soc_dai_driver *cpu_dai_drv = cpu_dai->driver; | 441 | const char *codec_dai_name = "multicodec"; |
| 354 | struct snd_soc_dai_driver *codec_dai_drv = codec_dai->driver; | 442 | int i, ret = 0; |
| 355 | int ret = 0; | ||
| 356 | 443 | ||
| 357 | pinctrl_pm_select_default_state(cpu_dai->dev); | 444 | pinctrl_pm_select_default_state(cpu_dai->dev); |
| 358 | pinctrl_pm_select_default_state(codec_dai->dev); | 445 | for (i = 0; i < rtd->num_codecs; i++) |
| 446 | pinctrl_pm_select_default_state(rtd->codec_dais[i]->dev); | ||
| 359 | pm_runtime_get_sync(cpu_dai->dev); | 447 | pm_runtime_get_sync(cpu_dai->dev); |
| 360 | pm_runtime_get_sync(codec_dai->dev); | 448 | for (i = 0; i < rtd->num_codecs; i++) |
| 449 | pm_runtime_get_sync(rtd->codec_dais[i]->dev); | ||
| 361 | pm_runtime_get_sync(platform->dev); | 450 | pm_runtime_get_sync(platform->dev); |
| 362 | 451 | ||
| 363 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 452 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
| @@ -376,18 +465,28 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
| 376 | ret = platform->driver->ops->open(substream); | 465 | ret = platform->driver->ops->open(substream); |
| 377 | if (ret < 0) { | 466 | if (ret < 0) { |
| 378 | dev_err(platform->dev, "ASoC: can't open platform" | 467 | dev_err(platform->dev, "ASoC: can't open platform" |
| 379 | " %s: %d\n", platform->name, ret); | 468 | " %s: %d\n", platform->component.name, ret); |
| 380 | goto platform_err; | 469 | goto platform_err; |
| 381 | } | 470 | } |
| 382 | } | 471 | } |
| 383 | 472 | ||
| 384 | if (codec_dai->driver->ops && codec_dai->driver->ops->startup) { | 473 | for (i = 0; i < rtd->num_codecs; i++) { |
| 385 | ret = codec_dai->driver->ops->startup(substream, codec_dai); | 474 | codec_dai = rtd->codec_dais[i]; |
| 386 | if (ret < 0) { | 475 | if (codec_dai->driver->ops && codec_dai->driver->ops->startup) { |
| 387 | dev_err(codec_dai->dev, "ASoC: can't open codec" | 476 | ret = codec_dai->driver->ops->startup(substream, |
| 388 | " %s: %d\n", codec_dai->name, ret); | 477 | codec_dai); |
| 389 | goto codec_dai_err; | 478 | if (ret < 0) { |
| 479 | dev_err(codec_dai->dev, | ||
| 480 | "ASoC: can't open codec %s: %d\n", | ||
| 481 | codec_dai->name, ret); | ||
| 482 | goto codec_dai_err; | ||
| 483 | } | ||
| 390 | } | 484 | } |
| 485 | |||
| 486 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 487 | codec_dai->tx_mask = 0; | ||
| 488 | else | ||
| 489 | codec_dai->rx_mask = 0; | ||
| 391 | } | 490 | } |
| 392 | 491 | ||
| 393 | if (rtd->dai_link->ops && rtd->dai_link->ops->startup) { | 492 | if (rtd->dai_link->ops && rtd->dai_link->ops->startup) { |
| @@ -404,13 +503,10 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
| 404 | goto dynamic; | 503 | goto dynamic; |
| 405 | 504 | ||
| 406 | /* Check that the codec and cpu DAIs are compatible */ | 505 | /* Check that the codec and cpu DAIs are compatible */ |
| 407 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 506 | soc_pcm_init_runtime_hw(substream); |
| 408 | soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->playback, | 507 | |
| 409 | &cpu_dai_drv->playback); | 508 | if (rtd->num_codecs == 1) |
| 410 | } else { | 509 | codec_dai_name = rtd->codec_dai->name; |
| 411 | soc_pcm_init_runtime_hw(runtime, &codec_dai_drv->capture, | ||
| 412 | &cpu_dai_drv->capture); | ||
| 413 | } | ||
| 414 | 510 | ||
| 415 | if (soc_pcm_has_symmetry(substream)) | 511 | if (soc_pcm_has_symmetry(substream)) |
| 416 | runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX; | 512 | runtime->hw.info |= SNDRV_PCM_INFO_JOINT_DUPLEX; |
| @@ -418,23 +514,22 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
| 418 | ret = -EINVAL; | 514 | ret = -EINVAL; |
| 419 | if (!runtime->hw.rates) { | 515 | if (!runtime->hw.rates) { |
| 420 | printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n", | 516 | printk(KERN_ERR "ASoC: %s <-> %s No matching rates\n", |
| 421 | codec_dai->name, cpu_dai->name); | 517 | codec_dai_name, cpu_dai->name); |
| 422 | goto config_err; | 518 | goto config_err; |
| 423 | } | 519 | } |
| 424 | if (!runtime->hw.formats) { | 520 | if (!runtime->hw.formats) { |
| 425 | printk(KERN_ERR "ASoC: %s <-> %s No matching formats\n", | 521 | printk(KERN_ERR "ASoC: %s <-> %s No matching formats\n", |
| 426 | codec_dai->name, cpu_dai->name); | 522 | codec_dai_name, cpu_dai->name); |
| 427 | goto config_err; | 523 | goto config_err; |
| 428 | } | 524 | } |
| 429 | if (!runtime->hw.channels_min || !runtime->hw.channels_max || | 525 | if (!runtime->hw.channels_min || !runtime->hw.channels_max || |
| 430 | runtime->hw.channels_min > runtime->hw.channels_max) { | 526 | runtime->hw.channels_min > runtime->hw.channels_max) { |
| 431 | printk(KERN_ERR "ASoC: %s <-> %s No matching channels\n", | 527 | printk(KERN_ERR "ASoC: %s <-> %s No matching channels\n", |
| 432 | codec_dai->name, cpu_dai->name); | 528 | codec_dai_name, cpu_dai->name); |
| 433 | goto config_err; | 529 | goto config_err; |
| 434 | } | 530 | } |
| 435 | 531 | ||
| 436 | soc_pcm_apply_msb(substream, codec_dai); | 532 | soc_pcm_apply_msb(substream); |
| 437 | soc_pcm_apply_msb(substream, cpu_dai); | ||
| 438 | 533 | ||
| 439 | /* Symmetry only applies if we've already got an active stream. */ | 534 | /* Symmetry only applies if we've already got an active stream. */ |
| 440 | if (cpu_dai->active) { | 535 | if (cpu_dai->active) { |
| @@ -443,14 +538,17 @@ static int soc_pcm_open(struct snd_pcm_substream *substream) | |||
| 443 | goto config_err; | 538 | goto config_err; |
| 444 | } | 539 | } |
| 445 | 540 | ||
| 446 | if (codec_dai->active) { | 541 | for (i = 0; i < rtd->num_codecs; i++) { |
| 447 | ret = soc_pcm_apply_symmetry(substream, codec_dai); | 542 | if (rtd->codec_dais[i]->active) { |
| 448 | if (ret != 0) | 543 | ret = soc_pcm_apply_symmetry(substream, |
| 449 | goto config_err; | 544 | rtd->codec_dais[i]); |
| 545 | if (ret != 0) | ||
| 546 | goto config_err; | ||
| 547 | } | ||
| 450 | } | 548 | } |
| 451 | 549 | ||
| 452 | pr_debug("ASoC: %s <-> %s info:\n", | 550 | pr_debug("ASoC: %s <-> %s info:\n", |
| 453 | codec_dai->name, cpu_dai->name); | 551 | codec_dai_name, cpu_dai->name); |
| 454 | pr_debug("ASoC: rate mask 0x%x\n", runtime->hw.rates); | 552 | pr_debug("ASoC: rate mask 0x%x\n", runtime->hw.rates); |
| 455 | pr_debug("ASoC: min ch %d max ch %d\n", runtime->hw.channels_min, | 553 | pr_debug("ASoC: min ch %d max ch %d\n", runtime->hw.channels_min, |
| 456 | runtime->hw.channels_max); | 554 | runtime->hw.channels_max); |
| @@ -469,10 +567,15 @@ config_err: | |||
| 469 | rtd->dai_link->ops->shutdown(substream); | 567 | rtd->dai_link->ops->shutdown(substream); |
| 470 | 568 | ||
| 471 | machine_err: | 569 | machine_err: |
| 472 | if (codec_dai->driver->ops->shutdown) | 570 | i = rtd->num_codecs; |
| 473 | codec_dai->driver->ops->shutdown(substream, codec_dai); | ||
| 474 | 571 | ||
| 475 | codec_dai_err: | 572 | codec_dai_err: |
| 573 | while (--i >= 0) { | ||
| 574 | codec_dai = rtd->codec_dais[i]; | ||
| 575 | if (codec_dai->driver->ops->shutdown) | ||
| 576 | codec_dai->driver->ops->shutdown(substream, codec_dai); | ||
| 577 | } | ||
| 578 | |||
| 476 | if (platform->driver->ops && platform->driver->ops->close) | 579 | if (platform->driver->ops && platform->driver->ops->close) |
| 477 | platform->driver->ops->close(substream); | 580 | platform->driver->ops->close(substream); |
| 478 | 581 | ||
| @@ -483,10 +586,13 @@ out: | |||
| 483 | mutex_unlock(&rtd->pcm_mutex); | 586 | mutex_unlock(&rtd->pcm_mutex); |
| 484 | 587 | ||
| 485 | pm_runtime_put(platform->dev); | 588 | pm_runtime_put(platform->dev); |
| 486 | pm_runtime_put(codec_dai->dev); | 589 | for (i = 0; i < rtd->num_codecs; i++) |
| 590 | pm_runtime_put(rtd->codec_dais[i]->dev); | ||
| 487 | pm_runtime_put(cpu_dai->dev); | 591 | pm_runtime_put(cpu_dai->dev); |
| 488 | if (!codec_dai->active) | 592 | for (i = 0; i < rtd->num_codecs; i++) { |
| 489 | pinctrl_pm_select_sleep_state(codec_dai->dev); | 593 | if (!rtd->codec_dais[i]->active) |
| 594 | pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev); | ||
| 595 | } | ||
| 490 | if (!cpu_dai->active) | 596 | if (!cpu_dai->active) |
| 491 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | 597 | pinctrl_pm_select_sleep_state(cpu_dai->dev); |
| 492 | 598 | ||
| @@ -502,7 +608,7 @@ static void close_delayed_work(struct work_struct *work) | |||
| 502 | { | 608 | { |
| 503 | struct snd_soc_pcm_runtime *rtd = | 609 | struct snd_soc_pcm_runtime *rtd = |
| 504 | container_of(work, struct snd_soc_pcm_runtime, delayed_work.work); | 610 | container_of(work, struct snd_soc_pcm_runtime, delayed_work.work); |
| 505 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 611 | struct snd_soc_dai *codec_dai = rtd->codec_dais[0]; |
| 506 | 612 | ||
| 507 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 613 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
| 508 | 614 | ||
| @@ -531,7 +637,8 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
| 531 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 637 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 532 | struct snd_soc_platform *platform = rtd->platform; | 638 | struct snd_soc_platform *platform = rtd->platform; |
| 533 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 639 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 534 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 640 | struct snd_soc_dai *codec_dai; |
| 641 | int i; | ||
| 535 | 642 | ||
| 536 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 643 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
| 537 | 644 | ||
| @@ -541,14 +648,20 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
| 541 | if (!cpu_dai->active) | 648 | if (!cpu_dai->active) |
| 542 | cpu_dai->rate = 0; | 649 | cpu_dai->rate = 0; |
| 543 | 650 | ||
| 544 | if (!codec_dai->active) | 651 | for (i = 0; i < rtd->num_codecs; i++) { |
| 545 | codec_dai->rate = 0; | 652 | codec_dai = rtd->codec_dais[i]; |
| 653 | if (!codec_dai->active) | ||
| 654 | codec_dai->rate = 0; | ||
| 655 | } | ||
| 546 | 656 | ||
| 547 | if (cpu_dai->driver->ops->shutdown) | 657 | if (cpu_dai->driver->ops->shutdown) |
| 548 | cpu_dai->driver->ops->shutdown(substream, cpu_dai); | 658 | cpu_dai->driver->ops->shutdown(substream, cpu_dai); |
| 549 | 659 | ||
| 550 | if (codec_dai->driver->ops->shutdown) | 660 | for (i = 0; i < rtd->num_codecs; i++) { |
| 551 | codec_dai->driver->ops->shutdown(substream, codec_dai); | 661 | codec_dai = rtd->codec_dais[i]; |
| 662 | if (codec_dai->driver->ops->shutdown) | ||
| 663 | codec_dai->driver->ops->shutdown(substream, codec_dai); | ||
| 664 | } | ||
| 552 | 665 | ||
| 553 | if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown) | 666 | if (rtd->dai_link->ops && rtd->dai_link->ops->shutdown) |
| 554 | rtd->dai_link->ops->shutdown(substream); | 667 | rtd->dai_link->ops->shutdown(substream); |
| @@ -578,10 +691,13 @@ static int soc_pcm_close(struct snd_pcm_substream *substream) | |||
| 578 | mutex_unlock(&rtd->pcm_mutex); | 691 | mutex_unlock(&rtd->pcm_mutex); |
| 579 | 692 | ||
| 580 | pm_runtime_put(platform->dev); | 693 | pm_runtime_put(platform->dev); |
| 581 | pm_runtime_put(codec_dai->dev); | 694 | for (i = 0; i < rtd->num_codecs; i++) |
| 695 | pm_runtime_put(rtd->codec_dais[i]->dev); | ||
| 582 | pm_runtime_put(cpu_dai->dev); | 696 | pm_runtime_put(cpu_dai->dev); |
| 583 | if (!codec_dai->active) | 697 | for (i = 0; i < rtd->num_codecs; i++) { |
| 584 | pinctrl_pm_select_sleep_state(codec_dai->dev); | 698 | if (!rtd->codec_dais[i]->active) |
| 699 | pinctrl_pm_select_sleep_state(rtd->codec_dais[i]->dev); | ||
| 700 | } | ||
| 585 | if (!cpu_dai->active) | 701 | if (!cpu_dai->active) |
| 586 | pinctrl_pm_select_sleep_state(cpu_dai->dev); | 702 | pinctrl_pm_select_sleep_state(cpu_dai->dev); |
| 587 | 703 | ||
| @@ -598,8 +714,8 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
| 598 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 714 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 599 | struct snd_soc_platform *platform = rtd->platform; | 715 | struct snd_soc_platform *platform = rtd->platform; |
| 600 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 716 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 601 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 717 | struct snd_soc_dai *codec_dai; |
| 602 | int ret = 0; | 718 | int i, ret = 0; |
| 603 | 719 | ||
| 604 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 720 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
| 605 | 721 | ||
| @@ -621,12 +737,16 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
| 621 | } | 737 | } |
| 622 | } | 738 | } |
| 623 | 739 | ||
| 624 | if (codec_dai->driver->ops && codec_dai->driver->ops->prepare) { | 740 | for (i = 0; i < rtd->num_codecs; i++) { |
| 625 | ret = codec_dai->driver->ops->prepare(substream, codec_dai); | 741 | codec_dai = rtd->codec_dais[i]; |
| 626 | if (ret < 0) { | 742 | if (codec_dai->driver->ops && codec_dai->driver->ops->prepare) { |
| 627 | dev_err(codec_dai->dev, "ASoC: DAI prepare error: %d\n", | 743 | ret = codec_dai->driver->ops->prepare(substream, |
| 628 | ret); | 744 | codec_dai); |
| 629 | goto out; | 745 | if (ret < 0) { |
| 746 | dev_err(codec_dai->dev, | ||
| 747 | "ASoC: DAI prepare error: %d\n", ret); | ||
| 748 | goto out; | ||
| 749 | } | ||
| 630 | } | 750 | } |
| 631 | } | 751 | } |
| 632 | 752 | ||
| @@ -649,13 +769,44 @@ static int soc_pcm_prepare(struct snd_pcm_substream *substream) | |||
| 649 | snd_soc_dapm_stream_event(rtd, substream->stream, | 769 | snd_soc_dapm_stream_event(rtd, substream->stream, |
| 650 | SND_SOC_DAPM_STREAM_START); | 770 | SND_SOC_DAPM_STREAM_START); |
| 651 | 771 | ||
| 652 | snd_soc_dai_digital_mute(codec_dai, 0, substream->stream); | 772 | for (i = 0; i < rtd->num_codecs; i++) |
| 773 | snd_soc_dai_digital_mute(rtd->codec_dais[i], 0, | ||
| 774 | substream->stream); | ||
| 653 | 775 | ||
| 654 | out: | 776 | out: |
| 655 | mutex_unlock(&rtd->pcm_mutex); | 777 | mutex_unlock(&rtd->pcm_mutex); |
| 656 | return ret; | 778 | return ret; |
| 657 | } | 779 | } |
| 658 | 780 | ||
| 781 | static void soc_pcm_codec_params_fixup(struct snd_pcm_hw_params *params, | ||
| 782 | unsigned int mask) | ||
| 783 | { | ||
| 784 | struct snd_interval *interval; | ||
| 785 | int channels = hweight_long(mask); | ||
| 786 | |||
| 787 | interval = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); | ||
| 788 | interval->min = channels; | ||
| 789 | interval->max = channels; | ||
| 790 | } | ||
| 791 | |||
| 792 | int soc_dai_hw_params(struct snd_pcm_substream *substream, | ||
| 793 | struct snd_pcm_hw_params *params, | ||
| 794 | struct snd_soc_dai *dai) | ||
| 795 | { | ||
| 796 | int ret; | ||
| 797 | |||
| 798 | if (dai->driver->ops && dai->driver->ops->hw_params) { | ||
| 799 | ret = dai->driver->ops->hw_params(substream, params, dai); | ||
| 800 | if (ret < 0) { | ||
| 801 | dev_err(dai->dev, "ASoC: can't set %s hw params: %d\n", | ||
| 802 | dai->name, ret); | ||
| 803 | return ret; | ||
| 804 | } | ||
| 805 | } | ||
| 806 | |||
| 807 | return 0; | ||
| 808 | } | ||
| 809 | |||
| 659 | /* | 810 | /* |
| 660 | * Called by ALSA when the hardware params are set by application. This | 811 | * Called by ALSA when the hardware params are set by application. This |
| 661 | * function can also be called multiple times and can allocate buffers | 812 | * function can also be called multiple times and can allocate buffers |
| @@ -667,8 +818,7 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 667 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 818 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 668 | struct snd_soc_platform *platform = rtd->platform; | 819 | struct snd_soc_platform *platform = rtd->platform; |
| 669 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 820 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 670 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 821 | int i, ret = 0; |
| 671 | int ret = 0; | ||
| 672 | 822 | ||
| 673 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 823 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
| 674 | 824 | ||
| @@ -685,29 +835,40 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 685 | } | 835 | } |
| 686 | } | 836 | } |
| 687 | 837 | ||
| 688 | if (codec_dai->driver->ops && codec_dai->driver->ops->hw_params) { | 838 | for (i = 0; i < rtd->num_codecs; i++) { |
| 689 | ret = codec_dai->driver->ops->hw_params(substream, params, codec_dai); | 839 | struct snd_soc_dai *codec_dai = rtd->codec_dais[i]; |
| 690 | if (ret < 0) { | 840 | struct snd_pcm_hw_params codec_params; |
| 691 | dev_err(codec_dai->dev, "ASoC: can't set %s hw params:" | 841 | |
| 692 | " %d\n", codec_dai->name, ret); | 842 | /* copy params for each codec */ |
| 843 | codec_params = *params; | ||
| 844 | |||
| 845 | /* fixup params based on TDM slot masks */ | ||
| 846 | if (codec_dai->tx_mask) | ||
| 847 | soc_pcm_codec_params_fixup(&codec_params, | ||
| 848 | codec_dai->tx_mask); | ||
| 849 | if (codec_dai->rx_mask) | ||
| 850 | soc_pcm_codec_params_fixup(&codec_params, | ||
| 851 | codec_dai->rx_mask); | ||
| 852 | |||
| 853 | ret = soc_dai_hw_params(substream, &codec_params, codec_dai); | ||
| 854 | if(ret < 0) | ||
| 693 | goto codec_err; | 855 | goto codec_err; |
| 694 | } | ||
| 695 | } | ||
| 696 | 856 | ||
| 697 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_params) { | 857 | codec_dai->rate = params_rate(&codec_params); |
| 698 | ret = cpu_dai->driver->ops->hw_params(substream, params, cpu_dai); | 858 | codec_dai->channels = params_channels(&codec_params); |
| 699 | if (ret < 0) { | 859 | codec_dai->sample_bits = snd_pcm_format_physical_width( |
| 700 | dev_err(cpu_dai->dev, "ASoC: %s hw params failed: %d\n", | 860 | params_format(&codec_params)); |
| 701 | cpu_dai->name, ret); | ||
| 702 | goto interface_err; | ||
| 703 | } | ||
| 704 | } | 861 | } |
| 705 | 862 | ||
| 863 | ret = soc_dai_hw_params(substream, params, cpu_dai); | ||
| 864 | if (ret < 0) | ||
| 865 | goto interface_err; | ||
| 866 | |||
| 706 | if (platform->driver->ops && platform->driver->ops->hw_params) { | 867 | if (platform->driver->ops && platform->driver->ops->hw_params) { |
| 707 | ret = platform->driver->ops->hw_params(substream, params); | 868 | ret = platform->driver->ops->hw_params(substream, params); |
| 708 | if (ret < 0) { | 869 | if (ret < 0) { |
| 709 | dev_err(platform->dev, "ASoC: %s hw params failed: %d\n", | 870 | dev_err(platform->dev, "ASoC: %s hw params failed: %d\n", |
| 710 | platform->name, ret); | 871 | platform->component.name, ret); |
| 711 | goto platform_err; | 872 | goto platform_err; |
| 712 | } | 873 | } |
| 713 | } | 874 | } |
| @@ -718,11 +879,6 @@ static int soc_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 718 | cpu_dai->sample_bits = | 879 | cpu_dai->sample_bits = |
| 719 | snd_pcm_format_physical_width(params_format(params)); | 880 | snd_pcm_format_physical_width(params_format(params)); |
| 720 | 881 | ||
| 721 | codec_dai->rate = params_rate(params); | ||
| 722 | codec_dai->channels = params_channels(params); | ||
| 723 | codec_dai->sample_bits = | ||
| 724 | snd_pcm_format_physical_width(params_format(params)); | ||
| 725 | |||
| 726 | out: | 882 | out: |
| 727 | mutex_unlock(&rtd->pcm_mutex); | 883 | mutex_unlock(&rtd->pcm_mutex); |
| 728 | return ret; | 884 | return ret; |
| @@ -732,10 +888,16 @@ platform_err: | |||
| 732 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); | 888 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); |
| 733 | 889 | ||
| 734 | interface_err: | 890 | interface_err: |
| 735 | if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) | 891 | i = rtd->num_codecs; |
| 736 | codec_dai->driver->ops->hw_free(substream, codec_dai); | ||
| 737 | 892 | ||
| 738 | codec_err: | 893 | codec_err: |
| 894 | while (--i >= 0) { | ||
| 895 | struct snd_soc_dai *codec_dai = rtd->codec_dais[i]; | ||
| 896 | if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) | ||
| 897 | codec_dai->driver->ops->hw_free(substream, codec_dai); | ||
| 898 | codec_dai->rate = 0; | ||
| 899 | } | ||
| 900 | |||
| 739 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) | 901 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) |
| 740 | rtd->dai_link->ops->hw_free(substream); | 902 | rtd->dai_link->ops->hw_free(substream); |
| 741 | 903 | ||
| @@ -751,8 +913,9 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
| 751 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 913 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 752 | struct snd_soc_platform *platform = rtd->platform; | 914 | struct snd_soc_platform *platform = rtd->platform; |
| 753 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 915 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 754 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 916 | struct snd_soc_dai *codec_dai; |
| 755 | bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; | 917 | bool playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; |
| 918 | int i; | ||
| 756 | 919 | ||
| 757 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); | 920 | mutex_lock_nested(&rtd->pcm_mutex, rtd->pcm_subclass); |
| 758 | 921 | ||
| @@ -763,16 +926,22 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
| 763 | cpu_dai->sample_bits = 0; | 926 | cpu_dai->sample_bits = 0; |
| 764 | } | 927 | } |
| 765 | 928 | ||
| 766 | if (codec_dai->active == 1) { | 929 | for (i = 0; i < rtd->num_codecs; i++) { |
| 767 | codec_dai->rate = 0; | 930 | codec_dai = rtd->codec_dais[i]; |
| 768 | codec_dai->channels = 0; | 931 | if (codec_dai->active == 1) { |
| 769 | codec_dai->sample_bits = 0; | 932 | codec_dai->rate = 0; |
| 933 | codec_dai->channels = 0; | ||
| 934 | codec_dai->sample_bits = 0; | ||
| 935 | } | ||
| 770 | } | 936 | } |
| 771 | 937 | ||
| 772 | /* apply codec digital mute */ | 938 | /* apply codec digital mute */ |
| 773 | if ((playback && codec_dai->playback_active == 1) || | 939 | for (i = 0; i < rtd->num_codecs; i++) { |
| 774 | (!playback && codec_dai->capture_active == 1)) | 940 | if ((playback && rtd->codec_dais[i]->playback_active == 1) || |
| 775 | snd_soc_dai_digital_mute(codec_dai, 1, substream->stream); | 941 | (!playback && rtd->codec_dais[i]->capture_active == 1)) |
| 942 | snd_soc_dai_digital_mute(rtd->codec_dais[i], 1, | ||
| 943 | substream->stream); | ||
| 944 | } | ||
| 776 | 945 | ||
| 777 | /* free any machine hw params */ | 946 | /* free any machine hw params */ |
| 778 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) | 947 | if (rtd->dai_link->ops && rtd->dai_link->ops->hw_free) |
| @@ -783,8 +952,11 @@ static int soc_pcm_hw_free(struct snd_pcm_substream *substream) | |||
| 783 | platform->driver->ops->hw_free(substream); | 952 | platform->driver->ops->hw_free(substream); |
| 784 | 953 | ||
| 785 | /* now free hw params for the DAIs */ | 954 | /* now free hw params for the DAIs */ |
| 786 | if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) | 955 | for (i = 0; i < rtd->num_codecs; i++) { |
| 787 | codec_dai->driver->ops->hw_free(substream, codec_dai); | 956 | codec_dai = rtd->codec_dais[i]; |
| 957 | if (codec_dai->driver->ops && codec_dai->driver->ops->hw_free) | ||
| 958 | codec_dai->driver->ops->hw_free(substream, codec_dai); | ||
| 959 | } | ||
| 788 | 960 | ||
| 789 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) | 961 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->hw_free) |
| 790 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); | 962 | cpu_dai->driver->ops->hw_free(substream, cpu_dai); |
| @@ -798,13 +970,17 @@ static int soc_pcm_trigger(struct snd_pcm_substream *substream, int cmd) | |||
| 798 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 970 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 799 | struct snd_soc_platform *platform = rtd->platform; | 971 | struct snd_soc_platform *platform = rtd->platform; |
| 800 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 972 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 801 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 973 | struct snd_soc_dai *codec_dai; |
| 802 | int ret; | 974 | int i, ret; |
| 803 | 975 | ||
| 804 | if (codec_dai->driver->ops && codec_dai->driver->ops->trigger) { | 976 | for (i = 0; i < rtd->num_codecs; i++) { |
| 805 | ret = codec_dai->driver->ops->trigger(substream, cmd, codec_dai); | 977 | codec_dai = rtd->codec_dais[i]; |
| 806 | if (ret < 0) | 978 | if (codec_dai->driver->ops && codec_dai->driver->ops->trigger) { |
| 807 | return ret; | 979 | ret = codec_dai->driver->ops->trigger(substream, |
| 980 | cmd, codec_dai); | ||
| 981 | if (ret < 0) | ||
| 982 | return ret; | ||
| 983 | } | ||
| 808 | } | 984 | } |
| 809 | 985 | ||
| 810 | if (platform->driver->ops && platform->driver->ops->trigger) { | 986 | if (platform->driver->ops && platform->driver->ops->trigger) { |
| @@ -834,14 +1010,18 @@ static int soc_pcm_bespoke_trigger(struct snd_pcm_substream *substream, | |||
| 834 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1010 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 835 | struct snd_soc_platform *platform = rtd->platform; | 1011 | struct snd_soc_platform *platform = rtd->platform; |
| 836 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1012 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 837 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 1013 | struct snd_soc_dai *codec_dai; |
| 838 | int ret; | 1014 | int i, ret; |
| 839 | 1015 | ||
| 840 | if (codec_dai->driver->ops && | 1016 | for (i = 0; i < rtd->num_codecs; i++) { |
| 841 | codec_dai->driver->ops->bespoke_trigger) { | 1017 | codec_dai = rtd->codec_dais[i]; |
| 842 | ret = codec_dai->driver->ops->bespoke_trigger(substream, cmd, codec_dai); | 1018 | if (codec_dai->driver->ops && |
| 843 | if (ret < 0) | 1019 | codec_dai->driver->ops->bespoke_trigger) { |
| 844 | return ret; | 1020 | ret = codec_dai->driver->ops->bespoke_trigger(substream, |
| 1021 | cmd, codec_dai); | ||
| 1022 | if (ret < 0) | ||
| 1023 | return ret; | ||
| 1024 | } | ||
| 845 | } | 1025 | } |
| 846 | 1026 | ||
| 847 | if (platform->driver->bespoke_trigger) { | 1027 | if (platform->driver->bespoke_trigger) { |
| @@ -867,10 +1047,12 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) | |||
| 867 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 1047 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 868 | struct snd_soc_platform *platform = rtd->platform; | 1048 | struct snd_soc_platform *platform = rtd->platform; |
| 869 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 1049 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 870 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 1050 | struct snd_soc_dai *codec_dai; |
| 871 | struct snd_pcm_runtime *runtime = substream->runtime; | 1051 | struct snd_pcm_runtime *runtime = substream->runtime; |
| 872 | snd_pcm_uframes_t offset = 0; | 1052 | snd_pcm_uframes_t offset = 0; |
| 873 | snd_pcm_sframes_t delay = 0; | 1053 | snd_pcm_sframes_t delay = 0; |
| 1054 | snd_pcm_sframes_t codec_delay = 0; | ||
| 1055 | int i; | ||
| 874 | 1056 | ||
| 875 | if (platform->driver->ops && platform->driver->ops->pointer) | 1057 | if (platform->driver->ops && platform->driver->ops->pointer) |
| 876 | offset = platform->driver->ops->pointer(substream); | 1058 | offset = platform->driver->ops->pointer(substream); |
| @@ -878,11 +1060,21 @@ static snd_pcm_uframes_t soc_pcm_pointer(struct snd_pcm_substream *substream) | |||
| 878 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay) | 1060 | if (cpu_dai->driver->ops && cpu_dai->driver->ops->delay) |
| 879 | delay += cpu_dai->driver->ops->delay(substream, cpu_dai); | 1061 | delay += cpu_dai->driver->ops->delay(substream, cpu_dai); |
| 880 | 1062 | ||
| 881 | if (codec_dai->driver->ops && codec_dai->driver->ops->delay) | 1063 | for (i = 0; i < rtd->num_codecs; i++) { |
| 882 | delay += codec_dai->driver->ops->delay(substream, codec_dai); | 1064 | codec_dai = rtd->codec_dais[i]; |
| 1065 | if (codec_dai->driver->ops && codec_dai->driver->ops->delay) | ||
| 1066 | codec_delay = max(codec_delay, | ||
| 1067 | codec_dai->driver->ops->delay(substream, | ||
| 1068 | codec_dai)); | ||
| 1069 | } | ||
| 1070 | delay += codec_delay; | ||
| 883 | 1071 | ||
| 1072 | /* | ||
| 1073 | * None of the existing platform drivers implement delay(), so | ||
| 1074 | * for now the codec_dai of first multicodec entry is used | ||
| 1075 | */ | ||
| 884 | if (platform->driver->delay) | 1076 | if (platform->driver->delay) |
| 885 | delay += platform->driver->delay(substream, codec_dai); | 1077 | delay += platform->driver->delay(substream, rtd->codec_dais[0]); |
| 886 | 1078 | ||
| 887 | runtime->delay = delay; | 1079 | runtime->delay = delay; |
| 888 | 1080 | ||
| @@ -985,7 +1177,7 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, | |||
| 985 | struct snd_soc_dapm_widget *widget, int stream) | 1177 | struct snd_soc_dapm_widget *widget, int stream) |
| 986 | { | 1178 | { |
| 987 | struct snd_soc_pcm_runtime *be; | 1179 | struct snd_soc_pcm_runtime *be; |
| 988 | int i; | 1180 | int i, j; |
| 989 | 1181 | ||
| 990 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { | 1182 | if (stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 991 | for (i = 0; i < card->num_links; i++) { | 1183 | for (i = 0; i < card->num_links; i++) { |
| @@ -994,9 +1186,14 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, | |||
| 994 | if (!be->dai_link->no_pcm) | 1186 | if (!be->dai_link->no_pcm) |
| 995 | continue; | 1187 | continue; |
| 996 | 1188 | ||
| 997 | if (be->cpu_dai->playback_widget == widget || | 1189 | if (be->cpu_dai->playback_widget == widget) |
| 998 | be->codec_dai->playback_widget == widget) | ||
| 999 | return be; | 1190 | return be; |
| 1191 | |||
| 1192 | for (j = 0; j < be->num_codecs; j++) { | ||
| 1193 | struct snd_soc_dai *dai = be->codec_dais[j]; | ||
| 1194 | if (dai->playback_widget == widget) | ||
| 1195 | return be; | ||
| 1196 | } | ||
| 1000 | } | 1197 | } |
| 1001 | } else { | 1198 | } else { |
| 1002 | 1199 | ||
| @@ -1006,9 +1203,14 @@ static struct snd_soc_pcm_runtime *dpcm_get_be(struct snd_soc_card *card, | |||
| 1006 | if (!be->dai_link->no_pcm) | 1203 | if (!be->dai_link->no_pcm) |
| 1007 | continue; | 1204 | continue; |
| 1008 | 1205 | ||
| 1009 | if (be->cpu_dai->capture_widget == widget || | 1206 | if (be->cpu_dai->capture_widget == widget) |
| 1010 | be->codec_dai->capture_widget == widget) | ||
| 1011 | return be; | 1207 | return be; |
| 1208 | |||
| 1209 | for (j = 0; j < be->num_codecs; j++) { | ||
| 1210 | struct snd_soc_dai *dai = be->codec_dais[j]; | ||
| 1211 | if (dai->capture_widget == widget) | ||
| 1212 | return be; | ||
| 1213 | } | ||
| 1012 | } | 1214 | } |
| 1013 | } | 1215 | } |
| 1014 | 1216 | ||
| @@ -1071,6 +1273,7 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, | |||
| 1071 | 1273 | ||
| 1072 | /* Destroy any old FE <--> BE connections */ | 1274 | /* Destroy any old FE <--> BE connections */ |
| 1073 | list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) { | 1275 | list_for_each_entry(dpcm, &fe->dpcm[stream].be_clients, list_be) { |
| 1276 | unsigned int i; | ||
| 1074 | 1277 | ||
| 1075 | /* is there a valid CPU DAI widget for this BE */ | 1278 | /* is there a valid CPU DAI widget for this BE */ |
| 1076 | widget = dai_get_widget(dpcm->be->cpu_dai, stream); | 1279 | widget = dai_get_widget(dpcm->be->cpu_dai, stream); |
| @@ -1080,11 +1283,14 @@ static int dpcm_prune_paths(struct snd_soc_pcm_runtime *fe, int stream, | |||
| 1080 | continue; | 1283 | continue; |
| 1081 | 1284 | ||
| 1082 | /* is there a valid CODEC DAI widget for this BE */ | 1285 | /* is there a valid CODEC DAI widget for this BE */ |
| 1083 | widget = dai_get_widget(dpcm->be->codec_dai, stream); | 1286 | for (i = 0; i < dpcm->be->num_codecs; i++) { |
| 1287 | struct snd_soc_dai *dai = dpcm->be->codec_dais[i]; | ||
| 1288 | widget = dai_get_widget(dai, stream); | ||
| 1084 | 1289 | ||
| 1085 | /* prune the BE if it's no longer in our active list */ | 1290 | /* prune the BE if it's no longer in our active list */ |
| 1086 | if (widget && widget_in_list(list, widget)) | 1291 | if (widget && widget_in_list(list, widget)) |
| 1087 | continue; | 1292 | continue; |
| 1293 | } | ||
| 1088 | 1294 | ||
| 1089 | dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", | 1295 | dev_dbg(fe->dev, "ASoC: pruning %s BE %s for %s\n", |
| 1090 | stream ? "capture" : "playback", | 1296 | stream ? "capture" : "playback", |
| @@ -2069,6 +2275,7 @@ int soc_dpcm_runtime_update(struct snd_soc_card *card) | |||
| 2069 | dpcm_be_disconnect(fe, SNDRV_PCM_STREAM_PLAYBACK); | 2275 | dpcm_be_disconnect(fe, SNDRV_PCM_STREAM_PLAYBACK); |
| 2070 | } | 2276 | } |
| 2071 | 2277 | ||
| 2278 | dpcm_path_put(&list); | ||
| 2072 | capture: | 2279 | capture: |
| 2073 | /* skip if FE doesn't have capture capability */ | 2280 | /* skip if FE doesn't have capture capability */ |
| 2074 | if (!fe->cpu_dai->driver->capture.channels_min) | 2281 | if (!fe->cpu_dai->driver->capture.channels_min) |
| @@ -2113,16 +2320,22 @@ int soc_dpcm_be_digital_mute(struct snd_soc_pcm_runtime *fe, int mute) | |||
| 2113 | list_for_each_entry(dpcm, clients, list_be) { | 2320 | list_for_each_entry(dpcm, clients, list_be) { |
| 2114 | 2321 | ||
| 2115 | struct snd_soc_pcm_runtime *be = dpcm->be; | 2322 | struct snd_soc_pcm_runtime *be = dpcm->be; |
| 2116 | struct snd_soc_dai *dai = be->codec_dai; | 2323 | int i; |
| 2117 | struct snd_soc_dai_driver *drv = dai->driver; | ||
| 2118 | 2324 | ||
| 2119 | if (be->dai_link->ignore_suspend) | 2325 | if (be->dai_link->ignore_suspend) |
| 2120 | continue; | 2326 | continue; |
| 2121 | 2327 | ||
| 2122 | dev_dbg(be->dev, "ASoC: BE digital mute %s\n", be->dai_link->name); | 2328 | for (i = 0; i < be->num_codecs; i++) { |
| 2329 | struct snd_soc_dai *dai = be->codec_dais[i]; | ||
| 2330 | struct snd_soc_dai_driver *drv = dai->driver; | ||
| 2331 | |||
| 2332 | dev_dbg(be->dev, "ASoC: BE digital mute %s\n", | ||
| 2333 | be->dai_link->name); | ||
| 2123 | 2334 | ||
| 2124 | if (drv->ops && drv->ops->digital_mute && dai->playback_active) | 2335 | if (drv->ops && drv->ops->digital_mute && |
| 2125 | drv->ops->digital_mute(dai, mute); | 2336 | dai->playback_active) |
| 2337 | drv->ops->digital_mute(dai, mute); | ||
| 2338 | } | ||
| 2126 | } | 2339 | } |
| 2127 | 2340 | ||
| 2128 | return 0; | 2341 | return 0; |
| @@ -2187,22 +2400,27 @@ static int dpcm_fe_dai_close(struct snd_pcm_substream *fe_substream) | |||
| 2187 | int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | 2400 | int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) |
| 2188 | { | 2401 | { |
| 2189 | struct snd_soc_platform *platform = rtd->platform; | 2402 | struct snd_soc_platform *platform = rtd->platform; |
| 2190 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 2403 | struct snd_soc_dai *codec_dai; |
| 2191 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 2404 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 2192 | struct snd_pcm *pcm; | 2405 | struct snd_pcm *pcm; |
| 2193 | char new_name[64]; | 2406 | char new_name[64]; |
| 2194 | int ret = 0, playback = 0, capture = 0; | 2407 | int ret = 0, playback = 0, capture = 0; |
| 2408 | int i; | ||
| 2195 | 2409 | ||
| 2196 | if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) { | 2410 | if (rtd->dai_link->dynamic || rtd->dai_link->no_pcm) { |
| 2197 | playback = rtd->dai_link->dpcm_playback; | 2411 | playback = rtd->dai_link->dpcm_playback; |
| 2198 | capture = rtd->dai_link->dpcm_capture; | 2412 | capture = rtd->dai_link->dpcm_capture; |
| 2199 | } else { | 2413 | } else { |
| 2200 | if (codec_dai->driver->playback.channels_min && | 2414 | for (i = 0; i < rtd->num_codecs; i++) { |
| 2201 | cpu_dai->driver->playback.channels_min) | 2415 | codec_dai = rtd->codec_dais[i]; |
| 2202 | playback = 1; | 2416 | if (codec_dai->driver->playback.channels_min) |
| 2203 | if (codec_dai->driver->capture.channels_min && | 2417 | playback = 1; |
| 2204 | cpu_dai->driver->capture.channels_min) | 2418 | if (codec_dai->driver->capture.channels_min) |
| 2205 | capture = 1; | 2419 | capture = 1; |
| 2420 | } | ||
| 2421 | |||
| 2422 | capture = capture && cpu_dai->driver->capture.channels_min; | ||
| 2423 | playback = playback && cpu_dai->driver->playback.channels_min; | ||
| 2206 | } | 2424 | } |
| 2207 | 2425 | ||
| 2208 | if (rtd->dai_link->playback_only) { | 2426 | if (rtd->dai_link->playback_only) { |
| @@ -2228,7 +2446,9 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
| 2228 | rtd->dai_link->stream_name); | 2446 | rtd->dai_link->stream_name); |
| 2229 | else | 2447 | else |
| 2230 | snprintf(new_name, sizeof(new_name), "%s %s-%d", | 2448 | snprintf(new_name, sizeof(new_name), "%s %s-%d", |
| 2231 | rtd->dai_link->stream_name, codec_dai->name, num); | 2449 | rtd->dai_link->stream_name, |
| 2450 | (rtd->num_codecs > 1) ? | ||
| 2451 | "multicodec" : rtd->codec_dai->name, num); | ||
| 2232 | 2452 | ||
| 2233 | ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback, | 2453 | ret = snd_pcm_new(rtd->card->snd_card, new_name, num, playback, |
| 2234 | capture, &pcm); | 2454 | capture, &pcm); |
| @@ -2301,8 +2521,9 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
| 2301 | 2521 | ||
| 2302 | pcm->private_free = platform->driver->pcm_free; | 2522 | pcm->private_free = platform->driver->pcm_free; |
| 2303 | out: | 2523 | out: |
| 2304 | dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", codec_dai->name, | 2524 | dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", |
| 2305 | cpu_dai->name); | 2525 | (rtd->num_codecs > 1) ? "multicodec" : rtd->codec_dai->name, |
| 2526 | cpu_dai->name); | ||
| 2306 | return ret; | 2527 | return ret; |
| 2307 | } | 2528 | } |
| 2308 | 2529 | ||
diff --git a/sound/soc/tegra/tegra_alc5632.c b/sound/soc/tegra/tegra_alc5632.c index 02734bd4f09b..a83aff09dce2 100644 --- a/sound/soc/tegra/tegra_alc5632.c +++ b/sound/soc/tegra/tegra_alc5632.c | |||
| @@ -41,8 +41,7 @@ static int tegra_alc5632_asoc_hw_params(struct snd_pcm_substream *substream, | |||
| 41 | { | 41 | { |
| 42 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 42 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 43 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 43 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 44 | struct snd_soc_codec *codec = codec_dai->codec; | 44 | struct snd_soc_card *card = rtd->card; |
| 45 | struct snd_soc_card *card = codec->card; | ||
| 46 | struct tegra_alc5632 *alc5632 = snd_soc_card_get_drvdata(card); | 45 | struct tegra_alc5632 *alc5632 = snd_soc_card_get_drvdata(card); |
| 47 | int srate, mclk; | 46 | int srate, mclk; |
| 48 | int err; | 47 | int err; |
| @@ -105,7 +104,7 @@ static int tegra_alc5632_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
| 105 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 104 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 106 | struct snd_soc_codec *codec = codec_dai->codec; | 105 | struct snd_soc_codec *codec = codec_dai->codec; |
| 107 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 106 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 108 | struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(codec->card); | 107 | struct tegra_alc5632 *machine = snd_soc_card_get_drvdata(rtd->card); |
| 109 | 108 | ||
| 110 | snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, | 109 | snd_soc_jack_new(codec, "Headset Jack", SND_JACK_HEADSET, |
| 111 | &tegra_alc5632_hs_jack); | 110 | &tegra_alc5632_hs_jack); |
diff --git a/sound/soc/tegra/tegra_max98090.c b/sound/soc/tegra/tegra_max98090.c index ce73e1f62c4b..b86cd9936ef1 100644 --- a/sound/soc/tegra/tegra_max98090.c +++ b/sound/soc/tegra/tegra_max98090.c | |||
| @@ -49,8 +49,7 @@ static int tegra_max98090_asoc_hw_params(struct snd_pcm_substream *substream, | |||
| 49 | { | 49 | { |
| 50 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 50 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 51 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 51 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 52 | struct snd_soc_codec *codec = codec_dai->codec; | 52 | struct snd_soc_card *card = rtd->card; |
| 53 | struct snd_soc_card *card = codec->card; | ||
| 54 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); | 53 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(card); |
| 55 | int srate, mclk; | 54 | int srate, mclk; |
| 56 | int err; | 55 | int err; |
| @@ -127,7 +126,7 @@ static int tegra_max98090_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
| 127 | { | 126 | { |
| 128 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 127 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 129 | struct snd_soc_codec *codec = codec_dai->codec; | 128 | struct snd_soc_codec *codec = codec_dai->codec; |
| 130 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(codec->card); | 129 | struct tegra_max98090 *machine = snd_soc_card_get_drvdata(rtd->card); |
| 131 | 130 | ||
| 132 | if (gpio_is_valid(machine->gpio_hp_det)) { | 131 | if (gpio_is_valid(machine->gpio_hp_det)) { |
| 133 | snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, | 132 | snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, |
diff --git a/sound/soc/tegra/tegra_rt5640.c b/sound/soc/tegra/tegra_rt5640.c index 4feb16a99e02..a6898831fb9f 100644 --- a/sound/soc/tegra/tegra_rt5640.c +++ b/sound/soc/tegra/tegra_rt5640.c | |||
| @@ -51,8 +51,7 @@ static int tegra_rt5640_asoc_hw_params(struct snd_pcm_substream *substream, | |||
| 51 | { | 51 | { |
| 52 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 52 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 53 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 53 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 54 | struct snd_soc_codec *codec = codec_dai->codec; | 54 | struct snd_soc_card *card = rtd->card; |
| 55 | struct snd_soc_card *card = codec->card; | ||
| 56 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); | 55 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(card); |
| 57 | int srate, mclk; | 56 | int srate, mclk; |
| 58 | int err; | 57 | int err; |
| @@ -110,7 +109,7 @@ static int tegra_rt5640_asoc_init(struct snd_soc_pcm_runtime *rtd) | |||
| 110 | { | 109 | { |
| 111 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 110 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 112 | struct snd_soc_codec *codec = codec_dai->codec; | 111 | struct snd_soc_codec *codec = codec_dai->codec; |
| 113 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(codec->card); | 112 | struct tegra_rt5640 *machine = snd_soc_card_get_drvdata(rtd->card); |
| 114 | 113 | ||
| 115 | snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, | 114 | snd_soc_jack_new(codec, "Headphones", SND_JACK_HEADPHONE, |
| 116 | &tegra_rt5640_hp_jack); | 115 | &tegra_rt5640_hp_jack); |
diff --git a/sound/soc/tegra/tegra_wm8753.c b/sound/soc/tegra/tegra_wm8753.c index 8e774d1a243c..769e28f6642e 100644 --- a/sound/soc/tegra/tegra_wm8753.c +++ b/sound/soc/tegra/tegra_wm8753.c | |||
| @@ -55,8 +55,7 @@ static int tegra_wm8753_hw_params(struct snd_pcm_substream *substream, | |||
| 55 | { | 55 | { |
| 56 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 56 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 57 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 57 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 58 | struct snd_soc_codec *codec = codec_dai->codec; | 58 | struct snd_soc_card *card = rtd->card; |
| 59 | struct snd_soc_card *card = codec->card; | ||
| 60 | struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card); | 59 | struct tegra_wm8753 *machine = snd_soc_card_get_drvdata(card); |
| 61 | int srate, mclk; | 60 | int srate, mclk; |
| 62 | int err; | 61 | int err; |
diff --git a/sound/soc/tegra/tegra_wm8903.c b/sound/soc/tegra/tegra_wm8903.c index 0939661df60b..86e05e938585 100644 --- a/sound/soc/tegra/tegra_wm8903.c +++ b/sound/soc/tegra/tegra_wm8903.c | |||
| @@ -60,8 +60,7 @@ static int tegra_wm8903_hw_params(struct snd_pcm_substream *substream, | |||
| 60 | { | 60 | { |
| 61 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 61 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 62 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 62 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 63 | struct snd_soc_codec *codec = codec_dai->codec; | 63 | struct snd_soc_card *card = rtd->card; |
| 64 | struct snd_soc_card *card = codec->card; | ||
| 65 | struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); | 64 | struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); |
| 66 | int srate, mclk; | 65 | int srate, mclk; |
| 67 | int err; | 66 | int err; |
| @@ -173,7 +172,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd) | |||
| 173 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 172 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 174 | struct snd_soc_codec *codec = codec_dai->codec; | 173 | struct snd_soc_codec *codec = codec_dai->codec; |
| 175 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 174 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 176 | struct snd_soc_card *card = codec->card; | 175 | struct snd_soc_card *card = rtd->card; |
| 177 | struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); | 176 | struct tegra_wm8903 *machine = snd_soc_card_get_drvdata(card); |
| 178 | 177 | ||
| 179 | if (gpio_is_valid(machine->gpio_hp_det)) { | 178 | if (gpio_is_valid(machine->gpio_hp_det)) { |
diff --git a/sound/soc/tegra/trimslice.c b/sound/soc/tegra/trimslice.c index 734bfcd21148..589d2d9b553a 100644 --- a/sound/soc/tegra/trimslice.c +++ b/sound/soc/tegra/trimslice.c | |||
| @@ -50,8 +50,7 @@ static int trimslice_asoc_hw_params(struct snd_pcm_substream *substream, | |||
| 50 | { | 50 | { |
| 51 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 51 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 52 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 52 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 53 | struct snd_soc_codec *codec = codec_dai->codec; | 53 | struct snd_soc_card *card = rtd->card; |
| 54 | struct snd_soc_card *card = codec->card; | ||
| 55 | struct tegra_trimslice *trimslice = snd_soc_card_get_drvdata(card); | 54 | struct tegra_trimslice *trimslice = snd_soc_card_get_drvdata(card); |
| 56 | int srate, mclk; | 55 | int srate, mclk; |
| 57 | int err; | 56 | int err; |
diff --git a/tools/lib/lockdep/include/liblockdep/mutex.h b/tools/lib/lockdep/include/liblockdep/mutex.h index c342f7087147..ee53a42818ca 100644 --- a/tools/lib/lockdep/include/liblockdep/mutex.h +++ b/tools/lib/lockdep/include/liblockdep/mutex.h | |||
| @@ -35,7 +35,7 @@ static inline int __mutex_init(liblockdep_pthread_mutex_t *lock, | |||
| 35 | 35 | ||
| 36 | static inline int liblockdep_pthread_mutex_lock(liblockdep_pthread_mutex_t *lock) | 36 | static inline int liblockdep_pthread_mutex_lock(liblockdep_pthread_mutex_t *lock) |
| 37 | { | 37 | { |
| 38 | lock_acquire(&lock->dep_map, 0, 0, 0, 2, NULL, (unsigned long)_RET_IP_); | 38 | lock_acquire(&lock->dep_map, 0, 0, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 39 | return pthread_mutex_lock(&lock->mutex); | 39 | return pthread_mutex_lock(&lock->mutex); |
| 40 | } | 40 | } |
| 41 | 41 | ||
| @@ -47,7 +47,7 @@ static inline int liblockdep_pthread_mutex_unlock(liblockdep_pthread_mutex_t *lo | |||
| 47 | 47 | ||
| 48 | static inline int liblockdep_pthread_mutex_trylock(liblockdep_pthread_mutex_t *lock) | 48 | static inline int liblockdep_pthread_mutex_trylock(liblockdep_pthread_mutex_t *lock) |
| 49 | { | 49 | { |
| 50 | lock_acquire(&lock->dep_map, 0, 1, 0, 2, NULL, (unsigned long)_RET_IP_); | 50 | lock_acquire(&lock->dep_map, 0, 1, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 51 | return pthread_mutex_trylock(&lock->mutex) == 0 ? 1 : 0; | 51 | return pthread_mutex_trylock(&lock->mutex) == 0 ? 1 : 0; |
| 52 | } | 52 | } |
| 53 | 53 | ||
diff --git a/tools/lib/lockdep/include/liblockdep/rwlock.h b/tools/lib/lockdep/include/liblockdep/rwlock.h index a680ab8c2e36..4ec03f861551 100644 --- a/tools/lib/lockdep/include/liblockdep/rwlock.h +++ b/tools/lib/lockdep/include/liblockdep/rwlock.h | |||
| @@ -36,7 +36,7 @@ static inline int __rwlock_init(liblockdep_pthread_rwlock_t *lock, | |||
| 36 | 36 | ||
| 37 | static inline int liblockdep_pthread_rwlock_rdlock(liblockdep_pthread_rwlock_t *lock) | 37 | static inline int liblockdep_pthread_rwlock_rdlock(liblockdep_pthread_rwlock_t *lock) |
| 38 | { | 38 | { |
| 39 | lock_acquire(&lock->dep_map, 0, 0, 2, 2, NULL, (unsigned long)_RET_IP_); | 39 | lock_acquire(&lock->dep_map, 0, 0, 2, 1, NULL, (unsigned long)_RET_IP_); |
| 40 | return pthread_rwlock_rdlock(&lock->rwlock); | 40 | return pthread_rwlock_rdlock(&lock->rwlock); |
| 41 | 41 | ||
| 42 | } | 42 | } |
| @@ -49,19 +49,19 @@ static inline int liblockdep_pthread_rwlock_unlock(liblockdep_pthread_rwlock_t * | |||
| 49 | 49 | ||
| 50 | static inline int liblockdep_pthread_rwlock_wrlock(liblockdep_pthread_rwlock_t *lock) | 50 | static inline int liblockdep_pthread_rwlock_wrlock(liblockdep_pthread_rwlock_t *lock) |
| 51 | { | 51 | { |
| 52 | lock_acquire(&lock->dep_map, 0, 0, 0, 2, NULL, (unsigned long)_RET_IP_); | 52 | lock_acquire(&lock->dep_map, 0, 0, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 53 | return pthread_rwlock_wrlock(&lock->rwlock); | 53 | return pthread_rwlock_wrlock(&lock->rwlock); |
| 54 | } | 54 | } |
| 55 | 55 | ||
| 56 | static inline int liblockdep_pthread_rwlock_tryrdlock(liblockdep_pthread_rwlock_t *lock) | 56 | static inline int liblockdep_pthread_rwlock_tryrdlock(liblockdep_pthread_rwlock_t *lock) |
| 57 | { | 57 | { |
| 58 | lock_acquire(&lock->dep_map, 0, 1, 2, 2, NULL, (unsigned long)_RET_IP_); | 58 | lock_acquire(&lock->dep_map, 0, 1, 2, 1, NULL, (unsigned long)_RET_IP_); |
| 59 | return pthread_rwlock_tryrdlock(&lock->rwlock) == 0 ? 1 : 0; | 59 | return pthread_rwlock_tryrdlock(&lock->rwlock) == 0 ? 1 : 0; |
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | static inline int liblockdep_pthread_rwlock_trywlock(liblockdep_pthread_rwlock_t *lock) | 62 | static inline int liblockdep_pthread_rwlock_trywlock(liblockdep_pthread_rwlock_t *lock) |
| 63 | { | 63 | { |
| 64 | lock_acquire(&lock->dep_map, 0, 1, 0, 2, NULL, (unsigned long)_RET_IP_); | 64 | lock_acquire(&lock->dep_map, 0, 1, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 65 | return pthread_rwlock_trywlock(&lock->rwlock) == 0 ? 1 : 0; | 65 | return pthread_rwlock_trywlock(&lock->rwlock) == 0 ? 1 : 0; |
| 66 | } | 66 | } |
| 67 | 67 | ||
diff --git a/tools/lib/lockdep/preload.c b/tools/lib/lockdep/preload.c index 23bd69cb5ade..6f803609e498 100644 --- a/tools/lib/lockdep/preload.c +++ b/tools/lib/lockdep/preload.c | |||
| @@ -92,7 +92,7 @@ enum { none, prepare, done, } __init_state; | |||
| 92 | static void init_preload(void); | 92 | static void init_preload(void); |
| 93 | static void try_init_preload(void) | 93 | static void try_init_preload(void) |
| 94 | { | 94 | { |
| 95 | if (!__init_state != done) | 95 | if (__init_state != done) |
| 96 | init_preload(); | 96 | init_preload(); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| @@ -252,7 +252,7 @@ int pthread_mutex_lock(pthread_mutex_t *mutex) | |||
| 252 | 252 | ||
| 253 | try_init_preload(); | 253 | try_init_preload(); |
| 254 | 254 | ||
| 255 | lock_acquire(&__get_lock(mutex)->dep_map, 0, 0, 0, 2, NULL, | 255 | lock_acquire(&__get_lock(mutex)->dep_map, 0, 0, 0, 1, NULL, |
| 256 | (unsigned long)_RET_IP_); | 256 | (unsigned long)_RET_IP_); |
| 257 | /* | 257 | /* |
| 258 | * Here's the thing with pthread mutexes: unlike the kernel variant, | 258 | * Here's the thing with pthread mutexes: unlike the kernel variant, |
| @@ -281,7 +281,7 @@ int pthread_mutex_trylock(pthread_mutex_t *mutex) | |||
| 281 | 281 | ||
| 282 | try_init_preload(); | 282 | try_init_preload(); |
| 283 | 283 | ||
| 284 | lock_acquire(&__get_lock(mutex)->dep_map, 0, 1, 0, 2, NULL, (unsigned long)_RET_IP_); | 284 | lock_acquire(&__get_lock(mutex)->dep_map, 0, 1, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 285 | r = ll_pthread_mutex_trylock(mutex); | 285 | r = ll_pthread_mutex_trylock(mutex); |
| 286 | if (r) | 286 | if (r) |
| 287 | lock_release(&__get_lock(mutex)->dep_map, 0, (unsigned long)_RET_IP_); | 287 | lock_release(&__get_lock(mutex)->dep_map, 0, (unsigned long)_RET_IP_); |
| @@ -303,7 +303,7 @@ int pthread_mutex_unlock(pthread_mutex_t *mutex) | |||
| 303 | */ | 303 | */ |
| 304 | r = ll_pthread_mutex_unlock(mutex); | 304 | r = ll_pthread_mutex_unlock(mutex); |
| 305 | if (r) | 305 | if (r) |
| 306 | lock_acquire(&__get_lock(mutex)->dep_map, 0, 0, 0, 2, NULL, (unsigned long)_RET_IP_); | 306 | lock_acquire(&__get_lock(mutex)->dep_map, 0, 0, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 307 | 307 | ||
| 308 | return r; | 308 | return r; |
| 309 | } | 309 | } |
| @@ -352,7 +352,7 @@ int pthread_rwlock_rdlock(pthread_rwlock_t *rwlock) | |||
| 352 | 352 | ||
| 353 | init_preload(); | 353 | init_preload(); |
| 354 | 354 | ||
| 355 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 0, 2, 2, NULL, (unsigned long)_RET_IP_); | 355 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 0, 2, 1, NULL, (unsigned long)_RET_IP_); |
| 356 | r = ll_pthread_rwlock_rdlock(rwlock); | 356 | r = ll_pthread_rwlock_rdlock(rwlock); |
| 357 | if (r) | 357 | if (r) |
| 358 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); | 358 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); |
| @@ -366,7 +366,7 @@ int pthread_rwlock_tryrdlock(pthread_rwlock_t *rwlock) | |||
| 366 | 366 | ||
| 367 | init_preload(); | 367 | init_preload(); |
| 368 | 368 | ||
| 369 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 1, 2, 2, NULL, (unsigned long)_RET_IP_); | 369 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 1, 2, 1, NULL, (unsigned long)_RET_IP_); |
| 370 | r = ll_pthread_rwlock_tryrdlock(rwlock); | 370 | r = ll_pthread_rwlock_tryrdlock(rwlock); |
| 371 | if (r) | 371 | if (r) |
| 372 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); | 372 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); |
| @@ -380,7 +380,7 @@ int pthread_rwlock_trywrlock(pthread_rwlock_t *rwlock) | |||
| 380 | 380 | ||
| 381 | init_preload(); | 381 | init_preload(); |
| 382 | 382 | ||
| 383 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 1, 0, 2, NULL, (unsigned long)_RET_IP_); | 383 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 1, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 384 | r = ll_pthread_rwlock_trywrlock(rwlock); | 384 | r = ll_pthread_rwlock_trywrlock(rwlock); |
| 385 | if (r) | 385 | if (r) |
| 386 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); | 386 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); |
| @@ -394,7 +394,7 @@ int pthread_rwlock_wrlock(pthread_rwlock_t *rwlock) | |||
| 394 | 394 | ||
| 395 | init_preload(); | 395 | init_preload(); |
| 396 | 396 | ||
| 397 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 0, 0, 2, NULL, (unsigned long)_RET_IP_); | 397 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 0, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 398 | r = ll_pthread_rwlock_wrlock(rwlock); | 398 | r = ll_pthread_rwlock_wrlock(rwlock); |
| 399 | if (r) | 399 | if (r) |
| 400 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); | 400 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); |
| @@ -411,7 +411,7 @@ int pthread_rwlock_unlock(pthread_rwlock_t *rwlock) | |||
| 411 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); | 411 | lock_release(&__get_lock(rwlock)->dep_map, 0, (unsigned long)_RET_IP_); |
| 412 | r = ll_pthread_rwlock_unlock(rwlock); | 412 | r = ll_pthread_rwlock_unlock(rwlock); |
| 413 | if (r) | 413 | if (r) |
| 414 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 0, 0, 2, NULL, (unsigned long)_RET_IP_); | 414 | lock_acquire(&__get_lock(rwlock)->dep_map, 0, 0, 0, 1, NULL, (unsigned long)_RET_IP_); |
| 415 | 415 | ||
| 416 | return r; | 416 | return r; |
| 417 | } | 417 | } |
| @@ -439,8 +439,6 @@ __attribute__((constructor)) static void init_preload(void) | |||
| 439 | ll_pthread_rwlock_unlock = dlsym(RTLD_NEXT, "pthread_rwlock_unlock"); | 439 | ll_pthread_rwlock_unlock = dlsym(RTLD_NEXT, "pthread_rwlock_unlock"); |
| 440 | #endif | 440 | #endif |
| 441 | 441 | ||
| 442 | printf("%p\n", ll_pthread_mutex_trylock);fflush(stdout); | ||
| 443 | |||
| 444 | lockdep_init(); | 442 | lockdep_init(); |
| 445 | 443 | ||
| 446 | __init_state = done; | 444 | __init_state = done; |
diff --git a/tools/perf/ui/browsers/hists.c b/tools/perf/ui/browsers/hists.c index 52c03fbbba17..04a229aa5c0f 100644 --- a/tools/perf/ui/browsers/hists.c +++ b/tools/perf/ui/browsers/hists.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "../util.h" | 17 | #include "../util.h" |
| 18 | #include "../ui.h" | 18 | #include "../ui.h" |
| 19 | #include "map.h" | 19 | #include "map.h" |
| 20 | #include "annotate.h" | ||
| 20 | 21 | ||
| 21 | struct hist_browser { | 22 | struct hist_browser { |
| 22 | struct ui_browser b; | 23 | struct ui_browser b; |
| @@ -1593,13 +1594,18 @@ static int perf_evsel__hists_browse(struct perf_evsel *evsel, int nr_events, | |||
| 1593 | bi->to.sym->name) > 0) | 1594 | bi->to.sym->name) > 0) |
| 1594 | annotate_t = nr_options++; | 1595 | annotate_t = nr_options++; |
| 1595 | } else { | 1596 | } else { |
| 1596 | |||
| 1597 | if (browser->selection != NULL && | 1597 | if (browser->selection != NULL && |
| 1598 | browser->selection->sym != NULL && | 1598 | browser->selection->sym != NULL && |
| 1599 | !browser->selection->map->dso->annotate_warned && | 1599 | !browser->selection->map->dso->annotate_warned) { |
| 1600 | asprintf(&options[nr_options], "Annotate %s", | 1600 | struct annotation *notes; |
| 1601 | browser->selection->sym->name) > 0) | 1601 | |
| 1602 | annotate = nr_options++; | 1602 | notes = symbol__annotation(browser->selection->sym); |
| 1603 | |||
| 1604 | if (notes->src && | ||
| 1605 | asprintf(&options[nr_options], "Annotate %s", | ||
| 1606 | browser->selection->sym->name) > 0) | ||
| 1607 | annotate = nr_options++; | ||
| 1608 | } | ||
| 1603 | } | 1609 | } |
| 1604 | 1610 | ||
| 1605 | if (thread != NULL && | 1611 | if (thread != NULL && |
| @@ -1656,6 +1662,7 @@ retry_popup_menu: | |||
| 1656 | 1662 | ||
| 1657 | if (choice == annotate || choice == annotate_t || choice == annotate_f) { | 1663 | if (choice == annotate || choice == annotate_t || choice == annotate_f) { |
| 1658 | struct hist_entry *he; | 1664 | struct hist_entry *he; |
| 1665 | struct annotation *notes; | ||
| 1659 | int err; | 1666 | int err; |
| 1660 | do_annotate: | 1667 | do_annotate: |
| 1661 | if (!objdump_path && perf_session_env__lookup_objdump(env)) | 1668 | if (!objdump_path && perf_session_env__lookup_objdump(env)) |
| @@ -1679,6 +1686,10 @@ do_annotate: | |||
| 1679 | he->ms.map = he->branch_info->to.map; | 1686 | he->ms.map = he->branch_info->to.map; |
| 1680 | } | 1687 | } |
| 1681 | 1688 | ||
| 1689 | notes = symbol__annotation(he->ms.sym); | ||
| 1690 | if (!notes->src) | ||
| 1691 | continue; | ||
| 1692 | |||
| 1682 | /* | 1693 | /* |
| 1683 | * Don't let this be freed, say, by hists__decay_entry. | 1694 | * Don't let this be freed, say, by hists__decay_entry. |
| 1684 | */ | 1695 | */ |
diff --git a/tools/perf/util/machine.c b/tools/perf/util/machine.c index 0e5fea95d596..c73e1fc12e53 100644 --- a/tools/perf/util/machine.c +++ b/tools/perf/util/machine.c | |||
| @@ -496,18 +496,6 @@ struct process_args { | |||
| 496 | u64 start; | 496 | u64 start; |
| 497 | }; | 497 | }; |
| 498 | 498 | ||
| 499 | static int symbol__in_kernel(void *arg, const char *name, | ||
| 500 | char type __maybe_unused, u64 start) | ||
| 501 | { | ||
| 502 | struct process_args *args = arg; | ||
| 503 | |||
| 504 | if (strchr(name, '[')) | ||
| 505 | return 0; | ||
| 506 | |||
| 507 | args->start = start; | ||
| 508 | return 1; | ||
| 509 | } | ||
| 510 | |||
| 511 | static void machine__get_kallsyms_filename(struct machine *machine, char *buf, | 499 | static void machine__get_kallsyms_filename(struct machine *machine, char *buf, |
| 512 | size_t bufsz) | 500 | size_t bufsz) |
| 513 | { | 501 | { |
| @@ -517,27 +505,41 @@ static void machine__get_kallsyms_filename(struct machine *machine, char *buf, | |||
| 517 | scnprintf(buf, bufsz, "%s/proc/kallsyms", machine->root_dir); | 505 | scnprintf(buf, bufsz, "%s/proc/kallsyms", machine->root_dir); |
| 518 | } | 506 | } |
| 519 | 507 | ||
| 520 | /* Figure out the start address of kernel map from /proc/kallsyms */ | 508 | const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL}; |
| 521 | static u64 machine__get_kernel_start_addr(struct machine *machine) | 509 | |
| 510 | /* Figure out the start address of kernel map from /proc/kallsyms. | ||
| 511 | * Returns the name of the start symbol in *symbol_name. Pass in NULL as | ||
| 512 | * symbol_name if it's not that important. | ||
| 513 | */ | ||
| 514 | static u64 machine__get_kernel_start_addr(struct machine *machine, | ||
| 515 | const char **symbol_name) | ||
| 522 | { | 516 | { |
| 523 | char filename[PATH_MAX]; | 517 | char filename[PATH_MAX]; |
| 524 | struct process_args args; | 518 | int i; |
| 519 | const char *name; | ||
| 520 | u64 addr = 0; | ||
| 525 | 521 | ||
| 526 | machine__get_kallsyms_filename(machine, filename, PATH_MAX); | 522 | machine__get_kallsyms_filename(machine, filename, PATH_MAX); |
| 527 | 523 | ||
| 528 | if (symbol__restricted_filename(filename, "/proc/kallsyms")) | 524 | if (symbol__restricted_filename(filename, "/proc/kallsyms")) |
| 529 | return 0; | 525 | return 0; |
| 530 | 526 | ||
| 531 | if (kallsyms__parse(filename, &args, symbol__in_kernel) <= 0) | 527 | for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { |
| 532 | return 0; | 528 | addr = kallsyms__get_function_start(filename, name); |
| 529 | if (addr) | ||
| 530 | break; | ||
| 531 | } | ||
| 532 | |||
| 533 | if (symbol_name) | ||
| 534 | *symbol_name = name; | ||
| 533 | 535 | ||
| 534 | return args.start; | 536 | return addr; |
| 535 | } | 537 | } |
| 536 | 538 | ||
| 537 | int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) | 539 | int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel) |
| 538 | { | 540 | { |
| 539 | enum map_type type; | 541 | enum map_type type; |
| 540 | u64 start = machine__get_kernel_start_addr(machine); | 542 | u64 start = machine__get_kernel_start_addr(machine, NULL); |
| 541 | 543 | ||
| 542 | for (type = 0; type < MAP__NR_TYPES; ++type) { | 544 | for (type = 0; type < MAP__NR_TYPES; ++type) { |
| 543 | struct kmap *kmap; | 545 | struct kmap *kmap; |
| @@ -852,23 +854,11 @@ static int machine__create_modules(struct machine *machine) | |||
| 852 | return 0; | 854 | return 0; |
| 853 | } | 855 | } |
| 854 | 856 | ||
| 855 | const char *ref_reloc_sym_names[] = {"_text", "_stext", NULL}; | ||
| 856 | |||
| 857 | int machine__create_kernel_maps(struct machine *machine) | 857 | int machine__create_kernel_maps(struct machine *machine) |
| 858 | { | 858 | { |
| 859 | struct dso *kernel = machine__get_kernel(machine); | 859 | struct dso *kernel = machine__get_kernel(machine); |
| 860 | char filename[PATH_MAX]; | ||
| 861 | const char *name; | 860 | const char *name; |
| 862 | u64 addr = 0; | 861 | u64 addr = machine__get_kernel_start_addr(machine, &name); |
| 863 | int i; | ||
| 864 | |||
| 865 | machine__get_kallsyms_filename(machine, filename, PATH_MAX); | ||
| 866 | |||
| 867 | for (i = 0; (name = ref_reloc_sym_names[i]) != NULL; i++) { | ||
| 868 | addr = kallsyms__get_function_start(filename, name); | ||
| 869 | if (addr) | ||
| 870 | break; | ||
| 871 | } | ||
| 872 | if (!addr) | 862 | if (!addr) |
| 873 | return -1; | 863 | return -1; |
| 874 | 864 | ||
diff --git a/tools/thermal/tmon/Makefile b/tools/thermal/tmon/Makefile index 447321104ec0..e775adcbd29f 100644 --- a/tools/thermal/tmon/Makefile +++ b/tools/thermal/tmon/Makefile | |||
| @@ -21,7 +21,7 @@ OBJS = tmon.o tui.o sysfs.o pid.o | |||
| 21 | OBJS += | 21 | OBJS += |
| 22 | 22 | ||
| 23 | tmon: $(OBJS) Makefile tmon.h | 23 | tmon: $(OBJS) Makefile tmon.h |
| 24 | $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -lpthread | 24 | $(CC) ${CFLAGS} $(LDFLAGS) $(OBJS) -o $(TARGET) -lm -lpanel -lncursesw -ltinfo -lpthread |
| 25 | 25 | ||
| 26 | valgrind: tmon | 26 | valgrind: tmon |
| 27 | sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null | 27 | sudo valgrind -v --track-origins=yes --tool=memcheck --leak-check=yes --show-reachable=yes --num-callers=20 --track-fds=yes ./$(TARGET) 1> /dev/null |
diff --git a/tools/thermal/tmon/tmon.c b/tools/thermal/tmon/tmon.c index b30f531173e4..09b7c3218334 100644 --- a/tools/thermal/tmon/tmon.c +++ b/tools/thermal/tmon/tmon.c | |||
| @@ -142,6 +142,7 @@ static void start_syslog(void) | |||
| 142 | static void prepare_logging(void) | 142 | static void prepare_logging(void) |
| 143 | { | 143 | { |
| 144 | int i; | 144 | int i; |
| 145 | struct stat logstat; | ||
| 145 | 146 | ||
| 146 | if (!logging) | 147 | if (!logging) |
| 147 | return; | 148 | return; |
| @@ -152,6 +153,29 @@ static void prepare_logging(void) | |||
| 152 | return; | 153 | return; |
| 153 | } | 154 | } |
| 154 | 155 | ||
| 156 | if (lstat(TMON_LOG_FILE, &logstat) < 0) { | ||
| 157 | syslog(LOG_ERR, "Unable to stat log file %s\n", TMON_LOG_FILE); | ||
| 158 | fclose(tmon_log); | ||
| 159 | tmon_log = NULL; | ||
| 160 | return; | ||
| 161 | } | ||
| 162 | |||
| 163 | /* The log file must be a regular file owned by us */ | ||
| 164 | if (S_ISLNK(logstat.st_mode)) { | ||
| 165 | syslog(LOG_ERR, "Log file is a symlink. Will not log\n"); | ||
| 166 | fclose(tmon_log); | ||
| 167 | tmon_log = NULL; | ||
| 168 | return; | ||
| 169 | } | ||
| 170 | |||
| 171 | if (logstat.st_uid != getuid()) { | ||
| 172 | syslog(LOG_ERR, "We don't own the log file. Not logging\n"); | ||
| 173 | fclose(tmon_log); | ||
| 174 | tmon_log = NULL; | ||
| 175 | return; | ||
| 176 | } | ||
| 177 | |||
| 178 | |||
| 155 | fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n"); | 179 | fprintf(tmon_log, "#----------- THERMAL SYSTEM CONFIG -------------\n"); |
| 156 | for (i = 0; i < ptdata.nr_tz_sensor; i++) { | 180 | for (i = 0; i < ptdata.nr_tz_sensor; i++) { |
| 157 | char binding_str[33]; /* size of long + 1 */ | 181 | char binding_str[33]; /* size of long + 1 */ |
| @@ -331,7 +355,7 @@ static void start_daemon_mode() | |||
| 331 | disable_tui(); | 355 | disable_tui(); |
| 332 | 356 | ||
| 333 | /* change the file mode mask */ | 357 | /* change the file mode mask */ |
| 334 | umask(0); | 358 | umask(S_IWGRP | S_IWOTH); |
| 335 | 359 | ||
| 336 | /* new SID for the daemon process */ | 360 | /* new SID for the daemon process */ |
| 337 | sid = setsid(); | 361 | sid = setsid(); |
diff --git a/virt/kvm/arm/vgic.c b/virt/kvm/arm/vgic.c index 56ff9bebb577..476d3bf540a8 100644 --- a/virt/kvm/arm/vgic.c +++ b/virt/kvm/arm/vgic.c | |||
| @@ -1526,17 +1526,33 @@ int kvm_vgic_hyp_init(void) | |||
| 1526 | goto out_unmap; | 1526 | goto out_unmap; |
| 1527 | } | 1527 | } |
| 1528 | 1528 | ||
| 1529 | kvm_info("%s@%llx IRQ%d\n", vgic_node->name, | ||
| 1530 | vctrl_res.start, vgic_maint_irq); | ||
| 1531 | on_each_cpu(vgic_init_maintenance_interrupt, NULL, 1); | ||
| 1532 | |||
| 1533 | if (of_address_to_resource(vgic_node, 3, &vcpu_res)) { | 1529 | if (of_address_to_resource(vgic_node, 3, &vcpu_res)) { |
| 1534 | kvm_err("Cannot obtain VCPU resource\n"); | 1530 | kvm_err("Cannot obtain VCPU resource\n"); |
| 1535 | ret = -ENXIO; | 1531 | ret = -ENXIO; |
| 1536 | goto out_unmap; | 1532 | goto out_unmap; |
| 1537 | } | 1533 | } |
| 1534 | |||
| 1535 | if (!PAGE_ALIGNED(vcpu_res.start)) { | ||
| 1536 | kvm_err("GICV physical address 0x%llx not page aligned\n", | ||
| 1537 | (unsigned long long)vcpu_res.start); | ||
| 1538 | ret = -ENXIO; | ||
| 1539 | goto out_unmap; | ||
| 1540 | } | ||
| 1541 | |||
| 1542 | if (!PAGE_ALIGNED(resource_size(&vcpu_res))) { | ||
| 1543 | kvm_err("GICV size 0x%llx not a multiple of page size 0x%lx\n", | ||
| 1544 | (unsigned long long)resource_size(&vcpu_res), | ||
| 1545 | PAGE_SIZE); | ||
| 1546 | ret = -ENXIO; | ||
| 1547 | goto out_unmap; | ||
| 1548 | } | ||
| 1549 | |||
| 1538 | vgic_vcpu_base = vcpu_res.start; | 1550 | vgic_vcpu_base = vcpu_res.start; |
| 1539 | 1551 | ||
| 1552 | kvm_info("%s@%llx IRQ%d\n", vgic_node->name, | ||
| 1553 | vctrl_res.start, vgic_maint_irq); | ||
| 1554 | on_each_cpu(vgic_init_maintenance_interrupt, NULL, 1); | ||
| 1555 | |||
| 1540 | goto out; | 1556 | goto out; |
| 1541 | 1557 | ||
| 1542 | out_unmap: | 1558 | out_unmap: |
