diff options
252 files changed, 5136 insertions, 4072 deletions
diff --git a/Documentation/ABI/stable/sysfs-bus-usb b/Documentation/ABI/stable/sysfs-bus-usb index 2be603c52a24..a6b685724740 100644 --- a/Documentation/ABI/stable/sysfs-bus-usb +++ b/Documentation/ABI/stable/sysfs-bus-usb | |||
| @@ -37,8 +37,8 @@ Description: | |||
| 37 | that the USB device has been connected to the machine. This | 37 | that the USB device has been connected to the machine. This |
| 38 | file is read-only. | 38 | file is read-only. |
| 39 | Users: | 39 | Users: |
| 40 | PowerTOP <power@bughost.org> | 40 | PowerTOP <powertop@lists.01.org> |
| 41 | http://www.lesswatts.org/projects/powertop/ | 41 | https://01.org/powertop/ |
| 42 | 42 | ||
| 43 | What: /sys/bus/usb/device/.../power/active_duration | 43 | What: /sys/bus/usb/device/.../power/active_duration |
| 44 | Date: January 2008 | 44 | Date: January 2008 |
| @@ -57,8 +57,8 @@ Description: | |||
| 57 | will give an integer percentage. Note that this does not | 57 | will give an integer percentage. Note that this does not |
| 58 | account for counter wrap. | 58 | account for counter wrap. |
| 59 | Users: | 59 | Users: |
| 60 | PowerTOP <power@bughost.org> | 60 | PowerTOP <powertop@lists.01.org> |
| 61 | http://www.lesswatts.org/projects/powertop/ | 61 | https://01.org/powertop/ |
| 62 | 62 | ||
| 63 | What: /sys/bus/usb/devices/<busnum>-<port[.port]>...:<config num>-<interface num>/supports_autosuspend | 63 | What: /sys/bus/usb/devices/<busnum>-<port[.port]>...:<config num>-<interface num>/supports_autosuspend |
| 64 | Date: January 2008 | 64 | Date: January 2008 |
diff --git a/Documentation/ABI/testing/sysfs-devices-power b/Documentation/ABI/testing/sysfs-devices-power index 9d43e7670841..efe449bdf811 100644 --- a/Documentation/ABI/testing/sysfs-devices-power +++ b/Documentation/ABI/testing/sysfs-devices-power | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | What: /sys/devices/.../power/ | 1 | What: /sys/devices/.../power/ |
| 2 | Date: January 2009 | 2 | Date: January 2009 |
| 3 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 3 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 4 | Description: | 4 | Description: |
| 5 | The /sys/devices/.../power directory contains attributes | 5 | The /sys/devices/.../power directory contains attributes |
| 6 | allowing the user space to check and modify some power | 6 | allowing the user space to check and modify some power |
| @@ -8,7 +8,7 @@ Description: | |||
| 8 | 8 | ||
| 9 | What: /sys/devices/.../power/wakeup | 9 | What: /sys/devices/.../power/wakeup |
| 10 | Date: January 2009 | 10 | Date: January 2009 |
| 11 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 11 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 12 | Description: | 12 | Description: |
| 13 | The /sys/devices/.../power/wakeup attribute allows the user | 13 | The /sys/devices/.../power/wakeup attribute allows the user |
| 14 | space to check if the device is enabled to wake up the system | 14 | space to check if the device is enabled to wake up the system |
| @@ -34,7 +34,7 @@ Description: | |||
| 34 | 34 | ||
| 35 | What: /sys/devices/.../power/control | 35 | What: /sys/devices/.../power/control |
| 36 | Date: January 2009 | 36 | Date: January 2009 |
| 37 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 37 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 38 | Description: | 38 | Description: |
| 39 | The /sys/devices/.../power/control attribute allows the user | 39 | The /sys/devices/.../power/control attribute allows the user |
| 40 | space to control the run-time power management of the device. | 40 | space to control the run-time power management of the device. |
| @@ -53,7 +53,7 @@ Description: | |||
| 53 | 53 | ||
| 54 | What: /sys/devices/.../power/async | 54 | What: /sys/devices/.../power/async |
| 55 | Date: January 2009 | 55 | Date: January 2009 |
| 56 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 56 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 57 | Description: | 57 | Description: |
| 58 | The /sys/devices/.../async attribute allows the user space to | 58 | The /sys/devices/.../async attribute allows the user space to |
| 59 | enable or diasble the device's suspend and resume callbacks to | 59 | enable or diasble the device's suspend and resume callbacks to |
| @@ -79,7 +79,7 @@ Description: | |||
| 79 | 79 | ||
| 80 | What: /sys/devices/.../power/wakeup_count | 80 | What: /sys/devices/.../power/wakeup_count |
| 81 | Date: September 2010 | 81 | Date: September 2010 |
| 82 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 82 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 83 | Description: | 83 | Description: |
| 84 | The /sys/devices/.../wakeup_count attribute contains the number | 84 | The /sys/devices/.../wakeup_count attribute contains the number |
| 85 | of signaled wakeup events associated with the device. This | 85 | of signaled wakeup events associated with the device. This |
| @@ -88,7 +88,7 @@ Description: | |||
| 88 | 88 | ||
| 89 | What: /sys/devices/.../power/wakeup_active_count | 89 | What: /sys/devices/.../power/wakeup_active_count |
| 90 | Date: September 2010 | 90 | Date: September 2010 |
| 91 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 91 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 92 | Description: | 92 | Description: |
| 93 | The /sys/devices/.../wakeup_active_count attribute contains the | 93 | The /sys/devices/.../wakeup_active_count attribute contains the |
| 94 | number of times the processing of wakeup events associated with | 94 | number of times the processing of wakeup events associated with |
| @@ -98,7 +98,7 @@ Description: | |||
| 98 | 98 | ||
| 99 | What: /sys/devices/.../power/wakeup_abort_count | 99 | What: /sys/devices/.../power/wakeup_abort_count |
| 100 | Date: February 2012 | 100 | Date: February 2012 |
| 101 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 101 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 102 | Description: | 102 | Description: |
| 103 | The /sys/devices/.../wakeup_abort_count attribute contains the | 103 | The /sys/devices/.../wakeup_abort_count attribute contains the |
| 104 | number of times the processing of a wakeup event associated with | 104 | number of times the processing of a wakeup event associated with |
| @@ -109,7 +109,7 @@ Description: | |||
| 109 | 109 | ||
| 110 | What: /sys/devices/.../power/wakeup_expire_count | 110 | What: /sys/devices/.../power/wakeup_expire_count |
| 111 | Date: February 2012 | 111 | Date: February 2012 |
| 112 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 112 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 113 | Description: | 113 | Description: |
| 114 | The /sys/devices/.../wakeup_expire_count attribute contains the | 114 | The /sys/devices/.../wakeup_expire_count attribute contains the |
| 115 | number of times a wakeup event associated with the device has | 115 | number of times a wakeup event associated with the device has |
| @@ -119,7 +119,7 @@ Description: | |||
| 119 | 119 | ||
| 120 | What: /sys/devices/.../power/wakeup_active | 120 | What: /sys/devices/.../power/wakeup_active |
| 121 | Date: September 2010 | 121 | Date: September 2010 |
| 122 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 122 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 123 | Description: | 123 | Description: |
| 124 | The /sys/devices/.../wakeup_active attribute contains either 1, | 124 | The /sys/devices/.../wakeup_active attribute contains either 1, |
| 125 | or 0, depending on whether or not a wakeup event associated with | 125 | or 0, depending on whether or not a wakeup event associated with |
| @@ -129,7 +129,7 @@ Description: | |||
| 129 | 129 | ||
| 130 | What: /sys/devices/.../power/wakeup_total_time_ms | 130 | What: /sys/devices/.../power/wakeup_total_time_ms |
| 131 | Date: September 2010 | 131 | Date: September 2010 |
| 132 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 132 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 133 | Description: | 133 | Description: |
| 134 | The /sys/devices/.../wakeup_total_time_ms attribute contains | 134 | The /sys/devices/.../wakeup_total_time_ms attribute contains |
| 135 | the total time of processing wakeup events associated with the | 135 | the total time of processing wakeup events associated with the |
| @@ -139,7 +139,7 @@ Description: | |||
| 139 | 139 | ||
| 140 | What: /sys/devices/.../power/wakeup_max_time_ms | 140 | What: /sys/devices/.../power/wakeup_max_time_ms |
| 141 | Date: September 2010 | 141 | Date: September 2010 |
| 142 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 142 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 143 | Description: | 143 | Description: |
| 144 | The /sys/devices/.../wakeup_max_time_ms attribute contains | 144 | The /sys/devices/.../wakeup_max_time_ms attribute contains |
| 145 | the maximum time of processing a single wakeup event associated | 145 | the maximum time of processing a single wakeup event associated |
| @@ -149,7 +149,7 @@ Description: | |||
| 149 | 149 | ||
| 150 | What: /sys/devices/.../power/wakeup_last_time_ms | 150 | What: /sys/devices/.../power/wakeup_last_time_ms |
| 151 | Date: September 2010 | 151 | Date: September 2010 |
| 152 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 152 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 153 | Description: | 153 | Description: |
| 154 | The /sys/devices/.../wakeup_last_time_ms attribute contains | 154 | The /sys/devices/.../wakeup_last_time_ms attribute contains |
| 155 | the value of the monotonic clock corresponding to the time of | 155 | the value of the monotonic clock corresponding to the time of |
| @@ -160,7 +160,7 @@ Description: | |||
| 160 | 160 | ||
| 161 | What: /sys/devices/.../power/wakeup_prevent_sleep_time_ms | 161 | What: /sys/devices/.../power/wakeup_prevent_sleep_time_ms |
| 162 | Date: February 2012 | 162 | Date: February 2012 |
| 163 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 163 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 164 | Description: | 164 | Description: |
| 165 | The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute | 165 | The /sys/devices/.../wakeup_prevent_sleep_time_ms attribute |
| 166 | contains the total time the device has been preventing | 166 | contains the total time the device has been preventing |
| @@ -189,7 +189,7 @@ Description: | |||
| 189 | 189 | ||
| 190 | What: /sys/devices/.../power/pm_qos_latency_us | 190 | What: /sys/devices/.../power/pm_qos_latency_us |
| 191 | Date: March 2012 | 191 | Date: March 2012 |
| 192 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 192 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 193 | Description: | 193 | Description: |
| 194 | The /sys/devices/.../power/pm_qos_resume_latency_us attribute | 194 | The /sys/devices/.../power/pm_qos_resume_latency_us attribute |
| 195 | contains the PM QoS resume latency limit for the given device, | 195 | contains the PM QoS resume latency limit for the given device, |
| @@ -207,7 +207,7 @@ Description: | |||
| 207 | 207 | ||
| 208 | What: /sys/devices/.../power/pm_qos_no_power_off | 208 | What: /sys/devices/.../power/pm_qos_no_power_off |
| 209 | Date: September 2012 | 209 | Date: September 2012 |
| 210 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 210 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 211 | Description: | 211 | Description: |
| 212 | The /sys/devices/.../power/pm_qos_no_power_off attribute | 212 | The /sys/devices/.../power/pm_qos_no_power_off attribute |
| 213 | is used for manipulating the PM QoS "no power off" flag. If | 213 | is used for manipulating the PM QoS "no power off" flag. If |
| @@ -222,7 +222,7 @@ Description: | |||
| 222 | 222 | ||
| 223 | What: /sys/devices/.../power/pm_qos_remote_wakeup | 223 | What: /sys/devices/.../power/pm_qos_remote_wakeup |
| 224 | Date: September 2012 | 224 | Date: September 2012 |
| 225 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 225 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 226 | Description: | 226 | Description: |
| 227 | The /sys/devices/.../power/pm_qos_remote_wakeup attribute | 227 | The /sys/devices/.../power/pm_qos_remote_wakeup attribute |
| 228 | is used for manipulating the PM QoS "remote wakeup required" | 228 | is used for manipulating the PM QoS "remote wakeup required" |
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power index 217772615d02..205a73878441 100644 --- a/Documentation/ABI/testing/sysfs-power +++ b/Documentation/ABI/testing/sysfs-power | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | What: /sys/power/ | 1 | What: /sys/power/ |
| 2 | Date: August 2006 | 2 | Date: August 2006 |
| 3 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 3 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 4 | Description: | 4 | Description: |
| 5 | The /sys/power directory will contain files that will | 5 | The /sys/power directory will contain files that will |
| 6 | provide a unified interface to the power management | 6 | provide a unified interface to the power management |
| @@ -8,7 +8,7 @@ Description: | |||
| 8 | 8 | ||
| 9 | What: /sys/power/state | 9 | What: /sys/power/state |
| 10 | Date: August 2006 | 10 | Date: August 2006 |
| 11 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 11 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 12 | Description: | 12 | Description: |
| 13 | The /sys/power/state file controls the system power state. | 13 | The /sys/power/state file controls the system power state. |
| 14 | Reading from this file returns what states are supported, | 14 | Reading from this file returns what states are supported, |
| @@ -22,7 +22,7 @@ Description: | |||
| 22 | 22 | ||
| 23 | What: /sys/power/disk | 23 | What: /sys/power/disk |
| 24 | Date: September 2006 | 24 | Date: September 2006 |
| 25 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 25 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 26 | Description: | 26 | Description: |
| 27 | The /sys/power/disk file controls the operating mode of the | 27 | The /sys/power/disk file controls the operating mode of the |
| 28 | suspend-to-disk mechanism. Reading from this file returns | 28 | suspend-to-disk mechanism. Reading from this file returns |
| @@ -67,7 +67,7 @@ Description: | |||
| 67 | 67 | ||
| 68 | What: /sys/power/image_size | 68 | What: /sys/power/image_size |
| 69 | Date: August 2006 | 69 | Date: August 2006 |
| 70 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 70 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 71 | Description: | 71 | Description: |
| 72 | The /sys/power/image_size file controls the size of the image | 72 | The /sys/power/image_size file controls the size of the image |
| 73 | created by the suspend-to-disk mechanism. It can be written a | 73 | created by the suspend-to-disk mechanism. It can be written a |
| @@ -84,7 +84,7 @@ Description: | |||
| 84 | 84 | ||
| 85 | What: /sys/power/pm_trace | 85 | What: /sys/power/pm_trace |
| 86 | Date: August 2006 | 86 | Date: August 2006 |
| 87 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 87 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 88 | Description: | 88 | Description: |
| 89 | The /sys/power/pm_trace file controls the code which saves the | 89 | The /sys/power/pm_trace file controls the code which saves the |
| 90 | last PM event point in the RTC across reboots, so that you can | 90 | last PM event point in the RTC across reboots, so that you can |
| @@ -133,7 +133,7 @@ Description: | |||
| 133 | 133 | ||
| 134 | What: /sys/power/pm_async | 134 | What: /sys/power/pm_async |
| 135 | Date: January 2009 | 135 | Date: January 2009 |
| 136 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 136 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 137 | Description: | 137 | Description: |
| 138 | The /sys/power/pm_async file controls the switch allowing the | 138 | The /sys/power/pm_async file controls the switch allowing the |
| 139 | user space to enable or disable asynchronous suspend and resume | 139 | user space to enable or disable asynchronous suspend and resume |
| @@ -146,7 +146,7 @@ Description: | |||
| 146 | 146 | ||
| 147 | What: /sys/power/wakeup_count | 147 | What: /sys/power/wakeup_count |
| 148 | Date: July 2010 | 148 | Date: July 2010 |
| 149 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 149 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 150 | Description: | 150 | Description: |
| 151 | The /sys/power/wakeup_count file allows user space to put the | 151 | The /sys/power/wakeup_count file allows user space to put the |
| 152 | system into a sleep state while taking into account the | 152 | system into a sleep state while taking into account the |
| @@ -161,7 +161,7 @@ Description: | |||
| 161 | 161 | ||
| 162 | What: /sys/power/reserved_size | 162 | What: /sys/power/reserved_size |
| 163 | Date: May 2011 | 163 | Date: May 2011 |
| 164 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 164 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 165 | Description: | 165 | Description: |
| 166 | The /sys/power/reserved_size file allows user space to control | 166 | The /sys/power/reserved_size file allows user space to control |
| 167 | the amount of memory reserved for allocations made by device | 167 | the amount of memory reserved for allocations made by device |
| @@ -175,7 +175,7 @@ Description: | |||
| 175 | 175 | ||
| 176 | What: /sys/power/autosleep | 176 | What: /sys/power/autosleep |
| 177 | Date: April 2012 | 177 | Date: April 2012 |
| 178 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 178 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 179 | Description: | 179 | Description: |
| 180 | The /sys/power/autosleep file can be written one of the strings | 180 | The /sys/power/autosleep file can be written one of the strings |
| 181 | returned by reads from /sys/power/state. If that happens, a | 181 | returned by reads from /sys/power/state. If that happens, a |
| @@ -192,7 +192,7 @@ Description: | |||
| 192 | 192 | ||
| 193 | What: /sys/power/wake_lock | 193 | What: /sys/power/wake_lock |
| 194 | Date: February 2012 | 194 | Date: February 2012 |
| 195 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 195 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 196 | Description: | 196 | Description: |
| 197 | The /sys/power/wake_lock file allows user space to create | 197 | The /sys/power/wake_lock file allows user space to create |
| 198 | wakeup source objects and activate them on demand (if one of | 198 | wakeup source objects and activate them on demand (if one of |
| @@ -219,7 +219,7 @@ Description: | |||
| 219 | 219 | ||
| 220 | What: /sys/power/wake_unlock | 220 | What: /sys/power/wake_unlock |
| 221 | Date: February 2012 | 221 | Date: February 2012 |
| 222 | Contact: Rafael J. Wysocki <rjw@sisk.pl> | 222 | Contact: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 223 | Description: | 223 | Description: |
| 224 | The /sys/power/wake_unlock file allows user space to deactivate | 224 | The /sys/power/wake_unlock file allows user space to deactivate |
| 225 | wakeup sources created with the help of /sys/power/wake_lock. | 225 | wakeup sources created with the help of /sys/power/wake_lock. |
diff --git a/Documentation/acpi/dsdt-override.txt b/Documentation/acpi/dsdt-override.txt index febbb1ba4d23..784841caa6e6 100644 --- a/Documentation/acpi/dsdt-override.txt +++ b/Documentation/acpi/dsdt-override.txt | |||
| @@ -4,4 +4,4 @@ CONFIG_ACPI_CUSTOM_DSDT builds the image into the kernel. | |||
| 4 | 4 | ||
| 5 | When to use this method is described in detail on the | 5 | When to use this method is described in detail on the |
| 6 | Linux/ACPI home page: | 6 | Linux/ACPI home page: |
| 7 | http://www.lesswatts.org/projects/acpi/overridingDSDT.php | 7 | https://01.org/linux-acpi/documentation/overriding-dsdt |
diff --git a/Documentation/devicetree/bindings/memory.txt b/Documentation/devicetree/bindings/memory.txt deleted file mode 100644 index eb2469365593..000000000000 --- a/Documentation/devicetree/bindings/memory.txt +++ /dev/null | |||
| @@ -1,168 +0,0 @@ | |||
| 1 | *** Memory binding *** | ||
| 2 | |||
| 3 | The /memory node provides basic information about the address and size | ||
| 4 | of the physical memory. This node is usually filled or updated by the | ||
| 5 | bootloader, depending on the actual memory configuration of the given | ||
| 6 | hardware. | ||
| 7 | |||
| 8 | The memory layout is described by the following node: | ||
| 9 | |||
| 10 | / { | ||
| 11 | #address-cells = <(n)>; | ||
| 12 | #size-cells = <(m)>; | ||
| 13 | memory { | ||
| 14 | device_type = "memory"; | ||
| 15 | reg = <(baseaddr1) (size1) | ||
| 16 | (baseaddr2) (size2) | ||
| 17 | ... | ||
| 18 | (baseaddrN) (sizeN)>; | ||
| 19 | }; | ||
| 20 | ... | ||
| 21 | }; | ||
| 22 | |||
| 23 | A memory node follows the typical device tree rules for "reg" property: | ||
| 24 | n: number of cells used to store base address value | ||
| 25 | m: number of cells used to store size value | ||
| 26 | baseaddrX: defines a base address of the defined memory bank | ||
| 27 | sizeX: the size of the defined memory bank | ||
| 28 | |||
| 29 | |||
| 30 | More than one memory bank can be defined. | ||
| 31 | |||
| 32 | |||
| 33 | *** Reserved memory regions *** | ||
| 34 | |||
| 35 | In /memory/reserved-memory node one can create child nodes describing | ||
| 36 | particular reserved (excluded from normal use) memory regions. Such | ||
| 37 | memory regions are usually designed for the special usage by various | ||
| 38 | device drivers. A good example are contiguous memory allocations or | ||
| 39 | memory sharing with other operating system on the same hardware board. | ||
| 40 | Those special memory regions might depend on the board configuration and | ||
| 41 | devices used on the target system. | ||
| 42 | |||
| 43 | Parameters for each memory region can be encoded into the device tree | ||
| 44 | with the following convention: | ||
| 45 | |||
| 46 | [(label):] (name) { | ||
| 47 | compatible = "linux,contiguous-memory-region", "reserved-memory-region"; | ||
| 48 | reg = <(address) (size)>; | ||
| 49 | (linux,default-contiguous-region); | ||
| 50 | }; | ||
| 51 | |||
| 52 | compatible: one or more of: | ||
| 53 | - "linux,contiguous-memory-region" - enables binding of this | ||
| 54 | region to Contiguous Memory Allocator (special region for | ||
| 55 | contiguous memory allocations, shared with movable system | ||
| 56 | memory, Linux kernel-specific). | ||
| 57 | - "reserved-memory-region" - compatibility is defined, given | ||
| 58 | region is assigned for exclusive usage for by the respective | ||
| 59 | devices. | ||
| 60 | |||
| 61 | reg: standard property defining the base address and size of | ||
| 62 | the memory region | ||
| 63 | |||
| 64 | linux,default-contiguous-region: property indicating that the region | ||
| 65 | is the default region for all contiguous memory | ||
| 66 | allocations, Linux specific (optional) | ||
| 67 | |||
| 68 | It is optional to specify the base address, so if one wants to use | ||
| 69 | autoconfiguration of the base address, '0' can be specified as a base | ||
| 70 | address in the 'reg' property. | ||
| 71 | |||
| 72 | The /memory/reserved-memory node must contain the same #address-cells | ||
| 73 | and #size-cells value as the root node. | ||
| 74 | |||
| 75 | |||
| 76 | *** Device node's properties *** | ||
| 77 | |||
| 78 | Once regions in the /memory/reserved-memory node have been defined, they | ||
| 79 | may be referenced by other device nodes. Bindings that wish to reference | ||
| 80 | memory regions should explicitly document their use of the following | ||
| 81 | property: | ||
| 82 | |||
| 83 | memory-region = <&phandle_to_defined_region>; | ||
| 84 | |||
| 85 | This property indicates that the device driver should use the memory | ||
| 86 | region pointed by the given phandle. | ||
| 87 | |||
| 88 | |||
| 89 | *** Example *** | ||
| 90 | |||
| 91 | This example defines a memory consisting of 4 memory banks. 3 contiguous | ||
| 92 | regions are defined for Linux kernel, one default of all device drivers | ||
| 93 | (named contig_mem, placed at 0x72000000, 64MiB), one dedicated to the | ||
| 94 | framebuffer device (labelled display_mem, placed at 0x78000000, 8MiB) | ||
| 95 | and one for multimedia processing (labelled multimedia_mem, placed at | ||
| 96 | 0x77000000, 64MiB). 'display_mem' region is then assigned to fb@12300000 | ||
| 97 | device for DMA memory allocations (Linux kernel drivers will use CMA is | ||
| 98 | available or dma-exclusive usage otherwise). 'multimedia_mem' is | ||
| 99 | assigned to scaler@12500000 and codec@12600000 devices for contiguous | ||
| 100 | memory allocations when CMA driver is enabled. | ||
| 101 | |||
| 102 | The reason for creating a separate region for framebuffer device is to | ||
| 103 | match the framebuffer base address to the one configured by bootloader, | ||
| 104 | so once Linux kernel drivers starts no glitches on the displayed boot | ||
| 105 | logo appears. Scaller and codec drivers should share the memory | ||
| 106 | allocations. | ||
| 107 | |||
| 108 | / { | ||
| 109 | #address-cells = <1>; | ||
| 110 | #size-cells = <1>; | ||
| 111 | |||
| 112 | /* ... */ | ||
| 113 | |||
| 114 | memory { | ||
| 115 | reg = <0x40000000 0x10000000 | ||
| 116 | 0x50000000 0x10000000 | ||
| 117 | 0x60000000 0x10000000 | ||
| 118 | 0x70000000 0x10000000>; | ||
| 119 | |||
| 120 | reserved-memory { | ||
| 121 | #address-cells = <1>; | ||
| 122 | #size-cells = <1>; | ||
| 123 | |||
| 124 | /* | ||
| 125 | * global autoconfigured region for contiguous allocations | ||
| 126 | * (used only with Contiguous Memory Allocator) | ||
| 127 | */ | ||
| 128 | contig_region@0 { | ||
| 129 | compatible = "linux,contiguous-memory-region"; | ||
| 130 | reg = <0x0 0x4000000>; | ||
| 131 | linux,default-contiguous-region; | ||
| 132 | }; | ||
| 133 | |||
| 134 | /* | ||
| 135 | * special region for framebuffer | ||
| 136 | */ | ||
| 137 | display_region: region@78000000 { | ||
| 138 | compatible = "linux,contiguous-memory-region", "reserved-memory-region"; | ||
| 139 | reg = <0x78000000 0x800000>; | ||
| 140 | }; | ||
| 141 | |||
| 142 | /* | ||
| 143 | * special region for multimedia processing devices | ||
| 144 | */ | ||
| 145 | multimedia_region: region@77000000 { | ||
| 146 | compatible = "linux,contiguous-memory-region"; | ||
| 147 | reg = <0x77000000 0x4000000>; | ||
| 148 | }; | ||
| 149 | }; | ||
| 150 | }; | ||
| 151 | |||
| 152 | /* ... */ | ||
| 153 | |||
| 154 | fb0: fb@12300000 { | ||
| 155 | status = "okay"; | ||
| 156 | memory-region = <&display_region>; | ||
| 157 | }; | ||
| 158 | |||
| 159 | scaler: scaler@12500000 { | ||
| 160 | status = "okay"; | ||
| 161 | memory-region = <&multimedia_region>; | ||
| 162 | }; | ||
| 163 | |||
| 164 | codec: codec@12600000 { | ||
| 165 | status = "okay"; | ||
| 166 | memory-region = <&multimedia_region>; | ||
| 167 | }; | ||
| 168 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/cs42l73.txt b/Documentation/devicetree/bindings/sound/cs42l73.txt new file mode 100644 index 000000000000..80ae910dbf6c --- /dev/null +++ b/Documentation/devicetree/bindings/sound/cs42l73.txt | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | CS42L73 audio CODEC | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | |||
| 5 | - compatible : "cirrus,cs42l73" | ||
| 6 | |||
| 7 | - reg : the I2C address of the device for I2C | ||
| 8 | |||
| 9 | Optional properties: | ||
| 10 | |||
| 11 | - reset_gpio : a GPIO spec for the reset pin. | ||
| 12 | - chgfreq : Charge Pump Frequency values 0x00-0x0F | ||
| 13 | |||
| 14 | |||
| 15 | Example: | ||
| 16 | |||
| 17 | codec: cs42l73@4a { | ||
| 18 | compatible = "cirrus,cs42l73"; | ||
| 19 | reg = <0x4a>; | ||
| 20 | reset_gpio = <&gpio 10 0>; | ||
| 21 | chgfreq = <0x05>; | ||
| 22 | }; \ No newline at end of file | ||
diff --git a/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt new file mode 100644 index 000000000000..865178d5cdf3 --- /dev/null +++ b/Documentation/devicetree/bindings/sound/davinci-evm-audio.txt | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | * Texas Instruments SoC audio setups with TLV320AIC3X Codec | ||
| 2 | |||
| 3 | Required properties: | ||
| 4 | - compatible : "ti,da830-evm-audio" : forDM365/DA8xx/OMAPL1x/AM33xx | ||
| 5 | - ti,model : The user-visible name of this sound complex. | ||
| 6 | - ti,audio-codec : The phandle of the TLV320AIC3x audio codec | ||
| 7 | - ti,mcasp-controller : The phandle of the McASP controller | ||
| 8 | - ti,codec-clock-rate : The Codec Clock rate (in Hz) applied to the Codec | ||
| 9 | - ti,audio-routing : A list of the connections between audio components. | ||
| 10 | Each entry is a pair of strings, the first being the connection's sink, | ||
| 11 | the second being the connection's source. Valid names for sources and | ||
| 12 | sinks are the codec's pins, and the jacks on the board: | ||
| 13 | |||
| 14 | Board connectors: | ||
| 15 | |||
| 16 | * Headphone Jack | ||
| 17 | * Line Out | ||
| 18 | * Mic Jack | ||
| 19 | * Line In | ||
| 20 | |||
| 21 | |||
| 22 | Example: | ||
| 23 | |||
| 24 | sound { | ||
| 25 | compatible = "ti,da830-evm-audio"; | ||
| 26 | ti,model = "DA830 EVM"; | ||
| 27 | ti,audio-codec = <&tlv320aic3x>; | ||
| 28 | ti,mcasp-controller = <&mcasp1>; | ||
| 29 | ti,codec-clock-rate = <12000000>; | ||
| 30 | ti,audio-routing = | ||
| 31 | "Headphone Jack", "HPLOUT", | ||
| 32 | "Headphone Jack", "HPROUT", | ||
| 33 | "Line Out", "LLOUT", | ||
| 34 | "Line Out", "RLOUT", | ||
| 35 | "MIC3L", "Mic Bias 2V", | ||
| 36 | "MIC3R", "Mic Bias 2V", | ||
| 37 | "Mic Bias 2V", "Mic Jack", | ||
| 38 | "LINE1L", "Line In", | ||
| 39 | "LINE2L", "Line In", | ||
| 40 | "LINE1R", "Line In", | ||
| 41 | "LINE2R", "Line In"; | ||
| 42 | }; | ||
diff --git a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt index 374e145c2ef1..ed785b3f67be 100644 --- a/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt +++ b/Documentation/devicetree/bindings/sound/davinci-mcasp-audio.txt | |||
| @@ -4,17 +4,25 @@ Required properties: | |||
| 4 | - compatible : | 4 | - compatible : |
| 5 | "ti,dm646x-mcasp-audio" : for DM646x platforms | 5 | "ti,dm646x-mcasp-audio" : for DM646x platforms |
| 6 | "ti,da830-mcasp-audio" : for both DA830 & DA850 platforms | 6 | "ti,da830-mcasp-audio" : for both DA830 & DA850 platforms |
| 7 | "ti,omap2-mcasp-audio" : for OMAP2 platforms (TI81xx, AM33xx) | 7 | "ti,am33xx-mcasp-audio" : for AM33xx platforms (AM33xx, TI81xx) |
| 8 | |||
| 9 | - reg : Should contain McASP registers offset and length | ||
| 10 | - interrupts : Interrupt number for McASP | ||
| 11 | - op-mode : I2S/DIT ops mode. | ||
| 12 | - tdm-slots : Slots for TDM operation. | ||
| 13 | - num-serializer : Serializers used by McASP. | ||
| 14 | - serial-dir : A list of serializer pin mode. The list number should be equal | ||
| 15 | to "num-serializer" parameter. Each entry is a number indication | ||
| 16 | serializer pin direction. (0 - INACTIVE, 1 - TX, 2 - RX) | ||
| 17 | 8 | ||
| 9 | - reg : Should contain reg specifiers for the entries in the reg-names property. | ||
| 10 | - reg-names : Should contain: | ||
| 11 | * "mpu" for the main registers (required). For compatibility with | ||
| 12 | existing software, it is recommended this is the first entry. | ||
| 13 | * "dat" for separate data port register access (optional). | ||
| 14 | - op-mode : I2S/DIT ops mode. 0 for I2S mode. 1 for DIT mode used for S/PDIF, | ||
| 15 | IEC60958-1, and AES-3 formats. | ||
| 16 | - tdm-slots : Slots for TDM operation. Indicates number of channels transmitted | ||
| 17 | or received over one serializer. | ||
| 18 | - serial-dir : A list of serializer configuration. Each entry is a number | ||
| 19 | indication for serializer pin direction. | ||
| 20 | (0 - INACTIVE, 1 - TX, 2 - RX) | ||
| 21 | - dmas: two element list of DMA controller phandles and DMA request line | ||
| 22 | ordered pairs. | ||
| 23 | - dma-names: identifier string for each DMA request line in the dmas property. | ||
| 24 | These strings correspond 1:1 with the ordered pairs in dmas. The dma | ||
| 25 | identifiers must be "rx" and "tx". | ||
| 18 | 26 | ||
| 19 | Optional properties: | 27 | Optional properties: |
| 20 | 28 | ||
| @@ -23,18 +31,23 @@ Optional properties: | |||
| 23 | - rx-num-evt : FIFO levels. | 31 | - rx-num-evt : FIFO levels. |
| 24 | - sram-size-playback : size of sram to be allocated during playback | 32 | - sram-size-playback : size of sram to be allocated during playback |
| 25 | - sram-size-capture : size of sram to be allocated during capture | 33 | - sram-size-capture : size of sram to be allocated during capture |
| 34 | - interrupts : Interrupt numbers for McASP, currently not used by the driver | ||
| 35 | - interrupt-names : Known interrupt names are "tx" and "rx" | ||
| 36 | - pinctrl-0: Should specify pin control group used for this controller. | ||
| 37 | - pinctrl-names: Should contain only one value - "default", for more details | ||
| 38 | please refer to pinctrl-bindings.txt | ||
| 39 | |||
| 26 | 40 | ||
| 27 | Example: | 41 | Example: |
| 28 | 42 | ||
| 29 | mcasp0: mcasp0@1d00000 { | 43 | mcasp0: mcasp0@1d00000 { |
| 30 | compatible = "ti,da830-mcasp-audio"; | 44 | compatible = "ti,da830-mcasp-audio"; |
| 31 | #address-cells = <1>; | ||
| 32 | #size-cells = <0>; | ||
| 33 | reg = <0x100000 0x3000>; | 45 | reg = <0x100000 0x3000>; |
| 34 | interrupts = <82 83>; | 46 | reg-names "mpu"; |
| 47 | interrupts = <82>, <83>; | ||
| 48 | interrupts-names = "tx", "rx"; | ||
| 35 | op-mode = <0>; /* MCASP_IIS_MODE */ | 49 | op-mode = <0>; /* MCASP_IIS_MODE */ |
| 36 | tdm-slots = <2>; | 50 | tdm-slots = <2>; |
| 37 | num-serializer = <16>; | ||
| 38 | serial-dir = < | 51 | serial-dir = < |
| 39 | 0 0 0 0 /* 0: INACTIVE, 1: TX, 2: RX */ | 52 | 0 0 0 0 /* 0: INACTIVE, 1: TX, 2: RX */ |
| 40 | 0 0 0 0 | 53 | 0 0 0 0 |
diff --git a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt index 705a6b156c6c..5e6040c2c2e9 100644 --- a/Documentation/devicetree/bindings/sound/tlv320aic3x.txt +++ b/Documentation/devicetree/bindings/sound/tlv320aic3x.txt | |||
| @@ -24,10 +24,36 @@ Optional properties: | |||
| 24 | 3 - MICBIAS output is connected to AVDD, | 24 | 3 - MICBIAS output is connected to AVDD, |
| 25 | If this node is not mentioned or if the value is incorrect, then MicBias | 25 | If this node is not mentioned or if the value is incorrect, then MicBias |
| 26 | is powered down. | 26 | is powered down. |
| 27 | - AVDD-supply, IOVDD-supply, DRVDD-supply, DVDD-supply : power supplies for the | ||
| 28 | device as covered in Documentation/devicetree/bindings/regulator/regulator.txt | ||
| 29 | |||
| 30 | CODEC output pins: | ||
| 31 | * LLOUT | ||
| 32 | * RLOUT | ||
| 33 | * MONO_LOUT | ||
| 34 | * HPLOUT | ||
| 35 | * HPROUT | ||
| 36 | * HPLCOM | ||
| 37 | * HPRCOM | ||
| 38 | |||
| 39 | CODEC input pins: | ||
| 40 | * MIC3L | ||
| 41 | * MIC3R | ||
| 42 | * LINE1L | ||
| 43 | * LINE2L | ||
| 44 | * LINE1R | ||
| 45 | * LINE2R | ||
| 46 | |||
| 47 | The pins can be used in referring sound node's audio-routing property. | ||
| 27 | 48 | ||
| 28 | Example: | 49 | Example: |
| 29 | 50 | ||
| 30 | tlv320aic3x: tlv320aic3x@1b { | 51 | tlv320aic3x: tlv320aic3x@1b { |
| 31 | compatible = "ti,tlv320aic3x"; | 52 | compatible = "ti,tlv320aic3x"; |
| 32 | reg = <0x1b>; | 53 | reg = <0x1b>; |
| 54 | |||
| 55 | AVDD-supply = <®ulator>; | ||
| 56 | IOVDD-supply = <®ulator>; | ||
| 57 | DRVDD-supply = <®ulator>; | ||
| 58 | DVDD-supply = <®ulator>; | ||
| 33 | }; | 59 | }; |
diff --git a/Documentation/devicetree/bindings/sound/tpa6130a2.txt b/Documentation/devicetree/bindings/sound/tpa6130a2.txt new file mode 100644 index 000000000000..6dfa740e4b2d --- /dev/null +++ b/Documentation/devicetree/bindings/sound/tpa6130a2.txt | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | Texas Instruments - tpa6130a2 Codec module | ||
| 2 | |||
| 3 | The tpa6130a2 serial control bus communicates through I2C protocols | ||
| 4 | |||
| 5 | Required properties: | ||
| 6 | |||
| 7 | - compatible - "string" - One of: | ||
| 8 | "ti,tpa6130a2" - TPA6130A2 | ||
| 9 | "ti,tpa6140a2" - TPA6140A2 | ||
| 10 | |||
| 11 | |||
| 12 | - reg - <int> - I2C slave address | ||
| 13 | |||
| 14 | - Vdd-supply - <phandle> - power supply regulator | ||
| 15 | |||
| 16 | Optional properties: | ||
| 17 | |||
| 18 | - power-gpio - gpio pin to power the device | ||
| 19 | |||
| 20 | Example: | ||
| 21 | |||
| 22 | tpa6130a2: tpa6130a2@60 { | ||
| 23 | compatible = "ti,tpa6130a2"; | ||
| 24 | reg = <0x60>; | ||
| 25 | Vdd-supply = <&vmmc2>; | ||
| 26 | power-gpio = <&gpio4 2 GPIO_ACTIVE_HIGH>; | ||
| 27 | }; | ||
diff --git a/Documentation/sound/alsa/soc/DPCM.txt b/Documentation/sound/alsa/soc/DPCM.txt new file mode 100644 index 000000000000..aa8546f2d144 --- /dev/null +++ b/Documentation/sound/alsa/soc/DPCM.txt | |||
| @@ -0,0 +1,380 @@ | |||
| 1 | Dynamic PCM | ||
| 2 | =========== | ||
| 3 | |||
| 4 | 1. Description | ||
| 5 | ============== | ||
| 6 | |||
| 7 | Dynamic PCM allows an ALSA PCM device to digitally route its PCM audio to | ||
| 8 | various digital endpoints during the PCM stream runtime. e.g. PCM0 can route | ||
| 9 | digital audio to I2S DAI0, I2S DAI1 or PDM DAI2. This is useful for on SoC DSP | ||
| 10 | drivers that expose several ALSA PCMs and can route to multiple DAIs. | ||
| 11 | |||
| 12 | The DPCM runtime routing is determined by the ALSA mixer settings in the same | ||
| 13 | way as the analog signal is routed in an ASoC codec driver. DPCM uses a DAPM | ||
| 14 | graph representing the DSP internal audio paths and uses the mixer settings to | ||
| 15 | determine the patch used by each ALSA PCM. | ||
| 16 | |||
| 17 | DPCM re-uses all the existing component codec, platform and DAI drivers without | ||
| 18 | any modifications. | ||
| 19 | |||
| 20 | |||
| 21 | Phone Audio System with SoC based DSP | ||
| 22 | ------------------------------------- | ||
| 23 | |||
| 24 | Consider the following phone audio subsystem. This will be used in this | ||
| 25 | document for all examples :- | ||
| 26 | |||
| 27 | | Front End PCMs | SoC DSP | Back End DAIs | Audio devices | | ||
| 28 | |||
| 29 | ************* | ||
| 30 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
| 31 | * * | ||
| 32 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
| 33 | * DSP * | ||
| 34 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
| 35 | * * | ||
| 36 | PCM3 <------------> * * <----DAI3-----> BT | ||
| 37 | * * | ||
| 38 | * * <----DAI4-----> DMIC | ||
| 39 | * * | ||
| 40 | * * <----DAI5-----> FM | ||
| 41 | ************* | ||
| 42 | |||
| 43 | This diagram shows a simple smart phone audio subsystem. It supports Bluetooth, | ||
| 44 | FM digital radio, Speakers, Headset Jack, digital microphones and cellular | ||
| 45 | modem. This sound card exposes 4 DSP front end (FE) ALSA PCM devices and | ||
| 46 | supports 6 back end (BE) DAIs. Each FE PCM can digitally route audio data to any | ||
| 47 | of the BE DAIs. The FE PCM devices can also route audio to more than 1 BE DAI. | ||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | Example - DPCM Switching playback from DAI0 to DAI1 | ||
| 52 | --------------------------------------------------- | ||
| 53 | |||
| 54 | Audio is being played to the Headset. After a while the user removes the headset | ||
| 55 | and audio continues playing on the speakers. | ||
| 56 | |||
| 57 | Playback on PCM0 to Headset would look like :- | ||
| 58 | |||
| 59 | ************* | ||
| 60 | PCM0 <============> * * <====DAI0=====> Codec Headset | ||
| 61 | * * | ||
| 62 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
| 63 | * DSP * | ||
| 64 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
| 65 | * * | ||
| 66 | PCM3 <------------> * * <----DAI3-----> BT | ||
| 67 | * * | ||
| 68 | * * <----DAI4-----> DMIC | ||
| 69 | * * | ||
| 70 | * * <----DAI5-----> FM | ||
| 71 | ************* | ||
| 72 | |||
| 73 | The headset is removed from the jack by user so the speakers must now be used :- | ||
| 74 | |||
| 75 | ************* | ||
| 76 | PCM0 <============> * * <----DAI0-----> Codec Headset | ||
| 77 | * * | ||
| 78 | PCM1 <------------> * * <====DAI1=====> Codec Speakers | ||
| 79 | * DSP * | ||
| 80 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
| 81 | * * | ||
| 82 | PCM3 <------------> * * <----DAI3-----> BT | ||
| 83 | * * | ||
| 84 | * * <----DAI4-----> DMIC | ||
| 85 | * * | ||
| 86 | * * <----DAI5-----> FM | ||
| 87 | ************* | ||
| 88 | |||
| 89 | The audio driver processes this as follows :- | ||
| 90 | |||
| 91 | 1) Machine driver receives Jack removal event. | ||
| 92 | |||
| 93 | 2) Machine driver OR audio HAL disables the Headset path. | ||
| 94 | |||
| 95 | 3) DPCM runs the PCM trigger(stop), hw_free(), shutdown() operations on DAI0 | ||
| 96 | for headset since the path is now disabled. | ||
| 97 | |||
| 98 | 4) Machine driver or audio HAL enables the speaker path. | ||
| 99 | |||
| 100 | 5) DPCM runs the PCM ops for startup(), hw_params(), prepapre() and | ||
| 101 | trigger(start) for DAI1 Speakers since the path is enabled. | ||
| 102 | |||
| 103 | In this example, the machine driver or userspace audio HAL can alter the routing | ||
| 104 | and then DPCM will take care of managing the DAI PCM operations to either bring | ||
| 105 | the link up or down. Audio playback does not stop during this transition. | ||
| 106 | |||
| 107 | |||
| 108 | |||
| 109 | DPCM machine driver | ||
| 110 | =================== | ||
| 111 | |||
| 112 | The DPCM enabled ASoC machine driver is similar to normal machine drivers | ||
| 113 | except that we also have to :- | ||
| 114 | |||
| 115 | 1) Define the FE and BE DAI links. | ||
| 116 | |||
| 117 | 2) Define any FE/BE PCM operations. | ||
| 118 | |||
| 119 | 3) Define widget graph connections. | ||
| 120 | |||
| 121 | |||
| 122 | 1 FE and BE DAI links | ||
| 123 | --------------------- | ||
| 124 | |||
| 125 | | Front End PCMs | SoC DSP | Back End DAIs | Audio devices | | ||
| 126 | |||
| 127 | ************* | ||
| 128 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
| 129 | * * | ||
| 130 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
| 131 | * DSP * | ||
| 132 | PCM2 <------------> * * <----DAI2-----> MODEM | ||
| 133 | * * | ||
| 134 | PCM3 <------------> * * <----DAI3-----> BT | ||
| 135 | * * | ||
| 136 | * * <----DAI4-----> DMIC | ||
| 137 | * * | ||
| 138 | * * <----DAI5-----> FM | ||
| 139 | ************* | ||
| 140 | |||
| 141 | For the example above we have to define 4 FE DAI links and 6 BE DAI links. The | ||
| 142 | FE DAI links are defined as follows :- | ||
| 143 | |||
| 144 | static struct snd_soc_dai_link machine_dais[] = { | ||
| 145 | { | ||
| 146 | .name = "PCM0 System", | ||
| 147 | .stream_name = "System Playback", | ||
| 148 | .cpu_dai_name = "System Pin", | ||
| 149 | .platform_name = "dsp-audio", | ||
| 150 | .codec_name = "snd-soc-dummy", | ||
| 151 | .codec_dai_name = "snd-soc-dummy-dai", | ||
| 152 | .dynamic = 1, | ||
| 153 | .trigger = {SND_SOC_DPCM_TRIGGER_POST, SND_SOC_DPCM_TRIGGER_POST}, | ||
| 154 | .dpcm_playback = 1, | ||
| 155 | }, | ||
| 156 | .....< other FE and BE DAI links here > | ||
| 157 | }; | ||
| 158 | |||
| 159 | This FE DAI link is pretty similar to a regular DAI link except that we also | ||
| 160 | set the DAI link to a DPCM FE with the "dynamic = 1". The supported FE stream | ||
| 161 | directions should also be set with the "dpcm_playback" and "dpcm_capture" | ||
| 162 | flags. There is also an option to specify the ordering of the trigger call for | ||
| 163 | each FE. This allows the ASoC core to trigger the DSP before or after the other | ||
| 164 | components (as some DSPs have strong requirements for the ordering DAI/DSP | ||
| 165 | start and stop sequences). | ||
| 166 | |||
| 167 | The FE DAI above sets the codec and code DAIs to dummy devices since the BE is | ||
| 168 | dynamic and will change depending on runtime config. | ||
| 169 | |||
| 170 | The BE DAIs are configured as follows :- | ||
| 171 | |||
| 172 | static struct snd_soc_dai_link machine_dais[] = { | ||
| 173 | .....< FE DAI links here > | ||
| 174 | { | ||
| 175 | .name = "Codec Headset", | ||
| 176 | .cpu_dai_name = "ssp-dai.0", | ||
| 177 | .platform_name = "snd-soc-dummy", | ||
| 178 | .no_pcm = 1, | ||
| 179 | .codec_name = "rt5640.0-001c", | ||
| 180 | .codec_dai_name = "rt5640-aif1", | ||
| 181 | .ignore_suspend = 1, | ||
| 182 | .ignore_pmdown_time = 1, | ||
| 183 | .be_hw_params_fixup = hswult_ssp0_fixup, | ||
| 184 | .ops = &haswell_ops, | ||
| 185 | .dpcm_playback = 1, | ||
| 186 | .dpcm_capture = 1, | ||
| 187 | }, | ||
| 188 | .....< other BE DAI links here > | ||
| 189 | }; | ||
| 190 | |||
| 191 | This BE DAI link connects DAI0 to the codec (in this case RT5460 AIF1). It sets | ||
| 192 | the "no_pcm" flag to mark it has a BE and sets flags for supported stream | ||
| 193 | directions using "dpcm_playback" and "dpcm_capture" above. | ||
| 194 | |||
| 195 | The BE has also flags set for ignoreing suspend and PM down time. This allows | ||
| 196 | the BE to work in a hostless mode where the host CPU is not transferring data | ||
| 197 | like a BT phone call :- | ||
| 198 | |||
| 199 | ************* | ||
| 200 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
| 201 | * * | ||
| 202 | PCM1 <------------> * * <----DAI1-----> Codec Speakers | ||
| 203 | * DSP * | ||
| 204 | PCM2 <------------> * * <====DAI2=====> MODEM | ||
| 205 | * * | ||
| 206 | PCM3 <------------> * * <====DAI3=====> BT | ||
| 207 | * * | ||
| 208 | * * <----DAI4-----> DMIC | ||
| 209 | * * | ||
| 210 | * * <----DAI5-----> FM | ||
| 211 | ************* | ||
| 212 | |||
| 213 | This allows the host CPU to sleep whilst the DSP, MODEM DAI and the BT DAI are | ||
| 214 | still in operation. | ||
| 215 | |||
| 216 | A BE DAI link can also set the codec to a dummy device if the code is a device | ||
| 217 | that is managed externally. | ||
| 218 | |||
| 219 | Likewise a BE DAI can also set a dummy cpu DAI if the CPU DAI is managed by the | ||
| 220 | DSP firmware. | ||
| 221 | |||
| 222 | |||
| 223 | 2 FE/BE PCM operations | ||
| 224 | ---------------------- | ||
| 225 | |||
| 226 | The BE above also exports some PCM operations and a "fixup" callback. The fixup | ||
| 227 | callback is used by the machine driver to (re)configure the DAI based upon the | ||
| 228 | FE hw params. i.e. the DSP may perform SRC or ASRC from the FE to BE. | ||
| 229 | |||
| 230 | e.g. DSP converts all FE hw params to run at fixed rate of 48k, 16bit, stereo for | ||
| 231 | DAI0. This means all FE hw_params have to be fixed in the machine driver for | ||
| 232 | DAI0 so that the DAI is running at desired configuration regardless of the FE | ||
| 233 | configuration. | ||
| 234 | |||
| 235 | static int dai0_fixup(struct snd_soc_pcm_runtime *rtd, | ||
| 236 | struct snd_pcm_hw_params *params) | ||
| 237 | { | ||
| 238 | struct snd_interval *rate = hw_param_interval(params, | ||
| 239 | SNDRV_PCM_HW_PARAM_RATE); | ||
| 240 | struct snd_interval *channels = hw_param_interval(params, | ||
| 241 | SNDRV_PCM_HW_PARAM_CHANNELS); | ||
| 242 | |||
| 243 | /* The DSP will covert the FE rate to 48k, stereo */ | ||
| 244 | rate->min = rate->max = 48000; | ||
| 245 | channels->min = channels->max = 2; | ||
| 246 | |||
| 247 | /* set DAI0 to 16 bit */ | ||
| 248 | snd_mask_set(¶ms->masks[SNDRV_PCM_HW_PARAM_FORMAT - | ||
| 249 | SNDRV_PCM_HW_PARAM_FIRST_MASK], | ||
| 250 | SNDRV_PCM_FORMAT_S16_LE); | ||
| 251 | return 0; | ||
| 252 | } | ||
| 253 | |||
| 254 | The other PCM operation are the same as for regular DAI links. Use as necessary. | ||
| 255 | |||
| 256 | |||
| 257 | 3 Widget graph connections | ||
| 258 | -------------------------- | ||
| 259 | |||
| 260 | The BE DAI links will normally be connected to the graph at initialisation time | ||
| 261 | by the ASoC DAPM core. However, if the BE codec or BE DAI is a dummy then this | ||
| 262 | has to be set explicitly in the driver :- | ||
| 263 | |||
| 264 | /* BE for codec Headset - DAI0 is dummy and managed by DSP FW */ | ||
| 265 | {"DAI0 CODEC IN", NULL, "AIF1 Capture"}, | ||
| 266 | {"AIF1 Playback", NULL, "DAI0 CODEC OUT"}, | ||
| 267 | |||
| 268 | |||
| 269 | Writing a DPCM DSP driver | ||
| 270 | ========================= | ||
| 271 | |||
| 272 | The DPCM DSP driver looks much like a standard platform class ASoC driver | ||
| 273 | combined with elements from a codec class driver. A DSP platform driver must | ||
| 274 | implement :- | ||
| 275 | |||
| 276 | 1) Front End PCM DAIs - i.e. struct snd_soc_dai_driver. | ||
| 277 | |||
| 278 | 2) DAPM graph showing DSP audio routing from FE DAIs to BEs. | ||
| 279 | |||
| 280 | 3) DAPM widgets from DSP graph. | ||
| 281 | |||
| 282 | 4) Mixers for gains, routing, etc. | ||
| 283 | |||
| 284 | 5) DMA configuration. | ||
| 285 | |||
| 286 | 6) BE AIF widgets. | ||
| 287 | |||
| 288 | Items 6 is important for routing the audio outside of the DSP. AIF need to be | ||
| 289 | defined for each BE and each stream direction. e.g for BE DAI0 above we would | ||
| 290 | have :- | ||
| 291 | |||
| 292 | SND_SOC_DAPM_AIF_IN("DAI0 RX", NULL, 0, SND_SOC_NOPM, 0, 0), | ||
| 293 | SND_SOC_DAPM_AIF_OUT("DAI0 TX", NULL, 0, SND_SOC_NOPM, 0, 0), | ||
| 294 | |||
| 295 | The BE AIF are used to connect the DSP graph to the graphs for the other | ||
| 296 | component drivers (e.g. codec graph). | ||
| 297 | |||
| 298 | |||
| 299 | Hostless PCM streams | ||
| 300 | ==================== | ||
| 301 | |||
| 302 | A hostless PCM stream is a stream that is not routed through the host CPU. An | ||
| 303 | example of this would be a phone call from handset to modem. | ||
| 304 | |||
| 305 | |||
| 306 | ************* | ||
| 307 | PCM0 <------------> * * <----DAI0-----> Codec Headset | ||
| 308 | * * | ||
| 309 | PCM1 <------------> * * <====DAI1=====> Codec Speakers/Mic | ||
| 310 | * DSP * | ||
| 311 | PCM2 <------------> * * <====DAI2=====> MODEM | ||
| 312 | * * | ||
| 313 | PCM3 <------------> * * <----DAI3-----> BT | ||
| 314 | * * | ||
| 315 | * * <----DAI4-----> DMIC | ||
| 316 | * * | ||
| 317 | * * <----DAI5-----> FM | ||
| 318 | ************* | ||
| 319 | |||
| 320 | In this case the PCM data is routed via the DSP. The host CPU in this use case | ||
| 321 | is only used for control and can sleep during the runtime of the stream. | ||
| 322 | |||
| 323 | The host can control the hostless link either by :- | ||
| 324 | |||
| 325 | 1) Configuring the link as a CODEC <-> CODEC style link. In this case the link | ||
| 326 | is enabled or disabled by the state of the DAPM graph. This usually means | ||
| 327 | there is a mixer control that can be used to connect or disconnect the path | ||
| 328 | between both DAIs. | ||
| 329 | |||
| 330 | 2) Hostless FE. This FE has a virtual connection to the BE DAI links on the DAPM | ||
| 331 | graph. Control is then carried out by the FE as regualar PCM operations. | ||
| 332 | This method gives more control over the DAI links, but requires much more | ||
| 333 | userspace code to control the link. Its recommended to use CODEC<->CODEC | ||
| 334 | unless your HW needs more fine grained sequencing of the PCM ops. | ||
| 335 | |||
| 336 | |||
| 337 | CODEC <-> CODEC link | ||
| 338 | -------------------- | ||
| 339 | |||
| 340 | This DAI link is enabled when DAPM detects a valid path within the DAPM graph. | ||
| 341 | The machine driver sets some additional parameters to the DAI link i.e. | ||
| 342 | |||
| 343 | static const struct snd_soc_pcm_stream dai_params = { | ||
| 344 | .formats = SNDRV_PCM_FMTBIT_S32_LE, | ||
| 345 | .rate_min = 8000, | ||
| 346 | .rate_max = 8000, | ||
| 347 | .channels_min = 2, | ||
| 348 | .channels_max = 2, | ||
| 349 | }; | ||
| 350 | |||
| 351 | static struct snd_soc_dai_link dais[] = { | ||
| 352 | < ... more DAI links above ... > | ||
| 353 | { | ||
| 354 | .name = "MODEM", | ||
| 355 | .stream_name = "MODEM", | ||
| 356 | .cpu_dai_name = "dai2", | ||
| 357 | .codec_dai_name = "modem-aif1", | ||
| 358 | .codec_name = "modem", | ||
| 359 | .dai_fmt = SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | ||
| 360 | | SND_SOC_DAIFMT_CBM_CFM, | ||
| 361 | .params = &dai_params, | ||
| 362 | } | ||
| 363 | < ... more DAI links here ... > | ||
| 364 | |||
| 365 | These parameters are used to configure the DAI hw_params() when DAPM detects a | ||
| 366 | valid path and then calls the PCM operations to start the link. DAPM will also | ||
| 367 | call the appropriate PCM operations to disable the DAI when the path is no | ||
| 368 | longer valid. | ||
| 369 | |||
| 370 | |||
| 371 | Hostless FE | ||
| 372 | ----------- | ||
| 373 | |||
| 374 | The DAI link(s) are enabled by a FE that does not read or write any PCM data. | ||
| 375 | This means creating a new FE that is connected with a virtual path to both | ||
| 376 | DAI links. The DAI links will be started when the FE PCM is started and stopped | ||
| 377 | when the FE PCM is stopped. Note that the FE PCM cannot read or write data in | ||
| 378 | this configuration. | ||
| 379 | |||
| 380 | |||
diff --git a/Documentation/sound/alsa/soc/codec.txt b/Documentation/sound/alsa/soc/codec.txt index bce23a4a7875..db5f9c9ae149 100644 --- a/Documentation/sound/alsa/soc/codec.txt +++ b/Documentation/sound/alsa/soc/codec.txt | |||
| @@ -1,22 +1,23 @@ | |||
| 1 | ASoC Codec Driver | 1 | ASoC Codec Class Driver |
| 2 | ================= | 2 | ======================= |
| 3 | 3 | ||
| 4 | The codec driver is generic and hardware independent code that configures the | 4 | The codec class driver is generic and hardware independent code that configures |
| 5 | codec to provide audio capture and playback. It should contain no code that is | 5 | the codec, FM, MODEM, BT or external DSP to provide audio capture and playback. |
| 6 | specific to the target platform or machine. All platform and machine specific | 6 | It should contain no code that is specific to the target platform or machine. |
| 7 | code should be added to the platform and machine drivers respectively. | 7 | All platform and machine specific code should be added to the platform and |
| 8 | machine drivers respectively. | ||
| 8 | 9 | ||
| 9 | Each codec driver *must* provide the following features:- | 10 | Each codec class driver *must* provide the following features:- |
| 10 | 11 | ||
| 11 | 1) Codec DAI and PCM configuration | 12 | 1) Codec DAI and PCM configuration |
| 12 | 2) Codec control IO - using I2C, 3 Wire(SPI) or both APIs | 13 | 2) Codec control IO - using RegMap API |
| 13 | 3) Mixers and audio controls | 14 | 3) Mixers and audio controls |
| 14 | 4) Codec audio operations | 15 | 4) Codec audio operations |
| 16 | 5) DAPM description. | ||
| 17 | 6) DAPM event handler. | ||
| 15 | 18 | ||
| 16 | Optionally, codec drivers can also provide:- | 19 | Optionally, codec drivers can also provide:- |
| 17 | 20 | ||
| 18 | 5) DAPM description. | ||
| 19 | 6) DAPM event handler. | ||
| 20 | 7) DAC Digital mute control. | 21 | 7) DAC Digital mute control. |
| 21 | 22 | ||
| 22 | Its probably best to use this guide in conjunction with the existing codec | 23 | Its probably best to use this guide in conjunction with the existing codec |
| @@ -64,26 +65,9 @@ struct snd_soc_dai_driver wm8731_dai = { | |||
| 64 | 2 - Codec control IO | 65 | 2 - Codec control IO |
| 65 | -------------------- | 66 | -------------------- |
| 66 | The codec can usually be controlled via an I2C or SPI style interface | 67 | The codec can usually be controlled via an I2C or SPI style interface |
| 67 | (AC97 combines control with data in the DAI). The codec drivers provide | 68 | (AC97 combines control with data in the DAI). The codec driver should use the |
| 68 | functions to read and write the codec registers along with supplying a | 69 | Regmap API for all codec IO. Please see include/linux/regmap.h and existing |
| 69 | register cache:- | 70 | codec drivers for example regmap usage. |
| 70 | |||
| 71 | /* IO control data and register cache */ | ||
| 72 | void *control_data; /* codec control (i2c/3wire) data */ | ||
| 73 | void *reg_cache; | ||
| 74 | |||
| 75 | Codec read/write should do any data formatting and call the hardware | ||
| 76 | read write below to perform the IO. These functions are called by the | ||
| 77 | core and ALSA when performing DAPM or changing the mixer:- | ||
| 78 | |||
| 79 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | ||
| 80 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | ||
| 81 | |||
| 82 | Codec hardware IO functions - usually points to either the I2C, SPI or AC97 | ||
| 83 | read/write:- | ||
| 84 | |||
| 85 | hw_write_t hw_write; | ||
| 86 | hw_read_t hw_read; | ||
| 87 | 71 | ||
| 88 | 72 | ||
| 89 | 3 - Mixers and audio controls | 73 | 3 - Mixers and audio controls |
| @@ -127,7 +111,7 @@ Defines a stereo enumerated control | |||
| 127 | 111 | ||
| 128 | 4 - Codec Audio Operations | 112 | 4 - Codec Audio Operations |
| 129 | -------------------------- | 113 | -------------------------- |
| 130 | The codec driver also supports the following ALSA operations:- | 114 | The codec driver also supports the following ALSA PCM operations:- |
| 131 | 115 | ||
| 132 | /* SoC audio ops */ | 116 | /* SoC audio ops */ |
| 133 | struct snd_soc_ops { | 117 | struct snd_soc_ops { |
diff --git a/Documentation/sound/alsa/soc/dapm.txt b/Documentation/sound/alsa/soc/dapm.txt index 05bf5a0eee41..7dfd88ce31ac 100644 --- a/Documentation/sound/alsa/soc/dapm.txt +++ b/Documentation/sound/alsa/soc/dapm.txt | |||
| @@ -21,7 +21,7 @@ level power systems. | |||
| 21 | 21 | ||
| 22 | There are 4 power domains within DAPM | 22 | There are 4 power domains within DAPM |
| 23 | 23 | ||
| 24 | 1. Codec domain - VREF, VMID (core codec and audio power) | 24 | 1. Codec bias domain - VREF, VMID (core codec and audio power) |
| 25 | Usually controlled at codec probe/remove and suspend/resume, although | 25 | Usually controlled at codec probe/remove and suspend/resume, although |
| 26 | can be set at stream time if power is not needed for sidetone, etc. | 26 | can be set at stream time if power is not needed for sidetone, etc. |
| 27 | 27 | ||
| @@ -63,14 +63,22 @@ Audio DAPM widgets fall into a number of types:- | |||
| 63 | o Line - Line Input/Output (and optional Jack) | 63 | o Line - Line Input/Output (and optional Jack) |
| 64 | o Speaker - Speaker | 64 | o Speaker - Speaker |
| 65 | o Supply - Power or clock supply widget used by other widgets. | 65 | o Supply - Power or clock supply widget used by other widgets. |
| 66 | o Regulator - External regulator that supplies power to audio components. | ||
| 67 | o Clock - External clock that supplies clock to audio componnents. | ||
| 68 | o AIF IN - Audio Interface Input (with TDM slot mask). | ||
| 69 | o AIF OUT - Audio Interface Output (with TDM slot mask). | ||
| 70 | o Siggen - Signal Generator. | ||
| 71 | o DAI IN - Digital Audio Interface Input. | ||
| 72 | o DAI OUT - Digital Audio Interface Output. | ||
| 73 | o DAI Link - DAI Link between two DAI structures */ | ||
| 66 | o Pre - Special PRE widget (exec before all others) | 74 | o Pre - Special PRE widget (exec before all others) |
| 67 | o Post - Special POST widget (exec after all others) | 75 | o Post - Special POST widget (exec after all others) |
| 68 | 76 | ||
| 69 | (Widgets are defined in include/sound/soc-dapm.h) | 77 | (Widgets are defined in include/sound/soc-dapm.h) |
| 70 | 78 | ||
| 71 | Widgets are usually added in the codec driver and the machine driver. There are | 79 | Widgets can be added to the sound card by any of the component driver types. |
| 72 | convenience macros defined in soc-dapm.h that can be used to quickly build a | 80 | There are convenience macros defined in soc-dapm.h that can be used to quickly |
| 73 | list of widgets of the codecs and machines DAPM widgets. | 81 | build a list of widgets of the codecs and machines DAPM widgets. |
| 74 | 82 | ||
| 75 | Most widgets have a name, register, shift and invert. Some widgets have extra | 83 | Most widgets have a name, register, shift and invert. Some widgets have extra |
| 76 | parameters for stream name and kcontrols. | 84 | parameters for stream name and kcontrols. |
| @@ -80,11 +88,13 @@ parameters for stream name and kcontrols. | |||
| 80 | ------------------------- | 88 | ------------------------- |
| 81 | 89 | ||
| 82 | Stream Widgets relate to the stream power domain and only consist of ADCs | 90 | Stream Widgets relate to the stream power domain and only consist of ADCs |
| 83 | (analog to digital converters) and DACs (digital to analog converters). | 91 | (analog to digital converters), DACs (digital to analog converters), |
| 92 | AIF IN and AIF OUT. | ||
| 84 | 93 | ||
| 85 | Stream widgets have the following format:- | 94 | Stream widgets have the following format:- |
| 86 | 95 | ||
| 87 | SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), | 96 | SND_SOC_DAPM_DAC(name, stream name, reg, shift, invert), |
| 97 | SND_SOC_DAPM_AIF_IN(name, stream, slot, reg, shift, invert) | ||
| 88 | 98 | ||
| 89 | NOTE: the stream name must match the corresponding stream name in your codec | 99 | NOTE: the stream name must match the corresponding stream name in your codec |
| 90 | snd_soc_codec_dai. | 100 | snd_soc_codec_dai. |
| @@ -94,6 +104,11 @@ e.g. stream widgets for HiFi playback and capture | |||
| 94 | SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1), | 104 | SND_SOC_DAPM_DAC("HiFi DAC", "HiFi Playback", REG, 3, 1), |
| 95 | SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1), | 105 | SND_SOC_DAPM_ADC("HiFi ADC", "HiFi Capture", REG, 2, 1), |
| 96 | 106 | ||
| 107 | e.g. stream widgets for AIF | ||
| 108 | |||
| 109 | SND_SOC_DAPM_AIF_IN("AIF1RX", "AIF1 Playback", 0, SND_SOC_NOPM, 0, 0), | ||
| 110 | SND_SOC_DAPM_AIF_OUT("AIF1TX", "AIF1 Capture", 0, SND_SOC_NOPM, 0, 0), | ||
| 111 | |||
| 97 | 112 | ||
| 98 | 2.2 Path Domain Widgets | 113 | 2.2 Path Domain Widgets |
| 99 | ----------------------- | 114 | ----------------------- |
| @@ -121,12 +136,14 @@ If you dont want the mixer elements prefixed with the name of the mixer widget, | |||
| 121 | you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same | 136 | you can use SND_SOC_DAPM_MIXER_NAMED_CTL instead. the parameters are the same |
| 122 | as for SND_SOC_DAPM_MIXER. | 137 | as for SND_SOC_DAPM_MIXER. |
| 123 | 138 | ||
| 124 | 2.3 Platform/Machine domain Widgets | 139 | |
| 125 | ----------------------------------- | 140 | 2.3 Machine domain Widgets |
| 141 | -------------------------- | ||
| 126 | 142 | ||
| 127 | Machine widgets are different from codec widgets in that they don't have a | 143 | Machine widgets are different from codec widgets in that they don't have a |
| 128 | codec register bit associated with them. A machine widget is assigned to each | 144 | codec register bit associated with them. A machine widget is assigned to each |
| 129 | machine audio component (non codec) that can be independently powered. e.g. | 145 | machine audio component (non codec or DSP) that can be independently |
| 146 | powered. e.g. | ||
| 130 | 147 | ||
| 131 | o Speaker Amp | 148 | o Speaker Amp |
| 132 | o Microphone Bias | 149 | o Microphone Bias |
| @@ -146,12 +163,12 @@ static int spitz_mic_bias(struct snd_soc_dapm_widget* w, int event) | |||
| 146 | SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), | 163 | SND_SOC_DAPM_MIC("Mic Jack", spitz_mic_bias), |
| 147 | 164 | ||
| 148 | 165 | ||
| 149 | 2.4 Codec Domain | 166 | 2.4 Codec (BIAS) Domain |
| 150 | ---------------- | 167 | ----------------------- |
| 151 | 168 | ||
| 152 | The codec power domain has no widgets and is handled by the codecs DAPM event | 169 | The codec bias power domain has no widgets and is handled by the codecs DAPM |
| 153 | handler. This handler is called when the codec powerstate is changed wrt to any | 170 | event handler. This handler is called when the codec powerstate is changed wrt |
| 154 | stream event or by kernel PM events. | 171 | to any stream event or by kernel PM events. |
| 155 | 172 | ||
| 156 | 173 | ||
| 157 | 2.5 Virtual Widgets | 174 | 2.5 Virtual Widgets |
| @@ -169,15 +186,16 @@ After all the widgets have been defined, they can then be added to the DAPM | |||
| 169 | subsystem individually with a call to snd_soc_dapm_new_control(). | 186 | subsystem individually with a call to snd_soc_dapm_new_control(). |
| 170 | 187 | ||
| 171 | 188 | ||
| 172 | 3. Codec Widget Interconnections | 189 | 3. Codec/DSP Widget Interconnections |
| 173 | ================================ | 190 | ==================================== |
| 174 | 191 | ||
| 175 | Widgets are connected to each other within the codec and machine by audio paths | 192 | Widgets are connected to each other within the codec, platform and machine by |
| 176 | (called interconnections). Each interconnection must be defined in order to | 193 | audio paths (called interconnections). Each interconnection must be defined in |
| 177 | create a map of all audio paths between widgets. | 194 | order to create a map of all audio paths between widgets. |
| 178 | 195 | ||
| 179 | This is easiest with a diagram of the codec (and schematic of the machine audio | 196 | This is easiest with a diagram of the codec or DSP (and schematic of the machine |
| 180 | system), as it requires joining widgets together via their audio signal paths. | 197 | audio system), as it requires joining widgets together via their audio signal |
| 198 | paths. | ||
| 181 | 199 | ||
| 182 | e.g., from the WM8731 output mixer (wm8731.c) | 200 | e.g., from the WM8731 output mixer (wm8731.c) |
| 183 | 201 | ||
| @@ -247,16 +265,9 @@ machine and includes the codec. e.g. | |||
| 247 | o Mic Jack | 265 | o Mic Jack |
| 248 | o Codec Pins | 266 | o Codec Pins |
| 249 | 267 | ||
| 250 | When a codec pin is NC it can be marked as not used with a call to | 268 | Endpoints are added to the DAPM graph so that their usage can be determined in |
| 251 | 269 | order to save power. e.g. NC codecs pins will be switched OFF, unconnected | |
| 252 | snd_soc_dapm_set_endpoint(codec, "Widget Name", 0); | 270 | jacks can also be switched OFF. |
| 253 | |||
| 254 | The last argument is 0 for inactive and 1 for active. This way the pin and its | ||
| 255 | input widget will never be powered up and consume power. | ||
| 256 | |||
| 257 | This also applies to machine widgets. e.g. if a headphone is connected to a | ||
| 258 | jack then the jack can be marked active. If the headphone is removed, then | ||
| 259 | the headphone jack can be marked inactive. | ||
| 260 | 271 | ||
| 261 | 272 | ||
| 262 | 5 DAPM Widget Events | 273 | 5 DAPM Widget Events |
diff --git a/Documentation/sound/alsa/soc/machine.txt b/Documentation/sound/alsa/soc/machine.txt index d50c14df3411..74056dba52be 100644 --- a/Documentation/sound/alsa/soc/machine.txt +++ b/Documentation/sound/alsa/soc/machine.txt | |||
| @@ -1,8 +1,10 @@ | |||
| 1 | ASoC Machine Driver | 1 | ASoC Machine Driver |
| 2 | =================== | 2 | =================== |
| 3 | 3 | ||
| 4 | The ASoC machine (or board) driver is the code that glues together the platform | 4 | The ASoC machine (or board) driver is the code that glues together all the |
| 5 | and codec drivers. | 5 | component drivers (e.g. codecs, platforms and DAIs). It also describes the |
| 6 | relationships between each componnent which include audio paths, GPIOs, | ||
| 7 | interrupts, clocking, jacks and voltage regulators. | ||
| 6 | 8 | ||
| 7 | The machine driver can contain codec and platform specific code. It registers | 9 | The machine driver can contain codec and platform specific code. It registers |
| 8 | the audio subsystem with the kernel as a platform device and is represented by | 10 | the audio subsystem with the kernel as a platform device and is represented by |
diff --git a/Documentation/sound/alsa/soc/platform.txt b/Documentation/sound/alsa/soc/platform.txt index d57efad37e0a..3a08a2c9150c 100644 --- a/Documentation/sound/alsa/soc/platform.txt +++ b/Documentation/sound/alsa/soc/platform.txt | |||
| @@ -1,9 +1,9 @@ | |||
| 1 | ASoC Platform Driver | 1 | ASoC Platform Driver |
| 2 | ==================== | 2 | ==================== |
| 3 | 3 | ||
| 4 | An ASoC platform driver can be divided into audio DMA and SoC DAI configuration | 4 | An ASoC platform driver class can be divided into audio DMA drivers, SoC DAI |
| 5 | and control. The platform drivers only target the SoC CPU and must have no board | 5 | drivers and DSP drivers. The platform drivers only target the SoC CPU and must |
| 6 | specific code. | 6 | have no board specific code. |
| 7 | 7 | ||
| 8 | Audio DMA | 8 | Audio DMA |
| 9 | ========= | 9 | ========= |
| @@ -64,3 +64,16 @@ Each SoC DAI driver must provide the following features:- | |||
| 64 | 5) Suspend and resume (optional) | 64 | 5) Suspend and resume (optional) |
| 65 | 65 | ||
| 66 | Please see codec.txt for a description of items 1 - 4. | 66 | Please see codec.txt for a description of items 1 - 4. |
| 67 | |||
| 68 | |||
| 69 | SoC DSP Drivers | ||
| 70 | =============== | ||
| 71 | |||
| 72 | Each SoC DSP driver usually supplies the following features :- | ||
| 73 | |||
| 74 | 1) DAPM graph | ||
| 75 | 2) Mixer controls | ||
| 76 | 3) DMA IO to/from DSP buffers (if applicable) | ||
| 77 | 4) Definition of DSP front end (FE) PCM devices. | ||
| 78 | |||
| 79 | Please see DPCM.txt for a description of item 4. | ||
diff --git a/MAINTAINERS b/MAINTAINERS index 8a0cbf3cf2c8..a7c34ef3509d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
| @@ -237,11 +237,11 @@ F: drivers/platform/x86/acer-wmi.c | |||
| 237 | 237 | ||
| 238 | ACPI | 238 | ACPI |
| 239 | M: Len Brown <lenb@kernel.org> | 239 | M: Len Brown <lenb@kernel.org> |
| 240 | M: Rafael J. Wysocki <rjw@sisk.pl> | 240 | M: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 241 | L: linux-acpi@vger.kernel.org | 241 | L: linux-acpi@vger.kernel.org |
| 242 | W: http://www.lesswatts.org/projects/acpi/ | 242 | W: https://01.org/linux-acpi |
| 243 | Q: http://patchwork.kernel.org/project/linux-acpi/list/ | 243 | Q: https://patchwork.kernel.org/project/linux-acpi/list/ |
| 244 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/lenb/linux | 244 | T: git git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm |
| 245 | S: Supported | 245 | S: Supported |
| 246 | F: drivers/acpi/ | 246 | F: drivers/acpi/ |
| 247 | F: drivers/pnp/pnpacpi/ | 247 | F: drivers/pnp/pnpacpi/ |
| @@ -256,21 +256,21 @@ F: drivers/pci/*/*/*acpi* | |||
| 256 | ACPI FAN DRIVER | 256 | ACPI FAN DRIVER |
| 257 | M: Zhang Rui <rui.zhang@intel.com> | 257 | M: Zhang Rui <rui.zhang@intel.com> |
| 258 | L: linux-acpi@vger.kernel.org | 258 | L: linux-acpi@vger.kernel.org |
| 259 | W: http://www.lesswatts.org/projects/acpi/ | 259 | W: https://01.org/linux-acpi |
| 260 | S: Supported | 260 | S: Supported |
| 261 | F: drivers/acpi/fan.c | 261 | F: drivers/acpi/fan.c |
| 262 | 262 | ||
| 263 | ACPI THERMAL DRIVER | 263 | ACPI THERMAL DRIVER |
| 264 | M: Zhang Rui <rui.zhang@intel.com> | 264 | M: Zhang Rui <rui.zhang@intel.com> |
| 265 | L: linux-acpi@vger.kernel.org | 265 | L: linux-acpi@vger.kernel.org |
| 266 | W: http://www.lesswatts.org/projects/acpi/ | 266 | W: https://01.org/linux-acpi |
| 267 | S: Supported | 267 | S: Supported |
| 268 | F: drivers/acpi/*thermal* | 268 | F: drivers/acpi/*thermal* |
| 269 | 269 | ||
| 270 | ACPI VIDEO DRIVER | 270 | ACPI VIDEO DRIVER |
| 271 | M: Zhang Rui <rui.zhang@intel.com> | 271 | M: Zhang Rui <rui.zhang@intel.com> |
| 272 | L: linux-acpi@vger.kernel.org | 272 | L: linux-acpi@vger.kernel.org |
| 273 | W: http://www.lesswatts.org/projects/acpi/ | 273 | W: https://01.org/linux-acpi |
| 274 | S: Supported | 274 | S: Supported |
| 275 | F: drivers/acpi/video.c | 275 | F: drivers/acpi/video.c |
| 276 | 276 | ||
| @@ -2300,7 +2300,7 @@ S: Maintained | |||
| 2300 | F: drivers/net/ethernet/ti/cpmac.c | 2300 | F: drivers/net/ethernet/ti/cpmac.c |
| 2301 | 2301 | ||
| 2302 | CPU FREQUENCY DRIVERS | 2302 | CPU FREQUENCY DRIVERS |
| 2303 | M: Rafael J. Wysocki <rjw@sisk.pl> | 2303 | M: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 2304 | M: Viresh Kumar <viresh.kumar@linaro.org> | 2304 | M: Viresh Kumar <viresh.kumar@linaro.org> |
| 2305 | L: cpufreq@vger.kernel.org | 2305 | L: cpufreq@vger.kernel.org |
| 2306 | L: linux-pm@vger.kernel.org | 2306 | L: linux-pm@vger.kernel.org |
| @@ -2331,7 +2331,7 @@ S: Maintained | |||
| 2331 | F: drivers/cpuidle/cpuidle-big_little.c | 2331 | F: drivers/cpuidle/cpuidle-big_little.c |
| 2332 | 2332 | ||
| 2333 | CPUIDLE DRIVERS | 2333 | CPUIDLE DRIVERS |
| 2334 | M: Rafael J. Wysocki <rjw@sisk.pl> | 2334 | M: Rafael J. Wysocki <rjw@rjwysocki.net> |
| 2335 | M: Daniel Lezcano <daniel.lezcano@linaro.org> | 2335 | M: Daniel Lezcano <daniel.lezcano@linaro.org> |
| 2336 | L: linux-pm@vger.kernel.org | 2336 | L: linux-pm@vger.kernel.org |
| 2337 | S: Maintained | 2337 | S: Maintained |
| @@ -3553,7 +3553,7 @@ F: fs/freevxfs/ | |||
| 3553 | 3553 | ||
| 3554 | FREEZER | 3554 | FREEZER |
| 3555 | M: Pavel Machek <pavel@ucw.cz> | 3555 | M: Pavel Machek <pavel@ucw.cz> |
| 3556 | M: "Rafael J. Wysocki" <rjw@sisk.pl> | 3556 | M: "Rafael J. Wysocki" <rjw@rjwysocki.net> |
| 3557 | L: linux-pm@vger.kernel.org | 3557 | L: linux-pm@vger.kernel.org |
| 3558 | S: Supported | 3558 | S: Supported |
| 3559 | F: Documentation/power/freezing-of-tasks.txt | 3559 | F: Documentation/power/freezing-of-tasks.txt |
| @@ -3624,6 +3624,12 @@ L: linux-scsi@vger.kernel.org | |||
| 3624 | S: Odd Fixes (e.g., new signatures) | 3624 | S: Odd Fixes (e.g., new signatures) |
| 3625 | F: drivers/scsi/fdomain.* | 3625 | F: drivers/scsi/fdomain.* |
| 3626 | 3626 | ||
| 3627 | GCOV BASED KERNEL PROFILING | ||
| 3628 | M: Peter Oberparleiter <oberpar@linux.vnet.ibm.com> | ||
| 3629 | S: Maintained | ||
| 3630 | F: kernel/gcov/ | ||
| 3631 | F: Documentation/gcov.txt | ||
| 3632 | |||
| 3627 | GDT SCSI DISK ARRAY CONTROLLER DRIVER | 3633 | GDT SCSI DISK ARRAY CONTROLLER DRIVER |
| 3628 | M: Achim Leubner <achim_leubner@adaptec.com> | 3634 | M: Achim Leubner <achim_leubner@adaptec.com> |
| 3629 | L: linux-scsi@vger.kernel.org | 3635 | L: linux-scsi@vger.kernel.org |
| @@ -3889,7 +3895,7 @@ F: drivers/video/hgafb.c | |||
| 3889 | 3895 | ||
| 3890 | HIBERNATION (aka Software Suspend, aka swsusp) | 3896 | HIBERNATION (aka Software Suspend, aka swsusp) |
| 3891 | M: Pavel Machek <pavel@ucw.cz> | 3897 | M: Pavel Machek <pavel@ucw.cz> |
| 3892 | M: "Rafael J. Wysocki" <rjw@sisk.pl> | 3898 | M: "Rafael J. Wysocki" <rjw@rjwysocki.net> |
| 3893 | L: linux-pm@vger.kernel.org | 3899 | L: linux-pm@vger.kernel.org |
| 3894 | S: Supported | 3900 | S: Supported |
| 3895 | F: arch/x86/power/ | 3901 | F: arch/x86/power/ |
| @@ -4339,7 +4345,7 @@ F: drivers/video/i810/ | |||
| 4339 | INTEL MENLOW THERMAL DRIVER | 4345 | INTEL MENLOW THERMAL DRIVER |
| 4340 | M: Sujith Thomas <sujith.thomas@intel.com> | 4346 | M: Sujith Thomas <sujith.thomas@intel.com> |
| 4341 | L: platform-driver-x86@vger.kernel.org | 4347 | L: platform-driver-x86@vger.kernel.org |
| 4342 | W: http://www.lesswatts.org/projects/acpi/ | 4348 | W: https://01.org/linux-acpi |
| 4343 | S: Supported | 4349 | S: Supported |
| 4344 | F: drivers/platform/x86/intel_menlow.c | 4350 | F: drivers/platform/x86/intel_menlow.c |
| 4345 | 4351 | ||
| @@ -8095,7 +8101,7 @@ F: drivers/sh/ | |||
| 8095 | SUSPEND TO RAM | 8101 | SUSPEND TO RAM |
| 8096 | M: Len Brown <len.brown@intel.com> | 8102 | M: Len Brown <len.brown@intel.com> |
| 8097 | M: Pavel Machek <pavel@ucw.cz> | 8103 | M: Pavel Machek <pavel@ucw.cz> |
| 8098 | M: "Rafael J. Wysocki" <rjw@sisk.pl> | 8104 | M: "Rafael J. Wysocki" <rjw@rjwysocki.net> |
| 8099 | L: linux-pm@vger.kernel.org | 8105 | L: linux-pm@vger.kernel.org |
| 8100 | S: Supported | 8106 | S: Supported |
| 8101 | F: Documentation/power/ | 8107 | F: Documentation/power/ |
| @@ -1,7 +1,7 @@ | |||
| 1 | VERSION = 3 | 1 | VERSION = 3 |
| 2 | PATCHLEVEL = 12 | 2 | PATCHLEVEL = 12 |
| 3 | SUBLEVEL = 0 | 3 | SUBLEVEL = 0 |
| 4 | EXTRAVERSION = -rc5 | 4 | EXTRAVERSION = -rc6 |
| 5 | NAME = One Giant Leap for Frogkind | 5 | NAME = One Giant Leap for Frogkind |
| 6 | 6 | ||
| 7 | # *DOCUMENTATION* | 7 | # *DOCUMENTATION* |
diff --git a/arch/arm/common/mcpm_entry.c b/arch/arm/common/mcpm_entry.c index 370236dd1a03..990250965f2c 100644 --- a/arch/arm/common/mcpm_entry.c +++ b/arch/arm/common/mcpm_entry.c | |||
| @@ -51,7 +51,8 @@ void mcpm_cpu_power_down(void) | |||
| 51 | { | 51 | { |
| 52 | phys_reset_t phys_reset; | 52 | phys_reset_t phys_reset; |
| 53 | 53 | ||
| 54 | BUG_ON(!platform_ops); | 54 | if (WARN_ON_ONCE(!platform_ops || !platform_ops->power_down)) |
| 55 | return; | ||
| 55 | BUG_ON(!irqs_disabled()); | 56 | BUG_ON(!irqs_disabled()); |
| 56 | 57 | ||
| 57 | /* | 58 | /* |
| @@ -93,7 +94,8 @@ void mcpm_cpu_suspend(u64 expected_residency) | |||
| 93 | { | 94 | { |
| 94 | phys_reset_t phys_reset; | 95 | phys_reset_t phys_reset; |
| 95 | 96 | ||
| 96 | BUG_ON(!platform_ops); | 97 | if (WARN_ON_ONCE(!platform_ops || !platform_ops->suspend)) |
| 98 | return; | ||
| 97 | BUG_ON(!irqs_disabled()); | 99 | BUG_ON(!irqs_disabled()); |
| 98 | 100 | ||
| 99 | /* Very similar to mcpm_cpu_power_down() */ | 101 | /* Very similar to mcpm_cpu_power_down() */ |
diff --git a/arch/arm/common/sharpsl_param.c b/arch/arm/common/sharpsl_param.c index d56c932580eb..025f6ce38596 100644 --- a/arch/arm/common/sharpsl_param.c +++ b/arch/arm/common/sharpsl_param.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/module.h> | 15 | #include <linux/module.h> |
| 16 | #include <linux/string.h> | 16 | #include <linux/string.h> |
| 17 | #include <asm/mach/sharpsl_param.h> | 17 | #include <asm/mach/sharpsl_param.h> |
| 18 | #include <asm/memory.h> | ||
| 18 | 19 | ||
| 19 | /* | 20 | /* |
| 20 | * Certain hardware parameters determined at the time of device manufacture, | 21 | * Certain hardware parameters determined at the time of device manufacture, |
| @@ -25,8 +26,10 @@ | |||
| 25 | */ | 26 | */ |
| 26 | #ifdef CONFIG_ARCH_SA1100 | 27 | #ifdef CONFIG_ARCH_SA1100 |
| 27 | #define PARAM_BASE 0xe8ffc000 | 28 | #define PARAM_BASE 0xe8ffc000 |
| 29 | #define param_start(x) (void *)(x) | ||
| 28 | #else | 30 | #else |
| 29 | #define PARAM_BASE 0xa0000a00 | 31 | #define PARAM_BASE 0xa0000a00 |
| 32 | #define param_start(x) __va(x) | ||
| 30 | #endif | 33 | #endif |
| 31 | #define MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 ) | ( b << 8 ) | a ) | 34 | #define MAGIC_CHG(a,b,c,d) ( ( d << 24 ) | ( c << 16 ) | ( b << 8 ) | a ) |
| 32 | 35 | ||
| @@ -41,7 +44,7 @@ EXPORT_SYMBOL(sharpsl_param); | |||
| 41 | 44 | ||
| 42 | void sharpsl_save_param(void) | 45 | void sharpsl_save_param(void) |
| 43 | { | 46 | { |
| 44 | memcpy(&sharpsl_param, (void *)PARAM_BASE, sizeof(struct sharpsl_param_info)); | 47 | memcpy(&sharpsl_param, param_start(PARAM_BASE), sizeof(struct sharpsl_param_info)); |
| 45 | 48 | ||
| 46 | if (sharpsl_param.comadj_keyword != COMADJ_MAGIC) | 49 | if (sharpsl_param.comadj_keyword != COMADJ_MAGIC) |
| 47 | sharpsl_param.comadj=-1; | 50 | sharpsl_param.comadj=-1; |
diff --git a/arch/arm/include/asm/Kbuild b/arch/arm/include/asm/Kbuild index d3db39860b9c..59ceae8f3c95 100644 --- a/arch/arm/include/asm/Kbuild +++ b/arch/arm/include/asm/Kbuild | |||
| @@ -31,5 +31,4 @@ generic-y += termbits.h | |||
| 31 | generic-y += termios.h | 31 | generic-y += termios.h |
| 32 | generic-y += timex.h | 32 | generic-y += timex.h |
| 33 | generic-y += trace_clock.h | 33 | generic-y += trace_clock.h |
| 34 | generic-y += types.h | ||
| 35 | generic-y += unaligned.h | 34 | generic-y += unaligned.h |
diff --git a/arch/arm/include/asm/mcpm.h b/arch/arm/include/asm/mcpm.h index 0f7b7620e9a5..fc82a88f5b69 100644 --- a/arch/arm/include/asm/mcpm.h +++ b/arch/arm/include/asm/mcpm.h | |||
| @@ -76,8 +76,11 @@ int mcpm_cpu_power_up(unsigned int cpu, unsigned int cluster); | |||
| 76 | * | 76 | * |
| 77 | * This must be called with interrupts disabled. | 77 | * This must be called with interrupts disabled. |
| 78 | * | 78 | * |
| 79 | * This does not return. Re-entry in the kernel is expected via | 79 | * On success this does not return. Re-entry in the kernel is expected |
| 80 | * mcpm_entry_point. | 80 | * via mcpm_entry_point. |
| 81 | * | ||
| 82 | * This will return if mcpm_platform_register() has not been called | ||
| 83 | * previously in which case the caller should take appropriate action. | ||
| 81 | */ | 84 | */ |
| 82 | void mcpm_cpu_power_down(void); | 85 | void mcpm_cpu_power_down(void); |
| 83 | 86 | ||
| @@ -98,8 +101,11 @@ void mcpm_cpu_power_down(void); | |||
| 98 | * | 101 | * |
| 99 | * This must be called with interrupts disabled. | 102 | * This must be called with interrupts disabled. |
| 100 | * | 103 | * |
| 101 | * This does not return. Re-entry in the kernel is expected via | 104 | * On success this does not return. Re-entry in the kernel is expected |
| 102 | * mcpm_entry_point. | 105 | * via mcpm_entry_point. |
| 106 | * | ||
| 107 | * This will return if mcpm_platform_register() has not been called | ||
| 108 | * previously in which case the caller should take appropriate action. | ||
| 103 | */ | 109 | */ |
| 104 | void mcpm_cpu_suspend(u64 expected_residency); | 110 | void mcpm_cpu_suspend(u64 expected_residency); |
| 105 | 111 | ||
diff --git a/arch/arm/include/asm/syscall.h b/arch/arm/include/asm/syscall.h index f1d96d4e8092..73ddd7239b33 100644 --- a/arch/arm/include/asm/syscall.h +++ b/arch/arm/include/asm/syscall.h | |||
| @@ -57,6 +57,9 @@ static inline void syscall_get_arguments(struct task_struct *task, | |||
| 57 | unsigned int i, unsigned int n, | 57 | unsigned int i, unsigned int n, |
| 58 | unsigned long *args) | 58 | unsigned long *args) |
| 59 | { | 59 | { |
| 60 | if (n == 0) | ||
| 61 | return; | ||
| 62 | |||
| 60 | if (i + n > SYSCALL_MAX_ARGS) { | 63 | if (i + n > SYSCALL_MAX_ARGS) { |
| 61 | unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i; | 64 | unsigned long *args_bad = args + SYSCALL_MAX_ARGS - i; |
| 62 | unsigned int n_bad = n + i - SYSCALL_MAX_ARGS; | 65 | unsigned int n_bad = n + i - SYSCALL_MAX_ARGS; |
| @@ -81,6 +84,9 @@ static inline void syscall_set_arguments(struct task_struct *task, | |||
| 81 | unsigned int i, unsigned int n, | 84 | unsigned int i, unsigned int n, |
| 82 | const unsigned long *args) | 85 | const unsigned long *args) |
| 83 | { | 86 | { |
| 87 | if (n == 0) | ||
| 88 | return; | ||
| 89 | |||
| 84 | if (i + n > SYSCALL_MAX_ARGS) { | 90 | if (i + n > SYSCALL_MAX_ARGS) { |
| 85 | pr_warning("%s called with max args %d, handling only %d\n", | 91 | pr_warning("%s called with max args %d, handling only %d\n", |
| 86 | __func__, i + n, SYSCALL_MAX_ARGS); | 92 | __func__, i + n, SYSCALL_MAX_ARGS); |
diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 2c7cc1e03473..476de57dcef2 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S | |||
| @@ -487,7 +487,26 @@ __fixup_smp: | |||
| 487 | mrc p15, 0, r0, c0, c0, 5 @ read MPIDR | 487 | mrc p15, 0, r0, c0, c0, 5 @ read MPIDR |
| 488 | and r0, r0, #0xc0000000 @ multiprocessing extensions and | 488 | and r0, r0, #0xc0000000 @ multiprocessing extensions and |
| 489 | teq r0, #0x80000000 @ not part of a uniprocessor system? | 489 | teq r0, #0x80000000 @ not part of a uniprocessor system? |
| 490 | moveq pc, lr @ yes, assume SMP | 490 | bne __fixup_smp_on_up @ no, assume UP |
| 491 | |||
| 492 | @ Core indicates it is SMP. Check for Aegis SOC where a single | ||
| 493 | @ Cortex-A9 CPU is present but SMP operations fault. | ||
| 494 | mov r4, #0x41000000 | ||
| 495 | orr r4, r4, #0x0000c000 | ||
| 496 | orr r4, r4, #0x00000090 | ||
| 497 | teq r3, r4 @ Check for ARM Cortex-A9 | ||
| 498 | movne pc, lr @ Not ARM Cortex-A9, | ||
| 499 | |||
| 500 | @ If a future SoC *does* use 0x0 as the PERIPH_BASE, then the | ||
| 501 | @ below address check will need to be #ifdef'd or equivalent | ||
| 502 | @ for the Aegis platform. | ||
| 503 | mrc p15, 4, r0, c15, c0 @ get SCU base address | ||
| 504 | teq r0, #0x0 @ '0' on actual UP A9 hardware | ||
| 505 | beq __fixup_smp_on_up @ So its an A9 UP | ||
| 506 | ldr r0, [r0, #4] @ read SCU Config | ||
| 507 | and r0, r0, #0x3 @ number of CPUs | ||
| 508 | teq r0, #0x0 @ is 1? | ||
| 509 | movne pc, lr | ||
| 491 | 510 | ||
| 492 | __fixup_smp_on_up: | 511 | __fixup_smp_on_up: |
| 493 | adr r0, 1f | 512 | adr r0, 1f |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index f5e1a8471714..1272ed202dde 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
| @@ -1232,7 +1232,8 @@ __iommu_create_mapping(struct device *dev, struct page **pages, size_t size) | |||
| 1232 | break; | 1232 | break; |
| 1233 | 1233 | ||
| 1234 | len = (j - i) << PAGE_SHIFT; | 1234 | len = (j - i) << PAGE_SHIFT; |
| 1235 | ret = iommu_map(mapping->domain, iova, phys, len, 0); | 1235 | ret = iommu_map(mapping->domain, iova, phys, len, |
| 1236 | IOMMU_READ|IOMMU_WRITE); | ||
| 1236 | if (ret < 0) | 1237 | if (ret < 0) |
| 1237 | goto fail; | 1238 | goto fail; |
| 1238 | iova += len; | 1239 | iova += len; |
| @@ -1431,6 +1432,27 @@ static int arm_iommu_get_sgtable(struct device *dev, struct sg_table *sgt, | |||
| 1431 | GFP_KERNEL); | 1432 | GFP_KERNEL); |
| 1432 | } | 1433 | } |
| 1433 | 1434 | ||
| 1435 | static int __dma_direction_to_prot(enum dma_data_direction dir) | ||
| 1436 | { | ||
| 1437 | int prot; | ||
| 1438 | |||
| 1439 | switch (dir) { | ||
| 1440 | case DMA_BIDIRECTIONAL: | ||
| 1441 | prot = IOMMU_READ | IOMMU_WRITE; | ||
| 1442 | break; | ||
| 1443 | case DMA_TO_DEVICE: | ||
| 1444 | prot = IOMMU_READ; | ||
| 1445 | break; | ||
| 1446 | case DMA_FROM_DEVICE: | ||
| 1447 | prot = IOMMU_WRITE; | ||
| 1448 | break; | ||
| 1449 | default: | ||
| 1450 | prot = 0; | ||
| 1451 | } | ||
| 1452 | |||
| 1453 | return prot; | ||
| 1454 | } | ||
| 1455 | |||
| 1434 | /* | 1456 | /* |
| 1435 | * Map a part of the scatter-gather list into contiguous io address space | 1457 | * Map a part of the scatter-gather list into contiguous io address space |
| 1436 | */ | 1458 | */ |
| @@ -1444,6 +1466,7 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, | |||
| 1444 | int ret = 0; | 1466 | int ret = 0; |
| 1445 | unsigned int count; | 1467 | unsigned int count; |
| 1446 | struct scatterlist *s; | 1468 | struct scatterlist *s; |
| 1469 | int prot; | ||
| 1447 | 1470 | ||
| 1448 | size = PAGE_ALIGN(size); | 1471 | size = PAGE_ALIGN(size); |
| 1449 | *handle = DMA_ERROR_CODE; | 1472 | *handle = DMA_ERROR_CODE; |
| @@ -1460,7 +1483,9 @@ static int __map_sg_chunk(struct device *dev, struct scatterlist *sg, | |||
| 1460 | !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) | 1483 | !dma_get_attr(DMA_ATTR_SKIP_CPU_SYNC, attrs)) |
| 1461 | __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); | 1484 | __dma_page_cpu_to_dev(sg_page(s), s->offset, s->length, dir); |
| 1462 | 1485 | ||
| 1463 | ret = iommu_map(mapping->domain, iova, phys, len, 0); | 1486 | prot = __dma_direction_to_prot(dir); |
| 1487 | |||
| 1488 | ret = iommu_map(mapping->domain, iova, phys, len, prot); | ||
| 1464 | if (ret < 0) | 1489 | if (ret < 0) |
| 1465 | goto fail; | 1490 | goto fail; |
| 1466 | count += len >> PAGE_SHIFT; | 1491 | count += len >> PAGE_SHIFT; |
| @@ -1665,19 +1690,7 @@ static dma_addr_t arm_coherent_iommu_map_page(struct device *dev, struct page *p | |||
| 1665 | if (dma_addr == DMA_ERROR_CODE) | 1690 | if (dma_addr == DMA_ERROR_CODE) |
| 1666 | return dma_addr; | 1691 | return dma_addr; |
| 1667 | 1692 | ||
| 1668 | switch (dir) { | 1693 | prot = __dma_direction_to_prot(dir); |
| 1669 | case DMA_BIDIRECTIONAL: | ||
| 1670 | prot = IOMMU_READ | IOMMU_WRITE; | ||
| 1671 | break; | ||
| 1672 | case DMA_TO_DEVICE: | ||
| 1673 | prot = IOMMU_READ; | ||
| 1674 | break; | ||
| 1675 | case DMA_FROM_DEVICE: | ||
| 1676 | prot = IOMMU_WRITE; | ||
| 1677 | break; | ||
| 1678 | default: | ||
| 1679 | prot = 0; | ||
| 1680 | } | ||
| 1681 | 1694 | ||
| 1682 | ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); | 1695 | ret = iommu_map(mapping->domain, dma_addr, page_to_phys(page), len, prot); |
| 1683 | if (ret < 0) | 1696 | if (ret < 0) |
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index febaee7ca57b..18ec4c504abf 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
| @@ -17,7 +17,6 @@ | |||
| 17 | #include <linux/nodemask.h> | 17 | #include <linux/nodemask.h> |
| 18 | #include <linux/initrd.h> | 18 | #include <linux/initrd.h> |
| 19 | #include <linux/of_fdt.h> | 19 | #include <linux/of_fdt.h> |
| 20 | #include <linux/of_reserved_mem.h> | ||
| 21 | #include <linux/highmem.h> | 20 | #include <linux/highmem.h> |
| 22 | #include <linux/gfp.h> | 21 | #include <linux/gfp.h> |
| 23 | #include <linux/memblock.h> | 22 | #include <linux/memblock.h> |
| @@ -379,8 +378,6 @@ void __init arm_memblock_init(struct meminfo *mi, | |||
| 379 | if (mdesc->reserve) | 378 | if (mdesc->reserve) |
| 380 | mdesc->reserve(); | 379 | mdesc->reserve(); |
| 381 | 380 | ||
| 382 | early_init_dt_scan_reserved_mem(); | ||
| 383 | |||
| 384 | /* | 381 | /* |
| 385 | * reserve memory for DMA contigouos allocations, | 382 | * reserve memory for DMA contigouos allocations, |
| 386 | * must come from DMA area inside low memory | 383 | * must come from DMA area inside low memory |
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 145d703227bf..f67e839f06c8 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig | |||
| @@ -1033,6 +1033,7 @@ config X86_REBOOTFIXUPS | |||
| 1033 | 1033 | ||
| 1034 | config MICROCODE | 1034 | config MICROCODE |
| 1035 | tristate "CPU microcode loading support" | 1035 | tristate "CPU microcode loading support" |
| 1036 | depends on CPU_SUP_AMD || CPU_SUP_INTEL | ||
| 1036 | select FW_LOADER | 1037 | select FW_LOADER |
| 1037 | ---help--- | 1038 | ---help--- |
| 1038 | 1039 | ||
diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c index 1191ac1c9d25..a419814cea57 100644 --- a/arch/x86/kernel/apic/x2apic_uv_x.c +++ b/arch/x86/kernel/apic/x2apic_uv_x.c | |||
| @@ -113,7 +113,7 @@ static int __init early_get_pnodeid(void) | |||
| 113 | break; | 113 | break; |
| 114 | case UV3_HUB_PART_NUMBER: | 114 | case UV3_HUB_PART_NUMBER: |
| 115 | case UV3_HUB_PART_NUMBER_X: | 115 | case UV3_HUB_PART_NUMBER_X: |
| 116 | uv_min_hub_revision_id += UV3_HUB_REVISION_BASE - 1; | 116 | uv_min_hub_revision_id += UV3_HUB_REVISION_BASE; |
| 117 | break; | 117 | break; |
| 118 | } | 118 | } |
| 119 | 119 | ||
diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c index 697b93af02dd..a0e2a8a80c94 100644 --- a/arch/x86/kernel/kvm.c +++ b/arch/x86/kernel/kvm.c | |||
| @@ -775,11 +775,22 @@ void __init kvm_spinlock_init(void) | |||
| 775 | if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) | 775 | if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) |
| 776 | return; | 776 | return; |
| 777 | 777 | ||
| 778 | printk(KERN_INFO "KVM setup paravirtual spinlock\n"); | 778 | pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning); |
| 779 | pv_lock_ops.unlock_kick = kvm_unlock_kick; | ||
| 780 | } | ||
| 781 | |||
| 782 | static __init int kvm_spinlock_init_jump(void) | ||
| 783 | { | ||
| 784 | if (!kvm_para_available()) | ||
| 785 | return 0; | ||
| 786 | if (!kvm_para_has_feature(KVM_FEATURE_PV_UNHALT)) | ||
| 787 | return 0; | ||
| 779 | 788 | ||
| 780 | static_key_slow_inc(¶virt_ticketlocks_enabled); | 789 | static_key_slow_inc(¶virt_ticketlocks_enabled); |
| 790 | printk(KERN_INFO "KVM setup paravirtual spinlock\n"); | ||
| 781 | 791 | ||
| 782 | pv_lock_ops.lock_spinning = PV_CALLEE_SAVE(kvm_lock_spinning); | 792 | return 0; |
| 783 | pv_lock_ops.unlock_kick = kvm_unlock_kick; | ||
| 784 | } | 793 | } |
| 794 | early_initcall(kvm_spinlock_init_jump); | ||
| 795 | |||
| 785 | #endif /* CONFIG_PARAVIRT_SPINLOCKS */ | 796 | #endif /* CONFIG_PARAVIRT_SPINLOCKS */ |
diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c index d1e4777b4e75..31d04758b76f 100644 --- a/arch/x86/xen/smp.c +++ b/arch/x86/xen/smp.c | |||
| @@ -278,6 +278,15 @@ static void __init xen_smp_prepare_boot_cpu(void) | |||
| 278 | old memory can be recycled */ | 278 | old memory can be recycled */ |
| 279 | make_lowmem_page_readwrite(xen_initial_gdt); | 279 | make_lowmem_page_readwrite(xen_initial_gdt); |
| 280 | 280 | ||
| 281 | #ifdef CONFIG_X86_32 | ||
| 282 | /* | ||
| 283 | * Xen starts us with XEN_FLAT_RING1_DS, but linux code | ||
| 284 | * expects __USER_DS | ||
| 285 | */ | ||
| 286 | loadsegment(ds, __USER_DS); | ||
| 287 | loadsegment(es, __USER_DS); | ||
| 288 | #endif | ||
| 289 | |||
| 281 | xen_filter_cpu_maps(); | 290 | xen_filter_cpu_maps(); |
| 282 | xen_setup_vcpu_info_placement(); | 291 | xen_setup_vcpu_info_placement(); |
| 283 | } | 292 | } |
diff --git a/block/partitions/efi.c b/block/partitions/efi.c index 1eb09ee5311b..a8287b49d062 100644 --- a/block/partitions/efi.c +++ b/block/partitions/efi.c | |||
| @@ -222,11 +222,16 @@ check_hybrid: | |||
| 222 | * the disk size. | 222 | * the disk size. |
| 223 | * | 223 | * |
| 224 | * Hybrid MBRs do not necessarily comply with this. | 224 | * Hybrid MBRs do not necessarily comply with this. |
| 225 | * | ||
| 226 | * Consider a bad value here to be a warning to support dd'ing | ||
| 227 | * an image from a smaller disk to a larger disk. | ||
| 225 | */ | 228 | */ |
| 226 | if (ret == GPT_MBR_PROTECTIVE) { | 229 | if (ret == GPT_MBR_PROTECTIVE) { |
| 227 | sz = le32_to_cpu(mbr->partition_record[part].size_in_lba); | 230 | sz = le32_to_cpu(mbr->partition_record[part].size_in_lba); |
| 228 | if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF) | 231 | if (sz != (uint32_t) total_sectors - 1 && sz != 0xFFFFFFFF) |
| 229 | ret = 0; | 232 | pr_debug("GPT: mbr size in lba (%u) different than whole disk (%u).\n", |
| 233 | sz, min_t(uint32_t, | ||
| 234 | total_sectors - 1, 0xFFFFFFFF)); | ||
| 230 | } | 235 | } |
| 231 | done: | 236 | done: |
| 232 | return ret; | 237 | return ret; |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 22327e6a7236..6efe2ac6902f 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
| @@ -24,7 +24,7 @@ menuconfig ACPI | |||
| 24 | are configured, ACPI is used. | 24 | are configured, ACPI is used. |
| 25 | 25 | ||
| 26 | The project home page for the Linux ACPI subsystem is here: | 26 | The project home page for the Linux ACPI subsystem is here: |
| 27 | <http://www.lesswatts.org/projects/acpi/> | 27 | <https://01.org/linux-acpi> |
| 28 | 28 | ||
| 29 | Linux support for ACPI is based on Intel Corporation's ACPI | 29 | Linux support for ACPI is based on Intel Corporation's ACPI |
| 30 | Component Architecture (ACPI CA). For more information on the | 30 | Component Architecture (ACPI CA). For more information on the |
| @@ -123,9 +123,9 @@ config ACPI_BUTTON | |||
| 123 | default y | 123 | default y |
| 124 | help | 124 | help |
| 125 | This driver handles events on the power, sleep, and lid buttons. | 125 | This driver handles events on the power, sleep, and lid buttons. |
| 126 | A daemon reads /proc/acpi/event and perform user-defined actions | 126 | A daemon reads events from input devices or via netlink and |
| 127 | such as shutting down the system. This is necessary for | 127 | performs user-defined actions such as shutting down the system. |
| 128 | software-controlled poweroff. | 128 | This is necessary for software-controlled poweroff. |
| 129 | 129 | ||
| 130 | To compile this driver as a module, choose M here: | 130 | To compile this driver as a module, choose M here: |
| 131 | the module will be called button. | 131 | the module will be called button. |
diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 59d3202f6b36..a94383d1f350 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c | |||
| @@ -1025,60 +1025,4 @@ void acpi_dev_pm_detach(struct device *dev, bool power_off) | |||
| 1025 | } | 1025 | } |
| 1026 | } | 1026 | } |
| 1027 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); | 1027 | EXPORT_SYMBOL_GPL(acpi_dev_pm_detach); |
| 1028 | |||
| 1029 | /** | ||
| 1030 | * acpi_dev_pm_add_dependent - Add physical device depending for PM. | ||
| 1031 | * @handle: Handle of ACPI device node. | ||
| 1032 | * @depdev: Device depending on that node for PM. | ||
| 1033 | */ | ||
| 1034 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev) | ||
| 1035 | { | ||
| 1036 | struct acpi_device_physical_node *dep; | ||
| 1037 | struct acpi_device *adev; | ||
| 1038 | |||
| 1039 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
| 1040 | return; | ||
| 1041 | |||
| 1042 | mutex_lock(&adev->physical_node_lock); | ||
| 1043 | |||
| 1044 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
| 1045 | if (dep->dev == depdev) | ||
| 1046 | goto out; | ||
| 1047 | |||
| 1048 | dep = kzalloc(sizeof(*dep), GFP_KERNEL); | ||
| 1049 | if (dep) { | ||
| 1050 | dep->dev = depdev; | ||
| 1051 | list_add_tail(&dep->node, &adev->power_dependent); | ||
| 1052 | } | ||
| 1053 | |||
| 1054 | out: | ||
| 1055 | mutex_unlock(&adev->physical_node_lock); | ||
| 1056 | } | ||
| 1057 | EXPORT_SYMBOL_GPL(acpi_dev_pm_add_dependent); | ||
| 1058 | |||
| 1059 | /** | ||
| 1060 | * acpi_dev_pm_remove_dependent - Remove physical device depending for PM. | ||
| 1061 | * @handle: Handle of ACPI device node. | ||
| 1062 | * @depdev: Device depending on that node for PM. | ||
| 1063 | */ | ||
| 1064 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev) | ||
| 1065 | { | ||
| 1066 | struct acpi_device_physical_node *dep; | ||
| 1067 | struct acpi_device *adev; | ||
| 1068 | |||
| 1069 | if (!depdev || acpi_bus_get_device(handle, &adev)) | ||
| 1070 | return; | ||
| 1071 | |||
| 1072 | mutex_lock(&adev->physical_node_lock); | ||
| 1073 | |||
| 1074 | list_for_each_entry(dep, &adev->power_dependent, node) | ||
| 1075 | if (dep->dev == depdev) { | ||
| 1076 | list_del(&dep->node); | ||
| 1077 | kfree(dep); | ||
| 1078 | break; | ||
| 1079 | } | ||
| 1080 | |||
| 1081 | mutex_unlock(&adev->physical_node_lock); | ||
| 1082 | } | ||
| 1083 | EXPORT_SYMBOL_GPL(acpi_dev_pm_remove_dependent); | ||
| 1084 | #endif /* CONFIG_PM */ | 1028 | #endif /* CONFIG_PM */ |
diff --git a/drivers/acpi/power.c b/drivers/acpi/power.c index 0dbe5cdf3396..c2ad391d8041 100644 --- a/drivers/acpi/power.c +++ b/drivers/acpi/power.c | |||
| @@ -59,16 +59,9 @@ ACPI_MODULE_NAME("power"); | |||
| 59 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 | 59 | #define ACPI_POWER_RESOURCE_STATE_ON 0x01 |
| 60 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF | 60 | #define ACPI_POWER_RESOURCE_STATE_UNKNOWN 0xFF |
| 61 | 61 | ||
| 62 | struct acpi_power_dependent_device { | ||
| 63 | struct list_head node; | ||
| 64 | struct acpi_device *adev; | ||
| 65 | struct work_struct work; | ||
| 66 | }; | ||
| 67 | |||
| 68 | struct acpi_power_resource { | 62 | struct acpi_power_resource { |
| 69 | struct acpi_device device; | 63 | struct acpi_device device; |
| 70 | struct list_head list_node; | 64 | struct list_head list_node; |
| 71 | struct list_head dependent; | ||
| 72 | char *name; | 65 | char *name; |
| 73 | u32 system_level; | 66 | u32 system_level; |
| 74 | u32 order; | 67 | u32 order; |
| @@ -233,32 +226,6 @@ static int acpi_power_get_list_state(struct list_head *list, int *state) | |||
| 233 | return 0; | 226 | return 0; |
| 234 | } | 227 | } |
| 235 | 228 | ||
| 236 | static void acpi_power_resume_dependent(struct work_struct *work) | ||
| 237 | { | ||
| 238 | struct acpi_power_dependent_device *dep; | ||
| 239 | struct acpi_device_physical_node *pn; | ||
| 240 | struct acpi_device *adev; | ||
| 241 | int state; | ||
| 242 | |||
| 243 | dep = container_of(work, struct acpi_power_dependent_device, work); | ||
| 244 | adev = dep->adev; | ||
| 245 | if (acpi_power_get_inferred_state(adev, &state)) | ||
| 246 | return; | ||
| 247 | |||
| 248 | if (state > ACPI_STATE_D0) | ||
| 249 | return; | ||
| 250 | |||
| 251 | mutex_lock(&adev->physical_node_lock); | ||
| 252 | |||
| 253 | list_for_each_entry(pn, &adev->physical_node_list, node) | ||
| 254 | pm_request_resume(pn->dev); | ||
| 255 | |||
| 256 | list_for_each_entry(pn, &adev->power_dependent, node) | ||
| 257 | pm_request_resume(pn->dev); | ||
| 258 | |||
| 259 | mutex_unlock(&adev->physical_node_lock); | ||
| 260 | } | ||
| 261 | |||
| 262 | static int __acpi_power_on(struct acpi_power_resource *resource) | 229 | static int __acpi_power_on(struct acpi_power_resource *resource) |
| 263 | { | 230 | { |
| 264 | acpi_status status = AE_OK; | 231 | acpi_status status = AE_OK; |
| @@ -283,14 +250,8 @@ static int acpi_power_on_unlocked(struct acpi_power_resource *resource) | |||
| 283 | resource->name)); | 250 | resource->name)); |
| 284 | } else { | 251 | } else { |
| 285 | result = __acpi_power_on(resource); | 252 | result = __acpi_power_on(resource); |
| 286 | if (result) { | 253 | if (result) |
| 287 | resource->ref_count--; | 254 | resource->ref_count--; |
| 288 | } else { | ||
| 289 | struct acpi_power_dependent_device *dep; | ||
| 290 | |||
| 291 | list_for_each_entry(dep, &resource->dependent, node) | ||
| 292 | schedule_work(&dep->work); | ||
| 293 | } | ||
| 294 | } | 255 | } |
| 295 | return result; | 256 | return result; |
| 296 | } | 257 | } |
| @@ -390,52 +351,6 @@ static int acpi_power_on_list(struct list_head *list) | |||
| 390 | return result; | 351 | return result; |
| 391 | } | 352 | } |
| 392 | 353 | ||
| 393 | static void acpi_power_add_dependent(struct acpi_power_resource *resource, | ||
| 394 | struct acpi_device *adev) | ||
| 395 | { | ||
| 396 | struct acpi_power_dependent_device *dep; | ||
| 397 | |||
| 398 | mutex_lock(&resource->resource_lock); | ||
| 399 | |||
| 400 | list_for_each_entry(dep, &resource->dependent, node) | ||
| 401 | if (dep->adev == adev) | ||
| 402 | goto out; | ||
| 403 | |||
| 404 | dep = kzalloc(sizeof(*dep), GFP_KERNEL); | ||
| 405 | if (!dep) | ||
| 406 | goto out; | ||
| 407 | |||
| 408 | dep->adev = adev; | ||
| 409 | INIT_WORK(&dep->work, acpi_power_resume_dependent); | ||
| 410 | list_add_tail(&dep->node, &resource->dependent); | ||
| 411 | |||
| 412 | out: | ||
| 413 | mutex_unlock(&resource->resource_lock); | ||
| 414 | } | ||
| 415 | |||
| 416 | static void acpi_power_remove_dependent(struct acpi_power_resource *resource, | ||
| 417 | struct acpi_device *adev) | ||
| 418 | { | ||
| 419 | struct acpi_power_dependent_device *dep; | ||
| 420 | struct work_struct *work = NULL; | ||
| 421 | |||
| 422 | mutex_lock(&resource->resource_lock); | ||
| 423 | |||
| 424 | list_for_each_entry(dep, &resource->dependent, node) | ||
| 425 | if (dep->adev == adev) { | ||
| 426 | list_del(&dep->node); | ||
| 427 | work = &dep->work; | ||
| 428 | break; | ||
| 429 | } | ||
| 430 | |||
| 431 | mutex_unlock(&resource->resource_lock); | ||
| 432 | |||
| 433 | if (work) { | ||
| 434 | cancel_work_sync(work); | ||
| 435 | kfree(dep); | ||
| 436 | } | ||
| 437 | } | ||
| 438 | |||
| 439 | static struct attribute *attrs[] = { | 354 | static struct attribute *attrs[] = { |
| 440 | NULL, | 355 | NULL, |
| 441 | }; | 356 | }; |
| @@ -524,8 +439,6 @@ static void acpi_power_expose_hide(struct acpi_device *adev, | |||
| 524 | 439 | ||
| 525 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | 440 | void acpi_power_add_remove_device(struct acpi_device *adev, bool add) |
| 526 | { | 441 | { |
| 527 | struct acpi_device_power_state *ps; | ||
| 528 | struct acpi_power_resource_entry *entry; | ||
| 529 | int state; | 442 | int state; |
| 530 | 443 | ||
| 531 | if (adev->wakeup.flags.valid) | 444 | if (adev->wakeup.flags.valid) |
| @@ -535,16 +448,6 @@ void acpi_power_add_remove_device(struct acpi_device *adev, bool add) | |||
| 535 | if (!adev->power.flags.power_resources) | 448 | if (!adev->power.flags.power_resources) |
| 536 | return; | 449 | return; |
| 537 | 450 | ||
| 538 | ps = &adev->power.states[ACPI_STATE_D0]; | ||
| 539 | list_for_each_entry(entry, &ps->resources, node) { | ||
| 540 | struct acpi_power_resource *resource = entry->resource; | ||
| 541 | |||
| 542 | if (add) | ||
| 543 | acpi_power_add_dependent(resource, adev); | ||
| 544 | else | ||
| 545 | acpi_power_remove_dependent(resource, adev); | ||
| 546 | } | ||
| 547 | |||
| 548 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) | 451 | for (state = ACPI_STATE_D0; state <= ACPI_STATE_D3_HOT; state++) |
| 549 | acpi_power_expose_hide(adev, | 452 | acpi_power_expose_hide(adev, |
| 550 | &adev->power.states[state].resources, | 453 | &adev->power.states[state].resources, |
| @@ -882,7 +785,6 @@ int acpi_add_power_resource(acpi_handle handle) | |||
| 882 | acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, | 785 | acpi_init_device_object(device, handle, ACPI_BUS_TYPE_POWER, |
| 883 | ACPI_STA_DEFAULT); | 786 | ACPI_STA_DEFAULT); |
| 884 | mutex_init(&resource->resource_lock); | 787 | mutex_init(&resource->resource_lock); |
| 885 | INIT_LIST_HEAD(&resource->dependent); | ||
| 886 | INIT_LIST_HEAD(&resource->list_node); | 788 | INIT_LIST_HEAD(&resource->list_node); |
| 887 | resource->name = device->pnp.bus_id; | 789 | resource->name = device->pnp.bus_id; |
| 888 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); | 790 | strcpy(acpi_device_name(device), ACPI_POWER_DEVICE_NAME); |
| @@ -936,8 +838,10 @@ void acpi_resume_power_resources(void) | |||
| 936 | mutex_lock(&resource->resource_lock); | 838 | mutex_lock(&resource->resource_lock); |
| 937 | 839 | ||
| 938 | result = acpi_power_get_state(resource->device.handle, &state); | 840 | result = acpi_power_get_state(resource->device.handle, &state); |
| 939 | if (result) | 841 | if (result) { |
| 842 | mutex_unlock(&resource->resource_lock); | ||
| 940 | continue; | 843 | continue; |
| 844 | } | ||
| 941 | 845 | ||
| 942 | if (state == ACPI_POWER_RESOURCE_STATE_OFF | 846 | if (state == ACPI_POWER_RESOURCE_STATE_OFF |
| 943 | && resource->ref_count) { | 847 | && resource->ref_count) { |
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 407ad13cac2f..fee8a297c7d9 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c | |||
| @@ -999,7 +999,6 @@ int acpi_device_add(struct acpi_device *device, | |||
| 999 | INIT_LIST_HEAD(&device->wakeup_list); | 999 | INIT_LIST_HEAD(&device->wakeup_list); |
| 1000 | INIT_LIST_HEAD(&device->physical_node_list); | 1000 | INIT_LIST_HEAD(&device->physical_node_list); |
| 1001 | mutex_init(&device->physical_node_lock); | 1001 | mutex_init(&device->physical_node_lock); |
| 1002 | INIT_LIST_HEAD(&device->power_dependent); | ||
| 1003 | 1002 | ||
| 1004 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); | 1003 | new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); |
| 1005 | if (!new_bus_id) { | 1004 | if (!new_bus_id) { |
diff --git a/drivers/ata/libata-acpi.c b/drivers/ata/libata-acpi.c index 4ba8b0405572..ab714d2ad978 100644 --- a/drivers/ata/libata-acpi.c +++ b/drivers/ata/libata-acpi.c | |||
| @@ -1035,17 +1035,3 @@ void ata_acpi_on_disable(struct ata_device *dev) | |||
| 1035 | { | 1035 | { |
| 1036 | ata_acpi_clear_gtf(dev); | 1036 | ata_acpi_clear_gtf(dev); |
| 1037 | } | 1037 | } |
| 1038 | |||
| 1039 | void ata_scsi_acpi_bind(struct ata_device *dev) | ||
| 1040 | { | ||
| 1041 | acpi_handle handle = ata_dev_acpi_handle(dev); | ||
| 1042 | if (handle) | ||
| 1043 | acpi_dev_pm_add_dependent(handle, &dev->sdev->sdev_gendev); | ||
| 1044 | } | ||
| 1045 | |||
| 1046 | void ata_scsi_acpi_unbind(struct ata_device *dev) | ||
| 1047 | { | ||
| 1048 | acpi_handle handle = ata_dev_acpi_handle(dev); | ||
| 1049 | if (handle) | ||
| 1050 | acpi_dev_pm_remove_dependent(handle, &dev->sdev->sdev_gendev); | ||
| 1051 | } | ||
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 97a0cef12959..db6dfcfa3e2e 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c | |||
| @@ -3679,7 +3679,6 @@ void ata_scsi_scan_host(struct ata_port *ap, int sync) | |||
| 3679 | if (!IS_ERR(sdev)) { | 3679 | if (!IS_ERR(sdev)) { |
| 3680 | dev->sdev = sdev; | 3680 | dev->sdev = sdev; |
| 3681 | scsi_device_put(sdev); | 3681 | scsi_device_put(sdev); |
| 3682 | ata_scsi_acpi_bind(dev); | ||
| 3683 | } else { | 3682 | } else { |
| 3684 | dev->sdev = NULL; | 3683 | dev->sdev = NULL; |
| 3685 | } | 3684 | } |
| @@ -3767,8 +3766,6 @@ static void ata_scsi_remove_dev(struct ata_device *dev) | |||
| 3767 | struct scsi_device *sdev; | 3766 | struct scsi_device *sdev; |
| 3768 | unsigned long flags; | 3767 | unsigned long flags; |
| 3769 | 3768 | ||
| 3770 | ata_scsi_acpi_unbind(dev); | ||
| 3771 | |||
| 3772 | /* Alas, we need to grab scan_mutex to ensure SCSI device | 3769 | /* Alas, we need to grab scan_mutex to ensure SCSI device |
| 3773 | * state doesn't change underneath us and thus | 3770 | * state doesn't change underneath us and thus |
| 3774 | * scsi_device_get() always succeeds. The mutex locking can | 3771 | * scsi_device_get() always succeeds. The mutex locking can |
diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index eeeb77845d48..45b5ab3a95d5 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h | |||
| @@ -121,8 +121,6 @@ extern void ata_acpi_set_state(struct ata_port *ap, pm_message_t state); | |||
| 121 | extern void ata_acpi_bind_port(struct ata_port *ap); | 121 | extern void ata_acpi_bind_port(struct ata_port *ap); |
| 122 | extern void ata_acpi_bind_dev(struct ata_device *dev); | 122 | extern void ata_acpi_bind_dev(struct ata_device *dev); |
| 123 | extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev); | 123 | extern acpi_handle ata_dev_acpi_handle(struct ata_device *dev); |
| 124 | extern void ata_scsi_acpi_bind(struct ata_device *dev); | ||
| 125 | extern void ata_scsi_acpi_unbind(struct ata_device *dev); | ||
| 126 | #else | 124 | #else |
| 127 | static inline void ata_acpi_dissociate(struct ata_host *host) { } | 125 | static inline void ata_acpi_dissociate(struct ata_host *host) { } |
| 128 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } | 126 | static inline int ata_acpi_on_suspend(struct ata_port *ap) { return 0; } |
| @@ -133,8 +131,6 @@ static inline void ata_acpi_set_state(struct ata_port *ap, | |||
| 133 | pm_message_t state) { } | 131 | pm_message_t state) { } |
| 134 | static inline void ata_acpi_bind_port(struct ata_port *ap) {} | 132 | static inline void ata_acpi_bind_port(struct ata_port *ap) {} |
| 135 | static inline void ata_acpi_bind_dev(struct ata_device *dev) {} | 133 | static inline void ata_acpi_bind_dev(struct ata_device *dev) {} |
| 136 | static inline void ata_scsi_acpi_bind(struct ata_device *dev) {} | ||
| 137 | static inline void ata_scsi_acpi_unbind(struct ata_device *dev) {} | ||
| 138 | #endif | 134 | #endif |
| 139 | 135 | ||
| 140 | /* libata-scsi.c */ | 136 | /* libata-scsi.c */ |
diff --git a/drivers/base/memory.c b/drivers/base/memory.c index 9e59f6535c44..bece691cb5d9 100644 --- a/drivers/base/memory.c +++ b/drivers/base/memory.c | |||
| @@ -333,8 +333,10 @@ store_mem_state(struct device *dev, | |||
| 333 | online_type = ONLINE_KEEP; | 333 | online_type = ONLINE_KEEP; |
| 334 | else if (!strncmp(buf, "offline", min_t(int, count, 7))) | 334 | else if (!strncmp(buf, "offline", min_t(int, count, 7))) |
| 335 | online_type = -1; | 335 | online_type = -1; |
| 336 | else | 336 | else { |
| 337 | return -EINVAL; | 337 | ret = -EINVAL; |
| 338 | goto err; | ||
| 339 | } | ||
| 338 | 340 | ||
| 339 | switch (online_type) { | 341 | switch (online_type) { |
| 340 | case ONLINE_KERNEL: | 342 | case ONLINE_KERNEL: |
| @@ -357,6 +359,7 @@ store_mem_state(struct device *dev, | |||
| 357 | ret = -EINVAL; /* should never happen */ | 359 | ret = -EINVAL; /* should never happen */ |
| 358 | } | 360 | } |
| 359 | 361 | ||
| 362 | err: | ||
| 360 | unlock_device_hotplug(); | 363 | unlock_device_hotplug(); |
| 361 | 364 | ||
| 362 | if (ret) | 365 | if (ret) |
diff --git a/drivers/base/regmap/internal.h b/drivers/base/regmap/internal.h index 57f777835d97..33414b1de201 100644 --- a/drivers/base/regmap/internal.h +++ b/drivers/base/regmap/internal.h | |||
| @@ -44,7 +44,6 @@ struct regmap_format { | |||
| 44 | 44 | ||
| 45 | struct regmap_async { | 45 | struct regmap_async { |
| 46 | struct list_head list; | 46 | struct list_head list; |
| 47 | struct work_struct cleanup; | ||
| 48 | struct regmap *map; | 47 | struct regmap *map; |
| 49 | void *work_buf; | 48 | void *work_buf; |
| 50 | }; | 49 | }; |
| @@ -64,9 +63,11 @@ struct regmap { | |||
| 64 | void *bus_context; | 63 | void *bus_context; |
| 65 | const char *name; | 64 | const char *name; |
| 66 | 65 | ||
| 66 | bool async; | ||
| 67 | spinlock_t async_lock; | 67 | spinlock_t async_lock; |
| 68 | wait_queue_head_t async_waitq; | 68 | wait_queue_head_t async_waitq; |
| 69 | struct list_head async_list; | 69 | struct list_head async_list; |
| 70 | struct list_head async_free; | ||
| 70 | int async_ret; | 71 | int async_ret; |
| 71 | 72 | ||
| 72 | #ifdef CONFIG_DEBUG_FS | 73 | #ifdef CONFIG_DEBUG_FS |
| @@ -179,6 +180,9 @@ struct regmap_field { | |||
| 179 | /* lsb */ | 180 | /* lsb */ |
| 180 | unsigned int shift; | 181 | unsigned int shift; |
| 181 | unsigned int reg; | 182 | unsigned int reg; |
| 183 | |||
| 184 | unsigned int id_size; | ||
| 185 | unsigned int id_offset; | ||
| 182 | }; | 186 | }; |
| 183 | 187 | ||
| 184 | #ifdef CONFIG_DEBUG_FS | 188 | #ifdef CONFIG_DEBUG_FS |
| @@ -218,7 +222,7 @@ bool regcache_set_val(struct regmap *map, void *base, unsigned int idx, | |||
| 218 | int regcache_lookup_reg(struct regmap *map, unsigned int reg); | 222 | int regcache_lookup_reg(struct regmap *map, unsigned int reg); |
| 219 | 223 | ||
| 220 | int _regmap_raw_write(struct regmap *map, unsigned int reg, | 224 | int _regmap_raw_write(struct regmap *map, unsigned int reg, |
| 221 | const void *val, size_t val_len, bool async); | 225 | const void *val, size_t val_len); |
| 222 | 226 | ||
| 223 | void regmap_async_complete_cb(struct regmap_async *async, int ret); | 227 | void regmap_async_complete_cb(struct regmap_async *async, int ret); |
| 224 | 228 | ||
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index d6c2d691b6e8..a36112af494c 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c | |||
| @@ -631,8 +631,7 @@ static int regcache_sync_block_raw_flush(struct regmap *map, const void **data, | |||
| 631 | 631 | ||
| 632 | map->cache_bypass = 1; | 632 | map->cache_bypass = 1; |
| 633 | 633 | ||
| 634 | ret = _regmap_raw_write(map, base, *data, count * val_bytes, | 634 | ret = _regmap_raw_write(map, base, *data, count * val_bytes); |
| 635 | false); | ||
| 636 | 635 | ||
| 637 | map->cache_bypass = 0; | 636 | map->cache_bypass = 0; |
| 638 | 637 | ||
diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index 7d689a15c500..ccdac61ac5e2 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c | |||
| @@ -42,15 +42,6 @@ static int _regmap_bus_formatted_write(void *context, unsigned int reg, | |||
| 42 | static int _regmap_bus_raw_write(void *context, unsigned int reg, | 42 | static int _regmap_bus_raw_write(void *context, unsigned int reg, |
| 43 | unsigned int val); | 43 | unsigned int val); |
| 44 | 44 | ||
| 45 | static void async_cleanup(struct work_struct *work) | ||
| 46 | { | ||
| 47 | struct regmap_async *async = container_of(work, struct regmap_async, | ||
| 48 | cleanup); | ||
| 49 | |||
| 50 | kfree(async->work_buf); | ||
| 51 | kfree(async); | ||
| 52 | } | ||
| 53 | |||
| 54 | bool regmap_reg_in_ranges(unsigned int reg, | 45 | bool regmap_reg_in_ranges(unsigned int reg, |
| 55 | const struct regmap_range *ranges, | 46 | const struct regmap_range *ranges, |
| 56 | unsigned int nranges) | 47 | unsigned int nranges) |
| @@ -465,6 +456,7 @@ struct regmap *regmap_init(struct device *dev, | |||
| 465 | 456 | ||
| 466 | spin_lock_init(&map->async_lock); | 457 | spin_lock_init(&map->async_lock); |
| 467 | INIT_LIST_HEAD(&map->async_list); | 458 | INIT_LIST_HEAD(&map->async_list); |
| 459 | INIT_LIST_HEAD(&map->async_free); | ||
| 468 | init_waitqueue_head(&map->async_waitq); | 460 | init_waitqueue_head(&map->async_waitq); |
| 469 | 461 | ||
| 470 | if (config->read_flag_mask || config->write_flag_mask) { | 462 | if (config->read_flag_mask || config->write_flag_mask) { |
| @@ -821,6 +813,8 @@ static void regmap_field_init(struct regmap_field *rm_field, | |||
| 821 | rm_field->reg = reg_field.reg; | 813 | rm_field->reg = reg_field.reg; |
| 822 | rm_field->shift = reg_field.lsb; | 814 | rm_field->shift = reg_field.lsb; |
| 823 | rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb); | 815 | rm_field->mask = ((BIT(field_bits) - 1) << reg_field.lsb); |
| 816 | rm_field->id_size = reg_field.id_size; | ||
| 817 | rm_field->id_offset = reg_field.id_offset; | ||
| 824 | } | 818 | } |
| 825 | 819 | ||
| 826 | /** | 820 | /** |
| @@ -942,12 +936,22 @@ EXPORT_SYMBOL_GPL(regmap_reinit_cache); | |||
| 942 | */ | 936 | */ |
| 943 | void regmap_exit(struct regmap *map) | 937 | void regmap_exit(struct regmap *map) |
| 944 | { | 938 | { |
| 939 | struct regmap_async *async; | ||
| 940 | |||
| 945 | regcache_exit(map); | 941 | regcache_exit(map); |
| 946 | regmap_debugfs_exit(map); | 942 | regmap_debugfs_exit(map); |
| 947 | regmap_range_exit(map); | 943 | regmap_range_exit(map); |
| 948 | if (map->bus && map->bus->free_context) | 944 | if (map->bus && map->bus->free_context) |
| 949 | map->bus->free_context(map->bus_context); | 945 | map->bus->free_context(map->bus_context); |
| 950 | kfree(map->work_buf); | 946 | kfree(map->work_buf); |
| 947 | while (!list_empty(&map->async_free)) { | ||
| 948 | async = list_first_entry_or_null(&map->async_free, | ||
| 949 | struct regmap_async, | ||
| 950 | list); | ||
| 951 | list_del(&async->list); | ||
| 952 | kfree(async->work_buf); | ||
| 953 | kfree(async); | ||
| 954 | } | ||
| 951 | kfree(map); | 955 | kfree(map); |
| 952 | } | 956 | } |
| 953 | EXPORT_SYMBOL_GPL(regmap_exit); | 957 | EXPORT_SYMBOL_GPL(regmap_exit); |
| @@ -1039,7 +1043,7 @@ static int _regmap_select_page(struct regmap *map, unsigned int *reg, | |||
| 1039 | } | 1043 | } |
| 1040 | 1044 | ||
| 1041 | int _regmap_raw_write(struct regmap *map, unsigned int reg, | 1045 | int _regmap_raw_write(struct regmap *map, unsigned int reg, |
| 1042 | const void *val, size_t val_len, bool async) | 1046 | const void *val, size_t val_len) |
| 1043 | { | 1047 | { |
| 1044 | struct regmap_range_node *range; | 1048 | struct regmap_range_node *range; |
| 1045 | unsigned long flags; | 1049 | unsigned long flags; |
| @@ -1091,7 +1095,7 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1091 | dev_dbg(map->dev, "Writing window %d/%zu\n", | 1095 | dev_dbg(map->dev, "Writing window %d/%zu\n", |
| 1092 | win_residue, val_len / map->format.val_bytes); | 1096 | win_residue, val_len / map->format.val_bytes); |
| 1093 | ret = _regmap_raw_write(map, reg, val, win_residue * | 1097 | ret = _regmap_raw_write(map, reg, val, win_residue * |
| 1094 | map->format.val_bytes, async); | 1098 | map->format.val_bytes); |
| 1095 | if (ret != 0) | 1099 | if (ret != 0) |
| 1096 | return ret; | 1100 | return ret; |
| 1097 | 1101 | ||
| @@ -1114,21 +1118,42 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1114 | 1118 | ||
| 1115 | u8[0] |= map->write_flag_mask; | 1119 | u8[0] |= map->write_flag_mask; |
| 1116 | 1120 | ||
| 1117 | if (async && map->bus->async_write) { | 1121 | /* |
| 1118 | struct regmap_async *async = map->bus->async_alloc(); | 1122 | * Essentially all I/O mechanisms will be faster with a single |
| 1119 | if (!async) | 1123 | * buffer to write. Since register syncs often generate raw |
| 1120 | return -ENOMEM; | 1124 | * writes of single registers optimise that case. |
| 1125 | */ | ||
| 1126 | if (val != work_val && val_len == map->format.val_bytes) { | ||
| 1127 | memcpy(work_val, val, map->format.val_bytes); | ||
| 1128 | val = work_val; | ||
| 1129 | } | ||
| 1130 | |||
| 1131 | if (map->async && map->bus->async_write) { | ||
| 1132 | struct regmap_async *async; | ||
| 1121 | 1133 | ||
| 1122 | trace_regmap_async_write_start(map->dev, reg, val_len); | 1134 | trace_regmap_async_write_start(map->dev, reg, val_len); |
| 1123 | 1135 | ||
| 1124 | async->work_buf = kzalloc(map->format.buf_size, | 1136 | spin_lock_irqsave(&map->async_lock, flags); |
| 1125 | GFP_KERNEL | GFP_DMA); | 1137 | async = list_first_entry_or_null(&map->async_free, |
| 1126 | if (!async->work_buf) { | 1138 | struct regmap_async, |
| 1127 | kfree(async); | 1139 | list); |
| 1128 | return -ENOMEM; | 1140 | if (async) |
| 1141 | list_del(&async->list); | ||
| 1142 | spin_unlock_irqrestore(&map->async_lock, flags); | ||
| 1143 | |||
| 1144 | if (!async) { | ||
| 1145 | async = map->bus->async_alloc(); | ||
| 1146 | if (!async) | ||
| 1147 | return -ENOMEM; | ||
| 1148 | |||
| 1149 | async->work_buf = kzalloc(map->format.buf_size, | ||
| 1150 | GFP_KERNEL | GFP_DMA); | ||
| 1151 | if (!async->work_buf) { | ||
| 1152 | kfree(async); | ||
| 1153 | return -ENOMEM; | ||
| 1154 | } | ||
| 1129 | } | 1155 | } |
| 1130 | 1156 | ||
| 1131 | INIT_WORK(&async->cleanup, async_cleanup); | ||
| 1132 | async->map = map; | 1157 | async->map = map; |
| 1133 | 1158 | ||
| 1134 | /* If the caller supplied the value we can use it safely. */ | 1159 | /* If the caller supplied the value we can use it safely. */ |
| @@ -1152,11 +1177,8 @@ int _regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1152 | ret); | 1177 | ret); |
| 1153 | 1178 | ||
| 1154 | spin_lock_irqsave(&map->async_lock, flags); | 1179 | spin_lock_irqsave(&map->async_lock, flags); |
| 1155 | list_del(&async->list); | 1180 | list_move(&async->list, &map->async_free); |
| 1156 | spin_unlock_irqrestore(&map->async_lock, flags); | 1181 | spin_unlock_irqrestore(&map->async_lock, flags); |
| 1157 | |||
| 1158 | kfree(async->work_buf); | ||
| 1159 | kfree(async); | ||
| 1160 | } | 1182 | } |
| 1161 | 1183 | ||
| 1162 | return ret; | 1184 | return ret; |
| @@ -1253,7 +1275,7 @@ static int _regmap_bus_raw_write(void *context, unsigned int reg, | |||
| 1253 | map->work_buf + | 1275 | map->work_buf + |
| 1254 | map->format.reg_bytes + | 1276 | map->format.reg_bytes + |
| 1255 | map->format.pad_bytes, | 1277 | map->format.pad_bytes, |
| 1256 | map->format.val_bytes, false); | 1278 | map->format.val_bytes); |
| 1257 | } | 1279 | } |
| 1258 | 1280 | ||
| 1259 | static inline void *_regmap_map_get_context(struct regmap *map) | 1281 | static inline void *_regmap_map_get_context(struct regmap *map) |
| @@ -1318,6 +1340,37 @@ int regmap_write(struct regmap *map, unsigned int reg, unsigned int val) | |||
| 1318 | EXPORT_SYMBOL_GPL(regmap_write); | 1340 | EXPORT_SYMBOL_GPL(regmap_write); |
| 1319 | 1341 | ||
| 1320 | /** | 1342 | /** |
| 1343 | * regmap_write_async(): Write a value to a single register asynchronously | ||
| 1344 | * | ||
| 1345 | * @map: Register map to write to | ||
| 1346 | * @reg: Register to write to | ||
| 1347 | * @val: Value to be written | ||
| 1348 | * | ||
| 1349 | * A value of zero will be returned on success, a negative errno will | ||
| 1350 | * be returned in error cases. | ||
| 1351 | */ | ||
| 1352 | int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val) | ||
| 1353 | { | ||
| 1354 | int ret; | ||
| 1355 | |||
| 1356 | if (reg % map->reg_stride) | ||
| 1357 | return -EINVAL; | ||
| 1358 | |||
| 1359 | map->lock(map->lock_arg); | ||
| 1360 | |||
| 1361 | map->async = true; | ||
| 1362 | |||
| 1363 | ret = _regmap_write(map, reg, val); | ||
| 1364 | |||
| 1365 | map->async = false; | ||
| 1366 | |||
| 1367 | map->unlock(map->lock_arg); | ||
| 1368 | |||
| 1369 | return ret; | ||
| 1370 | } | ||
| 1371 | EXPORT_SYMBOL_GPL(regmap_write_async); | ||
| 1372 | |||
| 1373 | /** | ||
| 1321 | * regmap_raw_write(): Write raw values to one or more registers | 1374 | * regmap_raw_write(): Write raw values to one or more registers |
| 1322 | * | 1375 | * |
| 1323 | * @map: Register map to write to | 1376 | * @map: Register map to write to |
| @@ -1345,7 +1398,7 @@ int regmap_raw_write(struct regmap *map, unsigned int reg, | |||
| 1345 | 1398 | ||
| 1346 | map->lock(map->lock_arg); | 1399 | map->lock(map->lock_arg); |
| 1347 | 1400 | ||
| 1348 | ret = _regmap_raw_write(map, reg, val, val_len, false); | 1401 | ret = _regmap_raw_write(map, reg, val, val_len); |
| 1349 | 1402 | ||
| 1350 | map->unlock(map->lock_arg); | 1403 | map->unlock(map->lock_arg); |
| 1351 | 1404 | ||
| @@ -1369,6 +1422,74 @@ int regmap_field_write(struct regmap_field *field, unsigned int val) | |||
| 1369 | } | 1422 | } |
| 1370 | EXPORT_SYMBOL_GPL(regmap_field_write); | 1423 | EXPORT_SYMBOL_GPL(regmap_field_write); |
| 1371 | 1424 | ||
| 1425 | /** | ||
| 1426 | * regmap_field_update_bits(): Perform a read/modify/write cycle | ||
| 1427 | * on the register field | ||
| 1428 | * | ||
| 1429 | * @field: Register field to write to | ||
| 1430 | * @mask: Bitmask to change | ||
| 1431 | * @val: Value to be written | ||
| 1432 | * | ||
| 1433 | * A value of zero will be returned on success, a negative errno will | ||
| 1434 | * be returned in error cases. | ||
| 1435 | */ | ||
| 1436 | int regmap_field_update_bits(struct regmap_field *field, unsigned int mask, unsigned int val) | ||
| 1437 | { | ||
| 1438 | mask = (mask << field->shift) & field->mask; | ||
| 1439 | |||
| 1440 | return regmap_update_bits(field->regmap, field->reg, | ||
| 1441 | mask, val << field->shift); | ||
| 1442 | } | ||
| 1443 | EXPORT_SYMBOL_GPL(regmap_field_update_bits); | ||
| 1444 | |||
| 1445 | /** | ||
| 1446 | * regmap_fields_write(): Write a value to a single register field with port ID | ||
| 1447 | * | ||
| 1448 | * @field: Register field to write to | ||
| 1449 | * @id: port ID | ||
| 1450 | * @val: Value to be written | ||
| 1451 | * | ||
| 1452 | * A value of zero will be returned on success, a negative errno will | ||
| 1453 | * be returned in error cases. | ||
| 1454 | */ | ||
| 1455 | int regmap_fields_write(struct regmap_field *field, unsigned int id, | ||
| 1456 | unsigned int val) | ||
| 1457 | { | ||
| 1458 | if (id >= field->id_size) | ||
| 1459 | return -EINVAL; | ||
| 1460 | |||
| 1461 | return regmap_update_bits(field->regmap, | ||
| 1462 | field->reg + (field->id_offset * id), | ||
| 1463 | field->mask, val << field->shift); | ||
| 1464 | } | ||
| 1465 | EXPORT_SYMBOL_GPL(regmap_fields_write); | ||
| 1466 | |||
| 1467 | /** | ||
| 1468 | * regmap_fields_update_bits(): Perform a read/modify/write cycle | ||
| 1469 | * on the register field | ||
| 1470 | * | ||
| 1471 | * @field: Register field to write to | ||
| 1472 | * @id: port ID | ||
| 1473 | * @mask: Bitmask to change | ||
| 1474 | * @val: Value to be written | ||
| 1475 | * | ||
| 1476 | * A value of zero will be returned on success, a negative errno will | ||
| 1477 | * be returned in error cases. | ||
| 1478 | */ | ||
| 1479 | int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, | ||
| 1480 | unsigned int mask, unsigned int val) | ||
| 1481 | { | ||
| 1482 | if (id >= field->id_size) | ||
| 1483 | return -EINVAL; | ||
| 1484 | |||
| 1485 | mask = (mask << field->shift) & field->mask; | ||
| 1486 | |||
| 1487 | return regmap_update_bits(field->regmap, | ||
| 1488 | field->reg + (field->id_offset * id), | ||
| 1489 | mask, val << field->shift); | ||
| 1490 | } | ||
| 1491 | EXPORT_SYMBOL_GPL(regmap_fields_update_bits); | ||
| 1492 | |||
| 1372 | /* | 1493 | /* |
| 1373 | * regmap_bulk_write(): Write multiple registers to the device | 1494 | * regmap_bulk_write(): Write multiple registers to the device |
| 1374 | * | 1495 | * |
| @@ -1426,8 +1547,7 @@ int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, | |||
| 1426 | return ret; | 1547 | return ret; |
| 1427 | } | 1548 | } |
| 1428 | } else { | 1549 | } else { |
| 1429 | ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count, | 1550 | ret = _regmap_raw_write(map, reg, wval, val_bytes * val_count); |
| 1430 | false); | ||
| 1431 | } | 1551 | } |
| 1432 | 1552 | ||
| 1433 | if (val_bytes != 1) | 1553 | if (val_bytes != 1) |
| @@ -1473,7 +1593,11 @@ int regmap_raw_write_async(struct regmap *map, unsigned int reg, | |||
| 1473 | 1593 | ||
| 1474 | map->lock(map->lock_arg); | 1594 | map->lock(map->lock_arg); |
| 1475 | 1595 | ||
| 1476 | ret = _regmap_raw_write(map, reg, val, val_len, true); | 1596 | map->async = true; |
| 1597 | |||
| 1598 | ret = _regmap_raw_write(map, reg, val, val_len); | ||
| 1599 | |||
| 1600 | map->async = false; | ||
| 1477 | 1601 | ||
| 1478 | map->unlock(map->lock_arg); | 1602 | map->unlock(map->lock_arg); |
| 1479 | 1603 | ||
| @@ -1677,6 +1801,39 @@ int regmap_field_read(struct regmap_field *field, unsigned int *val) | |||
| 1677 | EXPORT_SYMBOL_GPL(regmap_field_read); | 1801 | EXPORT_SYMBOL_GPL(regmap_field_read); |
| 1678 | 1802 | ||
| 1679 | /** | 1803 | /** |
| 1804 | * regmap_fields_read(): Read a value to a single register field with port ID | ||
| 1805 | * | ||
| 1806 | * @field: Register field to read from | ||
| 1807 | * @id: port ID | ||
| 1808 | * @val: Pointer to store read value | ||
| 1809 | * | ||
| 1810 | * A value of zero will be returned on success, a negative errno will | ||
| 1811 | * be returned in error cases. | ||
| 1812 | */ | ||
| 1813 | int regmap_fields_read(struct regmap_field *field, unsigned int id, | ||
| 1814 | unsigned int *val) | ||
| 1815 | { | ||
| 1816 | int ret; | ||
| 1817 | unsigned int reg_val; | ||
| 1818 | |||
| 1819 | if (id >= field->id_size) | ||
| 1820 | return -EINVAL; | ||
| 1821 | |||
| 1822 | ret = regmap_read(field->regmap, | ||
| 1823 | field->reg + (field->id_offset * id), | ||
| 1824 | ®_val); | ||
| 1825 | if (ret != 0) | ||
| 1826 | return ret; | ||
| 1827 | |||
| 1828 | reg_val &= field->mask; | ||
| 1829 | reg_val >>= field->shift; | ||
| 1830 | *val = reg_val; | ||
| 1831 | |||
| 1832 | return ret; | ||
| 1833 | } | ||
| 1834 | EXPORT_SYMBOL_GPL(regmap_fields_read); | ||
| 1835 | |||
| 1836 | /** | ||
| 1680 | * regmap_bulk_read(): Read multiple registers from the device | 1837 | * regmap_bulk_read(): Read multiple registers from the device |
| 1681 | * | 1838 | * |
| 1682 | * @map: Register map to write to | 1839 | * @map: Register map to write to |
| @@ -1788,6 +1945,41 @@ int regmap_update_bits(struct regmap *map, unsigned int reg, | |||
| 1788 | EXPORT_SYMBOL_GPL(regmap_update_bits); | 1945 | EXPORT_SYMBOL_GPL(regmap_update_bits); |
| 1789 | 1946 | ||
| 1790 | /** | 1947 | /** |
| 1948 | * regmap_update_bits_async: Perform a read/modify/write cycle on the register | ||
| 1949 | * map asynchronously | ||
| 1950 | * | ||
| 1951 | * @map: Register map to update | ||
| 1952 | * @reg: Register to update | ||
| 1953 | * @mask: Bitmask to change | ||
| 1954 | * @val: New value for bitmask | ||
| 1955 | * | ||
| 1956 | * With most buses the read must be done synchronously so this is most | ||
| 1957 | * useful for devices with a cache which do not need to interact with | ||
| 1958 | * the hardware to determine the current register value. | ||
| 1959 | * | ||
| 1960 | * Returns zero for success, a negative number on error. | ||
| 1961 | */ | ||
| 1962 | int regmap_update_bits_async(struct regmap *map, unsigned int reg, | ||
| 1963 | unsigned int mask, unsigned int val) | ||
| 1964 | { | ||
| 1965 | bool change; | ||
| 1966 | int ret; | ||
| 1967 | |||
| 1968 | map->lock(map->lock_arg); | ||
| 1969 | |||
| 1970 | map->async = true; | ||
| 1971 | |||
| 1972 | ret = _regmap_update_bits(map, reg, mask, val, &change); | ||
| 1973 | |||
| 1974 | map->async = false; | ||
| 1975 | |||
| 1976 | map->unlock(map->lock_arg); | ||
| 1977 | |||
| 1978 | return ret; | ||
| 1979 | } | ||
| 1980 | EXPORT_SYMBOL_GPL(regmap_update_bits_async); | ||
| 1981 | |||
| 1982 | /** | ||
| 1791 | * regmap_update_bits_check: Perform a read/modify/write cycle on the | 1983 | * regmap_update_bits_check: Perform a read/modify/write cycle on the |
| 1792 | * register map and report if updated | 1984 | * register map and report if updated |
| 1793 | * | 1985 | * |
| @@ -1812,6 +2004,43 @@ int regmap_update_bits_check(struct regmap *map, unsigned int reg, | |||
| 1812 | } | 2004 | } |
| 1813 | EXPORT_SYMBOL_GPL(regmap_update_bits_check); | 2005 | EXPORT_SYMBOL_GPL(regmap_update_bits_check); |
| 1814 | 2006 | ||
| 2007 | /** | ||
| 2008 | * regmap_update_bits_check_async: Perform a read/modify/write cycle on the | ||
| 2009 | * register map asynchronously and report if | ||
| 2010 | * updated | ||
| 2011 | * | ||
| 2012 | * @map: Register map to update | ||
| 2013 | * @reg: Register to update | ||
| 2014 | * @mask: Bitmask to change | ||
| 2015 | * @val: New value for bitmask | ||
| 2016 | * @change: Boolean indicating if a write was done | ||
| 2017 | * | ||
| 2018 | * With most buses the read must be done synchronously so this is most | ||
| 2019 | * useful for devices with a cache which do not need to interact with | ||
| 2020 | * the hardware to determine the current register value. | ||
| 2021 | * | ||
| 2022 | * Returns zero for success, a negative number on error. | ||
| 2023 | */ | ||
| 2024 | int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, | ||
| 2025 | unsigned int mask, unsigned int val, | ||
| 2026 | bool *change) | ||
| 2027 | { | ||
| 2028 | int ret; | ||
| 2029 | |||
| 2030 | map->lock(map->lock_arg); | ||
| 2031 | |||
| 2032 | map->async = true; | ||
| 2033 | |||
| 2034 | ret = _regmap_update_bits(map, reg, mask, val, change); | ||
| 2035 | |||
| 2036 | map->async = false; | ||
| 2037 | |||
| 2038 | map->unlock(map->lock_arg); | ||
| 2039 | |||
| 2040 | return ret; | ||
| 2041 | } | ||
| 2042 | EXPORT_SYMBOL_GPL(regmap_update_bits_check_async); | ||
| 2043 | |||
| 1815 | void regmap_async_complete_cb(struct regmap_async *async, int ret) | 2044 | void regmap_async_complete_cb(struct regmap_async *async, int ret) |
| 1816 | { | 2045 | { |
| 1817 | struct regmap *map = async->map; | 2046 | struct regmap *map = async->map; |
| @@ -1820,8 +2049,7 @@ void regmap_async_complete_cb(struct regmap_async *async, int ret) | |||
| 1820 | trace_regmap_async_io_complete(map->dev); | 2049 | trace_regmap_async_io_complete(map->dev); |
| 1821 | 2050 | ||
| 1822 | spin_lock(&map->async_lock); | 2051 | spin_lock(&map->async_lock); |
| 1823 | 2052 | list_move(&async->list, &map->async_free); | |
| 1824 | list_del(&async->list); | ||
| 1825 | wake = list_empty(&map->async_list); | 2053 | wake = list_empty(&map->async_list); |
| 1826 | 2054 | ||
| 1827 | if (ret != 0) | 2055 | if (ret != 0) |
| @@ -1829,8 +2057,6 @@ void regmap_async_complete_cb(struct regmap_async *async, int ret) | |||
| 1829 | 2057 | ||
| 1830 | spin_unlock(&map->async_lock); | 2058 | spin_unlock(&map->async_lock); |
| 1831 | 2059 | ||
| 1832 | schedule_work(&async->cleanup); | ||
| 1833 | |||
| 1834 | if (wake) | 2060 | if (wake) |
| 1835 | wake_up(&map->async_waitq); | 2061 | wake_up(&map->async_waitq); |
| 1836 | } | 2062 | } |
diff --git a/drivers/char/tpm/xen-tpmfront.c b/drivers/char/tpm/xen-tpmfront.c index 06189e55b4e5..94c280d36e8b 100644 --- a/drivers/char/tpm/xen-tpmfront.c +++ b/drivers/char/tpm/xen-tpmfront.c | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include <linux/errno.h> | 10 | #include <linux/errno.h> |
| 11 | #include <linux/err.h> | 11 | #include <linux/err.h> |
| 12 | #include <linux/interrupt.h> | 12 | #include <linux/interrupt.h> |
| 13 | #include <xen/xen.h> | ||
| 13 | #include <xen/events.h> | 14 | #include <xen/events.h> |
| 14 | #include <xen/interface/io/tpmif.h> | 15 | #include <xen/interface/io/tpmif.h> |
| 15 | #include <xen/grant_table.h> | 16 | #include <xen/grant_table.h> |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 32b3479a2405..badf6206b2b2 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -383,6 +383,7 @@ static void intel_pstate_get_min_max(struct cpudata *cpu, int *min, int *max) | |||
| 383 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | 383 | static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) |
| 384 | { | 384 | { |
| 385 | int max_perf, min_perf; | 385 | int max_perf, min_perf; |
| 386 | u64 val; | ||
| 386 | 387 | ||
| 387 | intel_pstate_get_min_max(cpu, &min_perf, &max_perf); | 388 | intel_pstate_get_min_max(cpu, &min_perf, &max_perf); |
| 388 | 389 | ||
| @@ -394,11 +395,11 @@ static void intel_pstate_set_pstate(struct cpudata *cpu, int pstate) | |||
| 394 | trace_cpu_frequency(pstate * 100000, cpu->cpu); | 395 | trace_cpu_frequency(pstate * 100000, cpu->cpu); |
| 395 | 396 | ||
| 396 | cpu->pstate.current_pstate = pstate; | 397 | cpu->pstate.current_pstate = pstate; |
| 398 | val = pstate << 8; | ||
| 397 | if (limits.no_turbo) | 399 | if (limits.no_turbo) |
| 398 | wrmsrl(MSR_IA32_PERF_CTL, BIT(32) | (pstate << 8)); | 400 | val |= (u64)1 << 32; |
| 399 | else | ||
| 400 | wrmsrl(MSR_IA32_PERF_CTL, pstate << 8); | ||
| 401 | 401 | ||
| 402 | wrmsrl(MSR_IA32_PERF_CTL, val); | ||
| 402 | } | 403 | } |
| 403 | 404 | ||
| 404 | static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps) | 405 | static inline void intel_pstate_pstate_increase(struct cpudata *cpu, int steps) |
| @@ -637,8 +638,8 @@ static int intel_pstate_cpu_exit(struct cpufreq_policy *policy) | |||
| 637 | 638 | ||
| 638 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | 639 | static int intel_pstate_cpu_init(struct cpufreq_policy *policy) |
| 639 | { | 640 | { |
| 640 | int rc, min_pstate, max_pstate; | ||
| 641 | struct cpudata *cpu; | 641 | struct cpudata *cpu; |
| 642 | int rc; | ||
| 642 | 643 | ||
| 643 | rc = intel_pstate_init_cpu(policy->cpu); | 644 | rc = intel_pstate_init_cpu(policy->cpu); |
| 644 | if (rc) | 645 | if (rc) |
| @@ -652,9 +653,8 @@ static int intel_pstate_cpu_init(struct cpufreq_policy *policy) | |||
| 652 | else | 653 | else |
| 653 | policy->policy = CPUFREQ_POLICY_POWERSAVE; | 654 | policy->policy = CPUFREQ_POLICY_POWERSAVE; |
| 654 | 655 | ||
| 655 | intel_pstate_get_min_max(cpu, &min_pstate, &max_pstate); | 656 | policy->min = cpu->pstate.min_pstate * 100000; |
| 656 | policy->min = min_pstate * 100000; | 657 | policy->max = cpu->pstate.turbo_pstate * 100000; |
| 657 | policy->max = max_pstate * 100000; | ||
| 658 | 658 | ||
| 659 | /* cpuinfo and default policy values */ | 659 | /* cpuinfo and default policy values */ |
| 660 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000; | 660 | policy->cpuinfo.min_freq = cpu->pstate.min_pstate * 100000; |
diff --git a/drivers/cpufreq/s3c64xx-cpufreq.c b/drivers/cpufreq/s3c64xx-cpufreq.c index 8a72b0c555f8..15631f92ab7d 100644 --- a/drivers/cpufreq/s3c64xx-cpufreq.c +++ b/drivers/cpufreq/s3c64xx-cpufreq.c | |||
| @@ -166,7 +166,7 @@ static void __init s3c64xx_cpufreq_config_regulator(void) | |||
| 166 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) | 166 | if (freq->frequency == CPUFREQ_ENTRY_INVALID) |
| 167 | continue; | 167 | continue; |
| 168 | 168 | ||
| 169 | dvfs = &s3c64xx_dvfs_table[freq->index]; | 169 | dvfs = &s3c64xx_dvfs_table[freq->driver_data]; |
| 170 | found = 0; | 170 | found = 0; |
| 171 | 171 | ||
| 172 | for (i = 0; i < count; i++) { | 172 | for (i = 0; i < count; i++) { |
diff --git a/drivers/gpio/gpio-lynxpoint.c b/drivers/gpio/gpio-lynxpoint.c index 2d9ca6055e5e..41b5913ddabe 100644 --- a/drivers/gpio/gpio-lynxpoint.c +++ b/drivers/gpio/gpio-lynxpoint.c | |||
| @@ -248,14 +248,15 @@ static void lp_gpio_irq_handler(unsigned irq, struct irq_desc *desc) | |||
| 248 | struct lp_gpio *lg = irq_data_get_irq_handler_data(data); | 248 | struct lp_gpio *lg = irq_data_get_irq_handler_data(data); |
| 249 | struct irq_chip *chip = irq_data_get_irq_chip(data); | 249 | struct irq_chip *chip = irq_data_get_irq_chip(data); |
| 250 | u32 base, pin, mask; | 250 | u32 base, pin, mask; |
| 251 | unsigned long reg, pending; | 251 | unsigned long reg, ena, pending; |
| 252 | unsigned virq; | 252 | unsigned virq; |
| 253 | 253 | ||
| 254 | /* check from GPIO controller which pin triggered the interrupt */ | 254 | /* check from GPIO controller which pin triggered the interrupt */ |
| 255 | for (base = 0; base < lg->chip.ngpio; base += 32) { | 255 | for (base = 0; base < lg->chip.ngpio; base += 32) { |
| 256 | reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT); | 256 | reg = lp_gpio_reg(&lg->chip, base, LP_INT_STAT); |
| 257 | ena = lp_gpio_reg(&lg->chip, base, LP_INT_ENABLE); | ||
| 257 | 258 | ||
| 258 | while ((pending = inl(reg))) { | 259 | while ((pending = (inl(reg) & inl(ena)))) { |
| 259 | pin = __ffs(pending); | 260 | pin = __ffs(pending); |
| 260 | mask = BIT(pin); | 261 | mask = BIT(pin); |
| 261 | /* Clear before handling so we don't lose an edge */ | 262 | /* Clear before handling so we don't lose an edge */ |
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 86ef3461ec06..0dee0e0c247a 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
| @@ -136,7 +136,7 @@ static struct gpio_desc *gpio_to_desc(unsigned gpio) | |||
| 136 | */ | 136 | */ |
| 137 | static int desc_to_gpio(const struct gpio_desc *desc) | 137 | static int desc_to_gpio(const struct gpio_desc *desc) |
| 138 | { | 138 | { |
| 139 | return desc->chip->base + gpio_chip_hwgpio(desc); | 139 | return desc - &gpio_desc[0]; |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | 142 | ||
| @@ -1398,7 +1398,7 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
| 1398 | int status = -EPROBE_DEFER; | 1398 | int status = -EPROBE_DEFER; |
| 1399 | unsigned long flags; | 1399 | unsigned long flags; |
| 1400 | 1400 | ||
| 1401 | if (!desc || !desc->chip) { | 1401 | if (!desc) { |
| 1402 | pr_warn("%s: invalid GPIO\n", __func__); | 1402 | pr_warn("%s: invalid GPIO\n", __func__); |
| 1403 | return -EINVAL; | 1403 | return -EINVAL; |
| 1404 | } | 1404 | } |
| @@ -1406,6 +1406,8 @@ static int gpiod_request(struct gpio_desc *desc, const char *label) | |||
| 1406 | spin_lock_irqsave(&gpio_lock, flags); | 1406 | spin_lock_irqsave(&gpio_lock, flags); |
| 1407 | 1407 | ||
| 1408 | chip = desc->chip; | 1408 | chip = desc->chip; |
| 1409 | if (chip == NULL) | ||
| 1410 | goto done; | ||
| 1409 | 1411 | ||
| 1410 | if (!try_module_get(chip->owner)) | 1412 | if (!try_module_get(chip->owner)) |
| 1411 | goto done; | 1413 | goto done; |
diff --git a/drivers/iio/frequency/adf4350.c b/drivers/iio/frequency/adf4350.c index a7b30be86ae0..52605c0ea3a6 100644 --- a/drivers/iio/frequency/adf4350.c +++ b/drivers/iio/frequency/adf4350.c | |||
| @@ -525,8 +525,10 @@ static int adf4350_probe(struct spi_device *spi) | |||
| 525 | } | 525 | } |
| 526 | 526 | ||
| 527 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); | 527 | indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); |
| 528 | if (indio_dev == NULL) | 528 | if (indio_dev == NULL) { |
| 529 | return -ENOMEM; | 529 | ret = -ENOMEM; |
| 530 | goto error_disable_clk; | ||
| 531 | } | ||
| 530 | 532 | ||
| 531 | st = iio_priv(indio_dev); | 533 | st = iio_priv(indio_dev); |
| 532 | 534 | ||
diff --git a/drivers/iio/industrialio-buffer.c b/drivers/iio/industrialio-buffer.c index 2710f7245c3b..2db7dcd826b9 100644 --- a/drivers/iio/industrialio-buffer.c +++ b/drivers/iio/industrialio-buffer.c | |||
| @@ -477,6 +477,9 @@ void iio_disable_all_buffers(struct iio_dev *indio_dev) | |||
| 477 | indio_dev->currentmode = INDIO_DIRECT_MODE; | 477 | indio_dev->currentmode = INDIO_DIRECT_MODE; |
| 478 | if (indio_dev->setup_ops->postdisable) | 478 | if (indio_dev->setup_ops->postdisable) |
| 479 | indio_dev->setup_ops->postdisable(indio_dev); | 479 | indio_dev->setup_ops->postdisable(indio_dev); |
| 480 | |||
| 481 | if (indio_dev->available_scan_masks == NULL) | ||
| 482 | kfree(indio_dev->active_scan_mask); | ||
| 480 | } | 483 | } |
| 481 | 484 | ||
| 482 | int iio_update_buffers(struct iio_dev *indio_dev, | 485 | int iio_update_buffers(struct iio_dev *indio_dev, |
diff --git a/drivers/infiniband/hw/amso1100/c2_ae.c b/drivers/infiniband/hw/amso1100/c2_ae.c index d5d1929753e4..cedda25232be 100644 --- a/drivers/infiniband/hw/amso1100/c2_ae.c +++ b/drivers/infiniband/hw/amso1100/c2_ae.c | |||
| @@ -141,7 +141,7 @@ static const char *to_qp_state_str(int state) | |||
| 141 | return "C2_QP_STATE_ERROR"; | 141 | return "C2_QP_STATE_ERROR"; |
| 142 | default: | 142 | default: |
| 143 | return "<invalid QP state>"; | 143 | return "<invalid QP state>"; |
| 144 | }; | 144 | } |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) | 147 | void c2_ae_event(struct c2_dev *c2dev, u32 mq_index) |
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index 3f831de9a4d8..b1a6cb3a2809 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c | |||
| @@ -164,6 +164,7 @@ int mlx5_vector2eqn(struct mlx5_ib_dev *dev, int vector, int *eqn, int *irqn) | |||
| 164 | static int alloc_comp_eqs(struct mlx5_ib_dev *dev) | 164 | static int alloc_comp_eqs(struct mlx5_ib_dev *dev) |
| 165 | { | 165 | { |
| 166 | struct mlx5_eq_table *table = &dev->mdev.priv.eq_table; | 166 | struct mlx5_eq_table *table = &dev->mdev.priv.eq_table; |
| 167 | char name[MLX5_MAX_EQ_NAME]; | ||
| 167 | struct mlx5_eq *eq, *n; | 168 | struct mlx5_eq *eq, *n; |
| 168 | int ncomp_vec; | 169 | int ncomp_vec; |
| 169 | int nent; | 170 | int nent; |
| @@ -180,11 +181,10 @@ static int alloc_comp_eqs(struct mlx5_ib_dev *dev) | |||
| 180 | goto clean; | 181 | goto clean; |
| 181 | } | 182 | } |
| 182 | 183 | ||
| 183 | snprintf(eq->name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i); | 184 | snprintf(name, MLX5_MAX_EQ_NAME, "mlx5_comp%d", i); |
| 184 | err = mlx5_create_map_eq(&dev->mdev, eq, | 185 | err = mlx5_create_map_eq(&dev->mdev, eq, |
| 185 | i + MLX5_EQ_VEC_COMP_BASE, nent, 0, | 186 | i + MLX5_EQ_VEC_COMP_BASE, nent, 0, |
| 186 | eq->name, | 187 | name, &dev->mdev.priv.uuari.uars[0]); |
| 187 | &dev->mdev.priv.uuari.uars[0]); | ||
| 188 | if (err) { | 188 | if (err) { |
| 189 | kfree(eq); | 189 | kfree(eq); |
| 190 | goto clean; | 190 | goto clean; |
| @@ -301,9 +301,8 @@ static int mlx5_ib_query_device(struct ib_device *ibdev, | |||
| 301 | props->max_srq_sge = max_rq_sg - 1; | 301 | props->max_srq_sge = max_rq_sg - 1; |
| 302 | props->max_fast_reg_page_list_len = (unsigned int)-1; | 302 | props->max_fast_reg_page_list_len = (unsigned int)-1; |
| 303 | props->local_ca_ack_delay = dev->mdev.caps.local_ca_ack_delay; | 303 | props->local_ca_ack_delay = dev->mdev.caps.local_ca_ack_delay; |
| 304 | props->atomic_cap = dev->mdev.caps.flags & MLX5_DEV_CAP_FLAG_ATOMIC ? | 304 | props->atomic_cap = IB_ATOMIC_NONE; |
| 305 | IB_ATOMIC_HCA : IB_ATOMIC_NONE; | 305 | props->masked_atomic_cap = IB_ATOMIC_NONE; |
| 306 | props->masked_atomic_cap = IB_ATOMIC_HCA; | ||
| 307 | props->max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28)); | 306 | props->max_pkeys = be16_to_cpup((__be16 *)(out_mad->data + 28)); |
| 308 | props->max_mcast_grp = 1 << dev->mdev.caps.log_max_mcg; | 307 | props->max_mcast_grp = 1 << dev->mdev.caps.log_max_mcg; |
| 309 | props->max_mcast_qp_attach = dev->mdev.caps.max_qp_mcg; | 308 | props->max_mcast_qp_attach = dev->mdev.caps.max_qp_mcg; |
| @@ -1006,6 +1005,11 @@ static void mlx5_ib_event(struct mlx5_core_dev *dev, enum mlx5_dev_event event, | |||
| 1006 | ibev.device = &ibdev->ib_dev; | 1005 | ibev.device = &ibdev->ib_dev; |
| 1007 | ibev.element.port_num = port; | 1006 | ibev.element.port_num = port; |
| 1008 | 1007 | ||
| 1008 | if (port < 1 || port > ibdev->num_ports) { | ||
| 1009 | mlx5_ib_warn(ibdev, "warning: event on port %d\n", port); | ||
| 1010 | return; | ||
| 1011 | } | ||
| 1012 | |||
| 1009 | if (ibdev->ib_active) | 1013 | if (ibdev->ib_active) |
| 1010 | ib_dispatch_event(&ibev); | 1014 | ib_dispatch_event(&ibev); |
| 1011 | } | 1015 | } |
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c index bd41df95b6f0..3453580b1eb2 100644 --- a/drivers/infiniband/hw/mlx5/mr.c +++ b/drivers/infiniband/hw/mlx5/mr.c | |||
| @@ -42,6 +42,10 @@ enum { | |||
| 42 | DEF_CACHE_SIZE = 10, | 42 | DEF_CACHE_SIZE = 10, |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | enum { | ||
| 46 | MLX5_UMR_ALIGN = 2048 | ||
| 47 | }; | ||
| 48 | |||
| 45 | static __be64 *mr_align(__be64 *ptr, int align) | 49 | static __be64 *mr_align(__be64 *ptr, int align) |
| 46 | { | 50 | { |
| 47 | unsigned long mask = align - 1; | 51 | unsigned long mask = align - 1; |
| @@ -61,13 +65,11 @@ static int order2idx(struct mlx5_ib_dev *dev, int order) | |||
| 61 | 65 | ||
| 62 | static int add_keys(struct mlx5_ib_dev *dev, int c, int num) | 66 | static int add_keys(struct mlx5_ib_dev *dev, int c, int num) |
| 63 | { | 67 | { |
| 64 | struct device *ddev = dev->ib_dev.dma_device; | ||
| 65 | struct mlx5_mr_cache *cache = &dev->cache; | 68 | struct mlx5_mr_cache *cache = &dev->cache; |
| 66 | struct mlx5_cache_ent *ent = &cache->ent[c]; | 69 | struct mlx5_cache_ent *ent = &cache->ent[c]; |
| 67 | struct mlx5_create_mkey_mbox_in *in; | 70 | struct mlx5_create_mkey_mbox_in *in; |
| 68 | struct mlx5_ib_mr *mr; | 71 | struct mlx5_ib_mr *mr; |
| 69 | int npages = 1 << ent->order; | 72 | int npages = 1 << ent->order; |
| 70 | int size = sizeof(u64) * npages; | ||
| 71 | int err = 0; | 73 | int err = 0; |
| 72 | int i; | 74 | int i; |
| 73 | 75 | ||
| @@ -83,21 +85,6 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num) | |||
| 83 | } | 85 | } |
| 84 | mr->order = ent->order; | 86 | mr->order = ent->order; |
| 85 | mr->umred = 1; | 87 | mr->umred = 1; |
| 86 | mr->pas = kmalloc(size + 0x3f, GFP_KERNEL); | ||
| 87 | if (!mr->pas) { | ||
| 88 | kfree(mr); | ||
| 89 | err = -ENOMEM; | ||
| 90 | goto out; | ||
| 91 | } | ||
| 92 | mr->dma = dma_map_single(ddev, mr_align(mr->pas, 0x40), size, | ||
| 93 | DMA_TO_DEVICE); | ||
| 94 | if (dma_mapping_error(ddev, mr->dma)) { | ||
| 95 | kfree(mr->pas); | ||
| 96 | kfree(mr); | ||
| 97 | err = -ENOMEM; | ||
| 98 | goto out; | ||
| 99 | } | ||
| 100 | |||
| 101 | in->seg.status = 1 << 6; | 88 | in->seg.status = 1 << 6; |
| 102 | in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2); | 89 | in->seg.xlt_oct_size = cpu_to_be32((npages + 1) / 2); |
| 103 | in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); | 90 | in->seg.qpn_mkey7_0 = cpu_to_be32(0xffffff << 8); |
| @@ -108,8 +95,6 @@ static int add_keys(struct mlx5_ib_dev *dev, int c, int num) | |||
| 108 | sizeof(*in)); | 95 | sizeof(*in)); |
| 109 | if (err) { | 96 | if (err) { |
| 110 | mlx5_ib_warn(dev, "create mkey failed %d\n", err); | 97 | mlx5_ib_warn(dev, "create mkey failed %d\n", err); |
| 111 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
| 112 | kfree(mr->pas); | ||
| 113 | kfree(mr); | 98 | kfree(mr); |
| 114 | goto out; | 99 | goto out; |
| 115 | } | 100 | } |
| @@ -129,11 +114,9 @@ out: | |||
| 129 | 114 | ||
| 130 | static void remove_keys(struct mlx5_ib_dev *dev, int c, int num) | 115 | static void remove_keys(struct mlx5_ib_dev *dev, int c, int num) |
| 131 | { | 116 | { |
| 132 | struct device *ddev = dev->ib_dev.dma_device; | ||
| 133 | struct mlx5_mr_cache *cache = &dev->cache; | 117 | struct mlx5_mr_cache *cache = &dev->cache; |
| 134 | struct mlx5_cache_ent *ent = &cache->ent[c]; | 118 | struct mlx5_cache_ent *ent = &cache->ent[c]; |
| 135 | struct mlx5_ib_mr *mr; | 119 | struct mlx5_ib_mr *mr; |
| 136 | int size; | ||
| 137 | int err; | 120 | int err; |
| 138 | int i; | 121 | int i; |
| 139 | 122 | ||
| @@ -149,14 +132,10 @@ static void remove_keys(struct mlx5_ib_dev *dev, int c, int num) | |||
| 149 | ent->size--; | 132 | ent->size--; |
| 150 | spin_unlock(&ent->lock); | 133 | spin_unlock(&ent->lock); |
| 151 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); | 134 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); |
| 152 | if (err) { | 135 | if (err) |
| 153 | mlx5_ib_warn(dev, "failed destroy mkey\n"); | 136 | mlx5_ib_warn(dev, "failed destroy mkey\n"); |
| 154 | } else { | 137 | else |
| 155 | size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40); | ||
| 156 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
| 157 | kfree(mr->pas); | ||
| 158 | kfree(mr); | 138 | kfree(mr); |
| 159 | } | ||
| 160 | } | 139 | } |
| 161 | } | 140 | } |
| 162 | 141 | ||
| @@ -408,13 +387,12 @@ static void free_cached_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) | |||
| 408 | 387 | ||
| 409 | static void clean_keys(struct mlx5_ib_dev *dev, int c) | 388 | static void clean_keys(struct mlx5_ib_dev *dev, int c) |
| 410 | { | 389 | { |
| 411 | struct device *ddev = dev->ib_dev.dma_device; | ||
| 412 | struct mlx5_mr_cache *cache = &dev->cache; | 390 | struct mlx5_mr_cache *cache = &dev->cache; |
| 413 | struct mlx5_cache_ent *ent = &cache->ent[c]; | 391 | struct mlx5_cache_ent *ent = &cache->ent[c]; |
| 414 | struct mlx5_ib_mr *mr; | 392 | struct mlx5_ib_mr *mr; |
| 415 | int size; | ||
| 416 | int err; | 393 | int err; |
| 417 | 394 | ||
| 395 | cancel_delayed_work(&ent->dwork); | ||
| 418 | while (1) { | 396 | while (1) { |
| 419 | spin_lock(&ent->lock); | 397 | spin_lock(&ent->lock); |
| 420 | if (list_empty(&ent->head)) { | 398 | if (list_empty(&ent->head)) { |
| @@ -427,14 +405,10 @@ static void clean_keys(struct mlx5_ib_dev *dev, int c) | |||
| 427 | ent->size--; | 405 | ent->size--; |
| 428 | spin_unlock(&ent->lock); | 406 | spin_unlock(&ent->lock); |
| 429 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); | 407 | err = mlx5_core_destroy_mkey(&dev->mdev, &mr->mmr); |
| 430 | if (err) { | 408 | if (err) |
| 431 | mlx5_ib_warn(dev, "failed destroy mkey\n"); | 409 | mlx5_ib_warn(dev, "failed destroy mkey\n"); |
| 432 | } else { | 410 | else |
| 433 | size = ALIGN(sizeof(u64) * (1 << mr->order), 0x40); | ||
| 434 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
| 435 | kfree(mr->pas); | ||
| 436 | kfree(mr); | 411 | kfree(mr); |
| 437 | } | ||
| 438 | } | 412 | } |
| 439 | } | 413 | } |
| 440 | 414 | ||
| @@ -540,13 +514,15 @@ int mlx5_mr_cache_cleanup(struct mlx5_ib_dev *dev) | |||
| 540 | int i; | 514 | int i; |
| 541 | 515 | ||
| 542 | dev->cache.stopped = 1; | 516 | dev->cache.stopped = 1; |
| 543 | destroy_workqueue(dev->cache.wq); | 517 | flush_workqueue(dev->cache.wq); |
| 544 | 518 | ||
| 545 | mlx5_mr_cache_debugfs_cleanup(dev); | 519 | mlx5_mr_cache_debugfs_cleanup(dev); |
| 546 | 520 | ||
| 547 | for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) | 521 | for (i = 0; i < MAX_MR_CACHE_ENTRIES; i++) |
| 548 | clean_keys(dev, i); | 522 | clean_keys(dev, i); |
| 549 | 523 | ||
| 524 | destroy_workqueue(dev->cache.wq); | ||
| 525 | |||
| 550 | return 0; | 526 | return 0; |
| 551 | } | 527 | } |
| 552 | 528 | ||
| @@ -675,10 +651,12 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem, | |||
| 675 | int page_shift, int order, int access_flags) | 651 | int page_shift, int order, int access_flags) |
| 676 | { | 652 | { |
| 677 | struct mlx5_ib_dev *dev = to_mdev(pd->device); | 653 | struct mlx5_ib_dev *dev = to_mdev(pd->device); |
| 654 | struct device *ddev = dev->ib_dev.dma_device; | ||
| 678 | struct umr_common *umrc = &dev->umrc; | 655 | struct umr_common *umrc = &dev->umrc; |
| 679 | struct ib_send_wr wr, *bad; | 656 | struct ib_send_wr wr, *bad; |
| 680 | struct mlx5_ib_mr *mr; | 657 | struct mlx5_ib_mr *mr; |
| 681 | struct ib_sge sg; | 658 | struct ib_sge sg; |
| 659 | int size = sizeof(u64) * npages; | ||
| 682 | int err; | 660 | int err; |
| 683 | int i; | 661 | int i; |
| 684 | 662 | ||
| @@ -697,7 +675,22 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem, | |||
| 697 | if (!mr) | 675 | if (!mr) |
| 698 | return ERR_PTR(-EAGAIN); | 676 | return ERR_PTR(-EAGAIN); |
| 699 | 677 | ||
| 700 | mlx5_ib_populate_pas(dev, umem, page_shift, mr_align(mr->pas, 0x40), 1); | 678 | mr->pas = kmalloc(size + MLX5_UMR_ALIGN - 1, GFP_KERNEL); |
| 679 | if (!mr->pas) { | ||
| 680 | err = -ENOMEM; | ||
| 681 | goto error; | ||
| 682 | } | ||
| 683 | |||
| 684 | mlx5_ib_populate_pas(dev, umem, page_shift, | ||
| 685 | mr_align(mr->pas, MLX5_UMR_ALIGN), 1); | ||
| 686 | |||
| 687 | mr->dma = dma_map_single(ddev, mr_align(mr->pas, MLX5_UMR_ALIGN), size, | ||
| 688 | DMA_TO_DEVICE); | ||
| 689 | if (dma_mapping_error(ddev, mr->dma)) { | ||
| 690 | kfree(mr->pas); | ||
| 691 | err = -ENOMEM; | ||
| 692 | goto error; | ||
| 693 | } | ||
| 701 | 694 | ||
| 702 | memset(&wr, 0, sizeof(wr)); | 695 | memset(&wr, 0, sizeof(wr)); |
| 703 | wr.wr_id = (u64)(unsigned long)mr; | 696 | wr.wr_id = (u64)(unsigned long)mr; |
| @@ -718,6 +711,9 @@ static struct mlx5_ib_mr *reg_umr(struct ib_pd *pd, struct ib_umem *umem, | |||
| 718 | wait_for_completion(&mr->done); | 711 | wait_for_completion(&mr->done); |
| 719 | up(&umrc->sem); | 712 | up(&umrc->sem); |
| 720 | 713 | ||
| 714 | dma_unmap_single(ddev, mr->dma, size, DMA_TO_DEVICE); | ||
| 715 | kfree(mr->pas); | ||
| 716 | |||
| 721 | if (mr->status != IB_WC_SUCCESS) { | 717 | if (mr->status != IB_WC_SUCCESS) { |
| 722 | mlx5_ib_warn(dev, "reg umr failed\n"); | 718 | mlx5_ib_warn(dev, "reg umr failed\n"); |
| 723 | err = -EFAULT; | 719 | err = -EFAULT; |
diff --git a/drivers/infiniband/hw/mlx5/qp.c b/drivers/infiniband/hw/mlx5/qp.c index 045f8cdbd303..5659ea880741 100644 --- a/drivers/infiniband/hw/mlx5/qp.c +++ b/drivers/infiniband/hw/mlx5/qp.c | |||
| @@ -203,7 +203,7 @@ static int sq_overhead(enum ib_qp_type qp_type) | |||
| 203 | 203 | ||
| 204 | switch (qp_type) { | 204 | switch (qp_type) { |
| 205 | case IB_QPT_XRC_INI: | 205 | case IB_QPT_XRC_INI: |
| 206 | size = sizeof(struct mlx5_wqe_xrc_seg); | 206 | size += sizeof(struct mlx5_wqe_xrc_seg); |
| 207 | /* fall through */ | 207 | /* fall through */ |
| 208 | case IB_QPT_RC: | 208 | case IB_QPT_RC: |
| 209 | size += sizeof(struct mlx5_wqe_ctrl_seg) + | 209 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
| @@ -211,20 +211,23 @@ static int sq_overhead(enum ib_qp_type qp_type) | |||
| 211 | sizeof(struct mlx5_wqe_raddr_seg); | 211 | sizeof(struct mlx5_wqe_raddr_seg); |
| 212 | break; | 212 | break; |
| 213 | 213 | ||
| 214 | case IB_QPT_XRC_TGT: | ||
| 215 | return 0; | ||
| 216 | |||
| 214 | case IB_QPT_UC: | 217 | case IB_QPT_UC: |
| 215 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 218 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
| 216 | sizeof(struct mlx5_wqe_raddr_seg); | 219 | sizeof(struct mlx5_wqe_raddr_seg); |
| 217 | break; | 220 | break; |
| 218 | 221 | ||
| 219 | case IB_QPT_UD: | 222 | case IB_QPT_UD: |
| 220 | case IB_QPT_SMI: | 223 | case IB_QPT_SMI: |
| 221 | case IB_QPT_GSI: | 224 | case IB_QPT_GSI: |
| 222 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 225 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
| 223 | sizeof(struct mlx5_wqe_datagram_seg); | 226 | sizeof(struct mlx5_wqe_datagram_seg); |
| 224 | break; | 227 | break; |
| 225 | 228 | ||
| 226 | case MLX5_IB_QPT_REG_UMR: | 229 | case MLX5_IB_QPT_REG_UMR: |
| 227 | size = sizeof(struct mlx5_wqe_ctrl_seg) + | 230 | size += sizeof(struct mlx5_wqe_ctrl_seg) + |
| 228 | sizeof(struct mlx5_wqe_umr_ctrl_seg) + | 231 | sizeof(struct mlx5_wqe_umr_ctrl_seg) + |
| 229 | sizeof(struct mlx5_mkey_seg); | 232 | sizeof(struct mlx5_mkey_seg); |
| 230 | break; | 233 | break; |
| @@ -270,7 +273,8 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr, | |||
| 270 | return wqe_size; | 273 | return wqe_size; |
| 271 | 274 | ||
| 272 | if (wqe_size > dev->mdev.caps.max_sq_desc_sz) { | 275 | if (wqe_size > dev->mdev.caps.max_sq_desc_sz) { |
| 273 | mlx5_ib_dbg(dev, "\n"); | 276 | mlx5_ib_dbg(dev, "wqe_size(%d) > max_sq_desc_sz(%d)\n", |
| 277 | wqe_size, dev->mdev.caps.max_sq_desc_sz); | ||
| 274 | return -EINVAL; | 278 | return -EINVAL; |
| 275 | } | 279 | } |
| 276 | 280 | ||
| @@ -280,9 +284,15 @@ static int calc_sq_size(struct mlx5_ib_dev *dev, struct ib_qp_init_attr *attr, | |||
| 280 | 284 | ||
| 281 | wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size); | 285 | wq_size = roundup_pow_of_two(attr->cap.max_send_wr * wqe_size); |
| 282 | qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; | 286 | qp->sq.wqe_cnt = wq_size / MLX5_SEND_WQE_BB; |
| 287 | if (qp->sq.wqe_cnt > dev->mdev.caps.max_wqes) { | ||
| 288 | mlx5_ib_dbg(dev, "wqe count(%d) exceeds limits(%d)\n", | ||
| 289 | qp->sq.wqe_cnt, dev->mdev.caps.max_wqes); | ||
| 290 | return -ENOMEM; | ||
| 291 | } | ||
| 283 | qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB); | 292 | qp->sq.wqe_shift = ilog2(MLX5_SEND_WQE_BB); |
| 284 | qp->sq.max_gs = attr->cap.max_send_sge; | 293 | qp->sq.max_gs = attr->cap.max_send_sge; |
| 285 | qp->sq.max_post = 1 << ilog2(wq_size / wqe_size); | 294 | qp->sq.max_post = wq_size / wqe_size; |
| 295 | attr->cap.max_send_wr = qp->sq.max_post; | ||
| 286 | 296 | ||
| 287 | return wq_size; | 297 | return wq_size; |
| 288 | } | 298 | } |
| @@ -1280,6 +1290,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q | |||
| 1280 | MLX5_QP_OPTPAR_Q_KEY, | 1290 | MLX5_QP_OPTPAR_Q_KEY, |
| 1281 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_PKEY_INDEX | | 1291 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_PKEY_INDEX | |
| 1282 | MLX5_QP_OPTPAR_Q_KEY, | 1292 | MLX5_QP_OPTPAR_Q_KEY, |
| 1293 | [MLX5_QP_ST_XRC] = MLX5_QP_OPTPAR_ALT_ADDR_PATH | | ||
| 1294 | MLX5_QP_OPTPAR_RRE | | ||
| 1295 | MLX5_QP_OPTPAR_RAE | | ||
| 1296 | MLX5_QP_OPTPAR_RWE | | ||
| 1297 | MLX5_QP_OPTPAR_PKEY_INDEX, | ||
| 1283 | }, | 1298 | }, |
| 1284 | }, | 1299 | }, |
| 1285 | [MLX5_QP_STATE_RTR] = { | 1300 | [MLX5_QP_STATE_RTR] = { |
| @@ -1314,6 +1329,11 @@ static enum mlx5_qp_optpar opt_mask[MLX5_QP_NUM_STATE][MLX5_QP_NUM_STATE][MLX5_Q | |||
| 1314 | [MLX5_QP_STATE_RTS] = { | 1329 | [MLX5_QP_STATE_RTS] = { |
| 1315 | [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY, | 1330 | [MLX5_QP_ST_UD] = MLX5_QP_OPTPAR_Q_KEY, |
| 1316 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_Q_KEY, | 1331 | [MLX5_QP_ST_MLX] = MLX5_QP_OPTPAR_Q_KEY, |
| 1332 | [MLX5_QP_ST_UC] = MLX5_QP_OPTPAR_RWE, | ||
| 1333 | [MLX5_QP_ST_RC] = MLX5_QP_OPTPAR_RNR_TIMEOUT | | ||
| 1334 | MLX5_QP_OPTPAR_RWE | | ||
| 1335 | MLX5_QP_OPTPAR_RAE | | ||
| 1336 | MLX5_QP_OPTPAR_RRE, | ||
| 1317 | }, | 1337 | }, |
| 1318 | }, | 1338 | }, |
| 1319 | }; | 1339 | }; |
| @@ -1651,29 +1671,6 @@ static __always_inline void set_raddr_seg(struct mlx5_wqe_raddr_seg *rseg, | |||
| 1651 | rseg->reserved = 0; | 1671 | rseg->reserved = 0; |
| 1652 | } | 1672 | } |
| 1653 | 1673 | ||
| 1654 | static void set_atomic_seg(struct mlx5_wqe_atomic_seg *aseg, struct ib_send_wr *wr) | ||
| 1655 | { | ||
| 1656 | if (wr->opcode == IB_WR_ATOMIC_CMP_AND_SWP) { | ||
| 1657 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap); | ||
| 1658 | aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add); | ||
| 1659 | } else if (wr->opcode == IB_WR_MASKED_ATOMIC_FETCH_AND_ADD) { | ||
| 1660 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add); | ||
| 1661 | aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add_mask); | ||
| 1662 | } else { | ||
| 1663 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.compare_add); | ||
| 1664 | aseg->compare = 0; | ||
| 1665 | } | ||
| 1666 | } | ||
| 1667 | |||
| 1668 | static void set_masked_atomic_seg(struct mlx5_wqe_masked_atomic_seg *aseg, | ||
| 1669 | struct ib_send_wr *wr) | ||
| 1670 | { | ||
| 1671 | aseg->swap_add = cpu_to_be64(wr->wr.atomic.swap); | ||
| 1672 | aseg->swap_add_mask = cpu_to_be64(wr->wr.atomic.swap_mask); | ||
| 1673 | aseg->compare = cpu_to_be64(wr->wr.atomic.compare_add); | ||
| 1674 | aseg->compare_mask = cpu_to_be64(wr->wr.atomic.compare_add_mask); | ||
| 1675 | } | ||
| 1676 | |||
| 1677 | static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg, | 1674 | static void set_datagram_seg(struct mlx5_wqe_datagram_seg *dseg, |
| 1678 | struct ib_send_wr *wr) | 1675 | struct ib_send_wr *wr) |
| 1679 | { | 1676 | { |
| @@ -2063,28 +2060,11 @@ int mlx5_ib_post_send(struct ib_qp *ibqp, struct ib_send_wr *wr, | |||
| 2063 | 2060 | ||
| 2064 | case IB_WR_ATOMIC_CMP_AND_SWP: | 2061 | case IB_WR_ATOMIC_CMP_AND_SWP: |
| 2065 | case IB_WR_ATOMIC_FETCH_AND_ADD: | 2062 | case IB_WR_ATOMIC_FETCH_AND_ADD: |
| 2066 | set_raddr_seg(seg, wr->wr.atomic.remote_addr, | ||
| 2067 | wr->wr.atomic.rkey); | ||
| 2068 | seg += sizeof(struct mlx5_wqe_raddr_seg); | ||
| 2069 | |||
| 2070 | set_atomic_seg(seg, wr); | ||
| 2071 | seg += sizeof(struct mlx5_wqe_atomic_seg); | ||
| 2072 | |||
| 2073 | size += (sizeof(struct mlx5_wqe_raddr_seg) + | ||
| 2074 | sizeof(struct mlx5_wqe_atomic_seg)) / 16; | ||
| 2075 | break; | ||
| 2076 | |||
| 2077 | case IB_WR_MASKED_ATOMIC_CMP_AND_SWP: | 2063 | case IB_WR_MASKED_ATOMIC_CMP_AND_SWP: |
| 2078 | set_raddr_seg(seg, wr->wr.atomic.remote_addr, | 2064 | mlx5_ib_warn(dev, "Atomic operations are not supported yet\n"); |
| 2079 | wr->wr.atomic.rkey); | 2065 | err = -ENOSYS; |
| 2080 | seg += sizeof(struct mlx5_wqe_raddr_seg); | 2066 | *bad_wr = wr; |
| 2081 | 2067 | goto out; | |
| 2082 | set_masked_atomic_seg(seg, wr); | ||
| 2083 | seg += sizeof(struct mlx5_wqe_masked_atomic_seg); | ||
| 2084 | |||
| 2085 | size += (sizeof(struct mlx5_wqe_raddr_seg) + | ||
| 2086 | sizeof(struct mlx5_wqe_masked_atomic_seg)) / 16; | ||
| 2087 | break; | ||
| 2088 | 2068 | ||
| 2089 | case IB_WR_LOCAL_INV: | 2069 | case IB_WR_LOCAL_INV: |
| 2090 | next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL; | 2070 | next_fence = MLX5_FENCE_MODE_INITIATOR_SMALL; |
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index 84d297afd6a9..0aa478bc291a 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c | |||
| @@ -295,7 +295,7 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, | |||
| 295 | mlx5_vfree(in); | 295 | mlx5_vfree(in); |
| 296 | if (err) { | 296 | if (err) { |
| 297 | mlx5_ib_dbg(dev, "create SRQ failed, err %d\n", err); | 297 | mlx5_ib_dbg(dev, "create SRQ failed, err %d\n", err); |
| 298 | goto err_srq; | 298 | goto err_usr_kern_srq; |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | mlx5_ib_dbg(dev, "create SRQ with srqn 0x%x\n", srq->msrq.srqn); | 301 | mlx5_ib_dbg(dev, "create SRQ with srqn 0x%x\n", srq->msrq.srqn); |
| @@ -316,6 +316,8 @@ struct ib_srq *mlx5_ib_create_srq(struct ib_pd *pd, | |||
| 316 | 316 | ||
| 317 | err_core: | 317 | err_core: |
| 318 | mlx5_core_destroy_srq(&dev->mdev, &srq->msrq); | 318 | mlx5_core_destroy_srq(&dev->mdev, &srq->msrq); |
| 319 | |||
| 320 | err_usr_kern_srq: | ||
| 319 | if (pd->uobject) | 321 | if (pd->uobject) |
| 320 | destroy_srq_user(pd, srq); | 322 | destroy_srq_user(pd, srq); |
| 321 | else | 323 | else |
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index 7c9d35f39d75..690201738993 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c | |||
| @@ -357,7 +357,7 @@ static int mthca_eq_int(struct mthca_dev *dev, struct mthca_eq *eq) | |||
| 357 | mthca_warn(dev, "Unhandled event %02x(%02x) on EQ %d\n", | 357 | mthca_warn(dev, "Unhandled event %02x(%02x) on EQ %d\n", |
| 358 | eqe->type, eqe->subtype, eq->eqn); | 358 | eqe->type, eqe->subtype, eq->eqn); |
| 359 | break; | 359 | break; |
| 360 | }; | 360 | } |
| 361 | 361 | ||
| 362 | set_eqe_hw(eqe); | 362 | set_eqe_hw(eqe); |
| 363 | ++eq->cons_index; | 363 | ++eq->cons_index; |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 4ed8235d2d36..50219ab2279d 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c | |||
| @@ -150,7 +150,7 @@ enum ib_qp_state get_ibqp_state(enum ocrdma_qp_state qps) | |||
| 150 | return IB_QPS_SQE; | 150 | return IB_QPS_SQE; |
| 151 | case OCRDMA_QPS_ERR: | 151 | case OCRDMA_QPS_ERR: |
| 152 | return IB_QPS_ERR; | 152 | return IB_QPS_ERR; |
| 153 | }; | 153 | } |
| 154 | return IB_QPS_ERR; | 154 | return IB_QPS_ERR; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| @@ -171,7 +171,7 @@ static enum ocrdma_qp_state get_ocrdma_qp_state(enum ib_qp_state qps) | |||
| 171 | return OCRDMA_QPS_SQE; | 171 | return OCRDMA_QPS_SQE; |
| 172 | case IB_QPS_ERR: | 172 | case IB_QPS_ERR: |
| 173 | return OCRDMA_QPS_ERR; | 173 | return OCRDMA_QPS_ERR; |
| 174 | }; | 174 | } |
| 175 | return OCRDMA_QPS_ERR; | 175 | return OCRDMA_QPS_ERR; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| @@ -1982,7 +1982,7 @@ int ocrdma_mbx_create_qp(struct ocrdma_qp *qp, struct ib_qp_init_attr *attrs, | |||
| 1982 | break; | 1982 | break; |
| 1983 | default: | 1983 | default: |
| 1984 | return -EINVAL; | 1984 | return -EINVAL; |
| 1985 | }; | 1985 | } |
| 1986 | 1986 | ||
| 1987 | cmd = ocrdma_init_emb_mqe(OCRDMA_CMD_CREATE_QP, sizeof(*cmd)); | 1987 | cmd = ocrdma_init_emb_mqe(OCRDMA_CMD_CREATE_QP, sizeof(*cmd)); |
| 1988 | if (!cmd) | 1988 | if (!cmd) |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index 56e004940f18..0ce7674621ea 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c | |||
| @@ -531,7 +531,7 @@ static void ocrdma_event_handler(struct ocrdma_dev *dev, u32 event) | |||
| 531 | case BE_DEV_DOWN: | 531 | case BE_DEV_DOWN: |
| 532 | ocrdma_close(dev); | 532 | ocrdma_close(dev); |
| 533 | break; | 533 | break; |
| 534 | }; | 534 | } |
| 535 | } | 535 | } |
| 536 | 536 | ||
| 537 | static struct ocrdma_driver ocrdma_drv = { | 537 | static struct ocrdma_driver ocrdma_drv = { |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 6e982bb43c31..69f1d1221a6b 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | |||
| @@ -141,7 +141,7 @@ static inline void get_link_speed_and_width(struct ocrdma_dev *dev, | |||
| 141 | /* Unsupported */ | 141 | /* Unsupported */ |
| 142 | *ib_speed = IB_SPEED_SDR; | 142 | *ib_speed = IB_SPEED_SDR; |
| 143 | *ib_width = IB_WIDTH_1X; | 143 | *ib_width = IB_WIDTH_1X; |
| 144 | }; | 144 | } |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | 147 | ||
| @@ -2331,7 +2331,7 @@ static enum ib_wc_status ocrdma_to_ibwc_err(u16 status) | |||
| 2331 | default: | 2331 | default: |
| 2332 | ibwc_status = IB_WC_GENERAL_ERR; | 2332 | ibwc_status = IB_WC_GENERAL_ERR; |
| 2333 | break; | 2333 | break; |
| 2334 | }; | 2334 | } |
| 2335 | return ibwc_status; | 2335 | return ibwc_status; |
| 2336 | } | 2336 | } |
| 2337 | 2337 | ||
| @@ -2370,7 +2370,7 @@ static void ocrdma_update_wc(struct ocrdma_qp *qp, struct ib_wc *ibwc, | |||
| 2370 | pr_err("%s() invalid opcode received = 0x%x\n", | 2370 | pr_err("%s() invalid opcode received = 0x%x\n", |
| 2371 | __func__, hdr->cw & OCRDMA_WQE_OPCODE_MASK); | 2371 | __func__, hdr->cw & OCRDMA_WQE_OPCODE_MASK); |
| 2372 | break; | 2372 | break; |
| 2373 | }; | 2373 | } |
| 2374 | } | 2374 | } |
| 2375 | 2375 | ||
| 2376 | static void ocrdma_set_cqe_status_flushed(struct ocrdma_qp *qp, | 2376 | static void ocrdma_set_cqe_status_flushed(struct ocrdma_qp *qp, |
diff --git a/drivers/md/dm-snap-persistent.c b/drivers/md/dm-snap-persistent.c index 4caa8e6d59d7..2d2b1b7588d7 100644 --- a/drivers/md/dm-snap-persistent.c +++ b/drivers/md/dm-snap-persistent.c | |||
| @@ -269,6 +269,14 @@ static chunk_t area_location(struct pstore *ps, chunk_t area) | |||
| 269 | return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area + 1) * area); | 269 | return NUM_SNAPSHOT_HDR_CHUNKS + ((ps->exceptions_per_area + 1) * area); |
| 270 | } | 270 | } |
| 271 | 271 | ||
| 272 | static void skip_metadata(struct pstore *ps) | ||
| 273 | { | ||
| 274 | uint32_t stride = ps->exceptions_per_area + 1; | ||
| 275 | chunk_t next_free = ps->next_free; | ||
| 276 | if (sector_div(next_free, stride) == NUM_SNAPSHOT_HDR_CHUNKS) | ||
| 277 | ps->next_free++; | ||
| 278 | } | ||
| 279 | |||
| 272 | /* | 280 | /* |
| 273 | * Read or write a metadata area. Remembering to skip the first | 281 | * Read or write a metadata area. Remembering to skip the first |
| 274 | * chunk which holds the header. | 282 | * chunk which holds the header. |
| @@ -502,6 +510,8 @@ static int read_exceptions(struct pstore *ps, | |||
| 502 | 510 | ||
| 503 | ps->current_area--; | 511 | ps->current_area--; |
| 504 | 512 | ||
| 513 | skip_metadata(ps); | ||
| 514 | |||
| 505 | return 0; | 515 | return 0; |
| 506 | } | 516 | } |
| 507 | 517 | ||
| @@ -616,8 +626,6 @@ static int persistent_prepare_exception(struct dm_exception_store *store, | |||
| 616 | struct dm_exception *e) | 626 | struct dm_exception *e) |
| 617 | { | 627 | { |
| 618 | struct pstore *ps = get_info(store); | 628 | struct pstore *ps = get_info(store); |
| 619 | uint32_t stride; | ||
| 620 | chunk_t next_free; | ||
| 621 | sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev); | 629 | sector_t size = get_dev_size(dm_snap_cow(store->snap)->bdev); |
| 622 | 630 | ||
| 623 | /* Is there enough room ? */ | 631 | /* Is there enough room ? */ |
| @@ -630,10 +638,8 @@ static int persistent_prepare_exception(struct dm_exception_store *store, | |||
| 630 | * Move onto the next free pending, making sure to take | 638 | * Move onto the next free pending, making sure to take |
| 631 | * into account the location of the metadata chunks. | 639 | * into account the location of the metadata chunks. |
| 632 | */ | 640 | */ |
| 633 | stride = (ps->exceptions_per_area + 1); | 641 | ps->next_free++; |
| 634 | next_free = ++ps->next_free; | 642 | skip_metadata(ps); |
| 635 | if (sector_div(next_free, stride) == 1) | ||
| 636 | ps->next_free++; | ||
| 637 | 643 | ||
| 638 | atomic_inc(&ps->pending_count); | 644 | atomic_inc(&ps->pending_count); |
| 639 | return 0; | 645 | return 0; |
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c index 2a9b100c4825..dbbf8ee3f592 100644 --- a/drivers/mfd/mc13xxx-core.c +++ b/drivers/mfd/mc13xxx-core.c | |||
| @@ -158,8 +158,6 @@ int mc13xxx_reg_read(struct mc13xxx *mc13xxx, unsigned int offset, u32 *val) | |||
| 158 | { | 158 | { |
| 159 | int ret; | 159 | int ret; |
| 160 | 160 | ||
| 161 | BUG_ON(!mutex_is_locked(&mc13xxx->lock)); | ||
| 162 | |||
| 163 | if (offset > MC13XXX_NUMREGS) | 161 | if (offset > MC13XXX_NUMREGS) |
| 164 | return -EINVAL; | 162 | return -EINVAL; |
| 165 | 163 | ||
| @@ -172,8 +170,6 @@ EXPORT_SYMBOL(mc13xxx_reg_read); | |||
| 172 | 170 | ||
| 173 | int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val) | 171 | int mc13xxx_reg_write(struct mc13xxx *mc13xxx, unsigned int offset, u32 val) |
| 174 | { | 172 | { |
| 175 | BUG_ON(!mutex_is_locked(&mc13xxx->lock)); | ||
| 176 | |||
| 177 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); | 173 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x\n", offset, val); |
| 178 | 174 | ||
| 179 | if (offset > MC13XXX_NUMREGS || val > 0xffffff) | 175 | if (offset > MC13XXX_NUMREGS || val > 0xffffff) |
| @@ -186,7 +182,6 @@ EXPORT_SYMBOL(mc13xxx_reg_write); | |||
| 186 | int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset, | 182 | int mc13xxx_reg_rmw(struct mc13xxx *mc13xxx, unsigned int offset, |
| 187 | u32 mask, u32 val) | 183 | u32 mask, u32 val) |
| 188 | { | 184 | { |
| 189 | BUG_ON(!mutex_is_locked(&mc13xxx->lock)); | ||
| 190 | BUG_ON(val & ~mask); | 185 | BUG_ON(val & ~mask); |
| 191 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n", | 186 | dev_vdbg(mc13xxx->dev, "[0x%02x] <- 0x%06x (mask: 0x%06x)\n", |
| 192 | offset, val, mask); | 187 | offset, val, mask); |
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c index 77189daadf1e..5f14ef6693c2 100644 --- a/drivers/mfd/mc13xxx-spi.c +++ b/drivers/mfd/mc13xxx-spi.c | |||
| @@ -94,10 +94,15 @@ static int mc13xxx_spi_write(void *context, const void *data, size_t count) | |||
| 94 | { | 94 | { |
| 95 | struct device *dev = context; | 95 | struct device *dev = context; |
| 96 | struct spi_device *spi = to_spi_device(dev); | 96 | struct spi_device *spi = to_spi_device(dev); |
| 97 | const char *reg = data; | ||
| 97 | 98 | ||
| 98 | if (count != 4) | 99 | if (count != 4) |
| 99 | return -ENOTSUPP; | 100 | return -ENOTSUPP; |
| 100 | 101 | ||
| 102 | /* include errata fix for spi audio problems */ | ||
| 103 | if (*reg == MC13783_AUDIO_CODEC || *reg == MC13783_AUDIO_DAC) | ||
| 104 | spi_write(spi, data, count); | ||
| 105 | |||
| 101 | return spi_write(spi, data, count); | 106 | return spi_write(spi, data, count); |
| 102 | } | 107 | } |
| 103 | 108 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c index 5472cbd34028..6ca30739625f 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/cmd.c | |||
| @@ -180,28 +180,32 @@ static int verify_block_sig(struct mlx5_cmd_prot_block *block) | |||
| 180 | return 0; | 180 | return 0; |
| 181 | } | 181 | } |
| 182 | 182 | ||
| 183 | static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token) | 183 | static void calc_block_sig(struct mlx5_cmd_prot_block *block, u8 token, |
| 184 | int csum) | ||
| 184 | { | 185 | { |
| 185 | block->token = token; | 186 | block->token = token; |
| 186 | block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - sizeof(block->data) - 2); | 187 | if (csum) { |
| 187 | block->sig = ~xor8_buf(block, sizeof(*block) - 1); | 188 | block->ctrl_sig = ~xor8_buf(block->rsvd0, sizeof(*block) - |
| 189 | sizeof(block->data) - 2); | ||
| 190 | block->sig = ~xor8_buf(block, sizeof(*block) - 1); | ||
| 191 | } | ||
| 188 | } | 192 | } |
| 189 | 193 | ||
| 190 | static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token) | 194 | static void calc_chain_sig(struct mlx5_cmd_msg *msg, u8 token, int csum) |
| 191 | { | 195 | { |
| 192 | struct mlx5_cmd_mailbox *next = msg->next; | 196 | struct mlx5_cmd_mailbox *next = msg->next; |
| 193 | 197 | ||
| 194 | while (next) { | 198 | while (next) { |
| 195 | calc_block_sig(next->buf, token); | 199 | calc_block_sig(next->buf, token, csum); |
| 196 | next = next->next; | 200 | next = next->next; |
| 197 | } | 201 | } |
| 198 | } | 202 | } |
| 199 | 203 | ||
| 200 | static void set_signature(struct mlx5_cmd_work_ent *ent) | 204 | static void set_signature(struct mlx5_cmd_work_ent *ent, int csum) |
| 201 | { | 205 | { |
| 202 | ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); | 206 | ent->lay->sig = ~xor8_buf(ent->lay, sizeof(*ent->lay)); |
| 203 | calc_chain_sig(ent->in, ent->token); | 207 | calc_chain_sig(ent->in, ent->token, csum); |
| 204 | calc_chain_sig(ent->out, ent->token); | 208 | calc_chain_sig(ent->out, ent->token, csum); |
| 205 | } | 209 | } |
| 206 | 210 | ||
| 207 | static void poll_timeout(struct mlx5_cmd_work_ent *ent) | 211 | static void poll_timeout(struct mlx5_cmd_work_ent *ent) |
| @@ -539,8 +543,7 @@ static void cmd_work_handler(struct work_struct *work) | |||
| 539 | lay->type = MLX5_PCI_CMD_XPORT; | 543 | lay->type = MLX5_PCI_CMD_XPORT; |
| 540 | lay->token = ent->token; | 544 | lay->token = ent->token; |
| 541 | lay->status_own = CMD_OWNER_HW; | 545 | lay->status_own = CMD_OWNER_HW; |
| 542 | if (!cmd->checksum_disabled) | 546 | set_signature(ent, !cmd->checksum_disabled); |
| 543 | set_signature(ent); | ||
| 544 | dump_command(dev, ent, 1); | 547 | dump_command(dev, ent, 1); |
| 545 | ktime_get_ts(&ent->ts1); | 548 | ktime_get_ts(&ent->ts1); |
| 546 | 549 | ||
| @@ -773,8 +776,6 @@ static int mlx5_copy_from_msg(void *to, struct mlx5_cmd_msg *from, int size) | |||
| 773 | 776 | ||
| 774 | copy = min_t(int, size, MLX5_CMD_DATA_BLOCK_SIZE); | 777 | copy = min_t(int, size, MLX5_CMD_DATA_BLOCK_SIZE); |
| 775 | block = next->buf; | 778 | block = next->buf; |
| 776 | if (xor8_buf(block, sizeof(*block)) != 0xff) | ||
| 777 | return -EINVAL; | ||
| 778 | 779 | ||
| 779 | memcpy(to, block->data, copy); | 780 | memcpy(to, block->data, copy); |
| 780 | to += copy; | 781 | to += copy; |
| @@ -1361,6 +1362,7 @@ int mlx5_cmd_init(struct mlx5_core_dev *dev) | |||
| 1361 | goto err_map; | 1362 | goto err_map; |
| 1362 | } | 1363 | } |
| 1363 | 1364 | ||
| 1365 | cmd->checksum_disabled = 1; | ||
| 1364 | cmd->max_reg_cmds = (1 << cmd->log_sz) - 1; | 1366 | cmd->max_reg_cmds = (1 << cmd->log_sz) - 1; |
| 1365 | cmd->bitmask = (1 << cmd->max_reg_cmds) - 1; | 1367 | cmd->bitmask = (1 << cmd->max_reg_cmds) - 1; |
| 1366 | 1368 | ||
| @@ -1510,7 +1512,7 @@ int mlx5_cmd_status_to_err(struct mlx5_outbox_hdr *hdr) | |||
| 1510 | case MLX5_CMD_STAT_BAD_SYS_STATE_ERR: return -EIO; | 1512 | case MLX5_CMD_STAT_BAD_SYS_STATE_ERR: return -EIO; |
| 1511 | case MLX5_CMD_STAT_BAD_RES_ERR: return -EINVAL; | 1513 | case MLX5_CMD_STAT_BAD_RES_ERR: return -EINVAL; |
| 1512 | case MLX5_CMD_STAT_RES_BUSY: return -EBUSY; | 1514 | case MLX5_CMD_STAT_RES_BUSY: return -EBUSY; |
| 1513 | case MLX5_CMD_STAT_LIM_ERR: return -EINVAL; | 1515 | case MLX5_CMD_STAT_LIM_ERR: return -ENOMEM; |
| 1514 | case MLX5_CMD_STAT_BAD_RES_STATE_ERR: return -EINVAL; | 1516 | case MLX5_CMD_STAT_BAD_RES_STATE_ERR: return -EINVAL; |
| 1515 | case MLX5_CMD_STAT_IX_ERR: return -EINVAL; | 1517 | case MLX5_CMD_STAT_IX_ERR: return -EINVAL; |
| 1516 | case MLX5_CMD_STAT_NO_RES_ERR: return -EAGAIN; | 1518 | case MLX5_CMD_STAT_NO_RES_ERR: return -EAGAIN; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c index 443cc4d7b024..2231d93cc7ad 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c | |||
| @@ -366,9 +366,11 @@ int mlx5_create_map_eq(struct mlx5_core_dev *dev, struct mlx5_eq *eq, u8 vecidx, | |||
| 366 | goto err_in; | 366 | goto err_in; |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | snprintf(eq->name, MLX5_MAX_EQ_NAME, "%s@pci:%s", | ||
| 370 | name, pci_name(dev->pdev)); | ||
| 369 | eq->eqn = out.eq_number; | 371 | eq->eqn = out.eq_number; |
| 370 | err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0, | 372 | err = request_irq(table->msix_arr[vecidx].vector, mlx5_msix_handler, 0, |
| 371 | name, eq); | 373 | eq->name, eq); |
| 372 | if (err) | 374 | if (err) |
| 373 | goto err_eq; | 375 | goto err_eq; |
| 374 | 376 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c index b47739b0b5f6..bc0f5fb66e24 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c | |||
| @@ -165,9 +165,7 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) | |||
| 165 | struct mlx5_cmd_set_hca_cap_mbox_in *set_ctx = NULL; | 165 | struct mlx5_cmd_set_hca_cap_mbox_in *set_ctx = NULL; |
| 166 | struct mlx5_cmd_query_hca_cap_mbox_in query_ctx; | 166 | struct mlx5_cmd_query_hca_cap_mbox_in query_ctx; |
| 167 | struct mlx5_cmd_set_hca_cap_mbox_out set_out; | 167 | struct mlx5_cmd_set_hca_cap_mbox_out set_out; |
| 168 | struct mlx5_profile *prof = dev->profile; | ||
| 169 | u64 flags; | 168 | u64 flags; |
| 170 | int csum = 1; | ||
| 171 | int err; | 169 | int err; |
| 172 | 170 | ||
| 173 | memset(&query_ctx, 0, sizeof(query_ctx)); | 171 | memset(&query_ctx, 0, sizeof(query_ctx)); |
| @@ -197,20 +195,14 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) | |||
| 197 | memcpy(&set_ctx->hca_cap, &query_out->hca_cap, | 195 | memcpy(&set_ctx->hca_cap, &query_out->hca_cap, |
| 198 | sizeof(set_ctx->hca_cap)); | 196 | sizeof(set_ctx->hca_cap)); |
| 199 | 197 | ||
| 200 | if (prof->mask & MLX5_PROF_MASK_CMDIF_CSUM) { | ||
| 201 | csum = !!prof->cmdif_csum; | ||
| 202 | flags = be64_to_cpu(set_ctx->hca_cap.flags); | ||
| 203 | if (csum) | ||
| 204 | flags |= MLX5_DEV_CAP_FLAG_CMDIF_CSUM; | ||
| 205 | else | ||
| 206 | flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM; | ||
| 207 | |||
| 208 | set_ctx->hca_cap.flags = cpu_to_be64(flags); | ||
| 209 | } | ||
| 210 | |||
| 211 | if (dev->profile->mask & MLX5_PROF_MASK_QP_SIZE) | 198 | if (dev->profile->mask & MLX5_PROF_MASK_QP_SIZE) |
| 212 | set_ctx->hca_cap.log_max_qp = dev->profile->log_max_qp; | 199 | set_ctx->hca_cap.log_max_qp = dev->profile->log_max_qp; |
| 213 | 200 | ||
| 201 | flags = be64_to_cpu(query_out->hca_cap.flags); | ||
| 202 | /* disable checksum */ | ||
| 203 | flags &= ~MLX5_DEV_CAP_FLAG_CMDIF_CSUM; | ||
| 204 | |||
| 205 | set_ctx->hca_cap.flags = cpu_to_be64(flags); | ||
| 214 | memset(&set_out, 0, sizeof(set_out)); | 206 | memset(&set_out, 0, sizeof(set_out)); |
| 215 | set_ctx->hca_cap.log_uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12); | 207 | set_ctx->hca_cap.log_uar_page_sz = cpu_to_be16(PAGE_SHIFT - 12); |
| 216 | set_ctx->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_SET_HCA_CAP); | 208 | set_ctx->hdr.opcode = cpu_to_be16(MLX5_CMD_OP_SET_HCA_CAP); |
| @@ -225,9 +217,6 @@ static int handle_hca_cap(struct mlx5_core_dev *dev) | |||
| 225 | if (err) | 217 | if (err) |
| 226 | goto query_ex; | 218 | goto query_ex; |
| 227 | 219 | ||
| 228 | if (!csum) | ||
| 229 | dev->cmd.checksum_disabled = 1; | ||
| 230 | |||
| 231 | query_ex: | 220 | query_ex: |
| 232 | kfree(query_out); | 221 | kfree(query_out); |
| 233 | kfree(set_ctx); | 222 | kfree(set_ctx); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c index 3a2408d44820..7b12acf210f8 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/pagealloc.c | |||
| @@ -90,6 +90,10 @@ struct mlx5_manage_pages_outbox { | |||
| 90 | __be64 pas[0]; | 90 | __be64 pas[0]; |
| 91 | }; | 91 | }; |
| 92 | 92 | ||
| 93 | enum { | ||
| 94 | MAX_RECLAIM_TIME_MSECS = 5000, | ||
| 95 | }; | ||
| 96 | |||
| 93 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) | 97 | static int insert_page(struct mlx5_core_dev *dev, u64 addr, struct page *page, u16 func_id) |
| 94 | { | 98 | { |
| 95 | struct rb_root *root = &dev->priv.page_root; | 99 | struct rb_root *root = &dev->priv.page_root; |
| @@ -279,6 +283,9 @@ static int reclaim_pages(struct mlx5_core_dev *dev, u32 func_id, int npages, | |||
| 279 | int err; | 283 | int err; |
| 280 | int i; | 284 | int i; |
| 281 | 285 | ||
| 286 | if (nclaimed) | ||
| 287 | *nclaimed = 0; | ||
| 288 | |||
| 282 | memset(&in, 0, sizeof(in)); | 289 | memset(&in, 0, sizeof(in)); |
| 283 | outlen = sizeof(*out) + npages * sizeof(out->pas[0]); | 290 | outlen = sizeof(*out) + npages * sizeof(out->pas[0]); |
| 284 | out = mlx5_vzalloc(outlen); | 291 | out = mlx5_vzalloc(outlen); |
| @@ -388,20 +395,25 @@ static int optimal_reclaimed_pages(void) | |||
| 388 | 395 | ||
| 389 | int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) | 396 | int mlx5_reclaim_startup_pages(struct mlx5_core_dev *dev) |
| 390 | { | 397 | { |
| 391 | unsigned long end = jiffies + msecs_to_jiffies(5000); | 398 | unsigned long end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS); |
| 392 | struct fw_page *fwp; | 399 | struct fw_page *fwp; |
| 393 | struct rb_node *p; | 400 | struct rb_node *p; |
| 401 | int nclaimed = 0; | ||
| 394 | int err; | 402 | int err; |
| 395 | 403 | ||
| 396 | do { | 404 | do { |
| 397 | p = rb_first(&dev->priv.page_root); | 405 | p = rb_first(&dev->priv.page_root); |
| 398 | if (p) { | 406 | if (p) { |
| 399 | fwp = rb_entry(p, struct fw_page, rb_node); | 407 | fwp = rb_entry(p, struct fw_page, rb_node); |
| 400 | err = reclaim_pages(dev, fwp->func_id, optimal_reclaimed_pages(), NULL); | 408 | err = reclaim_pages(dev, fwp->func_id, |
| 409 | optimal_reclaimed_pages(), | ||
| 410 | &nclaimed); | ||
| 401 | if (err) { | 411 | if (err) { |
| 402 | mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err); | 412 | mlx5_core_warn(dev, "failed reclaiming pages (%d)\n", err); |
| 403 | return err; | 413 | return err; |
| 404 | } | 414 | } |
| 415 | if (nclaimed) | ||
| 416 | end = jiffies + msecs_to_jiffies(MAX_RECLAIM_TIME_MSECS); | ||
| 405 | } | 417 | } |
| 406 | if (time_after(jiffies, end)) { | 418 | if (time_after(jiffies, end)) { |
| 407 | mlx5_core_warn(dev, "FW did not return all pages. giving up...\n"); | 419 | mlx5_core_warn(dev, "FW did not return all pages. giving up...\n"); |
diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index 9d2009a9004d..78cc76053328 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig | |||
| @@ -74,10 +74,4 @@ config OF_MTD | |||
| 74 | depends on MTD | 74 | depends on MTD |
| 75 | def_bool y | 75 | def_bool y |
| 76 | 76 | ||
| 77 | config OF_RESERVED_MEM | ||
| 78 | depends on OF_FLATTREE && (DMA_CMA || (HAVE_GENERIC_DMA_COHERENT && HAVE_MEMBLOCK)) | ||
| 79 | def_bool y | ||
| 80 | help | ||
| 81 | Initialization code for DMA reserved memory | ||
| 82 | |||
| 83 | endmenu # OF | 77 | endmenu # OF |
diff --git a/drivers/of/Makefile b/drivers/of/Makefile index ed9660adad77..efd05102c405 100644 --- a/drivers/of/Makefile +++ b/drivers/of/Makefile | |||
| @@ -9,4 +9,3 @@ obj-$(CONFIG_OF_MDIO) += of_mdio.o | |||
| 9 | obj-$(CONFIG_OF_PCI) += of_pci.o | 9 | obj-$(CONFIG_OF_PCI) += of_pci.o |
| 10 | obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o | 10 | obj-$(CONFIG_OF_PCI_IRQ) += of_pci_irq.o |
| 11 | obj-$(CONFIG_OF_MTD) += of_mtd.o | 11 | obj-$(CONFIG_OF_MTD) += of_mtd.o |
| 12 | obj-$(CONFIG_OF_RESERVED_MEM) += of_reserved_mem.o | ||
diff --git a/drivers/of/base.c b/drivers/of/base.c index 865d3f66c86b..7d4c70f859e3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c | |||
| @@ -303,10 +303,8 @@ struct device_node *of_get_cpu_node(int cpu, unsigned int *thread) | |||
| 303 | struct device_node *cpun, *cpus; | 303 | struct device_node *cpun, *cpus; |
| 304 | 304 | ||
| 305 | cpus = of_find_node_by_path("/cpus"); | 305 | cpus = of_find_node_by_path("/cpus"); |
| 306 | if (!cpus) { | 306 | if (!cpus) |
| 307 | pr_warn("Missing cpus node, bailing out\n"); | ||
| 308 | return NULL; | 307 | return NULL; |
| 309 | } | ||
| 310 | 308 | ||
| 311 | for_each_child_of_node(cpus, cpun) { | 309 | for_each_child_of_node(cpus, cpun) { |
| 312 | if (of_node_cmp(cpun->type, "cpu")) | 310 | if (of_node_cmp(cpun->type, "cpu")) |
diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index 229dd9d69e18..a4fa9ad31b8f 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c | |||
| @@ -18,7 +18,6 @@ | |||
| 18 | #include <linux/string.h> | 18 | #include <linux/string.h> |
| 19 | #include <linux/errno.h> | 19 | #include <linux/errno.h> |
| 20 | #include <linux/slab.h> | 20 | #include <linux/slab.h> |
| 21 | #include <linux/random.h> | ||
| 22 | 21 | ||
| 23 | #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ | 22 | #include <asm/setup.h> /* for COMMAND_LINE_SIZE */ |
| 24 | #ifdef CONFIG_PPC | 23 | #ifdef CONFIG_PPC |
| @@ -803,14 +802,3 @@ void __init unflatten_device_tree(void) | |||
| 803 | } | 802 | } |
| 804 | 803 | ||
| 805 | #endif /* CONFIG_OF_EARLY_FLATTREE */ | 804 | #endif /* CONFIG_OF_EARLY_FLATTREE */ |
| 806 | |||
| 807 | /* Feed entire flattened device tree into the random pool */ | ||
| 808 | static int __init add_fdt_randomness(void) | ||
| 809 | { | ||
| 810 | if (initial_boot_params) | ||
| 811 | add_device_randomness(initial_boot_params, | ||
| 812 | be32_to_cpu(initial_boot_params->totalsize)); | ||
| 813 | |||
| 814 | return 0; | ||
| 815 | } | ||
| 816 | core_initcall(add_fdt_randomness); | ||
diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c deleted file mode 100644 index 0fe40c7d6904..000000000000 --- a/drivers/of/of_reserved_mem.c +++ /dev/null | |||
| @@ -1,173 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Device tree based initialization code for reserved memory. | ||
| 3 | * | ||
| 4 | * Copyright (c) 2013 Samsung Electronics Co., Ltd. | ||
| 5 | * http://www.samsung.com | ||
| 6 | * Author: Marek Szyprowski <m.szyprowski@samsung.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 as | ||
| 10 | * published by the Free Software Foundation; either version 2 of the | ||
| 11 | * License or (at your optional) any later version of the license. | ||
| 12 | */ | ||
| 13 | |||
| 14 | #include <linux/memblock.h> | ||
| 15 | #include <linux/err.h> | ||
| 16 | #include <linux/of.h> | ||
| 17 | #include <linux/of_fdt.h> | ||
| 18 | #include <linux/of_platform.h> | ||
| 19 | #include <linux/mm.h> | ||
| 20 | #include <linux/sizes.h> | ||
| 21 | #include <linux/mm_types.h> | ||
| 22 | #include <linux/dma-contiguous.h> | ||
| 23 | #include <linux/dma-mapping.h> | ||
| 24 | #include <linux/of_reserved_mem.h> | ||
| 25 | |||
| 26 | #define MAX_RESERVED_REGIONS 16 | ||
| 27 | struct reserved_mem { | ||
| 28 | phys_addr_t base; | ||
| 29 | unsigned long size; | ||
| 30 | struct cma *cma; | ||
| 31 | char name[32]; | ||
| 32 | }; | ||
| 33 | static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; | ||
| 34 | static int reserved_mem_count; | ||
| 35 | |||
| 36 | static int __init fdt_scan_reserved_mem(unsigned long node, const char *uname, | ||
| 37 | int depth, void *data) | ||
| 38 | { | ||
| 39 | struct reserved_mem *rmem = &reserved_mem[reserved_mem_count]; | ||
| 40 | phys_addr_t base, size; | ||
| 41 | int is_cma, is_reserved; | ||
| 42 | unsigned long len; | ||
| 43 | const char *status; | ||
| 44 | __be32 *prop; | ||
| 45 | |||
| 46 | is_cma = IS_ENABLED(CONFIG_DMA_CMA) && | ||
| 47 | of_flat_dt_is_compatible(node, "linux,contiguous-memory-region"); | ||
| 48 | is_reserved = of_flat_dt_is_compatible(node, "reserved-memory-region"); | ||
| 49 | |||
| 50 | if (!is_reserved && !is_cma) { | ||
| 51 | /* ignore node and scan next one */ | ||
| 52 | return 0; | ||
| 53 | } | ||
| 54 | |||
| 55 | status = of_get_flat_dt_prop(node, "status", &len); | ||
| 56 | if (status && strcmp(status, "okay") != 0) { | ||
| 57 | /* ignore disabled node nad scan next one */ | ||
| 58 | return 0; | ||
| 59 | } | ||
| 60 | |||
| 61 | prop = of_get_flat_dt_prop(node, "reg", &len); | ||
| 62 | if (!prop || (len < (dt_root_size_cells + dt_root_addr_cells) * | ||
| 63 | sizeof(__be32))) { | ||
| 64 | pr_err("Reserved mem: node %s, incorrect \"reg\" property\n", | ||
| 65 | uname); | ||
| 66 | /* ignore node and scan next one */ | ||
| 67 | return 0; | ||
| 68 | } | ||
| 69 | base = dt_mem_next_cell(dt_root_addr_cells, &prop); | ||
| 70 | size = dt_mem_next_cell(dt_root_size_cells, &prop); | ||
| 71 | |||
| 72 | if (!size) { | ||
| 73 | /* ignore node and scan next one */ | ||
| 74 | return 0; | ||
| 75 | } | ||
| 76 | |||
| 77 | pr_info("Reserved mem: found %s, memory base %lx, size %ld MiB\n", | ||
| 78 | uname, (unsigned long)base, (unsigned long)size / SZ_1M); | ||
| 79 | |||
| 80 | if (reserved_mem_count == ARRAY_SIZE(reserved_mem)) | ||
| 81 | return -ENOSPC; | ||
| 82 | |||
| 83 | rmem->base = base; | ||
| 84 | rmem->size = size; | ||
| 85 | strlcpy(rmem->name, uname, sizeof(rmem->name)); | ||
| 86 | |||
| 87 | if (is_cma) { | ||
| 88 | struct cma *cma; | ||
| 89 | if (dma_contiguous_reserve_area(size, base, 0, &cma) == 0) { | ||
| 90 | rmem->cma = cma; | ||
| 91 | reserved_mem_count++; | ||
| 92 | if (of_get_flat_dt_prop(node, | ||
| 93 | "linux,default-contiguous-region", | ||
| 94 | NULL)) | ||
| 95 | dma_contiguous_set_default(cma); | ||
| 96 | } | ||
| 97 | } else if (is_reserved) { | ||
| 98 | if (memblock_remove(base, size) == 0) | ||
| 99 | reserved_mem_count++; | ||
| 100 | else | ||
| 101 | pr_err("Failed to reserve memory for %s\n", uname); | ||
| 102 | } | ||
| 103 | |||
| 104 | return 0; | ||
| 105 | } | ||
| 106 | |||
| 107 | static struct reserved_mem *get_dma_memory_region(struct device *dev) | ||
| 108 | { | ||
| 109 | struct device_node *node; | ||
| 110 | const char *name; | ||
| 111 | int i; | ||
| 112 | |||
| 113 | node = of_parse_phandle(dev->of_node, "memory-region", 0); | ||
| 114 | if (!node) | ||
| 115 | return NULL; | ||
| 116 | |||
| 117 | name = kbasename(node->full_name); | ||
| 118 | for (i = 0; i < reserved_mem_count; i++) | ||
| 119 | if (strcmp(name, reserved_mem[i].name) == 0) | ||
| 120 | return &reserved_mem[i]; | ||
| 121 | return NULL; | ||
| 122 | } | ||
| 123 | |||
| 124 | /** | ||
| 125 | * of_reserved_mem_device_init() - assign reserved memory region to given device | ||
| 126 | * | ||
| 127 | * This function assign memory region pointed by "memory-region" device tree | ||
| 128 | * property to the given device. | ||
| 129 | */ | ||
| 130 | void of_reserved_mem_device_init(struct device *dev) | ||
| 131 | { | ||
| 132 | struct reserved_mem *region = get_dma_memory_region(dev); | ||
| 133 | if (!region) | ||
| 134 | return; | ||
| 135 | |||
| 136 | if (region->cma) { | ||
| 137 | dev_set_cma_area(dev, region->cma); | ||
| 138 | pr_info("Assigned CMA %s to %s device\n", region->name, | ||
| 139 | dev_name(dev)); | ||
| 140 | } else { | ||
| 141 | if (dma_declare_coherent_memory(dev, region->base, region->base, | ||
| 142 | region->size, DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE) != 0) | ||
| 143 | pr_info("Declared reserved memory %s to %s device\n", | ||
| 144 | region->name, dev_name(dev)); | ||
| 145 | } | ||
| 146 | } | ||
| 147 | |||
| 148 | /** | ||
| 149 | * of_reserved_mem_device_release() - release reserved memory device structures | ||
| 150 | * | ||
| 151 | * This function releases structures allocated for memory region handling for | ||
| 152 | * the given device. | ||
| 153 | */ | ||
| 154 | void of_reserved_mem_device_release(struct device *dev) | ||
| 155 | { | ||
| 156 | struct reserved_mem *region = get_dma_memory_region(dev); | ||
| 157 | if (!region && !region->cma) | ||
| 158 | dma_release_declared_memory(dev); | ||
| 159 | } | ||
| 160 | |||
| 161 | /** | ||
| 162 | * early_init_dt_scan_reserved_mem() - create reserved memory regions | ||
| 163 | * | ||
| 164 | * This function grabs memory from early allocator for device exclusive use | ||
| 165 | * defined in device tree structures. It should be called by arch specific code | ||
| 166 | * once the early allocator (memblock) has been activated and all other | ||
| 167 | * subsystems have already allocated/reserved memory. | ||
| 168 | */ | ||
| 169 | void __init early_init_dt_scan_reserved_mem(void) | ||
| 170 | { | ||
| 171 | of_scan_flat_dt_by_path("/memory/reserved-memory", | ||
| 172 | fdt_scan_reserved_mem, NULL); | ||
| 173 | } | ||
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 9b439ac63d8e..f6dcde220821 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
| @@ -21,7 +21,6 @@ | |||
| 21 | #include <linux/of_device.h> | 21 | #include <linux/of_device.h> |
| 22 | #include <linux/of_irq.h> | 22 | #include <linux/of_irq.h> |
| 23 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
| 24 | #include <linux/of_reserved_mem.h> | ||
| 25 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
| 26 | 25 | ||
| 27 | const struct of_device_id of_default_bus_match_table[] = { | 26 | const struct of_device_id of_default_bus_match_table[] = { |
| @@ -219,8 +218,6 @@ static struct platform_device *of_platform_device_create_pdata( | |||
| 219 | dev->dev.bus = &platform_bus_type; | 218 | dev->dev.bus = &platform_bus_type; |
| 220 | dev->dev.platform_data = platform_data; | 219 | dev->dev.platform_data = platform_data; |
| 221 | 220 | ||
| 222 | of_reserved_mem_device_init(&dev->dev); | ||
| 223 | |||
| 224 | /* We do not fill the DMA ops for platform devices by default. | 221 | /* We do not fill the DMA ops for platform devices by default. |
| 225 | * This is currently the responsibility of the platform code | 222 | * This is currently the responsibility of the platform code |
| 226 | * to do such, possibly using a device notifier | 223 | * to do such, possibly using a device notifier |
| @@ -228,7 +225,6 @@ static struct platform_device *of_platform_device_create_pdata( | |||
| 228 | 225 | ||
| 229 | if (of_device_add(dev) != 0) { | 226 | if (of_device_add(dev) != 0) { |
| 230 | platform_device_put(dev); | 227 | platform_device_put(dev); |
| 231 | of_reserved_mem_device_release(&dev->dev); | ||
| 232 | return NULL; | 228 | return NULL; |
| 233 | } | 229 | } |
| 234 | 230 | ||
diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index 0b7d23b4ad95..be12fbfcae10 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c | |||
| @@ -994,14 +994,16 @@ void acpiphp_enumerate_slots(struct pci_bus *bus) | |||
| 994 | 994 | ||
| 995 | /* | 995 | /* |
| 996 | * This bridge should have been registered as a hotplug function | 996 | * This bridge should have been registered as a hotplug function |
| 997 | * under its parent, so the context has to be there. If not, we | 997 | * under its parent, so the context should be there, unless the |
| 998 | * are in deep goo. | 998 | * parent is going to be handled by pciehp, in which case this |
| 999 | * bridge is not interesting to us either. | ||
| 999 | */ | 1000 | */ |
| 1000 | mutex_lock(&acpiphp_context_lock); | 1001 | mutex_lock(&acpiphp_context_lock); |
| 1001 | context = acpiphp_get_context(handle); | 1002 | context = acpiphp_get_context(handle); |
| 1002 | if (WARN_ON(!context)) { | 1003 | if (!context) { |
| 1003 | mutex_unlock(&acpiphp_context_lock); | 1004 | mutex_unlock(&acpiphp_context_lock); |
| 1004 | put_device(&bus->dev); | 1005 | put_device(&bus->dev); |
| 1006 | pci_dev_put(bridge->pci_dev); | ||
| 1005 | kfree(bridge); | 1007 | kfree(bridge); |
| 1006 | return; | 1008 | return; |
| 1007 | } | 1009 | } |
diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c index a0ebbc9ce5cd..042aa077b5b3 100644 --- a/drivers/tty/serial/imx.c +++ b/drivers/tty/serial/imx.c | |||
| @@ -1912,9 +1912,6 @@ static int serial_imx_probe_dt(struct imx_port *sport, | |||
| 1912 | 1912 | ||
| 1913 | sport->devdata = of_id->data; | 1913 | sport->devdata = of_id->data; |
| 1914 | 1914 | ||
| 1915 | if (of_device_is_stdout_path(np)) | ||
| 1916 | add_preferred_console(imx_reg.cons->name, sport->port.line, 0); | ||
| 1917 | |||
| 1918 | return 0; | 1915 | return 0; |
| 1919 | } | 1916 | } |
| 1920 | #else | 1917 | #else |
diff --git a/drivers/tty/serial/vt8500_serial.c b/drivers/tty/serial/vt8500_serial.c index 93b697a0de65..15ad6fcda88b 100644 --- a/drivers/tty/serial/vt8500_serial.c +++ b/drivers/tty/serial/vt8500_serial.c | |||
| @@ -561,12 +561,13 @@ static int vt8500_serial_probe(struct platform_device *pdev) | |||
| 561 | if (!mmres || !irqres) | 561 | if (!mmres || !irqres) |
| 562 | return -ENODEV; | 562 | return -ENODEV; |
| 563 | 563 | ||
| 564 | if (np) | 564 | if (np) { |
| 565 | port = of_alias_get_id(np, "serial"); | 565 | port = of_alias_get_id(np, "serial"); |
| 566 | if (port >= VT8500_MAX_PORTS) | 566 | if (port >= VT8500_MAX_PORTS) |
| 567 | port = -1; | 567 | port = -1; |
| 568 | else | 568 | } else { |
| 569 | port = -1; | 569 | port = -1; |
| 570 | } | ||
| 570 | 571 | ||
| 571 | if (port < 0) { | 572 | if (port < 0) { |
| 572 | /* calculate the port id */ | 573 | /* calculate the port id */ |
diff --git a/drivers/usb/chipidea/host.c b/drivers/usb/chipidea/host.c index 6f96795dd20c..64d7a6d9a1ad 100644 --- a/drivers/usb/chipidea/host.c +++ b/drivers/usb/chipidea/host.c | |||
| @@ -100,8 +100,10 @@ static void host_stop(struct ci_hdrc *ci) | |||
| 100 | { | 100 | { |
| 101 | struct usb_hcd *hcd = ci->hcd; | 101 | struct usb_hcd *hcd = ci->hcd; |
| 102 | 102 | ||
| 103 | usb_remove_hcd(hcd); | 103 | if (hcd) { |
| 104 | usb_put_hcd(hcd); | 104 | usb_remove_hcd(hcd); |
| 105 | usb_put_hcd(hcd); | ||
| 106 | } | ||
| 105 | if (ci->platdata->reg_vbus) | 107 | if (ci->platdata->reg_vbus) |
| 106 | regulator_disable(ci->platdata->reg_vbus); | 108 | regulator_disable(ci->platdata->reg_vbus); |
| 107 | } | 109 | } |
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c index 5b44cd47da5b..01fe36273f3b 100644 --- a/drivers/usb/core/quirks.c +++ b/drivers/usb/core/quirks.c | |||
| @@ -97,6 +97,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
| 97 | /* Alcor Micro Corp. Hub */ | 97 | /* Alcor Micro Corp. Hub */ |
| 98 | { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, | 98 | { USB_DEVICE(0x058f, 0x9254), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 99 | 99 | ||
| 100 | /* MicroTouch Systems touchscreen */ | ||
| 101 | { USB_DEVICE(0x0596, 0x051e), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
| 102 | |||
| 100 | /* appletouch */ | 103 | /* appletouch */ |
| 101 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, | 104 | { USB_DEVICE(0x05ac, 0x021a), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 102 | 105 | ||
| @@ -130,6 +133,9 @@ static const struct usb_device_id usb_quirk_list[] = { | |||
| 130 | /* Broadcom BCM92035DGROM BT dongle */ | 133 | /* Broadcom BCM92035DGROM BT dongle */ |
| 131 | { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, | 134 | { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, |
| 132 | 135 | ||
| 136 | /* MAYA44USB sound device */ | ||
| 137 | { USB_DEVICE(0x0a92, 0x0091), .driver_info = USB_QUIRK_RESET_RESUME }, | ||
| 138 | |||
| 133 | /* Action Semiconductor flash disk */ | 139 | /* Action Semiconductor flash disk */ |
| 134 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = | 140 | { USB_DEVICE(0x10d6, 0x2200), .driver_info = |
| 135 | USB_QUIRK_STRING_FETCH_255 }, | 141 | USB_QUIRK_STRING_FETCH_255 }, |
diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index 2c76ef1320ea..08ef2829a7e2 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c | |||
| @@ -799,7 +799,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) | |||
| 799 | * switchable ports. | 799 | * switchable ports. |
| 800 | */ | 800 | */ |
| 801 | pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, | 801 | pci_write_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, |
| 802 | cpu_to_le32(ports_available)); | 802 | ports_available); |
| 803 | 803 | ||
| 804 | pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, | 804 | pci_read_config_dword(xhci_pdev, USB_INTEL_USB3_PSSEN, |
| 805 | &ports_available); | 805 | &ports_available); |
| @@ -821,7 +821,7 @@ void usb_enable_intel_xhci_ports(struct pci_dev *xhci_pdev) | |||
| 821 | * host. | 821 | * host. |
| 822 | */ | 822 | */ |
| 823 | pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, | 823 | pci_write_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, |
| 824 | cpu_to_le32(ports_available)); | 824 | ports_available); |
| 825 | 825 | ||
| 826 | pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, | 826 | pci_read_config_dword(xhci_pdev, USB_INTEL_XUSB2PR, |
| 827 | &ports_available); | 827 | &ports_available); |
diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 773a6b28c4f1..e8b4c56dcf62 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c | |||
| @@ -1157,18 +1157,6 @@ int xhci_bus_suspend(struct usb_hcd *hcd) | |||
| 1157 | t1 = xhci_port_state_to_neutral(t1); | 1157 | t1 = xhci_port_state_to_neutral(t1); |
| 1158 | if (t1 != t2) | 1158 | if (t1 != t2) |
| 1159 | xhci_writel(xhci, t2, port_array[port_index]); | 1159 | xhci_writel(xhci, t2, port_array[port_index]); |
| 1160 | |||
| 1161 | if (hcd->speed != HCD_USB3) { | ||
| 1162 | /* enable remote wake up for USB 2.0 */ | ||
| 1163 | __le32 __iomem *addr; | ||
| 1164 | u32 tmp; | ||
| 1165 | |||
| 1166 | /* Get the port power control register address. */ | ||
| 1167 | addr = port_array[port_index] + PORTPMSC; | ||
| 1168 | tmp = xhci_readl(xhci, addr); | ||
| 1169 | tmp |= PORT_RWE; | ||
| 1170 | xhci_writel(xhci, tmp, addr); | ||
| 1171 | } | ||
| 1172 | } | 1160 | } |
| 1173 | hcd->state = HC_STATE_SUSPENDED; | 1161 | hcd->state = HC_STATE_SUSPENDED; |
| 1174 | bus_state->next_statechange = jiffies + msecs_to_jiffies(10); | 1162 | bus_state->next_statechange = jiffies + msecs_to_jiffies(10); |
| @@ -1247,20 +1235,6 @@ int xhci_bus_resume(struct usb_hcd *hcd) | |||
| 1247 | xhci_ring_device(xhci, slot_id); | 1235 | xhci_ring_device(xhci, slot_id); |
| 1248 | } else | 1236 | } else |
| 1249 | xhci_writel(xhci, temp, port_array[port_index]); | 1237 | xhci_writel(xhci, temp, port_array[port_index]); |
| 1250 | |||
| 1251 | if (hcd->speed != HCD_USB3) { | ||
| 1252 | /* disable remote wake up for USB 2.0 */ | ||
| 1253 | __le32 __iomem *addr; | ||
| 1254 | u32 tmp; | ||
| 1255 | |||
| 1256 | /* Add one to the port status register address to get | ||
| 1257 | * the port power control register address. | ||
| 1258 | */ | ||
| 1259 | addr = port_array[port_index] + PORTPMSC; | ||
| 1260 | tmp = xhci_readl(xhci, addr); | ||
| 1261 | tmp &= ~PORT_RWE; | ||
| 1262 | xhci_writel(xhci, tmp, addr); | ||
| 1263 | } | ||
| 1264 | } | 1238 | } |
| 1265 | 1239 | ||
| 1266 | (void) xhci_readl(xhci, &xhci->op_regs->command); | 1240 | (void) xhci_readl(xhci, &xhci->op_regs->command); |
diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c index 236c3aabe940..b8dffd59eb25 100644 --- a/drivers/usb/host/xhci-pci.c +++ b/drivers/usb/host/xhci-pci.c | |||
| @@ -35,6 +35,9 @@ | |||
| 35 | #define PCI_VENDOR_ID_ETRON 0x1b6f | 35 | #define PCI_VENDOR_ID_ETRON 0x1b6f |
| 36 | #define PCI_DEVICE_ID_ASROCK_P67 0x7023 | 36 | #define PCI_DEVICE_ID_ASROCK_P67 0x7023 |
| 37 | 37 | ||
| 38 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI 0x8c31 | ||
| 39 | #define PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI 0x9c31 | ||
| 40 | |||
| 38 | static const char hcd_name[] = "xhci_hcd"; | 41 | static const char hcd_name[] = "xhci_hcd"; |
| 39 | 42 | ||
| 40 | /* called after powerup, by probe or system-pm "wakeup" */ | 43 | /* called after powerup, by probe or system-pm "wakeup" */ |
| @@ -69,6 +72,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
| 69 | "QUIRK: Fresco Logic xHC needs configure" | 72 | "QUIRK: Fresco Logic xHC needs configure" |
| 70 | " endpoint cmd after reset endpoint"); | 73 | " endpoint cmd after reset endpoint"); |
| 71 | } | 74 | } |
| 75 | if (pdev->device == PCI_DEVICE_ID_FRESCO_LOGIC_PDK && | ||
| 76 | pdev->revision == 0x4) { | ||
| 77 | xhci->quirks |= XHCI_SLOW_SUSPEND; | ||
| 78 | xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, | ||
| 79 | "QUIRK: Fresco Logic xHC revision %u" | ||
| 80 | "must be suspended extra slowly", | ||
| 81 | pdev->revision); | ||
| 82 | } | ||
| 72 | /* Fresco Logic confirms: all revisions of this chip do not | 83 | /* Fresco Logic confirms: all revisions of this chip do not |
| 73 | * support MSI, even though some of them claim to in their PCI | 84 | * support MSI, even though some of them claim to in their PCI |
| 74 | * capabilities. | 85 | * capabilities. |
| @@ -110,6 +121,15 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) | |||
| 110 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; | 121 | xhci->quirks |= XHCI_SPURIOUS_REBOOT; |
| 111 | xhci->quirks |= XHCI_AVOID_BEI; | 122 | xhci->quirks |= XHCI_AVOID_BEI; |
| 112 | } | 123 | } |
| 124 | if (pdev->vendor == PCI_VENDOR_ID_INTEL && | ||
| 125 | (pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_XHCI || | ||
| 126 | pdev->device == PCI_DEVICE_ID_INTEL_LYNXPOINT_LP_XHCI)) { | ||
| 127 | /* Workaround for occasional spurious wakeups from S5 (or | ||
| 128 | * any other sleep) on Haswell machines with LPT and LPT-LP | ||
| 129 | * with the new Intel BIOS | ||
| 130 | */ | ||
| 131 | xhci->quirks |= XHCI_SPURIOUS_WAKEUP; | ||
| 132 | } | ||
| 113 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && | 133 | if (pdev->vendor == PCI_VENDOR_ID_ETRON && |
| 114 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { | 134 | pdev->device == PCI_DEVICE_ID_ASROCK_P67) { |
| 115 | xhci->quirks |= XHCI_RESET_ON_RESUME; | 135 | xhci->quirks |= XHCI_RESET_ON_RESUME; |
| @@ -217,6 +237,11 @@ static void xhci_pci_remove(struct pci_dev *dev) | |||
| 217 | usb_put_hcd(xhci->shared_hcd); | 237 | usb_put_hcd(xhci->shared_hcd); |
| 218 | } | 238 | } |
| 219 | usb_hcd_pci_remove(dev); | 239 | usb_hcd_pci_remove(dev); |
| 240 | |||
| 241 | /* Workaround for spurious wakeups at shutdown with HSW */ | ||
| 242 | if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) | ||
| 243 | pci_set_power_state(dev, PCI_D3hot); | ||
| 244 | |||
| 220 | kfree(xhci); | 245 | kfree(xhci); |
| 221 | } | 246 | } |
| 222 | 247 | ||
diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 1e36dbb48366..6e0d886bcce5 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c | |||
| @@ -730,6 +730,9 @@ void xhci_shutdown(struct usb_hcd *hcd) | |||
| 730 | 730 | ||
| 731 | spin_lock_irq(&xhci->lock); | 731 | spin_lock_irq(&xhci->lock); |
| 732 | xhci_halt(xhci); | 732 | xhci_halt(xhci); |
| 733 | /* Workaround for spurious wakeups at shutdown with HSW */ | ||
| 734 | if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) | ||
| 735 | xhci_reset(xhci); | ||
| 733 | spin_unlock_irq(&xhci->lock); | 736 | spin_unlock_irq(&xhci->lock); |
| 734 | 737 | ||
| 735 | xhci_cleanup_msix(xhci); | 738 | xhci_cleanup_msix(xhci); |
| @@ -737,6 +740,10 @@ void xhci_shutdown(struct usb_hcd *hcd) | |||
| 737 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, | 740 | xhci_dbg_trace(xhci, trace_xhci_dbg_init, |
| 738 | "xhci_shutdown completed - status = %x", | 741 | "xhci_shutdown completed - status = %x", |
| 739 | xhci_readl(xhci, &xhci->op_regs->status)); | 742 | xhci_readl(xhci, &xhci->op_regs->status)); |
| 743 | |||
| 744 | /* Yet another workaround for spurious wakeups at shutdown with HSW */ | ||
| 745 | if (xhci->quirks & XHCI_SPURIOUS_WAKEUP) | ||
| 746 | pci_set_power_state(to_pci_dev(hcd->self.controller), PCI_D3hot); | ||
| 740 | } | 747 | } |
| 741 | 748 | ||
| 742 | #ifdef CONFIG_PM | 749 | #ifdef CONFIG_PM |
| @@ -839,6 +846,7 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci) | |||
| 839 | int xhci_suspend(struct xhci_hcd *xhci) | 846 | int xhci_suspend(struct xhci_hcd *xhci) |
| 840 | { | 847 | { |
| 841 | int rc = 0; | 848 | int rc = 0; |
| 849 | unsigned int delay = XHCI_MAX_HALT_USEC; | ||
| 842 | struct usb_hcd *hcd = xhci_to_hcd(xhci); | 850 | struct usb_hcd *hcd = xhci_to_hcd(xhci); |
| 843 | u32 command; | 851 | u32 command; |
| 844 | 852 | ||
| @@ -861,8 +869,12 @@ int xhci_suspend(struct xhci_hcd *xhci) | |||
| 861 | command = xhci_readl(xhci, &xhci->op_regs->command); | 869 | command = xhci_readl(xhci, &xhci->op_regs->command); |
| 862 | command &= ~CMD_RUN; | 870 | command &= ~CMD_RUN; |
| 863 | xhci_writel(xhci, command, &xhci->op_regs->command); | 871 | xhci_writel(xhci, command, &xhci->op_regs->command); |
| 872 | |||
| 873 | /* Some chips from Fresco Logic need an extraordinary delay */ | ||
| 874 | delay *= (xhci->quirks & XHCI_SLOW_SUSPEND) ? 10 : 1; | ||
| 875 | |||
| 864 | if (xhci_handshake(xhci, &xhci->op_regs->status, | 876 | if (xhci_handshake(xhci, &xhci->op_regs->status, |
| 865 | STS_HALT, STS_HALT, XHCI_MAX_HALT_USEC)) { | 877 | STS_HALT, STS_HALT, delay)) { |
| 866 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); | 878 | xhci_warn(xhci, "WARN: xHC CMD_RUN timeout\n"); |
| 867 | spin_unlock_irq(&xhci->lock); | 879 | spin_unlock_irq(&xhci->lock); |
| 868 | return -ETIMEDOUT; | 880 | return -ETIMEDOUT; |
diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index 289fbfbae746..941d5f59e4dc 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h | |||
| @@ -1548,6 +1548,8 @@ struct xhci_hcd { | |||
| 1548 | #define XHCI_COMP_MODE_QUIRK (1 << 14) | 1548 | #define XHCI_COMP_MODE_QUIRK (1 << 14) |
| 1549 | #define XHCI_AVOID_BEI (1 << 15) | 1549 | #define XHCI_AVOID_BEI (1 << 15) |
| 1550 | #define XHCI_PLAT (1 << 16) | 1550 | #define XHCI_PLAT (1 << 16) |
| 1551 | #define XHCI_SLOW_SUSPEND (1 << 17) | ||
| 1552 | #define XHCI_SPURIOUS_WAKEUP (1 << 18) | ||
| 1551 | unsigned int num_active_eps; | 1553 | unsigned int num_active_eps; |
| 1552 | unsigned int limit_active_eps; | 1554 | unsigned int limit_active_eps; |
| 1553 | /* There are two roothubs to keep track of bus suspend info for */ | 1555 | /* There are two roothubs to keep track of bus suspend info for */ |
diff --git a/drivers/usb/misc/Kconfig b/drivers/usb/misc/Kconfig index e2b21c1d9c40..ba5f70f92888 100644 --- a/drivers/usb/misc/Kconfig +++ b/drivers/usb/misc/Kconfig | |||
| @@ -246,6 +246,6 @@ config USB_EZUSB_FX2 | |||
| 246 | config USB_HSIC_USB3503 | 246 | config USB_HSIC_USB3503 |
| 247 | tristate "USB3503 HSIC to USB20 Driver" | 247 | tristate "USB3503 HSIC to USB20 Driver" |
| 248 | depends on I2C | 248 | depends on I2C |
| 249 | select REGMAP | 249 | select REGMAP_I2C |
| 250 | help | 250 | help |
| 251 | This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver. | 251 | This option enables support for SMSC USB3503 HSIC to USB 2.0 Driver. |
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 18e877ffe7b7..cd70cc886171 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c | |||
| @@ -922,6 +922,52 @@ static void musb_generic_disable(struct musb *musb) | |||
| 922 | } | 922 | } |
| 923 | 923 | ||
| 924 | /* | 924 | /* |
| 925 | * Program the HDRC to start (enable interrupts, dma, etc.). | ||
| 926 | */ | ||
| 927 | void musb_start(struct musb *musb) | ||
| 928 | { | ||
| 929 | void __iomem *regs = musb->mregs; | ||
| 930 | u8 devctl = musb_readb(regs, MUSB_DEVCTL); | ||
| 931 | |||
| 932 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); | ||
| 933 | |||
| 934 | /* Set INT enable registers, enable interrupts */ | ||
| 935 | musb->intrtxe = musb->epmask; | ||
| 936 | musb_writew(regs, MUSB_INTRTXE, musb->intrtxe); | ||
| 937 | musb->intrrxe = musb->epmask & 0xfffe; | ||
| 938 | musb_writew(regs, MUSB_INTRRXE, musb->intrrxe); | ||
| 939 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); | ||
| 940 | |||
| 941 | musb_writeb(regs, MUSB_TESTMODE, 0); | ||
| 942 | |||
| 943 | /* put into basic highspeed mode and start session */ | ||
| 944 | musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE | ||
| 945 | | MUSB_POWER_HSENAB | ||
| 946 | /* ENSUSPEND wedges tusb */ | ||
| 947 | /* | MUSB_POWER_ENSUSPEND */ | ||
| 948 | ); | ||
| 949 | |||
| 950 | musb->is_active = 0; | ||
| 951 | devctl = musb_readb(regs, MUSB_DEVCTL); | ||
| 952 | devctl &= ~MUSB_DEVCTL_SESSION; | ||
| 953 | |||
| 954 | /* session started after: | ||
| 955 | * (a) ID-grounded irq, host mode; | ||
| 956 | * (b) vbus present/connect IRQ, peripheral mode; | ||
| 957 | * (c) peripheral initiates, using SRP | ||
| 958 | */ | ||
| 959 | if (musb->port_mode != MUSB_PORT_MODE_HOST && | ||
| 960 | (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) { | ||
| 961 | musb->is_active = 1; | ||
| 962 | } else { | ||
| 963 | devctl |= MUSB_DEVCTL_SESSION; | ||
| 964 | } | ||
| 965 | |||
| 966 | musb_platform_enable(musb); | ||
| 967 | musb_writeb(regs, MUSB_DEVCTL, devctl); | ||
| 968 | } | ||
| 969 | |||
| 970 | /* | ||
| 925 | * Make the HDRC stop (disable interrupts, etc.); | 971 | * Make the HDRC stop (disable interrupts, etc.); |
| 926 | * reversible by musb_start | 972 | * reversible by musb_start |
| 927 | * called on gadget driver unregister | 973 | * called on gadget driver unregister |
diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 65f3917b4fc5..1c5bf75ee8ff 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h | |||
| @@ -503,6 +503,7 @@ static inline void musb_configure_ep0(struct musb *musb) | |||
| 503 | extern const char musb_driver_name[]; | 503 | extern const char musb_driver_name[]; |
| 504 | 504 | ||
| 505 | extern void musb_stop(struct musb *musb); | 505 | extern void musb_stop(struct musb *musb); |
| 506 | extern void musb_start(struct musb *musb); | ||
| 506 | 507 | ||
| 507 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); | 508 | extern void musb_write_fifo(struct musb_hw_ep *ep, u16 len, const u8 *src); |
| 508 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); | 509 | extern void musb_read_fifo(struct musb_hw_ep *ep, u16 len, u8 *dst); |
diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index b19ed213ab85..3671898a4535 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c | |||
| @@ -1853,11 +1853,14 @@ static int musb_gadget_start(struct usb_gadget *g, | |||
| 1853 | musb->gadget_driver = driver; | 1853 | musb->gadget_driver = driver; |
| 1854 | 1854 | ||
| 1855 | spin_lock_irqsave(&musb->lock, flags); | 1855 | spin_lock_irqsave(&musb->lock, flags); |
| 1856 | musb->is_active = 1; | ||
| 1856 | 1857 | ||
| 1857 | otg_set_peripheral(otg, &musb->g); | 1858 | otg_set_peripheral(otg, &musb->g); |
| 1858 | musb->xceiv->state = OTG_STATE_B_IDLE; | 1859 | musb->xceiv->state = OTG_STATE_B_IDLE; |
| 1859 | spin_unlock_irqrestore(&musb->lock, flags); | 1860 | spin_unlock_irqrestore(&musb->lock, flags); |
| 1860 | 1861 | ||
| 1862 | musb_start(musb); | ||
| 1863 | |||
| 1861 | /* REVISIT: funcall to other code, which also | 1864 | /* REVISIT: funcall to other code, which also |
| 1862 | * handles power budgeting ... this way also | 1865 | * handles power budgeting ... this way also |
| 1863 | * ensures HdrcStart is indirectly called. | 1866 | * ensures HdrcStart is indirectly called. |
diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index a523950c2b32..d1d6b83aabca 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c | |||
| @@ -44,52 +44,6 @@ | |||
| 44 | 44 | ||
| 45 | #include "musb_core.h" | 45 | #include "musb_core.h" |
| 46 | 46 | ||
| 47 | /* | ||
| 48 | * Program the HDRC to start (enable interrupts, dma, etc.). | ||
| 49 | */ | ||
| 50 | static void musb_start(struct musb *musb) | ||
| 51 | { | ||
| 52 | void __iomem *regs = musb->mregs; | ||
| 53 | u8 devctl = musb_readb(regs, MUSB_DEVCTL); | ||
| 54 | |||
| 55 | dev_dbg(musb->controller, "<== devctl %02x\n", devctl); | ||
| 56 | |||
| 57 | /* Set INT enable registers, enable interrupts */ | ||
| 58 | musb->intrtxe = musb->epmask; | ||
| 59 | musb_writew(regs, MUSB_INTRTXE, musb->intrtxe); | ||
| 60 | musb->intrrxe = musb->epmask & 0xfffe; | ||
| 61 | musb_writew(regs, MUSB_INTRRXE, musb->intrrxe); | ||
| 62 | musb_writeb(regs, MUSB_INTRUSBE, 0xf7); | ||
| 63 | |||
| 64 | musb_writeb(regs, MUSB_TESTMODE, 0); | ||
| 65 | |||
| 66 | /* put into basic highspeed mode and start session */ | ||
| 67 | musb_writeb(regs, MUSB_POWER, MUSB_POWER_ISOUPDATE | ||
| 68 | | MUSB_POWER_HSENAB | ||
| 69 | /* ENSUSPEND wedges tusb */ | ||
| 70 | /* | MUSB_POWER_ENSUSPEND */ | ||
| 71 | ); | ||
| 72 | |||
| 73 | musb->is_active = 0; | ||
| 74 | devctl = musb_readb(regs, MUSB_DEVCTL); | ||
| 75 | devctl &= ~MUSB_DEVCTL_SESSION; | ||
| 76 | |||
| 77 | /* session started after: | ||
| 78 | * (a) ID-grounded irq, host mode; | ||
| 79 | * (b) vbus present/connect IRQ, peripheral mode; | ||
| 80 | * (c) peripheral initiates, using SRP | ||
| 81 | */ | ||
| 82 | if (musb->port_mode != MUSB_PORT_MODE_HOST && | ||
| 83 | (devctl & MUSB_DEVCTL_VBUS) == MUSB_DEVCTL_VBUS) { | ||
| 84 | musb->is_active = 1; | ||
| 85 | } else { | ||
| 86 | devctl |= MUSB_DEVCTL_SESSION; | ||
| 87 | } | ||
| 88 | |||
| 89 | musb_platform_enable(musb); | ||
| 90 | musb_writeb(regs, MUSB_DEVCTL, devctl); | ||
| 91 | } | ||
| 92 | |||
| 93 | static void musb_port_suspend(struct musb *musb, bool do_suspend) | 47 | static void musb_port_suspend(struct musb *musb, bool do_suspend) |
| 94 | { | 48 | { |
| 95 | struct usb_otg *otg = musb->xceiv->otg; | 49 | struct usb_otg *otg = musb->xceiv->otg; |
diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c index 80a7104d5ddb..acaee066b99a 100644 --- a/drivers/usb/serial/option.c +++ b/drivers/usb/serial/option.c | |||
| @@ -451,6 +451,10 @@ static void option_instat_callback(struct urb *urb); | |||
| 451 | #define CHANGHONG_VENDOR_ID 0x2077 | 451 | #define CHANGHONG_VENDOR_ID 0x2077 |
| 452 | #define CHANGHONG_PRODUCT_CH690 0x7001 | 452 | #define CHANGHONG_PRODUCT_CH690 0x7001 |
| 453 | 453 | ||
| 454 | /* Inovia */ | ||
| 455 | #define INOVIA_VENDOR_ID 0x20a6 | ||
| 456 | #define INOVIA_SEW858 0x1105 | ||
| 457 | |||
| 454 | /* some devices interfaces need special handling due to a number of reasons */ | 458 | /* some devices interfaces need special handling due to a number of reasons */ |
| 455 | enum option_blacklist_reason { | 459 | enum option_blacklist_reason { |
| 456 | OPTION_BLACKLIST_NONE = 0, | 460 | OPTION_BLACKLIST_NONE = 0, |
| @@ -689,6 +693,222 @@ static const struct usb_device_id option_ids[] = { | |||
| 689 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) }, | 693 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7A) }, |
| 690 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7B) }, | 694 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7B) }, |
| 691 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7C) }, | 695 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x02, 0x7C) }, |
| 696 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x01) }, | ||
| 697 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x02) }, | ||
| 698 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x03) }, | ||
| 699 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x04) }, | ||
| 700 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x05) }, | ||
| 701 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x06) }, | ||
| 702 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0A) }, | ||
| 703 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0B) }, | ||
| 704 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0D) }, | ||
| 705 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0E) }, | ||
| 706 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x0F) }, | ||
| 707 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x10) }, | ||
| 708 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x12) }, | ||
| 709 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x13) }, | ||
| 710 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x14) }, | ||
| 711 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x15) }, | ||
| 712 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x17) }, | ||
| 713 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x18) }, | ||
| 714 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x19) }, | ||
| 715 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1A) }, | ||
| 716 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1B) }, | ||
| 717 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x1C) }, | ||
| 718 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x31) }, | ||
| 719 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x32) }, | ||
| 720 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x33) }, | ||
| 721 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x34) }, | ||
| 722 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x35) }, | ||
| 723 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x36) }, | ||
| 724 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3A) }, | ||
| 725 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3B) }, | ||
| 726 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3D) }, | ||
| 727 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3E) }, | ||
| 728 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x3F) }, | ||
| 729 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x48) }, | ||
| 730 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x49) }, | ||
| 731 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4A) }, | ||
| 732 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4B) }, | ||
| 733 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x4C) }, | ||
| 734 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x61) }, | ||
| 735 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x62) }, | ||
| 736 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x63) }, | ||
| 737 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x64) }, | ||
| 738 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x65) }, | ||
| 739 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x66) }, | ||
| 740 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6A) }, | ||
| 741 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6B) }, | ||
| 742 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6D) }, | ||
| 743 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6E) }, | ||
| 744 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x6F) }, | ||
| 745 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x78) }, | ||
| 746 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x79) }, | ||
| 747 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7A) }, | ||
| 748 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7B) }, | ||
| 749 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x03, 0x7C) }, | ||
| 750 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x01) }, | ||
| 751 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x02) }, | ||
| 752 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x03) }, | ||
| 753 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x04) }, | ||
| 754 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x05) }, | ||
| 755 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x06) }, | ||
| 756 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0A) }, | ||
| 757 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0B) }, | ||
| 758 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0D) }, | ||
| 759 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0E) }, | ||
| 760 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x0F) }, | ||
| 761 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x10) }, | ||
| 762 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x12) }, | ||
| 763 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x13) }, | ||
| 764 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x14) }, | ||
| 765 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x15) }, | ||
| 766 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x17) }, | ||
| 767 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x18) }, | ||
| 768 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x19) }, | ||
| 769 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1A) }, | ||
| 770 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1B) }, | ||
| 771 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x1C) }, | ||
| 772 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x31) }, | ||
| 773 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x32) }, | ||
| 774 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x33) }, | ||
| 775 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x34) }, | ||
| 776 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x35) }, | ||
| 777 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x36) }, | ||
| 778 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3A) }, | ||
| 779 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3B) }, | ||
| 780 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3D) }, | ||
| 781 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3E) }, | ||
| 782 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x3F) }, | ||
| 783 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x48) }, | ||
| 784 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x49) }, | ||
| 785 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4A) }, | ||
| 786 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4B) }, | ||
| 787 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x4C) }, | ||
| 788 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x61) }, | ||
| 789 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x62) }, | ||
| 790 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x63) }, | ||
| 791 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x64) }, | ||
| 792 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x65) }, | ||
| 793 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x66) }, | ||
| 794 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6A) }, | ||
| 795 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6B) }, | ||
| 796 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6D) }, | ||
| 797 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6E) }, | ||
| 798 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x6F) }, | ||
| 799 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x78) }, | ||
| 800 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x79) }, | ||
| 801 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7A) }, | ||
| 802 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7B) }, | ||
| 803 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x04, 0x7C) }, | ||
| 804 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x01) }, | ||
| 805 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x02) }, | ||
| 806 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x03) }, | ||
| 807 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x04) }, | ||
| 808 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x05) }, | ||
| 809 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x06) }, | ||
| 810 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0A) }, | ||
| 811 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0B) }, | ||
| 812 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0D) }, | ||
| 813 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0E) }, | ||
| 814 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x0F) }, | ||
| 815 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x10) }, | ||
| 816 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x12) }, | ||
| 817 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x13) }, | ||
| 818 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x14) }, | ||
| 819 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x15) }, | ||
| 820 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x17) }, | ||
| 821 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x18) }, | ||
| 822 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x19) }, | ||
| 823 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1A) }, | ||
| 824 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1B) }, | ||
| 825 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x1C) }, | ||
| 826 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x31) }, | ||
| 827 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x32) }, | ||
| 828 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x33) }, | ||
| 829 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x34) }, | ||
| 830 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x35) }, | ||
| 831 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x36) }, | ||
| 832 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3A) }, | ||
| 833 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3B) }, | ||
| 834 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3D) }, | ||
| 835 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3E) }, | ||
| 836 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x3F) }, | ||
| 837 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x48) }, | ||
| 838 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x49) }, | ||
| 839 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4A) }, | ||
| 840 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4B) }, | ||
| 841 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x4C) }, | ||
| 842 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x61) }, | ||
| 843 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x62) }, | ||
| 844 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x63) }, | ||
| 845 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x64) }, | ||
| 846 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x65) }, | ||
| 847 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x66) }, | ||
| 848 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6A) }, | ||
| 849 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6B) }, | ||
| 850 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6D) }, | ||
| 851 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6E) }, | ||
| 852 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x6F) }, | ||
| 853 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x78) }, | ||
| 854 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x79) }, | ||
| 855 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7A) }, | ||
| 856 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7B) }, | ||
| 857 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x05, 0x7C) }, | ||
| 858 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x01) }, | ||
| 859 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x02) }, | ||
| 860 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x03) }, | ||
| 861 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x04) }, | ||
| 862 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x05) }, | ||
| 863 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x06) }, | ||
| 864 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0A) }, | ||
| 865 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0B) }, | ||
| 866 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0D) }, | ||
| 867 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0E) }, | ||
| 868 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x0F) }, | ||
| 869 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x10) }, | ||
| 870 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x12) }, | ||
| 871 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x13) }, | ||
| 872 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x14) }, | ||
| 873 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x15) }, | ||
| 874 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x17) }, | ||
| 875 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x18) }, | ||
| 876 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x19) }, | ||
| 877 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1A) }, | ||
| 878 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1B) }, | ||
| 879 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x1C) }, | ||
| 880 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x31) }, | ||
| 881 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x32) }, | ||
| 882 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x33) }, | ||
| 883 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x34) }, | ||
| 884 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x35) }, | ||
| 885 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x36) }, | ||
| 886 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3A) }, | ||
| 887 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3B) }, | ||
| 888 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3D) }, | ||
| 889 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3E) }, | ||
| 890 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x3F) }, | ||
| 891 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x48) }, | ||
| 892 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x49) }, | ||
| 893 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4A) }, | ||
| 894 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4B) }, | ||
| 895 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x4C) }, | ||
| 896 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x61) }, | ||
| 897 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x62) }, | ||
| 898 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x63) }, | ||
| 899 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x64) }, | ||
| 900 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x65) }, | ||
| 901 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x66) }, | ||
| 902 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6A) }, | ||
| 903 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6B) }, | ||
| 904 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6D) }, | ||
| 905 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6E) }, | ||
| 906 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x6F) }, | ||
| 907 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x78) }, | ||
| 908 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x79) }, | ||
| 909 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7A) }, | ||
| 910 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7B) }, | ||
| 911 | { USB_VENDOR_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, 0xff, 0x06, 0x7C) }, | ||
| 692 | 912 | ||
| 693 | 913 | ||
| 694 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, | 914 | { USB_DEVICE(NOVATELWIRELESS_VENDOR_ID, NOVATELWIRELESS_PRODUCT_V640) }, |
| @@ -1257,7 +1477,9 @@ static const struct usb_device_id option_ids[] = { | |||
| 1257 | 1477 | ||
| 1258 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, | 1478 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD100) }, |
| 1259 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) }, | 1479 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD145) }, |
| 1260 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200) }, | 1480 | { USB_DEVICE(OLIVETTI_VENDOR_ID, OLIVETTI_PRODUCT_OLICARD200), |
| 1481 | .driver_info = (kernel_ulong_t)&net_intf6_blacklist | ||
| 1482 | }, | ||
| 1261 | { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ | 1483 | { USB_DEVICE(CELOT_VENDOR_ID, CELOT_PRODUCT_CT680M) }, /* CT-650 CDMA 450 1xEVDO modem */ |
| 1262 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/ | 1484 | { USB_DEVICE_AND_INTERFACE_INFO(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_GT_B3730, USB_CLASS_CDC_DATA, 0x00, 0x00) }, /* Samsung GT-B3730 LTE USB modem.*/ |
| 1263 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) }, | 1485 | { USB_DEVICE(YUGA_VENDOR_ID, YUGA_PRODUCT_CEM600) }, |
| @@ -1345,6 +1567,7 @@ static const struct usb_device_id option_ids[] = { | |||
| 1345 | { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, | 1567 | { USB_DEVICE_AND_INTERFACE_INFO(0x2001, 0x7d03, 0xff, 0x00, 0x00) }, |
| 1346 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ | 1568 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e01, 0xff, 0xff, 0xff) }, /* D-Link DWM-152/C1 */ |
| 1347 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ | 1569 | { USB_DEVICE_AND_INTERFACE_INFO(0x07d1, 0x3e02, 0xff, 0xff, 0xff) }, /* D-Link DWM-156/C1 */ |
| 1570 | { USB_DEVICE(INOVIA_VENDOR_ID, INOVIA_SEW858) }, | ||
| 1348 | { } /* Terminating entry */ | 1571 | { } /* Terminating entry */ |
| 1349 | }; | 1572 | }; |
| 1350 | MODULE_DEVICE_TABLE(usb, option_ids); | 1573 | MODULE_DEVICE_TABLE(usb, option_ids); |
diff --git a/drivers/usb/serial/ti_usb_3410_5052.c b/drivers/usb/serial/ti_usb_3410_5052.c index 760b78560f67..c9a35697ebe9 100644 --- a/drivers/usb/serial/ti_usb_3410_5052.c +++ b/drivers/usb/serial/ti_usb_3410_5052.c | |||
| @@ -190,6 +190,7 @@ static struct usb_device_id ti_id_table_combined[] = { | |||
| 190 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, | 190 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454B_PRODUCT_ID) }, |
| 191 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, | 191 | { USB_DEVICE(IBM_VENDOR_ID, IBM_454C_PRODUCT_ID) }, |
| 192 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) }, | 192 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_PRODUCT_ID) }, |
| 193 | { USB_DEVICE(ABBOTT_VENDOR_ID, ABBOTT_STRIP_PORT_ID) }, | ||
| 193 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, | 194 | { USB_DEVICE(TI_VENDOR_ID, FRI2_PRODUCT_ID) }, |
| 194 | { } /* terminator */ | 195 | { } /* terminator */ |
| 195 | }; | 196 | }; |
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index 94d75edef77f..18509e6c21ab 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c | |||
| @@ -211,8 +211,11 @@ static int slave_configure(struct scsi_device *sdev) | |||
| 211 | /* | 211 | /* |
| 212 | * Many devices do not respond properly to READ_CAPACITY_16. | 212 | * Many devices do not respond properly to READ_CAPACITY_16. |
| 213 | * Tell the SCSI layer to try READ_CAPACITY_10 first. | 213 | * Tell the SCSI layer to try READ_CAPACITY_10 first. |
| 214 | * However some USB 3.0 drive enclosures return capacity | ||
| 215 | * modulo 2TB. Those must use READ_CAPACITY_16 | ||
| 214 | */ | 216 | */ |
| 215 | sdev->try_rc_10_first = 1; | 217 | if (!(us->fflags & US_FL_NEEDS_CAP16)) |
| 218 | sdev->try_rc_10_first = 1; | ||
| 216 | 219 | ||
| 217 | /* assume SPC3 or latter devices support sense size > 18 */ | 220 | /* assume SPC3 or latter devices support sense size > 18 */ |
| 218 | if (sdev->scsi_level > SCSI_SPC_2) | 221 | if (sdev->scsi_level > SCSI_SPC_2) |
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h index c015f2c16729..de32cfa5bfa6 100644 --- a/drivers/usb/storage/unusual_devs.h +++ b/drivers/usb/storage/unusual_devs.h | |||
| @@ -1925,6 +1925,13 @@ UNUSUAL_DEV( 0x1652, 0x6600, 0x0201, 0x0201, | |||
| 1925 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | 1925 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, |
| 1926 | US_FL_IGNORE_RESIDUE ), | 1926 | US_FL_IGNORE_RESIDUE ), |
| 1927 | 1927 | ||
| 1928 | /* Reported by Oliver Neukum <oneukum@suse.com> */ | ||
| 1929 | UNUSUAL_DEV( 0x174c, 0x55aa, 0x0100, 0x0100, | ||
| 1930 | "ASMedia", | ||
| 1931 | "AS2105", | ||
| 1932 | USB_SC_DEVICE, USB_PR_DEVICE, NULL, | ||
| 1933 | US_FL_NEEDS_CAP16), | ||
| 1934 | |||
| 1928 | /* Reported by Jesse Feddema <jdfeddema@gmail.com> */ | 1935 | /* Reported by Jesse Feddema <jdfeddema@gmail.com> */ |
| 1929 | UNUSUAL_DEV( 0x177f, 0x0400, 0x0000, 0x0000, | 1936 | UNUSUAL_DEV( 0x177f, 0x0400, 0x0000, 0x0000, |
| 1930 | "Yarvik", | 1937 | "Yarvik", |
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index a9807dea3887..4fb7a8f83c8a 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c | |||
| @@ -545,6 +545,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
| 545 | long npage; | 545 | long npage; |
| 546 | int ret = 0, prot = 0; | 546 | int ret = 0, prot = 0; |
| 547 | uint64_t mask; | 547 | uint64_t mask; |
| 548 | struct vfio_dma *dma = NULL; | ||
| 549 | unsigned long pfn; | ||
| 548 | 550 | ||
| 549 | end = map->iova + map->size; | 551 | end = map->iova + map->size; |
| 550 | 552 | ||
| @@ -587,8 +589,6 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
| 587 | } | 589 | } |
| 588 | 590 | ||
| 589 | for (iova = map->iova; iova < end; iova += size, vaddr += size) { | 591 | for (iova = map->iova; iova < end; iova += size, vaddr += size) { |
| 590 | struct vfio_dma *dma = NULL; | ||
| 591 | unsigned long pfn; | ||
| 592 | long i; | 592 | long i; |
| 593 | 593 | ||
| 594 | /* Pin a contiguous chunk of memory */ | 594 | /* Pin a contiguous chunk of memory */ |
| @@ -597,16 +597,15 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
| 597 | if (npage <= 0) { | 597 | if (npage <= 0) { |
| 598 | WARN_ON(!npage); | 598 | WARN_ON(!npage); |
| 599 | ret = (int)npage; | 599 | ret = (int)npage; |
| 600 | break; | 600 | goto out; |
| 601 | } | 601 | } |
| 602 | 602 | ||
| 603 | /* Verify pages are not already mapped */ | 603 | /* Verify pages are not already mapped */ |
| 604 | for (i = 0; i < npage; i++) { | 604 | for (i = 0; i < npage; i++) { |
| 605 | if (iommu_iova_to_phys(iommu->domain, | 605 | if (iommu_iova_to_phys(iommu->domain, |
| 606 | iova + (i << PAGE_SHIFT))) { | 606 | iova + (i << PAGE_SHIFT))) { |
| 607 | vfio_unpin_pages(pfn, npage, prot, true); | ||
| 608 | ret = -EBUSY; | 607 | ret = -EBUSY; |
| 609 | break; | 608 | goto out_unpin; |
| 610 | } | 609 | } |
| 611 | } | 610 | } |
| 612 | 611 | ||
| @@ -616,8 +615,7 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
| 616 | if (ret) { | 615 | if (ret) { |
| 617 | if (ret != -EBUSY || | 616 | if (ret != -EBUSY || |
| 618 | map_try_harder(iommu, iova, pfn, npage, prot)) { | 617 | map_try_harder(iommu, iova, pfn, npage, prot)) { |
| 619 | vfio_unpin_pages(pfn, npage, prot, true); | 618 | goto out_unpin; |
| 620 | break; | ||
| 621 | } | 619 | } |
| 622 | } | 620 | } |
| 623 | 621 | ||
| @@ -672,9 +670,8 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
| 672 | dma = kzalloc(sizeof(*dma), GFP_KERNEL); | 670 | dma = kzalloc(sizeof(*dma), GFP_KERNEL); |
| 673 | if (!dma) { | 671 | if (!dma) { |
| 674 | iommu_unmap(iommu->domain, iova, size); | 672 | iommu_unmap(iommu->domain, iova, size); |
| 675 | vfio_unpin_pages(pfn, npage, prot, true); | ||
| 676 | ret = -ENOMEM; | 673 | ret = -ENOMEM; |
| 677 | break; | 674 | goto out_unpin; |
| 678 | } | 675 | } |
| 679 | 676 | ||
| 680 | dma->size = size; | 677 | dma->size = size; |
| @@ -685,16 +682,21 @@ static int vfio_dma_do_map(struct vfio_iommu *iommu, | |||
| 685 | } | 682 | } |
| 686 | } | 683 | } |
| 687 | 684 | ||
| 688 | if (ret) { | 685 | WARN_ON(ret); |
| 689 | struct vfio_dma *tmp; | 686 | mutex_unlock(&iommu->lock); |
| 690 | iova = map->iova; | 687 | return ret; |
| 691 | size = map->size; | 688 | |
| 692 | while ((tmp = vfio_find_dma(iommu, iova, size))) { | 689 | out_unpin: |
| 693 | int r = vfio_remove_dma_overlap(iommu, iova, | 690 | vfio_unpin_pages(pfn, npage, prot, true); |
| 694 | &size, tmp); | 691 | |
| 695 | if (WARN_ON(r || !size)) | 692 | out: |
| 696 | break; | 693 | iova = map->iova; |
| 697 | } | 694 | size = map->size; |
| 695 | while ((dma = vfio_find_dma(iommu, iova, size))) { | ||
| 696 | int r = vfio_remove_dma_overlap(iommu, iova, | ||
| 697 | &size, dma); | ||
| 698 | if (WARN_ON(r || !size)) | ||
| 699 | break; | ||
| 698 | } | 700 | } |
| 699 | 701 | ||
| 700 | mutex_unlock(&iommu->lock); | 702 | mutex_unlock(&iommu->lock); |
diff --git a/drivers/w1/w1.c b/drivers/w1/w1.c index c7c64f18773d..fa932c2f7d97 100644 --- a/drivers/w1/w1.c +++ b/drivers/w1/w1.c | |||
| @@ -613,6 +613,9 @@ static int w1_bus_notify(struct notifier_block *nb, unsigned long action, | |||
| 613 | sl = dev_to_w1_slave(dev); | 613 | sl = dev_to_w1_slave(dev); |
| 614 | fops = sl->family->fops; | 614 | fops = sl->family->fops; |
| 615 | 615 | ||
| 616 | if (!fops) | ||
| 617 | return 0; | ||
| 618 | |||
| 616 | switch (action) { | 619 | switch (action) { |
| 617 | case BUS_NOTIFY_ADD_DEVICE: | 620 | case BUS_NOTIFY_ADD_DEVICE: |
| 618 | /* if the family driver needs to initialize something... */ | 621 | /* if the family driver needs to initialize something... */ |
| @@ -713,7 +716,10 @@ static int w1_attach_slave_device(struct w1_master *dev, struct w1_reg_num *rn) | |||
| 713 | atomic_set(&sl->refcnt, 0); | 716 | atomic_set(&sl->refcnt, 0); |
| 714 | init_completion(&sl->released); | 717 | init_completion(&sl->released); |
| 715 | 718 | ||
| 719 | /* slave modules need to be loaded in a context with unlocked mutex */ | ||
| 720 | mutex_unlock(&dev->mutex); | ||
| 716 | request_module("w1-family-0x%0x", rn->family); | 721 | request_module("w1-family-0x%0x", rn->family); |
| 722 | mutex_lock(&dev->mutex); | ||
| 717 | 723 | ||
| 718 | spin_lock(&w1_flock); | 724 | spin_lock(&w1_flock); |
| 719 | f = w1_family_registered(rn->family); | 725 | f = w1_family_registered(rn->family); |
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index b0ef7b07b1b3..51e3afa78354 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c | |||
| @@ -6437,6 +6437,7 @@ noinline int can_nocow_extent(struct inode *inode, u64 offset, u64 *len, | |||
| 6437 | 6437 | ||
| 6438 | if (btrfs_extent_readonly(root, disk_bytenr)) | 6438 | if (btrfs_extent_readonly(root, disk_bytenr)) |
| 6439 | goto out; | 6439 | goto out; |
| 6440 | btrfs_release_path(path); | ||
| 6440 | 6441 | ||
| 6441 | /* | 6442 | /* |
| 6442 | * look for other files referencing this extent, if we | 6443 | * look for other files referencing this extent, if we |
diff --git a/fs/buffer.c b/fs/buffer.c index 4d7433534f5c..6024877335ca 100644 --- a/fs/buffer.c +++ b/fs/buffer.c | |||
| @@ -1005,9 +1005,19 @@ grow_dev_page(struct block_device *bdev, sector_t block, | |||
| 1005 | struct buffer_head *bh; | 1005 | struct buffer_head *bh; |
| 1006 | sector_t end_block; | 1006 | sector_t end_block; |
| 1007 | int ret = 0; /* Will call free_more_memory() */ | 1007 | int ret = 0; /* Will call free_more_memory() */ |
| 1008 | gfp_t gfp_mask; | ||
| 1008 | 1009 | ||
| 1009 | page = find_or_create_page(inode->i_mapping, index, | 1010 | gfp_mask = mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS; |
| 1010 | (mapping_gfp_mask(inode->i_mapping) & ~__GFP_FS)|__GFP_MOVABLE); | 1011 | gfp_mask |= __GFP_MOVABLE; |
| 1012 | /* | ||
| 1013 | * XXX: __getblk_slow() can not really deal with failure and | ||
| 1014 | * will endlessly loop on improvised global reclaim. Prefer | ||
| 1015 | * looping in the allocator rather than here, at least that | ||
| 1016 | * code knows what it's doing. | ||
| 1017 | */ | ||
| 1018 | gfp_mask |= __GFP_NOFAIL; | ||
| 1019 | |||
| 1020 | page = find_or_create_page(inode->i_mapping, index, gfp_mask); | ||
| 1011 | if (!page) | 1021 | if (!page) |
| 1012 | return ret; | 1022 | return ret; |
| 1013 | 1023 | ||
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index a16b4e58bcc6..77fc5e181077 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c | |||
| @@ -120,14 +120,16 @@ cifs_read_super(struct super_block *sb) | |||
| 120 | { | 120 | { |
| 121 | struct inode *inode; | 121 | struct inode *inode; |
| 122 | struct cifs_sb_info *cifs_sb; | 122 | struct cifs_sb_info *cifs_sb; |
| 123 | struct cifs_tcon *tcon; | ||
| 123 | int rc = 0; | 124 | int rc = 0; |
| 124 | 125 | ||
| 125 | cifs_sb = CIFS_SB(sb); | 126 | cifs_sb = CIFS_SB(sb); |
| 127 | tcon = cifs_sb_master_tcon(cifs_sb); | ||
| 126 | 128 | ||
| 127 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) | 129 | if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) |
| 128 | sb->s_flags |= MS_POSIXACL; | 130 | sb->s_flags |= MS_POSIXACL; |
| 129 | 131 | ||
| 130 | if (cifs_sb_master_tcon(cifs_sb)->ses->capabilities & CAP_LARGE_FILES) | 132 | if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files) |
| 131 | sb->s_maxbytes = MAX_LFS_FILESIZE; | 133 | sb->s_maxbytes = MAX_LFS_FILESIZE; |
| 132 | else | 134 | else |
| 133 | sb->s_maxbytes = MAX_NON_LFS; | 135 | sb->s_maxbytes = MAX_NON_LFS; |
| @@ -147,7 +149,7 @@ cifs_read_super(struct super_block *sb) | |||
| 147 | goto out_no_root; | 149 | goto out_no_root; |
| 148 | } | 150 | } |
| 149 | 151 | ||
| 150 | if (cifs_sb_master_tcon(cifs_sb)->nocase) | 152 | if (tcon->nocase) |
| 151 | sb->s_d_op = &cifs_ci_dentry_ops; | 153 | sb->s_d_op = &cifs_ci_dentry_ops; |
| 152 | else | 154 | else |
| 153 | sb->s_d_op = &cifs_dentry_ops; | 155 | sb->s_d_op = &cifs_dentry_ops; |
diff --git a/fs/cifs/cifspdu.h b/fs/cifs/cifspdu.h index a630475e421c..08f9dfb1a894 100644 --- a/fs/cifs/cifspdu.h +++ b/fs/cifs/cifspdu.h | |||
| @@ -1491,15 +1491,30 @@ struct file_notify_information { | |||
| 1491 | __u8 FileName[0]; | 1491 | __u8 FileName[0]; |
| 1492 | } __attribute__((packed)); | 1492 | } __attribute__((packed)); |
| 1493 | 1493 | ||
| 1494 | struct reparse_data { | 1494 | /* For IO_REPARSE_TAG_SYMLINK */ |
| 1495 | __u32 ReparseTag; | 1495 | struct reparse_symlink_data { |
| 1496 | __u16 ReparseDataLength; | 1496 | __le32 ReparseTag; |
| 1497 | __le16 ReparseDataLength; | ||
| 1497 | __u16 Reserved; | 1498 | __u16 Reserved; |
| 1498 | __u16 SubstituteNameOffset; | 1499 | __le16 SubstituteNameOffset; |
| 1499 | __u16 SubstituteNameLength; | 1500 | __le16 SubstituteNameLength; |
| 1500 | __u16 PrintNameOffset; | 1501 | __le16 PrintNameOffset; |
| 1501 | __u16 PrintNameLength; | 1502 | __le16 PrintNameLength; |
| 1502 | __u32 Flags; | 1503 | __le32 Flags; |
| 1504 | char PathBuffer[0]; | ||
| 1505 | } __attribute__((packed)); | ||
| 1506 | |||
| 1507 | /* For IO_REPARSE_TAG_NFS */ | ||
| 1508 | #define NFS_SPECFILE_LNK 0x00000000014B4E4C | ||
| 1509 | #define NFS_SPECFILE_CHR 0x0000000000524843 | ||
| 1510 | #define NFS_SPECFILE_BLK 0x00000000004B4C42 | ||
| 1511 | #define NFS_SPECFILE_FIFO 0x000000004F464946 | ||
| 1512 | #define NFS_SPECFILE_SOCK 0x000000004B434F53 | ||
| 1513 | struct reparse_posix_data { | ||
| 1514 | __le32 ReparseTag; | ||
| 1515 | __le16 ReparseDataLength; | ||
| 1516 | __u16 Reserved; | ||
| 1517 | __le64 InodeType; /* LNK, FIFO, CHR etc. */ | ||
| 1503 | char PathBuffer[0]; | 1518 | char PathBuffer[0]; |
| 1504 | } __attribute__((packed)); | 1519 | } __attribute__((packed)); |
| 1505 | 1520 | ||
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 4baf35949b51..ccd31ab815d4 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
| @@ -3088,7 +3088,8 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3088 | bool is_unicode; | 3088 | bool is_unicode; |
| 3089 | unsigned int sub_len; | 3089 | unsigned int sub_len; |
| 3090 | char *sub_start; | 3090 | char *sub_start; |
| 3091 | struct reparse_data *reparse_buf; | 3091 | struct reparse_symlink_data *reparse_buf; |
| 3092 | struct reparse_posix_data *posix_buf; | ||
| 3092 | __u32 data_offset, data_count; | 3093 | __u32 data_offset, data_count; |
| 3093 | char *end_of_smb; | 3094 | char *end_of_smb; |
| 3094 | 3095 | ||
| @@ -3137,20 +3138,47 @@ CIFSSMBQuerySymLink(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3137 | goto qreparse_out; | 3138 | goto qreparse_out; |
| 3138 | } | 3139 | } |
| 3139 | end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount; | 3140 | end_of_smb = 2 + get_bcc(&pSMBr->hdr) + (char *)&pSMBr->ByteCount; |
| 3140 | reparse_buf = (struct reparse_data *) | 3141 | reparse_buf = (struct reparse_symlink_data *) |
| 3141 | ((char *)&pSMBr->hdr.Protocol + data_offset); | 3142 | ((char *)&pSMBr->hdr.Protocol + data_offset); |
| 3142 | if ((char *)reparse_buf >= end_of_smb) { | 3143 | if ((char *)reparse_buf >= end_of_smb) { |
| 3143 | rc = -EIO; | 3144 | rc = -EIO; |
| 3144 | goto qreparse_out; | 3145 | goto qreparse_out; |
| 3145 | } | 3146 | } |
| 3146 | if ((reparse_buf->PathBuffer + reparse_buf->PrintNameOffset + | 3147 | if (reparse_buf->ReparseTag == cpu_to_le32(IO_REPARSE_TAG_NFS)) { |
| 3147 | reparse_buf->PrintNameLength) > end_of_smb) { | 3148 | cifs_dbg(FYI, "NFS style reparse tag\n"); |
| 3149 | posix_buf = (struct reparse_posix_data *)reparse_buf; | ||
| 3150 | |||
| 3151 | if (posix_buf->InodeType != cpu_to_le64(NFS_SPECFILE_LNK)) { | ||
| 3152 | cifs_dbg(FYI, "unsupported file type 0x%llx\n", | ||
| 3153 | le64_to_cpu(posix_buf->InodeType)); | ||
| 3154 | rc = -EOPNOTSUPP; | ||
| 3155 | goto qreparse_out; | ||
| 3156 | } | ||
| 3157 | is_unicode = true; | ||
| 3158 | sub_len = le16_to_cpu(reparse_buf->ReparseDataLength); | ||
| 3159 | if (posix_buf->PathBuffer + sub_len > end_of_smb) { | ||
| 3160 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); | ||
| 3161 | rc = -EIO; | ||
| 3162 | goto qreparse_out; | ||
| 3163 | } | ||
| 3164 | *symlinkinfo = cifs_strndup_from_utf16(posix_buf->PathBuffer, | ||
| 3165 | sub_len, is_unicode, nls_codepage); | ||
| 3166 | goto qreparse_out; | ||
| 3167 | } else if (reparse_buf->ReparseTag != | ||
| 3168 | cpu_to_le32(IO_REPARSE_TAG_SYMLINK)) { | ||
| 3169 | rc = -EOPNOTSUPP; | ||
| 3170 | goto qreparse_out; | ||
| 3171 | } | ||
| 3172 | |||
| 3173 | /* Reparse tag is NTFS symlink */ | ||
| 3174 | sub_start = le16_to_cpu(reparse_buf->SubstituteNameOffset) + | ||
| 3175 | reparse_buf->PathBuffer; | ||
| 3176 | sub_len = le16_to_cpu(reparse_buf->SubstituteNameLength); | ||
| 3177 | if (sub_start + sub_len > end_of_smb) { | ||
| 3148 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); | 3178 | cifs_dbg(FYI, "reparse buf beyond SMB\n"); |
| 3149 | rc = -EIO; | 3179 | rc = -EIO; |
| 3150 | goto qreparse_out; | 3180 | goto qreparse_out; |
| 3151 | } | 3181 | } |
| 3152 | sub_start = reparse_buf->SubstituteNameOffset + reparse_buf->PathBuffer; | ||
| 3153 | sub_len = reparse_buf->SubstituteNameLength; | ||
| 3154 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) | 3182 | if (pSMBr->hdr.Flags2 & SMBFLG2_UNICODE) |
| 3155 | is_unicode = true; | 3183 | is_unicode = true; |
| 3156 | else | 3184 | else |
diff --git a/fs/cifs/netmisc.c b/fs/cifs/netmisc.c index af847e1cf1c1..651a5279607b 100644 --- a/fs/cifs/netmisc.c +++ b/fs/cifs/netmisc.c | |||
| @@ -780,7 +780,9 @@ static const struct { | |||
| 780 | ERRDOS, ERRnoaccess, 0xc0000290}, { | 780 | ERRDOS, ERRnoaccess, 0xc0000290}, { |
| 781 | ERRDOS, ERRbadfunc, 0xc000029c}, { | 781 | ERRDOS, ERRbadfunc, 0xc000029c}, { |
| 782 | ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, { | 782 | ERRDOS, ERRsymlink, NT_STATUS_STOPPED_ON_SYMLINK}, { |
| 783 | ERRDOS, ERRinvlevel, 0x007c0001}, }; | 783 | ERRDOS, ERRinvlevel, 0x007c0001}, { |
| 784 | 0, 0, 0 } | ||
| 785 | }; | ||
| 784 | 786 | ||
| 785 | /***************************************************************************** | 787 | /***************************************************************************** |
| 786 | Print an error message from the status code | 788 | Print an error message from the status code |
diff --git a/fs/cifs/sess.c b/fs/cifs/sess.c index 352358de1d7e..e87387dbf39f 100644 --- a/fs/cifs/sess.c +++ b/fs/cifs/sess.c | |||
| @@ -500,9 +500,9 @@ select_sectype(struct TCP_Server_Info *server, enum securityEnum requested) | |||
| 500 | return NTLMv2; | 500 | return NTLMv2; |
| 501 | if (global_secflags & CIFSSEC_MAY_NTLM) | 501 | if (global_secflags & CIFSSEC_MAY_NTLM) |
| 502 | return NTLM; | 502 | return NTLM; |
| 503 | /* Fallthrough */ | ||
| 504 | default: | 503 | default: |
| 505 | return Unspecified; | 504 | /* Fallthrough to attempt LANMAN authentication next */ |
| 505 | break; | ||
| 506 | } | 506 | } |
| 507 | case CIFS_NEGFLAVOR_LANMAN: | 507 | case CIFS_NEGFLAVOR_LANMAN: |
| 508 | switch (requested) { | 508 | switch (requested) { |
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index eba0efde66d7..edccb5252462 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
| @@ -687,6 +687,10 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
| 687 | else | 687 | else |
| 688 | return -EIO; | 688 | return -EIO; |
| 689 | 689 | ||
| 690 | /* no need to send SMB logoff if uid already closed due to reconnect */ | ||
| 691 | if (ses->need_reconnect) | ||
| 692 | goto smb2_session_already_dead; | ||
| 693 | |||
| 690 | rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); | 694 | rc = small_smb2_init(SMB2_LOGOFF, NULL, (void **) &req); |
| 691 | if (rc) | 695 | if (rc) |
| 692 | return rc; | 696 | return rc; |
| @@ -701,6 +705,8 @@ SMB2_logoff(const unsigned int xid, struct cifs_ses *ses) | |||
| 701 | * No tcon so can't do | 705 | * No tcon so can't do |
| 702 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); | 706 | * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]); |
| 703 | */ | 707 | */ |
| 708 | |||
| 709 | smb2_session_already_dead: | ||
| 704 | return rc; | 710 | return rc; |
| 705 | } | 711 | } |
| 706 | 712 | ||
diff --git a/fs/cifs/smbfsctl.h b/fs/cifs/smbfsctl.h index d952ee48f4dc..a4b2391fe66e 100644 --- a/fs/cifs/smbfsctl.h +++ b/fs/cifs/smbfsctl.h | |||
| @@ -97,9 +97,23 @@ | |||
| 97 | #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ | 97 | #define FSCTL_QUERY_NETWORK_INTERFACE_INFO 0x001401FC /* BB add struct */ |
| 98 | #define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ | 98 | #define FSCTL_SRV_READ_HASH 0x001441BB /* BB add struct */ |
| 99 | 99 | ||
| 100 | /* See FSCC 2.1.2.5 */ | ||
| 100 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 | 101 | #define IO_REPARSE_TAG_MOUNT_POINT 0xA0000003 |
| 101 | #define IO_REPARSE_TAG_HSM 0xC0000004 | 102 | #define IO_REPARSE_TAG_HSM 0xC0000004 |
| 102 | #define IO_REPARSE_TAG_SIS 0x80000007 | 103 | #define IO_REPARSE_TAG_SIS 0x80000007 |
| 104 | #define IO_REPARSE_TAG_HSM2 0x80000006 | ||
| 105 | #define IO_REPARSE_TAG_DRIVER_EXTENDER 0x80000005 | ||
| 106 | /* Used by the DFS filter. See MS-DFSC */ | ||
| 107 | #define IO_REPARSE_TAG_DFS 0x8000000A | ||
| 108 | /* Used by the DFS filter See MS-DFSC */ | ||
| 109 | #define IO_REPARSE_TAG_DFSR 0x80000012 | ||
| 110 | #define IO_REPARSE_TAG_FILTER_MANAGER 0x8000000B | ||
| 111 | /* See section MS-FSCC 2.1.2.4 */ | ||
| 112 | #define IO_REPARSE_TAG_SYMLINK 0xA000000C | ||
| 113 | #define IO_REPARSE_TAG_DEDUP 0x80000013 | ||
| 114 | #define IO_REPARSE_APPXSTREAM 0xC0000014 | ||
| 115 | /* NFS symlinks, Win 8/SMB3 and later */ | ||
| 116 | #define IO_REPARSE_TAG_NFS 0x80000014 | ||
| 103 | 117 | ||
| 104 | /* fsctl flags */ | 118 | /* fsctl flags */ |
| 105 | /* If Flags is set to this value, the request is an FSCTL not ioctl request */ | 119 | /* If Flags is set to this value, the request is an FSCTL not ioctl request */ |
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 6fdcb1b4a106..800b938e4061 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
| @@ -410,8 +410,13 @@ static int | |||
| 410 | wait_for_free_request(struct TCP_Server_Info *server, const int timeout, | 410 | wait_for_free_request(struct TCP_Server_Info *server, const int timeout, |
| 411 | const int optype) | 411 | const int optype) |
| 412 | { | 412 | { |
| 413 | return wait_for_free_credits(server, timeout, | 413 | int *val; |
| 414 | server->ops->get_credits_field(server, optype)); | 414 | |
| 415 | val = server->ops->get_credits_field(server, optype); | ||
| 416 | /* Since an echo is already inflight, no need to wait to send another */ | ||
| 417 | if (*val <= 0 && optype == CIFS_ECHO_OP) | ||
| 418 | return -EAGAIN; | ||
| 419 | return wait_for_free_credits(server, timeout, val); | ||
| 415 | } | 420 | } |
| 416 | 421 | ||
| 417 | static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, | 422 | static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, |
diff --git a/fs/ext3/namei.c b/fs/ext3/namei.c index 1194b1f0f839..f8cde46de9cd 100644 --- a/fs/ext3/namei.c +++ b/fs/ext3/namei.c | |||
| @@ -1783,7 +1783,7 @@ retry: | |||
| 1783 | d_tmpfile(dentry, inode); | 1783 | d_tmpfile(dentry, inode); |
| 1784 | err = ext3_orphan_add(handle, inode); | 1784 | err = ext3_orphan_add(handle, inode); |
| 1785 | if (err) | 1785 | if (err) |
| 1786 | goto err_drop_inode; | 1786 | goto err_unlock_inode; |
| 1787 | mark_inode_dirty(inode); | 1787 | mark_inode_dirty(inode); |
| 1788 | unlock_new_inode(inode); | 1788 | unlock_new_inode(inode); |
| 1789 | } | 1789 | } |
| @@ -1791,10 +1791,9 @@ retry: | |||
| 1791 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) | 1791 | if (err == -ENOSPC && ext3_should_retry_alloc(dir->i_sb, &retries)) |
| 1792 | goto retry; | 1792 | goto retry; |
| 1793 | return err; | 1793 | return err; |
| 1794 | err_drop_inode: | 1794 | err_unlock_inode: |
| 1795 | ext3_journal_stop(handle); | 1795 | ext3_journal_stop(handle); |
| 1796 | unlock_new_inode(inode); | 1796 | unlock_new_inode(inode); |
| 1797 | iput(inode); | ||
| 1798 | return err; | 1797 | return err; |
| 1799 | } | 1798 | } |
| 1800 | 1799 | ||
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 1bec5a5c1e45..5a0408d7b114 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c | |||
| @@ -2319,7 +2319,7 @@ retry: | |||
| 2319 | d_tmpfile(dentry, inode); | 2319 | d_tmpfile(dentry, inode); |
| 2320 | err = ext4_orphan_add(handle, inode); | 2320 | err = ext4_orphan_add(handle, inode); |
| 2321 | if (err) | 2321 | if (err) |
| 2322 | goto err_drop_inode; | 2322 | goto err_unlock_inode; |
| 2323 | mark_inode_dirty(inode); | 2323 | mark_inode_dirty(inode); |
| 2324 | unlock_new_inode(inode); | 2324 | unlock_new_inode(inode); |
| 2325 | } | 2325 | } |
| @@ -2328,10 +2328,9 @@ retry: | |||
| 2328 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) | 2328 | if (err == -ENOSPC && ext4_should_retry_alloc(dir->i_sb, &retries)) |
| 2329 | goto retry; | 2329 | goto retry; |
| 2330 | return err; | 2330 | return err; |
| 2331 | err_drop_inode: | 2331 | err_unlock_inode: |
| 2332 | ext4_journal_stop(handle); | 2332 | ext4_journal_stop(handle); |
| 2333 | unlock_new_inode(inode); | 2333 | unlock_new_inode(inode); |
| 2334 | iput(inode); | ||
| 2335 | return err; | 2334 | return err; |
| 2336 | } | 2335 | } |
| 2337 | 2336 | ||
diff --git a/fs/proc/inode.c b/fs/proc/inode.c index 9f8ef9b7674d..8eaa1ba793fc 100644 --- a/fs/proc/inode.c +++ b/fs/proc/inode.c | |||
| @@ -288,10 +288,14 @@ static int proc_reg_mmap(struct file *file, struct vm_area_struct *vma) | |||
| 288 | static unsigned long proc_reg_get_unmapped_area(struct file *file, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags) | 288 | static unsigned long proc_reg_get_unmapped_area(struct file *file, unsigned long orig_addr, unsigned long len, unsigned long pgoff, unsigned long flags) |
| 289 | { | 289 | { |
| 290 | struct proc_dir_entry *pde = PDE(file_inode(file)); | 290 | struct proc_dir_entry *pde = PDE(file_inode(file)); |
| 291 | int rv = -EIO; | 291 | unsigned long rv = -EIO; |
| 292 | unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long); | 292 | unsigned long (*get_unmapped_area)(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) = NULL; |
| 293 | if (use_pde(pde)) { | 293 | if (use_pde(pde)) { |
| 294 | get_unmapped_area = pde->proc_fops->get_unmapped_area; | 294 | #ifdef CONFIG_MMU |
| 295 | get_unmapped_area = current->mm->get_unmapped_area; | ||
| 296 | #endif | ||
| 297 | if (pde->proc_fops->get_unmapped_area) | ||
| 298 | get_unmapped_area = pde->proc_fops->get_unmapped_area; | ||
| 295 | if (get_unmapped_area) | 299 | if (get_unmapped_area) |
| 296 | rv = get_unmapped_area(file, orig_addr, len, pgoff, flags); | 300 | rv = get_unmapped_area(file, orig_addr, len, pgoff, flags); |
| 297 | unuse_pde(pde); | 301 | unuse_pde(pde); |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 7366e9d63cee..390bdab01c3c 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -941,6 +941,8 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm, | |||
| 941 | frame = pte_pfn(pte); | 941 | frame = pte_pfn(pte); |
| 942 | flags = PM_PRESENT; | 942 | flags = PM_PRESENT; |
| 943 | page = vm_normal_page(vma, addr, pte); | 943 | page = vm_normal_page(vma, addr, pte); |
| 944 | if (pte_soft_dirty(pte)) | ||
| 945 | flags2 |= __PM_SOFT_DIRTY; | ||
| 944 | } else if (is_swap_pte(pte)) { | 946 | } else if (is_swap_pte(pte)) { |
| 945 | swp_entry_t entry; | 947 | swp_entry_t entry; |
| 946 | if (pte_swp_soft_dirty(pte)) | 948 | if (pte_swp_soft_dirty(pte)) |
| @@ -960,7 +962,7 @@ static void pte_to_pagemap_entry(pagemap_entry_t *pme, struct pagemapread *pm, | |||
| 960 | 962 | ||
| 961 | if (page && !PageAnon(page)) | 963 | if (page && !PageAnon(page)) |
| 962 | flags |= PM_FILE; | 964 | flags |= PM_FILE; |
| 963 | if ((vma->vm_flags & VM_SOFTDIRTY) || pte_soft_dirty(pte)) | 965 | if ((vma->vm_flags & VM_SOFTDIRTY)) |
| 964 | flags2 |= __PM_SOFT_DIRTY; | 966 | flags2 |= __PM_SOFT_DIRTY; |
| 965 | 967 | ||
| 966 | *pme = make_pme(PM_PFRAME(frame) | PM_STATUS2(pm->v2, flags2) | flags); | 968 | *pme = make_pme(PM_PFRAME(frame) | PM_STATUS2(pm->v2, flags2) | flags); |
diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h index 02e113bb8b7d..d9019821aa60 100644 --- a/include/acpi/acpi_bus.h +++ b/include/acpi/acpi_bus.h | |||
| @@ -311,7 +311,6 @@ struct acpi_device { | |||
| 311 | unsigned int physical_node_count; | 311 | unsigned int physical_node_count; |
| 312 | struct list_head physical_node_list; | 312 | struct list_head physical_node_list; |
| 313 | struct mutex physical_node_lock; | 313 | struct mutex physical_node_lock; |
| 314 | struct list_head power_dependent; | ||
| 315 | void (*remove)(struct acpi_device *); | 314 | void (*remove)(struct acpi_device *); |
| 316 | }; | 315 | }; |
| 317 | 316 | ||
| @@ -456,8 +455,6 @@ acpi_status acpi_add_pm_notifier(struct acpi_device *adev, | |||
| 456 | acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, | 455 | acpi_status acpi_remove_pm_notifier(struct acpi_device *adev, |
| 457 | acpi_notify_handler handler); | 456 | acpi_notify_handler handler); |
| 458 | int acpi_pm_device_sleep_state(struct device *, int *, int); | 457 | int acpi_pm_device_sleep_state(struct device *, int *, int); |
| 459 | void acpi_dev_pm_add_dependent(acpi_handle handle, struct device *depdev); | ||
| 460 | void acpi_dev_pm_remove_dependent(acpi_handle handle, struct device *depdev); | ||
| 461 | #else | 458 | #else |
| 462 | static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev, | 459 | static inline acpi_status acpi_add_pm_notifier(struct acpi_device *adev, |
| 463 | acpi_notify_handler handler, | 460 | acpi_notify_handler handler, |
| @@ -478,10 +475,6 @@ static inline int acpi_pm_device_sleep_state(struct device *d, int *p, int m) | |||
| 478 | return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ? | 475 | return (m >= ACPI_STATE_D0 && m <= ACPI_STATE_D3_COLD) ? |
| 479 | m : ACPI_STATE_D0; | 476 | m : ACPI_STATE_D0; |
| 480 | } | 477 | } |
| 481 | static inline void acpi_dev_pm_add_dependent(acpi_handle handle, | ||
| 482 | struct device *depdev) {} | ||
| 483 | static inline void acpi_dev_pm_remove_dependent(acpi_handle handle, | ||
| 484 | struct device *depdev) {} | ||
| 485 | #endif | 478 | #endif |
| 486 | 479 | ||
| 487 | #ifdef CONFIG_PM_RUNTIME | 480 | #ifdef CONFIG_PM_RUNTIME |
diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h index ecc82b37c4cc..b3e7a667e03c 100644 --- a/include/linux/memcontrol.h +++ b/include/linux/memcontrol.h | |||
| @@ -137,47 +137,24 @@ extern void mem_cgroup_print_oom_info(struct mem_cgroup *memcg, | |||
| 137 | extern void mem_cgroup_replace_page_cache(struct page *oldpage, | 137 | extern void mem_cgroup_replace_page_cache(struct page *oldpage, |
| 138 | struct page *newpage); | 138 | struct page *newpage); |
| 139 | 139 | ||
| 140 | /** | 140 | static inline void mem_cgroup_oom_enable(void) |
| 141 | * mem_cgroup_toggle_oom - toggle the memcg OOM killer for the current task | ||
| 142 | * @new: true to enable, false to disable | ||
| 143 | * | ||
| 144 | * Toggle whether a failed memcg charge should invoke the OOM killer | ||
| 145 | * or just return -ENOMEM. Returns the previous toggle state. | ||
| 146 | * | ||
| 147 | * NOTE: Any path that enables the OOM killer before charging must | ||
| 148 | * call mem_cgroup_oom_synchronize() afterward to finalize the | ||
| 149 | * OOM handling and clean up. | ||
| 150 | */ | ||
| 151 | static inline bool mem_cgroup_toggle_oom(bool new) | ||
| 152 | { | 141 | { |
| 153 | bool old; | 142 | WARN_ON(current->memcg_oom.may_oom); |
| 154 | 143 | current->memcg_oom.may_oom = 1; | |
| 155 | old = current->memcg_oom.may_oom; | ||
| 156 | current->memcg_oom.may_oom = new; | ||
| 157 | |||
| 158 | return old; | ||
| 159 | } | 144 | } |
| 160 | 145 | ||
| 161 | static inline void mem_cgroup_enable_oom(void) | 146 | static inline void mem_cgroup_oom_disable(void) |
| 162 | { | 147 | { |
| 163 | bool old = mem_cgroup_toggle_oom(true); | 148 | WARN_ON(!current->memcg_oom.may_oom); |
| 164 | 149 | current->memcg_oom.may_oom = 0; | |
| 165 | WARN_ON(old == true); | ||
| 166 | } | ||
| 167 | |||
| 168 | static inline void mem_cgroup_disable_oom(void) | ||
| 169 | { | ||
| 170 | bool old = mem_cgroup_toggle_oom(false); | ||
| 171 | |||
| 172 | WARN_ON(old == false); | ||
| 173 | } | 150 | } |
| 174 | 151 | ||
| 175 | static inline bool task_in_memcg_oom(struct task_struct *p) | 152 | static inline bool task_in_memcg_oom(struct task_struct *p) |
| 176 | { | 153 | { |
| 177 | return p->memcg_oom.in_memcg_oom; | 154 | return p->memcg_oom.memcg; |
| 178 | } | 155 | } |
| 179 | 156 | ||
| 180 | bool mem_cgroup_oom_synchronize(void); | 157 | bool mem_cgroup_oom_synchronize(bool wait); |
| 181 | 158 | ||
| 182 | #ifdef CONFIG_MEMCG_SWAP | 159 | #ifdef CONFIG_MEMCG_SWAP |
| 183 | extern int do_swap_account; | 160 | extern int do_swap_account; |
| @@ -402,16 +379,11 @@ static inline void mem_cgroup_end_update_page_stat(struct page *page, | |||
| 402 | { | 379 | { |
| 403 | } | 380 | } |
| 404 | 381 | ||
| 405 | static inline bool mem_cgroup_toggle_oom(bool new) | 382 | static inline void mem_cgroup_oom_enable(void) |
| 406 | { | ||
| 407 | return false; | ||
| 408 | } | ||
| 409 | |||
| 410 | static inline void mem_cgroup_enable_oom(void) | ||
| 411 | { | 383 | { |
| 412 | } | 384 | } |
| 413 | 385 | ||
| 414 | static inline void mem_cgroup_disable_oom(void) | 386 | static inline void mem_cgroup_oom_disable(void) |
| 415 | { | 387 | { |
| 416 | } | 388 | } |
| 417 | 389 | ||
| @@ -420,7 +392,7 @@ static inline bool task_in_memcg_oom(struct task_struct *p) | |||
| 420 | return false; | 392 | return false; |
| 421 | } | 393 | } |
| 422 | 394 | ||
| 423 | static inline bool mem_cgroup_oom_synchronize(void) | 395 | static inline bool mem_cgroup_oom_synchronize(bool wait) |
| 424 | { | 396 | { |
| 425 | return false; | 397 | return false; |
| 426 | } | 398 | } |
diff --git a/include/linux/mfd/mc13xxx.h b/include/linux/mfd/mc13xxx.h index 41ed59276c00..67c17b5a6f44 100644 --- a/include/linux/mfd/mc13xxx.h +++ b/include/linux/mfd/mc13xxx.h | |||
| @@ -41,6 +41,13 @@ int mc13xxx_adc_do_conversion(struct mc13xxx *mc13xxx, | |||
| 41 | unsigned int mode, unsigned int channel, | 41 | unsigned int mode, unsigned int channel, |
| 42 | u8 ato, bool atox, unsigned int *sample); | 42 | u8 ato, bool atox, unsigned int *sample); |
| 43 | 43 | ||
| 44 | #define MC13783_AUDIO_RX0 36 | ||
| 45 | #define MC13783_AUDIO_RX1 37 | ||
| 46 | #define MC13783_AUDIO_TX 38 | ||
| 47 | #define MC13783_SSI_NETWORK 39 | ||
| 48 | #define MC13783_AUDIO_CODEC 40 | ||
| 49 | #define MC13783_AUDIO_DAC 41 | ||
| 50 | |||
| 44 | #define MC13XXX_IRQ_ADCDONE 0 | 51 | #define MC13XXX_IRQ_ADCDONE 0 |
| 45 | #define MC13XXX_IRQ_ADCBISDONE 1 | 52 | #define MC13XXX_IRQ_ADCBISDONE 1 |
| 46 | #define MC13XXX_IRQ_TS 2 | 53 | #define MC13XXX_IRQ_TS 2 |
diff --git a/include/linux/mlx5/device.h b/include/linux/mlx5/device.h index 68029b30c3dc..5eb4e31af22b 100644 --- a/include/linux/mlx5/device.h +++ b/include/linux/mlx5/device.h | |||
| @@ -181,7 +181,7 @@ enum { | |||
| 181 | MLX5_DEV_CAP_FLAG_TLP_HINTS = 1LL << 39, | 181 | MLX5_DEV_CAP_FLAG_TLP_HINTS = 1LL << 39, |
| 182 | MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40, | 182 | MLX5_DEV_CAP_FLAG_SIG_HAND_OVER = 1LL << 40, |
| 183 | MLX5_DEV_CAP_FLAG_DCT = 1LL << 41, | 183 | MLX5_DEV_CAP_FLAG_DCT = 1LL << 41, |
| 184 | MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 1LL << 46, | 184 | MLX5_DEV_CAP_FLAG_CMDIF_CSUM = 3LL << 46, |
| 185 | }; | 185 | }; |
| 186 | 186 | ||
| 187 | enum { | 187 | enum { |
| @@ -417,7 +417,7 @@ struct mlx5_init_seg { | |||
| 417 | struct health_buffer health; | 417 | struct health_buffer health; |
| 418 | __be32 rsvd2[884]; | 418 | __be32 rsvd2[884]; |
| 419 | __be32 health_counter; | 419 | __be32 health_counter; |
| 420 | __be32 rsvd3[1023]; | 420 | __be32 rsvd3[1019]; |
| 421 | __be64 ieee1588_clk; | 421 | __be64 ieee1588_clk; |
| 422 | __be32 ieee1588_clk_type; | 422 | __be32 ieee1588_clk_type; |
| 423 | __be32 clr_intx; | 423 | __be32 clr_intx; |
diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h index 8888381fc150..6b8c496572c8 100644 --- a/include/linux/mlx5/driver.h +++ b/include/linux/mlx5/driver.h | |||
| @@ -82,7 +82,7 @@ enum { | |||
| 82 | }; | 82 | }; |
| 83 | 83 | ||
| 84 | enum { | 84 | enum { |
| 85 | MLX5_MAX_EQ_NAME = 20 | 85 | MLX5_MAX_EQ_NAME = 32 |
| 86 | }; | 86 | }; |
| 87 | 87 | ||
| 88 | enum { | 88 | enum { |
| @@ -747,8 +747,7 @@ static inline u32 mlx5_idx_to_mkey(u32 mkey_idx) | |||
| 747 | 747 | ||
| 748 | enum { | 748 | enum { |
| 749 | MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0, | 749 | MLX5_PROF_MASK_QP_SIZE = (u64)1 << 0, |
| 750 | MLX5_PROF_MASK_CMDIF_CSUM = (u64)1 << 1, | 750 | MLX5_PROF_MASK_MR_CACHE = (u64)1 << 1, |
| 751 | MLX5_PROF_MASK_MR_CACHE = (u64)1 << 2, | ||
| 752 | }; | 751 | }; |
| 753 | 752 | ||
| 754 | enum { | 753 | enum { |
| @@ -758,7 +757,6 @@ enum { | |||
| 758 | struct mlx5_profile { | 757 | struct mlx5_profile { |
| 759 | u64 mask; | 758 | u64 mask; |
| 760 | u32 log_max_qp; | 759 | u32 log_max_qp; |
| 761 | int cmdif_csum; | ||
| 762 | struct { | 760 | struct { |
| 763 | int size; | 761 | int size; |
| 764 | int limit; | 762 | int limit; |
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h deleted file mode 100644 index c84128255814..000000000000 --- a/include/linux/of_reserved_mem.h +++ /dev/null | |||
| @@ -1,14 +0,0 @@ | |||
| 1 | #ifndef __OF_RESERVED_MEM_H | ||
| 2 | #define __OF_RESERVED_MEM_H | ||
| 3 | |||
| 4 | #ifdef CONFIG_OF_RESERVED_MEM | ||
| 5 | void of_reserved_mem_device_init(struct device *dev); | ||
| 6 | void of_reserved_mem_device_release(struct device *dev); | ||
| 7 | void early_init_dt_scan_reserved_mem(void); | ||
| 8 | #else | ||
| 9 | static inline void of_reserved_mem_device_init(struct device *dev) { } | ||
| 10 | static inline void of_reserved_mem_device_release(struct device *dev) { } | ||
| 11 | static inline void early_init_dt_scan_reserved_mem(void) { } | ||
| 12 | #endif | ||
| 13 | |||
| 14 | #endif /* __OF_RESERVED_MEM_H */ | ||
diff --git a/include/linux/platform_data/davinci_asp.h b/include/linux/platform_data/davinci_asp.h index 8db5ae03b6e3..689a856b86f9 100644 --- a/include/linux/platform_data/davinci_asp.h +++ b/include/linux/platform_data/davinci_asp.h | |||
| @@ -84,6 +84,8 @@ struct snd_platform_data { | |||
| 84 | u8 version; | 84 | u8 version; |
| 85 | u8 txnumevt; | 85 | u8 txnumevt; |
| 86 | u8 rxnumevt; | 86 | u8 rxnumevt; |
| 87 | int tx_dma_channel; | ||
| 88 | int rx_dma_channel; | ||
| 87 | }; | 89 | }; |
| 88 | 90 | ||
| 89 | enum { | 91 | enum { |
diff --git a/include/linux/regmap.h b/include/linux/regmap.h index a10380bfbeac..dc90b8c134a1 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h | |||
| @@ -374,6 +374,7 @@ int regmap_reinit_cache(struct regmap *map, | |||
| 374 | const struct regmap_config *config); | 374 | const struct regmap_config *config); |
| 375 | struct regmap *dev_get_regmap(struct device *dev, const char *name); | 375 | struct regmap *dev_get_regmap(struct device *dev, const char *name); |
| 376 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); | 376 | int regmap_write(struct regmap *map, unsigned int reg, unsigned int val); |
| 377 | int regmap_write_async(struct regmap *map, unsigned int reg, unsigned int val); | ||
| 377 | int regmap_raw_write(struct regmap *map, unsigned int reg, | 378 | int regmap_raw_write(struct regmap *map, unsigned int reg, |
| 378 | const void *val, size_t val_len); | 379 | const void *val, size_t val_len); |
| 379 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, | 380 | int regmap_bulk_write(struct regmap *map, unsigned int reg, const void *val, |
| @@ -387,9 +388,14 @@ int regmap_bulk_read(struct regmap *map, unsigned int reg, void *val, | |||
| 387 | size_t val_count); | 388 | size_t val_count); |
| 388 | int regmap_update_bits(struct regmap *map, unsigned int reg, | 389 | int regmap_update_bits(struct regmap *map, unsigned int reg, |
| 389 | unsigned int mask, unsigned int val); | 390 | unsigned int mask, unsigned int val); |
| 391 | int regmap_update_bits_async(struct regmap *map, unsigned int reg, | ||
| 392 | unsigned int mask, unsigned int val); | ||
| 390 | int regmap_update_bits_check(struct regmap *map, unsigned int reg, | 393 | int regmap_update_bits_check(struct regmap *map, unsigned int reg, |
| 391 | unsigned int mask, unsigned int val, | 394 | unsigned int mask, unsigned int val, |
| 392 | bool *change); | 395 | bool *change); |
| 396 | int regmap_update_bits_check_async(struct regmap *map, unsigned int reg, | ||
| 397 | unsigned int mask, unsigned int val, | ||
| 398 | bool *change); | ||
| 393 | int regmap_get_val_bytes(struct regmap *map); | 399 | int regmap_get_val_bytes(struct regmap *map); |
| 394 | int regmap_async_complete(struct regmap *map); | 400 | int regmap_async_complete(struct regmap *map); |
| 395 | bool regmap_can_raw_write(struct regmap *map); | 401 | bool regmap_can_raw_write(struct regmap *map); |
| @@ -425,11 +431,15 @@ bool regmap_reg_in_ranges(unsigned int reg, | |||
| 425 | * @reg: Offset of the register within the regmap bank | 431 | * @reg: Offset of the register within the regmap bank |
| 426 | * @lsb: lsb of the register field. | 432 | * @lsb: lsb of the register field. |
| 427 | * @reg: msb of the register field. | 433 | * @reg: msb of the register field. |
| 434 | * @id_size: port size if it has some ports | ||
| 435 | * @id_offset: address offset for each ports | ||
| 428 | */ | 436 | */ |
| 429 | struct reg_field { | 437 | struct reg_field { |
| 430 | unsigned int reg; | 438 | unsigned int reg; |
| 431 | unsigned int lsb; | 439 | unsigned int lsb; |
| 432 | unsigned int msb; | 440 | unsigned int msb; |
| 441 | unsigned int id_size; | ||
| 442 | unsigned int id_offset; | ||
| 433 | }; | 443 | }; |
| 434 | 444 | ||
| 435 | #define REG_FIELD(_reg, _lsb, _msb) { \ | 445 | #define REG_FIELD(_reg, _lsb, _msb) { \ |
| @@ -448,6 +458,15 @@ void devm_regmap_field_free(struct device *dev, struct regmap_field *field); | |||
| 448 | 458 | ||
| 449 | int regmap_field_read(struct regmap_field *field, unsigned int *val); | 459 | int regmap_field_read(struct regmap_field *field, unsigned int *val); |
| 450 | int regmap_field_write(struct regmap_field *field, unsigned int val); | 460 | int regmap_field_write(struct regmap_field *field, unsigned int val); |
| 461 | int regmap_field_update_bits(struct regmap_field *field, | ||
| 462 | unsigned int mask, unsigned int val); | ||
| 463 | |||
| 464 | int regmap_fields_write(struct regmap_field *field, unsigned int id, | ||
| 465 | unsigned int val); | ||
| 466 | int regmap_fields_read(struct regmap_field *field, unsigned int id, | ||
| 467 | unsigned int *val); | ||
| 468 | int regmap_fields_update_bits(struct regmap_field *field, unsigned int id, | ||
| 469 | unsigned int mask, unsigned int val); | ||
| 451 | 470 | ||
| 452 | /** | 471 | /** |
| 453 | * Description of an IRQ for the generic regmap irq_chip. | 472 | * Description of an IRQ for the generic regmap irq_chip. |
| @@ -527,6 +546,13 @@ static inline int regmap_write(struct regmap *map, unsigned int reg, | |||
| 527 | return -EINVAL; | 546 | return -EINVAL; |
| 528 | } | 547 | } |
| 529 | 548 | ||
| 549 | static inline int regmap_write_async(struct regmap *map, unsigned int reg, | ||
| 550 | unsigned int val) | ||
| 551 | { | ||
| 552 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 553 | return -EINVAL; | ||
| 554 | } | ||
| 555 | |||
| 530 | static inline int regmap_raw_write(struct regmap *map, unsigned int reg, | 556 | static inline int regmap_raw_write(struct regmap *map, unsigned int reg, |
| 531 | const void *val, size_t val_len) | 557 | const void *val, size_t val_len) |
| 532 | { | 558 | { |
| @@ -576,6 +602,14 @@ static inline int regmap_update_bits(struct regmap *map, unsigned int reg, | |||
| 576 | return -EINVAL; | 602 | return -EINVAL; |
| 577 | } | 603 | } |
| 578 | 604 | ||
| 605 | static inline int regmap_update_bits_async(struct regmap *map, | ||
| 606 | unsigned int reg, | ||
| 607 | unsigned int mask, unsigned int val) | ||
| 608 | { | ||
| 609 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 610 | return -EINVAL; | ||
| 611 | } | ||
| 612 | |||
| 579 | static inline int regmap_update_bits_check(struct regmap *map, | 613 | static inline int regmap_update_bits_check(struct regmap *map, |
| 580 | unsigned int reg, | 614 | unsigned int reg, |
| 581 | unsigned int mask, unsigned int val, | 615 | unsigned int mask, unsigned int val, |
| @@ -585,6 +619,16 @@ static inline int regmap_update_bits_check(struct regmap *map, | |||
| 585 | return -EINVAL; | 619 | return -EINVAL; |
| 586 | } | 620 | } |
| 587 | 621 | ||
| 622 | static inline int regmap_update_bits_check_async(struct regmap *map, | ||
| 623 | unsigned int reg, | ||
| 624 | unsigned int mask, | ||
| 625 | unsigned int val, | ||
| 626 | bool *change) | ||
| 627 | { | ||
| 628 | WARN_ONCE(1, "regmap API is disabled"); | ||
| 629 | return -EINVAL; | ||
| 630 | } | ||
| 631 | |||
| 588 | static inline int regmap_get_val_bytes(struct regmap *map) | 632 | static inline int regmap_get_val_bytes(struct regmap *map) |
| 589 | { | 633 | { |
| 590 | WARN_ONCE(1, "regmap API is disabled"); | 634 | WARN_ONCE(1, "regmap API is disabled"); |
diff --git a/include/linux/sched.h b/include/linux/sched.h index 6682da36b293..e27baeeda3f4 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
| @@ -1394,11 +1394,10 @@ struct task_struct { | |||
| 1394 | } memcg_batch; | 1394 | } memcg_batch; |
| 1395 | unsigned int memcg_kmem_skip_account; | 1395 | unsigned int memcg_kmem_skip_account; |
| 1396 | struct memcg_oom_info { | 1396 | struct memcg_oom_info { |
| 1397 | struct mem_cgroup *memcg; | ||
| 1398 | gfp_t gfp_mask; | ||
| 1399 | int order; | ||
| 1397 | unsigned int may_oom:1; | 1400 | unsigned int may_oom:1; |
| 1398 | unsigned int in_memcg_oom:1; | ||
| 1399 | unsigned int oom_locked:1; | ||
| 1400 | int wakeups; | ||
| 1401 | struct mem_cgroup *wait_on_memcg; | ||
| 1402 | } memcg_oom; | 1401 | } memcg_oom; |
| 1403 | #endif | 1402 | #endif |
| 1404 | #ifdef CONFIG_UPROBES | 1403 | #ifdef CONFIG_UPROBES |
diff --git a/include/linux/usb/usb_phy_gen_xceiv.h b/include/linux/usb/usb_phy_gen_xceiv.h index f9a7e7bc925b..11d85b9c1b08 100644 --- a/include/linux/usb/usb_phy_gen_xceiv.h +++ b/include/linux/usb/usb_phy_gen_xceiv.h | |||
| @@ -12,7 +12,7 @@ struct usb_phy_gen_xceiv_platform_data { | |||
| 12 | unsigned int needs_reset:1; | 12 | unsigned int needs_reset:1; |
| 13 | }; | 13 | }; |
| 14 | 14 | ||
| 15 | #if IS_ENABLED(CONFIG_NOP_USB_XCEIV) | 15 | #if defined(CONFIG_NOP_USB_XCEIV) || (defined(CONFIG_NOP_USB_XCEIV_MODULE) && defined(MODULE)) |
| 16 | /* sometimes transceivers are accessed only through e.g. ULPI */ | 16 | /* sometimes transceivers are accessed only through e.g. ULPI */ |
| 17 | extern void usb_nop_xceiv_register(void); | 17 | extern void usb_nop_xceiv_register(void); |
| 18 | extern void usb_nop_xceiv_unregister(void); | 18 | extern void usb_nop_xceiv_unregister(void); |
diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h index bf99cd01be20..630356866030 100644 --- a/include/linux/usb_usual.h +++ b/include/linux/usb_usual.h | |||
| @@ -66,7 +66,9 @@ | |||
| 66 | US_FLAG(INITIAL_READ10, 0x00100000) \ | 66 | US_FLAG(INITIAL_READ10, 0x00100000) \ |
| 67 | /* Initial READ(10) (and others) must be retried */ \ | 67 | /* Initial READ(10) (and others) must be retried */ \ |
| 68 | US_FLAG(WRITE_CACHE, 0x00200000) \ | 68 | US_FLAG(WRITE_CACHE, 0x00200000) \ |
| 69 | /* Write Cache status is not available */ | 69 | /* Write Cache status is not available */ \ |
| 70 | US_FLAG(NEEDS_CAP16, 0x00400000) | ||
| 71 | /* cannot handle READ_CAPACITY_10 */ | ||
| 70 | 72 | ||
| 71 | #define US_FLAG(name, value) US_FL_##name = value , | 73 | #define US_FLAG(name, value) US_FL_##name = value , |
| 72 | enum { US_DO_ALL_FLAGS }; | 74 | enum { US_DO_ALL_FLAGS }; |
diff --git a/include/sound/cs42l73.h b/include/sound/cs42l73.h new file mode 100644 index 000000000000..f354be4cdc9e --- /dev/null +++ b/include/sound/cs42l73.h | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | /* | ||
| 2 | * linux/sound/cs42l73.h -- Platform data for CS42L73 | ||
| 3 | * | ||
| 4 | * Copyright (c) 2012 Cirrus Logic Inc. | ||
| 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 __CS42L73_H | ||
| 12 | #define __CS42L73_H | ||
| 13 | |||
| 14 | struct cs42l73_platform_data { | ||
| 15 | /* RST GPIO */ | ||
| 16 | unsigned int reset_gpio; | ||
| 17 | unsigned int chgfreq; | ||
| 18 | int jack_detection; | ||
| 19 | unsigned int mclk_freq; | ||
| 20 | }; | ||
| 21 | |||
| 22 | #endif /* __CS42L73_H */ | ||
diff --git a/include/sound/dmaengine_pcm.h b/include/sound/dmaengine_pcm.h index f11c35cd5532..15017311f2e9 100644 --- a/include/sound/dmaengine_pcm.h +++ b/include/sound/dmaengine_pcm.h | |||
| @@ -61,6 +61,8 @@ struct dma_chan *snd_dmaengine_pcm_get_chan(struct snd_pcm_substream *substream) | |||
| 61 | * @slave_id: Slave requester id for the DMA channel. | 61 | * @slave_id: Slave requester id for the DMA channel. |
| 62 | * @filter_data: Custom DMA channel filter data, this will usually be used when | 62 | * @filter_data: Custom DMA channel filter data, this will usually be used when |
| 63 | * requesting the DMA channel. | 63 | * requesting the DMA channel. |
| 64 | * @chan_name: Custom channel name to use when requesting DMA channel. | ||
| 65 | * @fifo_size: FIFO size of the DAI controller in bytes | ||
| 64 | */ | 66 | */ |
| 65 | struct snd_dmaengine_dai_dma_data { | 67 | struct snd_dmaengine_dai_dma_data { |
| 66 | dma_addr_t addr; | 68 | dma_addr_t addr; |
| @@ -68,6 +70,8 @@ struct snd_dmaengine_dai_dma_data { | |||
| 68 | u32 maxburst; | 70 | u32 maxburst; |
| 69 | unsigned int slave_id; | 71 | unsigned int slave_id; |
| 70 | void *filter_data; | 72 | void *filter_data; |
| 73 | const char *chan_name; | ||
| 74 | unsigned int fifo_size; | ||
| 71 | }; | 75 | }; |
| 72 | 76 | ||
| 73 | void snd_dmaengine_pcm_set_config_from_dai_data( | 77 | void snd_dmaengine_pcm_set_config_from_dai_data( |
| @@ -96,6 +100,10 @@ void snd_dmaengine_pcm_set_config_from_dai_data( | |||
| 96 | * playback. | 100 | * playback. |
| 97 | */ | 101 | */ |
| 98 | #define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3) | 102 | #define SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX BIT(3) |
| 103 | /* | ||
| 104 | * The PCM streams have custom channel names specified. | ||
| 105 | */ | ||
| 106 | #define SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME BIT(4) | ||
| 99 | 107 | ||
| 100 | /** | 108 | /** |
| 101 | * struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM | 109 | * struct snd_dmaengine_pcm_config - Configuration data for dmaengine based PCM |
diff --git a/include/sound/rcar_snd.h b/include/sound/rcar_snd.h index fe66533e9b7a..12afab18945d 100644 --- a/include/sound/rcar_snd.h +++ b/include/sound/rcar_snd.h | |||
| @@ -36,7 +36,6 @@ | |||
| 36 | #define RSND_SSI_CLK_PIN_SHARE (1 << 31) | 36 | #define RSND_SSI_CLK_PIN_SHARE (1 << 31) |
| 37 | #define RSND_SSI_CLK_FROM_ADG (1 << 30) /* clock parent is master */ | 37 | #define RSND_SSI_CLK_FROM_ADG (1 << 30) /* clock parent is master */ |
| 38 | #define RSND_SSI_SYNC (1 << 29) /* SSI34_sync etc */ | 38 | #define RSND_SSI_SYNC (1 << 29) /* SSI34_sync etc */ |
| 39 | #define RSND_SSI_DEPENDENT (1 << 28) /* SSI needs SRU/SCU */ | ||
| 40 | 39 | ||
| 41 | #define RSND_SSI_PLAY (1 << 24) | 40 | #define RSND_SSI_PLAY (1 << 24) |
| 42 | 41 | ||
| @@ -68,6 +67,7 @@ struct rsnd_scu_platform_info { | |||
| 68 | * | 67 | * |
| 69 | * A : generation | 68 | * A : generation |
| 70 | */ | 69 | */ |
| 70 | #define RSND_GEN_MASK (0xF << 0) | ||
| 71 | #define RSND_GEN1 (1 << 0) /* fixme */ | 71 | #define RSND_GEN1 (1 << 0) /* fixme */ |
| 72 | #define RSND_GEN2 (2 << 0) /* fixme */ | 72 | #define RSND_GEN2 (2 << 0) /* fixme */ |
| 73 | 73 | ||
diff --git a/include/sound/soc-dai.h b/include/sound/soc-dai.h index ae9a227d35d3..800c101bb096 100644 --- a/include/sound/soc-dai.h +++ b/include/sound/soc-dai.h | |||
| @@ -105,6 +105,8 @@ int snd_soc_dai_set_clkdiv(struct snd_soc_dai *dai, | |||
| 105 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, | 105 | int snd_soc_dai_set_pll(struct snd_soc_dai *dai, |
| 106 | int pll_id, int source, unsigned int freq_in, unsigned int freq_out); | 106 | int pll_id, int source, unsigned int freq_in, unsigned int freq_out); |
| 107 | 107 | ||
| 108 | int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio); | ||
| 109 | |||
| 108 | /* Digital Audio interface formatting */ | 110 | /* Digital Audio interface formatting */ |
| 109 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); | 111 | int snd_soc_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt); |
| 110 | 112 | ||
| @@ -131,6 +133,7 @@ struct snd_soc_dai_ops { | |||
| 131 | int (*set_pll)(struct snd_soc_dai *dai, int pll_id, int source, | 133 | int (*set_pll)(struct snd_soc_dai *dai, int pll_id, int source, |
| 132 | unsigned int freq_in, unsigned int freq_out); | 134 | unsigned int freq_in, unsigned int freq_out); |
| 133 | int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div); | 135 | int (*set_clkdiv)(struct snd_soc_dai *dai, int div_id, int div); |
| 136 | int (*set_bclk_ratio)(struct snd_soc_dai *dai, unsigned int ratio); | ||
| 134 | 137 | ||
| 135 | /* | 138 | /* |
| 136 | * DAI format configuration | 139 | * DAI format configuration |
| @@ -166,6 +169,13 @@ struct snd_soc_dai_ops { | |||
| 166 | struct snd_soc_dai *); | 169 | struct snd_soc_dai *); |
| 167 | int (*prepare)(struct snd_pcm_substream *, | 170 | int (*prepare)(struct snd_pcm_substream *, |
| 168 | struct snd_soc_dai *); | 171 | struct snd_soc_dai *); |
| 172 | /* | ||
| 173 | * NOTE: Commands passed to the trigger function are not necessarily | ||
| 174 | * compatible with the current state of the dai. For example this | ||
| 175 | * sequence of commands is possible: START STOP STOP. | ||
| 176 | * So do not unconditionally use refcounting functions in the trigger | ||
| 177 | * function, e.g. clk_enable/disable. | ||
| 178 | */ | ||
| 169 | int (*trigger)(struct snd_pcm_substream *, int, | 179 | int (*trigger)(struct snd_pcm_substream *, int, |
| 170 | struct snd_soc_dai *); | 180 | struct snd_soc_dai *); |
| 171 | int (*bespoke_trigger)(struct snd_pcm_substream *, int, | 181 | int (*bespoke_trigger)(struct snd_pcm_substream *, int, |
| @@ -276,6 +286,13 @@ static inline void snd_soc_dai_set_dma_data(struct snd_soc_dai *dai, | |||
| 276 | dai->capture_dma_data = data; | 286 | dai->capture_dma_data = data; |
| 277 | } | 287 | } |
| 278 | 288 | ||
| 289 | static inline void snd_soc_dai_init_dma_data(struct snd_soc_dai *dai, | ||
| 290 | void *playback, void *capture) | ||
| 291 | { | ||
| 292 | dai->playback_dma_data = playback; | ||
| 293 | dai->capture_dma_data = capture; | ||
| 294 | } | ||
| 295 | |||
| 279 | static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai, | 296 | static inline void snd_soc_dai_set_drvdata(struct snd_soc_dai *dai, |
| 280 | void *data) | 297 | void *data) |
| 281 | { | 298 | { |
diff --git a/include/sound/soc-dapm.h b/include/sound/soc-dapm.h index 27a72d5d4b00..2037c45adfe6 100644 --- a/include/sound/soc-dapm.h +++ b/include/sound/soc-dapm.h | |||
| @@ -286,6 +286,8 @@ struct device; | |||
| 286 | .info = snd_soc_info_volsw, \ | 286 | .info = snd_soc_info_volsw, \ |
| 287 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ | 287 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 288 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) } | 288 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 1) } |
| 289 | #define SOC_DAPM_SINGLE_VIRT(xname, max) \ | ||
| 290 | SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0) | ||
| 289 | #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ | 291 | #define SOC_DAPM_SINGLE_TLV(xname, reg, shift, max, invert, tlv_array) \ |
| 290 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 292 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 291 | .info = snd_soc_info_volsw, \ | 293 | .info = snd_soc_info_volsw, \ |
| @@ -300,6 +302,8 @@ struct device; | |||
| 300 | .tlv.p = (tlv_array), \ | 302 | .tlv.p = (tlv_array), \ |
| 301 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ | 303 | .get = snd_soc_dapm_get_volsw, .put = snd_soc_dapm_put_volsw, \ |
| 302 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } | 304 | .private_value = SOC_SINGLE_VALUE(reg, shift, max, invert, 0) } |
| 305 | #define SOC_DAPM_SINGLE_TLV_VIRT(xname, max, tlv_array) \ | ||
| 306 | SOC_DAPM_SINGLE(xname, SND_SOC_NOPM, 0, max, 0, tlv_array) | ||
| 303 | #define SOC_DAPM_ENUM(xname, xenum) \ | 307 | #define SOC_DAPM_ENUM(xname, xenum) \ |
| 304 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ | 308 | { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
| 305 | .info = snd_soc_info_enum_double, \ | 309 | .info = snd_soc_info_enum_double, \ |
diff --git a/include/sound/soc.h b/include/sound/soc.h index d22cb0a06feb..1f741cb24f33 100644 --- a/include/sound/soc.h +++ b/include/sound/soc.h | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #ifndef __LINUX_SND_SOC_H | 13 | #ifndef __LINUX_SND_SOC_H |
| 14 | #define __LINUX_SND_SOC_H | 14 | #define __LINUX_SND_SOC_H |
| 15 | 15 | ||
| 16 | #include <linux/of.h> | ||
| 16 | #include <linux/platform_device.h> | 17 | #include <linux/platform_device.h> |
| 17 | #include <linux/types.h> | 18 | #include <linux/types.h> |
| 18 | #include <linux/notifier.h> | 19 | #include <linux/notifier.h> |
| @@ -330,7 +331,6 @@ struct soc_enum; | |||
| 330 | struct snd_soc_jack; | 331 | struct snd_soc_jack; |
| 331 | struct snd_soc_jack_zone; | 332 | struct snd_soc_jack_zone; |
| 332 | struct snd_soc_jack_pin; | 333 | struct snd_soc_jack_pin; |
| 333 | struct snd_soc_cache_ops; | ||
| 334 | #include <sound/soc-dapm.h> | 334 | #include <sound/soc-dapm.h> |
| 335 | #include <sound/soc-dpcm.h> | 335 | #include <sound/soc-dpcm.h> |
| 336 | 336 | ||
| @@ -348,10 +348,6 @@ enum snd_soc_control_type { | |||
| 348 | SND_SOC_REGMAP, | 348 | SND_SOC_REGMAP, |
| 349 | }; | 349 | }; |
| 350 | 350 | ||
| 351 | enum snd_soc_compress_type { | ||
| 352 | SND_SOC_FLAT_COMPRESSION = 1, | ||
| 353 | }; | ||
| 354 | |||
| 355 | enum snd_soc_pcm_subclass { | 351 | enum snd_soc_pcm_subclass { |
| 356 | SND_SOC_PCM_CLASS_PCM = 0, | 352 | SND_SOC_PCM_CLASS_PCM = 0, |
| 357 | SND_SOC_PCM_CLASS_BE = 1, | 353 | SND_SOC_PCM_CLASS_BE = 1, |
| @@ -369,6 +365,7 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, | |||
| 369 | 365 | ||
| 370 | int snd_soc_register_card(struct snd_soc_card *card); | 366 | int snd_soc_register_card(struct snd_soc_card *card); |
| 371 | int snd_soc_unregister_card(struct snd_soc_card *card); | 367 | int snd_soc_unregister_card(struct snd_soc_card *card); |
| 368 | int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card); | ||
| 372 | int snd_soc_suspend(struct device *dev); | 369 | int snd_soc_suspend(struct device *dev); |
| 373 | int snd_soc_resume(struct device *dev); | 370 | int snd_soc_resume(struct device *dev); |
| 374 | int snd_soc_poweroff(struct device *dev); | 371 | int snd_soc_poweroff(struct device *dev); |
| @@ -386,6 +383,9 @@ void snd_soc_unregister_codec(struct device *dev); | |||
| 386 | int snd_soc_register_component(struct device *dev, | 383 | int snd_soc_register_component(struct device *dev, |
| 387 | const struct snd_soc_component_driver *cmpnt_drv, | 384 | const struct snd_soc_component_driver *cmpnt_drv, |
| 388 | struct snd_soc_dai_driver *dai_drv, int num_dai); | 385 | struct snd_soc_dai_driver *dai_drv, int num_dai); |
| 386 | int devm_snd_soc_register_component(struct device *dev, | ||
| 387 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 388 | struct snd_soc_dai_driver *dai_drv, int num_dai); | ||
| 389 | void snd_soc_unregister_component(struct device *dev); | 389 | void snd_soc_unregister_component(struct device *dev); |
| 390 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, | 390 | int snd_soc_codec_volatile_register(struct snd_soc_codec *codec, |
| 391 | unsigned int reg); | 391 | unsigned int reg); |
| @@ -403,12 +403,6 @@ int snd_soc_cache_write(struct snd_soc_codec *codec, | |||
| 403 | unsigned int reg, unsigned int value); | 403 | unsigned int reg, unsigned int value); |
| 404 | int snd_soc_cache_read(struct snd_soc_codec *codec, | 404 | int snd_soc_cache_read(struct snd_soc_codec *codec, |
| 405 | unsigned int reg, unsigned int *value); | 405 | unsigned int reg, unsigned int *value); |
| 406 | int snd_soc_default_volatile_register(struct snd_soc_codec *codec, | ||
| 407 | unsigned int reg); | ||
| 408 | int snd_soc_default_readable_register(struct snd_soc_codec *codec, | ||
| 409 | unsigned int reg); | ||
| 410 | int snd_soc_default_writable_register(struct snd_soc_codec *codec, | ||
| 411 | unsigned int reg); | ||
| 412 | int snd_soc_platform_read(struct snd_soc_platform *platform, | 406 | int snd_soc_platform_read(struct snd_soc_platform *platform, |
| 413 | unsigned int reg); | 407 | unsigned int reg); |
| 414 | int snd_soc_platform_write(struct snd_soc_platform *platform, | 408 | int snd_soc_platform_write(struct snd_soc_platform *platform, |
| @@ -542,22 +536,6 @@ int snd_soc_put_strobe(struct snd_kcontrol *kcontrol, | |||
| 542 | struct snd_ctl_elem_value *ucontrol); | 536 | struct snd_ctl_elem_value *ucontrol); |
| 543 | 537 | ||
| 544 | /** | 538 | /** |
| 545 | * struct snd_soc_reg_access - Describes whether a given register is | ||
| 546 | * readable, writable or volatile. | ||
| 547 | * | ||
| 548 | * @reg: the register number | ||
| 549 | * @read: whether this register is readable | ||
| 550 | * @write: whether this register is writable | ||
| 551 | * @vol: whether this register is volatile | ||
| 552 | */ | ||
| 553 | struct snd_soc_reg_access { | ||
| 554 | u16 reg; | ||
| 555 | u16 read; | ||
| 556 | u16 write; | ||
| 557 | u16 vol; | ||
| 558 | }; | ||
| 559 | |||
| 560 | /** | ||
| 561 | * struct snd_soc_jack_pin - Describes a pin to update based on jack detection | 539 | * struct snd_soc_jack_pin - Describes a pin to update based on jack detection |
| 562 | * | 540 | * |
| 563 | * @pin: name of the pin to update | 541 | * @pin: name of the pin to update |
| @@ -657,17 +635,26 @@ struct snd_soc_compr_ops { | |||
| 657 | int (*trigger)(struct snd_compr_stream *); | 635 | int (*trigger)(struct snd_compr_stream *); |
| 658 | }; | 636 | }; |
| 659 | 637 | ||
| 660 | /* SoC cache ops */ | 638 | /* component interface */ |
| 661 | struct snd_soc_cache_ops { | 639 | struct snd_soc_component_driver { |
| 640 | const char *name; | ||
| 641 | |||
| 642 | /* DT */ | ||
| 643 | int (*of_xlate_dai_name)(struct snd_soc_component *component, | ||
| 644 | struct of_phandle_args *args, | ||
| 645 | const char **dai_name); | ||
| 646 | }; | ||
| 647 | |||
| 648 | struct snd_soc_component { | ||
| 662 | const char *name; | 649 | const char *name; |
| 663 | enum snd_soc_compress_type id; | 650 | int id; |
| 664 | int (*init)(struct snd_soc_codec *codec); | 651 | struct device *dev; |
| 665 | int (*exit)(struct snd_soc_codec *codec); | 652 | struct list_head list; |
| 666 | int (*read)(struct snd_soc_codec *codec, unsigned int reg, | 653 | |
| 667 | unsigned int *value); | 654 | struct snd_soc_dai_driver *dai_drv; |
| 668 | int (*write)(struct snd_soc_codec *codec, unsigned int reg, | 655 | int num_dai; |
| 669 | unsigned int value); | 656 | |
| 670 | int (*sync)(struct snd_soc_codec *codec); | 657 | const struct snd_soc_component_driver *driver; |
| 671 | }; | 658 | }; |
| 672 | 659 | ||
| 673 | /* SoC Audio Codec device */ | 660 | /* SoC Audio Codec device */ |
| @@ -683,8 +670,6 @@ struct snd_soc_codec { | |||
| 683 | struct list_head list; | 670 | struct list_head list; |
| 684 | struct list_head card_list; | 671 | struct list_head card_list; |
| 685 | int num_dai; | 672 | int num_dai; |
| 686 | enum snd_soc_compress_type compress_type; | ||
| 687 | size_t reg_size; /* reg_cache_size * reg_word_size */ | ||
| 688 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); | 673 | int (*volatile_register)(struct snd_soc_codec *, unsigned int); |
| 689 | int (*readable_register)(struct snd_soc_codec *, unsigned int); | 674 | int (*readable_register)(struct snd_soc_codec *, unsigned int); |
| 690 | int (*writable_register)(struct snd_soc_codec *, unsigned int); | 675 | int (*writable_register)(struct snd_soc_codec *, unsigned int); |
| @@ -708,13 +693,13 @@ struct snd_soc_codec { | |||
| 708 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); | 693 | unsigned int (*hw_read)(struct snd_soc_codec *, unsigned int); |
| 709 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); | 694 | unsigned int (*read)(struct snd_soc_codec *, unsigned int); |
| 710 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); | 695 | int (*write)(struct snd_soc_codec *, unsigned int, unsigned int); |
| 711 | int (*bulk_write_raw)(struct snd_soc_codec *, unsigned int, const void *, size_t); | ||
| 712 | void *reg_cache; | 696 | void *reg_cache; |
| 713 | const void *reg_def_copy; | ||
| 714 | const struct snd_soc_cache_ops *cache_ops; | ||
| 715 | struct mutex cache_rw_mutex; | 697 | struct mutex cache_rw_mutex; |
| 716 | int val_bytes; | 698 | int val_bytes; |
| 717 | 699 | ||
| 700 | /* component */ | ||
| 701 | struct snd_soc_component component; | ||
| 702 | |||
| 718 | /* dapm */ | 703 | /* dapm */ |
| 719 | struct snd_soc_dapm_context dapm; | 704 | struct snd_soc_dapm_context dapm; |
| 720 | unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ | 705 | unsigned int ignore_pmdown_time:1; /* pmdown_time is ignored at stop */ |
| @@ -733,6 +718,7 @@ struct snd_soc_codec_driver { | |||
| 733 | int (*remove)(struct snd_soc_codec *); | 718 | int (*remove)(struct snd_soc_codec *); |
| 734 | int (*suspend)(struct snd_soc_codec *); | 719 | int (*suspend)(struct snd_soc_codec *); |
| 735 | int (*resume)(struct snd_soc_codec *); | 720 | int (*resume)(struct snd_soc_codec *); |
| 721 | struct snd_soc_component_driver component_driver; | ||
| 736 | 722 | ||
| 737 | /* Default control and setup, added after probe() is run */ | 723 | /* Default control and setup, added after probe() is run */ |
| 738 | const struct snd_kcontrol_new *controls; | 724 | const struct snd_kcontrol_new *controls; |
| @@ -760,9 +746,6 @@ struct snd_soc_codec_driver { | |||
| 760 | short reg_cache_step; | 746 | short reg_cache_step; |
| 761 | short reg_word_size; | 747 | short reg_word_size; |
| 762 | const void *reg_cache_default; | 748 | const void *reg_cache_default; |
| 763 | short reg_access_size; | ||
| 764 | const struct snd_soc_reg_access *reg_access_default; | ||
| 765 | enum snd_soc_compress_type compress_type; | ||
| 766 | 749 | ||
| 767 | /* codec bias level */ | 750 | /* codec bias level */ |
| 768 | int (*set_bias_level)(struct snd_soc_codec *, | 751 | int (*set_bias_level)(struct snd_soc_codec *, |
| @@ -849,20 +832,6 @@ struct snd_soc_platform { | |||
| 849 | #endif | 832 | #endif |
| 850 | }; | 833 | }; |
| 851 | 834 | ||
| 852 | struct snd_soc_component_driver { | ||
| 853 | const char *name; | ||
| 854 | }; | ||
| 855 | |||
| 856 | struct snd_soc_component { | ||
| 857 | const char *name; | ||
| 858 | int id; | ||
| 859 | int num_dai; | ||
| 860 | struct device *dev; | ||
| 861 | struct list_head list; | ||
| 862 | |||
| 863 | const struct snd_soc_component_driver *driver; | ||
| 864 | }; | ||
| 865 | |||
| 866 | struct snd_soc_dai_link { | 835 | struct snd_soc_dai_link { |
| 867 | /* config - must be set by machine driver */ | 836 | /* config - must be set by machine driver */ |
| 868 | const char *name; /* Codec name */ | 837 | const char *name; /* Codec name */ |
| @@ -944,12 +913,6 @@ struct snd_soc_codec_conf { | |||
| 944 | * associated per device | 913 | * associated per device |
| 945 | */ | 914 | */ |
| 946 | const char *name_prefix; | 915 | const char *name_prefix; |
| 947 | |||
| 948 | /* | ||
| 949 | * set this to the desired compression type if you want to | ||
| 950 | * override the one supplied in codec->driver->compress_type | ||
| 951 | */ | ||
| 952 | enum snd_soc_compress_type compress_type; | ||
| 953 | }; | 916 | }; |
| 954 | 917 | ||
| 955 | struct snd_soc_aux_dev { | 918 | struct snd_soc_aux_dev { |
| @@ -1088,7 +1051,8 @@ struct snd_soc_pcm_runtime { | |||
| 1088 | /* mixer control */ | 1051 | /* mixer control */ |
| 1089 | struct soc_mixer_control { | 1052 | struct soc_mixer_control { |
| 1090 | int min, max, platform_max; | 1053 | int min, max, platform_max; |
| 1091 | unsigned int reg, rreg, shift, rshift; | 1054 | int reg, rreg; |
| 1055 | unsigned int shift, rshift; | ||
| 1092 | unsigned int invert:1; | 1056 | unsigned int invert:1; |
| 1093 | unsigned int autodisable:1; | 1057 | unsigned int autodisable:1; |
| 1094 | }; | 1058 | }; |
| @@ -1121,8 +1085,6 @@ struct soc_enum { | |||
| 1121 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); | 1085 | unsigned int snd_soc_read(struct snd_soc_codec *codec, unsigned int reg); |
| 1122 | unsigned int snd_soc_write(struct snd_soc_codec *codec, | 1086 | unsigned int snd_soc_write(struct snd_soc_codec *codec, |
| 1123 | unsigned int reg, unsigned int val); | 1087 | unsigned int reg, unsigned int val); |
| 1124 | unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec, | ||
| 1125 | unsigned int reg, const void *data, size_t len); | ||
| 1126 | 1088 | ||
| 1127 | /* device driver data */ | 1089 | /* device driver data */ |
| 1128 | 1090 | ||
| @@ -1201,6 +1163,8 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
| 1201 | const char *propname); | 1163 | const char *propname); |
| 1202 | unsigned int snd_soc_of_parse_daifmt(struct device_node *np, | 1164 | unsigned int snd_soc_of_parse_daifmt(struct device_node *np, |
| 1203 | const char *prefix); | 1165 | const char *prefix); |
| 1166 | int snd_soc_of_get_dai_name(struct device_node *of_node, | ||
| 1167 | const char **dai_name); | ||
| 1204 | 1168 | ||
| 1205 | #include <sound/soc-dai.h> | 1169 | #include <sound/soc-dai.h> |
| 1206 | 1170 | ||
diff --git a/include/trace/events/asoc.h b/include/trace/events/asoc.h index 5fc2dcdd21cd..03996b2bb04f 100644 --- a/include/trace/events/asoc.h +++ b/include/trace/events/asoc.h | |||
| @@ -14,6 +14,7 @@ struct snd_soc_codec; | |||
| 14 | struct snd_soc_platform; | 14 | struct snd_soc_platform; |
| 15 | struct snd_soc_card; | 15 | struct snd_soc_card; |
| 16 | struct snd_soc_dapm_widget; | 16 | struct snd_soc_dapm_widget; |
| 17 | struct snd_soc_dapm_path; | ||
| 17 | 18 | ||
| 18 | /* | 19 | /* |
| 19 | * Log register events | 20 | * Log register events |
| @@ -1282,6 +1282,12 @@ static int semctl_setval(struct ipc_namespace *ns, int semid, int semnum, | |||
| 1282 | 1282 | ||
| 1283 | sem_lock(sma, NULL, -1); | 1283 | sem_lock(sma, NULL, -1); |
| 1284 | 1284 | ||
| 1285 | if (sma->sem_perm.deleted) { | ||
| 1286 | sem_unlock(sma, -1); | ||
| 1287 | rcu_read_unlock(); | ||
| 1288 | return -EIDRM; | ||
| 1289 | } | ||
| 1290 | |||
| 1285 | curr = &sma->sem_base[semnum]; | 1291 | curr = &sma->sem_base[semnum]; |
| 1286 | 1292 | ||
| 1287 | ipc_assert_locked_object(&sma->sem_perm); | 1293 | ipc_assert_locked_object(&sma->sem_perm); |
| @@ -1336,12 +1342,14 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
| 1336 | int i; | 1342 | int i; |
| 1337 | 1343 | ||
| 1338 | sem_lock(sma, NULL, -1); | 1344 | sem_lock(sma, NULL, -1); |
| 1345 | if (sma->sem_perm.deleted) { | ||
| 1346 | err = -EIDRM; | ||
| 1347 | goto out_unlock; | ||
| 1348 | } | ||
| 1339 | if(nsems > SEMMSL_FAST) { | 1349 | if(nsems > SEMMSL_FAST) { |
| 1340 | if (!ipc_rcu_getref(sma)) { | 1350 | if (!ipc_rcu_getref(sma)) { |
| 1341 | sem_unlock(sma, -1); | ||
| 1342 | rcu_read_unlock(); | ||
| 1343 | err = -EIDRM; | 1351 | err = -EIDRM; |
| 1344 | goto out_free; | 1352 | goto out_unlock; |
| 1345 | } | 1353 | } |
| 1346 | sem_unlock(sma, -1); | 1354 | sem_unlock(sma, -1); |
| 1347 | rcu_read_unlock(); | 1355 | rcu_read_unlock(); |
| @@ -1354,10 +1362,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
| 1354 | rcu_read_lock(); | 1362 | rcu_read_lock(); |
| 1355 | sem_lock_and_putref(sma); | 1363 | sem_lock_and_putref(sma); |
| 1356 | if (sma->sem_perm.deleted) { | 1364 | if (sma->sem_perm.deleted) { |
| 1357 | sem_unlock(sma, -1); | ||
| 1358 | rcu_read_unlock(); | ||
| 1359 | err = -EIDRM; | 1365 | err = -EIDRM; |
| 1360 | goto out_free; | 1366 | goto out_unlock; |
| 1361 | } | 1367 | } |
| 1362 | } | 1368 | } |
| 1363 | for (i = 0; i < sma->sem_nsems; i++) | 1369 | for (i = 0; i < sma->sem_nsems; i++) |
| @@ -1375,8 +1381,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
| 1375 | struct sem_undo *un; | 1381 | struct sem_undo *un; |
| 1376 | 1382 | ||
| 1377 | if (!ipc_rcu_getref(sma)) { | 1383 | if (!ipc_rcu_getref(sma)) { |
| 1378 | rcu_read_unlock(); | 1384 | err = -EIDRM; |
| 1379 | return -EIDRM; | 1385 | goto out_rcu_wakeup; |
| 1380 | } | 1386 | } |
| 1381 | rcu_read_unlock(); | 1387 | rcu_read_unlock(); |
| 1382 | 1388 | ||
| @@ -1404,10 +1410,8 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
| 1404 | rcu_read_lock(); | 1410 | rcu_read_lock(); |
| 1405 | sem_lock_and_putref(sma); | 1411 | sem_lock_and_putref(sma); |
| 1406 | if (sma->sem_perm.deleted) { | 1412 | if (sma->sem_perm.deleted) { |
| 1407 | sem_unlock(sma, -1); | ||
| 1408 | rcu_read_unlock(); | ||
| 1409 | err = -EIDRM; | 1413 | err = -EIDRM; |
| 1410 | goto out_free; | 1414 | goto out_unlock; |
| 1411 | } | 1415 | } |
| 1412 | 1416 | ||
| 1413 | for (i = 0; i < nsems; i++) | 1417 | for (i = 0; i < nsems; i++) |
| @@ -1431,6 +1435,10 @@ static int semctl_main(struct ipc_namespace *ns, int semid, int semnum, | |||
| 1431 | goto out_rcu_wakeup; | 1435 | goto out_rcu_wakeup; |
| 1432 | 1436 | ||
| 1433 | sem_lock(sma, NULL, -1); | 1437 | sem_lock(sma, NULL, -1); |
| 1438 | if (sma->sem_perm.deleted) { | ||
| 1439 | err = -EIDRM; | ||
| 1440 | goto out_unlock; | ||
| 1441 | } | ||
| 1434 | curr = &sma->sem_base[semnum]; | 1442 | curr = &sma->sem_base[semnum]; |
| 1435 | 1443 | ||
| 1436 | switch (cmd) { | 1444 | switch (cmd) { |
| @@ -1836,6 +1844,10 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
| 1836 | if (error) | 1844 | if (error) |
| 1837 | goto out_rcu_wakeup; | 1845 | goto out_rcu_wakeup; |
| 1838 | 1846 | ||
| 1847 | error = -EIDRM; | ||
| 1848 | locknum = sem_lock(sma, sops, nsops); | ||
| 1849 | if (sma->sem_perm.deleted) | ||
| 1850 | goto out_unlock_free; | ||
| 1839 | /* | 1851 | /* |
| 1840 | * semid identifiers are not unique - find_alloc_undo may have | 1852 | * semid identifiers are not unique - find_alloc_undo may have |
| 1841 | * allocated an undo structure, it was invalidated by an RMID | 1853 | * allocated an undo structure, it was invalidated by an RMID |
| @@ -1843,8 +1855,6 @@ SYSCALL_DEFINE4(semtimedop, int, semid, struct sembuf __user *, tsops, | |||
| 1843 | * This case can be detected checking un->semid. The existence of | 1855 | * This case can be detected checking un->semid. The existence of |
| 1844 | * "un" itself is guaranteed by rcu. | 1856 | * "un" itself is guaranteed by rcu. |
| 1845 | */ | 1857 | */ |
| 1846 | error = -EIDRM; | ||
| 1847 | locknum = sem_lock(sma, sops, nsops); | ||
| 1848 | if (un && un->semid == -1) | 1858 | if (un && un->semid == -1) |
| 1849 | goto out_unlock_free; | 1859 | goto out_unlock_free; |
| 1850 | 1860 | ||
| @@ -2057,6 +2067,12 @@ void exit_sem(struct task_struct *tsk) | |||
| 2057 | } | 2067 | } |
| 2058 | 2068 | ||
| 2059 | sem_lock(sma, NULL, -1); | 2069 | sem_lock(sma, NULL, -1); |
| 2070 | /* exit_sem raced with IPC_RMID, nothing to do */ | ||
| 2071 | if (sma->sem_perm.deleted) { | ||
| 2072 | sem_unlock(sma, -1); | ||
| 2073 | rcu_read_unlock(); | ||
| 2074 | continue; | ||
| 2075 | } | ||
| 2060 | un = __lookup_undo(ulp, semid); | 2076 | un = __lookup_undo(ulp, semid); |
| 2061 | if (un == NULL) { | 2077 | if (un == NULL) { |
| 2062 | /* exit_sem raced with IPC_RMID+semget() that created | 2078 | /* exit_sem raced with IPC_RMID+semget() that created |
diff --git a/ipc/util.c b/ipc/util.c index fdb8ae740775..7684f41bce76 100644 --- a/ipc/util.c +++ b/ipc/util.c | |||
| @@ -17,12 +17,27 @@ | |||
| 17 | * Pavel Emelianov <xemul@openvz.org> | 17 | * Pavel Emelianov <xemul@openvz.org> |
| 18 | * | 18 | * |
| 19 | * General sysv ipc locking scheme: | 19 | * General sysv ipc locking scheme: |
| 20 | * when doing ipc id lookups, take the ids->rwsem | 20 | * rcu_read_lock() |
| 21 | * rcu_read_lock() | 21 | * obtain the ipc object (kern_ipc_perm) by looking up the id in an idr |
| 22 | * obtain the ipc object (kern_ipc_perm) | 22 | * tree. |
| 23 | * perform security, capabilities, auditing and permission checks, etc. | 23 | * - perform initial checks (capabilities, auditing and permission, |
| 24 | * acquire the ipc lock (kern_ipc_perm.lock) throught ipc_lock_object() | 24 | * etc). |
| 25 | * perform data updates (ie: SET, RMID, LOCK/UNLOCK commands) | 25 | * - perform read-only operations, such as STAT, INFO commands. |
| 26 | * acquire the ipc lock (kern_ipc_perm.lock) through | ||
| 27 | * ipc_lock_object() | ||
| 28 | * - perform data updates, such as SET, RMID commands and | ||
| 29 | * mechanism-specific operations (semop/semtimedop, | ||
| 30 | * msgsnd/msgrcv, shmat/shmdt). | ||
| 31 | * drop the ipc lock, through ipc_unlock_object(). | ||
| 32 | * rcu_read_unlock() | ||
| 33 | * | ||
| 34 | * The ids->rwsem must be taken when: | ||
| 35 | * - creating, removing and iterating the existing entries in ipc | ||
| 36 | * identifier sets. | ||
| 37 | * - iterating through files under /proc/sysvipc/ | ||
| 38 | * | ||
| 39 | * Note that sems have a special fast path that avoids kern_ipc_perm.lock - | ||
| 40 | * see sem_lock(). | ||
| 26 | */ | 41 | */ |
| 27 | 42 | ||
| 28 | #include <linux/mm.h> | 43 | #include <linux/mm.h> |
diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c index 7deeb6297a48..1a53d497a8c5 100644 --- a/lib/percpu-refcount.c +++ b/lib/percpu-refcount.c | |||
| @@ -53,6 +53,7 @@ int percpu_ref_init(struct percpu_ref *ref, percpu_ref_func_t *release) | |||
| 53 | ref->release = release; | 53 | ref->release = release; |
| 54 | return 0; | 54 | return 0; |
| 55 | } | 55 | } |
| 56 | EXPORT_SYMBOL_GPL(percpu_ref_init); | ||
| 56 | 57 | ||
| 57 | /** | 58 | /** |
| 58 | * percpu_ref_cancel_init - cancel percpu_ref_init() | 59 | * percpu_ref_cancel_init - cancel percpu_ref_init() |
| @@ -84,6 +85,7 @@ void percpu_ref_cancel_init(struct percpu_ref *ref) | |||
| 84 | free_percpu(ref->pcpu_count); | 85 | free_percpu(ref->pcpu_count); |
| 85 | } | 86 | } |
| 86 | } | 87 | } |
| 88 | EXPORT_SYMBOL_GPL(percpu_ref_cancel_init); | ||
| 87 | 89 | ||
| 88 | static void percpu_ref_kill_rcu(struct rcu_head *rcu) | 90 | static void percpu_ref_kill_rcu(struct rcu_head *rcu) |
| 89 | { | 91 | { |
| @@ -156,3 +158,4 @@ void percpu_ref_kill_and_confirm(struct percpu_ref *ref, | |||
| 156 | 158 | ||
| 157 | call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu); | 159 | call_rcu_sched(&ref->rcu, percpu_ref_kill_rcu); |
| 158 | } | 160 | } |
| 161 | EXPORT_SYMBOL_GPL(percpu_ref_kill_and_confirm); | ||
diff --git a/mm/filemap.c b/mm/filemap.c index 1e6aec4a2d2e..ae4846ff4849 100644 --- a/mm/filemap.c +++ b/mm/filemap.c | |||
| @@ -1616,7 +1616,6 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 1616 | struct inode *inode = mapping->host; | 1616 | struct inode *inode = mapping->host; |
| 1617 | pgoff_t offset = vmf->pgoff; | 1617 | pgoff_t offset = vmf->pgoff; |
| 1618 | struct page *page; | 1618 | struct page *page; |
| 1619 | bool memcg_oom; | ||
| 1620 | pgoff_t size; | 1619 | pgoff_t size; |
| 1621 | int ret = 0; | 1620 | int ret = 0; |
| 1622 | 1621 | ||
| @@ -1625,11 +1624,7 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 1625 | return VM_FAULT_SIGBUS; | 1624 | return VM_FAULT_SIGBUS; |
| 1626 | 1625 | ||
| 1627 | /* | 1626 | /* |
| 1628 | * Do we have something in the page cache already? Either | 1627 | * Do we have something in the page cache already? |
| 1629 | * way, try readahead, but disable the memcg OOM killer for it | ||
| 1630 | * as readahead is optional and no errors are propagated up | ||
| 1631 | * the fault stack. The OOM killer is enabled while trying to | ||
| 1632 | * instantiate the faulting page individually below. | ||
| 1633 | */ | 1628 | */ |
| 1634 | page = find_get_page(mapping, offset); | 1629 | page = find_get_page(mapping, offset); |
| 1635 | if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { | 1630 | if (likely(page) && !(vmf->flags & FAULT_FLAG_TRIED)) { |
| @@ -1637,14 +1632,10 @@ int filemap_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 1637 | * We found the page, so try async readahead before | 1632 | * We found the page, so try async readahead before |
| 1638 | * waiting for the lock. | 1633 | * waiting for the lock. |
| 1639 | */ | 1634 | */ |
| 1640 | memcg_oom = mem_cgroup_toggle_oom(false); | ||
| 1641 | do_async_mmap_readahead(vma, ra, file, page, offset); | 1635 | do_async_mmap_readahead(vma, ra, file, page, offset); |
| 1642 | mem_cgroup_toggle_oom(memcg_oom); | ||
| 1643 | } else if (!page) { | 1636 | } else if (!page) { |
| 1644 | /* No page in the page cache at all */ | 1637 | /* No page in the page cache at all */ |
| 1645 | memcg_oom = mem_cgroup_toggle_oom(false); | ||
| 1646 | do_sync_mmap_readahead(vma, ra, file, offset); | 1638 | do_sync_mmap_readahead(vma, ra, file, offset); |
| 1647 | mem_cgroup_toggle_oom(memcg_oom); | ||
| 1648 | count_vm_event(PGMAJFAULT); | 1639 | count_vm_event(PGMAJFAULT); |
| 1649 | mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); | 1640 | mem_cgroup_count_vm_event(vma->vm_mm, PGMAJFAULT); |
| 1650 | ret = VM_FAULT_MAJOR; | 1641 | ret = VM_FAULT_MAJOR; |
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 7489884682d8..610e3df2768a 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
| @@ -2697,6 +2697,7 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
| 2697 | 2697 | ||
| 2698 | mmun_start = haddr; | 2698 | mmun_start = haddr; |
| 2699 | mmun_end = haddr + HPAGE_PMD_SIZE; | 2699 | mmun_end = haddr + HPAGE_PMD_SIZE; |
| 2700 | again: | ||
| 2700 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); | 2701 | mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end); |
| 2701 | spin_lock(&mm->page_table_lock); | 2702 | spin_lock(&mm->page_table_lock); |
| 2702 | if (unlikely(!pmd_trans_huge(*pmd))) { | 2703 | if (unlikely(!pmd_trans_huge(*pmd))) { |
| @@ -2719,7 +2720,14 @@ void __split_huge_page_pmd(struct vm_area_struct *vma, unsigned long address, | |||
| 2719 | split_huge_page(page); | 2720 | split_huge_page(page); |
| 2720 | 2721 | ||
| 2721 | put_page(page); | 2722 | put_page(page); |
| 2722 | BUG_ON(pmd_trans_huge(*pmd)); | 2723 | |
| 2724 | /* | ||
| 2725 | * We don't always have down_write of mmap_sem here: a racing | ||
| 2726 | * do_huge_pmd_wp_page() might have copied-on-write to another | ||
| 2727 | * huge page before our split_huge_page() got the anon_vma lock. | ||
| 2728 | */ | ||
| 2729 | if (unlikely(pmd_trans_huge(*pmd))) | ||
| 2730 | goto again; | ||
| 2723 | } | 2731 | } |
| 2724 | 2732 | ||
| 2725 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, | 2733 | void split_huge_page_pmd_mm(struct mm_struct *mm, unsigned long address, |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index b49579c7f2a5..0b7656e804d1 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
| @@ -653,6 +653,7 @@ static void free_huge_page(struct page *page) | |||
| 653 | BUG_ON(page_count(page)); | 653 | BUG_ON(page_count(page)); |
| 654 | BUG_ON(page_mapcount(page)); | 654 | BUG_ON(page_mapcount(page)); |
| 655 | restore_reserve = PagePrivate(page); | 655 | restore_reserve = PagePrivate(page); |
| 656 | ClearPagePrivate(page); | ||
| 656 | 657 | ||
| 657 | spin_lock(&hugetlb_lock); | 658 | spin_lock(&hugetlb_lock); |
| 658 | hugetlb_cgroup_uncharge_page(hstate_index(h), | 659 | hugetlb_cgroup_uncharge_page(hstate_index(h), |
| @@ -695,8 +696,22 @@ static void prep_compound_gigantic_page(struct page *page, unsigned long order) | |||
| 695 | /* we rely on prep_new_huge_page to set the destructor */ | 696 | /* we rely on prep_new_huge_page to set the destructor */ |
| 696 | set_compound_order(page, order); | 697 | set_compound_order(page, order); |
| 697 | __SetPageHead(page); | 698 | __SetPageHead(page); |
| 699 | __ClearPageReserved(page); | ||
| 698 | for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { | 700 | for (i = 1; i < nr_pages; i++, p = mem_map_next(p, page, i)) { |
| 699 | __SetPageTail(p); | 701 | __SetPageTail(p); |
| 702 | /* | ||
| 703 | * For gigantic hugepages allocated through bootmem at | ||
| 704 | * boot, it's safer to be consistent with the not-gigantic | ||
| 705 | * hugepages and clear the PG_reserved bit from all tail pages | ||
| 706 | * too. Otherwse drivers using get_user_pages() to access tail | ||
| 707 | * pages may get the reference counting wrong if they see | ||
| 708 | * PG_reserved set on a tail page (despite the head page not | ||
| 709 | * having PG_reserved set). Enforcing this consistency between | ||
| 710 | * head and tail pages allows drivers to optimize away a check | ||
| 711 | * on the head page when they need know if put_page() is needed | ||
| 712 | * after get_user_pages(). | ||
| 713 | */ | ||
| 714 | __ClearPageReserved(p); | ||
| 700 | set_page_count(p, 0); | 715 | set_page_count(p, 0); |
| 701 | p->first_page = page; | 716 | p->first_page = page; |
| 702 | } | 717 | } |
| @@ -1329,9 +1344,9 @@ static void __init gather_bootmem_prealloc(void) | |||
| 1329 | #else | 1344 | #else |
| 1330 | page = virt_to_page(m); | 1345 | page = virt_to_page(m); |
| 1331 | #endif | 1346 | #endif |
| 1332 | __ClearPageReserved(page); | ||
| 1333 | WARN_ON(page_count(page) != 1); | 1347 | WARN_ON(page_count(page) != 1); |
| 1334 | prep_compound_huge_page(page, h->order); | 1348 | prep_compound_huge_page(page, h->order); |
| 1349 | WARN_ON(PageReserved(page)); | ||
| 1335 | prep_new_huge_page(h, page, page_to_nid(page)); | 1350 | prep_new_huge_page(h, page, page_to_nid(page)); |
| 1336 | /* | 1351 | /* |
| 1337 | * If we had gigantic hugepages allocated at boot time, we need | 1352 | * If we had gigantic hugepages allocated at boot time, we need |
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 1c52ddbc839b..34d3ca9572d6 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c | |||
| @@ -866,6 +866,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg, | |||
| 866 | unsigned long val = 0; | 866 | unsigned long val = 0; |
| 867 | int cpu; | 867 | int cpu; |
| 868 | 868 | ||
| 869 | get_online_cpus(); | ||
| 869 | for_each_online_cpu(cpu) | 870 | for_each_online_cpu(cpu) |
| 870 | val += per_cpu(memcg->stat->events[idx], cpu); | 871 | val += per_cpu(memcg->stat->events[idx], cpu); |
| 871 | #ifdef CONFIG_HOTPLUG_CPU | 872 | #ifdef CONFIG_HOTPLUG_CPU |
| @@ -873,6 +874,7 @@ static unsigned long mem_cgroup_read_events(struct mem_cgroup *memcg, | |||
| 873 | val += memcg->nocpu_base.events[idx]; | 874 | val += memcg->nocpu_base.events[idx]; |
| 874 | spin_unlock(&memcg->pcp_counter_lock); | 875 | spin_unlock(&memcg->pcp_counter_lock); |
| 875 | #endif | 876 | #endif |
| 877 | put_online_cpus(); | ||
| 876 | return val; | 878 | return val; |
| 877 | } | 879 | } |
| 878 | 880 | ||
| @@ -2159,110 +2161,59 @@ static void memcg_oom_recover(struct mem_cgroup *memcg) | |||
| 2159 | memcg_wakeup_oom(memcg); | 2161 | memcg_wakeup_oom(memcg); |
| 2160 | } | 2162 | } |
| 2161 | 2163 | ||
| 2162 | /* | ||
| 2163 | * try to call OOM killer | ||
| 2164 | */ | ||
| 2165 | static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) | 2164 | static void mem_cgroup_oom(struct mem_cgroup *memcg, gfp_t mask, int order) |
| 2166 | { | 2165 | { |
| 2167 | bool locked; | ||
| 2168 | int wakeups; | ||
| 2169 | |||
| 2170 | if (!current->memcg_oom.may_oom) | 2166 | if (!current->memcg_oom.may_oom) |
| 2171 | return; | 2167 | return; |
| 2172 | |||
| 2173 | current->memcg_oom.in_memcg_oom = 1; | ||
| 2174 | |||
| 2175 | /* | 2168 | /* |
| 2176 | * As with any blocking lock, a contender needs to start | 2169 | * We are in the middle of the charge context here, so we |
| 2177 | * listening for wakeups before attempting the trylock, | 2170 | * don't want to block when potentially sitting on a callstack |
| 2178 | * otherwise it can miss the wakeup from the unlock and sleep | 2171 | * that holds all kinds of filesystem and mm locks. |
| 2179 | * indefinitely. This is just open-coded because our locking | 2172 | * |
| 2180 | * is so particular to memcg hierarchies. | 2173 | * Also, the caller may handle a failed allocation gracefully |
| 2174 | * (like optional page cache readahead) and so an OOM killer | ||
| 2175 | * invocation might not even be necessary. | ||
| 2176 | * | ||
| 2177 | * That's why we don't do anything here except remember the | ||
| 2178 | * OOM context and then deal with it at the end of the page | ||
| 2179 | * fault when the stack is unwound, the locks are released, | ||
| 2180 | * and when we know whether the fault was overall successful. | ||
| 2181 | */ | 2181 | */ |
| 2182 | wakeups = atomic_read(&memcg->oom_wakeups); | 2182 | css_get(&memcg->css); |
| 2183 | mem_cgroup_mark_under_oom(memcg); | 2183 | current->memcg_oom.memcg = memcg; |
| 2184 | 2184 | current->memcg_oom.gfp_mask = mask; | |
| 2185 | locked = mem_cgroup_oom_trylock(memcg); | 2185 | current->memcg_oom.order = order; |
| 2186 | |||
| 2187 | if (locked) | ||
| 2188 | mem_cgroup_oom_notify(memcg); | ||
| 2189 | |||
| 2190 | if (locked && !memcg->oom_kill_disable) { | ||
| 2191 | mem_cgroup_unmark_under_oom(memcg); | ||
| 2192 | mem_cgroup_out_of_memory(memcg, mask, order); | ||
| 2193 | mem_cgroup_oom_unlock(memcg); | ||
| 2194 | /* | ||
| 2195 | * There is no guarantee that an OOM-lock contender | ||
| 2196 | * sees the wakeups triggered by the OOM kill | ||
| 2197 | * uncharges. Wake any sleepers explicitely. | ||
| 2198 | */ | ||
| 2199 | memcg_oom_recover(memcg); | ||
| 2200 | } else { | ||
| 2201 | /* | ||
| 2202 | * A system call can just return -ENOMEM, but if this | ||
| 2203 | * is a page fault and somebody else is handling the | ||
| 2204 | * OOM already, we need to sleep on the OOM waitqueue | ||
| 2205 | * for this memcg until the situation is resolved. | ||
| 2206 | * Which can take some time because it might be | ||
| 2207 | * handled by a userspace task. | ||
| 2208 | * | ||
| 2209 | * However, this is the charge context, which means | ||
| 2210 | * that we may sit on a large call stack and hold | ||
| 2211 | * various filesystem locks, the mmap_sem etc. and we | ||
| 2212 | * don't want the OOM handler to deadlock on them | ||
| 2213 | * while we sit here and wait. Store the current OOM | ||
| 2214 | * context in the task_struct, then return -ENOMEM. | ||
| 2215 | * At the end of the page fault handler, with the | ||
| 2216 | * stack unwound, pagefault_out_of_memory() will check | ||
| 2217 | * back with us by calling | ||
| 2218 | * mem_cgroup_oom_synchronize(), possibly putting the | ||
| 2219 | * task to sleep. | ||
| 2220 | */ | ||
| 2221 | current->memcg_oom.oom_locked = locked; | ||
| 2222 | current->memcg_oom.wakeups = wakeups; | ||
| 2223 | css_get(&memcg->css); | ||
| 2224 | current->memcg_oom.wait_on_memcg = memcg; | ||
| 2225 | } | ||
| 2226 | } | 2186 | } |
| 2227 | 2187 | ||
| 2228 | /** | 2188 | /** |
| 2229 | * mem_cgroup_oom_synchronize - complete memcg OOM handling | 2189 | * mem_cgroup_oom_synchronize - complete memcg OOM handling |
| 2190 | * @handle: actually kill/wait or just clean up the OOM state | ||
| 2230 | * | 2191 | * |
| 2231 | * This has to be called at the end of a page fault if the the memcg | 2192 | * This has to be called at the end of a page fault if the memcg OOM |
| 2232 | * OOM handler was enabled and the fault is returning %VM_FAULT_OOM. | 2193 | * handler was enabled. |
| 2233 | * | 2194 | * |
| 2234 | * Memcg supports userspace OOM handling, so failed allocations must | 2195 | * Memcg supports userspace OOM handling where failed allocations must |
| 2235 | * sleep on a waitqueue until the userspace task resolves the | 2196 | * sleep on a waitqueue until the userspace task resolves the |
| 2236 | * situation. Sleeping directly in the charge context with all kinds | 2197 | * situation. Sleeping directly in the charge context with all kinds |
| 2237 | * of locks held is not a good idea, instead we remember an OOM state | 2198 | * of locks held is not a good idea, instead we remember an OOM state |
| 2238 | * in the task and mem_cgroup_oom_synchronize() has to be called at | 2199 | * in the task and mem_cgroup_oom_synchronize() has to be called at |
| 2239 | * the end of the page fault to put the task to sleep and clean up the | 2200 | * the end of the page fault to complete the OOM handling. |
| 2240 | * OOM state. | ||
| 2241 | * | 2201 | * |
| 2242 | * Returns %true if an ongoing memcg OOM situation was detected and | 2202 | * Returns %true if an ongoing memcg OOM situation was detected and |
| 2243 | * finalized, %false otherwise. | 2203 | * completed, %false otherwise. |
| 2244 | */ | 2204 | */ |
| 2245 | bool mem_cgroup_oom_synchronize(void) | 2205 | bool mem_cgroup_oom_synchronize(bool handle) |
| 2246 | { | 2206 | { |
| 2207 | struct mem_cgroup *memcg = current->memcg_oom.memcg; | ||
| 2247 | struct oom_wait_info owait; | 2208 | struct oom_wait_info owait; |
| 2248 | struct mem_cgroup *memcg; | 2209 | bool locked; |
| 2249 | 2210 | ||
| 2250 | /* OOM is global, do not handle */ | 2211 | /* OOM is global, do not handle */ |
| 2251 | if (!current->memcg_oom.in_memcg_oom) | ||
| 2252 | return false; | ||
| 2253 | |||
| 2254 | /* | ||
| 2255 | * We invoked the OOM killer but there is a chance that a kill | ||
| 2256 | * did not free up any charges. Everybody else might already | ||
| 2257 | * be sleeping, so restart the fault and keep the rampage | ||
| 2258 | * going until some charges are released. | ||
| 2259 | */ | ||
| 2260 | memcg = current->memcg_oom.wait_on_memcg; | ||
| 2261 | if (!memcg) | 2212 | if (!memcg) |
| 2262 | goto out; | 2213 | return false; |
| 2263 | 2214 | ||
| 2264 | if (test_thread_flag(TIF_MEMDIE) || fatal_signal_pending(current)) | 2215 | if (!handle) |
| 2265 | goto out_memcg; | 2216 | goto cleanup; |
| 2266 | 2217 | ||
| 2267 | owait.memcg = memcg; | 2218 | owait.memcg = memcg; |
| 2268 | owait.wait.flags = 0; | 2219 | owait.wait.flags = 0; |
| @@ -2271,13 +2222,25 @@ bool mem_cgroup_oom_synchronize(void) | |||
| 2271 | INIT_LIST_HEAD(&owait.wait.task_list); | 2222 | INIT_LIST_HEAD(&owait.wait.task_list); |
| 2272 | 2223 | ||
| 2273 | prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE); | 2224 | prepare_to_wait(&memcg_oom_waitq, &owait.wait, TASK_KILLABLE); |
| 2274 | /* Only sleep if we didn't miss any wakeups since OOM */ | 2225 | mem_cgroup_mark_under_oom(memcg); |
| 2275 | if (atomic_read(&memcg->oom_wakeups) == current->memcg_oom.wakeups) | 2226 | |
| 2227 | locked = mem_cgroup_oom_trylock(memcg); | ||
| 2228 | |||
| 2229 | if (locked) | ||
| 2230 | mem_cgroup_oom_notify(memcg); | ||
| 2231 | |||
| 2232 | if (locked && !memcg->oom_kill_disable) { | ||
| 2233 | mem_cgroup_unmark_under_oom(memcg); | ||
| 2234 | finish_wait(&memcg_oom_waitq, &owait.wait); | ||
| 2235 | mem_cgroup_out_of_memory(memcg, current->memcg_oom.gfp_mask, | ||
| 2236 | current->memcg_oom.order); | ||
| 2237 | } else { | ||
| 2276 | schedule(); | 2238 | schedule(); |
| 2277 | finish_wait(&memcg_oom_waitq, &owait.wait); | 2239 | mem_cgroup_unmark_under_oom(memcg); |
| 2278 | out_memcg: | 2240 | finish_wait(&memcg_oom_waitq, &owait.wait); |
| 2279 | mem_cgroup_unmark_under_oom(memcg); | 2241 | } |
| 2280 | if (current->memcg_oom.oom_locked) { | 2242 | |
| 2243 | if (locked) { | ||
| 2281 | mem_cgroup_oom_unlock(memcg); | 2244 | mem_cgroup_oom_unlock(memcg); |
| 2282 | /* | 2245 | /* |
| 2283 | * There is no guarantee that an OOM-lock contender | 2246 | * There is no guarantee that an OOM-lock contender |
| @@ -2286,10 +2249,9 @@ out_memcg: | |||
| 2286 | */ | 2249 | */ |
| 2287 | memcg_oom_recover(memcg); | 2250 | memcg_oom_recover(memcg); |
| 2288 | } | 2251 | } |
| 2252 | cleanup: | ||
| 2253 | current->memcg_oom.memcg = NULL; | ||
| 2289 | css_put(&memcg->css); | 2254 | css_put(&memcg->css); |
| 2290 | current->memcg_oom.wait_on_memcg = NULL; | ||
| 2291 | out: | ||
| 2292 | current->memcg_oom.in_memcg_oom = 0; | ||
| 2293 | return true; | 2255 | return true; |
| 2294 | } | 2256 | } |
| 2295 | 2257 | ||
| @@ -2703,6 +2665,9 @@ static int __mem_cgroup_try_charge(struct mm_struct *mm, | |||
| 2703 | || fatal_signal_pending(current))) | 2665 | || fatal_signal_pending(current))) |
| 2704 | goto bypass; | 2666 | goto bypass; |
| 2705 | 2667 | ||
| 2668 | if (unlikely(task_in_memcg_oom(current))) | ||
| 2669 | goto bypass; | ||
| 2670 | |||
| 2706 | /* | 2671 | /* |
| 2707 | * We always charge the cgroup the mm_struct belongs to. | 2672 | * We always charge the cgroup the mm_struct belongs to. |
| 2708 | * The mm_struct's mem_cgroup changes on task migration if the | 2673 | * The mm_struct's mem_cgroup changes on task migration if the |
| @@ -2801,6 +2766,8 @@ done: | |||
| 2801 | return 0; | 2766 | return 0; |
| 2802 | nomem: | 2767 | nomem: |
| 2803 | *ptr = NULL; | 2768 | *ptr = NULL; |
| 2769 | if (gfp_mask & __GFP_NOFAIL) | ||
| 2770 | return 0; | ||
| 2804 | return -ENOMEM; | 2771 | return -ENOMEM; |
| 2805 | bypass: | 2772 | bypass: |
| 2806 | *ptr = root_mem_cgroup; | 2773 | *ptr = root_mem_cgroup; |
diff --git a/mm/memory.c b/mm/memory.c index ca0003947115..1311f26497e6 100644 --- a/mm/memory.c +++ b/mm/memory.c | |||
| @@ -837,6 +837,8 @@ copy_one_pte(struct mm_struct *dst_mm, struct mm_struct *src_mm, | |||
| 837 | */ | 837 | */ |
| 838 | make_migration_entry_read(&entry); | 838 | make_migration_entry_read(&entry); |
| 839 | pte = swp_entry_to_pte(entry); | 839 | pte = swp_entry_to_pte(entry); |
| 840 | if (pte_swp_soft_dirty(*src_pte)) | ||
| 841 | pte = pte_swp_mksoft_dirty(pte); | ||
| 840 | set_pte_at(src_mm, addr, src_pte, pte); | 842 | set_pte_at(src_mm, addr, src_pte, pte); |
| 841 | } | 843 | } |
| 842 | } | 844 | } |
| @@ -3863,15 +3865,21 @@ int handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 3863 | * space. Kernel faults are handled more gracefully. | 3865 | * space. Kernel faults are handled more gracefully. |
| 3864 | */ | 3866 | */ |
| 3865 | if (flags & FAULT_FLAG_USER) | 3867 | if (flags & FAULT_FLAG_USER) |
| 3866 | mem_cgroup_enable_oom(); | 3868 | mem_cgroup_oom_enable(); |
| 3867 | 3869 | ||
| 3868 | ret = __handle_mm_fault(mm, vma, address, flags); | 3870 | ret = __handle_mm_fault(mm, vma, address, flags); |
| 3869 | 3871 | ||
| 3870 | if (flags & FAULT_FLAG_USER) | 3872 | if (flags & FAULT_FLAG_USER) { |
| 3871 | mem_cgroup_disable_oom(); | 3873 | mem_cgroup_oom_disable(); |
| 3872 | 3874 | /* | |
| 3873 | if (WARN_ON(task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM))) | 3875 | * The task may have entered a memcg OOM situation but |
| 3874 | mem_cgroup_oom_synchronize(); | 3876 | * if the allocation error was handled gracefully (no |
| 3877 | * VM_FAULT_OOM), there is no need to kill anything. | ||
| 3878 | * Just clean up the OOM state peacefully. | ||
| 3879 | */ | ||
| 3880 | if (task_in_memcg_oom(current) && !(ret & VM_FAULT_OOM)) | ||
| 3881 | mem_cgroup_oom_synchronize(false); | ||
| 3882 | } | ||
| 3875 | 3883 | ||
| 3876 | return ret; | 3884 | return ret; |
| 3877 | } | 3885 | } |
diff --git a/mm/migrate.c b/mm/migrate.c index a26bccd44ccb..7a7325ee1d08 100644 --- a/mm/migrate.c +++ b/mm/migrate.c | |||
| @@ -161,6 +161,8 @@ static int remove_migration_pte(struct page *new, struct vm_area_struct *vma, | |||
| 161 | 161 | ||
| 162 | get_page(new); | 162 | get_page(new); |
| 163 | pte = pte_mkold(mk_pte(new, vma->vm_page_prot)); | 163 | pte = pte_mkold(mk_pte(new, vma->vm_page_prot)); |
| 164 | if (pte_swp_soft_dirty(*ptep)) | ||
| 165 | pte = pte_mksoft_dirty(pte); | ||
| 164 | if (is_write_migration_entry(entry)) | 166 | if (is_write_migration_entry(entry)) |
| 165 | pte = pte_mkwrite(pte); | 167 | pte = pte_mkwrite(pte); |
| 166 | #ifdef CONFIG_HUGETLB_PAGE | 168 | #ifdef CONFIG_HUGETLB_PAGE |
diff --git a/mm/mprotect.c b/mm/mprotect.c index 94722a4d6b43..a3af058f68e4 100644 --- a/mm/mprotect.c +++ b/mm/mprotect.c | |||
| @@ -94,13 +94,16 @@ static unsigned long change_pte_range(struct vm_area_struct *vma, pmd_t *pmd, | |||
| 94 | swp_entry_t entry = pte_to_swp_entry(oldpte); | 94 | swp_entry_t entry = pte_to_swp_entry(oldpte); |
| 95 | 95 | ||
| 96 | if (is_write_migration_entry(entry)) { | 96 | if (is_write_migration_entry(entry)) { |
| 97 | pte_t newpte; | ||
| 97 | /* | 98 | /* |
| 98 | * A protection check is difficult so | 99 | * A protection check is difficult so |
| 99 | * just be safe and disable write | 100 | * just be safe and disable write |
| 100 | */ | 101 | */ |
| 101 | make_migration_entry_read(&entry); | 102 | make_migration_entry_read(&entry); |
| 102 | set_pte_at(mm, addr, pte, | 103 | newpte = swp_entry_to_pte(entry); |
| 103 | swp_entry_to_pte(entry)); | 104 | if (pte_swp_soft_dirty(oldpte)) |
| 105 | newpte = pte_swp_mksoft_dirty(newpte); | ||
| 106 | set_pte_at(mm, addr, pte, newpte); | ||
| 104 | } | 107 | } |
| 105 | pages++; | 108 | pages++; |
| 106 | } | 109 | } |
diff --git a/mm/mremap.c b/mm/mremap.c index 91b13d6a16d4..0843feb66f3d 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
| @@ -25,7 +25,6 @@ | |||
| 25 | #include <asm/uaccess.h> | 25 | #include <asm/uaccess.h> |
| 26 | #include <asm/cacheflush.h> | 26 | #include <asm/cacheflush.h> |
| 27 | #include <asm/tlbflush.h> | 27 | #include <asm/tlbflush.h> |
| 28 | #include <asm/pgalloc.h> | ||
| 29 | 28 | ||
| 30 | #include "internal.h" | 29 | #include "internal.h" |
| 31 | 30 | ||
| @@ -63,10 +62,8 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma, | |||
| 63 | return NULL; | 62 | return NULL; |
| 64 | 63 | ||
| 65 | pmd = pmd_alloc(mm, pud, addr); | 64 | pmd = pmd_alloc(mm, pud, addr); |
| 66 | if (!pmd) { | 65 | if (!pmd) |
| 67 | pud_free(mm, pud); | ||
| 68 | return NULL; | 66 | return NULL; |
| 69 | } | ||
| 70 | 67 | ||
| 71 | VM_BUG_ON(pmd_trans_huge(*pmd)); | 68 | VM_BUG_ON(pmd_trans_huge(*pmd)); |
| 72 | 69 | ||
diff --git a/mm/oom_kill.c b/mm/oom_kill.c index 314e9d274381..6738c47f1f72 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c | |||
| @@ -680,7 +680,7 @@ void pagefault_out_of_memory(void) | |||
| 680 | { | 680 | { |
| 681 | struct zonelist *zonelist; | 681 | struct zonelist *zonelist; |
| 682 | 682 | ||
| 683 | if (mem_cgroup_oom_synchronize()) | 683 | if (mem_cgroup_oom_synchronize(true)) |
| 684 | return; | 684 | return; |
| 685 | 685 | ||
| 686 | zonelist = node_zonelist(first_online_node, GFP_KERNEL); | 686 | zonelist = node_zonelist(first_online_node, GFP_KERNEL); |
diff --git a/mm/page-writeback.c b/mm/page-writeback.c index f5236f804aa6..63807583d8e8 100644 --- a/mm/page-writeback.c +++ b/mm/page-writeback.c | |||
| @@ -1210,11 +1210,11 @@ static unsigned long dirty_poll_interval(unsigned long dirty, | |||
| 1210 | return 1; | 1210 | return 1; |
| 1211 | } | 1211 | } |
| 1212 | 1212 | ||
| 1213 | static long bdi_max_pause(struct backing_dev_info *bdi, | 1213 | static unsigned long bdi_max_pause(struct backing_dev_info *bdi, |
| 1214 | unsigned long bdi_dirty) | 1214 | unsigned long bdi_dirty) |
| 1215 | { | 1215 | { |
| 1216 | long bw = bdi->avg_write_bandwidth; | 1216 | unsigned long bw = bdi->avg_write_bandwidth; |
| 1217 | long t; | 1217 | unsigned long t; |
| 1218 | 1218 | ||
| 1219 | /* | 1219 | /* |
| 1220 | * Limit pause time for small memory systems. If sleeping for too long | 1220 | * Limit pause time for small memory systems. If sleeping for too long |
| @@ -1226,7 +1226,7 @@ static long bdi_max_pause(struct backing_dev_info *bdi, | |||
| 1226 | t = bdi_dirty / (1 + bw / roundup_pow_of_two(1 + HZ / 8)); | 1226 | t = bdi_dirty / (1 + bw / roundup_pow_of_two(1 + HZ / 8)); |
| 1227 | t++; | 1227 | t++; |
| 1228 | 1228 | ||
| 1229 | return min_t(long, t, MAX_PAUSE); | 1229 | return min_t(unsigned long, t, MAX_PAUSE); |
| 1230 | } | 1230 | } |
| 1231 | 1231 | ||
| 1232 | static long bdi_min_pause(struct backing_dev_info *bdi, | 1232 | static long bdi_min_pause(struct backing_dev_info *bdi, |
diff --git a/mm/slab_common.c b/mm/slab_common.c index a3443278ce3a..e2e98af703ea 100644 --- a/mm/slab_common.c +++ b/mm/slab_common.c | |||
| @@ -56,6 +56,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name, | |||
| 56 | continue; | 56 | continue; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | #if !defined(CONFIG_SLUB) || !defined(CONFIG_SLUB_DEBUG_ON) | ||
| 59 | /* | 60 | /* |
| 60 | * For simplicity, we won't check this in the list of memcg | 61 | * For simplicity, we won't check this in the list of memcg |
| 61 | * caches. We have control over memcg naming, and if there | 62 | * caches. We have control over memcg naming, and if there |
| @@ -69,6 +70,7 @@ static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name, | |||
| 69 | s = NULL; | 70 | s = NULL; |
| 70 | return -EINVAL; | 71 | return -EINVAL; |
| 71 | } | 72 | } |
| 73 | #endif | ||
| 72 | } | 74 | } |
| 73 | 75 | ||
| 74 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ | 76 | WARN_ON(strchr(name, ' ')); /* It confuses parsers */ |
diff --git a/mm/swapfile.c b/mm/swapfile.c index 3963fc24fcc1..de7c904e52e5 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
| @@ -1824,6 +1824,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
| 1824 | struct filename *pathname; | 1824 | struct filename *pathname; |
| 1825 | int i, type, prev; | 1825 | int i, type, prev; |
| 1826 | int err; | 1826 | int err; |
| 1827 | unsigned int old_block_size; | ||
| 1827 | 1828 | ||
| 1828 | if (!capable(CAP_SYS_ADMIN)) | 1829 | if (!capable(CAP_SYS_ADMIN)) |
| 1829 | return -EPERM; | 1830 | return -EPERM; |
| @@ -1914,6 +1915,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
| 1914 | } | 1915 | } |
| 1915 | 1916 | ||
| 1916 | swap_file = p->swap_file; | 1917 | swap_file = p->swap_file; |
| 1918 | old_block_size = p->old_block_size; | ||
| 1917 | p->swap_file = NULL; | 1919 | p->swap_file = NULL; |
| 1918 | p->max = 0; | 1920 | p->max = 0; |
| 1919 | swap_map = p->swap_map; | 1921 | swap_map = p->swap_map; |
| @@ -1938,7 +1940,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile) | |||
| 1938 | inode = mapping->host; | 1940 | inode = mapping->host; |
| 1939 | if (S_ISBLK(inode->i_mode)) { | 1941 | if (S_ISBLK(inode->i_mode)) { |
| 1940 | struct block_device *bdev = I_BDEV(inode); | 1942 | struct block_device *bdev = I_BDEV(inode); |
| 1941 | set_blocksize(bdev, p->old_block_size); | 1943 | set_blocksize(bdev, old_block_size); |
| 1942 | blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); | 1944 | blkdev_put(bdev, FMODE_READ | FMODE_WRITE | FMODE_EXCL); |
| 1943 | } else { | 1945 | } else { |
| 1944 | mutex_lock(&inode->i_mutex); | 1946 | mutex_lock(&inode->i_mutex); |
diff --git a/mm/vmscan.c b/mm/vmscan.c index 53f2f82f83ae..eea668d9cff6 100644 --- a/mm/vmscan.c +++ b/mm/vmscan.c | |||
| @@ -211,6 +211,7 @@ void unregister_shrinker(struct shrinker *shrinker) | |||
| 211 | down_write(&shrinker_rwsem); | 211 | down_write(&shrinker_rwsem); |
| 212 | list_del(&shrinker->list); | 212 | list_del(&shrinker->list); |
| 213 | up_write(&shrinker_rwsem); | 213 | up_write(&shrinker_rwsem); |
| 214 | kfree(shrinker->nr_deferred); | ||
| 214 | } | 215 | } |
| 215 | EXPORT_SYMBOL(unregister_shrinker); | 216 | EXPORT_SYMBOL(unregister_shrinker); |
| 216 | 217 | ||
diff --git a/mm/zswap.c b/mm/zswap.c index 841e35f1db22..d93510c6aa2d 100644 --- a/mm/zswap.c +++ b/mm/zswap.c | |||
| @@ -804,6 +804,10 @@ static void zswap_frontswap_invalidate_area(unsigned type) | |||
| 804 | } | 804 | } |
| 805 | tree->rbroot = RB_ROOT; | 805 | tree->rbroot = RB_ROOT; |
| 806 | spin_unlock(&tree->lock); | 806 | spin_unlock(&tree->lock); |
| 807 | |||
| 808 | zbud_destroy_pool(tree->pool); | ||
| 809 | kfree(tree); | ||
| 810 | zswap_trees[type] = NULL; | ||
| 807 | } | 811 | } |
| 808 | 812 | ||
| 809 | static struct zbud_ops zswap_zbud_ops = { | 813 | static struct zbud_ops zswap_zbud_ops = { |
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c index 95c2b2689a03..7db9954f1af2 100644 --- a/security/apparmor/apparmorfs.c +++ b/security/apparmor/apparmorfs.c | |||
| @@ -580,15 +580,13 @@ static struct aa_namespace *__next_namespace(struct aa_namespace *root, | |||
| 580 | 580 | ||
| 581 | /* check if the next ns is a sibling, parent, gp, .. */ | 581 | /* check if the next ns is a sibling, parent, gp, .. */ |
| 582 | parent = ns->parent; | 582 | parent = ns->parent; |
| 583 | while (parent) { | 583 | while (ns != root) { |
| 584 | mutex_unlock(&ns->lock); | 584 | mutex_unlock(&ns->lock); |
| 585 | next = list_entry_next(ns, base.list); | 585 | next = list_entry_next(ns, base.list); |
| 586 | if (!list_entry_is_head(next, &parent->sub_ns, base.list)) { | 586 | if (!list_entry_is_head(next, &parent->sub_ns, base.list)) { |
| 587 | mutex_lock(&next->lock); | 587 | mutex_lock(&next->lock); |
| 588 | return next; | 588 | return next; |
| 589 | } | 589 | } |
| 590 | if (parent == root) | ||
| 591 | return NULL; | ||
| 592 | ns = parent; | 590 | ns = parent; |
| 593 | parent = parent->parent; | 591 | parent = parent->parent; |
| 594 | } | 592 | } |
diff --git a/security/apparmor/policy.c b/security/apparmor/policy.c index 345bec07a27d..705c2879d3a9 100644 --- a/security/apparmor/policy.c +++ b/security/apparmor/policy.c | |||
| @@ -610,6 +610,7 @@ void aa_free_profile(struct aa_profile *profile) | |||
| 610 | aa_put_dfa(profile->policy.dfa); | 610 | aa_put_dfa(profile->policy.dfa); |
| 611 | aa_put_replacedby(profile->replacedby); | 611 | aa_put_replacedby(profile->replacedby); |
| 612 | 612 | ||
| 613 | kzfree(profile->hash); | ||
| 613 | kzfree(profile); | 614 | kzfree(profile); |
| 614 | } | 615 | } |
| 615 | 616 | ||
diff --git a/sound/arm/pxa2xx-ac97-lib.c b/sound/arm/pxa2xx-ac97-lib.c index e6f4633b8dd5..99a466822a7d 100644 --- a/sound/arm/pxa2xx-ac97-lib.c +++ b/sound/arm/pxa2xx-ac97-lib.c | |||
| @@ -117,8 +117,7 @@ static inline void pxa_ac97_warm_pxa25x(void) | |||
| 117 | { | 117 | { |
| 118 | gsr_bits = 0; | 118 | gsr_bits = 0; |
| 119 | 119 | ||
| 120 | GCR |= GCR_WARM_RST | GCR_PRIRDY_IEN | GCR_SECRDY_IEN; | 120 | GCR |= GCR_WARM_RST; |
| 121 | wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); | ||
| 122 | } | 121 | } |
| 123 | 122 | ||
| 124 | static inline void pxa_ac97_cold_pxa25x(void) | 123 | static inline void pxa_ac97_cold_pxa25x(void) |
| @@ -129,8 +128,6 @@ static inline void pxa_ac97_cold_pxa25x(void) | |||
| 129 | gsr_bits = 0; | 128 | gsr_bits = 0; |
| 130 | 129 | ||
| 131 | GCR = GCR_COLD_RST; | 130 | GCR = GCR_COLD_RST; |
| 132 | GCR |= GCR_CDONE_IE|GCR_SDONE_IE; | ||
| 133 | wait_event_timeout(gsr_wq, gsr_bits & (GSR_PCR | GSR_SCR), 1); | ||
| 134 | } | 131 | } |
| 135 | #endif | 132 | #endif |
| 136 | 133 | ||
| @@ -149,8 +146,6 @@ static inline void pxa_ac97_warm_pxa27x(void) | |||
| 149 | 146 | ||
| 150 | static inline void pxa_ac97_cold_pxa27x(void) | 147 | static inline void pxa_ac97_cold_pxa27x(void) |
| 151 | { | 148 | { |
| 152 | unsigned int timeout; | ||
| 153 | |||
| 154 | GCR &= GCR_COLD_RST; /* clear everything but nCRST */ | 149 | GCR &= GCR_COLD_RST; /* clear everything but nCRST */ |
| 155 | GCR &= ~GCR_COLD_RST; /* then assert nCRST */ | 150 | GCR &= ~GCR_COLD_RST; /* then assert nCRST */ |
| 156 | 151 | ||
| @@ -161,29 +156,20 @@ static inline void pxa_ac97_cold_pxa27x(void) | |||
| 161 | udelay(5); | 156 | udelay(5); |
| 162 | clk_disable(ac97conf_clk); | 157 | clk_disable(ac97conf_clk); |
| 163 | GCR = GCR_COLD_RST | GCR_WARM_RST; | 158 | GCR = GCR_COLD_RST | GCR_WARM_RST; |
| 164 | timeout = 100; /* wait for the codec-ready bit to be set */ | ||
| 165 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) | ||
| 166 | mdelay(1); | ||
| 167 | } | 159 | } |
| 168 | #endif | 160 | #endif |
| 169 | 161 | ||
| 170 | #ifdef CONFIG_PXA3xx | 162 | #ifdef CONFIG_PXA3xx |
| 171 | static inline void pxa_ac97_warm_pxa3xx(void) | 163 | static inline void pxa_ac97_warm_pxa3xx(void) |
| 172 | { | 164 | { |
| 173 | int timeout = 100; | ||
| 174 | |||
| 175 | gsr_bits = 0; | 165 | gsr_bits = 0; |
| 176 | 166 | ||
| 177 | /* Can't use interrupts */ | 167 | /* Can't use interrupts */ |
| 178 | GCR |= GCR_WARM_RST; | 168 | GCR |= GCR_WARM_RST; |
| 179 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) | ||
| 180 | mdelay(1); | ||
| 181 | } | 169 | } |
| 182 | 170 | ||
| 183 | static inline void pxa_ac97_cold_pxa3xx(void) | 171 | static inline void pxa_ac97_cold_pxa3xx(void) |
| 184 | { | 172 | { |
| 185 | int timeout = 1000; | ||
| 186 | |||
| 187 | /* Hold CLKBPB for 100us */ | 173 | /* Hold CLKBPB for 100us */ |
| 188 | GCR = 0; | 174 | GCR = 0; |
| 189 | GCR = GCR_CLKBPB; | 175 | GCR = GCR_CLKBPB; |
| @@ -199,14 +185,13 @@ static inline void pxa_ac97_cold_pxa3xx(void) | |||
| 199 | GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); | 185 | GCR &= ~(GCR_PRIRDY_IEN|GCR_SECRDY_IEN); |
| 200 | 186 | ||
| 201 | GCR = GCR_WARM_RST | GCR_COLD_RST; | 187 | GCR = GCR_WARM_RST | GCR_COLD_RST; |
| 202 | while (!(GSR & (GSR_PCR | GSR_SCR)) && timeout--) | ||
| 203 | mdelay(10); | ||
| 204 | } | 188 | } |
| 205 | #endif | 189 | #endif |
| 206 | 190 | ||
| 207 | bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) | 191 | bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) |
| 208 | { | 192 | { |
| 209 | unsigned long gsr; | 193 | unsigned long gsr; |
| 194 | unsigned int timeout = 100; | ||
| 210 | 195 | ||
| 211 | #ifdef CONFIG_PXA25x | 196 | #ifdef CONFIG_PXA25x |
| 212 | if (cpu_is_pxa25x()) | 197 | if (cpu_is_pxa25x()) |
| @@ -224,6 +209,10 @@ bool pxa2xx_ac97_try_warm_reset(struct snd_ac97 *ac97) | |||
| 224 | else | 209 | else |
| 225 | #endif | 210 | #endif |
| 226 | BUG(); | 211 | BUG(); |
| 212 | |||
| 213 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) | ||
| 214 | mdelay(1); | ||
| 215 | |||
| 227 | gsr = GSR | gsr_bits; | 216 | gsr = GSR | gsr_bits; |
| 228 | if (!(gsr & (GSR_PCR | GSR_SCR))) { | 217 | if (!(gsr & (GSR_PCR | GSR_SCR))) { |
| 229 | printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", | 218 | printk(KERN_INFO "%s: warm reset timeout (GSR=%#lx)\n", |
| @@ -239,6 +228,7 @@ EXPORT_SYMBOL_GPL(pxa2xx_ac97_try_warm_reset); | |||
| 239 | bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) | 228 | bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) |
| 240 | { | 229 | { |
| 241 | unsigned long gsr; | 230 | unsigned long gsr; |
| 231 | unsigned int timeout = 1000; | ||
| 242 | 232 | ||
| 243 | #ifdef CONFIG_PXA25x | 233 | #ifdef CONFIG_PXA25x |
| 244 | if (cpu_is_pxa25x()) | 234 | if (cpu_is_pxa25x()) |
| @@ -257,6 +247,9 @@ bool pxa2xx_ac97_try_cold_reset(struct snd_ac97 *ac97) | |||
| 257 | #endif | 247 | #endif |
| 258 | BUG(); | 248 | BUG(); |
| 259 | 249 | ||
| 250 | while (!((GSR | gsr_bits) & (GSR_PCR | GSR_SCR)) && timeout--) | ||
| 251 | mdelay(1); | ||
| 252 | |||
| 260 | gsr = GSR | gsr_bits; | 253 | gsr = GSR | gsr_bits; |
| 261 | if (!(gsr & (GSR_PCR | GSR_SCR))) { | 254 | if (!(gsr & (GSR_PCR | GSR_SCR))) { |
| 262 | printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", | 255 | printk(KERN_INFO "%s: cold reset timeout (GSR=%#lx)\n", |
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c index ac41e9cdc976..26ad4f0aade3 100644 --- a/sound/pci/hda/hda_generic.c +++ b/sound/pci/hda/hda_generic.c | |||
| @@ -3531,7 +3531,7 @@ static int create_capture_mixers(struct hda_codec *codec) | |||
| 3531 | if (!multi) | 3531 | if (!multi) |
| 3532 | err = create_single_cap_vol_ctl(codec, n, vol, sw, | 3532 | err = create_single_cap_vol_ctl(codec, n, vol, sw, |
| 3533 | inv_dmic); | 3533 | inv_dmic); |
| 3534 | else if (!multi_cap_vol) | 3534 | else if (!multi_cap_vol && !inv_dmic) |
| 3535 | err = create_bind_cap_vol_ctl(codec, n, vol, sw); | 3535 | err = create_bind_cap_vol_ctl(codec, n, vol, sw); |
| 3536 | else | 3536 | else |
| 3537 | err = create_multi_cap_vol_ctl(codec); | 3537 | err = create_multi_cap_vol_ctl(codec); |
diff --git a/sound/pci/rme9652/hdsp.c b/sound/pci/rme9652/hdsp.c index 4f255dfee450..f59a321a6d6a 100644 --- a/sound/pci/rme9652/hdsp.c +++ b/sound/pci/rme9652/hdsp.c | |||
| @@ -4845,6 +4845,7 @@ static int snd_hdsp_hwdep_ioctl(struct snd_hwdep *hw, struct file *file, unsigne | |||
| 4845 | if ((err = hdsp_get_iobox_version(hdsp)) < 0) | 4845 | if ((err = hdsp_get_iobox_version(hdsp)) < 0) |
| 4846 | return err; | 4846 | return err; |
| 4847 | } | 4847 | } |
| 4848 | memset(&hdsp_version, 0, sizeof(hdsp_version)); | ||
| 4848 | hdsp_version.io_type = hdsp->io_type; | 4849 | hdsp_version.io_type = hdsp->io_type; |
| 4849 | hdsp_version.firmware_rev = hdsp->firmware_rev; | 4850 | hdsp_version.firmware_rev = hdsp->firmware_rev; |
| 4850 | if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))) | 4851 | if ((err = copy_to_user(argp, &hdsp_version, sizeof(hdsp_version)))) |
diff --git a/sound/soc/Makefile b/sound/soc/Makefile index 61a64d281905..8b9e70105dd2 100644 --- a/sound/soc/Makefile +++ b/sound/soc/Makefile | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o | 1 | snd-soc-core-objs := soc-core.o soc-dapm.o soc-jack.o soc-cache.o soc-utils.o |
| 2 | snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o | 2 | snd-soc-core-objs += soc-pcm.o soc-compress.o soc-io.o soc-devres.o |
| 3 | 3 | ||
| 4 | ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) | 4 | ifneq ($(CONFIG_SND_SOC_GENERIC_DMAENGINE_PCM),) |
| 5 | snd-soc-core-objs += soc-generic-dmaengine-pcm.o | 5 | snd-soc-core-objs += soc-generic-dmaengine-pcm.o |
diff --git a/sound/soc/atmel/atmel-pcm.c b/sound/soc/atmel/atmel-pcm.c index 3109db7b9017..612e5801003f 100644 --- a/sound/soc/atmel/atmel-pcm.c +++ b/sound/soc/atmel/atmel-pcm.c | |||
| @@ -50,7 +50,7 @@ static int atmel_pcm_preallocate_dma_buffer(struct snd_pcm *pcm, | |||
| 50 | buf->area = dma_alloc_coherent(pcm->card->dev, size, | 50 | buf->area = dma_alloc_coherent(pcm->card->dev, size, |
| 51 | &buf->addr, GFP_KERNEL); | 51 | &buf->addr, GFP_KERNEL); |
| 52 | pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n", | 52 | pr_debug("atmel-pcm: alloc dma buffer: area=%p, addr=%p, size=%zu\n", |
| 53 | (void *)buf->area, (void *)buf->addr, size); | 53 | (void *)buf->area, (void *)(long)buf->addr, size); |
| 54 | 54 | ||
| 55 | if (!buf->area) | 55 | if (!buf->area) |
| 56 | return -ENOMEM; | 56 | return -ENOMEM; |
diff --git a/sound/soc/atmel/atmel_wm8904.c b/sound/soc/atmel/atmel_wm8904.c index 7222380131ea..b4e36901a40b 100644 --- a/sound/soc/atmel/atmel_wm8904.c +++ b/sound/soc/atmel/atmel_wm8904.c | |||
| @@ -12,7 +12,6 @@ | |||
| 12 | #include <linux/module.h> | 12 | #include <linux/module.h> |
| 13 | #include <linux/of.h> | 13 | #include <linux/of.h> |
| 14 | #include <linux/of_device.h> | 14 | #include <linux/of_device.h> |
| 15 | #include <linux/pinctrl/consumer.h> | ||
| 16 | 15 | ||
| 17 | #include <sound/soc.h> | 16 | #include <sound/soc.h> |
| 18 | 17 | ||
| @@ -155,15 +154,8 @@ static int atmel_asoc_wm8904_probe(struct platform_device *pdev) | |||
| 155 | struct snd_soc_card *card = &atmel_asoc_wm8904_card; | 154 | struct snd_soc_card *card = &atmel_asoc_wm8904_card; |
| 156 | struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink; | 155 | struct snd_soc_dai_link *dailink = &atmel_asoc_wm8904_dailink; |
| 157 | struct clk *clk_src; | 156 | struct clk *clk_src; |
| 158 | struct pinctrl *pinctrl; | ||
| 159 | int id, ret; | 157 | int id, ret; |
| 160 | 158 | ||
| 161 | pinctrl = devm_pinctrl_get_select_default(&pdev->dev); | ||
| 162 | if (IS_ERR(pinctrl)) { | ||
| 163 | dev_err(&pdev->dev, "failed to request pinctrl\n"); | ||
| 164 | return PTR_ERR(pinctrl); | ||
| 165 | } | ||
| 166 | |||
| 167 | card->dev = &pdev->dev; | 159 | card->dev = &pdev->dev; |
| 168 | ret = atmel_asoc_wm8904_dt_init(pdev); | 160 | ret = atmel_asoc_wm8904_dt_init(pdev); |
| 169 | if (ret) { | 161 | if (ret) { |
diff --git a/sound/soc/atmel/sam9g20_wm8731.c b/sound/soc/atmel/sam9g20_wm8731.c index 802717eccbd0..f15bff1548f8 100644 --- a/sound/soc/atmel/sam9g20_wm8731.c +++ b/sound/soc/atmel/sam9g20_wm8731.c | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #include <linux/interrupt.h> | 37 | #include <linux/interrupt.h> |
| 38 | #include <linux/platform_device.h> | 38 | #include <linux/platform_device.h> |
| 39 | #include <linux/i2c.h> | 39 | #include <linux/i2c.h> |
| 40 | #include <linux/of.h> | ||
| 40 | 41 | ||
| 41 | #include <linux/atmel-ssc.h> | 42 | #include <linux/atmel-ssc.h> |
| 42 | 43 | ||
diff --git a/sound/soc/cirrus/Kconfig b/sound/soc/cirrus/Kconfig index 2c20f01e1f7e..06f938deda15 100644 --- a/sound/soc/cirrus/Kconfig +++ b/sound/soc/cirrus/Kconfig | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | config SND_EP93XX_SOC | 1 | config SND_EP93XX_SOC |
| 2 | tristate "SoC Audio support for the Cirrus Logic EP93xx series" | 2 | tristate "SoC Audio support for the Cirrus Logic EP93xx series" |
| 3 | depends on ARCH_EP93XX && SND_SOC | 3 | depends on (ARCH_EP93XX || COMPILE_TEST) && SND_SOC |
| 4 | select SND_SOC_GENERIC_DMAENGINE_PCM | 4 | select SND_SOC_GENERIC_DMAENGINE_PCM |
| 5 | help | 5 | help |
| 6 | Say Y or M if you want to add support for codecs attached to | 6 | Say Y or M if you want to add support for codecs attached to |
diff --git a/sound/soc/cirrus/ep93xx-pcm.c b/sound/soc/cirrus/ep93xx-pcm.c index 0e9f56e0d4b2..cfe517e68009 100644 --- a/sound/soc/cirrus/ep93xx-pcm.c +++ b/sound/soc/cirrus/ep93xx-pcm.c | |||
| @@ -57,9 +57,22 @@ static bool ep93xx_pcm_dma_filter(struct dma_chan *chan, void *filter_param) | |||
| 57 | return false; | 57 | return false; |
| 58 | } | 58 | } |
| 59 | 59 | ||
| 60 | static struct dma_chan *ep93xx_compat_request_channel( | ||
| 61 | struct snd_soc_pcm_runtime *rtd, | ||
| 62 | struct snd_pcm_substream *substream) | ||
| 63 | { | ||
| 64 | struct snd_dmaengine_dai_dma_data *dma_data; | ||
| 65 | |||
| 66 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 67 | |||
| 68 | return snd_dmaengine_pcm_request_channel(ep93xx_pcm_dma_filter, | ||
| 69 | dma_data); | ||
| 70 | } | ||
| 71 | |||
| 60 | static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { | 72 | static const struct snd_dmaengine_pcm_config ep93xx_dmaengine_pcm_config = { |
| 61 | .pcm_hardware = &ep93xx_pcm_hardware, | 73 | .pcm_hardware = &ep93xx_pcm_hardware, |
| 62 | .compat_filter_fn = ep93xx_pcm_dma_filter, | 74 | .compat_filter_fn = ep93xx_pcm_dma_filter, |
| 75 | .compat_request_channel = ep93xx_compat_request_channel, | ||
| 63 | .prealloc_buffer_size = 131072, | 76 | .prealloc_buffer_size = 131072, |
| 64 | }; | 77 | }; |
| 65 | 78 | ||
diff --git a/sound/soc/codecs/88pm860x-codec.c b/sound/soc/codecs/88pm860x-codec.c index 259d1ac4492f..75d0ad5d2dcb 100644 --- a/sound/soc/codecs/88pm860x-codec.c +++ b/sound/soc/codecs/88pm860x-codec.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <linux/mfd/88pm860x.h> | 16 | #include <linux/mfd/88pm860x.h> |
| 17 | #include <linux/slab.h> | 17 | #include <linux/slab.h> |
| 18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
| 19 | #include <linux/regmap.h> | ||
| 19 | #include <sound/core.h> | 20 | #include <sound/core.h> |
| 20 | #include <sound/pcm.h> | 21 | #include <sound/pcm.h> |
| 21 | #include <sound/pcm_params.h> | 22 | #include <sound/pcm_params.h> |
| @@ -140,6 +141,7 @@ struct pm860x_priv { | |||
| 140 | unsigned int filter; | 141 | unsigned int filter; |
| 141 | struct snd_soc_codec *codec; | 142 | struct snd_soc_codec *codec; |
| 142 | struct i2c_client *i2c; | 143 | struct i2c_client *i2c; |
| 144 | struct regmap *regmap; | ||
| 143 | struct pm860x_chip *chip; | 145 | struct pm860x_chip *chip; |
| 144 | struct pm860x_det det; | 146 | struct pm860x_det det; |
| 145 | 147 | ||
| @@ -269,48 +271,6 @@ static struct st_gain st_table[] = { | |||
| 269 | { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0}, | 271 | { -86, 29, 0}, { -56, 30, 0}, { -28, 31, 0}, { 0, 0, 0}, |
| 270 | }; | 272 | }; |
| 271 | 273 | ||
| 272 | static int pm860x_volatile(unsigned int reg) | ||
| 273 | { | ||
| 274 | BUG_ON(reg >= REG_CACHE_SIZE); | ||
| 275 | |||
| 276 | switch (reg) { | ||
| 277 | case PM860X_AUDIO_SUPPLIES_2: | ||
| 278 | return 1; | ||
| 279 | } | ||
| 280 | |||
| 281 | return 0; | ||
| 282 | } | ||
| 283 | |||
| 284 | static unsigned int pm860x_read_reg_cache(struct snd_soc_codec *codec, | ||
| 285 | unsigned int reg) | ||
| 286 | { | ||
| 287 | unsigned char *cache = codec->reg_cache; | ||
| 288 | |||
| 289 | BUG_ON(reg >= REG_CACHE_SIZE); | ||
| 290 | |||
| 291 | if (pm860x_volatile(reg)) | ||
| 292 | return cache[reg]; | ||
| 293 | |||
| 294 | reg += REG_CACHE_BASE; | ||
| 295 | |||
| 296 | return pm860x_reg_read(codec->control_data, reg); | ||
| 297 | } | ||
| 298 | |||
| 299 | static int pm860x_write_reg_cache(struct snd_soc_codec *codec, | ||
| 300 | unsigned int reg, unsigned int value) | ||
| 301 | { | ||
| 302 | unsigned char *cache = codec->reg_cache; | ||
| 303 | |||
| 304 | BUG_ON(reg >= REG_CACHE_SIZE); | ||
| 305 | |||
| 306 | if (!pm860x_volatile(reg)) | ||
| 307 | cache[reg] = (unsigned char)value; | ||
| 308 | |||
| 309 | reg += REG_CACHE_BASE; | ||
| 310 | |||
| 311 | return pm860x_reg_write(codec->control_data, reg, value); | ||
| 312 | } | ||
| 313 | |||
| 314 | static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, | 274 | static int snd_soc_get_volsw_2r_st(struct snd_kcontrol *kcontrol, |
| 315 | struct snd_ctl_elem_value *ucontrol) | 275 | struct snd_ctl_elem_value *ucontrol) |
| 316 | { | 276 | { |
| @@ -1169,6 +1129,7 @@ static int pm860x_i2s_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
| 1169 | static int pm860x_set_bias_level(struct snd_soc_codec *codec, | 1129 | static int pm860x_set_bias_level(struct snd_soc_codec *codec, |
| 1170 | enum snd_soc_bias_level level) | 1130 | enum snd_soc_bias_level level) |
| 1171 | { | 1131 | { |
| 1132 | struct pm860x_priv *pm860x = snd_soc_codec_get_drvdata(codec); | ||
| 1172 | int data; | 1133 | int data; |
| 1173 | 1134 | ||
| 1174 | switch (level) { | 1135 | switch (level) { |
| @@ -1182,17 +1143,17 @@ static int pm860x_set_bias_level(struct snd_soc_codec *codec, | |||
| 1182 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 1143 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
| 1183 | /* Enable Audio PLL & Audio section */ | 1144 | /* Enable Audio PLL & Audio section */ |
| 1184 | data = AUDIO_PLL | AUDIO_SECTION_ON; | 1145 | data = AUDIO_PLL | AUDIO_SECTION_ON; |
| 1185 | pm860x_reg_write(codec->control_data, REG_MISC2, data); | 1146 | pm860x_reg_write(pm860x->i2c, REG_MISC2, data); |
| 1186 | udelay(300); | 1147 | udelay(300); |
| 1187 | data = AUDIO_PLL | AUDIO_SECTION_RESET | 1148 | data = AUDIO_PLL | AUDIO_SECTION_RESET |
| 1188 | | AUDIO_SECTION_ON; | 1149 | | AUDIO_SECTION_ON; |
| 1189 | pm860x_reg_write(codec->control_data, REG_MISC2, data); | 1150 | pm860x_reg_write(pm860x->i2c, REG_MISC2, data); |
| 1190 | } | 1151 | } |
| 1191 | break; | 1152 | break; |
| 1192 | 1153 | ||
| 1193 | case SND_SOC_BIAS_OFF: | 1154 | case SND_SOC_BIAS_OFF: |
| 1194 | data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON; | 1155 | data = AUDIO_PLL | AUDIO_SECTION_RESET | AUDIO_SECTION_ON; |
| 1195 | pm860x_set_bits(codec->control_data, REG_MISC2, data, 0); | 1156 | pm860x_set_bits(pm860x->i2c, REG_MISC2, data, 0); |
| 1196 | break; | 1157 | break; |
| 1197 | } | 1158 | } |
| 1198 | codec->dapm.bias_level = level; | 1159 | codec->dapm.bias_level = level; |
| @@ -1322,17 +1283,17 @@ int pm860x_hs_jack_detect(struct snd_soc_codec *codec, | |||
| 1322 | pm860x->det.lo_shrt = lo_shrt; | 1283 | pm860x->det.lo_shrt = lo_shrt; |
| 1323 | 1284 | ||
| 1324 | if (det & SND_JACK_HEADPHONE) | 1285 | if (det & SND_JACK_HEADPHONE) |
| 1325 | pm860x_set_bits(codec->control_data, REG_HS_DET, | 1286 | pm860x_set_bits(pm860x->i2c, REG_HS_DET, |
| 1326 | EN_HS_DET, EN_HS_DET); | 1287 | EN_HS_DET, EN_HS_DET); |
| 1327 | /* headset short detect */ | 1288 | /* headset short detect */ |
| 1328 | if (hs_shrt) { | 1289 | if (hs_shrt) { |
| 1329 | data = CLR_SHORT_HS2 | CLR_SHORT_HS1; | 1290 | data = CLR_SHORT_HS2 | CLR_SHORT_HS1; |
| 1330 | pm860x_set_bits(codec->control_data, REG_SHORTS, data, data); | 1291 | pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data); |
| 1331 | } | 1292 | } |
| 1332 | /* Lineout short detect */ | 1293 | /* Lineout short detect */ |
| 1333 | if (lo_shrt) { | 1294 | if (lo_shrt) { |
| 1334 | data = CLR_SHORT_LO2 | CLR_SHORT_LO1; | 1295 | data = CLR_SHORT_LO2 | CLR_SHORT_LO1; |
| 1335 | pm860x_set_bits(codec->control_data, REG_SHORTS, data, data); | 1296 | pm860x_set_bits(pm860x->i2c, REG_SHORTS, data, data); |
| 1336 | } | 1297 | } |
| 1337 | 1298 | ||
| 1338 | /* sync status */ | 1299 | /* sync status */ |
| @@ -1350,7 +1311,7 @@ int pm860x_mic_jack_detect(struct snd_soc_codec *codec, | |||
| 1350 | pm860x->det.mic_det = det; | 1311 | pm860x->det.mic_det = det; |
| 1351 | 1312 | ||
| 1352 | if (det & SND_JACK_MICROPHONE) | 1313 | if (det & SND_JACK_MICROPHONE) |
| 1353 | pm860x_set_bits(codec->control_data, REG_MIC_DET, | 1314 | pm860x_set_bits(pm860x->i2c, REG_MIC_DET, |
| 1354 | MICDET_MASK, MICDET_MASK); | 1315 | MICDET_MASK, MICDET_MASK); |
| 1355 | 1316 | ||
| 1356 | /* sync status */ | 1317 | /* sync status */ |
| @@ -1366,7 +1327,7 @@ static int pm860x_probe(struct snd_soc_codec *codec) | |||
| 1366 | 1327 | ||
| 1367 | pm860x->codec = codec; | 1328 | pm860x->codec = codec; |
| 1368 | 1329 | ||
| 1369 | codec->control_data = pm860x->i2c; | 1330 | codec->control_data = pm860x->regmap; |
| 1370 | 1331 | ||
| 1371 | for (i = 0; i < 4; i++) { | 1332 | for (i = 0; i < 4; i++) { |
| 1372 | ret = request_threaded_irq(pm860x->irq[i], NULL, | 1333 | ret = request_threaded_irq(pm860x->irq[i], NULL, |
| @@ -1380,14 +1341,6 @@ static int pm860x_probe(struct snd_soc_codec *codec) | |||
| 1380 | 1341 | ||
| 1381 | pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1342 | pm860x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 1382 | 1343 | ||
| 1383 | ret = pm860x_bulk_read(codec->control_data, REG_CACHE_BASE, | ||
| 1384 | REG_CACHE_SIZE, codec->reg_cache); | ||
| 1385 | if (ret < 0) { | ||
| 1386 | dev_err(codec->dev, "Failed to fill register cache: %d\n", | ||
| 1387 | ret); | ||
| 1388 | goto out; | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | return 0; | 1344 | return 0; |
| 1392 | 1345 | ||
| 1393 | out: | 1346 | out: |
| @@ -1410,10 +1363,6 @@ static int pm860x_remove(struct snd_soc_codec *codec) | |||
| 1410 | static struct snd_soc_codec_driver soc_codec_dev_pm860x = { | 1363 | static struct snd_soc_codec_driver soc_codec_dev_pm860x = { |
| 1411 | .probe = pm860x_probe, | 1364 | .probe = pm860x_probe, |
| 1412 | .remove = pm860x_remove, | 1365 | .remove = pm860x_remove, |
| 1413 | .read = pm860x_read_reg_cache, | ||
| 1414 | .write = pm860x_write_reg_cache, | ||
| 1415 | .reg_cache_size = REG_CACHE_SIZE, | ||
| 1416 | .reg_word_size = sizeof(u8), | ||
| 1417 | .set_bias_level = pm860x_set_bias_level, | 1366 | .set_bias_level = pm860x_set_bias_level, |
| 1418 | 1367 | ||
| 1419 | .controls = pm860x_snd_controls, | 1368 | .controls = pm860x_snd_controls, |
| @@ -1439,6 +1388,8 @@ static int pm860x_codec_probe(struct platform_device *pdev) | |||
| 1439 | pm860x->chip = chip; | 1388 | pm860x->chip = chip; |
| 1440 | pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client | 1389 | pm860x->i2c = (chip->id == CHIP_PM8607) ? chip->client |
| 1441 | : chip->companion; | 1390 | : chip->companion; |
| 1391 | pm860x->regmap = (chip->id == CHIP_PM8607) ? chip->regmap | ||
| 1392 | : chip->regmap_companion; | ||
| 1442 | platform_set_drvdata(pdev, pm860x); | 1393 | platform_set_drvdata(pdev, pm860x); |
| 1443 | 1394 | ||
| 1444 | for (i = 0; i < 4; i++) { | 1395 | for (i = 0; i < 4; i++) { |
diff --git a/sound/soc/codecs/88pm860x-codec.h b/sound/soc/codecs/88pm860x-codec.h index 3364ba4a3607..f7282f4f4a79 100644 --- a/sound/soc/codecs/88pm860x-codec.h +++ b/sound/soc/codecs/88pm860x-codec.h | |||
| @@ -12,67 +12,66 @@ | |||
| 12 | #ifndef __88PM860X_H | 12 | #ifndef __88PM860X_H |
| 13 | #define __88PM860X_H | 13 | #define __88PM860X_H |
| 14 | 14 | ||
| 15 | /* The offset of these registers are 0xb0 */ | 15 | #define PM860X_PCM_IFACE_1 0xb0 |
| 16 | #define PM860X_PCM_IFACE_1 0x00 | 16 | #define PM860X_PCM_IFACE_2 0xb1 |
| 17 | #define PM860X_PCM_IFACE_2 0x01 | 17 | #define PM860X_PCM_IFACE_3 0xb2 |
| 18 | #define PM860X_PCM_IFACE_3 0x02 | 18 | #define PM860X_PCM_RATE 0xb3 |
| 19 | #define PM860X_PCM_RATE 0x03 | 19 | #define PM860X_EC_PATH 0xb4 |
| 20 | #define PM860X_EC_PATH 0x04 | 20 | #define PM860X_SIDETONE_L_GAIN 0xb5 |
| 21 | #define PM860X_SIDETONE_L_GAIN 0x05 | 21 | #define PM860X_SIDETONE_R_GAIN 0xb6 |
| 22 | #define PM860X_SIDETONE_R_GAIN 0x06 | 22 | #define PM860X_SIDETONE_SHIFT 0xb7 |
| 23 | #define PM860X_SIDETONE_SHIFT 0x07 | 23 | #define PM860X_ADC_OFFSET_1 0xb8 |
| 24 | #define PM860X_ADC_OFFSET_1 0x08 | 24 | #define PM860X_ADC_OFFSET_2 0xb9 |
| 25 | #define PM860X_ADC_OFFSET_2 0x09 | 25 | #define PM860X_DMIC_DELAY 0xba |
| 26 | #define PM860X_DMIC_DELAY 0x0a | ||
| 27 | 26 | ||
| 28 | #define PM860X_I2S_IFACE_1 0x0b | 27 | #define PM860X_I2S_IFACE_1 0xbb |
| 29 | #define PM860X_I2S_IFACE_2 0x0c | 28 | #define PM860X_I2S_IFACE_2 0xbc |
| 30 | #define PM860X_I2S_IFACE_3 0x0d | 29 | #define PM860X_I2S_IFACE_3 0xbd |
| 31 | #define PM860X_I2S_IFACE_4 0x0e | 30 | #define PM860X_I2S_IFACE_4 0xbe |
| 32 | #define PM860X_EQUALIZER_N0_1 0x0f | 31 | #define PM860X_EQUALIZER_N0_1 0xbf |
| 33 | #define PM860X_EQUALIZER_N0_2 0x10 | 32 | #define PM860X_EQUALIZER_N0_2 0xc0 |
| 34 | #define PM860X_EQUALIZER_N1_1 0x11 | 33 | #define PM860X_EQUALIZER_N1_1 0xc1 |
| 35 | #define PM860X_EQUALIZER_N1_2 0x12 | 34 | #define PM860X_EQUALIZER_N1_2 0xc2 |
| 36 | #define PM860X_EQUALIZER_D1_1 0x13 | 35 | #define PM860X_EQUALIZER_D1_1 0xc3 |
| 37 | #define PM860X_EQUALIZER_D1_2 0x14 | 36 | #define PM860X_EQUALIZER_D1_2 0xc4 |
| 38 | #define PM860X_LOFI_GAIN_LEFT 0x15 | 37 | #define PM860X_LOFI_GAIN_LEFT 0xc5 |
| 39 | #define PM860X_LOFI_GAIN_RIGHT 0x16 | 38 | #define PM860X_LOFI_GAIN_RIGHT 0xc6 |
| 40 | #define PM860X_HIFIL_GAIN_LEFT 0x17 | 39 | #define PM860X_HIFIL_GAIN_LEFT 0xc7 |
| 41 | #define PM860X_HIFIL_GAIN_RIGHT 0x18 | 40 | #define PM860X_HIFIL_GAIN_RIGHT 0xc8 |
| 42 | #define PM860X_HIFIR_GAIN_LEFT 0x19 | 41 | #define PM860X_HIFIR_GAIN_LEFT 0xc9 |
| 43 | #define PM860X_HIFIR_GAIN_RIGHT 0x1a | 42 | #define PM860X_HIFIR_GAIN_RIGHT 0xca |
| 44 | #define PM860X_DAC_OFFSET 0x1b | 43 | #define PM860X_DAC_OFFSET 0xcb |
| 45 | #define PM860X_OFFSET_LEFT_1 0x1c | 44 | #define PM860X_OFFSET_LEFT_1 0xcc |
| 46 | #define PM860X_OFFSET_LEFT_2 0x1d | 45 | #define PM860X_OFFSET_LEFT_2 0xcd |
| 47 | #define PM860X_OFFSET_RIGHT_1 0x1e | 46 | #define PM860X_OFFSET_RIGHT_1 0xce |
| 48 | #define PM860X_OFFSET_RIGHT_2 0x1f | 47 | #define PM860X_OFFSET_RIGHT_2 0xcf |
| 49 | #define PM860X_ADC_ANA_1 0x20 | 48 | #define PM860X_ADC_ANA_1 0xd0 |
| 50 | #define PM860X_ADC_ANA_2 0x21 | 49 | #define PM860X_ADC_ANA_2 0xd1 |
| 51 | #define PM860X_ADC_ANA_3 0x22 | 50 | #define PM860X_ADC_ANA_3 0xd2 |
| 52 | #define PM860X_ADC_ANA_4 0x23 | 51 | #define PM860X_ADC_ANA_4 0xd3 |
| 53 | #define PM860X_ANA_TO_ANA 0x24 | 52 | #define PM860X_ANA_TO_ANA 0xd4 |
| 54 | #define PM860X_HS1_CTRL 0x25 | 53 | #define PM860X_HS1_CTRL 0xd5 |
| 55 | #define PM860X_HS2_CTRL 0x26 | 54 | #define PM860X_HS2_CTRL 0xd6 |
| 56 | #define PM860X_LO1_CTRL 0x27 | 55 | #define PM860X_LO1_CTRL 0xd7 |
| 57 | #define PM860X_LO2_CTRL 0x28 | 56 | #define PM860X_LO2_CTRL 0xd8 |
| 58 | #define PM860X_EAR_CTRL_1 0x29 | 57 | #define PM860X_EAR_CTRL_1 0xd9 |
| 59 | #define PM860X_EAR_CTRL_2 0x2a | 58 | #define PM860X_EAR_CTRL_2 0xda |
| 60 | #define PM860X_AUDIO_SUPPLIES_1 0x2b | 59 | #define PM860X_AUDIO_SUPPLIES_1 0xdb |
| 61 | #define PM860X_AUDIO_SUPPLIES_2 0x2c | 60 | #define PM860X_AUDIO_SUPPLIES_2 0xdc |
| 62 | #define PM860X_ADC_EN_1 0x2d | 61 | #define PM860X_ADC_EN_1 0xdd |
| 63 | #define PM860X_ADC_EN_2 0x2e | 62 | #define PM860X_ADC_EN_2 0xde |
| 64 | #define PM860X_DAC_EN_1 0x2f | 63 | #define PM860X_DAC_EN_1 0xdf |
| 65 | #define PM860X_DAC_EN_2 0x31 | 64 | #define PM860X_DAC_EN_2 0xe1 |
| 66 | #define PM860X_AUDIO_CAL_1 0x32 | 65 | #define PM860X_AUDIO_CAL_1 0xe2 |
| 67 | #define PM860X_AUDIO_CAL_2 0x33 | 66 | #define PM860X_AUDIO_CAL_2 0xe3 |
| 68 | #define PM860X_AUDIO_CAL_3 0x34 | 67 | #define PM860X_AUDIO_CAL_3 0xe4 |
| 69 | #define PM860X_AUDIO_CAL_4 0x35 | 68 | #define PM860X_AUDIO_CAL_4 0xe5 |
| 70 | #define PM860X_AUDIO_CAL_5 0x36 | 69 | #define PM860X_AUDIO_CAL_5 0xe6 |
| 71 | #define PM860X_ANA_INPUT_SEL_1 0x37 | 70 | #define PM860X_ANA_INPUT_SEL_1 0xe7 |
| 72 | #define PM860X_ANA_INPUT_SEL_2 0x38 | 71 | #define PM860X_ANA_INPUT_SEL_2 0xe8 |
| 73 | 72 | ||
| 74 | #define PM860X_PCM_IFACE_4 0x39 | 73 | #define PM860X_PCM_IFACE_4 0xe9 |
| 75 | #define PM860X_I2S_IFACE_5 0x3a | 74 | #define PM860X_I2S_IFACE_5 0xea |
| 76 | 75 | ||
| 77 | #define PM860X_SHORTS 0x3b | 76 | #define PM860X_SHORTS 0x3b |
| 78 | #define PM860X_PLL_ADJ_1 0x3c | 77 | #define PM860X_PLL_ADJ_1 0x3c |
diff --git a/sound/soc/codecs/ab8500-codec.c b/sound/soc/codecs/ab8500-codec.c index 80555d7551e6..a0394a8f2257 100644 --- a/sound/soc/codecs/ab8500-codec.c +++ b/sound/soc/codecs/ab8500-codec.c | |||
| @@ -126,6 +126,8 @@ struct ab8500_codec_drvdata_dbg { | |||
| 126 | 126 | ||
| 127 | /* Private data for AB8500 device-driver */ | 127 | /* Private data for AB8500 device-driver */ |
| 128 | struct ab8500_codec_drvdata { | 128 | struct ab8500_codec_drvdata { |
| 129 | struct regmap *regmap; | ||
| 130 | |||
| 129 | /* Sidetone */ | 131 | /* Sidetone */ |
| 130 | long *sid_fir_values; | 132 | long *sid_fir_values; |
| 131 | enum sid_state sid_status; | 133 | enum sid_state sid_status; |
| @@ -166,49 +168,35 @@ static inline const char *amic_type_str(enum amic_type type) | |||
| 166 | */ | 168 | */ |
| 167 | 169 | ||
| 168 | /* Read a register from the audio-bank of AB8500 */ | 170 | /* Read a register from the audio-bank of AB8500 */ |
| 169 | static unsigned int ab8500_codec_read_reg(struct snd_soc_codec *codec, | 171 | static int ab8500_codec_read_reg(void *context, unsigned int reg, |
| 170 | unsigned int reg) | 172 | unsigned int *value) |
| 171 | { | 173 | { |
| 174 | struct device *dev = context; | ||
| 172 | int status; | 175 | int status; |
| 173 | unsigned int value = 0; | ||
| 174 | 176 | ||
| 175 | u8 value8; | 177 | u8 value8; |
| 176 | status = abx500_get_register_interruptible(codec->dev, AB8500_AUDIO, | 178 | status = abx500_get_register_interruptible(dev, AB8500_AUDIO, |
| 177 | reg, &value8); | 179 | reg, &value8); |
| 178 | if (status < 0) { | 180 | *value = (unsigned int)value8; |
| 179 | dev_err(codec->dev, | ||
| 180 | "%s: ERROR: Register (0x%02x:0x%02x) read failed (%d).\n", | ||
| 181 | __func__, (u8)AB8500_AUDIO, (u8)reg, status); | ||
| 182 | } else { | ||
| 183 | dev_dbg(codec->dev, | ||
| 184 | "%s: Read 0x%02x from register 0x%02x:0x%02x\n", | ||
| 185 | __func__, value8, (u8)AB8500_AUDIO, (u8)reg); | ||
| 186 | value = (unsigned int)value8; | ||
| 187 | } | ||
| 188 | 181 | ||
| 189 | return value; | 182 | return status; |
| 190 | } | 183 | } |
| 191 | 184 | ||
| 192 | /* Write to a register in the audio-bank of AB8500 */ | 185 | /* Write to a register in the audio-bank of AB8500 */ |
| 193 | static int ab8500_codec_write_reg(struct snd_soc_codec *codec, | 186 | static int ab8500_codec_write_reg(void *context, unsigned int reg, |
| 194 | unsigned int reg, unsigned int value) | 187 | unsigned int value) |
| 195 | { | 188 | { |
| 196 | int status; | 189 | struct device *dev = context; |
| 197 | |||
| 198 | status = abx500_set_register_interruptible(codec->dev, AB8500_AUDIO, | ||
| 199 | reg, value); | ||
| 200 | if (status < 0) | ||
| 201 | dev_err(codec->dev, | ||
| 202 | "%s: ERROR: Register (%02x:%02x) write failed (%d).\n", | ||
| 203 | __func__, (u8)AB8500_AUDIO, (u8)reg, status); | ||
| 204 | else | ||
| 205 | dev_dbg(codec->dev, | ||
| 206 | "%s: Wrote 0x%02x into register %02x:%02x\n", | ||
| 207 | __func__, (u8)value, (u8)AB8500_AUDIO, (u8)reg); | ||
| 208 | 190 | ||
| 209 | return status; | 191 | return abx500_set_register_interruptible(dev, AB8500_AUDIO, |
| 192 | reg, value); | ||
| 210 | } | 193 | } |
| 211 | 194 | ||
| 195 | static const struct regmap_config ab8500_codec_regmap = { | ||
| 196 | .reg_read = ab8500_codec_read_reg, | ||
| 197 | .reg_write = ab8500_codec_write_reg, | ||
| 198 | }; | ||
| 199 | |||
| 212 | /* | 200 | /* |
| 213 | * Controls - DAPM | 201 | * Controls - DAPM |
| 214 | */ | 202 | */ |
| @@ -2485,9 +2473,13 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) | |||
| 2485 | 2473 | ||
| 2486 | dev_dbg(dev, "%s: Enter.\n", __func__); | 2474 | dev_dbg(dev, "%s: Enter.\n", __func__); |
| 2487 | 2475 | ||
| 2476 | snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); | ||
| 2477 | |||
| 2488 | /* Setup AB8500 according to board-settings */ | 2478 | /* Setup AB8500 according to board-settings */ |
| 2489 | pdata = dev_get_platdata(dev->parent); | 2479 | pdata = dev_get_platdata(dev->parent); |
| 2490 | 2480 | ||
| 2481 | codec->control_data = drvdata->regmap; | ||
| 2482 | |||
| 2491 | if (np) { | 2483 | if (np) { |
| 2492 | if (!pdata) | 2484 | if (!pdata) |
| 2493 | pdata = devm_kzalloc(dev, | 2485 | pdata = devm_kzalloc(dev, |
| @@ -2532,12 +2524,10 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) | |||
| 2532 | } | 2524 | } |
| 2533 | 2525 | ||
| 2534 | /* Override HW-defaults */ | 2526 | /* Override HW-defaults */ |
| 2535 | ab8500_codec_write_reg(codec, | 2527 | snd_soc_write(codec, AB8500_ANACONF5, |
| 2536 | AB8500_ANACONF5, | 2528 | BIT(AB8500_ANACONF5_HSAUTOEN)); |
| 2537 | BIT(AB8500_ANACONF5_HSAUTOEN)); | 2529 | snd_soc_write(codec, AB8500_SHORTCIRCONF, |
| 2538 | ab8500_codec_write_reg(codec, | 2530 | BIT(AB8500_SHORTCIRCONF_HSZCDDIS)); |
| 2539 | AB8500_SHORTCIRCONF, | ||
| 2540 | BIT(AB8500_SHORTCIRCONF_HSZCDDIS)); | ||
| 2541 | 2531 | ||
| 2542 | /* Add filter controls */ | 2532 | /* Add filter controls */ |
| 2543 | status = snd_soc_add_codec_controls(codec, ab8500_filter_controls, | 2533 | status = snd_soc_add_codec_controls(codec, ab8500_filter_controls, |
| @@ -2567,9 +2557,6 @@ static int ab8500_codec_probe(struct snd_soc_codec *codec) | |||
| 2567 | 2557 | ||
| 2568 | static struct snd_soc_codec_driver ab8500_codec_driver = { | 2558 | static struct snd_soc_codec_driver ab8500_codec_driver = { |
| 2569 | .probe = ab8500_codec_probe, | 2559 | .probe = ab8500_codec_probe, |
| 2570 | .read = ab8500_codec_read_reg, | ||
| 2571 | .write = ab8500_codec_write_reg, | ||
| 2572 | .reg_word_size = sizeof(u8), | ||
| 2573 | .controls = ab8500_ctrls, | 2560 | .controls = ab8500_ctrls, |
| 2574 | .num_controls = ARRAY_SIZE(ab8500_ctrls), | 2561 | .num_controls = ARRAY_SIZE(ab8500_ctrls), |
| 2575 | .dapm_widgets = ab8500_dapm_widgets, | 2562 | .dapm_widgets = ab8500_dapm_widgets, |
| @@ -2592,6 +2579,15 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) | |||
| 2592 | drvdata->anc_status = ANC_UNCONFIGURED; | 2579 | drvdata->anc_status = ANC_UNCONFIGURED; |
| 2593 | dev_set_drvdata(&pdev->dev, drvdata); | 2580 | dev_set_drvdata(&pdev->dev, drvdata); |
| 2594 | 2581 | ||
| 2582 | drvdata->regmap = devm_regmap_init(&pdev->dev, NULL, &pdev->dev, | ||
| 2583 | &ab8500_codec_regmap); | ||
| 2584 | if (IS_ERR(drvdata->regmap)) { | ||
| 2585 | status = PTR_ERR(drvdata->regmap); | ||
| 2586 | dev_err(&pdev->dev, "%s: Failed to allocate regmap: %d\n", | ||
| 2587 | __func__, status); | ||
| 2588 | return status; | ||
| 2589 | } | ||
| 2590 | |||
| 2595 | dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); | 2591 | dev_dbg(&pdev->dev, "%s: Register codec.\n", __func__); |
| 2596 | status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, | 2592 | status = snd_soc_register_codec(&pdev->dev, &ab8500_codec_driver, |
| 2597 | ab8500_codec_dai, | 2593 | ab8500_codec_dai, |
| @@ -2606,7 +2602,7 @@ static int ab8500_codec_driver_probe(struct platform_device *pdev) | |||
| 2606 | 2602 | ||
| 2607 | static int ab8500_codec_driver_remove(struct platform_device *pdev) | 2603 | static int ab8500_codec_driver_remove(struct platform_device *pdev) |
| 2608 | { | 2604 | { |
| 2609 | dev_info(&pdev->dev, "%s Enter.\n", __func__); | 2605 | dev_dbg(&pdev->dev, "%s Enter.\n", __func__); |
| 2610 | 2606 | ||
| 2611 | snd_soc_unregister_codec(&pdev->dev); | 2607 | snd_soc_unregister_codec(&pdev->dev); |
| 2612 | 2608 | ||
diff --git a/sound/soc/codecs/adau1373.c b/sound/soc/codecs/adau1373.c index 1aa10ddf3a61..59654b1e7f3f 100644 --- a/sound/soc/codecs/adau1373.c +++ b/sound/soc/codecs/adau1373.c | |||
| @@ -32,6 +32,7 @@ struct adau1373_dai { | |||
| 32 | }; | 32 | }; |
| 33 | 33 | ||
| 34 | struct adau1373 { | 34 | struct adau1373 { |
| 35 | struct regmap *regmap; | ||
| 35 | struct adau1373_dai dais[3]; | 36 | struct adau1373_dai dais[3]; |
| 36 | }; | 37 | }; |
| 37 | 38 | ||
| @@ -73,7 +74,6 @@ struct adau1373 { | |||
| 73 | #define ADAU1373_PLL_CTRL4(x) (0x2c + (x) * 7) | 74 | #define ADAU1373_PLL_CTRL4(x) (0x2c + (x) * 7) |
| 74 | #define ADAU1373_PLL_CTRL5(x) (0x2d + (x) * 7) | 75 | #define ADAU1373_PLL_CTRL5(x) (0x2d + (x) * 7) |
| 75 | #define ADAU1373_PLL_CTRL6(x) (0x2e + (x) * 7) | 76 | #define ADAU1373_PLL_CTRL6(x) (0x2e + (x) * 7) |
| 76 | #define ADAU1373_PLL_CTRL7(x) (0x2f + (x) * 7) | ||
| 77 | #define ADAU1373_HEADDECT 0x36 | 77 | #define ADAU1373_HEADDECT 0x36 |
| 78 | #define ADAU1373_ADC_DAC_STATUS 0x37 | 78 | #define ADAU1373_ADC_DAC_STATUS 0x37 |
| 79 | #define ADAU1373_ADC_CTRL 0x3c | 79 | #define ADAU1373_ADC_CTRL 0x3c |
| @@ -152,37 +152,172 @@ struct adau1373 { | |||
| 152 | #define ADAU1373_EP_CTRL_MICBIAS1_OFFSET 4 | 152 | #define ADAU1373_EP_CTRL_MICBIAS1_OFFSET 4 |
| 153 | #define ADAU1373_EP_CTRL_MICBIAS2_OFFSET 2 | 153 | #define ADAU1373_EP_CTRL_MICBIAS2_OFFSET 2 |
| 154 | 154 | ||
| 155 | static const uint8_t adau1373_default_regs[] = { | 155 | static const struct reg_default adau1373_reg_defaults[] = { |
| 156 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x00 */ | 156 | { ADAU1373_INPUT_MODE, 0x00 }, |
| 157 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 157 | { ADAU1373_AINL_CTRL(0), 0x00 }, |
| 158 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x10 */ | 158 | { ADAU1373_AINR_CTRL(0), 0x00 }, |
| 159 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 159 | { ADAU1373_AINL_CTRL(1), 0x00 }, |
| 160 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x20 */ | 160 | { ADAU1373_AINR_CTRL(1), 0x00 }, |
| 161 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, | 161 | { ADAU1373_AINL_CTRL(2), 0x00 }, |
| 162 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, /* 0x30 */ | 162 | { ADAU1373_AINR_CTRL(2), 0x00 }, |
| 163 | 0x00, 0x00, 0x00, 0x80, 0x00, 0x01, 0x00, 0x00, | 163 | { ADAU1373_AINL_CTRL(3), 0x00 }, |
| 164 | 0x00, 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x00, /* 0x40 */ | 164 | { ADAU1373_AINR_CTRL(3), 0x00 }, |
| 165 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 165 | { ADAU1373_LLINE_OUT(0), 0x00 }, |
| 166 | 0x00, 0x08, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, /* 0x50 */ | 166 | { ADAU1373_RLINE_OUT(0), 0x00 }, |
| 167 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 167 | { ADAU1373_LLINE_OUT(1), 0x00 }, |
| 168 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x60 */ | 168 | { ADAU1373_RLINE_OUT(1), 0x00 }, |
| 169 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 169 | { ADAU1373_LSPK_OUT, 0x00 }, |
| 170 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x70 */ | 170 | { ADAU1373_RSPK_OUT, 0x00 }, |
| 171 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 171 | { ADAU1373_LHP_OUT, 0x00 }, |
| 172 | 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0x80 */ | 172 | { ADAU1373_RHP_OUT, 0x00 }, |
| 173 | 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00, | 173 | { ADAU1373_ADC_GAIN, 0x00 }, |
| 174 | 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0x90 */ | 174 | { ADAU1373_LADC_MIXER, 0x00 }, |
| 175 | 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00, | 175 | { ADAU1373_RADC_MIXER, 0x00 }, |
| 176 | 0x78, 0x18, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, /* 0xa0 */ | 176 | { ADAU1373_LLINE1_MIX, 0x00 }, |
| 177 | 0x00, 0xc0, 0x88, 0x7a, 0xdf, 0x20, 0x00, 0x00, | 177 | { ADAU1373_RLINE1_MIX, 0x00 }, |
| 178 | 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, /* 0xb0 */ | 178 | { ADAU1373_LLINE2_MIX, 0x00 }, |
| 179 | 0xff, 0xff, 0xff, 0xff, 0xff, 0x1f, 0x00, 0x00, | 179 | { ADAU1373_RLINE2_MIX, 0x00 }, |
| 180 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xc0 */ | 180 | { ADAU1373_LSPK_MIX, 0x00 }, |
| 181 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 181 | { ADAU1373_RSPK_MIX, 0x00 }, |
| 182 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0xd0 */ | 182 | { ADAU1373_LHP_MIX, 0x00 }, |
| 183 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 183 | { ADAU1373_RHP_MIX, 0x00 }, |
| 184 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, /* 0xe0 */ | 184 | { ADAU1373_EP_MIX, 0x00 }, |
| 185 | 0x00, 0x1f, 0x0f, 0x00, 0x00, | 185 | { ADAU1373_HP_CTRL, 0x00 }, |
| 186 | { ADAU1373_HP_CTRL2, 0x00 }, | ||
| 187 | { ADAU1373_LS_CTRL, 0x00 }, | ||
| 188 | { ADAU1373_EP_CTRL, 0x00 }, | ||
| 189 | { ADAU1373_MICBIAS_CTRL1, 0x00 }, | ||
| 190 | { ADAU1373_MICBIAS_CTRL2, 0x00 }, | ||
| 191 | { ADAU1373_OUTPUT_CTRL, 0x00 }, | ||
| 192 | { ADAU1373_PWDN_CTRL1, 0x00 }, | ||
| 193 | { ADAU1373_PWDN_CTRL2, 0x00 }, | ||
| 194 | { ADAU1373_PWDN_CTRL3, 0x00 }, | ||
| 195 | { ADAU1373_DPLL_CTRL(0), 0x00 }, | ||
| 196 | { ADAU1373_PLL_CTRL1(0), 0x00 }, | ||
| 197 | { ADAU1373_PLL_CTRL2(0), 0x00 }, | ||
| 198 | { ADAU1373_PLL_CTRL3(0), 0x00 }, | ||
| 199 | { ADAU1373_PLL_CTRL4(0), 0x00 }, | ||
| 200 | { ADAU1373_PLL_CTRL5(0), 0x00 }, | ||
| 201 | { ADAU1373_PLL_CTRL6(0), 0x02 }, | ||
| 202 | { ADAU1373_DPLL_CTRL(1), 0x00 }, | ||
| 203 | { ADAU1373_PLL_CTRL1(1), 0x00 }, | ||
| 204 | { ADAU1373_PLL_CTRL2(1), 0x00 }, | ||
| 205 | { ADAU1373_PLL_CTRL3(1), 0x00 }, | ||
| 206 | { ADAU1373_PLL_CTRL4(1), 0x00 }, | ||
| 207 | { ADAU1373_PLL_CTRL5(1), 0x00 }, | ||
| 208 | { ADAU1373_PLL_CTRL6(1), 0x02 }, | ||
| 209 | { ADAU1373_HEADDECT, 0x00 }, | ||
| 210 | { ADAU1373_ADC_CTRL, 0x00 }, | ||
| 211 | { ADAU1373_CLK_SRC_DIV(0), 0x00 }, | ||
| 212 | { ADAU1373_CLK_SRC_DIV(1), 0x00 }, | ||
| 213 | { ADAU1373_DAI(0), 0x0a }, | ||
| 214 | { ADAU1373_DAI(1), 0x0a }, | ||
| 215 | { ADAU1373_DAI(2), 0x0a }, | ||
| 216 | { ADAU1373_BCLKDIV(0), 0x00 }, | ||
| 217 | { ADAU1373_BCLKDIV(1), 0x00 }, | ||
| 218 | { ADAU1373_BCLKDIV(2), 0x00 }, | ||
| 219 | { ADAU1373_SRC_RATIOA(0), 0x00 }, | ||
| 220 | { ADAU1373_SRC_RATIOB(0), 0x00 }, | ||
| 221 | { ADAU1373_SRC_RATIOA(1), 0x00 }, | ||
| 222 | { ADAU1373_SRC_RATIOB(1), 0x00 }, | ||
| 223 | { ADAU1373_SRC_RATIOA(2), 0x00 }, | ||
| 224 | { ADAU1373_SRC_RATIOB(2), 0x00 }, | ||
| 225 | { ADAU1373_DEEMP_CTRL, 0x00 }, | ||
| 226 | { ADAU1373_SRC_DAI_CTRL(0), 0x08 }, | ||
| 227 | { ADAU1373_SRC_DAI_CTRL(1), 0x08 }, | ||
| 228 | { ADAU1373_SRC_DAI_CTRL(2), 0x08 }, | ||
| 229 | { ADAU1373_DIN_MIX_CTRL(0), 0x00 }, | ||
| 230 | { ADAU1373_DIN_MIX_CTRL(1), 0x00 }, | ||
| 231 | { ADAU1373_DIN_MIX_CTRL(2), 0x00 }, | ||
| 232 | { ADAU1373_DIN_MIX_CTRL(3), 0x00 }, | ||
| 233 | { ADAU1373_DIN_MIX_CTRL(4), 0x00 }, | ||
| 234 | { ADAU1373_DOUT_MIX_CTRL(0), 0x00 }, | ||
| 235 | { ADAU1373_DOUT_MIX_CTRL(1), 0x00 }, | ||
| 236 | { ADAU1373_DOUT_MIX_CTRL(2), 0x00 }, | ||
| 237 | { ADAU1373_DOUT_MIX_CTRL(3), 0x00 }, | ||
| 238 | { ADAU1373_DOUT_MIX_CTRL(4), 0x00 }, | ||
| 239 | { ADAU1373_DAI_PBL_VOL(0), 0x00 }, | ||
| 240 | { ADAU1373_DAI_PBR_VOL(0), 0x00 }, | ||
| 241 | { ADAU1373_DAI_PBL_VOL(1), 0x00 }, | ||
| 242 | { ADAU1373_DAI_PBR_VOL(1), 0x00 }, | ||
| 243 | { ADAU1373_DAI_PBL_VOL(2), 0x00 }, | ||
| 244 | { ADAU1373_DAI_PBR_VOL(2), 0x00 }, | ||
| 245 | { ADAU1373_DAI_RECL_VOL(0), 0x00 }, | ||
| 246 | { ADAU1373_DAI_RECR_VOL(0), 0x00 }, | ||
| 247 | { ADAU1373_DAI_RECL_VOL(1), 0x00 }, | ||
| 248 | { ADAU1373_DAI_RECR_VOL(1), 0x00 }, | ||
| 249 | { ADAU1373_DAI_RECL_VOL(2), 0x00 }, | ||
| 250 | { ADAU1373_DAI_RECR_VOL(2), 0x00 }, | ||
| 251 | { ADAU1373_DAC1_PBL_VOL, 0x00 }, | ||
| 252 | { ADAU1373_DAC1_PBR_VOL, 0x00 }, | ||
| 253 | { ADAU1373_DAC2_PBL_VOL, 0x00 }, | ||
| 254 | { ADAU1373_DAC2_PBR_VOL, 0x00 }, | ||
| 255 | { ADAU1373_ADC_RECL_VOL, 0x00 }, | ||
| 256 | { ADAU1373_ADC_RECR_VOL, 0x00 }, | ||
| 257 | { ADAU1373_DMIC_RECL_VOL, 0x00 }, | ||
| 258 | { ADAU1373_DMIC_RECR_VOL, 0x00 }, | ||
| 259 | { ADAU1373_VOL_GAIN1, 0x00 }, | ||
| 260 | { ADAU1373_VOL_GAIN2, 0x00 }, | ||
| 261 | { ADAU1373_VOL_GAIN3, 0x00 }, | ||
| 262 | { ADAU1373_HPF_CTRL, 0x00 }, | ||
| 263 | { ADAU1373_BASS1, 0x00 }, | ||
| 264 | { ADAU1373_BASS2, 0x00 }, | ||
| 265 | { ADAU1373_DRC(0) + 0x0, 0x78 }, | ||
| 266 | { ADAU1373_DRC(0) + 0x1, 0x18 }, | ||
| 267 | { ADAU1373_DRC(0) + 0x2, 0x00 }, | ||
| 268 | { ADAU1373_DRC(0) + 0x3, 0x00 }, | ||
| 269 | { ADAU1373_DRC(0) + 0x4, 0x00 }, | ||
| 270 | { ADAU1373_DRC(0) + 0x5, 0xc0 }, | ||
| 271 | { ADAU1373_DRC(0) + 0x6, 0x00 }, | ||
| 272 | { ADAU1373_DRC(0) + 0x7, 0x00 }, | ||
| 273 | { ADAU1373_DRC(0) + 0x8, 0x00 }, | ||
| 274 | { ADAU1373_DRC(0) + 0x9, 0xc0 }, | ||
| 275 | { ADAU1373_DRC(0) + 0xa, 0x88 }, | ||
| 276 | { ADAU1373_DRC(0) + 0xb, 0x7a }, | ||
| 277 | { ADAU1373_DRC(0) + 0xc, 0xdf }, | ||
| 278 | { ADAU1373_DRC(0) + 0xd, 0x20 }, | ||
| 279 | { ADAU1373_DRC(0) + 0xe, 0x00 }, | ||
| 280 | { ADAU1373_DRC(0) + 0xf, 0x00 }, | ||
| 281 | { ADAU1373_DRC(1) + 0x0, 0x78 }, | ||
| 282 | { ADAU1373_DRC(1) + 0x1, 0x18 }, | ||
| 283 | { ADAU1373_DRC(1) + 0x2, 0x00 }, | ||
| 284 | { ADAU1373_DRC(1) + 0x3, 0x00 }, | ||
| 285 | { ADAU1373_DRC(1) + 0x4, 0x00 }, | ||
| 286 | { ADAU1373_DRC(1) + 0x5, 0xc0 }, | ||
| 287 | { ADAU1373_DRC(1) + 0x6, 0x00 }, | ||
| 288 | { ADAU1373_DRC(1) + 0x7, 0x00 }, | ||
| 289 | { ADAU1373_DRC(1) + 0x8, 0x00 }, | ||
| 290 | { ADAU1373_DRC(1) + 0x9, 0xc0 }, | ||
| 291 | { ADAU1373_DRC(1) + 0xa, 0x88 }, | ||
| 292 | { ADAU1373_DRC(1) + 0xb, 0x7a }, | ||
| 293 | { ADAU1373_DRC(1) + 0xc, 0xdf }, | ||
| 294 | { ADAU1373_DRC(1) + 0xd, 0x20 }, | ||
| 295 | { ADAU1373_DRC(1) + 0xe, 0x00 }, | ||
| 296 | { ADAU1373_DRC(1) + 0xf, 0x00 }, | ||
| 297 | { ADAU1373_DRC(2) + 0x0, 0x78 }, | ||
| 298 | { ADAU1373_DRC(2) + 0x1, 0x18 }, | ||
| 299 | { ADAU1373_DRC(2) + 0x2, 0x00 }, | ||
| 300 | { ADAU1373_DRC(2) + 0x3, 0x00 }, | ||
| 301 | { ADAU1373_DRC(2) + 0x4, 0x00 }, | ||
| 302 | { ADAU1373_DRC(2) + 0x5, 0xc0 }, | ||
| 303 | { ADAU1373_DRC(2) + 0x6, 0x00 }, | ||
| 304 | { ADAU1373_DRC(2) + 0x7, 0x00 }, | ||
| 305 | { ADAU1373_DRC(2) + 0x8, 0x00 }, | ||
| 306 | { ADAU1373_DRC(2) + 0x9, 0xc0 }, | ||
| 307 | { ADAU1373_DRC(2) + 0xa, 0x88 }, | ||
| 308 | { ADAU1373_DRC(2) + 0xb, 0x7a }, | ||
| 309 | { ADAU1373_DRC(2) + 0xc, 0xdf }, | ||
| 310 | { ADAU1373_DRC(2) + 0xd, 0x20 }, | ||
| 311 | { ADAU1373_DRC(2) + 0xe, 0x00 }, | ||
| 312 | { ADAU1373_DRC(2) + 0xf, 0x00 }, | ||
| 313 | { ADAU1373_3D_CTRL1, 0x00 }, | ||
| 314 | { ADAU1373_3D_CTRL2, 0x00 }, | ||
| 315 | { ADAU1373_FDSP_SEL1, 0x00 }, | ||
| 316 | { ADAU1373_FDSP_SEL2, 0x00 }, | ||
| 317 | { ADAU1373_FDSP_SEL2, 0x00 }, | ||
| 318 | { ADAU1373_FDSP_SEL4, 0x00 }, | ||
| 319 | { ADAU1373_DIGMICCTRL, 0x00 }, | ||
| 320 | { ADAU1373_DIGEN, 0x00 }, | ||
| 186 | }; | 321 | }; |
| 187 | 322 | ||
| 188 | static const unsigned int adau1373_out_tlv[] = { | 323 | static const unsigned int adau1373_out_tlv[] = { |
| @@ -418,6 +553,7 @@ static int adau1373_pll_event(struct snd_soc_dapm_widget *w, | |||
| 418 | struct snd_kcontrol *kcontrol, int event) | 553 | struct snd_kcontrol *kcontrol, int event) |
| 419 | { | 554 | { |
| 420 | struct snd_soc_codec *codec = w->codec; | 555 | struct snd_soc_codec *codec = w->codec; |
| 556 | struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); | ||
| 421 | unsigned int pll_id = w->name[3] - '1'; | 557 | unsigned int pll_id = w->name[3] - '1'; |
| 422 | unsigned int val; | 558 | unsigned int val; |
| 423 | 559 | ||
| @@ -426,7 +562,7 @@ static int adau1373_pll_event(struct snd_soc_dapm_widget *w, | |||
| 426 | else | 562 | else |
| 427 | val = 0; | 563 | val = 0; |
| 428 | 564 | ||
| 429 | snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id), | 565 | regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), |
| 430 | ADAU1373_PLL_CTRL6_PLL_EN, val); | 566 | ADAU1373_PLL_CTRL6_PLL_EN, val); |
| 431 | 567 | ||
| 432 | if (SND_SOC_DAPM_EVENT_ON(event)) | 568 | if (SND_SOC_DAPM_EVENT_ON(event)) |
| @@ -938,7 +1074,7 @@ static int adau1373_hw_params(struct snd_pcm_substream *substream, | |||
| 938 | 1074 | ||
| 939 | adau1373_dai->enable_src = (div != 0); | 1075 | adau1373_dai->enable_src = (div != 0); |
| 940 | 1076 | ||
| 941 | snd_soc_update_bits(codec, ADAU1373_BCLKDIV(dai->id), | 1077 | regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id), |
| 942 | ADAU1373_BCLKDIV_SR_MASK | ADAU1373_BCLKDIV_BCLK_MASK, | 1078 | ADAU1373_BCLKDIV_SR_MASK | ADAU1373_BCLKDIV_BCLK_MASK, |
| 943 | (div << 2) | ADAU1373_BCLKDIV_64); | 1079 | (div << 2) | ADAU1373_BCLKDIV_64); |
| 944 | 1080 | ||
| @@ -959,7 +1095,7 @@ static int adau1373_hw_params(struct snd_pcm_substream *substream, | |||
| 959 | return -EINVAL; | 1095 | return -EINVAL; |
| 960 | } | 1096 | } |
| 961 | 1097 | ||
| 962 | return snd_soc_update_bits(codec, ADAU1373_DAI(dai->id), | 1098 | return regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id), |
| 963 | ADAU1373_DAI_WLEN_MASK, ctrl); | 1099 | ADAU1373_DAI_WLEN_MASK, ctrl); |
| 964 | } | 1100 | } |
| 965 | 1101 | ||
| @@ -1016,7 +1152,7 @@ static int adau1373_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
| 1016 | return -EINVAL; | 1152 | return -EINVAL; |
| 1017 | } | 1153 | } |
| 1018 | 1154 | ||
| 1019 | snd_soc_update_bits(codec, ADAU1373_DAI(dai->id), | 1155 | regmap_update_bits(adau1373->regmap, ADAU1373_DAI(dai->id), |
| 1020 | ~ADAU1373_DAI_WLEN_MASK, ctrl); | 1156 | ~ADAU1373_DAI_WLEN_MASK, ctrl); |
| 1021 | 1157 | ||
| 1022 | return 0; | 1158 | return 0; |
| @@ -1039,7 +1175,7 @@ static int adau1373_set_dai_sysclk(struct snd_soc_dai *dai, | |||
| 1039 | adau1373_dai->sysclk = freq; | 1175 | adau1373_dai->sysclk = freq; |
| 1040 | adau1373_dai->clk_src = clk_id; | 1176 | adau1373_dai->clk_src = clk_id; |
| 1041 | 1177 | ||
| 1042 | snd_soc_update_bits(dai->codec, ADAU1373_BCLKDIV(dai->id), | 1178 | regmap_update_bits(adau1373->regmap, ADAU1373_BCLKDIV(dai->id), |
| 1043 | ADAU1373_BCLKDIV_SOURCE, clk_id << 5); | 1179 | ADAU1373_BCLKDIV_SOURCE, clk_id << 5); |
| 1044 | 1180 | ||
| 1045 | return 0; | 1181 | return 0; |
| @@ -1120,6 +1256,7 @@ static struct snd_soc_dai_driver adau1373_dai_driver[] = { | |||
| 1120 | static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id, | 1256 | static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id, |
| 1121 | int source, unsigned int freq_in, unsigned int freq_out) | 1257 | int source, unsigned int freq_in, unsigned int freq_out) |
| 1122 | { | 1258 | { |
| 1259 | struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); | ||
| 1123 | unsigned int dpll_div = 0; | 1260 | unsigned int dpll_div = 0; |
| 1124 | unsigned int x, r, n, m, i, j, mode; | 1261 | unsigned int x, r, n, m, i, j, mode; |
| 1125 | 1262 | ||
| @@ -1187,36 +1324,36 @@ static int adau1373_set_pll(struct snd_soc_codec *codec, int pll_id, | |||
| 1187 | 1324 | ||
| 1188 | if (dpll_div) { | 1325 | if (dpll_div) { |
| 1189 | dpll_div = 11 - dpll_div; | 1326 | dpll_div = 11 - dpll_div; |
| 1190 | snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id), | 1327 | regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), |
| 1191 | ADAU1373_PLL_CTRL6_DPLL_BYPASS, 0); | 1328 | ADAU1373_PLL_CTRL6_DPLL_BYPASS, 0); |
| 1192 | } else { | 1329 | } else { |
| 1193 | snd_soc_update_bits(codec, ADAU1373_PLL_CTRL6(pll_id), | 1330 | regmap_update_bits(adau1373->regmap, ADAU1373_PLL_CTRL6(pll_id), |
| 1194 | ADAU1373_PLL_CTRL6_DPLL_BYPASS, | 1331 | ADAU1373_PLL_CTRL6_DPLL_BYPASS, |
| 1195 | ADAU1373_PLL_CTRL6_DPLL_BYPASS); | 1332 | ADAU1373_PLL_CTRL6_DPLL_BYPASS); |
| 1196 | } | 1333 | } |
| 1197 | 1334 | ||
| 1198 | snd_soc_write(codec, ADAU1373_DPLL_CTRL(pll_id), | 1335 | regmap_write(adau1373->regmap, ADAU1373_DPLL_CTRL(pll_id), |
| 1199 | (source << 4) | dpll_div); | 1336 | (source << 4) | dpll_div); |
| 1200 | snd_soc_write(codec, ADAU1373_PLL_CTRL1(pll_id), (m >> 8) & 0xff); | 1337 | regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL1(pll_id), (m >> 8) & 0xff); |
| 1201 | snd_soc_write(codec, ADAU1373_PLL_CTRL2(pll_id), m & 0xff); | 1338 | regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL2(pll_id), m & 0xff); |
| 1202 | snd_soc_write(codec, ADAU1373_PLL_CTRL3(pll_id), (n >> 8) & 0xff); | 1339 | regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL3(pll_id), (n >> 8) & 0xff); |
| 1203 | snd_soc_write(codec, ADAU1373_PLL_CTRL4(pll_id), n & 0xff); | 1340 | regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL4(pll_id), n & 0xff); |
| 1204 | snd_soc_write(codec, ADAU1373_PLL_CTRL5(pll_id), | 1341 | regmap_write(adau1373->regmap, ADAU1373_PLL_CTRL5(pll_id), |
| 1205 | (r << 3) | (x << 1) | mode); | 1342 | (r << 3) | (x << 1) | mode); |
| 1206 | 1343 | ||
| 1207 | /* Set sysclk to pll_rate / 4 */ | 1344 | /* Set sysclk to pll_rate / 4 */ |
| 1208 | snd_soc_update_bits(codec, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09); | 1345 | regmap_update_bits(adau1373->regmap, ADAU1373_CLK_SRC_DIV(pll_id), 0x3f, 0x09); |
| 1209 | 1346 | ||
| 1210 | return 0; | 1347 | return 0; |
| 1211 | } | 1348 | } |
| 1212 | 1349 | ||
| 1213 | static void adau1373_load_drc_settings(struct snd_soc_codec *codec, | 1350 | static void adau1373_load_drc_settings(struct adau1373 *adau1373, |
| 1214 | unsigned int nr, uint8_t *drc) | 1351 | unsigned int nr, uint8_t *drc) |
| 1215 | { | 1352 | { |
| 1216 | unsigned int i; | 1353 | unsigned int i; |
| 1217 | 1354 | ||
| 1218 | for (i = 0; i < ADAU1373_DRC_SIZE; ++i) | 1355 | for (i = 0; i < ADAU1373_DRC_SIZE; ++i) |
| 1219 | snd_soc_write(codec, ADAU1373_DRC(nr) + i, drc[i]); | 1356 | regmap_write(adau1373->regmap, ADAU1373_DRC(nr) + i, drc[i]); |
| 1220 | } | 1357 | } |
| 1221 | 1358 | ||
| 1222 | static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias) | 1359 | static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias) |
| @@ -1235,13 +1372,14 @@ static bool adau1373_valid_micbias(enum adau1373_micbias_voltage micbias) | |||
| 1235 | 1372 | ||
| 1236 | static int adau1373_probe(struct snd_soc_codec *codec) | 1373 | static int adau1373_probe(struct snd_soc_codec *codec) |
| 1237 | { | 1374 | { |
| 1375 | struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); | ||
| 1238 | struct adau1373_platform_data *pdata = codec->dev->platform_data; | 1376 | struct adau1373_platform_data *pdata = codec->dev->platform_data; |
| 1239 | bool lineout_differential = false; | 1377 | bool lineout_differential = false; |
| 1240 | unsigned int val; | 1378 | unsigned int val; |
| 1241 | int ret; | 1379 | int ret; |
| 1242 | int i; | 1380 | int i; |
| 1243 | 1381 | ||
| 1244 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); | 1382 | ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); |
| 1245 | if (ret) { | 1383 | if (ret) { |
| 1246 | dev_err(codec->dev, "failed to set cache I/O: %d\n", ret); | 1384 | dev_err(codec->dev, "failed to set cache I/O: %d\n", ret); |
| 1247 | return ret; | 1385 | return ret; |
| @@ -1256,7 +1394,7 @@ static int adau1373_probe(struct snd_soc_codec *codec) | |||
| 1256 | return -EINVAL; | 1394 | return -EINVAL; |
| 1257 | 1395 | ||
| 1258 | for (i = 0; i < pdata->num_drc; ++i) { | 1396 | for (i = 0; i < pdata->num_drc; ++i) { |
| 1259 | adau1373_load_drc_settings(codec, i, | 1397 | adau1373_load_drc_settings(adau1373, i, |
| 1260 | pdata->drc_setting[i]); | 1398 | pdata->drc_setting[i]); |
| 1261 | } | 1399 | } |
| 1262 | 1400 | ||
| @@ -1268,18 +1406,18 @@ static int adau1373_probe(struct snd_soc_codec *codec) | |||
| 1268 | if (pdata->input_differential[i]) | 1406 | if (pdata->input_differential[i]) |
| 1269 | val |= BIT(i); | 1407 | val |= BIT(i); |
| 1270 | } | 1408 | } |
| 1271 | snd_soc_write(codec, ADAU1373_INPUT_MODE, val); | 1409 | regmap_write(adau1373->regmap, ADAU1373_INPUT_MODE, val); |
| 1272 | 1410 | ||
| 1273 | val = 0; | 1411 | val = 0; |
| 1274 | if (pdata->lineout_differential) | 1412 | if (pdata->lineout_differential) |
| 1275 | val |= ADAU1373_OUTPUT_CTRL_LDIFF; | 1413 | val |= ADAU1373_OUTPUT_CTRL_LDIFF; |
| 1276 | if (pdata->lineout_ground_sense) | 1414 | if (pdata->lineout_ground_sense) |
| 1277 | val |= ADAU1373_OUTPUT_CTRL_LNFBEN; | 1415 | val |= ADAU1373_OUTPUT_CTRL_LNFBEN; |
| 1278 | snd_soc_write(codec, ADAU1373_OUTPUT_CTRL, val); | 1416 | regmap_write(adau1373->regmap, ADAU1373_OUTPUT_CTRL, val); |
| 1279 | 1417 | ||
| 1280 | lineout_differential = pdata->lineout_differential; | 1418 | lineout_differential = pdata->lineout_differential; |
| 1281 | 1419 | ||
| 1282 | snd_soc_write(codec, ADAU1373_EP_CTRL, | 1420 | regmap_write(adau1373->regmap, ADAU1373_EP_CTRL, |
| 1283 | (pdata->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) | | 1421 | (pdata->micbias1 << ADAU1373_EP_CTRL_MICBIAS1_OFFSET) | |
| 1284 | (pdata->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET)); | 1422 | (pdata->micbias2 << ADAU1373_EP_CTRL_MICBIAS2_OFFSET)); |
| 1285 | } | 1423 | } |
| @@ -1289,7 +1427,7 @@ static int adau1373_probe(struct snd_soc_codec *codec) | |||
| 1289 | ARRAY_SIZE(adau1373_lineout2_controls)); | 1427 | ARRAY_SIZE(adau1373_lineout2_controls)); |
| 1290 | } | 1428 | } |
| 1291 | 1429 | ||
| 1292 | snd_soc_write(codec, ADAU1373_ADC_CTRL, | 1430 | regmap_write(adau1373->regmap, ADAU1373_ADC_CTRL, |
| 1293 | ADAU1373_ADC_CTRL_RESET_FORCE | ADAU1373_ADC_CTRL_PEAK_DETECT); | 1431 | ADAU1373_ADC_CTRL_RESET_FORCE | ADAU1373_ADC_CTRL_PEAK_DETECT); |
| 1294 | 1432 | ||
| 1295 | return 0; | 1433 | return 0; |
| @@ -1298,17 +1436,19 @@ static int adau1373_probe(struct snd_soc_codec *codec) | |||
| 1298 | static int adau1373_set_bias_level(struct snd_soc_codec *codec, | 1436 | static int adau1373_set_bias_level(struct snd_soc_codec *codec, |
| 1299 | enum snd_soc_bias_level level) | 1437 | enum snd_soc_bias_level level) |
| 1300 | { | 1438 | { |
| 1439 | struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); | ||
| 1440 | |||
| 1301 | switch (level) { | 1441 | switch (level) { |
| 1302 | case SND_SOC_BIAS_ON: | 1442 | case SND_SOC_BIAS_ON: |
| 1303 | break; | 1443 | break; |
| 1304 | case SND_SOC_BIAS_PREPARE: | 1444 | case SND_SOC_BIAS_PREPARE: |
| 1305 | break; | 1445 | break; |
| 1306 | case SND_SOC_BIAS_STANDBY: | 1446 | case SND_SOC_BIAS_STANDBY: |
| 1307 | snd_soc_update_bits(codec, ADAU1373_PWDN_CTRL3, | 1447 | regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3, |
| 1308 | ADAU1373_PWDN_CTRL3_PWR_EN, ADAU1373_PWDN_CTRL3_PWR_EN); | 1448 | ADAU1373_PWDN_CTRL3_PWR_EN, ADAU1373_PWDN_CTRL3_PWR_EN); |
| 1309 | break; | 1449 | break; |
| 1310 | case SND_SOC_BIAS_OFF: | 1450 | case SND_SOC_BIAS_OFF: |
| 1311 | snd_soc_update_bits(codec, ADAU1373_PWDN_CTRL3, | 1451 | regmap_update_bits(adau1373->regmap, ADAU1373_PWDN_CTRL3, |
| 1312 | ADAU1373_PWDN_CTRL3_PWR_EN, 0); | 1452 | ADAU1373_PWDN_CTRL3_PWR_EN, 0); |
| 1313 | break; | 1453 | break; |
| 1314 | } | 1454 | } |
| @@ -1324,17 +1464,49 @@ static int adau1373_remove(struct snd_soc_codec *codec) | |||
| 1324 | 1464 | ||
| 1325 | static int adau1373_suspend(struct snd_soc_codec *codec) | 1465 | static int adau1373_suspend(struct snd_soc_codec *codec) |
| 1326 | { | 1466 | { |
| 1327 | return adau1373_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1467 | struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); |
| 1468 | int ret; | ||
| 1469 | |||
| 1470 | ret = adau1373_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
| 1471 | regcache_cache_only(adau1373->regmap, true); | ||
| 1472 | |||
| 1473 | return ret; | ||
| 1328 | } | 1474 | } |
| 1329 | 1475 | ||
| 1330 | static int adau1373_resume(struct snd_soc_codec *codec) | 1476 | static int adau1373_resume(struct snd_soc_codec *codec) |
| 1331 | { | 1477 | { |
| 1478 | struct adau1373 *adau1373 = snd_soc_codec_get_drvdata(codec); | ||
| 1479 | |||
| 1480 | regcache_cache_only(adau1373->regmap, false); | ||
| 1332 | adau1373_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1481 | adau1373_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 1333 | snd_soc_cache_sync(codec); | 1482 | regcache_sync(adau1373->regmap); |
| 1334 | 1483 | ||
| 1335 | return 0; | 1484 | return 0; |
| 1336 | } | 1485 | } |
| 1337 | 1486 | ||
| 1487 | static bool adau1373_register_volatile(struct device *dev, unsigned int reg) | ||
| 1488 | { | ||
| 1489 | switch (reg) { | ||
| 1490 | case ADAU1373_SOFT_RESET: | ||
| 1491 | case ADAU1373_ADC_DAC_STATUS: | ||
| 1492 | return true; | ||
| 1493 | default: | ||
| 1494 | return false; | ||
| 1495 | } | ||
| 1496 | } | ||
| 1497 | |||
| 1498 | static const struct regmap_config adau1373_regmap_config = { | ||
| 1499 | .val_bits = 8, | ||
| 1500 | .reg_bits = 8, | ||
| 1501 | |||
| 1502 | .volatile_reg = adau1373_register_volatile, | ||
| 1503 | .max_register = ADAU1373_SOFT_RESET, | ||
| 1504 | |||
| 1505 | .cache_type = REGCACHE_RBTREE, | ||
| 1506 | .reg_defaults = adau1373_reg_defaults, | ||
| 1507 | .num_reg_defaults = ARRAY_SIZE(adau1373_reg_defaults), | ||
| 1508 | }; | ||
| 1509 | |||
| 1338 | static struct snd_soc_codec_driver adau1373_codec_driver = { | 1510 | static struct snd_soc_codec_driver adau1373_codec_driver = { |
| 1339 | .probe = adau1373_probe, | 1511 | .probe = adau1373_probe, |
| 1340 | .remove = adau1373_remove, | 1512 | .remove = adau1373_remove, |
| @@ -1342,9 +1514,6 @@ static struct snd_soc_codec_driver adau1373_codec_driver = { | |||
| 1342 | .resume = adau1373_resume, | 1514 | .resume = adau1373_resume, |
| 1343 | .set_bias_level = adau1373_set_bias_level, | 1515 | .set_bias_level = adau1373_set_bias_level, |
| 1344 | .idle_bias_off = true, | 1516 | .idle_bias_off = true, |
| 1345 | .reg_cache_size = ARRAY_SIZE(adau1373_default_regs), | ||
| 1346 | .reg_cache_default = adau1373_default_regs, | ||
| 1347 | .reg_word_size = sizeof(uint8_t), | ||
| 1348 | 1517 | ||
| 1349 | .set_pll = adau1373_set_pll, | 1518 | .set_pll = adau1373_set_pll, |
| 1350 | 1519 | ||
| @@ -1366,6 +1535,13 @@ static int adau1373_i2c_probe(struct i2c_client *client, | |||
| 1366 | if (!adau1373) | 1535 | if (!adau1373) |
| 1367 | return -ENOMEM; | 1536 | return -ENOMEM; |
| 1368 | 1537 | ||
| 1538 | adau1373->regmap = devm_regmap_init_i2c(client, | ||
| 1539 | &adau1373_regmap_config); | ||
| 1540 | if (IS_ERR(adau1373->regmap)) | ||
| 1541 | return PTR_ERR(adau1373->regmap); | ||
| 1542 | |||
| 1543 | regmap_write(adau1373->regmap, ADAU1373_SOFT_RESET, 0x00); | ||
| 1544 | |||
| 1369 | dev_set_drvdata(&client->dev, adau1373); | 1545 | dev_set_drvdata(&client->dev, adau1373); |
| 1370 | 1546 | ||
| 1371 | ret = snd_soc_register_codec(&client->dev, &adau1373_codec_driver, | 1547 | ret = snd_soc_register_codec(&client->dev, &adau1373_codec_driver, |
diff --git a/sound/soc/codecs/adav80x.c b/sound/soc/codecs/adav80x.c index 15b012d0f226..14a7c169d004 100644 --- a/sound/soc/codecs/adav80x.c +++ b/sound/soc/codecs/adav80x.c | |||
| @@ -115,22 +115,34 @@ | |||
| 115 | 115 | ||
| 116 | #define ADAV80X_PLL_OUTE_SYSCLKPD(x) BIT(2 - (x)) | 116 | #define ADAV80X_PLL_OUTE_SYSCLKPD(x) BIT(2 - (x)) |
| 117 | 117 | ||
| 118 | static u8 adav80x_default_regs[] = { | 118 | static struct reg_default adav80x_reg_defaults[] = { |
| 119 | 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x02, 0x01, 0x80, 0x26, 0x00, 0x00, | 119 | { ADAV80X_PLAYBACK_CTRL, 0x01 }, |
| 120 | 0x02, 0x40, 0x20, 0x00, 0x09, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 120 | { ADAV80X_AUX_IN_CTRL, 0x01 }, |
| 121 | 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd1, 0x92, 0xb1, 0x37, | 121 | { ADAV80X_REC_CTRL, 0x02 }, |
| 122 | 0x48, 0xd2, 0xfb, 0xca, 0xd2, 0x15, 0xe8, 0x29, 0xb9, 0x6a, 0xda, 0x2b, | 122 | { ADAV80X_AUX_OUT_CTRL, 0x01 }, |
| 123 | 0xb7, 0xc0, 0x11, 0x65, 0x5c, 0xf6, 0xff, 0x8d, 0x00, 0x00, 0x00, 0x00, | 123 | { ADAV80X_DPATH_CTRL1, 0xc0 }, |
| 124 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 124 | { ADAV80X_DPATH_CTRL2, 0x11 }, |
| 125 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, | 125 | { ADAV80X_DAC_CTRL1, 0x00 }, |
| 126 | 0x00, 0xe8, 0x46, 0xe1, 0x5b, 0xd3, 0x43, 0x77, 0x93, 0xa7, 0x44, 0xee, | 126 | { ADAV80X_DAC_CTRL2, 0x00 }, |
| 127 | 0x32, 0x12, 0xc0, 0x11, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x3f, 0x3f, | 127 | { ADAV80X_DAC_CTRL3, 0x00 }, |
| 128 | 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x00, | 128 | { ADAV80X_DAC_L_VOL, 0xff }, |
| 129 | 0x00, 0x00, 0x00, 0x00, 0x52, 0x00, | 129 | { ADAV80X_DAC_R_VOL, 0xff }, |
| 130 | { ADAV80X_PGA_L_VOL, 0x00 }, | ||
| 131 | { ADAV80X_PGA_R_VOL, 0x00 }, | ||
| 132 | { ADAV80X_ADC_CTRL1, 0x00 }, | ||
| 133 | { ADAV80X_ADC_CTRL2, 0x00 }, | ||
| 134 | { ADAV80X_ADC_L_VOL, 0xff }, | ||
| 135 | { ADAV80X_ADC_R_VOL, 0xff }, | ||
| 136 | { ADAV80X_PLL_CTRL1, 0x00 }, | ||
| 137 | { ADAV80X_PLL_CTRL2, 0x00 }, | ||
| 138 | { ADAV80X_ICLK_CTRL1, 0x00 }, | ||
| 139 | { ADAV80X_ICLK_CTRL2, 0x00 }, | ||
| 140 | { ADAV80X_PLL_CLK_SRC, 0x00 }, | ||
| 141 | { ADAV80X_PLL_OUTE, 0x00 }, | ||
| 130 | }; | 142 | }; |
| 131 | 143 | ||
| 132 | struct adav80x { | 144 | struct adav80x { |
| 133 | enum snd_soc_control_type control_type; | 145 | struct regmap *regmap; |
| 134 | 146 | ||
| 135 | enum adav80x_clk_src clk_src; | 147 | enum adav80x_clk_src clk_src; |
| 136 | unsigned int sysclk; | 148 | unsigned int sysclk; |
| @@ -298,7 +310,7 @@ static int adav80x_set_deemph(struct snd_soc_codec *codec) | |||
| 298 | val = ADAV80X_DAC_CTRL2_DEEMPH_NONE; | 310 | val = ADAV80X_DAC_CTRL2_DEEMPH_NONE; |
| 299 | } | 311 | } |
| 300 | 312 | ||
| 301 | return snd_soc_update_bits(codec, ADAV80X_DAC_CTRL2, | 313 | return regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL2, |
| 302 | ADAV80X_DAC_CTRL2_DEEMPH_MASK, val); | 314 | ADAV80X_DAC_CTRL2_DEEMPH_MASK, val); |
| 303 | } | 315 | } |
| 304 | 316 | ||
| @@ -394,10 +406,11 @@ static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
| 394 | return -EINVAL; | 406 | return -EINVAL; |
| 395 | } | 407 | } |
| 396 | 408 | ||
| 397 | snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][0], | 409 | regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][0], |
| 398 | ADAV80X_CAPTURE_MODE_MASK | ADAV80X_CAPTURE_MODE_MASTER, | 410 | ADAV80X_CAPTURE_MODE_MASK | ADAV80X_CAPTURE_MODE_MASTER, |
| 399 | capture); | 411 | capture); |
| 400 | snd_soc_write(codec, adav80x_port_ctrl_regs[dai->id][1], playback); | 412 | regmap_write(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][1], |
| 413 | playback); | ||
| 401 | 414 | ||
| 402 | adav80x->dai_fmt[dai->id] = fmt & SND_SOC_DAIFMT_FORMAT_MASK; | 415 | adav80x->dai_fmt[dai->id] = fmt & SND_SOC_DAIFMT_FORMAT_MASK; |
| 403 | 416 | ||
| @@ -407,6 +420,7 @@ static int adav80x_set_dai_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
| 407 | static int adav80x_set_adc_clock(struct snd_soc_codec *codec, | 420 | static int adav80x_set_adc_clock(struct snd_soc_codec *codec, |
| 408 | unsigned int sample_rate) | 421 | unsigned int sample_rate) |
| 409 | { | 422 | { |
| 423 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | ||
| 410 | unsigned int val; | 424 | unsigned int val; |
| 411 | 425 | ||
| 412 | if (sample_rate <= 48000) | 426 | if (sample_rate <= 48000) |
| @@ -414,7 +428,7 @@ static int adav80x_set_adc_clock(struct snd_soc_codec *codec, | |||
| 414 | else | 428 | else |
| 415 | val = ADAV80X_ADC_CTRL1_MODULATOR_64FS; | 429 | val = ADAV80X_ADC_CTRL1_MODULATOR_64FS; |
| 416 | 430 | ||
| 417 | snd_soc_update_bits(codec, ADAV80X_ADC_CTRL1, | 431 | regmap_update_bits(adav80x->regmap, ADAV80X_ADC_CTRL1, |
| 418 | ADAV80X_ADC_CTRL1_MODULATOR_MASK, val); | 432 | ADAV80X_ADC_CTRL1_MODULATOR_MASK, val); |
| 419 | 433 | ||
| 420 | return 0; | 434 | return 0; |
| @@ -423,6 +437,7 @@ static int adav80x_set_adc_clock(struct snd_soc_codec *codec, | |||
| 423 | static int adav80x_set_dac_clock(struct snd_soc_codec *codec, | 437 | static int adav80x_set_dac_clock(struct snd_soc_codec *codec, |
| 424 | unsigned int sample_rate) | 438 | unsigned int sample_rate) |
| 425 | { | 439 | { |
| 440 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | ||
| 426 | unsigned int val; | 441 | unsigned int val; |
| 427 | 442 | ||
| 428 | if (sample_rate <= 48000) | 443 | if (sample_rate <= 48000) |
| @@ -430,7 +445,7 @@ static int adav80x_set_dac_clock(struct snd_soc_codec *codec, | |||
| 430 | else | 445 | else |
| 431 | val = ADAV80X_DAC_CTRL2_DIV2 | ADAV80X_DAC_CTRL2_INTERPOL_128FS; | 446 | val = ADAV80X_DAC_CTRL2_DIV2 | ADAV80X_DAC_CTRL2_INTERPOL_128FS; |
| 432 | 447 | ||
| 433 | snd_soc_update_bits(codec, ADAV80X_DAC_CTRL2, | 448 | regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL2, |
| 434 | ADAV80X_DAC_CTRL2_DIV_MASK | ADAV80X_DAC_CTRL2_INTERPOL_MASK, | 449 | ADAV80X_DAC_CTRL2_DIV_MASK | ADAV80X_DAC_CTRL2_INTERPOL_MASK, |
| 435 | val); | 450 | val); |
| 436 | 451 | ||
| @@ -440,6 +455,7 @@ static int adav80x_set_dac_clock(struct snd_soc_codec *codec, | |||
| 440 | static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, | 455 | static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, |
| 441 | struct snd_soc_dai *dai, snd_pcm_format_t format) | 456 | struct snd_soc_dai *dai, snd_pcm_format_t format) |
| 442 | { | 457 | { |
| 458 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | ||
| 443 | unsigned int val; | 459 | unsigned int val; |
| 444 | 460 | ||
| 445 | switch (format) { | 461 | switch (format) { |
| @@ -459,7 +475,7 @@ static int adav80x_set_capture_pcm_format(struct snd_soc_codec *codec, | |||
| 459 | return -EINVAL; | 475 | return -EINVAL; |
| 460 | } | 476 | } |
| 461 | 477 | ||
| 462 | snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][0], | 478 | regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][0], |
| 463 | ADAV80X_CAPTURE_WORD_LEN_MASK, val); | 479 | ADAV80X_CAPTURE_WORD_LEN_MASK, val); |
| 464 | 480 | ||
| 465 | return 0; | 481 | return 0; |
| @@ -491,7 +507,7 @@ static int adav80x_set_playback_pcm_format(struct snd_soc_codec *codec, | |||
| 491 | return -EINVAL; | 507 | return -EINVAL; |
| 492 | } | 508 | } |
| 493 | 509 | ||
| 494 | snd_soc_update_bits(codec, adav80x_port_ctrl_regs[dai->id][1], | 510 | regmap_update_bits(adav80x->regmap, adav80x_port_ctrl_regs[dai->id][1], |
| 495 | ADAV80X_PLAYBACK_MODE_MASK, val); | 511 | ADAV80X_PLAYBACK_MODE_MASK, val); |
| 496 | 512 | ||
| 497 | return 0; | 513 | return 0; |
| @@ -554,8 +570,10 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec, | |||
| 554 | ADAV80X_ICLK_CTRL1_ICLK2_SRC(clk_id); | 570 | ADAV80X_ICLK_CTRL1_ICLK2_SRC(clk_id); |
| 555 | iclk_ctrl2 = ADAV80X_ICLK_CTRL2_ICLK1_SRC(clk_id); | 571 | iclk_ctrl2 = ADAV80X_ICLK_CTRL2_ICLK1_SRC(clk_id); |
| 556 | 572 | ||
| 557 | snd_soc_write(codec, ADAV80X_ICLK_CTRL1, iclk_ctrl1); | 573 | regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL1, |
| 558 | snd_soc_write(codec, ADAV80X_ICLK_CTRL2, iclk_ctrl2); | 574 | iclk_ctrl1); |
| 575 | regmap_write(adav80x->regmap, ADAV80X_ICLK_CTRL2, | ||
| 576 | iclk_ctrl2); | ||
| 559 | 577 | ||
| 560 | snd_soc_dapm_sync(&codec->dapm); | 578 | snd_soc_dapm_sync(&codec->dapm); |
| 561 | } | 579 | } |
| @@ -575,10 +593,12 @@ static int adav80x_set_sysclk(struct snd_soc_codec *codec, | |||
| 575 | mask = ADAV80X_PLL_OUTE_SYSCLKPD(clk_id); | 593 | mask = ADAV80X_PLL_OUTE_SYSCLKPD(clk_id); |
| 576 | 594 | ||
| 577 | if (freq == 0) { | 595 | if (freq == 0) { |
| 578 | snd_soc_update_bits(codec, ADAV80X_PLL_OUTE, mask, mask); | 596 | regmap_update_bits(adav80x->regmap, ADAV80X_PLL_OUTE, |
| 597 | mask, mask); | ||
| 579 | adav80x->sysclk_pd[clk_id] = true; | 598 | adav80x->sysclk_pd[clk_id] = true; |
| 580 | } else { | 599 | } else { |
| 581 | snd_soc_update_bits(codec, ADAV80X_PLL_OUTE, mask, 0); | 600 | regmap_update_bits(adav80x->regmap, ADAV80X_PLL_OUTE, |
| 601 | mask, 0); | ||
| 582 | adav80x->sysclk_pd[clk_id] = false; | 602 | adav80x->sysclk_pd[clk_id] = false; |
| 583 | } | 603 | } |
| 584 | 604 | ||
| @@ -650,9 +670,9 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, | |||
| 650 | return -EINVAL; | 670 | return -EINVAL; |
| 651 | } | 671 | } |
| 652 | 672 | ||
| 653 | snd_soc_update_bits(codec, ADAV80X_PLL_CTRL1, ADAV80X_PLL_CTRL1_PLLDIV, | 673 | regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CTRL1, |
| 654 | pll_ctrl1); | 674 | ADAV80X_PLL_CTRL1_PLLDIV, pll_ctrl1); |
| 655 | snd_soc_update_bits(codec, ADAV80X_PLL_CTRL2, | 675 | regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CTRL2, |
| 656 | ADAV80X_PLL_CTRL2_PLL_MASK(pll_id), pll_ctrl2); | 676 | ADAV80X_PLL_CTRL2_PLL_MASK(pll_id), pll_ctrl2); |
| 657 | 677 | ||
| 658 | if (source != adav80x->pll_src) { | 678 | if (source != adav80x->pll_src) { |
| @@ -661,7 +681,7 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, | |||
| 661 | else | 681 | else |
| 662 | pll_src = ADAV80X_PLL_CLK_SRC_PLL_XIN(pll_id); | 682 | pll_src = ADAV80X_PLL_CLK_SRC_PLL_XIN(pll_id); |
| 663 | 683 | ||
| 664 | snd_soc_update_bits(codec, ADAV80X_PLL_CLK_SRC, | 684 | regmap_update_bits(adav80x->regmap, ADAV80X_PLL_CLK_SRC, |
| 665 | ADAV80X_PLL_CLK_SRC_PLL_MASK(pll_id), pll_src); | 685 | ADAV80X_PLL_CLK_SRC_PLL_MASK(pll_id), pll_src); |
| 666 | 686 | ||
| 667 | adav80x->pll_src = source; | 687 | adav80x->pll_src = source; |
| @@ -675,6 +695,7 @@ static int adav80x_set_pll(struct snd_soc_codec *codec, int pll_id, | |||
| 675 | static int adav80x_set_bias_level(struct snd_soc_codec *codec, | 695 | static int adav80x_set_bias_level(struct snd_soc_codec *codec, |
| 676 | enum snd_soc_bias_level level) | 696 | enum snd_soc_bias_level level) |
| 677 | { | 697 | { |
| 698 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | ||
| 678 | unsigned int mask = ADAV80X_DAC_CTRL1_PD; | 699 | unsigned int mask = ADAV80X_DAC_CTRL1_PD; |
| 679 | 700 | ||
| 680 | switch (level) { | 701 | switch (level) { |
| @@ -683,10 +704,12 @@ static int adav80x_set_bias_level(struct snd_soc_codec *codec, | |||
| 683 | case SND_SOC_BIAS_PREPARE: | 704 | case SND_SOC_BIAS_PREPARE: |
| 684 | break; | 705 | break; |
| 685 | case SND_SOC_BIAS_STANDBY: | 706 | case SND_SOC_BIAS_STANDBY: |
| 686 | snd_soc_update_bits(codec, ADAV80X_DAC_CTRL1, mask, 0x00); | 707 | regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL1, mask, |
| 708 | 0x00); | ||
| 687 | break; | 709 | break; |
| 688 | case SND_SOC_BIAS_OFF: | 710 | case SND_SOC_BIAS_OFF: |
| 689 | snd_soc_update_bits(codec, ADAV80X_DAC_CTRL1, mask, mask); | 711 | regmap_update_bits(adav80x->regmap, ADAV80X_DAC_CTRL1, mask, |
| 712 | mask); | ||
| 690 | break; | 713 | break; |
| 691 | } | 714 | } |
| 692 | 715 | ||
| @@ -780,7 +803,7 @@ static int adav80x_probe(struct snd_soc_codec *codec) | |||
| 780 | int ret; | 803 | int ret; |
| 781 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | 804 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); |
| 782 | 805 | ||
| 783 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, adav80x->control_type); | 806 | ret = snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); |
| 784 | if (ret) { | 807 | if (ret) { |
| 785 | dev_err(codec->dev, "failed to set cache I/O: %d\n", ret); | 808 | dev_err(codec->dev, "failed to set cache I/O: %d\n", ret); |
| 786 | return ret; | 809 | return ret; |
| @@ -791,23 +814,31 @@ static int adav80x_probe(struct snd_soc_codec *codec) | |||
| 791 | snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL2"); | 814 | snd_soc_dapm_force_enable_pin(&codec->dapm, "PLL2"); |
| 792 | 815 | ||
| 793 | /* Power down S/PDIF receiver, since it is currently not supported */ | 816 | /* Power down S/PDIF receiver, since it is currently not supported */ |
| 794 | snd_soc_write(codec, ADAV80X_PLL_OUTE, 0x20); | 817 | regmap_write(adav80x->regmap, ADAV80X_PLL_OUTE, 0x20); |
| 795 | /* Disable DAC zero flag */ | 818 | /* Disable DAC zero flag */ |
| 796 | snd_soc_write(codec, ADAV80X_DAC_CTRL3, 0x6); | 819 | regmap_write(adav80x->regmap, ADAV80X_DAC_CTRL3, 0x6); |
| 797 | 820 | ||
| 798 | return adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 821 | return adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 799 | } | 822 | } |
| 800 | 823 | ||
| 801 | static int adav80x_suspend(struct snd_soc_codec *codec) | 824 | static int adav80x_suspend(struct snd_soc_codec *codec) |
| 802 | { | 825 | { |
| 803 | return adav80x_set_bias_level(codec, SND_SOC_BIAS_OFF); | 826 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); |
| 827 | int ret; | ||
| 828 | |||
| 829 | ret = adav80x_set_bias_level(codec, SND_SOC_BIAS_OFF); | ||
| 830 | regcache_cache_only(adav80x->regmap, true); | ||
| 831 | |||
| 832 | return ret; | ||
| 804 | } | 833 | } |
| 805 | 834 | ||
| 806 | static int adav80x_resume(struct snd_soc_codec *codec) | 835 | static int adav80x_resume(struct snd_soc_codec *codec) |
| 807 | { | 836 | { |
| 837 | struct adav80x *adav80x = snd_soc_codec_get_drvdata(codec); | ||
| 838 | |||
| 839 | regcache_cache_only(adav80x->regmap, false); | ||
| 808 | adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 840 | adav80x_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 809 | codec->cache_sync = 1; | 841 | regcache_sync(adav80x->regmap); |
| 810 | snd_soc_cache_sync(codec); | ||
| 811 | 842 | ||
| 812 | return 0; | 843 | return 0; |
| 813 | } | 844 | } |
| @@ -827,10 +858,6 @@ static struct snd_soc_codec_driver adav80x_codec_driver = { | |||
| 827 | .set_pll = adav80x_set_pll, | 858 | .set_pll = adav80x_set_pll, |
| 828 | .set_sysclk = adav80x_set_sysclk, | 859 | .set_sysclk = adav80x_set_sysclk, |
| 829 | 860 | ||
| 830 | .reg_word_size = sizeof(u8), | ||
| 831 | .reg_cache_size = ARRAY_SIZE(adav80x_default_regs), | ||
| 832 | .reg_cache_default = adav80x_default_regs, | ||
| 833 | |||
| 834 | .controls = adav80x_controls, | 861 | .controls = adav80x_controls, |
| 835 | .num_controls = ARRAY_SIZE(adav80x_controls), | 862 | .num_controls = ARRAY_SIZE(adav80x_controls), |
| 836 | .dapm_widgets = adav80x_dapm_widgets, | 863 | .dapm_widgets = adav80x_dapm_widgets, |
| @@ -839,18 +866,21 @@ static struct snd_soc_codec_driver adav80x_codec_driver = { | |||
| 839 | .num_dapm_routes = ARRAY_SIZE(adav80x_dapm_routes), | 866 | .num_dapm_routes = ARRAY_SIZE(adav80x_dapm_routes), |
| 840 | }; | 867 | }; |
| 841 | 868 | ||
| 842 | static int adav80x_bus_probe(struct device *dev, | 869 | static int adav80x_bus_probe(struct device *dev, struct regmap *regmap) |
| 843 | enum snd_soc_control_type control_type) | ||
| 844 | { | 870 | { |
| 845 | struct adav80x *adav80x; | 871 | struct adav80x *adav80x; |
| 846 | int ret; | 872 | int ret; |
| 847 | 873 | ||
| 874 | if (IS_ERR(regmap)) | ||
| 875 | return PTR_ERR(regmap); | ||
| 876 | |||
| 848 | adav80x = kzalloc(sizeof(*adav80x), GFP_KERNEL); | 877 | adav80x = kzalloc(sizeof(*adav80x), GFP_KERNEL); |
| 849 | if (!adav80x) | 878 | if (!adav80x) |
| 850 | return -ENOMEM; | 879 | return -ENOMEM; |
| 851 | 880 | ||
| 881 | |||
| 852 | dev_set_drvdata(dev, adav80x); | 882 | dev_set_drvdata(dev, adav80x); |
| 853 | adav80x->control_type = control_type; | 883 | adav80x->regmap = regmap; |
| 854 | 884 | ||
| 855 | ret = snd_soc_register_codec(dev, &adav80x_codec_driver, | 885 | ret = snd_soc_register_codec(dev, &adav80x_codec_driver, |
| 856 | adav80x_dais, ARRAY_SIZE(adav80x_dais)); | 886 | adav80x_dais, ARRAY_SIZE(adav80x_dais)); |
| @@ -868,6 +898,19 @@ static int adav80x_bus_remove(struct device *dev) | |||
| 868 | } | 898 | } |
| 869 | 899 | ||
| 870 | #if defined(CONFIG_SPI_MASTER) | 900 | #if defined(CONFIG_SPI_MASTER) |
| 901 | static const struct regmap_config adav80x_spi_regmap_config = { | ||
| 902 | .val_bits = 8, | ||
| 903 | .pad_bits = 1, | ||
| 904 | .reg_bits = 7, | ||
| 905 | .read_flag_mask = 0x01, | ||
| 906 | |||
| 907 | .max_register = ADAV80X_PLL_OUTE, | ||
| 908 | |||
| 909 | .cache_type = REGCACHE_RBTREE, | ||
| 910 | .reg_defaults = adav80x_reg_defaults, | ||
| 911 | .num_reg_defaults = ARRAY_SIZE(adav80x_reg_defaults), | ||
| 912 | }; | ||
| 913 | |||
| 871 | static const struct spi_device_id adav80x_spi_id[] = { | 914 | static const struct spi_device_id adav80x_spi_id[] = { |
| 872 | { "adav801", 0 }, | 915 | { "adav801", 0 }, |
| 873 | { } | 916 | { } |
| @@ -876,7 +919,8 @@ MODULE_DEVICE_TABLE(spi, adav80x_spi_id); | |||
| 876 | 919 | ||
| 877 | static int adav80x_spi_probe(struct spi_device *spi) | 920 | static int adav80x_spi_probe(struct spi_device *spi) |
| 878 | { | 921 | { |
| 879 | return adav80x_bus_probe(&spi->dev, SND_SOC_SPI); | 922 | return adav80x_bus_probe(&spi->dev, |
| 923 | devm_regmap_init_spi(spi, &adav80x_spi_regmap_config)); | ||
| 880 | } | 924 | } |
| 881 | 925 | ||
| 882 | static int adav80x_spi_remove(struct spi_device *spi) | 926 | static int adav80x_spi_remove(struct spi_device *spi) |
| @@ -896,6 +940,18 @@ static struct spi_driver adav80x_spi_driver = { | |||
| 896 | #endif | 940 | #endif |
| 897 | 941 | ||
| 898 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | 942 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) |
| 943 | static const struct regmap_config adav80x_i2c_regmap_config = { | ||
| 944 | .val_bits = 8, | ||
| 945 | .pad_bits = 1, | ||
| 946 | .reg_bits = 7, | ||
| 947 | |||
| 948 | .max_register = ADAV80X_PLL_OUTE, | ||
| 949 | |||
| 950 | .cache_type = REGCACHE_RBTREE, | ||
| 951 | .reg_defaults = adav80x_reg_defaults, | ||
| 952 | .num_reg_defaults = ARRAY_SIZE(adav80x_reg_defaults), | ||
| 953 | }; | ||
| 954 | |||
| 899 | static const struct i2c_device_id adav80x_i2c_id[] = { | 955 | static const struct i2c_device_id adav80x_i2c_id[] = { |
| 900 | { "adav803", 0 }, | 956 | { "adav803", 0 }, |
| 901 | { } | 957 | { } |
| @@ -905,7 +961,8 @@ MODULE_DEVICE_TABLE(i2c, adav80x_i2c_id); | |||
| 905 | static int adav80x_i2c_probe(struct i2c_client *client, | 961 | static int adav80x_i2c_probe(struct i2c_client *client, |
| 906 | const struct i2c_device_id *id) | 962 | const struct i2c_device_id *id) |
| 907 | { | 963 | { |
| 908 | return adav80x_bus_probe(&client->dev, SND_SOC_I2C); | 964 | return adav80x_bus_probe(&client->dev, |
| 965 | devm_regmap_init_i2c(client, &adav80x_i2c_regmap_config)); | ||
| 909 | } | 966 | } |
| 910 | 967 | ||
| 911 | static int adav80x_i2c_remove(struct i2c_client *client) | 968 | static int adav80x_i2c_remove(struct i2c_client *client) |
diff --git a/sound/soc/codecs/ak4104.c b/sound/soc/codecs/ak4104.c index 71059c07ae7b..b4819dcd4f4d 100644 --- a/sound/soc/codecs/ak4104.c +++ b/sound/soc/codecs/ak4104.c | |||
| @@ -45,8 +45,6 @@ | |||
| 45 | #define AK4104_TX_TXE (1 << 0) | 45 | #define AK4104_TX_TXE (1 << 0) |
| 46 | #define AK4104_TX_V (1 << 1) | 46 | #define AK4104_TX_V (1 << 1) |
| 47 | 47 | ||
| 48 | #define DRV_NAME "ak4104-codec" | ||
| 49 | |||
| 50 | struct ak4104_private { | 48 | struct ak4104_private { |
| 51 | struct regmap *regmap; | 49 | struct regmap *regmap; |
| 52 | }; | 50 | }; |
| @@ -291,12 +289,19 @@ static const struct of_device_id ak4104_of_match[] = { | |||
| 291 | }; | 289 | }; |
| 292 | MODULE_DEVICE_TABLE(of, ak4104_of_match); | 290 | MODULE_DEVICE_TABLE(of, ak4104_of_match); |
| 293 | 291 | ||
| 292 | static const struct spi_device_id ak4104_id_table[] = { | ||
| 293 | { "ak4104", 0 }, | ||
| 294 | { } | ||
| 295 | }; | ||
| 296 | MODULE_DEVICE_TABLE(spi, ak4104_id_table); | ||
| 297 | |||
| 294 | static struct spi_driver ak4104_spi_driver = { | 298 | static struct spi_driver ak4104_spi_driver = { |
| 295 | .driver = { | 299 | .driver = { |
| 296 | .name = DRV_NAME, | 300 | .name = "ak4104", |
| 297 | .owner = THIS_MODULE, | 301 | .owner = THIS_MODULE, |
| 298 | .of_match_table = ak4104_of_match, | 302 | .of_match_table = ak4104_of_match, |
| 299 | }, | 303 | }, |
| 304 | .id_table = ak4104_id_table, | ||
| 300 | .probe = ak4104_spi_probe, | 305 | .probe = ak4104_spi_probe, |
| 301 | .remove = ak4104_spi_remove, | 306 | .remove = ak4104_spi_remove, |
| 302 | }; | 307 | }; |
diff --git a/sound/soc/codecs/ak4642.c b/sound/soc/codecs/ak4642.c index 2d0378709702..21c35ed778cc 100644 --- a/sound/soc/codecs/ak4642.c +++ b/sound/soc/codecs/ak4642.c | |||
| @@ -352,7 +352,6 @@ static int ak4642_dai_set_fmt(struct snd_soc_dai *dai, unsigned int fmt) | |||
| 352 | */ | 352 | */ |
| 353 | default: | 353 | default: |
| 354 | return -EINVAL; | 354 | return -EINVAL; |
| 355 | break; | ||
| 356 | } | 355 | } |
| 357 | snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); | 356 | snd_soc_update_bits(codec, MD_CTL1, DIF_MASK, data); |
| 358 | 357 | ||
| @@ -405,7 +404,6 @@ static int ak4642_dai_hw_params(struct snd_pcm_substream *substream, | |||
| 405 | break; | 404 | break; |
| 406 | default: | 405 | default: |
| 407 | return -EINVAL; | 406 | return -EINVAL; |
| 408 | break; | ||
| 409 | } | 407 | } |
| 410 | snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate); | 408 | snd_soc_update_bits(codec, MD_CTL2, FS_MASK, rate); |
| 411 | 409 | ||
diff --git a/sound/soc/codecs/arizona.c b/sound/soc/codecs/arizona.c index 657808ba1418..6f05b17d1965 100644 --- a/sound/soc/codecs/arizona.c +++ b/sound/soc/codecs/arizona.c | |||
| @@ -1477,21 +1477,25 @@ static void arizona_enable_fll(struct arizona_fll *fll, | |||
| 1477 | { | 1477 | { |
| 1478 | struct arizona *arizona = fll->arizona; | 1478 | struct arizona *arizona = fll->arizona; |
| 1479 | int ret; | 1479 | int ret; |
| 1480 | bool use_sync = false; | ||
| 1480 | 1481 | ||
| 1481 | /* | 1482 | /* |
| 1482 | * If we have both REFCLK and SYNCCLK then enable both, | 1483 | * If we have both REFCLK and SYNCCLK then enable both, |
| 1483 | * otherwise apply the SYNCCLK settings to REFCLK. | 1484 | * otherwise apply the SYNCCLK settings to REFCLK. |
| 1484 | */ | 1485 | */ |
| 1485 | if (fll->ref_src >= 0 && fll->ref_src != fll->sync_src) { | 1486 | if (fll->ref_src >= 0 && fll->ref_freq && |
| 1487 | fll->ref_src != fll->sync_src) { | ||
| 1486 | regmap_update_bits(arizona->regmap, fll->base + 5, | 1488 | regmap_update_bits(arizona->regmap, fll->base + 5, |
| 1487 | ARIZONA_FLL1_OUTDIV_MASK, | 1489 | ARIZONA_FLL1_OUTDIV_MASK, |
| 1488 | ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); | 1490 | ref->outdiv << ARIZONA_FLL1_OUTDIV_SHIFT); |
| 1489 | 1491 | ||
| 1490 | arizona_apply_fll(arizona, fll->base, ref, fll->ref_src, | 1492 | arizona_apply_fll(arizona, fll->base, ref, fll->ref_src, |
| 1491 | false); | 1493 | false); |
| 1492 | if (fll->sync_src >= 0) | 1494 | if (fll->sync_src >= 0) { |
| 1493 | arizona_apply_fll(arizona, fll->base + 0x10, sync, | 1495 | arizona_apply_fll(arizona, fll->base + 0x10, sync, |
| 1494 | fll->sync_src, true); | 1496 | fll->sync_src, true); |
| 1497 | use_sync = true; | ||
| 1498 | } | ||
| 1495 | } else if (fll->sync_src >= 0) { | 1499 | } else if (fll->sync_src >= 0) { |
| 1496 | regmap_update_bits(arizona->regmap, fll->base + 5, | 1500 | regmap_update_bits(arizona->regmap, fll->base + 5, |
| 1497 | ARIZONA_FLL1_OUTDIV_MASK, | 1501 | ARIZONA_FLL1_OUTDIV_MASK, |
| @@ -1511,7 +1515,7 @@ static void arizona_enable_fll(struct arizona_fll *fll, | |||
| 1511 | * Increase the bandwidth if we're not using a low frequency | 1515 | * Increase the bandwidth if we're not using a low frequency |
| 1512 | * sync source. | 1516 | * sync source. |
| 1513 | */ | 1517 | */ |
| 1514 | if (fll->sync_src >= 0 && fll->sync_freq > 100000) | 1518 | if (use_sync && fll->sync_freq > 100000) |
| 1515 | regmap_update_bits(arizona->regmap, fll->base + 0x17, | 1519 | regmap_update_bits(arizona->regmap, fll->base + 0x17, |
| 1516 | ARIZONA_FLL1_SYNC_BW, 0); | 1520 | ARIZONA_FLL1_SYNC_BW, 0); |
| 1517 | else | 1521 | else |
| @@ -1526,8 +1530,7 @@ static void arizona_enable_fll(struct arizona_fll *fll, | |||
| 1526 | 1530 | ||
| 1527 | regmap_update_bits(arizona->regmap, fll->base + 1, | 1531 | regmap_update_bits(arizona->regmap, fll->base + 1, |
| 1528 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); | 1532 | ARIZONA_FLL1_ENA, ARIZONA_FLL1_ENA); |
| 1529 | if (fll->ref_src >= 0 && fll->sync_src >= 0 && | 1533 | if (use_sync) |
| 1530 | fll->ref_src != fll->sync_src) | ||
| 1531 | regmap_update_bits(arizona->regmap, fll->base + 0x11, | 1534 | regmap_update_bits(arizona->regmap, fll->base + 0x11, |
| 1532 | ARIZONA_FLL1_SYNC_ENA, | 1535 | ARIZONA_FLL1_SYNC_ENA, |
| 1533 | ARIZONA_FLL1_SYNC_ENA); | 1536 | ARIZONA_FLL1_SYNC_ENA); |
| @@ -1561,10 +1564,12 @@ int arizona_set_fll_refclk(struct arizona_fll *fll, int source, | |||
| 1561 | if (fll->ref_src == source && fll->ref_freq == Fref) | 1564 | if (fll->ref_src == source && fll->ref_freq == Fref) |
| 1562 | return 0; | 1565 | return 0; |
| 1563 | 1566 | ||
| 1564 | if (fll->fout && Fref > 0) { | 1567 | if (fll->fout) { |
| 1565 | ret = arizona_calc_fll(fll, &ref, Fref, fll->fout); | 1568 | if (Fref > 0) { |
| 1566 | if (ret != 0) | 1569 | ret = arizona_calc_fll(fll, &ref, Fref, fll->fout); |
| 1567 | return ret; | 1570 | if (ret != 0) |
| 1571 | return ret; | ||
| 1572 | } | ||
| 1568 | 1573 | ||
| 1569 | if (fll->sync_src >= 0) { | 1574 | if (fll->sync_src >= 0) { |
| 1570 | ret = arizona_calc_fll(fll, &sync, fll->sync_freq, | 1575 | ret = arizona_calc_fll(fll, &sync, fll->sync_freq, |
diff --git a/sound/soc/codecs/cq93vc.c b/sound/soc/codecs/cq93vc.c index 23316c887b19..43737a27d79c 100644 --- a/sound/soc/codecs/cq93vc.c +++ b/sound/soc/codecs/cq93vc.c | |||
| @@ -38,24 +38,6 @@ | |||
| 38 | #include <sound/soc.h> | 38 | #include <sound/soc.h> |
| 39 | #include <sound/initval.h> | 39 | #include <sound/initval.h> |
| 40 | 40 | ||
| 41 | static inline unsigned int cq93vc_read(struct snd_soc_codec *codec, | ||
| 42 | unsigned int reg) | ||
| 43 | { | ||
| 44 | struct davinci_vc *davinci_vc = codec->control_data; | ||
| 45 | |||
| 46 | return readl(davinci_vc->base + reg); | ||
| 47 | } | ||
| 48 | |||
| 49 | static inline int cq93vc_write(struct snd_soc_codec *codec, unsigned int reg, | ||
| 50 | unsigned int value) | ||
| 51 | { | ||
| 52 | struct davinci_vc *davinci_vc = codec->control_data; | ||
| 53 | |||
| 54 | writel(value, davinci_vc->base + reg); | ||
| 55 | |||
| 56 | return 0; | ||
| 57 | } | ||
| 58 | |||
| 59 | static const struct snd_kcontrol_new cq93vc_snd_controls[] = { | 41 | static const struct snd_kcontrol_new cq93vc_snd_controls[] = { |
| 60 | SOC_SINGLE("PGA Capture Volume", DAVINCI_VC_REG05, 0, 0x03, 0), | 42 | SOC_SINGLE("PGA Capture Volume", DAVINCI_VC_REG05, 0, 0x03, 0), |
| 61 | SOC_SINGLE("Mono DAC Playback Volume", DAVINCI_VC_REG09, 0, 0x3f, 0), | 43 | SOC_SINGLE("Mono DAC Playback Volume", DAVINCI_VC_REG09, 0, 0x3f, 0), |
| @@ -64,13 +46,15 @@ static const struct snd_kcontrol_new cq93vc_snd_controls[] = { | |||
| 64 | static int cq93vc_mute(struct snd_soc_dai *dai, int mute) | 46 | static int cq93vc_mute(struct snd_soc_dai *dai, int mute) |
| 65 | { | 47 | { |
| 66 | struct snd_soc_codec *codec = dai->codec; | 48 | struct snd_soc_codec *codec = dai->codec; |
| 67 | u8 reg = cq93vc_read(codec, DAVINCI_VC_REG09) & ~DAVINCI_VC_REG09_MUTE; | 49 | u8 reg; |
| 68 | 50 | ||
| 69 | if (mute) | 51 | if (mute) |
| 70 | cq93vc_write(codec, DAVINCI_VC_REG09, | 52 | reg = DAVINCI_VC_REG09_MUTE; |
| 71 | reg | DAVINCI_VC_REG09_MUTE); | ||
| 72 | else | 53 | else |
| 73 | cq93vc_write(codec, DAVINCI_VC_REG09, reg); | 54 | reg = 0; |
| 55 | |||
| 56 | snd_soc_update_bits(codec, DAVINCI_VC_REG09, DAVINCI_VC_REG09_MUTE, | ||
| 57 | reg); | ||
| 74 | 58 | ||
| 75 | return 0; | 59 | return 0; |
| 76 | } | 60 | } |
| @@ -79,7 +63,7 @@ static int cq93vc_set_dai_sysclk(struct snd_soc_dai *codec_dai, | |||
| 79 | int clk_id, unsigned int freq, int dir) | 63 | int clk_id, unsigned int freq, int dir) |
| 80 | { | 64 | { |
| 81 | struct snd_soc_codec *codec = codec_dai->codec; | 65 | struct snd_soc_codec *codec = codec_dai->codec; |
| 82 | struct davinci_vc *davinci_vc = codec->control_data; | 66 | struct davinci_vc *davinci_vc = codec->dev->platform_data; |
| 83 | 67 | ||
| 84 | switch (freq) { | 68 | switch (freq) { |
| 85 | case 22579200: | 69 | case 22579200: |
| @@ -97,18 +81,18 @@ static int cq93vc_set_bias_level(struct snd_soc_codec *codec, | |||
| 97 | { | 81 | { |
| 98 | switch (level) { | 82 | switch (level) { |
| 99 | case SND_SOC_BIAS_ON: | 83 | case SND_SOC_BIAS_ON: |
| 100 | cq93vc_write(codec, DAVINCI_VC_REG12, | 84 | snd_soc_write(codec, DAVINCI_VC_REG12, |
| 101 | DAVINCI_VC_REG12_POWER_ALL_ON); | 85 | DAVINCI_VC_REG12_POWER_ALL_ON); |
| 102 | break; | 86 | break; |
| 103 | case SND_SOC_BIAS_PREPARE: | 87 | case SND_SOC_BIAS_PREPARE: |
| 104 | break; | 88 | break; |
| 105 | case SND_SOC_BIAS_STANDBY: | 89 | case SND_SOC_BIAS_STANDBY: |
| 106 | cq93vc_write(codec, DAVINCI_VC_REG12, | 90 | snd_soc_write(codec, DAVINCI_VC_REG12, |
| 107 | DAVINCI_VC_REG12_POWER_ALL_OFF); | 91 | DAVINCI_VC_REG12_POWER_ALL_OFF); |
| 108 | break; | 92 | break; |
| 109 | case SND_SOC_BIAS_OFF: | 93 | case SND_SOC_BIAS_OFF: |
| 110 | /* force all power off */ | 94 | /* force all power off */ |
| 111 | cq93vc_write(codec, DAVINCI_VC_REG12, | 95 | snd_soc_write(codec, DAVINCI_VC_REG12, |
| 112 | DAVINCI_VC_REG12_POWER_ALL_OFF); | 96 | DAVINCI_VC_REG12_POWER_ALL_OFF); |
| 113 | break; | 97 | break; |
| 114 | } | 98 | } |
| @@ -154,11 +138,9 @@ static int cq93vc_probe(struct snd_soc_codec *codec) | |||
| 154 | struct davinci_vc *davinci_vc = codec->dev->platform_data; | 138 | struct davinci_vc *davinci_vc = codec->dev->platform_data; |
| 155 | 139 | ||
| 156 | davinci_vc->cq93vc.codec = codec; | 140 | davinci_vc->cq93vc.codec = codec; |
| 157 | codec->control_data = davinci_vc; | 141 | codec->control_data = davinci_vc->regmap; |
| 158 | 142 | ||
| 159 | /* Set controls */ | 143 | snd_soc_codec_set_cache_io(codec, 32, 32, SND_SOC_REGMAP); |
| 160 | snd_soc_add_codec_controls(codec, cq93vc_snd_controls, | ||
| 161 | ARRAY_SIZE(cq93vc_snd_controls)); | ||
| 162 | 144 | ||
| 163 | /* Off, with power on */ | 145 | /* Off, with power on */ |
| 164 | cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 146 | cq93vc_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| @@ -174,12 +156,12 @@ static int cq93vc_remove(struct snd_soc_codec *codec) | |||
| 174 | } | 156 | } |
| 175 | 157 | ||
| 176 | static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { | 158 | static struct snd_soc_codec_driver soc_codec_dev_cq93vc = { |
| 177 | .read = cq93vc_read, | ||
| 178 | .write = cq93vc_write, | ||
| 179 | .set_bias_level = cq93vc_set_bias_level, | 159 | .set_bias_level = cq93vc_set_bias_level, |
| 180 | .probe = cq93vc_probe, | 160 | .probe = cq93vc_probe, |
| 181 | .remove = cq93vc_remove, | 161 | .remove = cq93vc_remove, |
| 182 | .resume = cq93vc_resume, | 162 | .resume = cq93vc_resume, |
| 163 | .controls = cq93vc_snd_controls, | ||
| 164 | .num_controls = ARRAY_SIZE(cq93vc_snd_controls), | ||
| 183 | }; | 165 | }; |
| 184 | 166 | ||
| 185 | static int cq93vc_platform_probe(struct platform_device *pdev) | 167 | static int cq93vc_platform_probe(struct platform_device *pdev) |
diff --git a/sound/soc/codecs/cs4271.c b/sound/soc/codecs/cs4271.c index a20f1bb8f071..f6e953454bc0 100644 --- a/sound/soc/codecs/cs4271.c +++ b/sound/soc/codecs/cs4271.c | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include <linux/gpio.h> | 25 | #include <linux/gpio.h> |
| 26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
| 27 | #include <linux/spi/spi.h> | 27 | #include <linux/spi/spi.h> |
| 28 | #include <linux/of.h> | ||
| 28 | #include <linux/of_device.h> | 29 | #include <linux/of_device.h> |
| 29 | #include <linux/of_gpio.h> | 30 | #include <linux/of_gpio.h> |
| 30 | #include <sound/pcm.h> | 31 | #include <sound/pcm.h> |
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c index 3b20c86cdb01..549d5d6a3fef 100644 --- a/sound/soc/codecs/cs42l73.c +++ b/sound/soc/codecs/cs42l73.c | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include <linux/kernel.h> | 17 | #include <linux/kernel.h> |
| 18 | #include <linux/init.h> | 18 | #include <linux/init.h> |
| 19 | #include <linux/delay.h> | 19 | #include <linux/delay.h> |
| 20 | #include <linux/of_gpio.h> | ||
| 20 | #include <linux/pm.h> | 21 | #include <linux/pm.h> |
| 21 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
| 22 | #include <linux/regmap.h> | 23 | #include <linux/regmap.h> |
| @@ -28,6 +29,7 @@ | |||
| 28 | #include <sound/soc-dapm.h> | 29 | #include <sound/soc-dapm.h> |
| 29 | #include <sound/initval.h> | 30 | #include <sound/initval.h> |
| 30 | #include <sound/tlv.h> | 31 | #include <sound/tlv.h> |
| 32 | #include <sound/cs42l73.h> | ||
| 31 | #include "cs42l73.h" | 33 | #include "cs42l73.h" |
| 32 | 34 | ||
| 33 | struct sp_config { | 35 | struct sp_config { |
| @@ -35,6 +37,7 @@ struct sp_config { | |||
| 35 | u32 srate; | 37 | u32 srate; |
| 36 | }; | 38 | }; |
| 37 | struct cs42l73_private { | 39 | struct cs42l73_private { |
| 40 | struct cs42l73_platform_data pdata; | ||
| 38 | struct sp_config config[3]; | 41 | struct sp_config config[3]; |
| 39 | struct regmap *regmap; | 42 | struct regmap *regmap; |
| 40 | u32 sysclk; | 43 | u32 sysclk; |
| @@ -310,15 +313,6 @@ static const struct soc_enum ng_delay_enum = | |||
| 310 | SOC_ENUM_SINGLE(CS42L73_NGCAB, 0, | 313 | SOC_ENUM_SINGLE(CS42L73_NGCAB, 0, |
| 311 | ARRAY_SIZE(cs42l73_ng_delay_text), cs42l73_ng_delay_text); | 314 | ARRAY_SIZE(cs42l73_ng_delay_text), cs42l73_ng_delay_text); |
| 312 | 315 | ||
| 313 | static const char * const charge_pump_freq_text[] = { | ||
| 314 | "0", "1", "2", "3", "4", | ||
| 315 | "5", "6", "7", "8", "9", | ||
| 316 | "10", "11", "12", "13", "14", "15" }; | ||
| 317 | |||
| 318 | static const struct soc_enum charge_pump_enum = | ||
| 319 | SOC_ENUM_SINGLE(CS42L73_CPFCHC, 4, | ||
| 320 | ARRAY_SIZE(charge_pump_freq_text), charge_pump_freq_text); | ||
| 321 | |||
| 322 | static const char * const cs42l73_mono_mix_texts[] = { | 316 | static const char * const cs42l73_mono_mix_texts[] = { |
| 323 | "Left", "Right", "Mono Mix"}; | 317 | "Left", "Right", "Mono Mix"}; |
| 324 | 318 | ||
| @@ -511,8 +505,6 @@ static const struct snd_kcontrol_new cs42l73_snd_controls[] = { | |||
| 511 | SOC_SINGLE("NG Threshold", CS42L73_NGCAB, 2, 7, 0), | 505 | SOC_SINGLE("NG Threshold", CS42L73_NGCAB, 2, 7, 0), |
| 512 | SOC_ENUM("NG Delay", ng_delay_enum), | 506 | SOC_ENUM("NG Delay", ng_delay_enum), |
| 513 | 507 | ||
| 514 | SOC_ENUM("Charge Pump Frequency", charge_pump_enum), | ||
| 515 | |||
| 516 | SOC_DOUBLE_R_TLV("XSP-IP Volume", | 508 | SOC_DOUBLE_R_TLV("XSP-IP Volume", |
| 517 | CS42L73_XSPAIPAA, CS42L73_XSPBIPBA, 0, 0x3F, 1, | 509 | CS42L73_XSPAIPAA, CS42L73_XSPBIPBA, 0, 0x3F, 1, |
| 518 | attn_tlv), | 510 | attn_tlv), |
| @@ -1055,11 +1047,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 1055 | 1047 | ||
| 1056 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { | 1048 | switch (fmt & SND_SOC_DAIFMT_MASTER_MASK) { |
| 1057 | case SND_SOC_DAIFMT_CBM_CFM: | 1049 | case SND_SOC_DAIFMT_CBM_CFM: |
| 1058 | mmcc |= MS_MASTER; | 1050 | mmcc |= CS42L73_MS_MASTER; |
| 1059 | break; | 1051 | break; |
| 1060 | 1052 | ||
| 1061 | case SND_SOC_DAIFMT_CBS_CFS: | 1053 | case SND_SOC_DAIFMT_CBS_CFS: |
| 1062 | mmcc &= ~MS_MASTER; | 1054 | mmcc &= ~CS42L73_MS_MASTER; |
| 1063 | break; | 1055 | break; |
| 1064 | 1056 | ||
| 1065 | default: | 1057 | default: |
| @@ -1071,11 +1063,11 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 1071 | 1063 | ||
| 1072 | switch (format) { | 1064 | switch (format) { |
| 1073 | case SND_SOC_DAIFMT_I2S: | 1065 | case SND_SOC_DAIFMT_I2S: |
| 1074 | spc &= ~SPDIF_PCM; | 1066 | spc &= ~CS42L73_SPDIF_PCM; |
| 1075 | break; | 1067 | break; |
| 1076 | case SND_SOC_DAIFMT_DSP_A: | 1068 | case SND_SOC_DAIFMT_DSP_A: |
| 1077 | case SND_SOC_DAIFMT_DSP_B: | 1069 | case SND_SOC_DAIFMT_DSP_B: |
| 1078 | if (mmcc & MS_MASTER) { | 1070 | if (mmcc & CS42L73_MS_MASTER) { |
| 1079 | dev_err(codec->dev, | 1071 | dev_err(codec->dev, |
| 1080 | "PCM format in slave mode only\n"); | 1072 | "PCM format in slave mode only\n"); |
| 1081 | return -EINVAL; | 1073 | return -EINVAL; |
| @@ -1085,25 +1077,25 @@ static int cs42l73_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 1085 | "PCM format is not supported on ASP port\n"); | 1077 | "PCM format is not supported on ASP port\n"); |
| 1086 | return -EINVAL; | 1078 | return -EINVAL; |
| 1087 | } | 1079 | } |
| 1088 | spc |= SPDIF_PCM; | 1080 | spc |= CS42L73_SPDIF_PCM; |
| 1089 | break; | 1081 | break; |
| 1090 | default: | 1082 | default: |
| 1091 | return -EINVAL; | 1083 | return -EINVAL; |
| 1092 | } | 1084 | } |
| 1093 | 1085 | ||
| 1094 | if (spc & SPDIF_PCM) { | 1086 | if (spc & CS42L73_SPDIF_PCM) { |
| 1095 | /* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */ | 1087 | /* Clear PCM mode, clear PCM_BIT_ORDER bit for MSB->LSB */ |
| 1096 | spc &= ~(PCM_MODE_MASK | PCM_BIT_ORDER); | 1088 | spc &= ~(CS42L73_PCM_MODE_MASK | CS42L73_PCM_BIT_ORDER); |
| 1097 | switch (format) { | 1089 | switch (format) { |
| 1098 | case SND_SOC_DAIFMT_DSP_B: | 1090 | case SND_SOC_DAIFMT_DSP_B: |
| 1099 | if (inv == SND_SOC_DAIFMT_IB_IF) | 1091 | if (inv == SND_SOC_DAIFMT_IB_IF) |
| 1100 | spc |= PCM_MODE0; | 1092 | spc |= CS42L73_PCM_MODE0; |
| 1101 | if (inv == SND_SOC_DAIFMT_IB_NF) | 1093 | if (inv == SND_SOC_DAIFMT_IB_NF) |
| 1102 | spc |= PCM_MODE1; | 1094 | spc |= CS42L73_PCM_MODE1; |
| 1103 | break; | 1095 | break; |
| 1104 | case SND_SOC_DAIFMT_DSP_A: | 1096 | case SND_SOC_DAIFMT_DSP_A: |
| 1105 | if (inv == SND_SOC_DAIFMT_IB_IF) | 1097 | if (inv == SND_SOC_DAIFMT_IB_IF) |
| 1106 | spc |= PCM_MODE1; | 1098 | spc |= CS42L73_PCM_MODE1; |
| 1107 | break; | 1099 | break; |
| 1108 | default: | 1100 | default: |
| 1109 | return -EINVAL; | 1101 | return -EINVAL; |
| @@ -1163,7 +1155,7 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 1163 | int mclk_coeff; | 1155 | int mclk_coeff; |
| 1164 | int srate = params_rate(params); | 1156 | int srate = params_rate(params); |
| 1165 | 1157 | ||
| 1166 | if (priv->config[id].mmcc & MS_MASTER) { | 1158 | if (priv->config[id].mmcc & CS42L73_MS_MASTER) { |
| 1167 | /* CS42L73 Master */ | 1159 | /* CS42L73 Master */ |
| 1168 | /* MCLK -> srate */ | 1160 | /* MCLK -> srate */ |
| 1169 | mclk_coeff = | 1161 | mclk_coeff = |
| @@ -1182,13 +1174,13 @@ static int cs42l73_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 1182 | priv->config[id].spc &= 0xFC; | 1174 | priv->config[id].spc &= 0xFC; |
| 1183 | /* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */ | 1175 | /* Use SCLK=64*Fs if internal MCLK >= 6.4MHz */ |
| 1184 | if (priv->mclk >= 6400000) | 1176 | if (priv->mclk >= 6400000) |
| 1185 | priv->config[id].spc |= MCK_SCLK_64FS; | 1177 | priv->config[id].spc |= CS42L73_MCK_SCLK_64FS; |
| 1186 | else | 1178 | else |
| 1187 | priv->config[id].spc |= MCK_SCLK_MCLK; | 1179 | priv->config[id].spc |= CS42L73_MCK_SCLK_MCLK; |
| 1188 | } else { | 1180 | } else { |
| 1189 | /* CS42L73 Slave */ | 1181 | /* CS42L73 Slave */ |
| 1190 | priv->config[id].spc &= 0xFC; | 1182 | priv->config[id].spc &= 0xFC; |
| 1191 | priv->config[id].spc |= MCK_SCLK_64FS; | 1183 | priv->config[id].spc |= CS42L73_MCK_SCLK_64FS; |
| 1192 | } | 1184 | } |
| 1193 | /* Update ASRCs */ | 1185 | /* Update ASRCs */ |
| 1194 | priv->config[id].srate = srate; | 1186 | priv->config[id].srate = srate; |
| @@ -1208,8 +1200,8 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, | |||
| 1208 | 1200 | ||
| 1209 | switch (level) { | 1201 | switch (level) { |
| 1210 | case SND_SOC_BIAS_ON: | 1202 | case SND_SOC_BIAS_ON: |
| 1211 | snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 0); | 1203 | snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 0); |
| 1212 | snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 0); | 1204 | snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 0); |
| 1213 | break; | 1205 | break; |
| 1214 | 1206 | ||
| 1215 | case SND_SOC_BIAS_PREPARE: | 1207 | case SND_SOC_BIAS_PREPARE: |
| @@ -1220,11 +1212,11 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, | |||
| 1220 | regcache_cache_only(cs42l73->regmap, false); | 1212 | regcache_cache_only(cs42l73->regmap, false); |
| 1221 | regcache_sync(cs42l73->regmap); | 1213 | regcache_sync(cs42l73->regmap); |
| 1222 | } | 1214 | } |
| 1223 | snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1); | 1215 | snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1); |
| 1224 | break; | 1216 | break; |
| 1225 | 1217 | ||
| 1226 | case SND_SOC_BIAS_OFF: | 1218 | case SND_SOC_BIAS_OFF: |
| 1227 | snd_soc_update_bits(codec, CS42L73_PWRCTL1, PDN, 1); | 1219 | snd_soc_update_bits(codec, CS42L73_PWRCTL1, CS42L73_PDN, 1); |
| 1228 | if (cs42l73->shutdwn_delay > 0) { | 1220 | if (cs42l73->shutdwn_delay > 0) { |
| 1229 | mdelay(cs42l73->shutdwn_delay); | 1221 | mdelay(cs42l73->shutdwn_delay); |
| 1230 | cs42l73->shutdwn_delay = 0; | 1222 | cs42l73->shutdwn_delay = 0; |
| @@ -1233,7 +1225,7 @@ static int cs42l73_set_bias_level(struct snd_soc_codec *codec, | |||
| 1233 | * down. | 1225 | * down. |
| 1234 | */ | 1226 | */ |
| 1235 | } | 1227 | } |
| 1236 | snd_soc_update_bits(codec, CS42L73_DMMCC, MCLKDIS, 1); | 1228 | snd_soc_update_bits(codec, CS42L73_DMMCC, CS42L73_MCLKDIS, 1); |
| 1237 | break; | 1229 | break; |
| 1238 | } | 1230 | } |
| 1239 | codec->dapm.bias_level = level; | 1231 | codec->dapm.bias_level = level; |
| @@ -1367,11 +1359,16 @@ static int cs42l73_probe(struct snd_soc_codec *codec) | |||
| 1367 | return ret; | 1359 | return ret; |
| 1368 | } | 1360 | } |
| 1369 | 1361 | ||
| 1370 | regcache_cache_only(cs42l73->regmap, true); | ||
| 1371 | |||
| 1372 | cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1362 | cs42l73_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 1373 | 1363 | ||
| 1374 | cs42l73->mclksel = CS42L73_CLKID_MCLK1; /* MCLK1 as master clk */ | 1364 | /* Set Charge Pump Frequency */ |
| 1365 | if (cs42l73->pdata.chgfreq) | ||
| 1366 | snd_soc_update_bits(codec, CS42L73_CPFCHC, | ||
| 1367 | CS42L73_CHARGEPUMP_MASK, | ||
| 1368 | cs42l73->pdata.chgfreq << 4); | ||
| 1369 | |||
| 1370 | /* MCLK1 as master clk */ | ||
| 1371 | cs42l73->mclksel = CS42L73_CLKID_MCLK1; | ||
| 1375 | cs42l73->mclk = 0; | 1372 | cs42l73->mclk = 0; |
| 1376 | 1373 | ||
| 1377 | return ret; | 1374 | return ret; |
| @@ -1415,9 +1412,11 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, | |||
| 1415 | const struct i2c_device_id *id) | 1412 | const struct i2c_device_id *id) |
| 1416 | { | 1413 | { |
| 1417 | struct cs42l73_private *cs42l73; | 1414 | struct cs42l73_private *cs42l73; |
| 1415 | struct cs42l73_platform_data *pdata = dev_get_platdata(&i2c_client->dev); | ||
| 1418 | int ret; | 1416 | int ret; |
| 1419 | unsigned int devid = 0; | 1417 | unsigned int devid = 0; |
| 1420 | unsigned int reg; | 1418 | unsigned int reg; |
| 1419 | u32 val32; | ||
| 1421 | 1420 | ||
| 1422 | cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), | 1421 | cs42l73 = devm_kzalloc(&i2c_client->dev, sizeof(struct cs42l73_private), |
| 1423 | GFP_KERNEL); | 1422 | GFP_KERNEL); |
| @@ -1426,14 +1425,49 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, | |||
| 1426 | return -ENOMEM; | 1425 | return -ENOMEM; |
| 1427 | } | 1426 | } |
| 1428 | 1427 | ||
| 1429 | i2c_set_clientdata(i2c_client, cs42l73); | ||
| 1430 | |||
| 1431 | cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap); | 1428 | cs42l73->regmap = devm_regmap_init_i2c(i2c_client, &cs42l73_regmap); |
| 1432 | if (IS_ERR(cs42l73->regmap)) { | 1429 | if (IS_ERR(cs42l73->regmap)) { |
| 1433 | ret = PTR_ERR(cs42l73->regmap); | 1430 | ret = PTR_ERR(cs42l73->regmap); |
| 1434 | dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); | 1431 | dev_err(&i2c_client->dev, "regmap_init() failed: %d\n", ret); |
| 1435 | return ret; | 1432 | return ret; |
| 1436 | } | 1433 | } |
| 1434 | |||
| 1435 | if (pdata) { | ||
| 1436 | cs42l73->pdata = *pdata; | ||
| 1437 | } else { | ||
| 1438 | pdata = devm_kzalloc(&i2c_client->dev, | ||
| 1439 | sizeof(struct cs42l73_platform_data), | ||
| 1440 | GFP_KERNEL); | ||
| 1441 | if (!pdata) { | ||
| 1442 | dev_err(&i2c_client->dev, "could not allocate pdata\n"); | ||
| 1443 | return -ENOMEM; | ||
| 1444 | } | ||
| 1445 | if (i2c_client->dev.of_node) { | ||
| 1446 | if (of_property_read_u32(i2c_client->dev.of_node, | ||
| 1447 | "chgfreq", &val32) >= 0) | ||
| 1448 | pdata->chgfreq = val32; | ||
| 1449 | } | ||
| 1450 | pdata->reset_gpio = of_get_named_gpio(i2c_client->dev.of_node, | ||
| 1451 | "reset-gpio", 0); | ||
| 1452 | cs42l73->pdata = *pdata; | ||
| 1453 | } | ||
| 1454 | |||
| 1455 | i2c_set_clientdata(i2c_client, cs42l73); | ||
| 1456 | |||
| 1457 | if (cs42l73->pdata.reset_gpio) { | ||
| 1458 | ret = gpio_request_one(cs42l73->pdata.reset_gpio, | ||
| 1459 | GPIOF_OUT_INIT_HIGH, "CS42L73 /RST"); | ||
| 1460 | if (ret < 0) { | ||
| 1461 | dev_err(&i2c_client->dev, "Failed to request /RST %d: %d\n", | ||
| 1462 | cs42l73->pdata.reset_gpio, ret); | ||
| 1463 | return ret; | ||
| 1464 | } | ||
| 1465 | gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 0); | ||
| 1466 | gpio_set_value_cansleep(cs42l73->pdata.reset_gpio, 1); | ||
| 1467 | } | ||
| 1468 | |||
| 1469 | regcache_cache_bypass(cs42l73->regmap, true); | ||
| 1470 | |||
| 1437 | /* initialize codec */ | 1471 | /* initialize codec */ |
| 1438 | ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, ®); | 1472 | ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_AB, ®); |
| 1439 | devid = (reg & 0xFF) << 12; | 1473 | devid = (reg & 0xFF) << 12; |
| @@ -1444,7 +1478,6 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, | |||
| 1444 | ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, ®); | 1478 | ret = regmap_read(cs42l73->regmap, CS42L73_DEVID_E, ®); |
| 1445 | devid |= (reg & 0xF0) >> 4; | 1479 | devid |= (reg & 0xF0) >> 4; |
| 1446 | 1480 | ||
| 1447 | |||
| 1448 | if (devid != CS42L73_DEVID) { | 1481 | if (devid != CS42L73_DEVID) { |
| 1449 | ret = -ENODEV; | 1482 | ret = -ENODEV; |
| 1450 | dev_err(&i2c_client->dev, | 1483 | dev_err(&i2c_client->dev, |
| @@ -1462,7 +1495,7 @@ static int cs42l73_i2c_probe(struct i2c_client *i2c_client, | |||
| 1462 | dev_info(&i2c_client->dev, | 1495 | dev_info(&i2c_client->dev, |
| 1463 | "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF); | 1496 | "Cirrus Logic CS42L73, Revision: %02X\n", reg & 0xFF); |
| 1464 | 1497 | ||
| 1465 | regcache_cache_only(cs42l73->regmap, true); | 1498 | regcache_cache_bypass(cs42l73->regmap, false); |
| 1466 | 1499 | ||
| 1467 | ret = snd_soc_register_codec(&i2c_client->dev, | 1500 | ret = snd_soc_register_codec(&i2c_client->dev, |
| 1468 | &soc_codec_dev_cs42l73, cs42l73_dai, | 1501 | &soc_codec_dev_cs42l73, cs42l73_dai, |
| @@ -1478,6 +1511,12 @@ static int cs42l73_i2c_remove(struct i2c_client *client) | |||
| 1478 | return 0; | 1511 | return 0; |
| 1479 | } | 1512 | } |
| 1480 | 1513 | ||
| 1514 | static const struct of_device_id cs42l73_of_match[] = { | ||
| 1515 | { .compatible = "cirrus,cs42l73", }, | ||
| 1516 | {}, | ||
| 1517 | }; | ||
| 1518 | MODULE_DEVICE_TABLE(of, cs42l73_of_match); | ||
| 1519 | |||
| 1481 | static const struct i2c_device_id cs42l73_id[] = { | 1520 | static const struct i2c_device_id cs42l73_id[] = { |
| 1482 | {"cs42l73", 0}, | 1521 | {"cs42l73", 0}, |
| 1483 | {} | 1522 | {} |
| @@ -1489,6 +1528,7 @@ static struct i2c_driver cs42l73_i2c_driver = { | |||
| 1489 | .driver = { | 1528 | .driver = { |
| 1490 | .name = "cs42l73", | 1529 | .name = "cs42l73", |
| 1491 | .owner = THIS_MODULE, | 1530 | .owner = THIS_MODULE, |
| 1531 | .of_match_table = cs42l73_of_match, | ||
| 1492 | }, | 1532 | }, |
| 1493 | .id_table = cs42l73_id, | 1533 | .id_table = cs42l73_id, |
| 1494 | .probe = cs42l73_i2c_probe, | 1534 | .probe = cs42l73_i2c_probe, |
diff --git a/sound/soc/codecs/cs42l73.h b/sound/soc/codecs/cs42l73.h index f30a4c4d62e6..45746186a678 100644 --- a/sound/soc/codecs/cs42l73.h +++ b/sound/soc/codecs/cs42l73.h | |||
| @@ -128,59 +128,60 @@ | |||
| 128 | /* Bitfield Definitions */ | 128 | /* Bitfield Definitions */ |
| 129 | 129 | ||
| 130 | /* CS42L73_PWRCTL1 */ | 130 | /* CS42L73_PWRCTL1 */ |
| 131 | #define PDN_ADCB (1 << 7) | 131 | #define CS42L73_PDN_ADCB (1 << 7) |
| 132 | #define PDN_DMICB (1 << 6) | 132 | #define CS42L73_PDN_DMICB (1 << 6) |
| 133 | #define PDN_ADCA (1 << 5) | 133 | #define CS42L73_PDN_ADCA (1 << 5) |
| 134 | #define PDN_DMICA (1 << 4) | 134 | #define CS42L73_PDN_DMICA (1 << 4) |
| 135 | #define PDN_LDO (1 << 2) | 135 | #define CS42L73_PDN_LDO (1 << 2) |
| 136 | #define DISCHG_FILT (1 << 1) | 136 | #define CS42L73_DISCHG_FILT (1 << 1) |
| 137 | #define PDN (1 << 0) | 137 | #define CS42L73_PDN (1 << 0) |
| 138 | 138 | ||
| 139 | /* CS42L73_PWRCTL2 */ | 139 | /* CS42L73_PWRCTL2 */ |
| 140 | #define PDN_MIC2_BIAS (1 << 7) | 140 | #define CS42L73_PDN_MIC2_BIAS (1 << 7) |
| 141 | #define PDN_MIC1_BIAS (1 << 6) | 141 | #define CS42L73_PDN_MIC1_BIAS (1 << 6) |
| 142 | #define PDN_VSP (1 << 4) | 142 | #define CS42L73_PDN_VSP (1 << 4) |
| 143 | #define PDN_ASP_SDOUT (1 << 3) | 143 | #define CS42L73_PDN_ASP_SDOUT (1 << 3) |
| 144 | #define PDN_ASP_SDIN (1 << 2) | 144 | #define CS42L73_PDN_ASP_SDIN (1 << 2) |
| 145 | #define PDN_XSP_SDOUT (1 << 1) | 145 | #define CS42L73_PDN_XSP_SDOUT (1 << 1) |
| 146 | #define PDN_XSP_SDIN (1 << 0) | 146 | #define CS42L73_PDN_XSP_SDIN (1 << 0) |
| 147 | 147 | ||
| 148 | /* CS42L73_PWRCTL3 */ | 148 | /* CS42L73_PWRCTL3 */ |
| 149 | #define PDN_THMS (1 << 5) | 149 | #define CS42L73_PDN_THMS (1 << 5) |
| 150 | #define PDN_SPKLO (1 << 4) | 150 | #define CS42L73_PDN_SPKLO (1 << 4) |
| 151 | #define PDN_EAR (1 << 3) | 151 | #define CS42L73_PDN_EAR (1 << 3) |
| 152 | #define PDN_SPK (1 << 2) | 152 | #define CS42L73_PDN_SPK (1 << 2) |
| 153 | #define PDN_LO (1 << 1) | 153 | #define CS42L73_PDN_LO (1 << 1) |
| 154 | #define PDN_HP (1 << 0) | 154 | #define CS42L73_PDN_HP (1 << 0) |
| 155 | 155 | ||
| 156 | /* Thermal Overload Detect. Requires interrupt ... */ | 156 | /* Thermal Overload Detect. Requires interrupt ... */ |
| 157 | #define THMOVLD_150C 0 | 157 | #define CS42L73_THMOVLD_150C 0 |
| 158 | #define THMOVLD_132C 1 | 158 | #define CS42L73_THMOVLD_132C 1 |
| 159 | #define THMOVLD_115C 2 | 159 | #define CS42L73_THMOVLD_115C 2 |
| 160 | #define THMOVLD_098C 3 | 160 | #define CS42L73_THMOVLD_098C 3 |
| 161 | 161 | ||
| 162 | #define CS42L73_CHARGEPUMP_MASK (0xF0) | ||
| 162 | 163 | ||
| 163 | /* CS42L73_ASPC, CS42L73_XSPC, CS42L73_VSPC */ | 164 | /* CS42L73_ASPC, CS42L73_XSPC, CS42L73_VSPC */ |
| 164 | #define SP_3ST (1 << 7) | 165 | #define CS42L73_SP_3ST (1 << 7) |
| 165 | #define SPDIF_I2S (0 << 6) | 166 | #define CS42L73_SPDIF_I2S (0 << 6) |
| 166 | #define SPDIF_PCM (1 << 6) | 167 | #define CS42L73_SPDIF_PCM (1 << 6) |
| 167 | #define PCM_MODE0 (0 << 4) | 168 | #define CS42L73_PCM_MODE0 (0 << 4) |
| 168 | #define PCM_MODE1 (1 << 4) | 169 | #define CS42L73_PCM_MODE1 (1 << 4) |
| 169 | #define PCM_MODE2 (2 << 4) | 170 | #define CS42L73_PCM_MODE2 (2 << 4) |
| 170 | #define PCM_MODE_MASK (3 << 4) | 171 | #define CS42L73_PCM_MODE_MASK (3 << 4) |
| 171 | #define PCM_BIT_ORDER (1 << 3) | 172 | #define CS42L73_PCM_BIT_ORDER (1 << 3) |
| 172 | #define MCK_SCLK_64FS (0 << 0) | 173 | #define CS42L73_MCK_SCLK_64FS (0 << 0) |
| 173 | #define MCK_SCLK_MCLK (2 << 0) | 174 | #define CS42L73_MCK_SCLK_MCLK (2 << 0) |
| 174 | #define MCK_SCLK_PREMCLK (3 << 0) | 175 | #define CS42L73_MCK_SCLK_PREMCLK (3 << 0) |
| 175 | 176 | ||
| 176 | /* CS42L73_xSPMMCC */ | 177 | /* CS42L73_xSPMMCC */ |
| 177 | #define MS_MASTER (1 << 7) | 178 | #define CS42L73_MS_MASTER (1 << 7) |
| 178 | 179 | ||
| 179 | 180 | ||
| 180 | /* CS42L73_DMMCC */ | 181 | /* CS42L73_DMMCC */ |
| 181 | #define MCLKDIS (1 << 0) | 182 | #define CS42L73_MCLKDIS (1 << 0) |
| 182 | #define MCLKSEL_MCLK2 (1 << 4) | 183 | #define CS42L73_MCLKSEL_MCLK2 (1 << 4) |
| 183 | #define MCLKSEL_MCLK1 (0 << 4) | 184 | #define CS42L73_MCLKSEL_MCLK1 (0 << 4) |
| 184 | 185 | ||
| 185 | /* CS42L73 MCLK derived from MCLK1 or MCLK2 */ | 186 | /* CS42L73 MCLK derived from MCLK1 or MCLK2 */ |
| 186 | #define CS42L73_CLKID_MCLK1 0 | 187 | #define CS42L73_CLKID_MCLK1 0 |
| @@ -194,28 +195,26 @@ | |||
| 194 | #define CS42L73_VSP 2 | 195 | #define CS42L73_VSP 2 |
| 195 | 196 | ||
| 196 | /* IS1, IM1 */ | 197 | /* IS1, IM1 */ |
| 197 | #define MIC2_SDET (1 << 6) | 198 | #define CS42L73_MIC2_SDET (1 << 6) |
| 198 | #define THMOVLD (1 << 4) | 199 | #define CS42L73_THMOVLD (1 << 4) |
| 199 | #define DIGMIXOVFL (1 << 3) | 200 | #define CS42L73_DIGMIXOVFL (1 << 3) |
| 200 | #define IPBOVFL (1 << 1) | 201 | #define CS42L73_IPBOVFL (1 << 1) |
| 201 | #define IPAOVFL (1 << 0) | 202 | #define CS42L73_IPAOVFL (1 << 0) |
| 202 | 203 | ||
| 203 | /* Analog Softramp */ | 204 | /* Analog Softramp */ |
| 204 | #define ANLGOSFT (1 << 0) | 205 | #define CS42L73_ANLGOSFT (1 << 0) |
| 205 | 206 | ||
| 206 | /* HP A/B Analog Mute */ | 207 | /* HP A/B Analog Mute */ |
| 207 | #define HPA_MUTE (1 << 7) | 208 | #define CS42L73_HPA_MUTE (1 << 7) |
| 208 | /* LO A/B Analog Mute */ | 209 | /* LO A/B Analog Mute */ |
| 209 | #define LOA_MUTE (1 << 7) | 210 | #define CS42L73_LOA_MUTE (1 << 7) |
| 210 | /* Digital Mute */ | 211 | /* Digital Mute */ |
| 211 | #define HLAD_MUTE (1 << 0) | 212 | #define CS42L73_HLAD_MUTE (1 << 0) |
| 212 | #define HLBD_MUTE (1 << 1) | 213 | #define CS42L73_HLBD_MUTE (1 << 1) |
| 213 | #define SPKD_MUTE (1 << 2) | 214 | #define CS42L73_SPKD_MUTE (1 << 2) |
| 214 | #define ESLD_MUTE (1 << 3) | 215 | #define CS42L73_ESLD_MUTE (1 << 3) |
| 215 | 216 | ||
| 216 | /* Misc defines for codec */ | 217 | /* Misc defines for codec */ |
| 217 | #define CS42L73_RESET_GPIO 143 | ||
| 218 | |||
| 219 | #define CS42L73_DEVID 0x00042A73 | 218 | #define CS42L73_DEVID 0x00042A73 |
| 220 | #define CS42L73_MCLKX_MIN 5644800 | 219 | #define CS42L73_MCLKX_MIN 5644800 |
| 221 | #define CS42L73_MCLKX_MAX 38400000 | 220 | #define CS42L73_MCLKX_MAX 38400000 |
diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c index 566a367c94fa..66ceee22fdad 100644 --- a/sound/soc/codecs/max98088.c +++ b/sound/soc/codecs/max98088.c | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include <linux/delay.h> | 15 | #include <linux/delay.h> |
| 16 | #include <linux/pm.h> | 16 | #include <linux/pm.h> |
| 17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
| 18 | #include <linux/regmap.h> | ||
| 18 | #include <sound/core.h> | 19 | #include <sound/core.h> |
| 19 | #include <sound/pcm.h> | 20 | #include <sound/pcm.h> |
| 20 | #include <sound/pcm_params.h> | 21 | #include <sound/pcm_params.h> |
| @@ -38,294 +39,223 @@ struct max98088_cdata { | |||
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | struct max98088_priv { | 41 | struct max98088_priv { |
| 41 | enum max98088_type devtype; | 42 | struct regmap *regmap; |
| 42 | struct max98088_pdata *pdata; | 43 | enum max98088_type devtype; |
| 43 | unsigned int sysclk; | 44 | struct max98088_pdata *pdata; |
| 44 | struct max98088_cdata dai[2]; | 45 | unsigned int sysclk; |
| 45 | int eq_textcnt; | 46 | struct max98088_cdata dai[2]; |
| 46 | const char **eq_texts; | 47 | int eq_textcnt; |
| 47 | struct soc_enum eq_enum; | 48 | const char **eq_texts; |
| 48 | u8 ina_state; | 49 | struct soc_enum eq_enum; |
| 49 | u8 inb_state; | 50 | u8 ina_state; |
| 50 | unsigned int ex_mode; | 51 | u8 inb_state; |
| 51 | unsigned int digmic; | 52 | unsigned int ex_mode; |
| 52 | unsigned int mic1pre; | 53 | unsigned int digmic; |
| 53 | unsigned int mic2pre; | 54 | unsigned int mic1pre; |
| 54 | unsigned int extmic_mode; | 55 | unsigned int mic2pre; |
| 56 | unsigned int extmic_mode; | ||
| 55 | }; | 57 | }; |
| 56 | 58 | ||
| 57 | static const u8 max98088_reg[M98088_REG_CNT] = { | 59 | static const struct reg_default max98088_reg[] = { |
| 58 | 0x00, /* 00 IRQ status */ | 60 | { 0xf, 0x00 }, /* 0F interrupt enable */ |
| 59 | 0x00, /* 01 MIC status */ | 61 | |
| 60 | 0x00, /* 02 jack status */ | 62 | { 0x10, 0x00 }, /* 10 master clock */ |
| 61 | 0x00, /* 03 battery voltage */ | 63 | { 0x11, 0x00 }, /* 11 DAI1 clock mode */ |
| 62 | 0x00, /* 04 */ | 64 | { 0x12, 0x00 }, /* 12 DAI1 clock control */ |
| 63 | 0x00, /* 05 */ | 65 | { 0x13, 0x00 }, /* 13 DAI1 clock control */ |
| 64 | 0x00, /* 06 */ | 66 | { 0x14, 0x00 }, /* 14 DAI1 format */ |
| 65 | 0x00, /* 07 */ | 67 | { 0x15, 0x00 }, /* 15 DAI1 clock */ |
| 66 | 0x00, /* 08 */ | 68 | { 0x16, 0x00 }, /* 16 DAI1 config */ |
| 67 | 0x00, /* 09 */ | 69 | { 0x17, 0x00 }, /* 17 DAI1 TDM */ |
| 68 | 0x00, /* 0A */ | 70 | { 0x18, 0x00 }, /* 18 DAI1 filters */ |
| 69 | 0x00, /* 0B */ | 71 | { 0x19, 0x00 }, /* 19 DAI2 clock mode */ |
| 70 | 0x00, /* 0C */ | 72 | { 0x1a, 0x00 }, /* 1A DAI2 clock control */ |
| 71 | 0x00, /* 0D */ | 73 | { 0x1b, 0x00 }, /* 1B DAI2 clock control */ |
| 72 | 0x00, /* 0E */ | 74 | { 0x1c, 0x00 }, /* 1C DAI2 format */ |
| 73 | 0x00, /* 0F interrupt enable */ | 75 | { 0x1d, 0x00 }, /* 1D DAI2 clock */ |
| 74 | 76 | { 0x1e, 0x00 }, /* 1E DAI2 config */ | |
| 75 | 0x00, /* 10 master clock */ | 77 | { 0x1f, 0x00 }, /* 1F DAI2 TDM */ |
| 76 | 0x00, /* 11 DAI1 clock mode */ | 78 | |
| 77 | 0x00, /* 12 DAI1 clock control */ | 79 | { 0x20, 0x00 }, /* 20 DAI2 filters */ |
| 78 | 0x00, /* 13 DAI1 clock control */ | 80 | { 0x21, 0x00 }, /* 21 data config */ |
| 79 | 0x00, /* 14 DAI1 format */ | 81 | { 0x22, 0x00 }, /* 22 DAC mixer */ |
| 80 | 0x00, /* 15 DAI1 clock */ | 82 | { 0x23, 0x00 }, /* 23 left ADC mixer */ |
| 81 | 0x00, /* 16 DAI1 config */ | 83 | { 0x24, 0x00 }, /* 24 right ADC mixer */ |
| 82 | 0x00, /* 17 DAI1 TDM */ | 84 | { 0x25, 0x00 }, /* 25 left HP mixer */ |
| 83 | 0x00, /* 18 DAI1 filters */ | 85 | { 0x26, 0x00 }, /* 26 right HP mixer */ |
| 84 | 0x00, /* 19 DAI2 clock mode */ | 86 | { 0x27, 0x00 }, /* 27 HP control */ |
| 85 | 0x00, /* 1A DAI2 clock control */ | 87 | { 0x28, 0x00 }, /* 28 left REC mixer */ |
| 86 | 0x00, /* 1B DAI2 clock control */ | 88 | { 0x29, 0x00 }, /* 29 right REC mixer */ |
| 87 | 0x00, /* 1C DAI2 format */ | 89 | { 0x2a, 0x00 }, /* 2A REC control */ |
| 88 | 0x00, /* 1D DAI2 clock */ | 90 | { 0x2b, 0x00 }, /* 2B left SPK mixer */ |
| 89 | 0x00, /* 1E DAI2 config */ | 91 | { 0x2c, 0x00 }, /* 2C right SPK mixer */ |
| 90 | 0x00, /* 1F DAI2 TDM */ | 92 | { 0x2d, 0x00 }, /* 2D SPK control */ |
| 91 | 93 | { 0x2e, 0x00 }, /* 2E sidetone */ | |
| 92 | 0x00, /* 20 DAI2 filters */ | 94 | { 0x2f, 0x00 }, /* 2F DAI1 playback level */ |
| 93 | 0x00, /* 21 data config */ | 95 | |
| 94 | 0x00, /* 22 DAC mixer */ | 96 | { 0x30, 0x00 }, /* 30 DAI1 playback level */ |
| 95 | 0x00, /* 23 left ADC mixer */ | 97 | { 0x31, 0x00 }, /* 31 DAI2 playback level */ |
| 96 | 0x00, /* 24 right ADC mixer */ | 98 | { 0x32, 0x00 }, /* 32 DAI2 playbakc level */ |
| 97 | 0x00, /* 25 left HP mixer */ | 99 | { 0x33, 0x00 }, /* 33 left ADC level */ |
| 98 | 0x00, /* 26 right HP mixer */ | 100 | { 0x34, 0x00 }, /* 34 right ADC level */ |
| 99 | 0x00, /* 27 HP control */ | 101 | { 0x35, 0x00 }, /* 35 MIC1 level */ |
| 100 | 0x00, /* 28 left REC mixer */ | 102 | { 0x36, 0x00 }, /* 36 MIC2 level */ |
| 101 | 0x00, /* 29 right REC mixer */ | 103 | { 0x37, 0x00 }, /* 37 INA level */ |
| 102 | 0x00, /* 2A REC control */ | 104 | { 0x38, 0x00 }, /* 38 INB level */ |
| 103 | 0x00, /* 2B left SPK mixer */ | 105 | { 0x39, 0x00 }, /* 39 left HP volume */ |
| 104 | 0x00, /* 2C right SPK mixer */ | 106 | { 0x3a, 0x00 }, /* 3A right HP volume */ |
| 105 | 0x00, /* 2D SPK control */ | 107 | { 0x3b, 0x00 }, /* 3B left REC volume */ |
| 106 | 0x00, /* 2E sidetone */ | 108 | { 0x3c, 0x00 }, /* 3C right REC volume */ |
| 107 | 0x00, /* 2F DAI1 playback level */ | 109 | { 0x3d, 0x00 }, /* 3D left SPK volume */ |
| 108 | 110 | { 0x3e, 0x00 }, /* 3E right SPK volume */ | |
| 109 | 0x00, /* 30 DAI1 playback level */ | 111 | { 0x3f, 0x00 }, /* 3F MIC config */ |
| 110 | 0x00, /* 31 DAI2 playback level */ | 112 | |
| 111 | 0x00, /* 32 DAI2 playbakc level */ | 113 | { 0x40, 0x00 }, /* 40 MIC threshold */ |
| 112 | 0x00, /* 33 left ADC level */ | 114 | { 0x41, 0x00 }, /* 41 excursion limiter filter */ |
| 113 | 0x00, /* 34 right ADC level */ | 115 | { 0x42, 0x00 }, /* 42 excursion limiter threshold */ |
| 114 | 0x00, /* 35 MIC1 level */ | 116 | { 0x43, 0x00 }, /* 43 ALC */ |
| 115 | 0x00, /* 36 MIC2 level */ | 117 | { 0x44, 0x00 }, /* 44 power limiter threshold */ |
| 116 | 0x00, /* 37 INA level */ | 118 | { 0x45, 0x00 }, /* 45 power limiter config */ |
| 117 | 0x00, /* 38 INB level */ | 119 | { 0x46, 0x00 }, /* 46 distortion limiter config */ |
| 118 | 0x00, /* 39 left HP volume */ | 120 | { 0x47, 0x00 }, /* 47 audio input */ |
| 119 | 0x00, /* 3A right HP volume */ | 121 | { 0x48, 0x00 }, /* 48 microphone */ |
| 120 | 0x00, /* 3B left REC volume */ | 122 | { 0x49, 0x00 }, /* 49 level control */ |
| 121 | 0x00, /* 3C right REC volume */ | 123 | { 0x4a, 0x00 }, /* 4A bypass switches */ |
| 122 | 0x00, /* 3D left SPK volume */ | 124 | { 0x4b, 0x00 }, /* 4B jack detect */ |
| 123 | 0x00, /* 3E right SPK volume */ | 125 | { 0x4c, 0x00 }, /* 4C input enable */ |
| 124 | 0x00, /* 3F MIC config */ | 126 | { 0x4d, 0x00 }, /* 4D output enable */ |
| 125 | 127 | { 0x4e, 0xF0 }, /* 4E bias control */ | |
| 126 | 0x00, /* 40 MIC threshold */ | 128 | { 0x4f, 0x00 }, /* 4F DAC power */ |
| 127 | 0x00, /* 41 excursion limiter filter */ | 129 | |
| 128 | 0x00, /* 42 excursion limiter threshold */ | 130 | { 0x50, 0x0F }, /* 50 DAC power */ |
| 129 | 0x00, /* 43 ALC */ | 131 | { 0x51, 0x00 }, /* 51 system */ |
| 130 | 0x00, /* 44 power limiter threshold */ | 132 | { 0x52, 0x00 }, /* 52 DAI1 EQ1 */ |
| 131 | 0x00, /* 45 power limiter config */ | 133 | { 0x53, 0x00 }, /* 53 DAI1 EQ1 */ |
| 132 | 0x00, /* 46 distortion limiter config */ | 134 | { 0x54, 0x00 }, /* 54 DAI1 EQ1 */ |
| 133 | 0x00, /* 47 audio input */ | 135 | { 0x55, 0x00 }, /* 55 DAI1 EQ1 */ |
| 134 | 0x00, /* 48 microphone */ | 136 | { 0x56, 0x00 }, /* 56 DAI1 EQ1 */ |
| 135 | 0x00, /* 49 level control */ | 137 | { 0x57, 0x00 }, /* 57 DAI1 EQ1 */ |
| 136 | 0x00, /* 4A bypass switches */ | 138 | { 0x58, 0x00 }, /* 58 DAI1 EQ1 */ |
| 137 | 0x00, /* 4B jack detect */ | 139 | { 0x59, 0x00 }, /* 59 DAI1 EQ1 */ |
| 138 | 0x00, /* 4C input enable */ | 140 | { 0x5a, 0x00 }, /* 5A DAI1 EQ1 */ |
| 139 | 0x00, /* 4D output enable */ | 141 | { 0x5b, 0x00 }, /* 5B DAI1 EQ1 */ |
| 140 | 0xF0, /* 4E bias control */ | 142 | { 0x5c, 0x00 }, /* 5C DAI1 EQ2 */ |
| 141 | 0x00, /* 4F DAC power */ | 143 | { 0x5d, 0x00 }, /* 5D DAI1 EQ2 */ |
| 142 | 144 | { 0x5e, 0x00 }, /* 5E DAI1 EQ2 */ | |
| 143 | 0x0F, /* 50 DAC power */ | 145 | { 0x5f, 0x00 }, /* 5F DAI1 EQ2 */ |
| 144 | 0x00, /* 51 system */ | 146 | |
| 145 | 0x00, /* 52 DAI1 EQ1 */ | 147 | { 0x60, 0x00 }, /* 60 DAI1 EQ2 */ |
| 146 | 0x00, /* 53 DAI1 EQ1 */ | 148 | { 0x61, 0x00 }, /* 61 DAI1 EQ2 */ |
| 147 | 0x00, /* 54 DAI1 EQ1 */ | 149 | { 0x62, 0x00 }, /* 62 DAI1 EQ2 */ |
| 148 | 0x00, /* 55 DAI1 EQ1 */ | 150 | { 0x63, 0x00 }, /* 63 DAI1 EQ2 */ |
| 149 | 0x00, /* 56 DAI1 EQ1 */ | 151 | { 0x64, 0x00 }, /* 64 DAI1 EQ2 */ |
| 150 | 0x00, /* 57 DAI1 EQ1 */ | 152 | { 0x65, 0x00 }, /* 65 DAI1 EQ2 */ |
| 151 | 0x00, /* 58 DAI1 EQ1 */ | 153 | { 0x66, 0x00 }, /* 66 DAI1 EQ3 */ |
| 152 | 0x00, /* 59 DAI1 EQ1 */ | 154 | { 0x67, 0x00 }, /* 67 DAI1 EQ3 */ |
| 153 | 0x00, /* 5A DAI1 EQ1 */ | 155 | { 0x68, 0x00 }, /* 68 DAI1 EQ3 */ |
| 154 | 0x00, /* 5B DAI1 EQ1 */ | 156 | { 0x69, 0x00 }, /* 69 DAI1 EQ3 */ |
| 155 | 0x00, /* 5C DAI1 EQ2 */ | 157 | { 0x6a, 0x00 }, /* 6A DAI1 EQ3 */ |
| 156 | 0x00, /* 5D DAI1 EQ2 */ | 158 | { 0x6b, 0x00 }, /* 6B DAI1 EQ3 */ |
| 157 | 0x00, /* 5E DAI1 EQ2 */ | 159 | { 0x6c, 0x00 }, /* 6C DAI1 EQ3 */ |
| 158 | 0x00, /* 5F DAI1 EQ2 */ | 160 | { 0x6d, 0x00 }, /* 6D DAI1 EQ3 */ |
| 159 | 161 | { 0x6e, 0x00 }, /* 6E DAI1 EQ3 */ | |
| 160 | 0x00, /* 60 DAI1 EQ2 */ | 162 | { 0x6f, 0x00 }, /* 6F DAI1 EQ3 */ |
| 161 | 0x00, /* 61 DAI1 EQ2 */ | 163 | |
| 162 | 0x00, /* 62 DAI1 EQ2 */ | 164 | { 0x70, 0x00 }, /* 70 DAI1 EQ4 */ |
| 163 | 0x00, /* 63 DAI1 EQ2 */ | 165 | { 0x71, 0x00 }, /* 71 DAI1 EQ4 */ |
| 164 | 0x00, /* 64 DAI1 EQ2 */ | 166 | { 0x72, 0x00 }, /* 72 DAI1 EQ4 */ |
| 165 | 0x00, /* 65 DAI1 EQ2 */ | 167 | { 0x73, 0x00 }, /* 73 DAI1 EQ4 */ |
| 166 | 0x00, /* 66 DAI1 EQ3 */ | 168 | { 0x74, 0x00 }, /* 74 DAI1 EQ4 */ |
| 167 | 0x00, /* 67 DAI1 EQ3 */ | 169 | { 0x75, 0x00 }, /* 75 DAI1 EQ4 */ |
| 168 | 0x00, /* 68 DAI1 EQ3 */ | 170 | { 0x76, 0x00 }, /* 76 DAI1 EQ4 */ |
| 169 | 0x00, /* 69 DAI1 EQ3 */ | 171 | { 0x77, 0x00 }, /* 77 DAI1 EQ4 */ |
| 170 | 0x00, /* 6A DAI1 EQ3 */ | 172 | { 0x78, 0x00 }, /* 78 DAI1 EQ4 */ |
| 171 | 0x00, /* 6B DAI1 EQ3 */ | 173 | { 0x79, 0x00 }, /* 79 DAI1 EQ4 */ |
| 172 | 0x00, /* 6C DAI1 EQ3 */ | 174 | { 0x7a, 0x00 }, /* 7A DAI1 EQ5 */ |
| 173 | 0x00, /* 6D DAI1 EQ3 */ | 175 | { 0x7b, 0x00 }, /* 7B DAI1 EQ5 */ |
| 174 | 0x00, /* 6E DAI1 EQ3 */ | 176 | { 0x7c, 0x00 }, /* 7C DAI1 EQ5 */ |
| 175 | 0x00, /* 6F DAI1 EQ3 */ | 177 | { 0x7d, 0x00 }, /* 7D DAI1 EQ5 */ |
| 176 | 178 | { 0x7e, 0x00 }, /* 7E DAI1 EQ5 */ | |
| 177 | 0x00, /* 70 DAI1 EQ4 */ | 179 | { 0x7f, 0x00 }, /* 7F DAI1 EQ5 */ |
| 178 | 0x00, /* 71 DAI1 EQ4 */ | 180 | |
| 179 | 0x00, /* 72 DAI1 EQ4 */ | 181 | { 0x80, 0x00 }, /* 80 DAI1 EQ5 */ |
| 180 | 0x00, /* 73 DAI1 EQ4 */ | 182 | { 0x81, 0x00 }, /* 81 DAI1 EQ5 */ |
| 181 | 0x00, /* 74 DAI1 EQ4 */ | 183 | { 0x82, 0x00 }, /* 82 DAI1 EQ5 */ |
| 182 | 0x00, /* 75 DAI1 EQ4 */ | 184 | { 0x83, 0x00 }, /* 83 DAI1 EQ5 */ |
| 183 | 0x00, /* 76 DAI1 EQ4 */ | 185 | { 0x84, 0x00 }, /* 84 DAI2 EQ1 */ |
| 184 | 0x00, /* 77 DAI1 EQ4 */ | 186 | { 0x85, 0x00 }, /* 85 DAI2 EQ1 */ |
| 185 | 0x00, /* 78 DAI1 EQ4 */ | 187 | { 0x86, 0x00 }, /* 86 DAI2 EQ1 */ |
| 186 | 0x00, /* 79 DAI1 EQ4 */ | 188 | { 0x87, 0x00 }, /* 87 DAI2 EQ1 */ |
| 187 | 0x00, /* 7A DAI1 EQ5 */ | 189 | { 0x88, 0x00 }, /* 88 DAI2 EQ1 */ |
| 188 | 0x00, /* 7B DAI1 EQ5 */ | 190 | { 0x89, 0x00 }, /* 89 DAI2 EQ1 */ |
| 189 | 0x00, /* 7C DAI1 EQ5 */ | 191 | { 0x8a, 0x00 }, /* 8A DAI2 EQ1 */ |
| 190 | 0x00, /* 7D DAI1 EQ5 */ | 192 | { 0x8b, 0x00 }, /* 8B DAI2 EQ1 */ |
| 191 | 0x00, /* 7E DAI1 EQ5 */ | 193 | { 0x8c, 0x00 }, /* 8C DAI2 EQ1 */ |
| 192 | 0x00, /* 7F DAI1 EQ5 */ | 194 | { 0x8d, 0x00 }, /* 8D DAI2 EQ1 */ |
| 193 | 195 | { 0x8e, 0x00 }, /* 8E DAI2 EQ2 */ | |
| 194 | 0x00, /* 80 DAI1 EQ5 */ | 196 | { 0x8f, 0x00 }, /* 8F DAI2 EQ2 */ |
| 195 | 0x00, /* 81 DAI1 EQ5 */ | 197 | |
| 196 | 0x00, /* 82 DAI1 EQ5 */ | 198 | { 0x90, 0x00 }, /* 90 DAI2 EQ2 */ |
| 197 | 0x00, /* 83 DAI1 EQ5 */ | 199 | { 0x91, 0x00 }, /* 91 DAI2 EQ2 */ |
| 198 | 0x00, /* 84 DAI2 EQ1 */ | 200 | { 0x92, 0x00 }, /* 92 DAI2 EQ2 */ |
| 199 | 0x00, /* 85 DAI2 EQ1 */ | 201 | { 0x93, 0x00 }, /* 93 DAI2 EQ2 */ |
| 200 | 0x00, /* 86 DAI2 EQ1 */ | 202 | { 0x94, 0x00 }, /* 94 DAI2 EQ2 */ |
| 201 | 0x00, /* 87 DAI2 EQ1 */ | 203 | { 0x95, 0x00 }, /* 95 DAI2 EQ2 */ |
| 202 | 0x00, /* 88 DAI2 EQ1 */ | 204 | { 0x96, 0x00 }, /* 96 DAI2 EQ2 */ |
| 203 | 0x00, /* 89 DAI2 EQ1 */ | 205 | { 0x97, 0x00 }, /* 97 DAI2 EQ2 */ |
| 204 | 0x00, /* 8A DAI2 EQ1 */ | 206 | { 0x98, 0x00 }, /* 98 DAI2 EQ3 */ |
| 205 | 0x00, /* 8B DAI2 EQ1 */ | 207 | { 0x99, 0x00 }, /* 99 DAI2 EQ3 */ |
| 206 | 0x00, /* 8C DAI2 EQ1 */ | 208 | { 0x9a, 0x00 }, /* 9A DAI2 EQ3 */ |
| 207 | 0x00, /* 8D DAI2 EQ1 */ | 209 | { 0x9b, 0x00 }, /* 9B DAI2 EQ3 */ |
| 208 | 0x00, /* 8E DAI2 EQ2 */ | 210 | { 0x9c, 0x00 }, /* 9C DAI2 EQ3 */ |
| 209 | 0x00, /* 8F DAI2 EQ2 */ | 211 | { 0x9d, 0x00 }, /* 9D DAI2 EQ3 */ |
| 210 | 212 | { 0x9e, 0x00 }, /* 9E DAI2 EQ3 */ | |
| 211 | 0x00, /* 90 DAI2 EQ2 */ | 213 | { 0x9f, 0x00 }, /* 9F DAI2 EQ3 */ |
| 212 | 0x00, /* 91 DAI2 EQ2 */ | 214 | |
| 213 | 0x00, /* 92 DAI2 EQ2 */ | 215 | { 0xa0, 0x00 }, /* A0 DAI2 EQ3 */ |
| 214 | 0x00, /* 93 DAI2 EQ2 */ | 216 | { 0xa1, 0x00 }, /* A1 DAI2 EQ3 */ |
| 215 | 0x00, /* 94 DAI2 EQ2 */ | 217 | { 0xa2, 0x00 }, /* A2 DAI2 EQ4 */ |
| 216 | 0x00, /* 95 DAI2 EQ2 */ | 218 | { 0xa3, 0x00 }, /* A3 DAI2 EQ4 */ |
| 217 | 0x00, /* 96 DAI2 EQ2 */ | 219 | { 0xa4, 0x00 }, /* A4 DAI2 EQ4 */ |
| 218 | 0x00, /* 97 DAI2 EQ2 */ | 220 | { 0xa5, 0x00 }, /* A5 DAI2 EQ4 */ |
| 219 | 0x00, /* 98 DAI2 EQ3 */ | 221 | { 0xa6, 0x00 }, /* A6 DAI2 EQ4 */ |
| 220 | 0x00, /* 99 DAI2 EQ3 */ | 222 | { 0xa7, 0x00 }, /* A7 DAI2 EQ4 */ |
| 221 | 0x00, /* 9A DAI2 EQ3 */ | 223 | { 0xa8, 0x00 }, /* A8 DAI2 EQ4 */ |
| 222 | 0x00, /* 9B DAI2 EQ3 */ | 224 | { 0xa9, 0x00 }, /* A9 DAI2 EQ4 */ |
| 223 | 0x00, /* 9C DAI2 EQ3 */ | 225 | { 0xaa, 0x00 }, /* AA DAI2 EQ4 */ |
| 224 | 0x00, /* 9D DAI2 EQ3 */ | 226 | { 0xab, 0x00 }, /* AB DAI2 EQ4 */ |
| 225 | 0x00, /* 9E DAI2 EQ3 */ | 227 | { 0xac, 0x00 }, /* AC DAI2 EQ5 */ |
| 226 | 0x00, /* 9F DAI2 EQ3 */ | 228 | { 0xad, 0x00 }, /* AD DAI2 EQ5 */ |
| 227 | 229 | { 0xae, 0x00 }, /* AE DAI2 EQ5 */ | |
| 228 | 0x00, /* A0 DAI2 EQ3 */ | 230 | { 0xaf, 0x00 }, /* AF DAI2 EQ5 */ |
| 229 | 0x00, /* A1 DAI2 EQ3 */ | 231 | |
| 230 | 0x00, /* A2 DAI2 EQ4 */ | 232 | { 0xb0, 0x00 }, /* B0 DAI2 EQ5 */ |
| 231 | 0x00, /* A3 DAI2 EQ4 */ | 233 | { 0xb1, 0x00 }, /* B1 DAI2 EQ5 */ |
| 232 | 0x00, /* A4 DAI2 EQ4 */ | 234 | { 0xb2, 0x00 }, /* B2 DAI2 EQ5 */ |
| 233 | 0x00, /* A5 DAI2 EQ4 */ | 235 | { 0xb3, 0x00 }, /* B3 DAI2 EQ5 */ |
| 234 | 0x00, /* A6 DAI2 EQ4 */ | 236 | { 0xb4, 0x00 }, /* B4 DAI2 EQ5 */ |
| 235 | 0x00, /* A7 DAI2 EQ4 */ | 237 | { 0xb5, 0x00 }, /* B5 DAI2 EQ5 */ |
| 236 | 0x00, /* A8 DAI2 EQ4 */ | 238 | { 0xb6, 0x00 }, /* B6 DAI1 biquad */ |
| 237 | 0x00, /* A9 DAI2 EQ4 */ | 239 | { 0xb7, 0x00 }, /* B7 DAI1 biquad */ |
| 238 | 0x00, /* AA DAI2 EQ4 */ | 240 | { 0xb8 ,0x00 }, /* B8 DAI1 biquad */ |
| 239 | 0x00, /* AB DAI2 EQ4 */ | 241 | { 0xb9, 0x00 }, /* B9 DAI1 biquad */ |
| 240 | 0x00, /* AC DAI2 EQ5 */ | 242 | { 0xba, 0x00 }, /* BA DAI1 biquad */ |
| 241 | 0x00, /* AD DAI2 EQ5 */ | 243 | { 0xbb, 0x00 }, /* BB DAI1 biquad */ |
| 242 | 0x00, /* AE DAI2 EQ5 */ | 244 | { 0xbc, 0x00 }, /* BC DAI1 biquad */ |
| 243 | 0x00, /* AF DAI2 EQ5 */ | 245 | { 0xbd, 0x00 }, /* BD DAI1 biquad */ |
| 244 | 246 | { 0xbe, 0x00 }, /* BE DAI1 biquad */ | |
| 245 | 0x00, /* B0 DAI2 EQ5 */ | 247 | { 0xbf, 0x00 }, /* BF DAI1 biquad */ |
| 246 | 0x00, /* B1 DAI2 EQ5 */ | 248 | |
| 247 | 0x00, /* B2 DAI2 EQ5 */ | 249 | { 0xc0, 0x00 }, /* C0 DAI2 biquad */ |
| 248 | 0x00, /* B3 DAI2 EQ5 */ | 250 | { 0xc1, 0x00 }, /* C1 DAI2 biquad */ |
| 249 | 0x00, /* B4 DAI2 EQ5 */ | 251 | { 0xc2, 0x00 }, /* C2 DAI2 biquad */ |
| 250 | 0x00, /* B5 DAI2 EQ5 */ | 252 | { 0xc3, 0x00 }, /* C3 DAI2 biquad */ |
| 251 | 0x00, /* B6 DAI1 biquad */ | 253 | { 0xc4, 0x00 }, /* C4 DAI2 biquad */ |
| 252 | 0x00, /* B7 DAI1 biquad */ | 254 | { 0xc5, 0x00 }, /* C5 DAI2 biquad */ |
| 253 | 0x00, /* B8 DAI1 biquad */ | 255 | { 0xc6, 0x00 }, /* C6 DAI2 biquad */ |
| 254 | 0x00, /* B9 DAI1 biquad */ | 256 | { 0xc7, 0x00 }, /* C7 DAI2 biquad */ |
| 255 | 0x00, /* BA DAI1 biquad */ | 257 | { 0xc8, 0x00 }, /* C8 DAI2 biquad */ |
| 256 | 0x00, /* BB DAI1 biquad */ | 258 | { 0xc9, 0x00 }, /* C9 DAI2 biquad */ |
| 257 | 0x00, /* BC DAI1 biquad */ | ||
| 258 | 0x00, /* BD DAI1 biquad */ | ||
| 259 | 0x00, /* BE DAI1 biquad */ | ||
| 260 | 0x00, /* BF DAI1 biquad */ | ||
| 261 | |||
| 262 | 0x00, /* C0 DAI2 biquad */ | ||
| 263 | 0x00, /* C1 DAI2 biquad */ | ||
| 264 | 0x00, /* C2 DAI2 biquad */ | ||
| 265 | 0x00, /* C3 DAI2 biquad */ | ||
| 266 | 0x00, /* C4 DAI2 biquad */ | ||
| 267 | 0x00, /* C5 DAI2 biquad */ | ||
| 268 | 0x00, /* C6 DAI2 biquad */ | ||
| 269 | 0x00, /* C7 DAI2 biquad */ | ||
| 270 | 0x00, /* C8 DAI2 biquad */ | ||
| 271 | 0x00, /* C9 DAI2 biquad */ | ||
| 272 | 0x00, /* CA */ | ||
| 273 | 0x00, /* CB */ | ||
| 274 | 0x00, /* CC */ | ||
| 275 | 0x00, /* CD */ | ||
| 276 | 0x00, /* CE */ | ||
| 277 | 0x00, /* CF */ | ||
| 278 | |||
| 279 | 0x00, /* D0 */ | ||
| 280 | 0x00, /* D1 */ | ||
| 281 | 0x00, /* D2 */ | ||
| 282 | 0x00, /* D3 */ | ||
| 283 | 0x00, /* D4 */ | ||
| 284 | 0x00, /* D5 */ | ||
| 285 | 0x00, /* D6 */ | ||
| 286 | 0x00, /* D7 */ | ||
| 287 | 0x00, /* D8 */ | ||
| 288 | 0x00, /* D9 */ | ||
| 289 | 0x00, /* DA */ | ||
| 290 | 0x70, /* DB */ | ||
| 291 | 0x00, /* DC */ | ||
| 292 | 0x00, /* DD */ | ||
| 293 | 0x00, /* DE */ | ||
| 294 | 0x00, /* DF */ | ||
| 295 | |||
| 296 | 0x00, /* E0 */ | ||
| 297 | 0x00, /* E1 */ | ||
| 298 | 0x00, /* E2 */ | ||
| 299 | 0x00, /* E3 */ | ||
| 300 | 0x00, /* E4 */ | ||
| 301 | 0x00, /* E5 */ | ||
| 302 | 0x00, /* E6 */ | ||
| 303 | 0x00, /* E7 */ | ||
| 304 | 0x00, /* E8 */ | ||
| 305 | 0x00, /* E9 */ | ||
| 306 | 0x00, /* EA */ | ||
| 307 | 0x00, /* EB */ | ||
| 308 | 0x00, /* EC */ | ||
| 309 | 0x00, /* ED */ | ||
| 310 | 0x00, /* EE */ | ||
| 311 | 0x00, /* EF */ | ||
| 312 | |||
| 313 | 0x00, /* F0 */ | ||
| 314 | 0x00, /* F1 */ | ||
| 315 | 0x00, /* F2 */ | ||
| 316 | 0x00, /* F3 */ | ||
| 317 | 0x00, /* F4 */ | ||
| 318 | 0x00, /* F5 */ | ||
| 319 | 0x00, /* F6 */ | ||
| 320 | 0x00, /* F7 */ | ||
| 321 | 0x00, /* F8 */ | ||
| 322 | 0x00, /* F9 */ | ||
| 323 | 0x00, /* FA */ | ||
| 324 | 0x00, /* FB */ | ||
| 325 | 0x00, /* FC */ | ||
| 326 | 0x00, /* FD */ | ||
| 327 | 0x00, /* FE */ | ||
| 328 | 0x00, /* FF */ | ||
| 329 | }; | 259 | }; |
| 330 | 260 | ||
| 331 | static struct { | 261 | static struct { |
| @@ -606,11 +536,28 @@ static struct { | |||
| 606 | { 0xFF, 0x00, 1 }, /* FF */ | 536 | { 0xFF, 0x00, 1 }, /* FF */ |
| 607 | }; | 537 | }; |
| 608 | 538 | ||
| 609 | static int max98088_volatile_register(struct snd_soc_codec *codec, unsigned int reg) | 539 | static bool max98088_readable_register(struct device *dev, unsigned int reg) |
| 540 | { | ||
| 541 | return max98088_access[reg].readable; | ||
| 542 | } | ||
| 543 | |||
| 544 | static bool max98088_volatile_register(struct device *dev, unsigned int reg) | ||
| 610 | { | 545 | { |
| 611 | return max98088_access[reg].vol; | 546 | return max98088_access[reg].vol; |
| 612 | } | 547 | } |
| 613 | 548 | ||
| 549 | static const struct regmap_config max98088_regmap = { | ||
| 550 | .reg_bits = 8, | ||
| 551 | .val_bits = 8, | ||
| 552 | |||
| 553 | .readable_reg = max98088_readable_register, | ||
| 554 | .volatile_reg = max98088_volatile_register, | ||
| 555 | .max_register = 0xff, | ||
| 556 | |||
| 557 | .reg_defaults = max98088_reg, | ||
| 558 | .num_reg_defaults = ARRAY_SIZE(max98088_reg), | ||
| 559 | .cache_type = REGCACHE_RBTREE, | ||
| 560 | }; | ||
| 614 | 561 | ||
| 615 | /* | 562 | /* |
| 616 | * Load equalizer DSP coefficient configurations registers | 563 | * Load equalizer DSP coefficient configurations registers |
| @@ -1610,58 +1557,34 @@ static int max98088_dai2_digital_mute(struct snd_soc_dai *codec_dai, int mute) | |||
| 1610 | return 0; | 1557 | return 0; |
| 1611 | } | 1558 | } |
| 1612 | 1559 | ||
| 1613 | static void max98088_sync_cache(struct snd_soc_codec *codec) | ||
| 1614 | { | ||
| 1615 | u8 *reg_cache = codec->reg_cache; | ||
| 1616 | int i; | ||
| 1617 | |||
| 1618 | if (!codec->cache_sync) | ||
| 1619 | return; | ||
| 1620 | |||
| 1621 | codec->cache_only = 0; | ||
| 1622 | |||
| 1623 | /* write back cached values if they're writeable and | ||
| 1624 | * different from the hardware default. | ||
| 1625 | */ | ||
| 1626 | for (i = 1; i < codec->driver->reg_cache_size; i++) { | ||
| 1627 | if (!max98088_access[i].writable) | ||
| 1628 | continue; | ||
| 1629 | |||
| 1630 | if (reg_cache[i] == max98088_reg[i]) | ||
| 1631 | continue; | ||
| 1632 | |||
| 1633 | snd_soc_write(codec, i, reg_cache[i]); | ||
| 1634 | } | ||
| 1635 | |||
| 1636 | codec->cache_sync = 0; | ||
| 1637 | } | ||
| 1638 | |||
| 1639 | static int max98088_set_bias_level(struct snd_soc_codec *codec, | 1560 | static int max98088_set_bias_level(struct snd_soc_codec *codec, |
| 1640 | enum snd_soc_bias_level level) | 1561 | enum snd_soc_bias_level level) |
| 1641 | { | 1562 | { |
| 1642 | switch (level) { | 1563 | struct max98088_priv *max98088 = snd_soc_codec_get_drvdata(codec); |
| 1643 | case SND_SOC_BIAS_ON: | 1564 | |
| 1644 | break; | 1565 | switch (level) { |
| 1645 | 1566 | case SND_SOC_BIAS_ON: | |
| 1646 | case SND_SOC_BIAS_PREPARE: | 1567 | break; |
| 1647 | break; | 1568 | |
| 1648 | 1569 | case SND_SOC_BIAS_PREPARE: | |
| 1649 | case SND_SOC_BIAS_STANDBY: | 1570 | break; |
| 1650 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) | 1571 | |
| 1651 | max98088_sync_cache(codec); | 1572 | case SND_SOC_BIAS_STANDBY: |
| 1652 | 1573 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) | |
| 1653 | snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, | 1574 | regcache_sync(max98088->regmap); |
| 1654 | M98088_MBEN, M98088_MBEN); | 1575 | |
| 1655 | break; | 1576 | snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, |
| 1656 | 1577 | M98088_MBEN, M98088_MBEN); | |
| 1657 | case SND_SOC_BIAS_OFF: | 1578 | break; |
| 1658 | snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, | 1579 | |
| 1659 | M98088_MBEN, 0); | 1580 | case SND_SOC_BIAS_OFF: |
| 1660 | codec->cache_sync = 1; | 1581 | snd_soc_update_bits(codec, M98088_REG_4C_PWR_EN_IN, |
| 1661 | break; | 1582 | M98088_MBEN, 0); |
| 1662 | } | 1583 | regcache_mark_dirty(max98088->regmap); |
| 1663 | codec->dapm.bias_level = level; | 1584 | break; |
| 1664 | return 0; | 1585 | } |
| 1586 | codec->dapm.bias_level = level; | ||
| 1587 | return 0; | ||
| 1665 | } | 1588 | } |
| 1666 | 1589 | ||
| 1667 | #define MAX98088_RATES SNDRV_PCM_RATE_8000_96000 | 1590 | #define MAX98088_RATES SNDRV_PCM_RATE_8000_96000 |
| @@ -1988,9 +1911,9 @@ static int max98088_probe(struct snd_soc_codec *codec) | |||
| 1988 | struct max98088_cdata *cdata; | 1911 | struct max98088_cdata *cdata; |
| 1989 | int ret = 0; | 1912 | int ret = 0; |
| 1990 | 1913 | ||
| 1991 | codec->cache_sync = 1; | 1914 | regcache_mark_dirty(max98088->regmap); |
| 1992 | 1915 | ||
| 1993 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); | 1916 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); |
| 1994 | if (ret != 0) { | 1917 | if (ret != 0) { |
| 1995 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 1918 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 1996 | return ret; | 1919 | return ret; |
| @@ -2048,9 +1971,6 @@ static int max98088_probe(struct snd_soc_codec *codec) | |||
| 2048 | 1971 | ||
| 2049 | max98088_handle_pdata(codec); | 1972 | max98088_handle_pdata(codec); |
| 2050 | 1973 | ||
| 2051 | snd_soc_add_codec_controls(codec, max98088_snd_controls, | ||
| 2052 | ARRAY_SIZE(max98088_snd_controls)); | ||
| 2053 | |||
| 2054 | err_access: | 1974 | err_access: |
| 2055 | return ret; | 1975 | return ret; |
| 2056 | } | 1976 | } |
| @@ -2066,15 +1986,13 @@ static int max98088_remove(struct snd_soc_codec *codec) | |||
| 2066 | } | 1986 | } |
| 2067 | 1987 | ||
| 2068 | static struct snd_soc_codec_driver soc_codec_dev_max98088 = { | 1988 | static struct snd_soc_codec_driver soc_codec_dev_max98088 = { |
| 2069 | .probe = max98088_probe, | 1989 | .probe = max98088_probe, |
| 2070 | .remove = max98088_remove, | 1990 | .remove = max98088_remove, |
| 2071 | .suspend = max98088_suspend, | 1991 | .suspend = max98088_suspend, |
| 2072 | .resume = max98088_resume, | 1992 | .resume = max98088_resume, |
| 2073 | .set_bias_level = max98088_set_bias_level, | 1993 | .set_bias_level = max98088_set_bias_level, |
| 2074 | .reg_cache_size = ARRAY_SIZE(max98088_reg), | 1994 | .controls = max98088_snd_controls, |
| 2075 | .reg_word_size = sizeof(u8), | 1995 | .num_controls = ARRAY_SIZE(max98088_snd_controls), |
| 2076 | .reg_cache_default = max98088_reg, | ||
| 2077 | .volatile_register = max98088_volatile_register, | ||
| 2078 | .dapm_widgets = max98088_dapm_widgets, | 1996 | .dapm_widgets = max98088_dapm_widgets, |
| 2079 | .num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets), | 1997 | .num_dapm_widgets = ARRAY_SIZE(max98088_dapm_widgets), |
| 2080 | .dapm_routes = max98088_audio_map, | 1998 | .dapm_routes = max98088_audio_map, |
| @@ -2082,7 +2000,7 @@ static struct snd_soc_codec_driver soc_codec_dev_max98088 = { | |||
| 2082 | }; | 2000 | }; |
| 2083 | 2001 | ||
| 2084 | static int max98088_i2c_probe(struct i2c_client *i2c, | 2002 | static int max98088_i2c_probe(struct i2c_client *i2c, |
| 2085 | const struct i2c_device_id *id) | 2003 | const struct i2c_device_id *id) |
| 2086 | { | 2004 | { |
| 2087 | struct max98088_priv *max98088; | 2005 | struct max98088_priv *max98088; |
| 2088 | int ret; | 2006 | int ret; |
| @@ -2092,6 +2010,10 @@ static int max98088_i2c_probe(struct i2c_client *i2c, | |||
| 2092 | if (max98088 == NULL) | 2010 | if (max98088 == NULL) |
| 2093 | return -ENOMEM; | 2011 | return -ENOMEM; |
| 2094 | 2012 | ||
| 2013 | max98088->regmap = devm_regmap_init_i2c(i2c, &max98088_regmap); | ||
| 2014 | if (IS_ERR(max98088->regmap)) | ||
| 2015 | return PTR_ERR(max98088->regmap); | ||
| 2016 | |||
| 2095 | max98088->devtype = id->driver_data; | 2017 | max98088->devtype = id->driver_data; |
| 2096 | 2018 | ||
| 2097 | i2c_set_clientdata(i2c, max98088); | 2019 | i2c_set_clientdata(i2c, max98088); |
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c index 8dbcacd44e6a..8fb072455802 100644 --- a/sound/soc/codecs/max98095.c +++ b/sound/soc/codecs/max98095.c | |||
| @@ -39,6 +39,7 @@ struct max98095_cdata { | |||
| 39 | }; | 39 | }; |
| 40 | 40 | ||
| 41 | struct max98095_priv { | 41 | struct max98095_priv { |
| 42 | struct regmap *regmap; | ||
| 42 | enum max98095_type devtype; | 43 | enum max98095_type devtype; |
| 43 | struct max98095_pdata *pdata; | 44 | struct max98095_pdata *pdata; |
| 44 | unsigned int sysclk; | 45 | unsigned int sysclk; |
| @@ -56,263 +57,145 @@ struct max98095_priv { | |||
| 56 | struct snd_soc_jack *mic_jack; | 57 | struct snd_soc_jack *mic_jack; |
| 57 | }; | 58 | }; |
| 58 | 59 | ||
| 59 | static const u8 max98095_reg_def[M98095_REG_CNT] = { | 60 | static const struct reg_default max98095_reg_def[] = { |
| 60 | 0x00, /* 00 */ | 61 | { 0xf, 0x00 }, /* 0F */ |
| 61 | 0x00, /* 01 */ | 62 | { 0x10, 0x00 }, /* 10 */ |
| 62 | 0x00, /* 02 */ | 63 | { 0x11, 0x00 }, /* 11 */ |
| 63 | 0x00, /* 03 */ | 64 | { 0x12, 0x00 }, /* 12 */ |
| 64 | 0x00, /* 04 */ | 65 | { 0x13, 0x00 }, /* 13 */ |
| 65 | 0x00, /* 05 */ | 66 | { 0x14, 0x00 }, /* 14 */ |
| 66 | 0x00, /* 06 */ | 67 | { 0x15, 0x00 }, /* 15 */ |
| 67 | 0x00, /* 07 */ | 68 | { 0x16, 0x00 }, /* 16 */ |
| 68 | 0x00, /* 08 */ | 69 | { 0x17, 0x00 }, /* 17 */ |
| 69 | 0x00, /* 09 */ | 70 | { 0x18, 0x00 }, /* 18 */ |
| 70 | 0x00, /* 0A */ | 71 | { 0x19, 0x00 }, /* 19 */ |
| 71 | 0x00, /* 0B */ | 72 | { 0x1a, 0x00 }, /* 1A */ |
| 72 | 0x00, /* 0C */ | 73 | { 0x1b, 0x00 }, /* 1B */ |
| 73 | 0x00, /* 0D */ | 74 | { 0x1c, 0x00 }, /* 1C */ |
| 74 | 0x00, /* 0E */ | 75 | { 0x1d, 0x00 }, /* 1D */ |
| 75 | 0x00, /* 0F */ | 76 | { 0x1e, 0x00 }, /* 1E */ |
| 76 | 0x00, /* 10 */ | 77 | { 0x1f, 0x00 }, /* 1F */ |
| 77 | 0x00, /* 11 */ | 78 | { 0x20, 0x00 }, /* 20 */ |
| 78 | 0x00, /* 12 */ | 79 | { 0x21, 0x00 }, /* 21 */ |
| 79 | 0x00, /* 13 */ | 80 | { 0x22, 0x00 }, /* 22 */ |
| 80 | 0x00, /* 14 */ | 81 | { 0x23, 0x00 }, /* 23 */ |
| 81 | 0x00, /* 15 */ | 82 | { 0x24, 0x00 }, /* 24 */ |
| 82 | 0x00, /* 16 */ | 83 | { 0x25, 0x00 }, /* 25 */ |
| 83 | 0x00, /* 17 */ | 84 | { 0x26, 0x00 }, /* 26 */ |
| 84 | 0x00, /* 18 */ | 85 | { 0x27, 0x00 }, /* 27 */ |
| 85 | 0x00, /* 19 */ | 86 | { 0x28, 0x00 }, /* 28 */ |
| 86 | 0x00, /* 1A */ | 87 | { 0x29, 0x00 }, /* 29 */ |
| 87 | 0x00, /* 1B */ | 88 | { 0x2a, 0x00 }, /* 2A */ |
| 88 | 0x00, /* 1C */ | 89 | { 0x2b, 0x00 }, /* 2B */ |
| 89 | 0x00, /* 1D */ | 90 | { 0x2c, 0x00 }, /* 2C */ |
| 90 | 0x00, /* 1E */ | 91 | { 0x2d, 0x00 }, /* 2D */ |
| 91 | 0x00, /* 1F */ | 92 | { 0x2e, 0x00 }, /* 2E */ |
| 92 | 0x00, /* 20 */ | 93 | { 0x2f, 0x00 }, /* 2F */ |
| 93 | 0x00, /* 21 */ | 94 | { 0x30, 0x00 }, /* 30 */ |
| 94 | 0x00, /* 22 */ | 95 | { 0x31, 0x00 }, /* 31 */ |
| 95 | 0x00, /* 23 */ | 96 | { 0x32, 0x00 }, /* 32 */ |
| 96 | 0x00, /* 24 */ | 97 | { 0x33, 0x00 }, /* 33 */ |
| 97 | 0x00, /* 25 */ | 98 | { 0x34, 0x00 }, /* 34 */ |
| 98 | 0x00, /* 26 */ | 99 | { 0x35, 0x00 }, /* 35 */ |
| 99 | 0x00, /* 27 */ | 100 | { 0x36, 0x00 }, /* 36 */ |
| 100 | 0x00, /* 28 */ | 101 | { 0x37, 0x00 }, /* 37 */ |
| 101 | 0x00, /* 29 */ | 102 | { 0x38, 0x00 }, /* 38 */ |
| 102 | 0x00, /* 2A */ | 103 | { 0x39, 0x00 }, /* 39 */ |
| 103 | 0x00, /* 2B */ | 104 | { 0x3a, 0x00 }, /* 3A */ |
| 104 | 0x00, /* 2C */ | 105 | { 0x3b, 0x00 }, /* 3B */ |
| 105 | 0x00, /* 2D */ | 106 | { 0x3c, 0x00 }, /* 3C */ |
| 106 | 0x00, /* 2E */ | 107 | { 0x3d, 0x00 }, /* 3D */ |
| 107 | 0x00, /* 2F */ | 108 | { 0x3e, 0x00 }, /* 3E */ |
| 108 | 0x00, /* 30 */ | 109 | { 0x3f, 0x00 }, /* 3F */ |
| 109 | 0x00, /* 31 */ | 110 | { 0x40, 0x00 }, /* 40 */ |
| 110 | 0x00, /* 32 */ | 111 | { 0x41, 0x00 }, /* 41 */ |
| 111 | 0x00, /* 33 */ | 112 | { 0x42, 0x00 }, /* 42 */ |
| 112 | 0x00, /* 34 */ | 113 | { 0x43, 0x00 }, /* 43 */ |
| 113 | 0x00, /* 35 */ | 114 | { 0x44, 0x00 }, /* 44 */ |
| 114 | 0x00, /* 36 */ | 115 | { 0x45, 0x00 }, /* 45 */ |
| 115 | 0x00, /* 37 */ | 116 | { 0x46, 0x00 }, /* 46 */ |
| 116 | 0x00, /* 38 */ | 117 | { 0x47, 0x00 }, /* 47 */ |
| 117 | 0x00, /* 39 */ | 118 | { 0x48, 0x00 }, /* 48 */ |
| 118 | 0x00, /* 3A */ | 119 | { 0x49, 0x00 }, /* 49 */ |
| 119 | 0x00, /* 3B */ | 120 | { 0x4a, 0x00 }, /* 4A */ |
| 120 | 0x00, /* 3C */ | 121 | { 0x4b, 0x00 }, /* 4B */ |
| 121 | 0x00, /* 3D */ | 122 | { 0x4c, 0x00 }, /* 4C */ |
| 122 | 0x00, /* 3E */ | 123 | { 0x4d, 0x00 }, /* 4D */ |
| 123 | 0x00, /* 3F */ | 124 | { 0x4e, 0x00 }, /* 4E */ |
| 124 | 0x00, /* 40 */ | 125 | { 0x4f, 0x00 }, /* 4F */ |
| 125 | 0x00, /* 41 */ | 126 | { 0x50, 0x00 }, /* 50 */ |
| 126 | 0x00, /* 42 */ | 127 | { 0x51, 0x00 }, /* 51 */ |
| 127 | 0x00, /* 43 */ | 128 | { 0x52, 0x00 }, /* 52 */ |
| 128 | 0x00, /* 44 */ | 129 | { 0x53, 0x00 }, /* 53 */ |
| 129 | 0x00, /* 45 */ | 130 | { 0x54, 0x00 }, /* 54 */ |
| 130 | 0x00, /* 46 */ | 131 | { 0x55, 0x00 }, /* 55 */ |
| 131 | 0x00, /* 47 */ | 132 | { 0x56, 0x00 }, /* 56 */ |
| 132 | 0x00, /* 48 */ | 133 | { 0x57, 0x00 }, /* 57 */ |
| 133 | 0x00, /* 49 */ | 134 | { 0x58, 0x00 }, /* 58 */ |
| 134 | 0x00, /* 4A */ | 135 | { 0x59, 0x00 }, /* 59 */ |
| 135 | 0x00, /* 4B */ | 136 | { 0x5a, 0x00 }, /* 5A */ |
| 136 | 0x00, /* 4C */ | 137 | { 0x5b, 0x00 }, /* 5B */ |
| 137 | 0x00, /* 4D */ | 138 | { 0x5c, 0x00 }, /* 5C */ |
| 138 | 0x00, /* 4E */ | 139 | { 0x5d, 0x00 }, /* 5D */ |
| 139 | 0x00, /* 4F */ | 140 | { 0x5e, 0x00 }, /* 5E */ |
| 140 | 0x00, /* 50 */ | 141 | { 0x5f, 0x00 }, /* 5F */ |
| 141 | 0x00, /* 51 */ | 142 | { 0x60, 0x00 }, /* 60 */ |
| 142 | 0x00, /* 52 */ | 143 | { 0x61, 0x00 }, /* 61 */ |
| 143 | 0x00, /* 53 */ | 144 | { 0x62, 0x00 }, /* 62 */ |
| 144 | 0x00, /* 54 */ | 145 | { 0x63, 0x00 }, /* 63 */ |
| 145 | 0x00, /* 55 */ | 146 | { 0x64, 0x00 }, /* 64 */ |
| 146 | 0x00, /* 56 */ | 147 | { 0x65, 0x00 }, /* 65 */ |
| 147 | 0x00, /* 57 */ | 148 | { 0x66, 0x00 }, /* 66 */ |
| 148 | 0x00, /* 58 */ | 149 | { 0x67, 0x00 }, /* 67 */ |
| 149 | 0x00, /* 59 */ | 150 | { 0x68, 0x00 }, /* 68 */ |
| 150 | 0x00, /* 5A */ | 151 | { 0x69, 0x00 }, /* 69 */ |
| 151 | 0x00, /* 5B */ | 152 | { 0x6a, 0x00 }, /* 6A */ |
| 152 | 0x00, /* 5C */ | 153 | { 0x6b, 0x00 }, /* 6B */ |
| 153 | 0x00, /* 5D */ | 154 | { 0x6c, 0x00 }, /* 6C */ |
| 154 | 0x00, /* 5E */ | 155 | { 0x6d, 0x00 }, /* 6D */ |
| 155 | 0x00, /* 5F */ | 156 | { 0x6e, 0x00 }, /* 6E */ |
| 156 | 0x00, /* 60 */ | 157 | { 0x6f, 0x00 }, /* 6F */ |
| 157 | 0x00, /* 61 */ | 158 | { 0x70, 0x00 }, /* 70 */ |
| 158 | 0x00, /* 62 */ | 159 | { 0x71, 0x00 }, /* 71 */ |
| 159 | 0x00, /* 63 */ | 160 | { 0x72, 0x00 }, /* 72 */ |
| 160 | 0x00, /* 64 */ | 161 | { 0x73, 0x00 }, /* 73 */ |
| 161 | 0x00, /* 65 */ | 162 | { 0x74, 0x00 }, /* 74 */ |
| 162 | 0x00, /* 66 */ | 163 | { 0x75, 0x00 }, /* 75 */ |
| 163 | 0x00, /* 67 */ | 164 | { 0x76, 0x00 }, /* 76 */ |
| 164 | 0x00, /* 68 */ | 165 | { 0x77, 0x00 }, /* 77 */ |
| 165 | 0x00, /* 69 */ | 166 | { 0x78, 0x00 }, /* 78 */ |
| 166 | 0x00, /* 6A */ | 167 | { 0x79, 0x00 }, /* 79 */ |
| 167 | 0x00, /* 6B */ | 168 | { 0x7a, 0x00 }, /* 7A */ |
| 168 | 0x00, /* 6C */ | 169 | { 0x7b, 0x00 }, /* 7B */ |
| 169 | 0x00, /* 6D */ | 170 | { 0x7c, 0x00 }, /* 7C */ |
| 170 | 0x00, /* 6E */ | 171 | { 0x7d, 0x00 }, /* 7D */ |
| 171 | 0x00, /* 6F */ | 172 | { 0x7e, 0x00 }, /* 7E */ |
| 172 | 0x00, /* 70 */ | 173 | { 0x7f, 0x00 }, /* 7F */ |
| 173 | 0x00, /* 71 */ | 174 | { 0x80, 0x00 }, /* 80 */ |
| 174 | 0x00, /* 72 */ | 175 | { 0x81, 0x00 }, /* 81 */ |
| 175 | 0x00, /* 73 */ | 176 | { 0x82, 0x00 }, /* 82 */ |
| 176 | 0x00, /* 74 */ | 177 | { 0x83, 0x00 }, /* 83 */ |
| 177 | 0x00, /* 75 */ | 178 | { 0x84, 0x00 }, /* 84 */ |
| 178 | 0x00, /* 76 */ | 179 | { 0x85, 0x00 }, /* 85 */ |
| 179 | 0x00, /* 77 */ | 180 | { 0x86, 0x00 }, /* 86 */ |
| 180 | 0x00, /* 78 */ | 181 | { 0x87, 0x00 }, /* 87 */ |
| 181 | 0x00, /* 79 */ | 182 | { 0x88, 0x00 }, /* 88 */ |
| 182 | 0x00, /* 7A */ | 183 | { 0x89, 0x00 }, /* 89 */ |
| 183 | 0x00, /* 7B */ | 184 | { 0x8a, 0x00 }, /* 8A */ |
| 184 | 0x00, /* 7C */ | 185 | { 0x8b, 0x00 }, /* 8B */ |
| 185 | 0x00, /* 7D */ | 186 | { 0x8c, 0x00 }, /* 8C */ |
| 186 | 0x00, /* 7E */ | 187 | { 0x8d, 0x00 }, /* 8D */ |
| 187 | 0x00, /* 7F */ | 188 | { 0x8e, 0x00 }, /* 8E */ |
| 188 | 0x00, /* 80 */ | 189 | { 0x8f, 0x00 }, /* 8F */ |
| 189 | 0x00, /* 81 */ | 190 | { 0x90, 0x00 }, /* 90 */ |
| 190 | 0x00, /* 82 */ | 191 | { 0x91, 0x00 }, /* 91 */ |
| 191 | 0x00, /* 83 */ | 192 | { 0x92, 0x30 }, /* 92 */ |
| 192 | 0x00, /* 84 */ | 193 | { 0x93, 0xF0 }, /* 93 */ |
| 193 | 0x00, /* 85 */ | 194 | { 0x94, 0x00 }, /* 94 */ |
| 194 | 0x00, /* 86 */ | 195 | { 0x95, 0x00 }, /* 95 */ |
| 195 | 0x00, /* 87 */ | 196 | { 0x96, 0x3F }, /* 96 */ |
| 196 | 0x00, /* 88 */ | 197 | { 0x97, 0x00 }, /* 97 */ |
| 197 | 0x00, /* 89 */ | 198 | { 0xff, 0x00 }, /* FF */ |
| 198 | 0x00, /* 8A */ | ||
| 199 | 0x00, /* 8B */ | ||
| 200 | 0x00, /* 8C */ | ||
| 201 | 0x00, /* 8D */ | ||
| 202 | 0x00, /* 8E */ | ||
| 203 | 0x00, /* 8F */ | ||
| 204 | 0x00, /* 90 */ | ||
| 205 | 0x00, /* 91 */ | ||
| 206 | 0x30, /* 92 */ | ||
| 207 | 0xF0, /* 93 */ | ||
| 208 | 0x00, /* 94 */ | ||
| 209 | 0x00, /* 95 */ | ||
| 210 | 0x3F, /* 96 */ | ||
| 211 | 0x00, /* 97 */ | ||
| 212 | 0x00, /* 98 */ | ||
| 213 | 0x00, /* 99 */ | ||
| 214 | 0x00, /* 9A */ | ||
| 215 | 0x00, /* 9B */ | ||
| 216 | 0x00, /* 9C */ | ||
| 217 | 0x00, /* 9D */ | ||
| 218 | 0x00, /* 9E */ | ||
| 219 | 0x00, /* 9F */ | ||
| 220 | 0x00, /* A0 */ | ||
| 221 | 0x00, /* A1 */ | ||
| 222 | 0x00, /* A2 */ | ||
| 223 | 0x00, /* A3 */ | ||
| 224 | 0x00, /* A4 */ | ||
| 225 | 0x00, /* A5 */ | ||
| 226 | 0x00, /* A6 */ | ||
| 227 | 0x00, /* A7 */ | ||
| 228 | 0x00, /* A8 */ | ||
| 229 | 0x00, /* A9 */ | ||
| 230 | 0x00, /* AA */ | ||
| 231 | 0x00, /* AB */ | ||
| 232 | 0x00, /* AC */ | ||
| 233 | 0x00, /* AD */ | ||
| 234 | 0x00, /* AE */ | ||
| 235 | 0x00, /* AF */ | ||
| 236 | 0x00, /* B0 */ | ||
| 237 | 0x00, /* B1 */ | ||
| 238 | 0x00, /* B2 */ | ||
| 239 | 0x00, /* B3 */ | ||
| 240 | 0x00, /* B4 */ | ||
| 241 | 0x00, /* B5 */ | ||
| 242 | 0x00, /* B6 */ | ||
| 243 | 0x00, /* B7 */ | ||
| 244 | 0x00, /* B8 */ | ||
| 245 | 0x00, /* B9 */ | ||
| 246 | 0x00, /* BA */ | ||
| 247 | 0x00, /* BB */ | ||
| 248 | 0x00, /* BC */ | ||
| 249 | 0x00, /* BD */ | ||
| 250 | 0x00, /* BE */ | ||
| 251 | 0x00, /* BF */ | ||
| 252 | 0x00, /* C0 */ | ||
| 253 | 0x00, /* C1 */ | ||
| 254 | 0x00, /* C2 */ | ||
| 255 | 0x00, /* C3 */ | ||
| 256 | 0x00, /* C4 */ | ||
| 257 | 0x00, /* C5 */ | ||
| 258 | 0x00, /* C6 */ | ||
| 259 | 0x00, /* C7 */ | ||
| 260 | 0x00, /* C8 */ | ||
| 261 | 0x00, /* C9 */ | ||
| 262 | 0x00, /* CA */ | ||
| 263 | 0x00, /* CB */ | ||
| 264 | 0x00, /* CC */ | ||
| 265 | 0x00, /* CD */ | ||
| 266 | 0x00, /* CE */ | ||
| 267 | 0x00, /* CF */ | ||
| 268 | 0x00, /* D0 */ | ||
| 269 | 0x00, /* D1 */ | ||
| 270 | 0x00, /* D2 */ | ||
| 271 | 0x00, /* D3 */ | ||
| 272 | 0x00, /* D4 */ | ||
| 273 | 0x00, /* D5 */ | ||
| 274 | 0x00, /* D6 */ | ||
| 275 | 0x00, /* D7 */ | ||
| 276 | 0x00, /* D8 */ | ||
| 277 | 0x00, /* D9 */ | ||
| 278 | 0x00, /* DA */ | ||
| 279 | 0x00, /* DB */ | ||
| 280 | 0x00, /* DC */ | ||
| 281 | 0x00, /* DD */ | ||
| 282 | 0x00, /* DE */ | ||
| 283 | 0x00, /* DF */ | ||
| 284 | 0x00, /* E0 */ | ||
| 285 | 0x00, /* E1 */ | ||
| 286 | 0x00, /* E2 */ | ||
| 287 | 0x00, /* E3 */ | ||
| 288 | 0x00, /* E4 */ | ||
| 289 | 0x00, /* E5 */ | ||
| 290 | 0x00, /* E6 */ | ||
| 291 | 0x00, /* E7 */ | ||
| 292 | 0x00, /* E8 */ | ||
| 293 | 0x00, /* E9 */ | ||
| 294 | 0x00, /* EA */ | ||
| 295 | 0x00, /* EB */ | ||
| 296 | 0x00, /* EC */ | ||
| 297 | 0x00, /* ED */ | ||
| 298 | 0x00, /* EE */ | ||
| 299 | 0x00, /* EF */ | ||
| 300 | 0x00, /* F0 */ | ||
| 301 | 0x00, /* F1 */ | ||
| 302 | 0x00, /* F2 */ | ||
| 303 | 0x00, /* F3 */ | ||
| 304 | 0x00, /* F4 */ | ||
| 305 | 0x00, /* F5 */ | ||
| 306 | 0x00, /* F6 */ | ||
| 307 | 0x00, /* F7 */ | ||
| 308 | 0x00, /* F8 */ | ||
| 309 | 0x00, /* F9 */ | ||
| 310 | 0x00, /* FA */ | ||
| 311 | 0x00, /* FB */ | ||
| 312 | 0x00, /* FC */ | ||
| 313 | 0x00, /* FD */ | ||
| 314 | 0x00, /* FE */ | ||
| 315 | 0x00, /* FF */ | ||
| 316 | }; | 199 | }; |
| 317 | 200 | ||
| 318 | static struct { | 201 | static struct { |
| @@ -577,14 +460,14 @@ static struct { | |||
| 577 | { 0xFF, 0x00 }, /* FF */ | 460 | { 0xFF, 0x00 }, /* FF */ |
| 578 | }; | 461 | }; |
| 579 | 462 | ||
| 580 | static int max98095_readable(struct snd_soc_codec *codec, unsigned int reg) | 463 | static bool max98095_readable(struct device *dev, unsigned int reg) |
| 581 | { | 464 | { |
| 582 | if (reg >= M98095_REG_CNT) | 465 | if (reg >= M98095_REG_CNT) |
| 583 | return 0; | 466 | return 0; |
| 584 | return max98095_access[reg].readable != 0; | 467 | return max98095_access[reg].readable != 0; |
| 585 | } | 468 | } |
| 586 | 469 | ||
| 587 | static int max98095_volatile(struct snd_soc_codec *codec, unsigned int reg) | 470 | static bool max98095_volatile(struct device *dev, unsigned int reg) |
| 588 | { | 471 | { |
| 589 | if (reg > M98095_REG_MAX_CACHED) | 472 | if (reg > M98095_REG_MAX_CACHED) |
| 590 | return 1; | 473 | return 1; |
| @@ -611,22 +494,18 @@ static int max98095_volatile(struct snd_soc_codec *codec, unsigned int reg) | |||
| 611 | return 0; | 494 | return 0; |
| 612 | } | 495 | } |
| 613 | 496 | ||
| 614 | /* | 497 | static const struct regmap_config max98095_regmap = { |
| 615 | * Filter coefficients are in a separate register segment | 498 | .reg_bits = 8, |
| 616 | * and they share the address space of the normal registers. | 499 | .val_bits = 8, |
| 617 | * The coefficient registers do not need or share the cache. | ||
| 618 | */ | ||
| 619 | static int max98095_hw_write(struct snd_soc_codec *codec, unsigned int reg, | ||
| 620 | unsigned int value) | ||
| 621 | { | ||
| 622 | int ret; | ||
| 623 | 500 | ||
| 624 | codec->cache_bypass = 1; | 501 | .reg_defaults = max98095_reg_def, |
| 625 | ret = snd_soc_write(codec, reg, value); | 502 | .num_reg_defaults = ARRAY_SIZE(max98095_reg_def), |
| 626 | codec->cache_bypass = 0; | 503 | .max_register = M98095_0FF_REV_ID, |
| 504 | .cache_type = REGCACHE_RBTREE, | ||
| 627 | 505 | ||
| 628 | return ret ? -EIO : 0; | 506 | .readable_reg = max98095_readable, |
| 629 | } | 507 | .volatile_reg = max98095_volatile, |
| 508 | }; | ||
| 630 | 509 | ||
| 631 | /* | 510 | /* |
| 632 | * Load equalizer DSP coefficient configurations registers | 511 | * Load equalizer DSP coefficient configurations registers |
| @@ -648,8 +527,8 @@ static void m98095_eq_band(struct snd_soc_codec *codec, unsigned int dai, | |||
| 648 | 527 | ||
| 649 | /* Step through the registers and coefs */ | 528 | /* Step through the registers and coefs */ |
| 650 | for (i = 0; i < M98095_COEFS_PER_BAND; i++) { | 529 | for (i = 0; i < M98095_COEFS_PER_BAND; i++) { |
| 651 | max98095_hw_write(codec, eq_reg++, M98095_BYTE1(coefs[i])); | 530 | snd_soc_write(codec, eq_reg++, M98095_BYTE1(coefs[i])); |
| 652 | max98095_hw_write(codec, eq_reg++, M98095_BYTE0(coefs[i])); | 531 | snd_soc_write(codec, eq_reg++, M98095_BYTE0(coefs[i])); |
| 653 | } | 532 | } |
| 654 | } | 533 | } |
| 655 | 534 | ||
| @@ -673,8 +552,8 @@ static void m98095_biquad_band(struct snd_soc_codec *codec, unsigned int dai, | |||
| 673 | 552 | ||
| 674 | /* Step through the registers and coefs */ | 553 | /* Step through the registers and coefs */ |
| 675 | for (i = 0; i < M98095_COEFS_PER_BAND; i++) { | 554 | for (i = 0; i < M98095_COEFS_PER_BAND; i++) { |
| 676 | max98095_hw_write(codec, bq_reg++, M98095_BYTE1(coefs[i])); | 555 | snd_soc_write(codec, bq_reg++, M98095_BYTE1(coefs[i])); |
| 677 | max98095_hw_write(codec, bq_reg++, M98095_BYTE0(coefs[i])); | 556 | snd_soc_write(codec, bq_reg++, M98095_BYTE0(coefs[i])); |
| 678 | } | 557 | } |
| 679 | } | 558 | } |
| 680 | 559 | ||
| @@ -1285,14 +1164,6 @@ static const struct snd_soc_dapm_route max98095_audio_map[] = { | |||
| 1285 | {"MIC2 Input", NULL, "MIC2"}, | 1164 | {"MIC2 Input", NULL, "MIC2"}, |
| 1286 | }; | 1165 | }; |
| 1287 | 1166 | ||
| 1288 | static int max98095_add_widgets(struct snd_soc_codec *codec) | ||
| 1289 | { | ||
| 1290 | snd_soc_add_codec_controls(codec, max98095_snd_controls, | ||
| 1291 | ARRAY_SIZE(max98095_snd_controls)); | ||
| 1292 | |||
| 1293 | return 0; | ||
| 1294 | } | ||
| 1295 | |||
| 1296 | /* codec mclk clock divider coefficients */ | 1167 | /* codec mclk clock divider coefficients */ |
| 1297 | static const struct { | 1168 | static const struct { |
| 1298 | u32 rate; | 1169 | u32 rate; |
| @@ -1748,6 +1619,7 @@ static int max98095_dai3_set_fmt(struct snd_soc_dai *codec_dai, | |||
| 1748 | static int max98095_set_bias_level(struct snd_soc_codec *codec, | 1619 | static int max98095_set_bias_level(struct snd_soc_codec *codec, |
| 1749 | enum snd_soc_bias_level level) | 1620 | enum snd_soc_bias_level level) |
| 1750 | { | 1621 | { |
| 1622 | struct max98095_priv *max98095 = snd_soc_codec_get_drvdata(codec); | ||
| 1751 | int ret; | 1623 | int ret; |
| 1752 | 1624 | ||
| 1753 | switch (level) { | 1625 | switch (level) { |
| @@ -1759,7 +1631,7 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, | |||
| 1759 | 1631 | ||
| 1760 | case SND_SOC_BIAS_STANDBY: | 1632 | case SND_SOC_BIAS_STANDBY: |
| 1761 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 1633 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
| 1762 | ret = snd_soc_cache_sync(codec); | 1634 | ret = regcache_sync(max98095->regmap); |
| 1763 | 1635 | ||
| 1764 | if (ret != 0) { | 1636 | if (ret != 0) { |
| 1765 | dev_err(codec->dev, "Failed to sync cache: %d\n", ret); | 1637 | dev_err(codec->dev, "Failed to sync cache: %d\n", ret); |
| @@ -1774,7 +1646,7 @@ static int max98095_set_bias_level(struct snd_soc_codec *codec, | |||
| 1774 | case SND_SOC_BIAS_OFF: | 1646 | case SND_SOC_BIAS_OFF: |
| 1775 | snd_soc_update_bits(codec, M98095_090_PWR_EN_IN, | 1647 | snd_soc_update_bits(codec, M98095_090_PWR_EN_IN, |
| 1776 | M98095_MBEN, 0); | 1648 | M98095_MBEN, 0); |
| 1777 | codec->cache_sync = 1; | 1649 | regcache_mark_dirty(max98095->regmap); |
| 1778 | break; | 1650 | break; |
| 1779 | } | 1651 | } |
| 1780 | codec->dapm.bias_level = level; | 1652 | codec->dapm.bias_level = level; |
| @@ -2341,7 +2213,7 @@ static int max98095_reset(struct snd_soc_codec *codec) | |||
| 2341 | /* Reset to hardware default for registers, as there is not | 2213 | /* Reset to hardware default for registers, as there is not |
| 2342 | * a soft reset hardware control register */ | 2214 | * a soft reset hardware control register */ |
| 2343 | for (i = M98095_010_HOST_INT_CFG; i < M98095_REG_MAX_CACHED; i++) { | 2215 | for (i = M98095_010_HOST_INT_CFG; i < M98095_REG_MAX_CACHED; i++) { |
| 2344 | ret = snd_soc_write(codec, i, max98095_reg_def[i]); | 2216 | ret = snd_soc_write(codec, i, snd_soc_read(codec, i)); |
| 2345 | if (ret < 0) { | 2217 | if (ret < 0) { |
| 2346 | dev_err(codec->dev, "Failed to reset: %d\n", ret); | 2218 | dev_err(codec->dev, "Failed to reset: %d\n", ret); |
| 2347 | return ret; | 2219 | return ret; |
| @@ -2358,7 +2230,7 @@ static int max98095_probe(struct snd_soc_codec *codec) | |||
| 2358 | struct i2c_client *client; | 2230 | struct i2c_client *client; |
| 2359 | int ret = 0; | 2231 | int ret = 0; |
| 2360 | 2232 | ||
| 2361 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); | 2233 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); |
| 2362 | if (ret != 0) { | 2234 | if (ret != 0) { |
| 2363 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 2235 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 2364 | return ret; | 2236 | return ret; |
| @@ -2447,8 +2319,6 @@ static int max98095_probe(struct snd_soc_codec *codec) | |||
| 2447 | snd_soc_update_bits(codec, M98095_097_PWR_SYS, M98095_SHDNRUN, | 2319 | snd_soc_update_bits(codec, M98095_097_PWR_SYS, M98095_SHDNRUN, |
| 2448 | M98095_SHDNRUN); | 2320 | M98095_SHDNRUN); |
| 2449 | 2321 | ||
| 2450 | max98095_add_widgets(codec); | ||
| 2451 | |||
| 2452 | return 0; | 2322 | return 0; |
| 2453 | 2323 | ||
| 2454 | err_irq: | 2324 | err_irq: |
| @@ -2480,11 +2350,8 @@ static struct snd_soc_codec_driver soc_codec_dev_max98095 = { | |||
| 2480 | .suspend = max98095_suspend, | 2350 | .suspend = max98095_suspend, |
| 2481 | .resume = max98095_resume, | 2351 | .resume = max98095_resume, |
| 2482 | .set_bias_level = max98095_set_bias_level, | 2352 | .set_bias_level = max98095_set_bias_level, |
| 2483 | .reg_cache_size = ARRAY_SIZE(max98095_reg_def), | 2353 | .controls = max98095_snd_controls, |
| 2484 | .reg_word_size = sizeof(u8), | 2354 | .num_controls = ARRAY_SIZE(max98095_snd_controls), |
| 2485 | .reg_cache_default = max98095_reg_def, | ||
| 2486 | .readable_register = max98095_readable, | ||
| 2487 | .volatile_register = max98095_volatile, | ||
| 2488 | .dapm_widgets = max98095_dapm_widgets, | 2355 | .dapm_widgets = max98095_dapm_widgets, |
| 2489 | .num_dapm_widgets = ARRAY_SIZE(max98095_dapm_widgets), | 2356 | .num_dapm_widgets = ARRAY_SIZE(max98095_dapm_widgets), |
| 2490 | .dapm_routes = max98095_audio_map, | 2357 | .dapm_routes = max98095_audio_map, |
| @@ -2502,6 +2369,13 @@ static int max98095_i2c_probe(struct i2c_client *i2c, | |||
| 2502 | if (max98095 == NULL) | 2369 | if (max98095 == NULL) |
| 2503 | return -ENOMEM; | 2370 | return -ENOMEM; |
| 2504 | 2371 | ||
| 2372 | max98095->regmap = devm_regmap_init_i2c(i2c, &max98095_regmap); | ||
| 2373 | if (IS_ERR(max98095->regmap)) { | ||
| 2374 | ret = PTR_ERR(max98095->regmap); | ||
| 2375 | dev_err(&i2c->dev, "Failed to allocate regmap: %d\n", ret); | ||
| 2376 | return ret; | ||
| 2377 | } | ||
| 2378 | |||
| 2505 | max98095->devtype = id->driver_data; | 2379 | max98095->devtype = id->driver_data; |
| 2506 | i2c_set_clientdata(i2c, max98095); | 2380 | i2c_set_clientdata(i2c, max98095); |
| 2507 | max98095->pdata = i2c->dev.platform_data; | 2381 | max98095->pdata = i2c->dev.platform_data; |
diff --git a/sound/soc/codecs/max9850.c b/sound/soc/codecs/max9850.c index 58c38a5b481c..c5dd61785f8d 100644 --- a/sound/soc/codecs/max9850.c +++ b/sound/soc/codecs/max9850.c | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
| 19 | #include <linux/init.h> | 19 | #include <linux/init.h> |
| 20 | #include <linux/i2c.h> | 20 | #include <linux/i2c.h> |
| 21 | #include <linux/regmap.h> | ||
| 21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
| 22 | #include <sound/pcm.h> | 23 | #include <sound/pcm.h> |
| 23 | #include <sound/pcm_params.h> | 24 | #include <sound/pcm_params.h> |
| @@ -27,18 +28,26 @@ | |||
| 27 | #include "max9850.h" | 28 | #include "max9850.h" |
| 28 | 29 | ||
| 29 | struct max9850_priv { | 30 | struct max9850_priv { |
| 31 | struct regmap *regmap; | ||
| 30 | unsigned int sysclk; | 32 | unsigned int sysclk; |
| 31 | }; | 33 | }; |
| 32 | 34 | ||
| 33 | /* max9850 register cache */ | 35 | /* max9850 register cache */ |
| 34 | static const u8 max9850_reg[MAX9850_CACHEREGNUM] = { | 36 | static const struct reg_default max9850_reg[] = { |
| 35 | 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | 37 | { 2, 0x0c }, |
| 38 | { 3, 0x00 }, | ||
| 39 | { 4, 0x00 }, | ||
| 40 | { 5, 0x00 }, | ||
| 41 | { 6, 0x00 }, | ||
| 42 | { 7, 0x00 }, | ||
| 43 | { 8, 0x00 }, | ||
| 44 | { 9, 0x00 }, | ||
| 45 | { 10, 0x00 }, | ||
| 36 | }; | 46 | }; |
| 37 | 47 | ||
| 38 | /* these registers are not used at the moment but provided for the sake of | 48 | /* these registers are not used at the moment but provided for the sake of |
| 39 | * completeness */ | 49 | * completeness */ |
| 40 | static int max9850_volatile_register(struct snd_soc_codec *codec, | 50 | static bool max9850_volatile_register(struct device *dev, unsigned int reg) |
| 41 | unsigned int reg) | ||
| 42 | { | 51 | { |
| 43 | switch (reg) { | 52 | switch (reg) { |
| 44 | case MAX9850_STATUSA: | 53 | case MAX9850_STATUSA: |
| @@ -49,6 +58,15 @@ static int max9850_volatile_register(struct snd_soc_codec *codec, | |||
| 49 | } | 58 | } |
| 50 | } | 59 | } |
| 51 | 60 | ||
| 61 | static const struct regmap_config max9850_regmap = { | ||
| 62 | .reg_bits = 8, | ||
| 63 | .val_bits = 8, | ||
| 64 | |||
| 65 | .max_register = MAX9850_DIGITAL_AUDIO, | ||
| 66 | .volatile_reg = max9850_volatile_register, | ||
| 67 | .cache_type = REGCACHE_RBTREE, | ||
| 68 | }; | ||
| 69 | |||
| 52 | static const unsigned int max9850_tlv[] = { | 70 | static const unsigned int max9850_tlv[] = { |
| 53 | TLV_DB_RANGE_HEAD(4), | 71 | TLV_DB_RANGE_HEAD(4), |
| 54 | 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0), | 72 | 0x18, 0x1f, TLV_DB_SCALE_ITEM(-7450, 400, 0), |
| @@ -225,6 +243,7 @@ static int max9850_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) | |||
| 225 | static int max9850_set_bias_level(struct snd_soc_codec *codec, | 243 | static int max9850_set_bias_level(struct snd_soc_codec *codec, |
| 226 | enum snd_soc_bias_level level) | 244 | enum snd_soc_bias_level level) |
| 227 | { | 245 | { |
| 246 | struct max9850_priv *max9850 = snd_soc_codec_get_drvdata(codec); | ||
| 228 | int ret; | 247 | int ret; |
| 229 | 248 | ||
| 230 | switch (level) { | 249 | switch (level) { |
| @@ -234,7 +253,7 @@ static int max9850_set_bias_level(struct snd_soc_codec *codec, | |||
| 234 | break; | 253 | break; |
| 235 | case SND_SOC_BIAS_STANDBY: | 254 | case SND_SOC_BIAS_STANDBY: |
| 236 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { | 255 | if (codec->dapm.bias_level == SND_SOC_BIAS_OFF) { |
| 237 | ret = snd_soc_cache_sync(codec); | 256 | ret = regcache_sync(max9850->regmap); |
| 238 | if (ret) { | 257 | if (ret) { |
| 239 | dev_err(codec->dev, | 258 | dev_err(codec->dev, |
| 240 | "Failed to sync cache: %d\n", ret); | 259 | "Failed to sync cache: %d\n", ret); |
| @@ -295,7 +314,7 @@ static int max9850_probe(struct snd_soc_codec *codec) | |||
| 295 | { | 314 | { |
| 296 | int ret; | 315 | int ret; |
| 297 | 316 | ||
| 298 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_I2C); | 317 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); |
| 299 | if (ret < 0) { | 318 | if (ret < 0) { |
| 300 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 319 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 301 | return ret; | 320 | return ret; |
| @@ -316,10 +335,6 @@ static struct snd_soc_codec_driver soc_codec_dev_max9850 = { | |||
| 316 | .suspend = max9850_suspend, | 335 | .suspend = max9850_suspend, |
| 317 | .resume = max9850_resume, | 336 | .resume = max9850_resume, |
| 318 | .set_bias_level = max9850_set_bias_level, | 337 | .set_bias_level = max9850_set_bias_level, |
| 319 | .reg_cache_size = ARRAY_SIZE(max9850_reg), | ||
| 320 | .reg_word_size = sizeof(u8), | ||
| 321 | .reg_cache_default = max9850_reg, | ||
| 322 | .volatile_register = max9850_volatile_register, | ||
| 323 | 338 | ||
| 324 | .controls = max9850_controls, | 339 | .controls = max9850_controls, |
| 325 | .num_controls = ARRAY_SIZE(max9850_controls), | 340 | .num_controls = ARRAY_SIZE(max9850_controls), |
| @@ -340,6 +355,10 @@ static int max9850_i2c_probe(struct i2c_client *i2c, | |||
| 340 | if (max9850 == NULL) | 355 | if (max9850 == NULL) |
| 341 | return -ENOMEM; | 356 | return -ENOMEM; |
| 342 | 357 | ||
| 358 | max9850->regmap = devm_regmap_init_i2c(i2c, &max9850_regmap); | ||
| 359 | if (IS_ERR(max9850->regmap)) | ||
| 360 | return PTR_ERR(max9850->regmap); | ||
| 361 | |||
| 343 | i2c_set_clientdata(i2c, max9850); | 362 | i2c_set_clientdata(i2c, max9850); |
| 344 | 363 | ||
| 345 | ret = snd_soc_register_codec(&i2c->dev, | 364 | ret = snd_soc_register_codec(&i2c->dev, |
diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c index ea141e1d6f28..f5472adee674 100644 --- a/sound/soc/codecs/mc13783.c +++ b/sound/soc/codecs/mc13783.c | |||
| @@ -30,16 +30,10 @@ | |||
| 30 | #include <sound/soc.h> | 30 | #include <sound/soc.h> |
| 31 | #include <sound/initval.h> | 31 | #include <sound/initval.h> |
| 32 | #include <sound/soc-dapm.h> | 32 | #include <sound/soc-dapm.h> |
| 33 | #include <linux/regmap.h> | ||
| 33 | 34 | ||
| 34 | #include "mc13783.h" | 35 | #include "mc13783.h" |
| 35 | 36 | ||
| 36 | #define MC13783_AUDIO_RX0 36 | ||
| 37 | #define MC13783_AUDIO_RX1 37 | ||
| 38 | #define MC13783_AUDIO_TX 38 | ||
| 39 | #define MC13783_SSI_NETWORK 39 | ||
| 40 | #define MC13783_AUDIO_CODEC 40 | ||
| 41 | #define MC13783_AUDIO_DAC 41 | ||
| 42 | |||
| 43 | #define AUDIO_RX0_ALSPEN (1 << 5) | 37 | #define AUDIO_RX0_ALSPEN (1 << 5) |
| 44 | #define AUDIO_RX0_ALSPSEL (1 << 7) | 38 | #define AUDIO_RX0_ALSPSEL (1 << 7) |
| 45 | #define AUDIO_RX0_ADDCDC (1 << 21) | 39 | #define AUDIO_RX0_ADDCDC (1 << 21) |
| @@ -95,45 +89,12 @@ | |||
| 95 | 89 | ||
| 96 | struct mc13783_priv { | 90 | struct mc13783_priv { |
| 97 | struct mc13xxx *mc13xxx; | 91 | struct mc13xxx *mc13xxx; |
| 92 | struct regmap *regmap; | ||
| 98 | 93 | ||
| 99 | enum mc13783_ssi_port adc_ssi_port; | 94 | enum mc13783_ssi_port adc_ssi_port; |
| 100 | enum mc13783_ssi_port dac_ssi_port; | 95 | enum mc13783_ssi_port dac_ssi_port; |
| 101 | }; | 96 | }; |
| 102 | 97 | ||
| 103 | static unsigned int mc13783_read(struct snd_soc_codec *codec, | ||
| 104 | unsigned int reg) | ||
| 105 | { | ||
| 106 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 107 | unsigned int value = 0; | ||
| 108 | |||
| 109 | mc13xxx_lock(priv->mc13xxx); | ||
| 110 | |||
| 111 | mc13xxx_reg_read(priv->mc13xxx, reg, &value); | ||
| 112 | |||
| 113 | mc13xxx_unlock(priv->mc13xxx); | ||
| 114 | |||
| 115 | return value; | ||
| 116 | } | ||
| 117 | |||
| 118 | static int mc13783_write(struct snd_soc_codec *codec, | ||
| 119 | unsigned int reg, unsigned int value) | ||
| 120 | { | ||
| 121 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); | ||
| 122 | int ret; | ||
| 123 | |||
| 124 | mc13xxx_lock(priv->mc13xxx); | ||
| 125 | |||
| 126 | ret = mc13xxx_reg_write(priv->mc13xxx, reg, value); | ||
| 127 | |||
| 128 | /* include errata fix for spi audio problems */ | ||
| 129 | if (reg == MC13783_AUDIO_CODEC || reg == MC13783_AUDIO_DAC) | ||
| 130 | ret = mc13xxx_reg_write(priv->mc13xxx, reg, value); | ||
| 131 | |||
| 132 | mc13xxx_unlock(priv->mc13xxx); | ||
| 133 | |||
| 134 | return ret; | ||
| 135 | } | ||
| 136 | |||
| 137 | /* Mapping between sample rates and register value */ | 98 | /* Mapping between sample rates and register value */ |
| 138 | static unsigned int mc13783_rates[] = { | 99 | static unsigned int mc13783_rates[] = { |
| 139 | 8000, 11025, 12000, 16000, | 100 | 8000, 11025, 12000, 16000, |
| @@ -466,6 +427,29 @@ static const struct snd_kcontrol_new right_input_mux = | |||
| 466 | static const struct snd_kcontrol_new samp_ctl = | 427 | static const struct snd_kcontrol_new samp_ctl = |
| 467 | SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 3, 1, 0); | 428 | SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 3, 1, 0); |
| 468 | 429 | ||
| 430 | static const char * const speaker_amp_source_text[] = { | ||
| 431 | "CODEC", "Right" | ||
| 432 | }; | ||
| 433 | static const SOC_ENUM_SINGLE_DECL(speaker_amp_source, MC13783_AUDIO_RX0, 4, | ||
| 434 | speaker_amp_source_text); | ||
| 435 | static const struct snd_kcontrol_new speaker_amp_source_mux = | ||
| 436 | SOC_DAPM_ENUM("Speaker Amp Source MUX", speaker_amp_source); | ||
| 437 | |||
| 438 | static const char * const headset_amp_source_text[] = { | ||
| 439 | "CODEC", "Mixer" | ||
| 440 | }; | ||
| 441 | |||
| 442 | static const SOC_ENUM_SINGLE_DECL(headset_amp_source, MC13783_AUDIO_RX0, 11, | ||
| 443 | headset_amp_source_text); | ||
| 444 | static const struct snd_kcontrol_new headset_amp_source_mux = | ||
| 445 | SOC_DAPM_ENUM("Headset Amp Source MUX", headset_amp_source); | ||
| 446 | |||
| 447 | static const struct snd_kcontrol_new cdcout_ctl = | ||
| 448 | SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 18, 1, 0); | ||
| 449 | |||
| 450 | static const struct snd_kcontrol_new adc_bypass_ctl = | ||
| 451 | SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_CODEC, 16, 1, 0); | ||
| 452 | |||
| 469 | static const struct snd_kcontrol_new lamp_ctl = | 453 | static const struct snd_kcontrol_new lamp_ctl = |
| 470 | SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 5, 1, 0); | 454 | SOC_DAPM_SINGLE("Switch", MC13783_AUDIO_RX0, 5, 1, 0); |
| 471 | 455 | ||
| @@ -503,12 +487,22 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = { | |||
| 503 | SND_SOC_DAPM_VIRT_MUX("PGA Right Input Mux", SND_SOC_NOPM, 0, 0, | 487 | SND_SOC_DAPM_VIRT_MUX("PGA Right Input Mux", SND_SOC_NOPM, 0, 0, |
| 504 | &right_input_mux), | 488 | &right_input_mux), |
| 505 | 489 | ||
| 490 | SND_SOC_DAPM_MUX("Speaker Amp Source MUX", SND_SOC_NOPM, 0, 0, | ||
| 491 | &speaker_amp_source_mux), | ||
| 492 | |||
| 493 | SND_SOC_DAPM_MUX("Headset Amp Source MUX", SND_SOC_NOPM, 0, 0, | ||
| 494 | &headset_amp_source_mux), | ||
| 495 | |||
| 506 | SND_SOC_DAPM_PGA("PGA Left Input", SND_SOC_NOPM, 0, 0, NULL, 0), | 496 | SND_SOC_DAPM_PGA("PGA Left Input", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 507 | SND_SOC_DAPM_PGA("PGA Right Input", SND_SOC_NOPM, 0, 0, NULL, 0), | 497 | SND_SOC_DAPM_PGA("PGA Right Input", SND_SOC_NOPM, 0, 0, NULL, 0), |
| 508 | 498 | ||
| 509 | SND_SOC_DAPM_ADC("ADC", "Capture", MC13783_AUDIO_CODEC, 11, 0), | 499 | SND_SOC_DAPM_ADC("ADC", "Capture", MC13783_AUDIO_CODEC, 11, 0), |
| 510 | SND_SOC_DAPM_SUPPLY("ADC_Reset", MC13783_AUDIO_CODEC, 15, 0, NULL, 0), | 500 | SND_SOC_DAPM_SUPPLY("ADC_Reset", MC13783_AUDIO_CODEC, 15, 0, NULL, 0), |
| 511 | 501 | ||
| 502 | SND_SOC_DAPM_PGA("Voice CODEC PGA", MC13783_AUDIO_RX1, 0, 0, NULL, 0), | ||
| 503 | SND_SOC_DAPM_SWITCH("Voice CODEC Bypass", MC13783_AUDIO_CODEC, 16, 0, | ||
| 504 | &adc_bypass_ctl), | ||
| 505 | |||
| 512 | /* Output */ | 506 | /* Output */ |
| 513 | SND_SOC_DAPM_SUPPLY("DAC_E", MC13783_AUDIO_DAC, 11, 0, NULL, 0), | 507 | SND_SOC_DAPM_SUPPLY("DAC_E", MC13783_AUDIO_DAC, 11, 0, NULL, 0), |
| 514 | SND_SOC_DAPM_SUPPLY("DAC_Reset", MC13783_AUDIO_DAC, 15, 0, NULL, 0), | 508 | SND_SOC_DAPM_SUPPLY("DAC_Reset", MC13783_AUDIO_DAC, 15, 0, NULL, 0), |
| @@ -516,10 +510,15 @@ static const struct snd_soc_dapm_widget mc13783_dapm_widgets[] = { | |||
| 516 | SND_SOC_DAPM_OUTPUT("RXOUTR"), | 510 | SND_SOC_DAPM_OUTPUT("RXOUTR"), |
| 517 | SND_SOC_DAPM_OUTPUT("HSL"), | 511 | SND_SOC_DAPM_OUTPUT("HSL"), |
| 518 | SND_SOC_DAPM_OUTPUT("HSR"), | 512 | SND_SOC_DAPM_OUTPUT("HSR"), |
| 513 | SND_SOC_DAPM_OUTPUT("LSPL"), | ||
| 519 | SND_SOC_DAPM_OUTPUT("LSP"), | 514 | SND_SOC_DAPM_OUTPUT("LSP"), |
| 520 | SND_SOC_DAPM_OUTPUT("SP"), | 515 | SND_SOC_DAPM_OUTPUT("SP"), |
| 516 | SND_SOC_DAPM_OUTPUT("CDCOUT"), | ||
| 521 | 517 | ||
| 522 | SND_SOC_DAPM_SWITCH("Speaker Amp", MC13783_AUDIO_RX0, 3, 0, &samp_ctl), | 518 | SND_SOC_DAPM_SWITCH("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 0, |
| 519 | &cdcout_ctl), | ||
| 520 | SND_SOC_DAPM_SWITCH("Speaker Amp Switch", MC13783_AUDIO_RX0, 3, 0, | ||
| 521 | &samp_ctl), | ||
| 523 | SND_SOC_DAPM_SWITCH("Loudspeaker Amp", SND_SOC_NOPM, 0, 0, &lamp_ctl), | 522 | SND_SOC_DAPM_SWITCH("Loudspeaker Amp", SND_SOC_NOPM, 0, 0, &lamp_ctl), |
| 524 | SND_SOC_DAPM_SWITCH("Headset Amp Left", MC13783_AUDIO_RX0, 10, 0, | 523 | SND_SOC_DAPM_SWITCH("Headset Amp Left", MC13783_AUDIO_RX0, 10, 0, |
| 525 | &hlamp_ctl), | 524 | &hlamp_ctl), |
| @@ -554,20 +553,28 @@ static struct snd_soc_dapm_route mc13783_routes[] = { | |||
| 554 | { "ADC", NULL, "PGA Right Input"}, | 553 | { "ADC", NULL, "PGA Right Input"}, |
| 555 | { "ADC", NULL, "ADC_Reset"}, | 554 | { "ADC", NULL, "ADC_Reset"}, |
| 556 | 555 | ||
| 556 | { "Voice CODEC PGA", "Voice CODEC Bypass", "ADC" }, | ||
| 557 | |||
| 558 | { "Speaker Amp Source MUX", "CODEC", "Voice CODEC PGA"}, | ||
| 559 | { "Speaker Amp Source MUX", "Right", "DAC PGA"}, | ||
| 560 | |||
| 561 | { "Headset Amp Source MUX", "CODEC", "Voice CODEC PGA"}, | ||
| 562 | { "Headset Amp Source MUX", "Mixer", "DAC PGA"}, | ||
| 563 | |||
| 557 | /* Output */ | 564 | /* Output */ |
| 558 | { "HSL", NULL, "Headset Amp Left" }, | 565 | { "HSL", NULL, "Headset Amp Left" }, |
| 559 | { "HSR", NULL, "Headset Amp Right"}, | 566 | { "HSR", NULL, "Headset Amp Right"}, |
| 560 | { "RXOUTL", NULL, "Line out Amp Left"}, | 567 | { "RXOUTL", NULL, "Line out Amp Left"}, |
| 561 | { "RXOUTR", NULL, "Line out Amp Right"}, | 568 | { "RXOUTR", NULL, "Line out Amp Right"}, |
| 562 | { "SP", NULL, "Speaker Amp"}, | 569 | { "SP", "Speaker Amp Switch", "Speaker Amp Source MUX"}, |
| 563 | { "Speaker Amp", NULL, "DAC PGA"}, | 570 | { "LSP", "Loudspeaker Amp", "Speaker Amp Source MUX"}, |
| 564 | { "LSP", NULL, "DAC PGA"}, | 571 | { "HSL", "Headset Amp Left", "Headset Amp Source MUX"}, |
| 565 | { "Headset Amp Left", NULL, "DAC PGA"}, | 572 | { "HSR", "Headset Amp Right", "Headset Amp Source MUX"}, |
| 566 | { "Headset Amp Right", NULL, "DAC PGA"}, | ||
| 567 | { "Line out Amp Left", NULL, "DAC PGA"}, | 573 | { "Line out Amp Left", NULL, "DAC PGA"}, |
| 568 | { "Line out Amp Right", NULL, "DAC PGA"}, | 574 | { "Line out Amp Right", NULL, "DAC PGA"}, |
| 569 | { "DAC PGA", NULL, "DAC"}, | 575 | { "DAC PGA", NULL, "DAC"}, |
| 570 | { "DAC", NULL, "DAC_E"}, | 576 | { "DAC", NULL, "DAC_E"}, |
| 577 | { "CDCOUT", "CDCOUT Switch", "Voice CODEC PGA"}, | ||
| 571 | }; | 578 | }; |
| 572 | 579 | ||
| 573 | static const char * const mc13783_3d_mixer[] = {"Stereo", "Phase Mix", | 580 | static const char * const mc13783_3d_mixer[] = {"Stereo", "Phase Mix", |
| @@ -580,15 +587,39 @@ static const struct soc_enum mc13783_enum_3d_mixer = | |||
| 580 | static struct snd_kcontrol_new mc13783_control_list[] = { | 587 | static struct snd_kcontrol_new mc13783_control_list[] = { |
| 581 | SOC_SINGLE("Loudspeaker enable", MC13783_AUDIO_RX0, 5, 1, 0), | 588 | SOC_SINGLE("Loudspeaker enable", MC13783_AUDIO_RX0, 5, 1, 0), |
| 582 | SOC_SINGLE("PCM Playback Volume", MC13783_AUDIO_RX1, 6, 15, 0), | 589 | SOC_SINGLE("PCM Playback Volume", MC13783_AUDIO_RX1, 6, 15, 0), |
| 590 | SOC_SINGLE("PCM Playback Switch", MC13783_AUDIO_RX1, 5, 1, 0), | ||
| 583 | SOC_DOUBLE("PCM Capture Volume", MC13783_AUDIO_TX, 19, 14, 31, 0), | 591 | SOC_DOUBLE("PCM Capture Volume", MC13783_AUDIO_TX, 19, 14, 31, 0), |
| 584 | SOC_ENUM("3D Control", mc13783_enum_3d_mixer), | 592 | SOC_ENUM("3D Control", mc13783_enum_3d_mixer), |
| 593 | |||
| 594 | SOC_SINGLE("CDCOUT Switch", MC13783_AUDIO_RX0, 18, 1, 0), | ||
| 595 | SOC_SINGLE("Earpiece Amp Switch", MC13783_AUDIO_RX0, 3, 1, 0), | ||
| 596 | SOC_DOUBLE("Headset Amp Switch", MC13783_AUDIO_RX0, 10, 9, 1, 0), | ||
| 597 | SOC_DOUBLE("Line out Amp Switch", MC13783_AUDIO_RX0, 16, 15, 1, 0), | ||
| 598 | |||
| 599 | SOC_SINGLE("PCM Capture Mixin Switch", MC13783_AUDIO_RX0, 22, 1, 0), | ||
| 600 | SOC_SINGLE("Line in Capture Mixin Switch", MC13783_AUDIO_RX0, 23, 1, 0), | ||
| 601 | |||
| 602 | SOC_SINGLE("CODEC Capture Volume", MC13783_AUDIO_RX1, 1, 15, 0), | ||
| 603 | SOC_SINGLE("CODEC Capture Mixin Switch", MC13783_AUDIO_RX0, 21, 1, 0), | ||
| 604 | |||
| 605 | SOC_SINGLE("Line in Capture Volume", MC13783_AUDIO_RX1, 12, 15, 0), | ||
| 606 | SOC_SINGLE("Line in Capture Switch", MC13783_AUDIO_RX1, 10, 1, 0), | ||
| 607 | |||
| 608 | SOC_SINGLE("MC1 Capture Bias Switch", MC13783_AUDIO_TX, 0, 1, 0), | ||
| 609 | SOC_SINGLE("MC2 Capture Bias Switch", MC13783_AUDIO_TX, 1, 1, 0), | ||
| 585 | }; | 610 | }; |
| 586 | 611 | ||
| 587 | static int mc13783_probe(struct snd_soc_codec *codec) | 612 | static int mc13783_probe(struct snd_soc_codec *codec) |
| 588 | { | 613 | { |
| 589 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); | 614 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); |
| 615 | int ret; | ||
| 590 | 616 | ||
| 591 | mc13xxx_lock(priv->mc13xxx); | 617 | codec->control_data = dev_get_regmap(codec->dev->parent, NULL); |
| 618 | ret = snd_soc_codec_set_cache_io(codec, 8, 24, SND_SOC_REGMAP); | ||
| 619 | if (ret != 0) { | ||
| 620 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | ||
| 621 | return ret; | ||
| 622 | } | ||
| 592 | 623 | ||
| 593 | /* these are the reset values */ | 624 | /* these are the reset values */ |
| 594 | mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); | 625 | mc13xxx_reg_write(priv->mc13xxx, MC13783_AUDIO_RX0, 0x25893); |
| @@ -612,8 +643,6 @@ static int mc13783_probe(struct snd_soc_codec *codec) | |||
| 612 | mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC, | 643 | mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC, |
| 613 | 0, AUDIO_SSI_SEL); | 644 | 0, AUDIO_SSI_SEL); |
| 614 | 645 | ||
| 615 | mc13xxx_unlock(priv->mc13xxx); | ||
| 616 | |||
| 617 | return 0; | 646 | return 0; |
| 618 | } | 647 | } |
| 619 | 648 | ||
| @@ -621,13 +650,9 @@ static int mc13783_remove(struct snd_soc_codec *codec) | |||
| 621 | { | 650 | { |
| 622 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); | 651 | struct mc13783_priv *priv = snd_soc_codec_get_drvdata(codec); |
| 623 | 652 | ||
| 624 | mc13xxx_lock(priv->mc13xxx); | ||
| 625 | |||
| 626 | /* Make sure VAUDIOON is off */ | 653 | /* Make sure VAUDIOON is off */ |
| 627 | mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_RX0, 0x3, 0); | 654 | mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_RX0, 0x3, 0); |
| 628 | 655 | ||
| 629 | mc13xxx_unlock(priv->mc13xxx); | ||
| 630 | |||
| 631 | return 0; | 656 | return 0; |
| 632 | } | 657 | } |
| 633 | 658 | ||
| @@ -717,8 +742,6 @@ static struct snd_soc_dai_driver mc13783_dai_sync[] = { | |||
| 717 | static struct snd_soc_codec_driver soc_codec_dev_mc13783 = { | 742 | static struct snd_soc_codec_driver soc_codec_dev_mc13783 = { |
| 718 | .probe = mc13783_probe, | 743 | .probe = mc13783_probe, |
| 719 | .remove = mc13783_remove, | 744 | .remove = mc13783_remove, |
| 720 | .read = mc13783_read, | ||
| 721 | .write = mc13783_write, | ||
| 722 | .controls = mc13783_control_list, | 745 | .controls = mc13783_control_list, |
| 723 | .num_controls = ARRAY_SIZE(mc13783_control_list), | 746 | .num_controls = ARRAY_SIZE(mc13783_control_list), |
| 724 | .dapm_widgets = mc13783_dapm_widgets, | 747 | .dapm_widgets = mc13783_dapm_widgets, |
diff --git a/sound/soc/codecs/pcm1681.c b/sound/soc/codecs/pcm1681.c index 651ce0923675..73f9c3630e2c 100644 --- a/sound/soc/codecs/pcm1681.c +++ b/sound/soc/codecs/pcm1681.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/gpio.h> | 21 | #include <linux/gpio.h> |
| 22 | #include <linux/i2c.h> | 22 | #include <linux/i2c.h> |
| 23 | #include <linux/regmap.h> | 23 | #include <linux/regmap.h> |
| 24 | #include <linux/of.h> | ||
| 24 | #include <linux/of_device.h> | 25 | #include <linux/of_device.h> |
| 25 | #include <linux/of_gpio.h> | 26 | #include <linux/of_gpio.h> |
| 26 | #include <sound/pcm.h> | 27 | #include <sound/pcm.h> |
| @@ -270,7 +271,7 @@ MODULE_DEVICE_TABLE(of, pcm1681_dt_ids); | |||
| 270 | static const struct regmap_config pcm1681_regmap = { | 271 | static const struct regmap_config pcm1681_regmap = { |
| 271 | .reg_bits = 8, | 272 | .reg_bits = 8, |
| 272 | .val_bits = 8, | 273 | .val_bits = 8, |
| 273 | .max_register = ARRAY_SIZE(pcm1681_reg_defaults) + 1, | 274 | .max_register = 0x13, |
| 274 | .reg_defaults = pcm1681_reg_defaults, | 275 | .reg_defaults = pcm1681_reg_defaults, |
| 275 | .num_reg_defaults = ARRAY_SIZE(pcm1681_reg_defaults), | 276 | .num_reg_defaults = ARRAY_SIZE(pcm1681_reg_defaults), |
| 276 | .writeable_reg = pcm1681_writeable_reg, | 277 | .writeable_reg = pcm1681_writeable_reg, |
diff --git a/sound/soc/codecs/pcm1792a.c b/sound/soc/codecs/pcm1792a.c index 2a8eccf64c76..7146653a8e16 100644 --- a/sound/soc/codecs/pcm1792a.c +++ b/sound/soc/codecs/pcm1792a.c | |||
| @@ -28,6 +28,7 @@ | |||
| 28 | #include <sound/initval.h> | 28 | #include <sound/initval.h> |
| 29 | #include <sound/soc.h> | 29 | #include <sound/soc.h> |
| 30 | #include <sound/tlv.h> | 30 | #include <sound/tlv.h> |
| 31 | #include <linux/of.h> | ||
| 31 | #include <linux/of_device.h> | 32 | #include <linux/of_device.h> |
| 32 | 33 | ||
| 33 | #include "pcm1792a.h" | 34 | #include "pcm1792a.h" |
| @@ -188,7 +189,7 @@ MODULE_DEVICE_TABLE(of, pcm1792a_of_match); | |||
| 188 | static const struct regmap_config pcm1792a_regmap = { | 189 | static const struct regmap_config pcm1792a_regmap = { |
| 189 | .reg_bits = 8, | 190 | .reg_bits = 8, |
| 190 | .val_bits = 8, | 191 | .val_bits = 8, |
| 191 | .max_register = 24, | 192 | .max_register = 23, |
| 192 | .reg_defaults = pcm1792a_reg_defaults, | 193 | .reg_defaults = pcm1792a_reg_defaults, |
| 193 | .num_reg_defaults = ARRAY_SIZE(pcm1792a_reg_defaults), | 194 | .num_reg_defaults = ARRAY_SIZE(pcm1792a_reg_defaults), |
| 194 | .writeable_reg = pcm1792a_writeable_reg, | 195 | .writeable_reg = pcm1792a_writeable_reg, |
diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c index c26a8f814b18..4d041d376f31 100644 --- a/sound/soc/codecs/rt5640.c +++ b/sound/soc/codecs/rt5640.c | |||
| @@ -21,6 +21,7 @@ | |||
| 21 | #include <linux/of_gpio.h> | 21 | #include <linux/of_gpio.h> |
| 22 | #include <linux/platform_device.h> | 22 | #include <linux/platform_device.h> |
| 23 | #include <linux/spi/spi.h> | 23 | #include <linux/spi/spi.h> |
| 24 | #include <linux/acpi.h> | ||
| 24 | #include <sound/core.h> | 25 | #include <sound/core.h> |
| 25 | #include <sound/pcm.h> | 26 | #include <sound/pcm.h> |
| 26 | #include <sound/pcm_params.h> | 27 | #include <sound/pcm_params.h> |
| @@ -926,7 +927,7 @@ static int rt5640_set_dmic2_event(struct snd_soc_dapm_widget *w, | |||
| 926 | return 0; | 927 | return 0; |
| 927 | } | 928 | } |
| 928 | 929 | ||
| 929 | void hp_amp_power_on(struct snd_soc_codec *codec) | 930 | static void hp_amp_power_on(struct snd_soc_codec *codec) |
| 930 | { | 931 | { |
| 931 | struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); | 932 | struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); |
| 932 | 933 | ||
| @@ -1609,7 +1610,8 @@ static int rt5640_hw_params(struct snd_pcm_substream *substream, | |||
| 1609 | rt5640->lrck[dai->id] = params_rate(params); | 1610 | rt5640->lrck[dai->id] = params_rate(params); |
| 1610 | pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); | 1611 | pre_div = get_clk_info(rt5640->sysclk, rt5640->lrck[dai->id]); |
| 1611 | if (pre_div < 0) { | 1612 | if (pre_div < 0) { |
| 1612 | dev_err(codec->dev, "Unsupported clock setting\n"); | 1613 | dev_err(codec->dev, "Unsupported clock setting %d for DAI %d\n", |
| 1614 | rt5640->lrck[dai->id], dai->id); | ||
| 1613 | return -EINVAL; | 1615 | return -EINVAL; |
| 1614 | } | 1616 | } |
| 1615 | frame_size = snd_soc_params_to_frame_size(params); | 1617 | frame_size = snd_soc_params_to_frame_size(params); |
| @@ -1977,13 +1979,20 @@ static int rt5640_suspend(struct snd_soc_codec *codec) | |||
| 1977 | rt5640_reset(codec); | 1979 | rt5640_reset(codec); |
| 1978 | regcache_cache_only(rt5640->regmap, true); | 1980 | regcache_cache_only(rt5640->regmap, true); |
| 1979 | regcache_mark_dirty(rt5640->regmap); | 1981 | regcache_mark_dirty(rt5640->regmap); |
| 1982 | if (gpio_is_valid(rt5640->pdata.ldo1_en)) | ||
| 1983 | gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 0); | ||
| 1980 | 1984 | ||
| 1981 | return 0; | 1985 | return 0; |
| 1982 | } | 1986 | } |
| 1983 | 1987 | ||
| 1984 | static int rt5640_resume(struct snd_soc_codec *codec) | 1988 | static int rt5640_resume(struct snd_soc_codec *codec) |
| 1985 | { | 1989 | { |
| 1986 | rt5640_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 1990 | struct rt5640_priv *rt5640 = snd_soc_codec_get_drvdata(codec); |
| 1991 | |||
| 1992 | if (gpio_is_valid(rt5640->pdata.ldo1_en)) { | ||
| 1993 | gpio_set_value_cansleep(rt5640->pdata.ldo1_en, 1); | ||
| 1994 | msleep(400); | ||
| 1995 | } | ||
| 1987 | 1996 | ||
| 1988 | return 0; | 1997 | return 0; |
| 1989 | } | 1998 | } |
| @@ -2080,6 +2089,14 @@ static const struct i2c_device_id rt5640_i2c_id[] = { | |||
| 2080 | }; | 2089 | }; |
| 2081 | MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); | 2090 | MODULE_DEVICE_TABLE(i2c, rt5640_i2c_id); |
| 2082 | 2091 | ||
| 2092 | #ifdef CONFIG_ACPI | ||
| 2093 | static struct acpi_device_id rt5640_acpi_match[] = { | ||
| 2094 | { "INT33CA", 0 }, | ||
| 2095 | { }, | ||
| 2096 | }; | ||
| 2097 | MODULE_DEVICE_TABLE(acpi, rt5640_acpi_match); | ||
| 2098 | #endif | ||
| 2099 | |||
| 2083 | static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) | 2100 | static int rt5640_parse_dt(struct rt5640_priv *rt5640, struct device_node *np) |
| 2084 | { | 2101 | { |
| 2085 | rt5640->pdata.in1_diff = of_property_read_bool(np, | 2102 | rt5640->pdata.in1_diff = of_property_read_bool(np, |
| @@ -2199,6 +2216,7 @@ static struct i2c_driver rt5640_i2c_driver = { | |||
| 2199 | .driver = { | 2216 | .driver = { |
| 2200 | .name = "rt5640", | 2217 | .name = "rt5640", |
| 2201 | .owner = THIS_MODULE, | 2218 | .owner = THIS_MODULE, |
| 2219 | .acpi_match_table = ACPI_PTR(rt5640_acpi_match), | ||
| 2202 | }, | 2220 | }, |
| 2203 | .probe = rt5640_i2c_probe, | 2221 | .probe = rt5640_i2c_probe, |
| 2204 | .remove = rt5640_i2c_remove, | 2222 | .remove = rt5640_i2c_remove, |
diff --git a/sound/soc/codecs/si476x.c b/sound/soc/codecs/si476x.c index 38f3b105c17d..52e7cb08434b 100644 --- a/sound/soc/codecs/si476x.c +++ b/sound/soc/codecs/si476x.c | |||
| @@ -60,48 +60,6 @@ enum si476x_pcm_format { | |||
| 60 | SI476X_PCM_FORMAT_S24_LE = 6, | 60 | SI476X_PCM_FORMAT_S24_LE = 6, |
| 61 | }; | 61 | }; |
| 62 | 62 | ||
| 63 | static unsigned int si476x_codec_read(struct snd_soc_codec *codec, | ||
| 64 | unsigned int reg) | ||
| 65 | { | ||
| 66 | int err; | ||
| 67 | unsigned int val; | ||
| 68 | struct si476x_core *core = codec->control_data; | ||
| 69 | |||
| 70 | si476x_core_lock(core); | ||
| 71 | if (!si476x_core_is_powered_up(core)) | ||
| 72 | regcache_cache_only(core->regmap, true); | ||
| 73 | |||
| 74 | err = regmap_read(core->regmap, reg, &val); | ||
| 75 | |||
| 76 | if (!si476x_core_is_powered_up(core)) | ||
| 77 | regcache_cache_only(core->regmap, false); | ||
| 78 | si476x_core_unlock(core); | ||
| 79 | |||
| 80 | if (err < 0) | ||
| 81 | return err; | ||
| 82 | |||
| 83 | return val; | ||
| 84 | } | ||
| 85 | |||
| 86 | static int si476x_codec_write(struct snd_soc_codec *codec, | ||
| 87 | unsigned int reg, unsigned int val) | ||
| 88 | { | ||
| 89 | int err; | ||
| 90 | struct si476x_core *core = codec->control_data; | ||
| 91 | |||
| 92 | si476x_core_lock(core); | ||
| 93 | if (!si476x_core_is_powered_up(core)) | ||
| 94 | regcache_cache_only(core->regmap, true); | ||
| 95 | |||
| 96 | err = regmap_write(core->regmap, reg, val); | ||
| 97 | |||
| 98 | if (!si476x_core_is_powered_up(core)) | ||
| 99 | regcache_cache_only(core->regmap, false); | ||
| 100 | si476x_core_unlock(core); | ||
| 101 | |||
| 102 | return err; | ||
| 103 | } | ||
| 104 | |||
| 105 | static const struct snd_soc_dapm_widget si476x_dapm_widgets[] = { | 63 | static const struct snd_soc_dapm_widget si476x_dapm_widgets[] = { |
| 106 | SND_SOC_DAPM_OUTPUT("LOUT"), | 64 | SND_SOC_DAPM_OUTPUT("LOUT"), |
| 107 | SND_SOC_DAPM_OUTPUT("ROUT"), | 65 | SND_SOC_DAPM_OUTPUT("ROUT"), |
| @@ -115,6 +73,7 @@ static const struct snd_soc_dapm_route si476x_dapm_routes[] = { | |||
| 115 | static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, | 73 | static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, |
| 116 | unsigned int fmt) | 74 | unsigned int fmt) |
| 117 | { | 75 | { |
| 76 | struct si476x_core *core = i2c_mfd_cell_to_core(codec_dai->dev); | ||
| 118 | int err; | 77 | int err; |
| 119 | u16 format = 0; | 78 | u16 format = 0; |
| 120 | 79 | ||
| @@ -178,9 +137,14 @@ static int si476x_codec_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
| 178 | return -EINVAL; | 137 | return -EINVAL; |
| 179 | } | 138 | } |
| 180 | 139 | ||
| 140 | si476x_core_lock(core); | ||
| 141 | |||
| 181 | err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, | 142 | err = snd_soc_update_bits(codec_dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, |
| 182 | SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK, | 143 | SI476X_DIGITAL_IO_OUTPUT_FORMAT_MASK, |
| 183 | format); | 144 | format); |
| 145 | |||
| 146 | si476x_core_unlock(core); | ||
| 147 | |||
| 184 | if (err < 0) { | 148 | if (err < 0) { |
| 185 | dev_err(codec_dai->codec->dev, "Failed to set output format\n"); | 149 | dev_err(codec_dai->codec->dev, "Failed to set output format\n"); |
| 186 | return err; | 150 | return err; |
| @@ -193,6 +157,7 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, | |||
| 193 | struct snd_pcm_hw_params *params, | 157 | struct snd_pcm_hw_params *params, |
| 194 | struct snd_soc_dai *dai) | 158 | struct snd_soc_dai *dai) |
| 195 | { | 159 | { |
| 160 | struct si476x_core *core = i2c_mfd_cell_to_core(dai->dev); | ||
| 196 | int rate, width, err; | 161 | int rate, width, err; |
| 197 | 162 | ||
| 198 | rate = params_rate(params); | 163 | rate = params_rate(params); |
| @@ -218,11 +183,13 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, | |||
| 218 | return -EINVAL; | 183 | return -EINVAL; |
| 219 | } | 184 | } |
| 220 | 185 | ||
| 186 | si476x_core_lock(core); | ||
| 187 | |||
| 221 | err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE, | 188 | err = snd_soc_write(dai->codec, SI476X_DIGITAL_IO_OUTPUT_SAMPLE_RATE, |
| 222 | rate); | 189 | rate); |
| 223 | if (err < 0) { | 190 | if (err < 0) { |
| 224 | dev_err(dai->codec->dev, "Failed to set sample rate\n"); | 191 | dev_err(dai->codec->dev, "Failed to set sample rate\n"); |
| 225 | return err; | 192 | goto out; |
| 226 | } | 193 | } |
| 227 | 194 | ||
| 228 | err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, | 195 | err = snd_soc_update_bits(dai->codec, SI476X_DIGITAL_IO_OUTPUT_FORMAT, |
| @@ -231,15 +198,18 @@ static int si476x_codec_hw_params(struct snd_pcm_substream *substream, | |||
| 231 | (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT)); | 198 | (width << SI476X_DIGITAL_IO_SAMPLE_SIZE_SHIFT)); |
| 232 | if (err < 0) { | 199 | if (err < 0) { |
| 233 | dev_err(dai->codec->dev, "Failed to set output width\n"); | 200 | dev_err(dai->codec->dev, "Failed to set output width\n"); |
| 234 | return err; | 201 | goto out; |
| 235 | } | 202 | } |
| 236 | 203 | ||
| 237 | return 0; | 204 | out: |
| 205 | si476x_core_unlock(core); | ||
| 206 | |||
| 207 | return err; | ||
| 238 | } | 208 | } |
| 239 | 209 | ||
| 240 | static int si476x_codec_probe(struct snd_soc_codec *codec) | 210 | static int si476x_codec_probe(struct snd_soc_codec *codec) |
| 241 | { | 211 | { |
| 242 | codec->control_data = i2c_mfd_cell_to_core(codec->dev); | 212 | codec->control_data = dev_get_regmap(codec->dev->parent, NULL); |
| 243 | return 0; | 213 | return 0; |
| 244 | } | 214 | } |
| 245 | 215 | ||
| @@ -268,8 +238,6 @@ static struct snd_soc_dai_driver si476x_dai = { | |||
| 268 | 238 | ||
| 269 | static struct snd_soc_codec_driver soc_codec_dev_si476x = { | 239 | static struct snd_soc_codec_driver soc_codec_dev_si476x = { |
| 270 | .probe = si476x_codec_probe, | 240 | .probe = si476x_codec_probe, |
| 271 | .read = si476x_codec_read, | ||
| 272 | .write = si476x_codec_write, | ||
| 273 | .dapm_widgets = si476x_dapm_widgets, | 241 | .dapm_widgets = si476x_dapm_widgets, |
| 274 | .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), | 242 | .num_dapm_widgets = ARRAY_SIZE(si476x_dapm_widgets), |
| 275 | .dapm_routes = si476x_dapm_routes, | 243 | .dapm_routes = si476x_dapm_routes, |
diff --git a/sound/soc/codecs/sn95031.c b/sound/soc/codecs/sn95031.c index dba26e63844e..13045f2af4d3 100644 --- a/sound/soc/codecs/sn95031.c +++ b/sound/soc/codecs/sn95031.c | |||
| @@ -164,30 +164,28 @@ static unsigned int sn95031_get_mic_bias(struct snd_soc_codec *codec) | |||
| 164 | } | 164 | } |
| 165 | /*end - adc helper functions */ | 165 | /*end - adc helper functions */ |
| 166 | 166 | ||
| 167 | static inline unsigned int sn95031_read(struct snd_soc_codec *codec, | 167 | static int sn95031_read(void *ctx, unsigned int reg, unsigned int *val) |
| 168 | unsigned int reg) | ||
| 169 | { | 168 | { |
| 170 | u8 value = 0; | 169 | u8 value = 0; |
| 171 | int ret; | 170 | int ret; |
| 172 | 171 | ||
| 173 | ret = intel_scu_ipc_ioread8(reg, &value); | 172 | ret = intel_scu_ipc_ioread8(reg, &value); |
| 174 | if (ret) | 173 | if (ret == 0) |
| 175 | pr_err("read of %x failed, err %d\n", reg, ret); | 174 | *val = value; |
| 176 | return value; | ||
| 177 | 175 | ||
| 176 | return ret; | ||
| 178 | } | 177 | } |
| 179 | 178 | ||
| 180 | static inline int sn95031_write(struct snd_soc_codec *codec, | 179 | static int sn95031_write(void *ctx, unsigned int reg, unsigned int value) |
| 181 | unsigned int reg, unsigned int value) | ||
| 182 | { | 180 | { |
| 183 | int ret; | 181 | return intel_scu_ipc_iowrite8(reg, value); |
| 184 | |||
| 185 | ret = intel_scu_ipc_iowrite8(reg, value); | ||
| 186 | if (ret) | ||
| 187 | pr_err("write of %x failed, err %d\n", reg, ret); | ||
| 188 | return ret; | ||
| 189 | } | 182 | } |
| 190 | 183 | ||
| 184 | static const struct regmap_config sn95031_regmap = { | ||
| 185 | .reg_read = sn95031_read, | ||
| 186 | .reg_write = sn95031_write, | ||
| 187 | }; | ||
| 188 | |||
| 191 | static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, | 189 | static int sn95031_set_vaud_bias(struct snd_soc_codec *codec, |
| 192 | enum snd_soc_bias_level level) | 190 | enum snd_soc_bias_level level) |
| 193 | { | 191 | { |
| @@ -827,6 +825,8 @@ static int sn95031_codec_probe(struct snd_soc_codec *codec) | |||
| 827 | { | 825 | { |
| 828 | pr_debug("codec_probe called\n"); | 826 | pr_debug("codec_probe called\n"); |
| 829 | 827 | ||
| 828 | snd_soc_codec_set_cache_io(codec, 0, 0, SND_SOC_REGMAP); | ||
| 829 | |||
| 830 | /* PCM interface config | 830 | /* PCM interface config |
| 831 | * This sets the pcm rx slot conguration to max 6 slots | 831 | * This sets the pcm rx slot conguration to max 6 slots |
| 832 | * for max 4 dais (2 stereo and 2 mono) | 832 | * for max 4 dais (2 stereo and 2 mono) |
| @@ -886,8 +886,6 @@ static int sn95031_codec_remove(struct snd_soc_codec *codec) | |||
| 886 | static struct snd_soc_codec_driver sn95031_codec = { | 886 | static struct snd_soc_codec_driver sn95031_codec = { |
| 887 | .probe = sn95031_codec_probe, | 887 | .probe = sn95031_codec_probe, |
| 888 | .remove = sn95031_codec_remove, | 888 | .remove = sn95031_codec_remove, |
| 889 | .read = sn95031_read, | ||
| 890 | .write = sn95031_write, | ||
| 891 | .set_bias_level = sn95031_set_vaud_bias, | 889 | .set_bias_level = sn95031_set_vaud_bias, |
| 892 | .idle_bias_off = true, | 890 | .idle_bias_off = true, |
| 893 | .dapm_widgets = sn95031_dapm_widgets, | 891 | .dapm_widgets = sn95031_dapm_widgets, |
| @@ -898,7 +896,14 @@ static struct snd_soc_codec_driver sn95031_codec = { | |||
| 898 | 896 | ||
| 899 | static int sn95031_device_probe(struct platform_device *pdev) | 897 | static int sn95031_device_probe(struct platform_device *pdev) |
| 900 | { | 898 | { |
| 899 | struct regmap *regmap; | ||
| 900 | |||
| 901 | pr_debug("codec device probe called for %s\n", dev_name(&pdev->dev)); | 901 | pr_debug("codec device probe called for %s\n", dev_name(&pdev->dev)); |
| 902 | |||
| 903 | regmap = devm_regmap_init(&pdev->dev, NULL, NULL, &sn95031_regmap); | ||
| 904 | if (IS_ERR(regmap)) | ||
| 905 | return PTR_ERR(regmap); | ||
| 906 | |||
| 902 | return snd_soc_register_codec(&pdev->dev, &sn95031_codec, | 907 | return snd_soc_register_codec(&pdev->dev, &sn95031_codec, |
| 903 | sn95031_dais, ARRAY_SIZE(sn95031_dais)); | 908 | sn95031_dais, ARRAY_SIZE(sn95031_dais)); |
| 904 | } | 909 | } |
diff --git a/sound/soc/codecs/tas5086.c b/sound/soc/codecs/tas5086.c index 6d31d88f7204..fe4d29d88564 100644 --- a/sound/soc/codecs/tas5086.c +++ b/sound/soc/codecs/tas5086.c | |||
| @@ -37,6 +37,7 @@ | |||
| 37 | #include <linux/i2c.h> | 37 | #include <linux/i2c.h> |
| 38 | #include <linux/regmap.h> | 38 | #include <linux/regmap.h> |
| 39 | #include <linux/spi/spi.h> | 39 | #include <linux/spi/spi.h> |
| 40 | #include <linux/of.h> | ||
| 40 | #include <linux/of_device.h> | 41 | #include <linux/of_device.h> |
| 41 | #include <linux/of_gpio.h> | 42 | #include <linux/of_gpio.h> |
| 42 | #include <sound/pcm.h> | 43 | #include <sound/pcm.h> |
| @@ -244,6 +245,8 @@ struct tas5086_private { | |||
| 244 | unsigned int mclk, sclk; | 245 | unsigned int mclk, sclk; |
| 245 | unsigned int format; | 246 | unsigned int format; |
| 246 | bool deemph; | 247 | bool deemph; |
| 248 | unsigned int charge_period; | ||
| 249 | unsigned int pwm_start_mid_z; | ||
| 247 | /* Current sample rate for de-emphasis control */ | 250 | /* Current sample rate for de-emphasis control */ |
| 248 | int rate; | 251 | int rate; |
| 249 | /* GPIO driving Reset pin, if any */ | 252 | /* GPIO driving Reset pin, if any */ |
| @@ -456,6 +459,75 @@ static int tas5086_mute_stream(struct snd_soc_dai *dai, int mute, int stream) | |||
| 456 | return regmap_write(priv->regmap, TAS5086_SOFT_MUTE, val); | 459 | return regmap_write(priv->regmap, TAS5086_SOFT_MUTE, val); |
| 457 | } | 460 | } |
| 458 | 461 | ||
| 462 | static void tas5086_reset(struct tas5086_private *priv) | ||
| 463 | { | ||
| 464 | if (gpio_is_valid(priv->gpio_nreset)) { | ||
| 465 | /* Reset codec - minimum assertion time is 400ns */ | ||
| 466 | gpio_direction_output(priv->gpio_nreset, 0); | ||
| 467 | udelay(1); | ||
| 468 | gpio_set_value(priv->gpio_nreset, 1); | ||
| 469 | |||
| 470 | /* Codec needs ~15ms to wake up */ | ||
| 471 | msleep(15); | ||
| 472 | } | ||
| 473 | } | ||
| 474 | |||
| 475 | /* charge period values in microseconds */ | ||
| 476 | static const int tas5086_charge_period[] = { | ||
| 477 | 13000, 16900, 23400, 31200, 41600, 54600, 72800, 96200, | ||
| 478 | 130000, 156000, 234000, 312000, 416000, 546000, 728000, 962000, | ||
| 479 | 1300000, 169000, 2340000, 3120000, 4160000, 5460000, 7280000, 9620000, | ||
| 480 | }; | ||
| 481 | |||
| 482 | static int tas5086_init(struct device *dev, struct tas5086_private *priv) | ||
| 483 | { | ||
| 484 | int ret, i; | ||
| 485 | |||
| 486 | /* | ||
| 487 | * If any of the channels is configured to start in Mid-Z mode, | ||
| 488 | * configure 'part 1' of the PWM starts to use Mid-Z, and tell | ||
| 489 | * all configured mid-z channels to start start under 'part 1'. | ||
| 490 | */ | ||
| 491 | if (priv->pwm_start_mid_z) | ||
| 492 | regmap_write(priv->regmap, TAS5086_PWM_START, | ||
| 493 | TAS5086_PWM_START_MIDZ_FOR_START_1 | | ||
| 494 | priv->pwm_start_mid_z); | ||
| 495 | |||
| 496 | /* lookup and set split-capacitor charge period */ | ||
| 497 | if (priv->charge_period == 0) { | ||
| 498 | regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0); | ||
| 499 | } else { | ||
| 500 | i = index_in_array(tas5086_charge_period, | ||
| 501 | ARRAY_SIZE(tas5086_charge_period), | ||
| 502 | priv->charge_period); | ||
| 503 | if (i >= 0) | ||
| 504 | regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, | ||
| 505 | i + 0x08); | ||
| 506 | else | ||
| 507 | dev_warn(dev, | ||
| 508 | "Invalid split-cap charge period of %d ns.\n", | ||
| 509 | priv->charge_period); | ||
| 510 | } | ||
| 511 | |||
| 512 | /* enable factory trim */ | ||
| 513 | ret = regmap_write(priv->regmap, TAS5086_OSC_TRIM, 0x00); | ||
| 514 | if (ret < 0) | ||
| 515 | return ret; | ||
| 516 | |||
| 517 | /* start all channels */ | ||
| 518 | ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x20); | ||
| 519 | if (ret < 0) | ||
| 520 | return ret; | ||
| 521 | |||
| 522 | /* mute all channels for now */ | ||
| 523 | ret = regmap_write(priv->regmap, TAS5086_SOFT_MUTE, | ||
| 524 | TAS5086_SOFT_MUTE_ALL); | ||
| 525 | if (ret < 0) | ||
| 526 | return ret; | ||
| 527 | |||
| 528 | return 0; | ||
| 529 | } | ||
| 530 | |||
| 459 | /* TAS5086 controls */ | 531 | /* TAS5086 controls */ |
| 460 | static const DECLARE_TLV_DB_SCALE(tas5086_dac_tlv, -10350, 50, 1); | 532 | static const DECLARE_TLV_DB_SCALE(tas5086_dac_tlv, -10350, 50, 1); |
| 461 | 533 | ||
| @@ -691,14 +763,39 @@ static struct snd_soc_dai_driver tas5086_dai = { | |||
| 691 | }; | 763 | }; |
| 692 | 764 | ||
| 693 | #ifdef CONFIG_PM | 765 | #ifdef CONFIG_PM |
| 766 | static int tas5086_soc_suspend(struct snd_soc_codec *codec) | ||
| 767 | { | ||
| 768 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | ||
| 769 | int ret; | ||
| 770 | |||
| 771 | /* Shut down all channels */ | ||
| 772 | ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x60); | ||
| 773 | if (ret < 0) | ||
| 774 | return ret; | ||
| 775 | |||
| 776 | return 0; | ||
| 777 | } | ||
| 778 | |||
| 694 | static int tas5086_soc_resume(struct snd_soc_codec *codec) | 779 | static int tas5086_soc_resume(struct snd_soc_codec *codec) |
| 695 | { | 780 | { |
| 696 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 781 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); |
| 782 | int ret; | ||
| 783 | |||
| 784 | tas5086_reset(priv); | ||
| 785 | regcache_mark_dirty(priv->regmap); | ||
| 786 | |||
| 787 | ret = tas5086_init(codec->dev, priv); | ||
| 788 | if (ret < 0) | ||
| 789 | return ret; | ||
| 790 | |||
| 791 | ret = regcache_sync(priv->regmap); | ||
| 792 | if (ret < 0) | ||
| 793 | return ret; | ||
| 697 | 794 | ||
| 698 | /* Restore codec state */ | 795 | return 0; |
| 699 | return regcache_sync(priv->regmap); | ||
| 700 | } | 796 | } |
| 701 | #else | 797 | #else |
| 798 | #define tas5086_soc_suspend NULL | ||
| 702 | #define tas5086_soc_resume NULL | 799 | #define tas5086_soc_resume NULL |
| 703 | #endif /* CONFIG_PM */ | 800 | #endif /* CONFIG_PM */ |
| 704 | 801 | ||
| @@ -710,23 +807,19 @@ static const struct of_device_id tas5086_dt_ids[] = { | |||
| 710 | MODULE_DEVICE_TABLE(of, tas5086_dt_ids); | 807 | MODULE_DEVICE_TABLE(of, tas5086_dt_ids); |
| 711 | #endif | 808 | #endif |
| 712 | 809 | ||
| 713 | /* charge period values in microseconds */ | ||
| 714 | static const int tas5086_charge_period[] = { | ||
| 715 | 13000, 16900, 23400, 31200, 41600, 54600, 72800, 96200, | ||
| 716 | 130000, 156000, 234000, 312000, 416000, 546000, 728000, 962000, | ||
| 717 | 1300000, 169000, 2340000, 3120000, 4160000, 5460000, 7280000, 9620000, | ||
| 718 | }; | ||
| 719 | |||
| 720 | static int tas5086_probe(struct snd_soc_codec *codec) | 810 | static int tas5086_probe(struct snd_soc_codec *codec) |
| 721 | { | 811 | { |
| 722 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); | 812 | struct tas5086_private *priv = snd_soc_codec_get_drvdata(codec); |
| 723 | int charge_period = 1300000; /* hardware default is 1300 ms */ | ||
| 724 | u8 pwm_start_mid_z = 0; | ||
| 725 | int i, ret; | 813 | int i, ret; |
| 726 | 814 | ||
| 815 | priv->pwm_start_mid_z = 0; | ||
| 816 | priv->charge_period = 1300000; /* hardware default is 1300 ms */ | ||
| 817 | |||
| 727 | if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) { | 818 | if (of_match_device(of_match_ptr(tas5086_dt_ids), codec->dev)) { |
| 728 | struct device_node *of_node = codec->dev->of_node; | 819 | struct device_node *of_node = codec->dev->of_node; |
| 729 | of_property_read_u32(of_node, "ti,charge-period", &charge_period); | 820 | |
| 821 | of_property_read_u32(of_node, "ti,charge-period", | ||
| 822 | &priv->charge_period); | ||
| 730 | 823 | ||
| 731 | for (i = 0; i < 6; i++) { | 824 | for (i = 0; i < 6; i++) { |
| 732 | char name[25]; | 825 | char name[25]; |
| @@ -735,43 +828,11 @@ static int tas5086_probe(struct snd_soc_codec *codec) | |||
| 735 | "ti,mid-z-channel-%d", i + 1); | 828 | "ti,mid-z-channel-%d", i + 1); |
| 736 | 829 | ||
| 737 | if (of_get_property(of_node, name, NULL) != NULL) | 830 | if (of_get_property(of_node, name, NULL) != NULL) |
| 738 | pwm_start_mid_z |= 1 << i; | 831 | priv->pwm_start_mid_z |= 1 << i; |
| 739 | } | 832 | } |
| 740 | } | 833 | } |
| 741 | 834 | ||
| 742 | /* | 835 | ret = tas5086_init(codec->dev, priv); |
| 743 | * If any of the channels is configured to start in Mid-Z mode, | ||
| 744 | * configure 'part 1' of the PWM starts to use Mid-Z, and tell | ||
| 745 | * all configured mid-z channels to start start under 'part 1'. | ||
| 746 | */ | ||
| 747 | if (pwm_start_mid_z) | ||
| 748 | regmap_write(priv->regmap, TAS5086_PWM_START, | ||
| 749 | TAS5086_PWM_START_MIDZ_FOR_START_1 | | ||
| 750 | pwm_start_mid_z); | ||
| 751 | |||
| 752 | /* lookup and set split-capacitor charge period */ | ||
| 753 | if (charge_period == 0) { | ||
| 754 | regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, 0); | ||
| 755 | } else { | ||
| 756 | i = index_in_array(tas5086_charge_period, | ||
| 757 | ARRAY_SIZE(tas5086_charge_period), | ||
| 758 | charge_period); | ||
| 759 | if (i >= 0) | ||
| 760 | regmap_write(priv->regmap, TAS5086_SPLIT_CAP_CHARGE, | ||
| 761 | i + 0x08); | ||
| 762 | else | ||
| 763 | dev_warn(codec->dev, | ||
| 764 | "Invalid split-cap charge period of %d ns.\n", | ||
| 765 | charge_period); | ||
| 766 | } | ||
| 767 | |||
| 768 | /* enable factory trim */ | ||
| 769 | ret = regmap_write(priv->regmap, TAS5086_OSC_TRIM, 0x00); | ||
| 770 | if (ret < 0) | ||
| 771 | return ret; | ||
| 772 | |||
| 773 | /* start all channels */ | ||
| 774 | ret = regmap_write(priv->regmap, TAS5086_SYS_CONTROL_2, 0x20); | ||
| 775 | if (ret < 0) | 836 | if (ret < 0) |
| 776 | return ret; | 837 | return ret; |
| 777 | 838 | ||
| @@ -780,12 +841,6 @@ static int tas5086_probe(struct snd_soc_codec *codec) | |||
| 780 | if (ret < 0) | 841 | if (ret < 0) |
| 781 | return ret; | 842 | return ret; |
| 782 | 843 | ||
| 783 | /* mute all channels for now */ | ||
| 784 | ret = regmap_write(priv->regmap, TAS5086_SOFT_MUTE, | ||
| 785 | TAS5086_SOFT_MUTE_ALL); | ||
| 786 | if (ret < 0) | ||
| 787 | return ret; | ||
| 788 | |||
| 789 | return 0; | 844 | return 0; |
| 790 | } | 845 | } |
| 791 | 846 | ||
| @@ -803,6 +858,7 @@ static int tas5086_remove(struct snd_soc_codec *codec) | |||
| 803 | static struct snd_soc_codec_driver soc_codec_dev_tas5086 = { | 858 | static struct snd_soc_codec_driver soc_codec_dev_tas5086 = { |
| 804 | .probe = tas5086_probe, | 859 | .probe = tas5086_probe, |
| 805 | .remove = tas5086_remove, | 860 | .remove = tas5086_remove, |
| 861 | .suspend = tas5086_soc_suspend, | ||
| 806 | .resume = tas5086_soc_resume, | 862 | .resume = tas5086_soc_resume, |
| 807 | .controls = tas5086_controls, | 863 | .controls = tas5086_controls, |
| 808 | .num_controls = ARRAY_SIZE(tas5086_controls), | 864 | .num_controls = ARRAY_SIZE(tas5086_controls), |
| @@ -862,17 +918,8 @@ static int tas5086_i2c_probe(struct i2c_client *i2c, | |||
| 862 | if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset")) | 918 | if (devm_gpio_request(dev, gpio_nreset, "TAS5086 Reset")) |
| 863 | gpio_nreset = -EINVAL; | 919 | gpio_nreset = -EINVAL; |
| 864 | 920 | ||
| 865 | if (gpio_is_valid(gpio_nreset)) { | ||
| 866 | /* Reset codec - minimum assertion time is 400ns */ | ||
| 867 | gpio_direction_output(gpio_nreset, 0); | ||
| 868 | udelay(1); | ||
| 869 | gpio_set_value(gpio_nreset, 1); | ||
| 870 | |||
| 871 | /* Codec needs ~15ms to wake up */ | ||
| 872 | msleep(15); | ||
| 873 | } | ||
| 874 | |||
| 875 | priv->gpio_nreset = gpio_nreset; | 921 | priv->gpio_nreset = gpio_nreset; |
| 922 | tas5086_reset(priv); | ||
| 876 | 923 | ||
| 877 | /* The TAS5086 always returns 0x03 in its TAS5086_DEV_ID register */ | 924 | /* The TAS5086 always returns 0x03 in its TAS5086_DEV_ID register */ |
| 878 | ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i); | 925 | ret = regmap_read(priv->regmap, TAS5086_DEV_ID, &i); |
diff --git a/sound/soc/codecs/tlv320aic23.c b/sound/soc/codecs/tlv320aic23.c index 31762ebdd774..5d430cc56f51 100644 --- a/sound/soc/codecs/tlv320aic23.c +++ b/sound/soc/codecs/tlv320aic23.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/delay.h> | 24 | #include <linux/delay.h> |
| 25 | #include <linux/pm.h> | 25 | #include <linux/pm.h> |
| 26 | #include <linux/i2c.h> | 26 | #include <linux/i2c.h> |
| 27 | #include <linux/regmap.h> | ||
| 27 | #include <linux/slab.h> | 28 | #include <linux/slab.h> |
| 28 | #include <sound/core.h> | 29 | #include <sound/core.h> |
| 29 | #include <sound/pcm.h> | 30 | #include <sound/pcm.h> |
| @@ -37,11 +38,27 @@ | |||
| 37 | /* | 38 | /* |
| 38 | * AIC23 register cache | 39 | * AIC23 register cache |
| 39 | */ | 40 | */ |
| 40 | static const u16 tlv320aic23_reg[] = { | 41 | static const struct reg_default tlv320aic23_reg[] = { |
| 41 | 0x0097, 0x0097, 0x00F9, 0x00F9, /* 0 */ | 42 | { 0, 0x0097 }, |
| 42 | 0x001A, 0x0004, 0x0007, 0x0001, /* 4 */ | 43 | { 1, 0x0097 }, |
| 43 | 0x0020, 0x0000, 0x0000, 0x0000, /* 8 */ | 44 | { 2, 0x00F9 }, |
| 44 | 0x0000, 0x0000, 0x0000, 0x0000, /* 12 */ | 45 | { 3, 0x00F9 }, |
| 46 | { 4, 0x001A }, | ||
| 47 | { 5, 0x0004 }, | ||
| 48 | { 6, 0x0007 }, | ||
| 49 | { 7, 0x0001 }, | ||
| 50 | { 8, 0x0020 }, | ||
| 51 | { 9, 0x0000 }, | ||
| 52 | }; | ||
| 53 | |||
| 54 | static const struct regmap_config tlv320aic23_regmap = { | ||
| 55 | .reg_bits = 7, | ||
| 56 | .val_bits = 9, | ||
| 57 | |||
| 58 | .max_register = TLV320AIC23_RESET, | ||
| 59 | .reg_defaults = tlv320aic23_reg, | ||
| 60 | .num_reg_defaults = ARRAY_SIZE(tlv320aic23_reg), | ||
| 61 | .cache_type = REGCACHE_RBTREE, | ||
| 45 | }; | 62 | }; |
| 46 | 63 | ||
| 47 | static const char *rec_src_text[] = { "Line", "Mic" }; | 64 | static const char *rec_src_text[] = { "Line", "Mic" }; |
| @@ -171,7 +188,7 @@ static const struct snd_soc_dapm_route tlv320aic23_intercon[] = { | |||
| 171 | 188 | ||
| 172 | /* AIC23 driver data */ | 189 | /* AIC23 driver data */ |
| 173 | struct aic23 { | 190 | struct aic23 { |
| 174 | enum snd_soc_control_type control_type; | 191 | struct regmap *regmap; |
| 175 | int mclk; | 192 | int mclk; |
| 176 | int requested_adc; | 193 | int requested_adc; |
| 177 | int requested_dac; | 194 | int requested_dac; |
| @@ -532,7 +549,9 @@ static int tlv320aic23_suspend(struct snd_soc_codec *codec) | |||
| 532 | 549 | ||
| 533 | static int tlv320aic23_resume(struct snd_soc_codec *codec) | 550 | static int tlv320aic23_resume(struct snd_soc_codec *codec) |
| 534 | { | 551 | { |
| 535 | snd_soc_cache_sync(codec); | 552 | struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); |
| 553 | regcache_mark_dirty(aic23->regmap); | ||
| 554 | regcache_sync(aic23->regmap); | ||
| 536 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 555 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 537 | 556 | ||
| 538 | return 0; | 557 | return 0; |
| @@ -540,10 +559,9 @@ static int tlv320aic23_resume(struct snd_soc_codec *codec) | |||
| 540 | 559 | ||
| 541 | static int tlv320aic23_probe(struct snd_soc_codec *codec) | 560 | static int tlv320aic23_probe(struct snd_soc_codec *codec) |
| 542 | { | 561 | { |
| 543 | struct aic23 *aic23 = snd_soc_codec_get_drvdata(codec); | ||
| 544 | int ret; | 562 | int ret; |
| 545 | 563 | ||
| 546 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, aic23->control_type); | 564 | ret = snd_soc_codec_set_cache_io(codec, 7, 9, SND_SOC_REGMAP); |
| 547 | if (ret < 0) { | 565 | if (ret < 0) { |
| 548 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 566 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 549 | return ret; | 567 | return ret; |
| @@ -552,16 +570,6 @@ static int tlv320aic23_probe(struct snd_soc_codec *codec) | |||
| 552 | /* Reset codec */ | 570 | /* Reset codec */ |
| 553 | snd_soc_write(codec, TLV320AIC23_RESET, 0); | 571 | snd_soc_write(codec, TLV320AIC23_RESET, 0); |
| 554 | 572 | ||
| 555 | /* Write the register default value to cache for reserved registers, | ||
| 556 | * so the write to the these registers are suppressed by the cache | ||
| 557 | * restore code when it skips writes of default registers. | ||
| 558 | */ | ||
| 559 | snd_soc_cache_write(codec, 0x0A, 0); | ||
| 560 | snd_soc_cache_write(codec, 0x0B, 0); | ||
| 561 | snd_soc_cache_write(codec, 0x0C, 0); | ||
| 562 | snd_soc_cache_write(codec, 0x0D, 0); | ||
| 563 | snd_soc_cache_write(codec, 0x0E, 0); | ||
| 564 | |||
| 565 | /* power on device */ | 573 | /* power on device */ |
| 566 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); | 574 | tlv320aic23_set_bias_level(codec, SND_SOC_BIAS_STANDBY); |
| 567 | 575 | ||
| @@ -586,9 +594,6 @@ static int tlv320aic23_probe(struct snd_soc_codec *codec) | |||
| 586 | 594 | ||
| 587 | snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x1); | 595 | snd_soc_write(codec, TLV320AIC23_ACTIVE, 0x1); |
| 588 | 596 | ||
| 589 | snd_soc_add_codec_controls(codec, tlv320aic23_snd_controls, | ||
| 590 | ARRAY_SIZE(tlv320aic23_snd_controls)); | ||
| 591 | |||
| 592 | return 0; | 597 | return 0; |
| 593 | } | 598 | } |
| 594 | 599 | ||
| @@ -599,21 +604,19 @@ static int tlv320aic23_remove(struct snd_soc_codec *codec) | |||
| 599 | } | 604 | } |
| 600 | 605 | ||
| 601 | static struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = { | 606 | static struct snd_soc_codec_driver soc_codec_dev_tlv320aic23 = { |
| 602 | .reg_cache_size = ARRAY_SIZE(tlv320aic23_reg), | ||
| 603 | .reg_word_size = sizeof(u16), | ||
| 604 | .reg_cache_default = tlv320aic23_reg, | ||
| 605 | .probe = tlv320aic23_probe, | 607 | .probe = tlv320aic23_probe, |
| 606 | .remove = tlv320aic23_remove, | 608 | .remove = tlv320aic23_remove, |
| 607 | .suspend = tlv320aic23_suspend, | 609 | .suspend = tlv320aic23_suspend, |
| 608 | .resume = tlv320aic23_resume, | 610 | .resume = tlv320aic23_resume, |
| 609 | .set_bias_level = tlv320aic23_set_bias_level, | 611 | .set_bias_level = tlv320aic23_set_bias_level, |
| 612 | .controls = tlv320aic23_snd_controls, | ||
| 613 | .num_controls = ARRAY_SIZE(tlv320aic23_snd_controls), | ||
| 610 | .dapm_widgets = tlv320aic23_dapm_widgets, | 614 | .dapm_widgets = tlv320aic23_dapm_widgets, |
| 611 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), | 615 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic23_dapm_widgets), |
| 612 | .dapm_routes = tlv320aic23_intercon, | 616 | .dapm_routes = tlv320aic23_intercon, |
| 613 | .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon), | 617 | .num_dapm_routes = ARRAY_SIZE(tlv320aic23_intercon), |
| 614 | }; | 618 | }; |
| 615 | 619 | ||
| 616 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
| 617 | /* | 620 | /* |
| 618 | * If the i2c layer weren't so broken, we could pass this kind of data | 621 | * If the i2c layer weren't so broken, we could pass this kind of data |
| 619 | * around | 622 | * around |
| @@ -631,8 +634,11 @@ static int tlv320aic23_codec_probe(struct i2c_client *i2c, | |||
| 631 | if (aic23 == NULL) | 634 | if (aic23 == NULL) |
| 632 | return -ENOMEM; | 635 | return -ENOMEM; |
| 633 | 636 | ||
| 637 | aic23->regmap = devm_regmap_init_i2c(i2c, &tlv320aic23_regmap); | ||
| 638 | if (IS_ERR(aic23->regmap)) | ||
| 639 | return PTR_ERR(aic23->regmap); | ||
| 640 | |||
| 634 | i2c_set_clientdata(i2c, aic23); | 641 | i2c_set_clientdata(i2c, aic23); |
| 635 | aic23->control_type = SND_SOC_I2C; | ||
| 636 | 642 | ||
| 637 | ret = snd_soc_register_codec(&i2c->dev, | 643 | ret = snd_soc_register_codec(&i2c->dev, |
| 638 | &soc_codec_dev_tlv320aic23, &tlv320aic23_dai, 1); | 644 | &soc_codec_dev_tlv320aic23, &tlv320aic23_dai, 1); |
| @@ -660,29 +666,7 @@ static struct i2c_driver tlv320aic23_i2c_driver = { | |||
| 660 | .id_table = tlv320aic23_id, | 666 | .id_table = tlv320aic23_id, |
| 661 | }; | 667 | }; |
| 662 | 668 | ||
| 663 | #endif | 669 | module_i2c_driver(tlv320aic23_i2c_driver); |
| 664 | |||
| 665 | static int __init tlv320aic23_modinit(void) | ||
| 666 | { | ||
| 667 | int ret; | ||
| 668 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
| 669 | ret = i2c_add_driver(&tlv320aic23_i2c_driver); | ||
| 670 | if (ret != 0) { | ||
| 671 | printk(KERN_ERR "Failed to register TLV320AIC23 I2C driver: %d\n", | ||
| 672 | ret); | ||
| 673 | } | ||
| 674 | #endif | ||
| 675 | return ret; | ||
| 676 | } | ||
| 677 | module_init(tlv320aic23_modinit); | ||
| 678 | |||
| 679 | static void __exit tlv320aic23_exit(void) | ||
| 680 | { | ||
| 681 | #if defined(CONFIG_I2C) || defined(CONFIG_I2C_MODULE) | ||
| 682 | i2c_del_driver(&tlv320aic23_i2c_driver); | ||
| 683 | #endif | ||
| 684 | } | ||
| 685 | module_exit(tlv320aic23_exit); | ||
| 686 | 670 | ||
| 687 | MODULE_DESCRIPTION("ASoC TLV320AIC23 codec driver"); | 671 | MODULE_DESCRIPTION("ASoC TLV320AIC23 codec driver"); |
| 688 | MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>"); | 672 | MODULE_AUTHOR("Arun KS <arunks@mistralsolutions.com>"); |
diff --git a/sound/soc/codecs/tlv320aic26.c b/sound/soc/codecs/tlv320aic26.c index 7b8f3d965f43..94a658fa6d97 100644 --- a/sound/soc/codecs/tlv320aic26.c +++ b/sound/soc/codecs/tlv320aic26.c | |||
| @@ -29,6 +29,7 @@ MODULE_LICENSE("GPL"); | |||
| 29 | /* AIC26 driver private data */ | 29 | /* AIC26 driver private data */ |
| 30 | struct aic26 { | 30 | struct aic26 { |
| 31 | struct spi_device *spi; | 31 | struct spi_device *spi; |
| 32 | struct regmap *regmap; | ||
| 32 | struct snd_soc_codec *codec; | 33 | struct snd_soc_codec *codec; |
| 33 | int master; | 34 | int master; |
| 34 | int datfm; | 35 | int datfm; |
| @@ -40,85 +41,6 @@ struct aic26 { | |||
| 40 | int keyclick_len; | 41 | int keyclick_len; |
| 41 | }; | 42 | }; |
| 42 | 43 | ||
| 43 | /* --------------------------------------------------------------------- | ||
| 44 | * Register access routines | ||
| 45 | */ | ||
| 46 | static unsigned int aic26_reg_read(struct snd_soc_codec *codec, | ||
| 47 | unsigned int reg) | ||
| 48 | { | ||
| 49 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | ||
| 50 | u16 *cache = codec->reg_cache; | ||
| 51 | u16 cmd, value; | ||
| 52 | u8 buffer[2]; | ||
| 53 | int rc; | ||
| 54 | |||
| 55 | if (reg >= AIC26_NUM_REGS) { | ||
| 56 | WARN_ON_ONCE(1); | ||
| 57 | return 0; | ||
| 58 | } | ||
| 59 | |||
| 60 | /* Do SPI transfer; first 16bits are command; remaining is | ||
| 61 | * register contents */ | ||
| 62 | cmd = AIC26_READ_COMMAND_WORD(reg); | ||
| 63 | buffer[0] = (cmd >> 8) & 0xff; | ||
| 64 | buffer[1] = cmd & 0xff; | ||
| 65 | rc = spi_write_then_read(aic26->spi, buffer, 2, buffer, 2); | ||
| 66 | if (rc) { | ||
| 67 | dev_err(&aic26->spi->dev, "AIC26 reg read error\n"); | ||
| 68 | return -EIO; | ||
| 69 | } | ||
| 70 | value = (buffer[0] << 8) | buffer[1]; | ||
| 71 | |||
| 72 | /* Update the cache before returning with the value */ | ||
| 73 | cache[reg] = value; | ||
| 74 | return value; | ||
| 75 | } | ||
| 76 | |||
| 77 | static unsigned int aic26_reg_read_cache(struct snd_soc_codec *codec, | ||
| 78 | unsigned int reg) | ||
| 79 | { | ||
| 80 | u16 *cache = codec->reg_cache; | ||
| 81 | |||
| 82 | if (reg >= AIC26_NUM_REGS) { | ||
| 83 | WARN_ON_ONCE(1); | ||
| 84 | return 0; | ||
| 85 | } | ||
| 86 | |||
| 87 | return cache[reg]; | ||
| 88 | } | ||
| 89 | |||
| 90 | static int aic26_reg_write(struct snd_soc_codec *codec, unsigned int reg, | ||
| 91 | unsigned int value) | ||
| 92 | { | ||
| 93 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | ||
| 94 | u16 *cache = codec->reg_cache; | ||
| 95 | u16 cmd; | ||
| 96 | u8 buffer[4]; | ||
| 97 | int rc; | ||
| 98 | |||
| 99 | if (reg >= AIC26_NUM_REGS) { | ||
| 100 | WARN_ON_ONCE(1); | ||
| 101 | return -EINVAL; | ||
| 102 | } | ||
| 103 | |||
| 104 | /* Do SPI transfer; first 16bits are command; remaining is data | ||
| 105 | * to write into register */ | ||
| 106 | cmd = AIC26_WRITE_COMMAND_WORD(reg); | ||
| 107 | buffer[0] = (cmd >> 8) & 0xff; | ||
| 108 | buffer[1] = cmd & 0xff; | ||
| 109 | buffer[2] = value >> 8; | ||
| 110 | buffer[3] = value; | ||
| 111 | rc = spi_write(aic26->spi, buffer, 4); | ||
| 112 | if (rc) { | ||
| 113 | dev_err(&aic26->spi->dev, "AIC26 reg read error\n"); | ||
| 114 | return -EIO; | ||
| 115 | } | ||
| 116 | |||
| 117 | /* update cache before returning */ | ||
| 118 | cache[reg] = value; | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | |||
| 122 | static const struct snd_soc_dapm_widget tlv320aic26_dapm_widgets[] = { | 44 | static const struct snd_soc_dapm_widget tlv320aic26_dapm_widgets[] = { |
| 123 | SND_SOC_DAPM_INPUT("MICIN"), | 45 | SND_SOC_DAPM_INPUT("MICIN"), |
| 124 | SND_SOC_DAPM_INPUT("AUX"), | 46 | SND_SOC_DAPM_INPUT("AUX"), |
| @@ -195,19 +117,15 @@ static int aic26_hw_params(struct snd_pcm_substream *substream, | |||
| 195 | snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); | 117 | snd_soc_write(codec, AIC26_REG_PLL_PROG2, reg); |
| 196 | 118 | ||
| 197 | /* Audio Control 3 (master mode, fsref rate) */ | 119 | /* Audio Control 3 (master mode, fsref rate) */ |
| 198 | reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL3); | ||
| 199 | reg &= ~0xf800; | ||
| 200 | if (aic26->master) | 120 | if (aic26->master) |
| 201 | reg |= 0x0800; | 121 | reg = 0x0800; |
| 202 | if (fsref == 48000) | 122 | if (fsref == 48000) |
| 203 | reg |= 0x2000; | 123 | reg = 0x2000; |
| 204 | snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); | 124 | snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL3, 0xf800, reg); |
| 205 | 125 | ||
| 206 | /* Audio Control 1 (FSref divisor) */ | 126 | /* Audio Control 1 (FSref divisor) */ |
| 207 | reg = aic26_reg_read_cache(codec, AIC26_REG_AUDIO_CTRL1); | 127 | reg = wlen | aic26->datfm | (divisor << 3) | divisor; |
| 208 | reg &= ~0x0fff; | 128 | snd_soc_update_bits(codec, AIC26_REG_AUDIO_CTRL1, 0xfff, reg); |
| 209 | reg |= wlen | aic26->datfm | (divisor << 3) | divisor; | ||
| 210 | snd_soc_write(codec, AIC26_REG_AUDIO_CTRL1, reg); | ||
| 211 | 129 | ||
| 212 | return 0; | 130 | return 0; |
| 213 | } | 131 | } |
| @@ -219,16 +137,16 @@ static int aic26_mute(struct snd_soc_dai *dai, int mute) | |||
| 219 | { | 137 | { |
| 220 | struct snd_soc_codec *codec = dai->codec; | 138 | struct snd_soc_codec *codec = dai->codec; |
| 221 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); | 139 | struct aic26 *aic26 = snd_soc_codec_get_drvdata(codec); |
| 222 | u16 reg = aic26_reg_read_cache(codec, AIC26_REG_DAC_GAIN); | 140 | u16 reg; |
| 223 | 141 | ||
| 224 | dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", | 142 | dev_dbg(&aic26->spi->dev, "aic26_mute(dai=%p, mute=%i)\n", |
| 225 | dai, mute); | 143 | dai, mute); |
| 226 | 144 | ||
| 227 | if (mute) | 145 | if (mute) |
| 228 | reg |= 0x8080; | 146 | reg = 0x8080; |
| 229 | else | 147 | else |
| 230 | reg &= ~0x8080; | 148 | reg = 0; |
| 231 | snd_soc_write(codec, AIC26_REG_DAC_GAIN, reg); | 149 | snd_soc_update_bits(codec, AIC26_REG_DAC_GAIN, 0x8000, reg); |
| 232 | 150 | ||
| 233 | return 0; | 151 | return 0; |
| 234 | } | 152 | } |
| @@ -346,7 +264,7 @@ static ssize_t aic26_keyclick_show(struct device *dev, | |||
| 346 | struct aic26 *aic26 = dev_get_drvdata(dev); | 264 | struct aic26 *aic26 = dev_get_drvdata(dev); |
| 347 | int val, amp, freq, len; | 265 | int val, amp, freq, len; |
| 348 | 266 | ||
| 349 | val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); | 267 | val = snd_soc_read(aic26->codec, AIC26_REG_AUDIO_CTRL2); |
| 350 | amp = (val >> 12) & 0x7; | 268 | amp = (val >> 12) & 0x7; |
| 351 | freq = (125 << ((val >> 8) & 0x7)) >> 1; | 269 | freq = (125 << ((val >> 8) & 0x7)) >> 1; |
| 352 | len = 2 * (1 + ((val >> 4) & 0xf)); | 270 | len = 2 * (1 + ((val >> 4) & 0xf)); |
| @@ -360,11 +278,9 @@ static ssize_t aic26_keyclick_set(struct device *dev, | |||
| 360 | const char *buf, size_t count) | 278 | const char *buf, size_t count) |
| 361 | { | 279 | { |
| 362 | struct aic26 *aic26 = dev_get_drvdata(dev); | 280 | struct aic26 *aic26 = dev_get_drvdata(dev); |
| 363 | int val; | ||
| 364 | 281 | ||
| 365 | val = aic26_reg_read_cache(aic26->codec, AIC26_REG_AUDIO_CTRL2); | 282 | snd_soc_update_bits(aic26->codec, AIC26_REG_AUDIO_CTRL2, |
| 366 | val |= 0x8000; | 283 | 0x8000, 0x800); |
| 367 | snd_soc_write(aic26->codec, AIC26_REG_AUDIO_CTRL2, val); | ||
| 368 | 284 | ||
| 369 | return count; | 285 | return count; |
| 370 | } | 286 | } |
| @@ -377,7 +293,9 @@ static DEVICE_ATTR(keyclick, 0644, aic26_keyclick_show, aic26_keyclick_set); | |||
| 377 | static int aic26_probe(struct snd_soc_codec *codec) | 293 | static int aic26_probe(struct snd_soc_codec *codec) |
| 378 | { | 294 | { |
| 379 | struct aic26 *aic26 = dev_get_drvdata(codec->dev); | 295 | struct aic26 *aic26 = dev_get_drvdata(codec->dev); |
| 380 | int ret, err, i, reg; | 296 | int ret, reg; |
| 297 | |||
| 298 | snd_soc_codec_set_cache_io(codec, 16, 16, SND_SOC_REGMAP); | ||
| 381 | 299 | ||
| 382 | aic26->codec = codec; | 300 | aic26->codec = codec; |
| 383 | 301 | ||
| @@ -393,37 +311,30 @@ static int aic26_probe(struct snd_soc_codec *codec) | |||
| 393 | reg |= 0x0800; /* set master mode */ | 311 | reg |= 0x0800; /* set master mode */ |
| 394 | snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); | 312 | snd_soc_write(codec, AIC26_REG_AUDIO_CTRL3, reg); |
| 395 | 313 | ||
| 396 | /* Fill register cache */ | ||
| 397 | for (i = 0; i < codec->driver->reg_cache_size; i++) | ||
| 398 | snd_soc_read(codec, i); | ||
| 399 | |||
| 400 | /* Register the sysfs files for debugging */ | 314 | /* Register the sysfs files for debugging */ |
| 401 | /* Create SysFS files */ | 315 | /* Create SysFS files */ |
| 402 | ret = device_create_file(codec->dev, &dev_attr_keyclick); | 316 | ret = device_create_file(codec->dev, &dev_attr_keyclick); |
| 403 | if (ret) | 317 | if (ret) |
| 404 | dev_info(codec->dev, "error creating sysfs files\n"); | 318 | dev_info(codec->dev, "error creating sysfs files\n"); |
| 405 | 319 | ||
| 406 | /* register controls */ | ||
| 407 | dev_dbg(codec->dev, "Registering controls\n"); | ||
| 408 | err = snd_soc_add_codec_controls(codec, aic26_snd_controls, | ||
| 409 | ARRAY_SIZE(aic26_snd_controls)); | ||
| 410 | WARN_ON(err < 0); | ||
| 411 | |||
| 412 | return 0; | 320 | return 0; |
| 413 | } | 321 | } |
| 414 | 322 | ||
| 415 | static struct snd_soc_codec_driver aic26_soc_codec_dev = { | 323 | static struct snd_soc_codec_driver aic26_soc_codec_dev = { |
| 416 | .probe = aic26_probe, | 324 | .probe = aic26_probe, |
| 417 | .read = aic26_reg_read, | 325 | .controls = aic26_snd_controls, |
| 418 | .write = aic26_reg_write, | 326 | .num_controls = ARRAY_SIZE(aic26_snd_controls), |
| 419 | .reg_cache_size = AIC26_NUM_REGS, | ||
| 420 | .reg_word_size = sizeof(u16), | ||
| 421 | .dapm_widgets = tlv320aic26_dapm_widgets, | 327 | .dapm_widgets = tlv320aic26_dapm_widgets, |
| 422 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), | 328 | .num_dapm_widgets = ARRAY_SIZE(tlv320aic26_dapm_widgets), |
| 423 | .dapm_routes = tlv320aic26_dapm_routes, | 329 | .dapm_routes = tlv320aic26_dapm_routes, |
| 424 | .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), | 330 | .num_dapm_routes = ARRAY_SIZE(tlv320aic26_dapm_routes), |
| 425 | }; | 331 | }; |
| 426 | 332 | ||
| 333 | static const struct regmap_config aic26_regmap = { | ||
| 334 | .reg_bits = 16, | ||
| 335 | .val_bits = 16, | ||
| 336 | }; | ||
| 337 | |||
| 427 | /* --------------------------------------------------------------------- | 338 | /* --------------------------------------------------------------------- |
| 428 | * SPI device portion of driver: probe and release routines and SPI | 339 | * SPI device portion of driver: probe and release routines and SPI |
| 429 | * driver registration. | 340 | * driver registration. |
| @@ -440,6 +351,10 @@ static int aic26_spi_probe(struct spi_device *spi) | |||
| 440 | if (!aic26) | 351 | if (!aic26) |
| 441 | return -ENOMEM; | 352 | return -ENOMEM; |
| 442 | 353 | ||
| 354 | aic26->regmap = devm_regmap_init_spi(spi, &aic26_regmap); | ||
| 355 | if (IS_ERR(aic26->regmap)) | ||
| 356 | return PTR_ERR(aic26->regmap); | ||
| 357 | |||
| 443 | /* Initialize the driver data */ | 358 | /* Initialize the driver data */ |
| 444 | aic26->spi = spi; | 359 | aic26->spi = spi; |
| 445 | dev_set_drvdata(&spi->dev, aic26); | 360 | dev_set_drvdata(&spi->dev, aic26); |
diff --git a/sound/soc/codecs/tlv320aic26.h b/sound/soc/codecs/tlv320aic26.h index 67f19c3bebe6..629b85e75409 100644 --- a/sound/soc/codecs/tlv320aic26.h +++ b/sound/soc/codecs/tlv320aic26.h | |||
| @@ -9,10 +9,7 @@ | |||
| 9 | #define _TLV320AIC16_H_ | 9 | #define _TLV320AIC16_H_ |
| 10 | 10 | ||
| 11 | /* AIC26 Registers */ | 11 | /* AIC26 Registers */ |
| 12 | #define AIC26_READ_COMMAND_WORD(addr) ((1 << 15) | (addr << 5)) | 12 | #define AIC26_PAGE_ADDR(page, offset) ((page << 11) | offset << 5) |
| 13 | #define AIC26_WRITE_COMMAND_WORD(addr) ((0 << 15) | (addr << 5)) | ||
| 14 | #define AIC26_PAGE_ADDR(page, offset) ((page << 6) | offset) | ||
| 15 | #define AIC26_NUM_REGS AIC26_PAGE_ADDR(3, 0) | ||
| 16 | 13 | ||
| 17 | /* Page 0: Auxiliary data registers */ | 14 | /* Page 0: Auxiliary data registers */ |
| 18 | #define AIC26_REG_BAT1 AIC26_PAGE_ADDR(0, 0x05) | 15 | #define AIC26_REG_BAT1 AIC26_PAGE_ADDR(0, 0x05) |
diff --git a/sound/soc/codecs/tlv320aic32x4.c b/sound/soc/codecs/tlv320aic32x4.c index 2ed57d4aa445..18cdcca9014c 100644 --- a/sound/soc/codecs/tlv320aic32x4.c +++ b/sound/soc/codecs/tlv320aic32x4.c | |||
| @@ -60,9 +60,8 @@ struct aic32x4_rate_divs { | |||
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | struct aic32x4_priv { | 62 | struct aic32x4_priv { |
| 63 | struct regmap *regmap; | ||
| 63 | u32 sysclk; | 64 | u32 sysclk; |
| 64 | u8 page_no; | ||
| 65 | void *control_data; | ||
| 66 | u32 power_cfg; | 65 | u32 power_cfg; |
| 67 | u32 micpga_routing; | 66 | u32 micpga_routing; |
| 68 | bool swapdacs; | 67 | bool swapdacs; |
| @@ -262,67 +261,25 @@ static const struct snd_soc_dapm_route aic32x4_dapm_routes[] = { | |||
| 262 | {"Right ADC", NULL, "Right Input Mixer"}, | 261 | {"Right ADC", NULL, "Right Input Mixer"}, |
| 263 | }; | 262 | }; |
| 264 | 263 | ||
| 265 | static inline int aic32x4_change_page(struct snd_soc_codec *codec, | 264 | static const struct regmap_range_cfg aic32x4_regmap_pages[] = { |
| 266 | unsigned int new_page) | 265 | { |
| 267 | { | 266 | .selector_reg = 0, |
| 268 | struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); | 267 | .selector_mask = 0xff, |
| 269 | u8 data[2]; | 268 | .window_start = 0, |
| 270 | int ret; | 269 | .window_len = 128, |
| 271 | 270 | .range_min = AIC32X4_PAGE1, | |
| 272 | data[0] = 0x00; | 271 | .range_max = AIC32X4_PAGE1 + 127, |
| 273 | data[1] = new_page & 0xff; | 272 | }, |
| 274 | 273 | }; | |
| 275 | ret = codec->hw_write(codec->control_data, data, 2); | ||
| 276 | if (ret == 2) { | ||
| 277 | aic32x4->page_no = new_page; | ||
| 278 | return 0; | ||
| 279 | } else { | ||
| 280 | return ret; | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 284 | static int aic32x4_write(struct snd_soc_codec *codec, unsigned int reg, | ||
| 285 | unsigned int val) | ||
| 286 | { | ||
| 287 | struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); | ||
| 288 | unsigned int page = reg / 128; | ||
| 289 | unsigned int fixed_reg = reg % 128; | ||
| 290 | u8 data[2]; | ||
| 291 | int ret; | ||
| 292 | |||
| 293 | /* A write to AIC32X4_PSEL is really a non-explicit page change */ | ||
| 294 | if (reg == AIC32X4_PSEL) | ||
| 295 | return aic32x4_change_page(codec, val); | ||
| 296 | |||
| 297 | if (aic32x4->page_no != page) { | ||
| 298 | ret = aic32x4_change_page(codec, page); | ||
| 299 | if (ret != 0) | ||
| 300 | return ret; | ||
| 301 | } | ||
| 302 | |||
| 303 | data[0] = fixed_reg & 0xff; | ||
| 304 | data[1] = val & 0xff; | ||
| 305 | |||
| 306 | if (codec->hw_write(codec->control_data, data, 2) == 2) | ||
| 307 | return 0; | ||
| 308 | else | ||
| 309 | return -EIO; | ||
| 310 | } | ||
| 311 | 274 | ||
| 312 | static unsigned int aic32x4_read(struct snd_soc_codec *codec, unsigned int reg) | 275 | static const struct regmap_config aic32x4_regmap = { |
| 313 | { | 276 | .reg_bits = 8, |
| 314 | struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); | 277 | .val_bits = 8, |
| 315 | unsigned int page = reg / 128; | ||
| 316 | unsigned int fixed_reg = reg % 128; | ||
| 317 | int ret; | ||
| 318 | 278 | ||
| 319 | if (aic32x4->page_no != page) { | 279 | .max_register = AIC32X4_RMICPGAVOL, |
| 320 | ret = aic32x4_change_page(codec, page); | 280 | .ranges = aic32x4_regmap_pages, |
| 321 | if (ret != 0) | 281 | .num_ranges = ARRAY_SIZE(aic32x4_regmap_pages), |
| 322 | return ret; | 282 | }; |
| 323 | } | ||
| 324 | return i2c_smbus_read_byte_data(codec->control_data, fixed_reg & 0xff); | ||
| 325 | } | ||
| 326 | 283 | ||
| 327 | static inline int aic32x4_get_divs(int mclk, int rate) | 284 | static inline int aic32x4_get_divs(int mclk, int rate) |
| 328 | { | 285 | { |
| @@ -617,16 +574,10 @@ static int aic32x4_probe(struct snd_soc_codec *codec) | |||
| 617 | { | 574 | { |
| 618 | struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); | 575 | struct aic32x4_priv *aic32x4 = snd_soc_codec_get_drvdata(codec); |
| 619 | u32 tmp_reg; | 576 | u32 tmp_reg; |
| 620 | int ret; | ||
| 621 | 577 | ||
| 622 | codec->hw_write = (hw_write_t) i2c_master_send; | 578 | snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); |
| 623 | codec->control_data = aic32x4->control_data; | ||
| 624 | 579 | ||
| 625 | if (aic32x4->rstn_gpio >= 0) { | 580 | if (aic32x4->rstn_gpio >= 0) { |
| 626 | ret = devm_gpio_request_one(codec->dev, aic32x4->rstn_gpio, | ||
| 627 | GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn"); | ||
| 628 | if (ret != 0) | ||
| 629 | return ret; | ||
| 630 | ndelay(10); | 581 | ndelay(10); |
| 631 | gpio_set_value(aic32x4->rstn_gpio, 1); | 582 | gpio_set_value(aic32x4->rstn_gpio, 1); |
| 632 | } | 583 | } |
| @@ -692,8 +643,6 @@ static int aic32x4_remove(struct snd_soc_codec *codec) | |||
| 692 | } | 643 | } |
| 693 | 644 | ||
| 694 | static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { | 645 | static struct snd_soc_codec_driver soc_codec_dev_aic32x4 = { |
| 695 | .read = aic32x4_read, | ||
| 696 | .write = aic32x4_write, | ||
| 697 | .probe = aic32x4_probe, | 646 | .probe = aic32x4_probe, |
| 698 | .remove = aic32x4_remove, | 647 | .remove = aic32x4_remove, |
| 699 | .suspend = aic32x4_suspend, | 648 | .suspend = aic32x4_suspend, |
| @@ -720,7 +669,10 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c, | |||
| 720 | if (aic32x4 == NULL) | 669 | if (aic32x4 == NULL) |
| 721 | return -ENOMEM; | 670 | return -ENOMEM; |
| 722 | 671 | ||
| 723 | aic32x4->control_data = i2c; | 672 | aic32x4->regmap = devm_regmap_init_i2c(i2c, &aic32x4_regmap); |
| 673 | if (IS_ERR(aic32x4->regmap)) | ||
| 674 | return PTR_ERR(aic32x4->regmap); | ||
| 675 | |||
| 724 | i2c_set_clientdata(i2c, aic32x4); | 676 | i2c_set_clientdata(i2c, aic32x4); |
| 725 | 677 | ||
| 726 | if (pdata) { | 678 | if (pdata) { |
| @@ -735,6 +687,13 @@ static int aic32x4_i2c_probe(struct i2c_client *i2c, | |||
| 735 | aic32x4->rstn_gpio = -1; | 687 | aic32x4->rstn_gpio = -1; |
| 736 | } | 688 | } |
| 737 | 689 | ||
| 690 | if (aic32x4->rstn_gpio >= 0) { | ||
| 691 | ret = devm_gpio_request_one(&i2c->dev, aic32x4->rstn_gpio, | ||
| 692 | GPIOF_OUT_INIT_LOW, "tlv320aic32x4 rstn"); | ||
| 693 | if (ret != 0) | ||
| 694 | return ret; | ||
| 695 | } | ||
| 696 | |||
| 738 | ret = snd_soc_register_codec(&i2c->dev, | 697 | ret = snd_soc_register_codec(&i2c->dev, |
| 739 | &soc_codec_dev_aic32x4, &aic32x4_dai, 1); | 698 | &soc_codec_dev_aic32x4, &aic32x4_dai, 1); |
| 740 | return ret; | 699 | return ret; |
diff --git a/sound/soc/codecs/tlv320aic3x.c b/sound/soc/codecs/tlv320aic3x.c index 6e3f269243e0..546d16b7d38f 100644 --- a/sound/soc/codecs/tlv320aic3x.c +++ b/sound/soc/codecs/tlv320aic3x.c | |||
| @@ -40,6 +40,7 @@ | |||
| 40 | #include <linux/i2c.h> | 40 | #include <linux/i2c.h> |
| 41 | #include <linux/gpio.h> | 41 | #include <linux/gpio.h> |
| 42 | #include <linux/regulator/consumer.h> | 42 | #include <linux/regulator/consumer.h> |
| 43 | #include <linux/of.h> | ||
| 43 | #include <linux/of_gpio.h> | 44 | #include <linux/of_gpio.h> |
| 44 | #include <linux/slab.h> | 45 | #include <linux/slab.h> |
| 45 | #include <sound/core.h> | 46 | #include <sound/core.h> |
| @@ -72,9 +73,9 @@ struct aic3x_disable_nb { | |||
| 72 | /* codec private data */ | 73 | /* codec private data */ |
| 73 | struct aic3x_priv { | 74 | struct aic3x_priv { |
| 74 | struct snd_soc_codec *codec; | 75 | struct snd_soc_codec *codec; |
| 76 | struct regmap *regmap; | ||
| 75 | struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES]; | 77 | struct regulator_bulk_data supplies[AIC3X_NUM_SUPPLIES]; |
| 76 | struct aic3x_disable_nb disable_nb[AIC3X_NUM_SUPPLIES]; | 78 | struct aic3x_disable_nb disable_nb[AIC3X_NUM_SUPPLIES]; |
| 77 | enum snd_soc_control_type control_type; | ||
| 78 | struct aic3x_setup_data *setup; | 79 | struct aic3x_setup_data *setup; |
| 79 | unsigned int sysclk; | 80 | unsigned int sysclk; |
| 80 | struct list_head list; | 81 | struct list_head list; |
| @@ -90,41 +91,45 @@ struct aic3x_priv { | |||
| 90 | enum aic3x_micbias_voltage micbias_vg; | 91 | enum aic3x_micbias_voltage micbias_vg; |
| 91 | }; | 92 | }; |
| 92 | 93 | ||
| 93 | /* | 94 | static const struct reg_default aic3x_reg[] = { |
| 94 | * AIC3X register cache | 95 | { 0, 0x00 }, { 1, 0x00 }, { 2, 0x00 }, { 3, 0x10 }, |
| 95 | * We can't read the AIC3X register space when we are | 96 | { 4, 0x04 }, { 5, 0x00 }, { 6, 0x00 }, { 7, 0x00 }, |
| 96 | * using 2 wire for device control, so we cache them instead. | 97 | { 8, 0x00 }, { 9, 0x00 }, { 10, 0x00 }, { 11, 0x01 }, |
| 97 | * There is no point in caching the reset register | 98 | { 12, 0x00 }, { 13, 0x00 }, { 14, 0x00 }, { 15, 0x80 }, |
| 98 | */ | 99 | { 16, 0x80 }, { 17, 0xff }, { 18, 0xff }, { 19, 0x78 }, |
| 99 | static const u8 aic3x_reg[AIC3X_CACHEREGNUM] = { | 100 | { 20, 0x78 }, { 21, 0x78 }, { 22, 0x78 }, { 23, 0x78 }, |
| 100 | 0x00, 0x00, 0x00, 0x10, /* 0 */ | 101 | { 24, 0x78 }, { 25, 0x00 }, { 26, 0x00 }, { 27, 0xfe }, |
| 101 | 0x04, 0x00, 0x00, 0x00, /* 4 */ | 102 | { 28, 0x00 }, { 29, 0x00 }, { 30, 0xfe }, { 31, 0x00 }, |
| 102 | 0x00, 0x00, 0x00, 0x01, /* 8 */ | 103 | { 32, 0x18 }, { 33, 0x18 }, { 34, 0x00 }, { 35, 0x00 }, |
| 103 | 0x00, 0x00, 0x00, 0x80, /* 12 */ | 104 | { 36, 0x00 }, { 37, 0x00 }, { 38, 0x00 }, { 39, 0x00 }, |
| 104 | 0x80, 0xff, 0xff, 0x78, /* 16 */ | 105 | { 40, 0x00 }, { 41, 0x00 }, { 42, 0x00 }, { 43, 0x80 }, |
| 105 | 0x78, 0x78, 0x78, 0x78, /* 20 */ | 106 | { 44, 0x80 }, { 45, 0x00 }, { 46, 0x00 }, { 47, 0x00 }, |
| 106 | 0x78, 0x00, 0x00, 0xfe, /* 24 */ | 107 | { 48, 0x00 }, { 49, 0x00 }, { 50, 0x00 }, { 51, 0x04 }, |
| 107 | 0x00, 0x00, 0xfe, 0x00, /* 28 */ | 108 | { 52, 0x00 }, { 53, 0x00 }, { 54, 0x00 }, { 55, 0x00 }, |
| 108 | 0x18, 0x18, 0x00, 0x00, /* 32 */ | 109 | { 56, 0x00 }, { 57, 0x00 }, { 58, 0x04 }, { 59, 0x00 }, |
| 109 | 0x00, 0x00, 0x00, 0x00, /* 36 */ | 110 | { 60, 0x00 }, { 61, 0x00 }, { 62, 0x00 }, { 63, 0x00 }, |
| 110 | 0x00, 0x00, 0x00, 0x80, /* 40 */ | 111 | { 64, 0x00 }, { 65, 0x04 }, { 66, 0x00 }, { 67, 0x00 }, |
| 111 | 0x80, 0x00, 0x00, 0x00, /* 44 */ | 112 | { 68, 0x00 }, { 69, 0x00 }, { 70, 0x00 }, { 71, 0x00 }, |
| 112 | 0x00, 0x00, 0x00, 0x04, /* 48 */ | 113 | { 72, 0x04 }, { 73, 0x00 }, { 74, 0x00 }, { 75, 0x00 }, |
| 113 | 0x00, 0x00, 0x00, 0x00, /* 52 */ | 114 | { 76, 0x00 }, { 77, 0x00 }, { 78, 0x00 }, { 79, 0x00 }, |
| 114 | 0x00, 0x00, 0x04, 0x00, /* 56 */ | 115 | { 80, 0x00 }, { 81, 0x00 }, { 82, 0x00 }, { 83, 0x00 }, |
| 115 | 0x00, 0x00, 0x00, 0x00, /* 60 */ | 116 | { 84, 0x00 }, { 85, 0x00 }, { 86, 0x00 }, { 87, 0x00 }, |
| 116 | 0x00, 0x04, 0x00, 0x00, /* 64 */ | 117 | { 88, 0x00 }, { 89, 0x00 }, { 90, 0x00 }, { 91, 0x00 }, |
| 117 | 0x00, 0x00, 0x00, 0x00, /* 68 */ | 118 | { 92, 0x00 }, { 93, 0x00 }, { 94, 0x00 }, { 95, 0x00 }, |
| 118 | 0x04, 0x00, 0x00, 0x00, /* 72 */ | 119 | { 96, 0x00 }, { 97, 0x00 }, { 98, 0x00 }, { 99, 0x00 }, |
| 119 | 0x00, 0x00, 0x00, 0x00, /* 76 */ | 120 | { 100, 0x00 }, { 101, 0x00 }, { 102, 0x02 }, { 103, 0x00 }, |
| 120 | 0x00, 0x00, 0x00, 0x00, /* 80 */ | 121 | { 104, 0x00 }, { 105, 0x00 }, { 106, 0x00 }, { 107, 0x00 }, |
| 121 | 0x00, 0x00, 0x00, 0x00, /* 84 */ | 122 | { 108, 0x00 }, { 109, 0x00 }, |
| 122 | 0x00, 0x00, 0x00, 0x00, /* 88 */ | 123 | }; |
| 123 | 0x00, 0x00, 0x00, 0x00, /* 92 */ | 124 | |
| 124 | 0x00, 0x00, 0x00, 0x00, /* 96 */ | 125 | static const struct regmap_config aic3x_regmap = { |
| 125 | 0x00, 0x00, 0x02, 0x00, /* 100 */ | 126 | .reg_bits = 8, |
| 126 | 0x00, 0x00, 0x00, 0x00, /* 104 */ | 127 | .val_bits = 8, |
| 127 | 0x00, 0x00, /* 108 */ | 128 | |
| 129 | .max_register = DAC_ICC_ADJ, | ||
| 130 | .reg_defaults = aic3x_reg, | ||
| 131 | .num_reg_defaults = ARRAY_SIZE(aic3x_reg), | ||
| 132 | .cache_type = REGCACHE_RBTREE, | ||
| 128 | }; | 133 | }; |
| 129 | 134 | ||
| 130 | #define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \ | 135 | #define SOC_DAPM_SINGLE_AIC3X(xname, reg, shift, mask, invert) \ |
| @@ -674,6 +679,8 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
| 674 | /* Left Input */ | 679 | /* Left Input */ |
| 675 | {"Left Line1L Mux", "single-ended", "LINE1L"}, | 680 | {"Left Line1L Mux", "single-ended", "LINE1L"}, |
| 676 | {"Left Line1L Mux", "differential", "LINE1L"}, | 681 | {"Left Line1L Mux", "differential", "LINE1L"}, |
| 682 | {"Left Line1R Mux", "single-ended", "LINE1R"}, | ||
| 683 | {"Left Line1R Mux", "differential", "LINE1R"}, | ||
| 677 | 684 | ||
| 678 | {"Left Line2L Mux", "single-ended", "LINE2L"}, | 685 | {"Left Line2L Mux", "single-ended", "LINE2L"}, |
| 679 | {"Left Line2L Mux", "differential", "LINE2L"}, | 686 | {"Left Line2L Mux", "differential", "LINE2L"}, |
| @@ -690,6 +697,8 @@ static const struct snd_soc_dapm_route intercon[] = { | |||
| 690 | /* Right Input */ | 697 | /* Right Input */ |
| 691 | {"Right Line1R Mux", "single-ended", "LINE1R"}, | 698 | {"Right Line1R Mux", "single-ended", "LINE1R"}, |
| 692 | {"Right Line1R Mux", "differential", "LINE1R"}, | 699 | {"Right Line1R Mux", "differential", "LINE1R"}, |
| 700 | {"Right Line1L Mux", "single-ended", "LINE1L"}, | ||
| 701 | {"Right Line1L Mux", "differential", "LINE1L"}, | ||
| 693 | 702 | ||
| 694 | {"Right Line2R Mux", "single-ended", "LINE2R"}, | 703 | {"Right Line2R Mux", "single-ended", "LINE2R"}, |
| 695 | {"Right Line2R Mux", "differential", "LINE2R"}, | 704 | {"Right Line2R Mux", "differential", "LINE2R"}, |
| @@ -824,12 +833,6 @@ static int aic3x_add_widgets(struct snd_soc_codec *codec) | |||
| 824 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); | 833 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); |
| 825 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 834 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 826 | 835 | ||
| 827 | snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets, | ||
| 828 | ARRAY_SIZE(aic3x_dapm_widgets)); | ||
| 829 | |||
| 830 | /* set up audio path interconnects */ | ||
| 831 | snd_soc_dapm_add_routes(dapm, intercon, ARRAY_SIZE(intercon)); | ||
| 832 | |||
| 833 | if (aic3x->model == AIC3X_MODEL_3007) { | 836 | if (aic3x->model == AIC3X_MODEL_3007) { |
| 834 | snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets, | 837 | snd_soc_dapm_new_controls(dapm, aic3007_dapm_widgets, |
| 835 | ARRAY_SIZE(aic3007_dapm_widgets)); | 838 | ARRAY_SIZE(aic3007_dapm_widgets)); |
| @@ -1078,29 +1081,6 @@ static int aic3x_set_dai_fmt(struct snd_soc_dai *codec_dai, | |||
| 1078 | return 0; | 1081 | return 0; |
| 1079 | } | 1082 | } |
| 1080 | 1083 | ||
| 1081 | static int aic3x_init_3007(struct snd_soc_codec *codec) | ||
| 1082 | { | ||
| 1083 | u8 tmp1, tmp2, *cache = codec->reg_cache; | ||
| 1084 | |||
| 1085 | /* | ||
| 1086 | * There is no need to cache writes to undocumented page 0xD but | ||
| 1087 | * respective page 0 register cache entries must be preserved | ||
| 1088 | */ | ||
| 1089 | tmp1 = cache[0xD]; | ||
| 1090 | tmp2 = cache[0x8]; | ||
| 1091 | /* Class-D speaker driver init; datasheet p. 46 */ | ||
| 1092 | snd_soc_write(codec, AIC3X_PAGE_SELECT, 0x0D); | ||
| 1093 | snd_soc_write(codec, 0xD, 0x0D); | ||
| 1094 | snd_soc_write(codec, 0x8, 0x5C); | ||
| 1095 | snd_soc_write(codec, 0x8, 0x5D); | ||
| 1096 | snd_soc_write(codec, 0x8, 0x5C); | ||
| 1097 | snd_soc_write(codec, AIC3X_PAGE_SELECT, 0x00); | ||
| 1098 | cache[0xD] = tmp1; | ||
| 1099 | cache[0x8] = tmp2; | ||
| 1100 | |||
| 1101 | return 0; | ||
| 1102 | } | ||
| 1103 | |||
| 1104 | static int aic3x_regulator_event(struct notifier_block *nb, | 1084 | static int aic3x_regulator_event(struct notifier_block *nb, |
| 1105 | unsigned long event, void *data) | 1085 | unsigned long event, void *data) |
| 1106 | { | 1086 | { |
| @@ -1115,7 +1095,7 @@ static int aic3x_regulator_event(struct notifier_block *nb, | |||
| 1115 | */ | 1095 | */ |
| 1116 | if (gpio_is_valid(aic3x->gpio_reset)) | 1096 | if (gpio_is_valid(aic3x->gpio_reset)) |
| 1117 | gpio_set_value(aic3x->gpio_reset, 0); | 1097 | gpio_set_value(aic3x->gpio_reset, 0); |
| 1118 | aic3x->codec->cache_sync = 1; | 1098 | regcache_mark_dirty(aic3x->regmap); |
| 1119 | } | 1099 | } |
| 1120 | 1100 | ||
| 1121 | return 0; | 1101 | return 0; |
| @@ -1124,8 +1104,7 @@ static int aic3x_regulator_event(struct notifier_block *nb, | |||
| 1124 | static int aic3x_set_power(struct snd_soc_codec *codec, int power) | 1104 | static int aic3x_set_power(struct snd_soc_codec *codec, int power) |
| 1125 | { | 1105 | { |
| 1126 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); | 1106 | struct aic3x_priv *aic3x = snd_soc_codec_get_drvdata(codec); |
| 1127 | int i, ret; | 1107 | int ret; |
| 1128 | u8 *cache = codec->reg_cache; | ||
| 1129 | 1108 | ||
| 1130 | if (power) { | 1109 | if (power) { |
| 1131 | ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies), | 1110 | ret = regulator_bulk_enable(ARRAY_SIZE(aic3x->supplies), |
| @@ -1133,12 +1112,6 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) | |||
| 1133 | if (ret) | 1112 | if (ret) |
| 1134 | goto out; | 1113 | goto out; |
| 1135 | aic3x->power = 1; | 1114 | aic3x->power = 1; |
| 1136 | /* | ||
| 1137 | * Reset release and cache sync is necessary only if some | ||
| 1138 | * supply was off or if there were cached writes | ||
| 1139 | */ | ||
| 1140 | if (!codec->cache_sync) | ||
| 1141 | goto out; | ||
| 1142 | 1115 | ||
| 1143 | if (gpio_is_valid(aic3x->gpio_reset)) { | 1116 | if (gpio_is_valid(aic3x->gpio_reset)) { |
| 1144 | udelay(1); | 1117 | udelay(1); |
| @@ -1146,12 +1119,8 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) | |||
| 1146 | } | 1119 | } |
| 1147 | 1120 | ||
| 1148 | /* Sync reg_cache with the hardware */ | 1121 | /* Sync reg_cache with the hardware */ |
| 1149 | codec->cache_only = 0; | 1122 | regcache_cache_only(aic3x->regmap, false); |
| 1150 | for (i = AIC3X_SAMPLE_RATE_SEL_REG; i < ARRAY_SIZE(aic3x_reg); i++) | 1123 | regcache_sync(aic3x->regmap); |
| 1151 | snd_soc_write(codec, i, cache[i]); | ||
| 1152 | if (aic3x->model == AIC3X_MODEL_3007) | ||
| 1153 | aic3x_init_3007(codec); | ||
| 1154 | codec->cache_sync = 0; | ||
| 1155 | } else { | 1124 | } else { |
| 1156 | /* | 1125 | /* |
| 1157 | * Do soft reset to this codec instance in order to clear | 1126 | * Do soft reset to this codec instance in order to clear |
| @@ -1159,10 +1128,10 @@ static int aic3x_set_power(struct snd_soc_codec *codec, int power) | |||
| 1159 | * remain on | 1128 | * remain on |
| 1160 | */ | 1129 | */ |
| 1161 | snd_soc_write(codec, AIC3X_RESET, SOFT_RESET); | 1130 | snd_soc_write(codec, AIC3X_RESET, SOFT_RESET); |
| 1162 | codec->cache_sync = 1; | 1131 | regcache_mark_dirty(aic3x->regmap); |
| 1163 | aic3x->power = 0; | 1132 | aic3x->power = 0; |
| 1164 | /* HW writes are needless when bias is off */ | 1133 | /* HW writes are needless when bias is off */ |
| 1165 | codec->cache_only = 1; | 1134 | regcache_cache_only(aic3x->regmap, true); |
| 1166 | ret = regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), | 1135 | ret = regulator_bulk_disable(ARRAY_SIZE(aic3x->supplies), |
| 1167 | aic3x->supplies); | 1136 | aic3x->supplies); |
| 1168 | } | 1137 | } |
| @@ -1317,7 +1286,6 @@ static int aic3x_init(struct snd_soc_codec *codec) | |||
| 1317 | snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); | 1286 | snd_soc_write(codec, LINE2R_2_MONOLOPM_VOL, DEFAULT_VOL); |
| 1318 | 1287 | ||
| 1319 | if (aic3x->model == AIC3X_MODEL_3007) { | 1288 | if (aic3x->model == AIC3X_MODEL_3007) { |
| 1320 | aic3x_init_3007(codec); | ||
| 1321 | snd_soc_write(codec, CLASSD_CTRL, 0); | 1289 | snd_soc_write(codec, CLASSD_CTRL, 0); |
| 1322 | } | 1290 | } |
| 1323 | 1291 | ||
| @@ -1345,29 +1313,12 @@ static int aic3x_probe(struct snd_soc_codec *codec) | |||
| 1345 | INIT_LIST_HEAD(&aic3x->list); | 1313 | INIT_LIST_HEAD(&aic3x->list); |
| 1346 | aic3x->codec = codec; | 1314 | aic3x->codec = codec; |
| 1347 | 1315 | ||
| 1348 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, aic3x->control_type); | 1316 | ret = snd_soc_codec_set_cache_io(codec, 8, 8, SND_SOC_REGMAP); |
| 1349 | if (ret != 0) { | 1317 | if (ret != 0) { |
| 1350 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); | 1318 | dev_err(codec->dev, "Failed to set cache I/O: %d\n", ret); |
| 1351 | return ret; | 1319 | return ret; |
| 1352 | } | 1320 | } |
| 1353 | 1321 | ||
| 1354 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1355 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1356 | ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); | ||
| 1357 | if (ret != 0) | ||
| 1358 | goto err_gpio; | ||
| 1359 | gpio_direction_output(aic3x->gpio_reset, 0); | ||
| 1360 | } | ||
| 1361 | |||
| 1362 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | ||
| 1363 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | ||
| 1364 | |||
| 1365 | ret = regulator_bulk_get(codec->dev, ARRAY_SIZE(aic3x->supplies), | ||
| 1366 | aic3x->supplies); | ||
| 1367 | if (ret != 0) { | ||
| 1368 | dev_err(codec->dev, "Failed to request supplies: %d\n", ret); | ||
| 1369 | goto err_get; | ||
| 1370 | } | ||
| 1371 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { | 1322 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) { |
| 1372 | aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; | 1323 | aic3x->disable_nb[i].nb.notifier_call = aic3x_regulator_event; |
| 1373 | aic3x->disable_nb[i].aic3x = aic3x; | 1324 | aic3x->disable_nb[i].aic3x = aic3x; |
| @@ -1381,7 +1332,7 @@ static int aic3x_probe(struct snd_soc_codec *codec) | |||
| 1381 | } | 1332 | } |
| 1382 | } | 1333 | } |
| 1383 | 1334 | ||
| 1384 | codec->cache_only = 1; | 1335 | regcache_mark_dirty(aic3x->regmap); |
| 1385 | aic3x_init(codec); | 1336 | aic3x_init(codec); |
| 1386 | 1337 | ||
| 1387 | if (aic3x->setup) { | 1338 | if (aic3x->setup) { |
| @@ -1392,8 +1343,6 @@ static int aic3x_probe(struct snd_soc_codec *codec) | |||
| 1392 | (aic3x->setup->gpio_func[1] & 0xf) << 4); | 1343 | (aic3x->setup->gpio_func[1] & 0xf) << 4); |
| 1393 | } | 1344 | } |
| 1394 | 1345 | ||
| 1395 | snd_soc_add_codec_controls(codec, aic3x_snd_controls, | ||
| 1396 | ARRAY_SIZE(aic3x_snd_controls)); | ||
| 1397 | if (aic3x->model == AIC3X_MODEL_3007) | 1346 | if (aic3x->model == AIC3X_MODEL_3007) |
| 1398 | snd_soc_add_codec_controls(codec, &aic3x_classd_amp_gain_ctrl, 1); | 1347 | snd_soc_add_codec_controls(codec, &aic3x_classd_amp_gain_ctrl, 1); |
| 1399 | 1348 | ||
| @@ -1424,12 +1373,6 @@ err_notif: | |||
| 1424 | while (i--) | 1373 | while (i--) |
| 1425 | regulator_unregister_notifier(aic3x->supplies[i].consumer, | 1374 | regulator_unregister_notifier(aic3x->supplies[i].consumer, |
| 1426 | &aic3x->disable_nb[i].nb); | 1375 | &aic3x->disable_nb[i].nb); |
| 1427 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
| 1428 | err_get: | ||
| 1429 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1430 | !aic3x_is_shared_reset(aic3x)) | ||
| 1431 | gpio_free(aic3x->gpio_reset); | ||
| 1432 | err_gpio: | ||
| 1433 | return ret; | 1376 | return ret; |
| 1434 | } | 1377 | } |
| 1435 | 1378 | ||
| @@ -1440,15 +1383,9 @@ static int aic3x_remove(struct snd_soc_codec *codec) | |||
| 1440 | 1383 | ||
| 1441 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); | 1384 | aic3x_set_bias_level(codec, SND_SOC_BIAS_OFF); |
| 1442 | list_del(&aic3x->list); | 1385 | list_del(&aic3x->list); |
| 1443 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1444 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1445 | gpio_set_value(aic3x->gpio_reset, 0); | ||
| 1446 | gpio_free(aic3x->gpio_reset); | ||
| 1447 | } | ||
| 1448 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | 1386 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) |
| 1449 | regulator_unregister_notifier(aic3x->supplies[i].consumer, | 1387 | regulator_unregister_notifier(aic3x->supplies[i].consumer, |
| 1450 | &aic3x->disable_nb[i].nb); | 1388 | &aic3x->disable_nb[i].nb); |
| 1451 | regulator_bulk_free(ARRAY_SIZE(aic3x->supplies), aic3x->supplies); | ||
| 1452 | 1389 | ||
| 1453 | return 0; | 1390 | return 0; |
| 1454 | } | 1391 | } |
| @@ -1456,13 +1393,16 @@ static int aic3x_remove(struct snd_soc_codec *codec) | |||
| 1456 | static struct snd_soc_codec_driver soc_codec_dev_aic3x = { | 1393 | static struct snd_soc_codec_driver soc_codec_dev_aic3x = { |
| 1457 | .set_bias_level = aic3x_set_bias_level, | 1394 | .set_bias_level = aic3x_set_bias_level, |
| 1458 | .idle_bias_off = true, | 1395 | .idle_bias_off = true, |
| 1459 | .reg_cache_size = ARRAY_SIZE(aic3x_reg), | ||
| 1460 | .reg_word_size = sizeof(u8), | ||
| 1461 | .reg_cache_default = aic3x_reg, | ||
| 1462 | .probe = aic3x_probe, | 1396 | .probe = aic3x_probe, |
| 1463 | .remove = aic3x_remove, | 1397 | .remove = aic3x_remove, |
| 1464 | .suspend = aic3x_suspend, | 1398 | .suspend = aic3x_suspend, |
| 1465 | .resume = aic3x_resume, | 1399 | .resume = aic3x_resume, |
| 1400 | .controls = aic3x_snd_controls, | ||
| 1401 | .num_controls = ARRAY_SIZE(aic3x_snd_controls), | ||
| 1402 | .dapm_widgets = aic3x_dapm_widgets, | ||
| 1403 | .num_dapm_widgets = ARRAY_SIZE(aic3x_dapm_widgets), | ||
| 1404 | .dapm_routes = intercon, | ||
| 1405 | .num_dapm_routes = ARRAY_SIZE(intercon), | ||
| 1466 | }; | 1406 | }; |
| 1467 | 1407 | ||
| 1468 | /* | 1408 | /* |
| @@ -1479,6 +1419,16 @@ static const struct i2c_device_id aic3x_i2c_id[] = { | |||
| 1479 | }; | 1419 | }; |
| 1480 | MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id); | 1420 | MODULE_DEVICE_TABLE(i2c, aic3x_i2c_id); |
| 1481 | 1421 | ||
| 1422 | static const struct reg_default aic3007_class_d[] = { | ||
| 1423 | /* Class-D speaker driver init; datasheet p. 46 */ | ||
| 1424 | { AIC3X_PAGE_SELECT, 0x0D }, | ||
| 1425 | { 0xD, 0x0D }, | ||
| 1426 | { 0x8, 0x5C }, | ||
| 1427 | { 0x8, 0x5D }, | ||
| 1428 | { 0x8, 0x5C }, | ||
| 1429 | { AIC3X_PAGE_SELECT, 0x00 }, | ||
| 1430 | }; | ||
| 1431 | |||
| 1482 | /* | 1432 | /* |
| 1483 | * If the i2c layer weren't so broken, we could pass this kind of data | 1433 | * If the i2c layer weren't so broken, we could pass this kind of data |
| 1484 | * around | 1434 | * around |
| @@ -1490,7 +1440,7 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1490 | struct aic3x_priv *aic3x; | 1440 | struct aic3x_priv *aic3x; |
| 1491 | struct aic3x_setup_data *ai3x_setup; | 1441 | struct aic3x_setup_data *ai3x_setup; |
| 1492 | struct device_node *np = i2c->dev.of_node; | 1442 | struct device_node *np = i2c->dev.of_node; |
| 1493 | int ret; | 1443 | int ret, i; |
| 1494 | u32 value; | 1444 | u32 value; |
| 1495 | 1445 | ||
| 1496 | aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); | 1446 | aic3x = devm_kzalloc(&i2c->dev, sizeof(struct aic3x_priv), GFP_KERNEL); |
| @@ -1499,7 +1449,13 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1499 | return -ENOMEM; | 1449 | return -ENOMEM; |
| 1500 | } | 1450 | } |
| 1501 | 1451 | ||
| 1502 | aic3x->control_type = SND_SOC_I2C; | 1452 | aic3x->regmap = devm_regmap_init_i2c(i2c, &aic3x_regmap); |
| 1453 | if (IS_ERR(aic3x->regmap)) { | ||
| 1454 | ret = PTR_ERR(aic3x->regmap); | ||
| 1455 | return ret; | ||
| 1456 | } | ||
| 1457 | |||
| 1458 | regcache_cache_only(aic3x->regmap, true); | ||
| 1503 | 1459 | ||
| 1504 | i2c_set_clientdata(i2c, aic3x); | 1460 | i2c_set_clientdata(i2c, aic3x); |
| 1505 | if (pdata) { | 1461 | if (pdata) { |
| @@ -1551,14 +1507,54 @@ static int aic3x_i2c_probe(struct i2c_client *i2c, | |||
| 1551 | 1507 | ||
| 1552 | aic3x->model = id->driver_data; | 1508 | aic3x->model = id->driver_data; |
| 1553 | 1509 | ||
| 1510 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1511 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1512 | ret = gpio_request(aic3x->gpio_reset, "tlv320aic3x reset"); | ||
| 1513 | if (ret != 0) | ||
| 1514 | goto err; | ||
| 1515 | gpio_direction_output(aic3x->gpio_reset, 0); | ||
| 1516 | } | ||
| 1517 | |||
| 1518 | for (i = 0; i < ARRAY_SIZE(aic3x->supplies); i++) | ||
| 1519 | aic3x->supplies[i].supply = aic3x_supply_names[i]; | ||
| 1520 | |||
| 1521 | ret = devm_regulator_bulk_get(&i2c->dev, ARRAY_SIZE(aic3x->supplies), | ||
| 1522 | aic3x->supplies); | ||
| 1523 | if (ret != 0) { | ||
| 1524 | dev_err(&i2c->dev, "Failed to request supplies: %d\n", ret); | ||
| 1525 | goto err_gpio; | ||
| 1526 | } | ||
| 1527 | |||
| 1528 | if (aic3x->model == AIC3X_MODEL_3007) { | ||
| 1529 | ret = regmap_register_patch(aic3x->regmap, aic3007_class_d, | ||
| 1530 | ARRAY_SIZE(aic3007_class_d)); | ||
| 1531 | if (ret != 0) | ||
| 1532 | dev_err(&i2c->dev, "Failed to init class D: %d\n", | ||
| 1533 | ret); | ||
| 1534 | } | ||
| 1535 | |||
| 1554 | ret = snd_soc_register_codec(&i2c->dev, | 1536 | ret = snd_soc_register_codec(&i2c->dev, |
| 1555 | &soc_codec_dev_aic3x, &aic3x_dai, 1); | 1537 | &soc_codec_dev_aic3x, &aic3x_dai, 1); |
| 1556 | return ret; | 1538 | return ret; |
| 1539 | |||
| 1540 | err_gpio: | ||
| 1541 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1542 | !aic3x_is_shared_reset(aic3x)) | ||
| 1543 | gpio_free(aic3x->gpio_reset); | ||
| 1544 | err: | ||
| 1545 | return ret; | ||
| 1557 | } | 1546 | } |
| 1558 | 1547 | ||
| 1559 | static int aic3x_i2c_remove(struct i2c_client *client) | 1548 | static int aic3x_i2c_remove(struct i2c_client *client) |
| 1560 | { | 1549 | { |
| 1550 | struct aic3x_priv *aic3x = i2c_get_clientdata(client); | ||
| 1551 | |||
| 1561 | snd_soc_unregister_codec(&client->dev); | 1552 | snd_soc_unregister_codec(&client->dev); |
| 1553 | if (gpio_is_valid(aic3x->gpio_reset) && | ||
| 1554 | !aic3x_is_shared_reset(aic3x)) { | ||
| 1555 | gpio_set_value(aic3x->gpio_reset, 0); | ||
| 1556 | gpio_free(aic3x->gpio_reset); | ||
| 1557 | } | ||
| 1562 | return 0; | 1558 | return 0; |
| 1563 | } | 1559 | } |
| 1564 | 1560 | ||
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index c58bee8346ce..998555f2a8aa 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <sound/tpa6130a2-plat.h> | 30 | #include <sound/tpa6130a2-plat.h> |
| 31 | #include <sound/soc.h> | 31 | #include <sound/soc.h> |
| 32 | #include <sound/tlv.h> | 32 | #include <sound/tlv.h> |
| 33 | #include <linux/of_gpio.h> | ||
| 33 | 34 | ||
| 34 | #include "tpa6130a2.h" | 35 | #include "tpa6130a2.h" |
| 35 | 36 | ||
| @@ -364,30 +365,33 @@ static int tpa6130a2_probe(struct i2c_client *client, | |||
| 364 | { | 365 | { |
| 365 | struct device *dev; | 366 | struct device *dev; |
| 366 | struct tpa6130a2_data *data; | 367 | struct tpa6130a2_data *data; |
| 367 | struct tpa6130a2_platform_data *pdata; | 368 | struct tpa6130a2_platform_data *pdata = client->dev.platform_data; |
| 369 | struct device_node *np = client->dev.of_node; | ||
| 368 | const char *regulator; | 370 | const char *regulator; |
| 369 | int ret; | 371 | int ret; |
| 370 | 372 | ||
| 371 | dev = &client->dev; | 373 | dev = &client->dev; |
| 372 | 374 | ||
| 373 | if (client->dev.platform_data == NULL) { | ||
| 374 | dev_err(dev, "Platform data not set\n"); | ||
| 375 | dump_stack(); | ||
| 376 | return -ENODEV; | ||
| 377 | } | ||
| 378 | |||
| 379 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); | 375 | data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); |
| 380 | if (data == NULL) { | 376 | if (data == NULL) { |
| 381 | dev_err(dev, "Can not allocate memory\n"); | 377 | dev_err(dev, "Can not allocate memory\n"); |
| 382 | return -ENOMEM; | 378 | return -ENOMEM; |
| 383 | } | 379 | } |
| 384 | 380 | ||
| 381 | if (pdata) { | ||
| 382 | data->power_gpio = pdata->power_gpio; | ||
| 383 | } else if (np) { | ||
| 384 | data->power_gpio = of_get_named_gpio(np, "power-gpio", 0); | ||
| 385 | } else { | ||
| 386 | dev_err(dev, "Platform data not set\n"); | ||
| 387 | dump_stack(); | ||
| 388 | return -ENODEV; | ||
| 389 | } | ||
| 390 | |||
| 385 | tpa6130a2_client = client; | 391 | tpa6130a2_client = client; |
| 386 | 392 | ||
| 387 | i2c_set_clientdata(tpa6130a2_client, data); | 393 | i2c_set_clientdata(tpa6130a2_client, data); |
| 388 | 394 | ||
| 389 | pdata = client->dev.platform_data; | ||
| 390 | data->power_gpio = pdata->power_gpio; | ||
| 391 | data->id = id->driver_data; | 395 | data->id = id->driver_data; |
| 392 | 396 | ||
| 393 | mutex_init(&data->mutex); | 397 | mutex_init(&data->mutex); |
| @@ -466,10 +470,20 @@ static const struct i2c_device_id tpa6130a2_id[] = { | |||
| 466 | }; | 470 | }; |
| 467 | MODULE_DEVICE_TABLE(i2c, tpa6130a2_id); | 471 | MODULE_DEVICE_TABLE(i2c, tpa6130a2_id); |
| 468 | 472 | ||
| 473 | #if IS_ENABLED(CONFIG_OF) | ||
| 474 | static const struct of_device_id tpa6130a2_of_match[] = { | ||
| 475 | { .compatible = "ti,tpa6130a2", }, | ||
| 476 | { .compatible = "ti,tpa6140a2" }, | ||
| 477 | {}, | ||
| 478 | }; | ||
| 479 | MODULE_DEVICE_TABLE(of, tpa6130a2_of_match); | ||
| 480 | #endif | ||
| 481 | |||
| 469 | static struct i2c_driver tpa6130a2_i2c_driver = { | 482 | static struct i2c_driver tpa6130a2_i2c_driver = { |
| 470 | .driver = { | 483 | .driver = { |
| 471 | .name = "tpa6130a2", | 484 | .name = "tpa6130a2", |
| 472 | .owner = THIS_MODULE, | 485 | .owner = THIS_MODULE, |
| 486 | .of_match_table = of_match_ptr(tpa6130a2_of_match), | ||
| 473 | }, | 487 | }, |
| 474 | .probe = tpa6130a2_probe, | 488 | .probe = tpa6130a2_probe, |
| 475 | .remove = tpa6130a2_remove, | 489 | .remove = tpa6130a2_remove, |
diff --git a/sound/soc/codecs/twl4030.c b/sound/soc/codecs/twl4030.c index 1e3884d6b3fb..dfc51bb425da 100644 --- a/sound/soc/codecs/twl4030.c +++ b/sound/soc/codecs/twl4030.c | |||
| @@ -46,13 +46,7 @@ | |||
| 46 | /* TWL4030 PMBR1 Register GPIO6 mux bits */ | 46 | /* TWL4030 PMBR1 Register GPIO6 mux bits */ |
| 47 | #define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2) | 47 | #define TWL4030_GPIO6_PWM0_MUTE(value) ((value & 0x03) << 2) |
| 48 | 48 | ||
| 49 | /* Shadow register used by the audio driver */ | 49 | #define TWL4030_CACHEREGNUM (TWL4030_REG_MISC_SET_2 + 1) |
| 50 | #define TWL4030_REG_SW_SHADOW 0x4A | ||
| 51 | #define TWL4030_CACHEREGNUM (TWL4030_REG_SW_SHADOW + 1) | ||
| 52 | |||
| 53 | /* TWL4030_REG_SW_SHADOW (0x4A) Fields */ | ||
| 54 | #define TWL4030_HFL_EN 0x01 | ||
| 55 | #define TWL4030_HFR_EN 0x02 | ||
| 56 | 50 | ||
| 57 | /* | 51 | /* |
| 58 | * twl4030 register cache & default register settings | 52 | * twl4030 register cache & default register settings |
| @@ -132,7 +126,6 @@ static const u8 twl4030_reg[TWL4030_CACHEREGNUM] = { | |||
| 132 | 0x00, /* REG_VIBRA_PWM_SET (0x47) */ | 126 | 0x00, /* REG_VIBRA_PWM_SET (0x47) */ |
| 133 | 0x00, /* REG_ANAMIC_GAIN (0x48) */ | 127 | 0x00, /* REG_ANAMIC_GAIN (0x48) */ |
| 134 | 0x00, /* REG_MISC_SET_2 (0x49) */ | 128 | 0x00, /* REG_MISC_SET_2 (0x49) */ |
| 135 | 0x00, /* REG_SW_SHADOW (0x4A) - Shadow, non HW register */ | ||
| 136 | }; | 129 | }; |
| 137 | 130 | ||
| 138 | /* codec private data */ | 131 | /* codec private data */ |
| @@ -198,42 +191,41 @@ static int twl4030_write(struct snd_soc_codec *codec, | |||
| 198 | int write_to_reg = 0; | 191 | int write_to_reg = 0; |
| 199 | 192 | ||
| 200 | twl4030_write_reg_cache(codec, reg, value); | 193 | twl4030_write_reg_cache(codec, reg, value); |
| 201 | if (likely(reg < TWL4030_REG_SW_SHADOW)) { | 194 | /* Decide if the given register can be written */ |
| 202 | /* Decide if the given register can be written */ | 195 | switch (reg) { |
| 203 | switch (reg) { | 196 | case TWL4030_REG_EAR_CTL: |
| 204 | case TWL4030_REG_EAR_CTL: | 197 | if (twl4030->earpiece_enabled) |
| 205 | if (twl4030->earpiece_enabled) | ||
| 206 | write_to_reg = 1; | ||
| 207 | break; | ||
| 208 | case TWL4030_REG_PREDL_CTL: | ||
| 209 | if (twl4030->predrivel_enabled) | ||
| 210 | write_to_reg = 1; | ||
| 211 | break; | ||
| 212 | case TWL4030_REG_PREDR_CTL: | ||
| 213 | if (twl4030->predriver_enabled) | ||
| 214 | write_to_reg = 1; | ||
| 215 | break; | ||
| 216 | case TWL4030_REG_PRECKL_CTL: | ||
| 217 | if (twl4030->carkitl_enabled) | ||
| 218 | write_to_reg = 1; | ||
| 219 | break; | ||
| 220 | case TWL4030_REG_PRECKR_CTL: | ||
| 221 | if (twl4030->carkitr_enabled) | ||
| 222 | write_to_reg = 1; | ||
| 223 | break; | ||
| 224 | case TWL4030_REG_HS_GAIN_SET: | ||
| 225 | if (twl4030->hsl_enabled || twl4030->hsr_enabled) | ||
| 226 | write_to_reg = 1; | ||
| 227 | break; | ||
| 228 | default: | ||
| 229 | /* All other register can be written */ | ||
| 230 | write_to_reg = 1; | 198 | write_to_reg = 1; |
| 231 | break; | 199 | break; |
| 232 | } | 200 | case TWL4030_REG_PREDL_CTL: |
| 233 | if (write_to_reg) | 201 | if (twl4030->predrivel_enabled) |
| 234 | return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | 202 | write_to_reg = 1; |
| 235 | value, reg); | 203 | break; |
| 204 | case TWL4030_REG_PREDR_CTL: | ||
| 205 | if (twl4030->predriver_enabled) | ||
| 206 | write_to_reg = 1; | ||
| 207 | break; | ||
| 208 | case TWL4030_REG_PRECKL_CTL: | ||
| 209 | if (twl4030->carkitl_enabled) | ||
| 210 | write_to_reg = 1; | ||
| 211 | break; | ||
| 212 | case TWL4030_REG_PRECKR_CTL: | ||
| 213 | if (twl4030->carkitr_enabled) | ||
| 214 | write_to_reg = 1; | ||
| 215 | break; | ||
| 216 | case TWL4030_REG_HS_GAIN_SET: | ||
| 217 | if (twl4030->hsl_enabled || twl4030->hsr_enabled) | ||
| 218 | write_to_reg = 1; | ||
| 219 | break; | ||
| 220 | default: | ||
| 221 | /* All other register can be written */ | ||
| 222 | write_to_reg = 1; | ||
| 223 | break; | ||
| 236 | } | 224 | } |
| 225 | if (write_to_reg) | ||
| 226 | return twl_i2c_write_u8(TWL4030_MODULE_AUDIO_VOICE, | ||
| 227 | value, reg); | ||
| 228 | |||
| 237 | return 0; | 229 | return 0; |
| 238 | } | 230 | } |
| 239 | 231 | ||
| @@ -532,7 +524,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreel_enum); | |||
| 532 | 524 | ||
| 533 | /* Handsfree Left virtual mute */ | 525 | /* Handsfree Left virtual mute */ |
| 534 | static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control = | 526 | static const struct snd_kcontrol_new twl4030_dapm_handsfreelmute_control = |
| 535 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 0, 1, 0); | 527 | SOC_DAPM_SINGLE_VIRT("Switch", 1); |
| 536 | 528 | ||
| 537 | /* Handsfree Right */ | 529 | /* Handsfree Right */ |
| 538 | static const char *twl4030_handsfreer_texts[] = | 530 | static const char *twl4030_handsfreer_texts[] = |
| @@ -548,7 +540,7 @@ SOC_DAPM_ENUM("Route", twl4030_handsfreer_enum); | |||
| 548 | 540 | ||
| 549 | /* Handsfree Right virtual mute */ | 541 | /* Handsfree Right virtual mute */ |
| 550 | static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control = | 542 | static const struct snd_kcontrol_new twl4030_dapm_handsfreermute_control = |
| 551 | SOC_DAPM_SINGLE("Switch", TWL4030_REG_SW_SHADOW, 1, 1, 0); | 543 | SOC_DAPM_SINGLE_VIRT("Switch", 1); |
| 552 | 544 | ||
| 553 | /* Vibra */ | 545 | /* Vibra */ |
| 554 | /* Vibra audio path selection */ | 546 | /* Vibra audio path selection */ |
diff --git a/sound/soc/codecs/twl6040.c b/sound/soc/codecs/twl6040.c index 3c79dbb6c323..f2f4bcb2ff71 100644 --- a/sound/soc/codecs/twl6040.c +++ b/sound/soc/codecs/twl6040.c | |||
| @@ -54,12 +54,7 @@ enum twl6040_dai_id { | |||
| 54 | #define TWL6040_OUTHF_0dB 0x03 | 54 | #define TWL6040_OUTHF_0dB 0x03 |
| 55 | #define TWL6040_OUTHF_M52dB 0x1D | 55 | #define TWL6040_OUTHF_M52dB 0x1D |
| 56 | 56 | ||
| 57 | /* Shadow register used by the driver */ | 57 | #define TWL6040_CACHEREGNUM (TWL6040_REG_STATUS + 1) |
| 58 | #define TWL6040_REG_SW_SHADOW 0x2F | ||
| 59 | #define TWL6040_CACHEREGNUM (TWL6040_REG_SW_SHADOW + 1) | ||
| 60 | |||
| 61 | /* TWL6040_REG_SW_SHADOW (0x2F) fields */ | ||
| 62 | #define TWL6040_EAR_PATH_ENABLE 0x01 | ||
| 63 | 58 | ||
| 64 | struct twl6040_jack_data { | 59 | struct twl6040_jack_data { |
| 65 | struct snd_soc_jack *jack; | 60 | struct snd_soc_jack *jack; |
| @@ -135,8 +130,6 @@ static const u8 twl6040_reg[TWL6040_CACHEREGNUM] = { | |||
| 135 | 0x00, /* REG_HFOTRIM 0x2C */ | 130 | 0x00, /* REG_HFOTRIM 0x2C */ |
| 136 | 0x09, /* REG_ACCCTL 0x2D */ | 131 | 0x09, /* REG_ACCCTL 0x2D */ |
| 137 | 0x00, /* REG_STATUS 0x2E (ro) */ | 132 | 0x00, /* REG_STATUS 0x2E (ro) */ |
| 138 | |||
| 139 | 0x00, /* REG_SW_SHADOW 0x2F - Shadow, non HW register */ | ||
| 140 | }; | 133 | }; |
| 141 | 134 | ||
| 142 | /* List of registers to be restored after power up */ | 135 | /* List of registers to be restored after power up */ |
| @@ -220,12 +213,8 @@ static int twl6040_read_reg_volatile(struct snd_soc_codec *codec, | |||
| 220 | if (reg >= TWL6040_CACHEREGNUM) | 213 | if (reg >= TWL6040_CACHEREGNUM) |
| 221 | return -EIO; | 214 | return -EIO; |
| 222 | 215 | ||
| 223 | if (likely(reg < TWL6040_REG_SW_SHADOW)) { | 216 | value = twl6040_reg_read(twl6040, reg); |
| 224 | value = twl6040_reg_read(twl6040, reg); | 217 | twl6040_write_reg_cache(codec, reg, value); |
| 225 | twl6040_write_reg_cache(codec, reg, value); | ||
| 226 | } else { | ||
| 227 | value = twl6040_read_reg_cache(codec, reg); | ||
| 228 | } | ||
| 229 | 218 | ||
| 230 | return value; | 219 | return value; |
| 231 | } | 220 | } |
| @@ -246,7 +235,7 @@ static bool twl6040_is_path_unmuted(struct snd_soc_codec *codec, | |||
| 246 | return priv->dl2_unmuted; | 235 | return priv->dl2_unmuted; |
| 247 | default: | 236 | default: |
| 248 | return 1; | 237 | return 1; |
| 249 | }; | 238 | } |
| 250 | } | 239 | } |
| 251 | 240 | ||
| 252 | /* | 241 | /* |
| @@ -261,8 +250,7 @@ static int twl6040_write(struct snd_soc_codec *codec, | |||
| 261 | return -EIO; | 250 | return -EIO; |
| 262 | 251 | ||
| 263 | twl6040_write_reg_cache(codec, reg, value); | 252 | twl6040_write_reg_cache(codec, reg, value); |
| 264 | if (likely(reg < TWL6040_REG_SW_SHADOW) && | 253 | if (twl6040_is_path_unmuted(codec, reg)) |
| 265 | twl6040_is_path_unmuted(codec, reg)) | ||
| 266 | return twl6040_reg_write(twl6040, reg, value); | 254 | return twl6040_reg_write(twl6040, reg, value); |
| 267 | else | 255 | else |
| 268 | return 0; | 256 | return 0; |
| @@ -555,7 +543,7 @@ static const struct snd_kcontrol_new hfr_mux_controls = | |||
| 555 | SOC_DAPM_ENUM("Route", twl6040_hf_enum[1]); | 543 | SOC_DAPM_ENUM("Route", twl6040_hf_enum[1]); |
| 556 | 544 | ||
| 557 | static const struct snd_kcontrol_new ep_path_enable_control = | 545 | static const struct snd_kcontrol_new ep_path_enable_control = |
| 558 | SOC_DAPM_SINGLE("Switch", TWL6040_REG_SW_SHADOW, 0, 1, 0); | 546 | SOC_DAPM_SINGLE_VIRT("Switch", 1); |
| 559 | 547 | ||
| 560 | static const struct snd_kcontrol_new auxl_switch_control = | 548 | static const struct snd_kcontrol_new auxl_switch_control = |
| 561 | SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFLCTL, 6, 1, 0); | 549 | SOC_DAPM_SINGLE("Switch", TWL6040_REG_HFLCTL, 6, 1, 0); |
| @@ -1100,7 +1088,7 @@ static void twl6040_mute_path(struct snd_soc_codec *codec, enum twl6040_dai_id i | |||
| 1100 | break; | 1088 | break; |
| 1101 | default: | 1089 | default: |
| 1102 | break; | 1090 | break; |
| 1103 | }; | 1091 | } |
| 1104 | } | 1092 | } |
| 1105 | 1093 | ||
| 1106 | static int twl6040_digital_mute(struct snd_soc_dai *dai, int mute) | 1094 | static int twl6040_digital_mute(struct snd_soc_dai *dai, int mute) |
diff --git a/sound/soc/codecs/wm8400.c b/sound/soc/codecs/wm8400.c index d2a092850283..48dc7d2fee36 100644 --- a/sound/soc/codecs/wm8400.c +++ b/sound/soc/codecs/wm8400.c | |||
| @@ -32,13 +32,6 @@ | |||
| 32 | 32 | ||
| 33 | #include "wm8400.h" | 33 | #include "wm8400.h" |
| 34 | 34 | ||
| 35 | /* Fake register for internal state */ | ||
| 36 | #define WM8400_INTDRIVBITS (WM8400_REGISTER_COUNT + 1) | ||
| 37 | #define WM8400_INMIXL_PWR 0 | ||
| 38 | #define WM8400_AINLMUX_PWR 1 | ||
| 39 | #define WM8400_INMIXR_PWR 2 | ||
| 40 | #define WM8400_AINRMUX_PWR 3 | ||
| 41 | |||
| 42 | static struct regulator_bulk_data power[] = { | 35 | static struct regulator_bulk_data power[] = { |
| 43 | { | 36 | { |
| 44 | .supply = "I2S1VDD", | 37 | .supply = "I2S1VDD", |
| @@ -74,32 +67,6 @@ struct wm8400_priv { | |||
| 74 | int fll_in, fll_out; | 67 | int fll_in, fll_out; |
| 75 | }; | 68 | }; |
| 76 | 69 | ||
| 77 | static inline unsigned int wm8400_read(struct snd_soc_codec *codec, | ||
| 78 | unsigned int reg) | ||
| 79 | { | ||
| 80 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | ||
| 81 | |||
| 82 | if (reg == WM8400_INTDRIVBITS) | ||
| 83 | return wm8400->fake_register; | ||
| 84 | else | ||
| 85 | return wm8400_reg_read(wm8400->wm8400, reg); | ||
| 86 | } | ||
| 87 | |||
| 88 | /* | ||
| 89 | * write to the wm8400 register space | ||
| 90 | */ | ||
| 91 | static int wm8400_write(struct snd_soc_codec *codec, unsigned int reg, | ||
| 92 | unsigned int value) | ||
| 93 | { | ||
| 94 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | ||
| 95 | |||
| 96 | if (reg == WM8400_INTDRIVBITS) { | ||
| 97 | wm8400->fake_register = value; | ||
| 98 | return 0; | ||
| 99 | } else | ||
| 100 | return wm8400_set_bits(wm8400->wm8400, reg, 0xffff, value); | ||
| 101 | } | ||
| 102 | |||
| 103 | static void wm8400_codec_reset(struct snd_soc_codec *codec) | 70 | static void wm8400_codec_reset(struct snd_soc_codec *codec) |
| 104 | { | 71 | { |
| 105 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); | 72 | struct wm8400_priv *wm8400 = snd_soc_codec_get_drvdata(codec); |
| @@ -352,32 +319,6 @@ SOC_SINGLE("RIN34 Mute Switch", WM8400_RIGHT_LINE_INPUT_3_4_VOLUME, | |||
| 352 | * _DAPM_ Controls | 319 | * _DAPM_ Controls |
| 353 | */ | 320 | */ |
| 354 | 321 | ||
| 355 | static int inmixer_event (struct snd_soc_dapm_widget *w, | ||
| 356 | struct snd_kcontrol *kcontrol, int event) | ||
| 357 | { | ||
| 358 | u16 reg, fakepower; | ||
| 359 | |||
| 360 | reg = snd_soc_read(w->codec, WM8400_POWER_MANAGEMENT_2); | ||
| 361 | fakepower = snd_soc_read(w->codec, WM8400_INTDRIVBITS); | ||
| 362 | |||
| 363 | if (fakepower & ((1 << WM8400_INMIXL_PWR) | | ||
| 364 | (1 << WM8400_AINLMUX_PWR))) { | ||
| 365 | reg |= WM8400_AINL_ENA; | ||
| 366 | } else { | ||
| 367 | reg &= ~WM8400_AINL_ENA; | ||
| 368 | } | ||
| 369 | |||
| 370 | if (fakepower & ((1 << WM8400_INMIXR_PWR) | | ||
| 371 | (1 << WM8400_AINRMUX_PWR))) { | ||
| 372 | reg |= WM8400_AINR_ENA; | ||
| 373 | } else { | ||
| 374 | reg &= ~WM8400_AINR_ENA; | ||
| 375 | } | ||
| 376 | snd_soc_write(w->codec, WM8400_POWER_MANAGEMENT_2, reg); | ||
| 377 | |||
| 378 | return 0; | ||
| 379 | } | ||
| 380 | |||
| 381 | static int outmixer_event (struct snd_soc_dapm_widget *w, | 322 | static int outmixer_event (struct snd_soc_dapm_widget *w, |
| 382 | struct snd_kcontrol * kcontrol, int event) | 323 | struct snd_kcontrol * kcontrol, int event) |
| 383 | { | 324 | { |
| @@ -658,27 +599,26 @@ SND_SOC_DAPM_MIXER("RIN34 PGA", WM8400_POWER_MANAGEMENT_2, | |||
| 658 | 0, &wm8400_dapm_rin34_pga_controls[0], | 599 | 0, &wm8400_dapm_rin34_pga_controls[0], |
| 659 | ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), | 600 | ARRAY_SIZE(wm8400_dapm_rin34_pga_controls)), |
| 660 | 601 | ||
| 602 | SND_SOC_DAPM_SUPPLY("INL", WM8400_POWER_MANAGEMENT_2, WM8400_AINL_ENA_SHIFT, | ||
| 603 | 0, NULL, 0), | ||
| 604 | SND_SOC_DAPM_SUPPLY("INR", WM8400_POWER_MANAGEMENT_2, WM8400_AINR_ENA_SHIFT, | ||
| 605 | 0, NULL, 0), | ||
| 606 | |||
| 661 | /* INMIXL */ | 607 | /* INMIXL */ |
| 662 | SND_SOC_DAPM_MIXER_E("INMIXL", WM8400_INTDRIVBITS, WM8400_INMIXL_PWR, 0, | 608 | SND_SOC_DAPM_MIXER("INMIXL", SND_SOC_NOPM, 0, 0, |
| 663 | &wm8400_dapm_inmixl_controls[0], | 609 | &wm8400_dapm_inmixl_controls[0], |
| 664 | ARRAY_SIZE(wm8400_dapm_inmixl_controls), | 610 | ARRAY_SIZE(wm8400_dapm_inmixl_controls)), |
| 665 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 666 | 611 | ||
| 667 | /* AINLMUX */ | 612 | /* AINLMUX */ |
| 668 | SND_SOC_DAPM_MUX_E("AILNMUX", WM8400_INTDRIVBITS, WM8400_AINLMUX_PWR, 0, | 613 | SND_SOC_DAPM_MUX("AILNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainlmux_controls), |
| 669 | &wm8400_dapm_ainlmux_controls, inmixer_event, | ||
| 670 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 671 | 614 | ||
| 672 | /* INMIXR */ | 615 | /* INMIXR */ |
| 673 | SND_SOC_DAPM_MIXER_E("INMIXR", WM8400_INTDRIVBITS, WM8400_INMIXR_PWR, 0, | 616 | SND_SOC_DAPM_MIXER("INMIXR", SND_SOC_NOPM, 0, 0, |
| 674 | &wm8400_dapm_inmixr_controls[0], | 617 | &wm8400_dapm_inmixr_controls[0], |
| 675 | ARRAY_SIZE(wm8400_dapm_inmixr_controls), | 618 | ARRAY_SIZE(wm8400_dapm_inmixr_controls)), |
| 676 | inmixer_event, SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 677 | 619 | ||
| 678 | /* AINRMUX */ | 620 | /* AINRMUX */ |
| 679 | SND_SOC_DAPM_MUX_E("AIRNMUX", WM8400_INTDRIVBITS, WM8400_AINRMUX_PWR, 0, | 621 | SND_SOC_DAPM_MUX("AIRNMUX", SND_SOC_NOPM, 0, 0, &wm8400_dapm_ainrmux_controls), |
| 680 | &wm8400_dapm_ainrmux_controls, inmixer_event, | ||
| 681 | SND_SOC_DAPM_POST_PMU | SND_SOC_DAPM_POST_PMD), | ||
| 682 | 622 | ||
| 683 | /* Output Side */ | 623 | /* Output Side */ |
| 684 | /* DACs */ | 624 | /* DACs */ |
| @@ -789,11 +729,13 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { | |||
| 789 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, | 729 | {"LIN34 PGA", "LIN3 Switch", "LIN3"}, |
| 790 | {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, | 730 | {"LIN34 PGA", "LIN4 Switch", "LIN4/RXN"}, |
| 791 | /* INMIXL */ | 731 | /* INMIXL */ |
| 732 | {"INMIXL", NULL, "INL"}, | ||
| 792 | {"INMIXL", "Record Left Volume", "LOMIX"}, | 733 | {"INMIXL", "Record Left Volume", "LOMIX"}, |
| 793 | {"INMIXL", "LIN2 Volume", "LIN2"}, | 734 | {"INMIXL", "LIN2 Volume", "LIN2"}, |
| 794 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, | 735 | {"INMIXL", "LINPGA12 Switch", "LIN12 PGA"}, |
| 795 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, | 736 | {"INMIXL", "LINPGA34 Switch", "LIN34 PGA"}, |
| 796 | /* AILNMUX */ | 737 | /* AILNMUX */ |
| 738 | {"AILNMUX", NULL, "INL"}, | ||
| 797 | {"AILNMUX", "INMIXL Mix", "INMIXL"}, | 739 | {"AILNMUX", "INMIXL Mix", "INMIXL"}, |
| 798 | {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, | 740 | {"AILNMUX", "DIFFINL Mix", "LIN12 PGA"}, |
| 799 | {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, | 741 | {"AILNMUX", "DIFFINL Mix", "LIN34 PGA"}, |
| @@ -808,12 +750,14 @@ static const struct snd_soc_dapm_route wm8400_dapm_routes[] = { | |||
| 808 | /* RIN34 PGA */ | 750 | /* RIN34 PGA */ |
| 809 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, | 751 | {"RIN34 PGA", "RIN3 Switch", "RIN3"}, |
| 810 | {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, | 752 | {"RIN34 PGA", "RIN4 Switch", "RIN4/RXP"}, |
| 811 | /* INMIXL */ | 753 | /* INMIXR */ |
| 754 | {"INMIXR", NULL, "INR"}, | ||
| 812 | {"INMIXR", "Record Right Volume", "ROMIX"}, | 755 | {"INMIXR", "Record Right Volume", "ROMIX"}, |
| 813 | {"INMIXR", "RIN2 Volume", "RIN2"}, | 756 | {"INMIXR", "RIN2 Volume", "RIN2"}, |
| 814 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, | 757 | {"INMIXR", "RINPGA12 Switch", "RIN12 PGA"}, |
| 815 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, | 758 | {"INMIXR", "RINPGA34 Switch", "RIN34 PGA"}, |
| 816 | /* AIRNMUX */ | 759 | /* AIRNMUX */ |
| 760 | {"AIRNMUX", NULL, "INR"}, | ||
| 817 | {"AIRNMUX", "INMIXR Mix", "INMIXR"}, | 761 | {"AIRNMUX", "INMIXR Mix", "INMIXR"}, |
| 818 | {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, | 762 | {"AIRNMUX", "DIFFINR Mix", "RIN12 PGA"}, |
| 819 | {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, | 763 | {"AIRNMUX", "DIFFINR Mix", "RIN34 PGA"}, |
| @@ -1365,9 +1309,12 @@ static int wm8400_codec_probe(struct snd_soc_codec *codec) | |||
| 1365 | return -ENOMEM; | 1309 | return -ENOMEM; |
| 1366 | 1310 | ||
| 1367 | snd_soc_codec_set_drvdata(codec, priv); | 1311 | snd_soc_codec_set_drvdata(codec, priv); |
| 1368 | codec->control_data = priv->wm8400 = wm8400; | 1312 | priv->wm8400 = wm8400; |
| 1313 | codec->control_data = wm8400->regmap; | ||
| 1369 | priv->codec = codec; | 1314 | priv->codec = codec; |
| 1370 | 1315 | ||
| 1316 | snd_soc_codec_set_cache_io(codec, 8, 16, SND_SOC_REGMAP); | ||
| 1317 | |||
| 1371 | ret = devm_regulator_bulk_get(wm8400->dev, | 1318 | ret = devm_regulator_bulk_get(wm8400->dev, |
| 1372 | ARRAY_SIZE(power), &power[0]); | 1319 | ARRAY_SIZE(power), &power[0]); |
| 1373 | if (ret != 0) { | 1320 | if (ret != 0) { |
| @@ -1414,8 +1361,6 @@ static struct snd_soc_codec_driver soc_codec_dev_wm8400 = { | |||
| 1414 | .remove = wm8400_codec_remove, | 1361 | .remove = wm8400_codec_remove, |
| 1415 | .suspend = wm8400_suspend, | 1362 | .suspend = wm8400_suspend, |
| 1416 | .resume = wm8400_resume, | 1363 | .resume = wm8400_resume, |
| 1417 | .read = snd_soc_read, | ||
| 1418 | .write = wm8400_write, | ||
| 1419 | .set_bias_level = wm8400_set_bias_level, | 1364 | .set_bias_level = wm8400_set_bias_level, |
| 1420 | 1365 | ||
| 1421 | .controls = wm8400_snd_controls, | 1366 | .controls = wm8400_snd_controls, |
diff --git a/sound/soc/davinci/Kconfig b/sound/soc/davinci/Kconfig index c82f89c9475b..95970f5db3ec 100644 --- a/sound/soc/davinci/Kconfig +++ b/sound/soc/davinci/Kconfig | |||
| @@ -1,9 +1,10 @@ | |||
| 1 | config SND_DAVINCI_SOC | 1 | config SND_DAVINCI_SOC |
| 2 | tristate "SoC Audio for the TI DAVINCI chip" | 2 | tristate "SoC Audio for the TI DAVINCI or AM33XX chip" |
| 3 | depends on ARCH_DAVINCI | 3 | depends on ARCH_DAVINCI || SOC_AM33XX |
| 4 | help | 4 | help |
| 5 | Platform driver for daVinci or AM33xx | ||
| 5 | Say Y or M if you want to add support for codecs attached to | 6 | Say Y or M if you want to add support for codecs attached to |
| 6 | the DAVINCI AC97 or I2S interface. You will also need | 7 | the DAVINCI AC97, I2S, or McASP interface. You will also need |
| 7 | to select the audio interfaces to support below. | 8 | to select the audio interfaces to support below. |
| 8 | 9 | ||
| 9 | config SND_DAVINCI_SOC_I2S | 10 | config SND_DAVINCI_SOC_I2S |
| @@ -15,6 +16,17 @@ config SND_DAVINCI_SOC_MCASP | |||
| 15 | config SND_DAVINCI_SOC_VCIF | 16 | config SND_DAVINCI_SOC_VCIF |
| 16 | tristate | 17 | tristate |
| 17 | 18 | ||
| 19 | config SND_AM33XX_SOC_EVM | ||
| 20 | tristate "SoC Audio for the AM33XX chip based boards" | ||
| 21 | depends on SND_DAVINCI_SOC && SOC_AM33XX | ||
| 22 | select SND_SOC_TLV320AIC3X | ||
| 23 | select SND_DAVINCI_SOC_MCASP | ||
| 24 | help | ||
| 25 | Say Y or M if you want to add support for SoC audio on AM33XX | ||
| 26 | boards using McASP and TLV320AIC3X codec. For example AM335X-EVM, | ||
| 27 | AM335X-EVMSK, and BeagelBone with AudioCape boards have this | ||
| 28 | setup. | ||
| 29 | |||
| 18 | config SND_DAVINCI_SOC_EVM | 30 | config SND_DAVINCI_SOC_EVM |
| 19 | tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" | 31 | tristate "SoC Audio support for DaVinci DM6446, DM355 or DM365 EVM" |
| 20 | depends on SND_DAVINCI_SOC | 32 | depends on SND_DAVINCI_SOC |
diff --git a/sound/soc/davinci/Makefile b/sound/soc/davinci/Makefile index a396ab6d6d5e..bc81e79fc301 100644 --- a/sound/soc/davinci/Makefile +++ b/sound/soc/davinci/Makefile | |||
| @@ -13,6 +13,7 @@ obj-$(CONFIG_SND_DAVINCI_SOC_VCIF) += snd-soc-davinci-vcif.o | |||
| 13 | snd-soc-evm-objs := davinci-evm.o | 13 | snd-soc-evm-objs := davinci-evm.o |
| 14 | 14 | ||
| 15 | obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o | 15 | obj-$(CONFIG_SND_DAVINCI_SOC_EVM) += snd-soc-evm.o |
| 16 | obj-$(CONFIG_SND_AM33XX_SOC_EVM) += snd-soc-evm.o | ||
| 16 | obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o | 17 | obj-$(CONFIG_SND_DM6467_SOC_EVM) += snd-soc-evm.o |
| 17 | obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o | 18 | obj-$(CONFIG_SND_DA830_SOC_EVM) += snd-soc-evm.o |
| 18 | obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o | 19 | obj-$(CONFIG_SND_DA850_SOC_EVM) += snd-soc-evm.o |
diff --git a/sound/soc/davinci/davinci-evm.c b/sound/soc/davinci/davinci-evm.c index fd7c45b9ed5a..623eb5e7c089 100644 --- a/sound/soc/davinci/davinci-evm.c +++ b/sound/soc/davinci/davinci-evm.c | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <linux/platform_device.h> | 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/platform_data/edma.h> | 17 | #include <linux/platform_data/edma.h> |
| 18 | #include <linux/i2c.h> | 18 | #include <linux/i2c.h> |
| 19 | #include <linux/of_platform.h> | ||
| 19 | #include <sound/core.h> | 20 | #include <sound/core.h> |
| 20 | #include <sound/pcm.h> | 21 | #include <sound/pcm.h> |
| 21 | #include <sound/soc.h> | 22 | #include <sound/soc.h> |
| @@ -23,10 +24,16 @@ | |||
| 23 | #include <asm/dma.h> | 24 | #include <asm/dma.h> |
| 24 | #include <asm/mach-types.h> | 25 | #include <asm/mach-types.h> |
| 25 | 26 | ||
| 27 | #include <linux/edma.h> | ||
| 28 | |||
| 26 | #include "davinci-pcm.h" | 29 | #include "davinci-pcm.h" |
| 27 | #include "davinci-i2s.h" | 30 | #include "davinci-i2s.h" |
| 28 | #include "davinci-mcasp.h" | 31 | #include "davinci-mcasp.h" |
| 29 | 32 | ||
| 33 | struct snd_soc_card_drvdata_davinci { | ||
| 34 | unsigned sysclk; | ||
| 35 | }; | ||
| 36 | |||
| 30 | #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ | 37 | #define AUDIO_FORMAT (SND_SOC_DAIFMT_DSP_B | \ |
| 31 | SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) | 38 | SND_SOC_DAIFMT_CBM_CFM | SND_SOC_DAIFMT_IB_NF) |
| 32 | static int evm_hw_params(struct snd_pcm_substream *substream, | 39 | static int evm_hw_params(struct snd_pcm_substream *substream, |
| @@ -35,27 +42,11 @@ static int evm_hw_params(struct snd_pcm_substream *substream, | |||
| 35 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 42 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 36 | struct snd_soc_dai *codec_dai = rtd->codec_dai; | 43 | struct snd_soc_dai *codec_dai = rtd->codec_dai; |
| 37 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; | 44 | struct snd_soc_dai *cpu_dai = rtd->cpu_dai; |
| 45 | struct snd_soc_codec *codec = rtd->codec; | ||
| 46 | struct snd_soc_card *soc_card = codec->card; | ||
| 38 | int ret = 0; | 47 | int ret = 0; |
| 39 | unsigned sysclk; | 48 | unsigned sysclk = ((struct snd_soc_card_drvdata_davinci *) |
| 40 | 49 | snd_soc_card_get_drvdata(soc_card))->sysclk; | |
| 41 | /* ASP1 on DM355 EVM is clocked by an external oscillator */ | ||
| 42 | if (machine_is_davinci_dm355_evm() || machine_is_davinci_dm6467_evm() || | ||
| 43 | machine_is_davinci_dm365_evm()) | ||
| 44 | sysclk = 27000000; | ||
| 45 | |||
| 46 | /* ASP0 in DM6446 EVM is clocked by U55, as configured by | ||
| 47 | * board-dm644x-evm.c using GPIOs from U18. There are six | ||
| 48 | * options; here we "know" we use a 48 KHz sample rate. | ||
| 49 | */ | ||
| 50 | else if (machine_is_davinci_evm()) | ||
| 51 | sysclk = 12288000; | ||
| 52 | |||
| 53 | else if (machine_is_davinci_da830_evm() || | ||
| 54 | machine_is_davinci_da850_evm()) | ||
| 55 | sysclk = 24576000; | ||
| 56 | |||
| 57 | else | ||
| 58 | return -EINVAL; | ||
| 59 | 50 | ||
| 60 | /* set codec DAI configuration */ | 51 | /* set codec DAI configuration */ |
| 61 | ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); | 52 | ret = snd_soc_dai_set_fmt(codec_dai, AUDIO_FORMAT); |
| @@ -133,13 +124,22 @@ static int evm_aic3x_init(struct snd_soc_pcm_runtime *rtd) | |||
| 133 | { | 124 | { |
| 134 | struct snd_soc_codec *codec = rtd->codec; | 125 | struct snd_soc_codec *codec = rtd->codec; |
| 135 | struct snd_soc_dapm_context *dapm = &codec->dapm; | 126 | struct snd_soc_dapm_context *dapm = &codec->dapm; |
| 127 | struct device_node *np = codec->card->dev->of_node; | ||
| 128 | int ret; | ||
| 136 | 129 | ||
| 137 | /* Add davinci-evm specific widgets */ | 130 | /* Add davinci-evm specific widgets */ |
| 138 | snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets, | 131 | snd_soc_dapm_new_controls(dapm, aic3x_dapm_widgets, |
| 139 | ARRAY_SIZE(aic3x_dapm_widgets)); | 132 | ARRAY_SIZE(aic3x_dapm_widgets)); |
| 140 | 133 | ||
| 141 | /* Set up davinci-evm specific audio path audio_map */ | 134 | if (np) { |
| 142 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | 135 | ret = snd_soc_of_parse_audio_routing(codec->card, |
| 136 | "ti,audio-routing"); | ||
| 137 | if (ret) | ||
| 138 | return ret; | ||
| 139 | } else { | ||
| 140 | /* Set up davinci-evm specific audio path audio_map */ | ||
| 141 | snd_soc_dapm_add_routes(dapm, audio_map, ARRAY_SIZE(audio_map)); | ||
| 142 | } | ||
| 143 | 143 | ||
| 144 | /* not connected */ | 144 | /* not connected */ |
| 145 | snd_soc_dapm_disable_pin(dapm, "MONO_LOUT"); | 145 | snd_soc_dapm_disable_pin(dapm, "MONO_LOUT"); |
| @@ -243,35 +243,65 @@ static struct snd_soc_dai_link da850_evm_dai = { | |||
| 243 | }; | 243 | }; |
| 244 | 244 | ||
| 245 | /* davinci dm6446 evm audio machine driver */ | 245 | /* davinci dm6446 evm audio machine driver */ |
| 246 | /* | ||
| 247 | * ASP0 in DM6446 EVM is clocked by U55, as configured by | ||
| 248 | * board-dm644x-evm.c using GPIOs from U18. There are six | ||
| 249 | * options; here we "know" we use a 48 KHz sample rate. | ||
| 250 | */ | ||
| 251 | static struct snd_soc_card_drvdata_davinci dm6446_snd_soc_card_drvdata = { | ||
| 252 | .sysclk = 12288000, | ||
| 253 | }; | ||
| 254 | |||
| 246 | static struct snd_soc_card dm6446_snd_soc_card_evm = { | 255 | static struct snd_soc_card dm6446_snd_soc_card_evm = { |
| 247 | .name = "DaVinci DM6446 EVM", | 256 | .name = "DaVinci DM6446 EVM", |
| 248 | .owner = THIS_MODULE, | 257 | .owner = THIS_MODULE, |
| 249 | .dai_link = &dm6446_evm_dai, | 258 | .dai_link = &dm6446_evm_dai, |
| 250 | .num_links = 1, | 259 | .num_links = 1, |
| 260 | .drvdata = &dm6446_snd_soc_card_drvdata, | ||
| 251 | }; | 261 | }; |
| 252 | 262 | ||
| 253 | /* davinci dm355 evm audio machine driver */ | 263 | /* davinci dm355 evm audio machine driver */ |
| 264 | /* ASP1 on DM355 EVM is clocked by an external oscillator */ | ||
| 265 | static struct snd_soc_card_drvdata_davinci dm355_snd_soc_card_drvdata = { | ||
| 266 | .sysclk = 27000000, | ||
| 267 | }; | ||
| 268 | |||
| 254 | static struct snd_soc_card dm355_snd_soc_card_evm = { | 269 | static struct snd_soc_card dm355_snd_soc_card_evm = { |
| 255 | .name = "DaVinci DM355 EVM", | 270 | .name = "DaVinci DM355 EVM", |
| 256 | .owner = THIS_MODULE, | 271 | .owner = THIS_MODULE, |
| 257 | .dai_link = &dm355_evm_dai, | 272 | .dai_link = &dm355_evm_dai, |
| 258 | .num_links = 1, | 273 | .num_links = 1, |
| 274 | .drvdata = &dm355_snd_soc_card_drvdata, | ||
| 259 | }; | 275 | }; |
| 260 | 276 | ||
| 261 | /* davinci dm365 evm audio machine driver */ | 277 | /* davinci dm365 evm audio machine driver */ |
| 278 | static struct snd_soc_card_drvdata_davinci dm365_snd_soc_card_drvdata = { | ||
| 279 | .sysclk = 27000000, | ||
| 280 | }; | ||
| 281 | |||
| 262 | static struct snd_soc_card dm365_snd_soc_card_evm = { | 282 | static struct snd_soc_card dm365_snd_soc_card_evm = { |
| 263 | .name = "DaVinci DM365 EVM", | 283 | .name = "DaVinci DM365 EVM", |
| 264 | .owner = THIS_MODULE, | 284 | .owner = THIS_MODULE, |
| 265 | .dai_link = &dm365_evm_dai, | 285 | .dai_link = &dm365_evm_dai, |
| 266 | .num_links = 1, | 286 | .num_links = 1, |
| 287 | .drvdata = &dm365_snd_soc_card_drvdata, | ||
| 267 | }; | 288 | }; |
| 268 | 289 | ||
| 269 | /* davinci dm6467 evm audio machine driver */ | 290 | /* davinci dm6467 evm audio machine driver */ |
| 291 | static struct snd_soc_card_drvdata_davinci dm6467_snd_soc_card_drvdata = { | ||
| 292 | .sysclk = 27000000, | ||
| 293 | }; | ||
| 294 | |||
| 270 | static struct snd_soc_card dm6467_snd_soc_card_evm = { | 295 | static struct snd_soc_card dm6467_snd_soc_card_evm = { |
| 271 | .name = "DaVinci DM6467 EVM", | 296 | .name = "DaVinci DM6467 EVM", |
| 272 | .owner = THIS_MODULE, | 297 | .owner = THIS_MODULE, |
| 273 | .dai_link = dm6467_evm_dai, | 298 | .dai_link = dm6467_evm_dai, |
| 274 | .num_links = ARRAY_SIZE(dm6467_evm_dai), | 299 | .num_links = ARRAY_SIZE(dm6467_evm_dai), |
| 300 | .drvdata = &dm6467_snd_soc_card_drvdata, | ||
| 301 | }; | ||
| 302 | |||
| 303 | static struct snd_soc_card_drvdata_davinci da830_snd_soc_card_drvdata = { | ||
| 304 | .sysclk = 24576000, | ||
| 275 | }; | 305 | }; |
| 276 | 306 | ||
| 277 | static struct snd_soc_card da830_snd_soc_card = { | 307 | static struct snd_soc_card da830_snd_soc_card = { |
| @@ -279,6 +309,11 @@ static struct snd_soc_card da830_snd_soc_card = { | |||
| 279 | .owner = THIS_MODULE, | 309 | .owner = THIS_MODULE, |
| 280 | .dai_link = &da830_evm_dai, | 310 | .dai_link = &da830_evm_dai, |
| 281 | .num_links = 1, | 311 | .num_links = 1, |
| 312 | .drvdata = &da830_snd_soc_card_drvdata, | ||
| 313 | }; | ||
| 314 | |||
| 315 | static struct snd_soc_card_drvdata_davinci da850_snd_soc_card_drvdata = { | ||
| 316 | .sysclk = 24576000, | ||
| 282 | }; | 317 | }; |
| 283 | 318 | ||
| 284 | static struct snd_soc_card da850_snd_soc_card = { | 319 | static struct snd_soc_card da850_snd_soc_card = { |
| @@ -286,8 +321,101 @@ static struct snd_soc_card da850_snd_soc_card = { | |||
| 286 | .owner = THIS_MODULE, | 321 | .owner = THIS_MODULE, |
| 287 | .dai_link = &da850_evm_dai, | 322 | .dai_link = &da850_evm_dai, |
| 288 | .num_links = 1, | 323 | .num_links = 1, |
| 324 | .drvdata = &da850_snd_soc_card_drvdata, | ||
| 325 | }; | ||
| 326 | |||
| 327 | #if defined(CONFIG_OF) | ||
| 328 | |||
| 329 | /* | ||
| 330 | * The struct is used as place holder. It will be completely | ||
| 331 | * filled with data from dt node. | ||
| 332 | */ | ||
| 333 | static struct snd_soc_dai_link evm_dai_tlv320aic3x = { | ||
| 334 | .name = "TLV320AIC3X", | ||
| 335 | .stream_name = "AIC3X", | ||
| 336 | .codec_dai_name = "tlv320aic3x-hifi", | ||
| 337 | .ops = &evm_ops, | ||
| 338 | .init = evm_aic3x_init, | ||
| 339 | }; | ||
| 340 | |||
| 341 | static const struct of_device_id davinci_evm_dt_ids[] = { | ||
| 342 | { | ||
| 343 | .compatible = "ti,da830-evm-audio", | ||
| 344 | .data = (void *) &evm_dai_tlv320aic3x, | ||
| 345 | }, | ||
| 346 | { /* sentinel */ } | ||
| 347 | }; | ||
| 348 | MODULE_DEVICE_TABLE(of, davinci_evm_dt_ids); | ||
| 349 | |||
| 350 | /* davinci evm audio machine driver */ | ||
| 351 | static struct snd_soc_card evm_soc_card = { | ||
| 352 | .owner = THIS_MODULE, | ||
| 353 | .num_links = 1, | ||
| 289 | }; | 354 | }; |
| 290 | 355 | ||
| 356 | static int davinci_evm_probe(struct platform_device *pdev) | ||
| 357 | { | ||
| 358 | struct device_node *np = pdev->dev.of_node; | ||
| 359 | const struct of_device_id *match = | ||
| 360 | of_match_device(of_match_ptr(davinci_evm_dt_ids), &pdev->dev); | ||
| 361 | struct snd_soc_dai_link *dai = (struct snd_soc_dai_link *) match->data; | ||
| 362 | struct snd_soc_card_drvdata_davinci *drvdata = NULL; | ||
| 363 | int ret = 0; | ||
| 364 | |||
| 365 | evm_soc_card.dai_link = dai; | ||
| 366 | |||
| 367 | dai->codec_of_node = of_parse_phandle(np, "ti,audio-codec", 0); | ||
| 368 | if (!dai->codec_of_node) | ||
| 369 | return -EINVAL; | ||
| 370 | |||
| 371 | dai->cpu_of_node = of_parse_phandle(np, "ti,mcasp-controller", 0); | ||
| 372 | if (!dai->cpu_of_node) | ||
| 373 | return -EINVAL; | ||
| 374 | |||
| 375 | dai->platform_of_node = dai->cpu_of_node; | ||
| 376 | |||
| 377 | evm_soc_card.dev = &pdev->dev; | ||
| 378 | ret = snd_soc_of_parse_card_name(&evm_soc_card, "ti,model"); | ||
| 379 | if (ret) | ||
| 380 | return ret; | ||
| 381 | |||
| 382 | drvdata = devm_kzalloc(&pdev->dev, sizeof(*drvdata), GFP_KERNEL); | ||
| 383 | if (!drvdata) | ||
| 384 | return -ENOMEM; | ||
| 385 | |||
| 386 | ret = of_property_read_u32(np, "ti,codec-clock-rate", &drvdata->sysclk); | ||
| 387 | if (ret < 0) | ||
| 388 | return -EINVAL; | ||
| 389 | |||
| 390 | snd_soc_card_set_drvdata(&evm_soc_card, drvdata); | ||
| 391 | ret = devm_snd_soc_register_card(&pdev->dev, &evm_soc_card); | ||
| 392 | |||
| 393 | if (ret) | ||
| 394 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | ||
| 395 | |||
| 396 | return ret; | ||
| 397 | } | ||
| 398 | |||
| 399 | static int davinci_evm_remove(struct platform_device *pdev) | ||
| 400 | { | ||
| 401 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
| 402 | |||
| 403 | snd_soc_unregister_card(card); | ||
| 404 | |||
| 405 | return 0; | ||
| 406 | } | ||
| 407 | |||
| 408 | static struct platform_driver davinci_evm_driver = { | ||
| 409 | .probe = davinci_evm_probe, | ||
| 410 | .remove = davinci_evm_remove, | ||
| 411 | .driver = { | ||
| 412 | .name = "davinci_evm", | ||
| 413 | .owner = THIS_MODULE, | ||
| 414 | .of_match_table = of_match_ptr(davinci_evm_dt_ids), | ||
| 415 | }, | ||
| 416 | }; | ||
| 417 | #endif | ||
| 418 | |||
| 291 | static struct platform_device *evm_snd_device; | 419 | static struct platform_device *evm_snd_device; |
| 292 | 420 | ||
| 293 | static int __init evm_init(void) | 421 | static int __init evm_init(void) |
| @@ -296,6 +424,15 @@ static int __init evm_init(void) | |||
| 296 | int index; | 424 | int index; |
| 297 | int ret; | 425 | int ret; |
| 298 | 426 | ||
| 427 | /* | ||
| 428 | * If dtb is there, the devices will be created dynamically. | ||
| 429 | * Only register platfrom driver structure. | ||
| 430 | */ | ||
| 431 | #if defined(CONFIG_OF) | ||
| 432 | if (of_have_populated_dt()) | ||
| 433 | return platform_driver_register(&davinci_evm_driver); | ||
| 434 | #endif | ||
| 435 | |||
| 299 | if (machine_is_davinci_evm()) { | 436 | if (machine_is_davinci_evm()) { |
| 300 | evm_snd_dev_data = &dm6446_snd_soc_card_evm; | 437 | evm_snd_dev_data = &dm6446_snd_soc_card_evm; |
| 301 | index = 0; | 438 | index = 0; |
| @@ -331,6 +468,13 @@ static int __init evm_init(void) | |||
| 331 | 468 | ||
| 332 | static void __exit evm_exit(void) | 469 | static void __exit evm_exit(void) |
| 333 | { | 470 | { |
| 471 | #if defined(CONFIG_OF) | ||
| 472 | if (of_have_populated_dt()) { | ||
| 473 | platform_driver_unregister(&davinci_evm_driver); | ||
| 474 | return; | ||
| 475 | } | ||
| 476 | #endif | ||
| 477 | |||
| 334 | platform_device_unregister(evm_snd_device); | 478 | platform_device_unregister(evm_snd_device); |
| 335 | } | 479 | } |
| 336 | 480 | ||
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 32ddb7fe5034..71e14bb3a8cd 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
| @@ -1001,18 +1001,40 @@ static const struct snd_soc_component_driver davinci_mcasp_component = { | |||
| 1001 | .name = "davinci-mcasp", | 1001 | .name = "davinci-mcasp", |
| 1002 | }; | 1002 | }; |
| 1003 | 1003 | ||
| 1004 | /* Some HW specific values and defaults. The rest is filled in from DT. */ | ||
| 1005 | static struct snd_platform_data dm646x_mcasp_pdata = { | ||
| 1006 | .tx_dma_offset = 0x400, | ||
| 1007 | .rx_dma_offset = 0x400, | ||
| 1008 | .asp_chan_q = EVENTQ_0, | ||
| 1009 | .version = MCASP_VERSION_1, | ||
| 1010 | }; | ||
| 1011 | |||
| 1012 | static struct snd_platform_data da830_mcasp_pdata = { | ||
| 1013 | .tx_dma_offset = 0x2000, | ||
| 1014 | .rx_dma_offset = 0x2000, | ||
| 1015 | .asp_chan_q = EVENTQ_0, | ||
| 1016 | .version = MCASP_VERSION_2, | ||
| 1017 | }; | ||
| 1018 | |||
| 1019 | static struct snd_platform_data omap2_mcasp_pdata = { | ||
| 1020 | .tx_dma_offset = 0, | ||
| 1021 | .rx_dma_offset = 0, | ||
| 1022 | .asp_chan_q = EVENTQ_0, | ||
| 1023 | .version = MCASP_VERSION_3, | ||
| 1024 | }; | ||
| 1025 | |||
| 1004 | static const struct of_device_id mcasp_dt_ids[] = { | 1026 | static const struct of_device_id mcasp_dt_ids[] = { |
| 1005 | { | 1027 | { |
| 1006 | .compatible = "ti,dm646x-mcasp-audio", | 1028 | .compatible = "ti,dm646x-mcasp-audio", |
| 1007 | .data = (void *)MCASP_VERSION_1, | 1029 | .data = &dm646x_mcasp_pdata, |
| 1008 | }, | 1030 | }, |
| 1009 | { | 1031 | { |
| 1010 | .compatible = "ti,da830-mcasp-audio", | 1032 | .compatible = "ti,da830-mcasp-audio", |
| 1011 | .data = (void *)MCASP_VERSION_2, | 1033 | .data = &da830_mcasp_pdata, |
| 1012 | }, | 1034 | }, |
| 1013 | { | 1035 | { |
| 1014 | .compatible = "ti,omap2-mcasp-audio", | 1036 | .compatible = "ti,am33xx-mcasp-audio", |
| 1015 | .data = (void *)MCASP_VERSION_3, | 1037 | .data = &omap2_mcasp_pdata, |
| 1016 | }, | 1038 | }, |
| 1017 | { /* sentinel */ } | 1039 | { /* sentinel */ } |
| 1018 | }; | 1040 | }; |
| @@ -1025,9 +1047,9 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( | |||
| 1025 | struct snd_platform_data *pdata = NULL; | 1047 | struct snd_platform_data *pdata = NULL; |
| 1026 | const struct of_device_id *match = | 1048 | const struct of_device_id *match = |
| 1027 | of_match_device(mcasp_dt_ids, &pdev->dev); | 1049 | of_match_device(mcasp_dt_ids, &pdev->dev); |
| 1050 | struct of_phandle_args dma_spec; | ||
| 1028 | 1051 | ||
| 1029 | const u32 *of_serial_dir32; | 1052 | const u32 *of_serial_dir32; |
| 1030 | u8 *of_serial_dir; | ||
| 1031 | u32 val; | 1053 | u32 val; |
| 1032 | int i, ret = 0; | 1054 | int i, ret = 0; |
| 1033 | 1055 | ||
| @@ -1035,20 +1057,13 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( | |||
| 1035 | pdata = pdev->dev.platform_data; | 1057 | pdata = pdev->dev.platform_data; |
| 1036 | return pdata; | 1058 | return pdata; |
| 1037 | } else if (match) { | 1059 | } else if (match) { |
| 1038 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); | 1060 | pdata = (struct snd_platform_data *) match->data; |
| 1039 | if (!pdata) { | ||
| 1040 | ret = -ENOMEM; | ||
| 1041 | goto nodata; | ||
| 1042 | } | ||
| 1043 | } else { | 1061 | } else { |
| 1044 | /* control shouldn't reach here. something is wrong */ | 1062 | /* control shouldn't reach here. something is wrong */ |
| 1045 | ret = -EINVAL; | 1063 | ret = -EINVAL; |
| 1046 | goto nodata; | 1064 | goto nodata; |
| 1047 | } | 1065 | } |
| 1048 | 1066 | ||
| 1049 | if (match->data) | ||
| 1050 | pdata->version = (u8)((int)match->data); | ||
| 1051 | |||
| 1052 | ret = of_property_read_u32(np, "op-mode", &val); | 1067 | ret = of_property_read_u32(np, "op-mode", &val); |
| 1053 | if (ret >= 0) | 1068 | if (ret >= 0) |
| 1054 | pdata->op_mode = val; | 1069 | pdata->op_mode = val; |
| @@ -1065,35 +1080,46 @@ static struct snd_platform_data *davinci_mcasp_set_pdata_from_of( | |||
| 1065 | pdata->tdm_slots = val; | 1080 | pdata->tdm_slots = val; |
| 1066 | } | 1081 | } |
| 1067 | 1082 | ||
| 1068 | ret = of_property_read_u32(np, "num-serializer", &val); | ||
| 1069 | if (ret >= 0) | ||
| 1070 | pdata->num_serializer = val; | ||
| 1071 | |||
| 1072 | of_serial_dir32 = of_get_property(np, "serial-dir", &val); | 1083 | of_serial_dir32 = of_get_property(np, "serial-dir", &val); |
| 1073 | val /= sizeof(u32); | 1084 | val /= sizeof(u32); |
| 1074 | if (val != pdata->num_serializer) { | ||
| 1075 | dev_err(&pdev->dev, | ||
| 1076 | "num-serializer(%d) != serial-dir size(%d)\n", | ||
| 1077 | pdata->num_serializer, val); | ||
| 1078 | ret = -EINVAL; | ||
| 1079 | goto nodata; | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | if (of_serial_dir32) { | 1085 | if (of_serial_dir32) { |
| 1083 | of_serial_dir = devm_kzalloc(&pdev->dev, | 1086 | u8 *of_serial_dir = devm_kzalloc(&pdev->dev, |
| 1084 | (sizeof(*of_serial_dir) * val), | 1087 | (sizeof(*of_serial_dir) * val), |
| 1085 | GFP_KERNEL); | 1088 | GFP_KERNEL); |
| 1086 | if (!of_serial_dir) { | 1089 | if (!of_serial_dir) { |
| 1087 | ret = -ENOMEM; | 1090 | ret = -ENOMEM; |
| 1088 | goto nodata; | 1091 | goto nodata; |
| 1089 | } | 1092 | } |
| 1090 | 1093 | ||
| 1091 | for (i = 0; i < pdata->num_serializer; i++) | 1094 | for (i = 0; i < val; i++) |
| 1092 | of_serial_dir[i] = be32_to_cpup(&of_serial_dir32[i]); | 1095 | of_serial_dir[i] = be32_to_cpup(&of_serial_dir32[i]); |
| 1093 | 1096 | ||
| 1097 | pdata->num_serializer = val; | ||
| 1094 | pdata->serial_dir = of_serial_dir; | 1098 | pdata->serial_dir = of_serial_dir; |
| 1095 | } | 1099 | } |
| 1096 | 1100 | ||
| 1101 | ret = of_property_match_string(np, "dma-names", "tx"); | ||
| 1102 | if (ret < 0) | ||
| 1103 | goto nodata; | ||
| 1104 | |||
| 1105 | ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret, | ||
| 1106 | &dma_spec); | ||
| 1107 | if (ret < 0) | ||
| 1108 | goto nodata; | ||
| 1109 | |||
| 1110 | pdata->tx_dma_channel = dma_spec.args[0]; | ||
| 1111 | |||
| 1112 | ret = of_property_match_string(np, "dma-names", "rx"); | ||
| 1113 | if (ret < 0) | ||
| 1114 | goto nodata; | ||
| 1115 | |||
| 1116 | ret = of_parse_phandle_with_args(np, "dmas", "#dma-cells", ret, | ||
| 1117 | &dma_spec); | ||
| 1118 | if (ret < 0) | ||
| 1119 | goto nodata; | ||
| 1120 | |||
| 1121 | pdata->rx_dma_channel = dma_spec.args[0]; | ||
| 1122 | |||
| 1097 | ret = of_property_read_u32(np, "tx-num-evt", &val); | 1123 | ret = of_property_read_u32(np, "tx-num-evt", &val); |
| 1098 | if (ret >= 0) | 1124 | if (ret >= 0) |
| 1099 | pdata->txnumevt = val; | 1125 | pdata->txnumevt = val; |
| @@ -1124,7 +1150,7 @@ nodata: | |||
| 1124 | static int davinci_mcasp_probe(struct platform_device *pdev) | 1150 | static int davinci_mcasp_probe(struct platform_device *pdev) |
| 1125 | { | 1151 | { |
| 1126 | struct davinci_pcm_dma_params *dma_data; | 1152 | struct davinci_pcm_dma_params *dma_data; |
| 1127 | struct resource *mem, *ioarea, *res; | 1153 | struct resource *mem, *ioarea, *res, *dat; |
| 1128 | struct snd_platform_data *pdata; | 1154 | struct snd_platform_data *pdata; |
| 1129 | struct davinci_audio_dev *dev; | 1155 | struct davinci_audio_dev *dev; |
| 1130 | int ret; | 1156 | int ret; |
| @@ -1145,10 +1171,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
| 1145 | return -EINVAL; | 1171 | return -EINVAL; |
| 1146 | } | 1172 | } |
| 1147 | 1173 | ||
| 1148 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 1174 | mem = platform_get_resource_byname(pdev, IORESOURCE_MEM, "mpu"); |
| 1149 | if (!mem) { | 1175 | if (!mem) { |
| 1150 | dev_err(&pdev->dev, "no mem resource?\n"); | 1176 | dev_warn(dev->dev, |
| 1151 | return -ENODEV; | 1177 | "\"mpu\" mem resource not found, using index 0\n"); |
| 1178 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 1179 | if (!mem) { | ||
| 1180 | dev_err(&pdev->dev, "no mem resource?\n"); | ||
| 1181 | return -ENODEV; | ||
| 1182 | } | ||
| 1152 | } | 1183 | } |
| 1153 | 1184 | ||
| 1154 | ioarea = devm_request_mem_region(&pdev->dev, mem->start, | 1185 | ioarea = devm_request_mem_region(&pdev->dev, mem->start, |
| @@ -1182,40 +1213,36 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
| 1182 | dev->rxnumevt = pdata->rxnumevt; | 1213 | dev->rxnumevt = pdata->rxnumevt; |
| 1183 | dev->dev = &pdev->dev; | 1214 | dev->dev = &pdev->dev; |
| 1184 | 1215 | ||
| 1216 | dat = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dat"); | ||
| 1217 | if (!dat) | ||
| 1218 | dat = mem; | ||
| 1219 | |||
| 1185 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; | 1220 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_PLAYBACK]; |
| 1186 | dma_data->asp_chan_q = pdata->asp_chan_q; | 1221 | dma_data->asp_chan_q = pdata->asp_chan_q; |
| 1187 | dma_data->ram_chan_q = pdata->ram_chan_q; | 1222 | dma_data->ram_chan_q = pdata->ram_chan_q; |
| 1188 | dma_data->sram_pool = pdata->sram_pool; | 1223 | dma_data->sram_pool = pdata->sram_pool; |
| 1189 | dma_data->sram_size = pdata->sram_size_playback; | 1224 | dma_data->sram_size = pdata->sram_size_playback; |
| 1190 | dma_data->dma_addr = (dma_addr_t) (pdata->tx_dma_offset + | 1225 | dma_data->dma_addr = dat->start + pdata->tx_dma_offset; |
| 1191 | mem->start); | ||
| 1192 | 1226 | ||
| 1193 | /* first TX, then RX */ | ||
| 1194 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); | 1227 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
| 1195 | if (!res) { | 1228 | if (res) |
| 1196 | dev_err(&pdev->dev, "no DMA resource\n"); | 1229 | dma_data->channel = res->start; |
| 1197 | ret = -ENODEV; | 1230 | else |
| 1198 | goto err_release_clk; | 1231 | dma_data->channel = pdata->tx_dma_channel; |
| 1199 | } | ||
| 1200 | |||
| 1201 | dma_data->channel = res->start; | ||
| 1202 | 1232 | ||
| 1203 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]; | 1233 | dma_data = &dev->dma_params[SNDRV_PCM_STREAM_CAPTURE]; |
| 1204 | dma_data->asp_chan_q = pdata->asp_chan_q; | 1234 | dma_data->asp_chan_q = pdata->asp_chan_q; |
| 1205 | dma_data->ram_chan_q = pdata->ram_chan_q; | 1235 | dma_data->ram_chan_q = pdata->ram_chan_q; |
| 1206 | dma_data->sram_pool = pdata->sram_pool; | 1236 | dma_data->sram_pool = pdata->sram_pool; |
| 1207 | dma_data->sram_size = pdata->sram_size_capture; | 1237 | dma_data->sram_size = pdata->sram_size_capture; |
| 1208 | dma_data->dma_addr = (dma_addr_t)(pdata->rx_dma_offset + | 1238 | dma_data->dma_addr = dat->start + pdata->rx_dma_offset; |
| 1209 | mem->start); | ||
| 1210 | 1239 | ||
| 1211 | res = platform_get_resource(pdev, IORESOURCE_DMA, 1); | 1240 | res = platform_get_resource(pdev, IORESOURCE_DMA, 1); |
| 1212 | if (!res) { | 1241 | if (res) |
| 1213 | dev_err(&pdev->dev, "no DMA resource\n"); | 1242 | dma_data->channel = res->start; |
| 1214 | ret = -ENODEV; | 1243 | else |
| 1215 | goto err_release_clk; | 1244 | dma_data->channel = pdata->rx_dma_channel; |
| 1216 | } | ||
| 1217 | 1245 | ||
| 1218 | dma_data->channel = res->start; | ||
| 1219 | dev_set_drvdata(&pdev->dev, dev); | 1246 | dev_set_drvdata(&pdev->dev, dev); |
| 1220 | ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component, | 1247 | ret = snd_soc_register_component(&pdev->dev, &davinci_mcasp_component, |
| 1221 | &davinci_mcasp_dai[pdata->op_mode], 1); | 1248 | &davinci_mcasp_dai[pdata->op_mode], 1); |
| @@ -1251,12 +1278,51 @@ static int davinci_mcasp_remove(struct platform_device *pdev) | |||
| 1251 | return 0; | 1278 | return 0; |
| 1252 | } | 1279 | } |
| 1253 | 1280 | ||
| 1281 | #ifdef CONFIG_PM_SLEEP | ||
| 1282 | static int davinci_mcasp_suspend(struct device *dev) | ||
| 1283 | { | ||
| 1284 | struct davinci_audio_dev *a = dev_get_drvdata(dev); | ||
| 1285 | void __iomem *base = a->base; | ||
| 1286 | |||
| 1287 | a->context.txfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_TXFMCTL_REG); | ||
| 1288 | a->context.rxfmtctl = mcasp_get_reg(base + DAVINCI_MCASP_RXFMCTL_REG); | ||
| 1289 | a->context.txfmt = mcasp_get_reg(base + DAVINCI_MCASP_TXFMT_REG); | ||
| 1290 | a->context.rxfmt = mcasp_get_reg(base + DAVINCI_MCASP_RXFMT_REG); | ||
| 1291 | a->context.aclkxctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKXCTL_REG); | ||
| 1292 | a->context.aclkrctl = mcasp_get_reg(base + DAVINCI_MCASP_ACLKRCTL_REG); | ||
| 1293 | a->context.pdir = mcasp_get_reg(base + DAVINCI_MCASP_PDIR_REG); | ||
| 1294 | |||
| 1295 | return 0; | ||
| 1296 | } | ||
| 1297 | |||
| 1298 | static int davinci_mcasp_resume(struct device *dev) | ||
| 1299 | { | ||
| 1300 | struct davinci_audio_dev *a = dev_get_drvdata(dev); | ||
| 1301 | void __iomem *base = a->base; | ||
| 1302 | |||
| 1303 | mcasp_set_reg(base + DAVINCI_MCASP_TXFMCTL_REG, a->context.txfmtctl); | ||
| 1304 | mcasp_set_reg(base + DAVINCI_MCASP_RXFMCTL_REG, a->context.rxfmtctl); | ||
| 1305 | mcasp_set_reg(base + DAVINCI_MCASP_TXFMT_REG, a->context.txfmt); | ||
| 1306 | mcasp_set_reg(base + DAVINCI_MCASP_RXFMT_REG, a->context.rxfmt); | ||
| 1307 | mcasp_set_reg(base + DAVINCI_MCASP_ACLKXCTL_REG, a->context.aclkxctl); | ||
| 1308 | mcasp_set_reg(base + DAVINCI_MCASP_ACLKRCTL_REG, a->context.aclkrctl); | ||
| 1309 | mcasp_set_reg(base + DAVINCI_MCASP_PDIR_REG, a->context.pdir); | ||
| 1310 | |||
| 1311 | return 0; | ||
| 1312 | } | ||
| 1313 | #endif | ||
| 1314 | |||
| 1315 | SIMPLE_DEV_PM_OPS(davinci_mcasp_pm_ops, | ||
| 1316 | davinci_mcasp_suspend, | ||
| 1317 | davinci_mcasp_resume); | ||
| 1318 | |||
| 1254 | static struct platform_driver davinci_mcasp_driver = { | 1319 | static struct platform_driver davinci_mcasp_driver = { |
| 1255 | .probe = davinci_mcasp_probe, | 1320 | .probe = davinci_mcasp_probe, |
| 1256 | .remove = davinci_mcasp_remove, | 1321 | .remove = davinci_mcasp_remove, |
| 1257 | .driver = { | 1322 | .driver = { |
| 1258 | .name = "davinci-mcasp", | 1323 | .name = "davinci-mcasp", |
| 1259 | .owner = THIS_MODULE, | 1324 | .owner = THIS_MODULE, |
| 1325 | .pm = &davinci_mcasp_pm_ops, | ||
| 1260 | .of_match_table = mcasp_dt_ids, | 1326 | .of_match_table = mcasp_dt_ids, |
| 1261 | }, | 1327 | }, |
| 1262 | }; | 1328 | }; |
| @@ -1266,4 +1332,3 @@ module_platform_driver(davinci_mcasp_driver); | |||
| 1266 | MODULE_AUTHOR("Steve Chen"); | 1332 | MODULE_AUTHOR("Steve Chen"); |
| 1267 | MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface"); | 1333 | MODULE_DESCRIPTION("TI DAVINCI McASP SoC Interface"); |
| 1268 | MODULE_LICENSE("GPL"); | 1334 | MODULE_LICENSE("GPL"); |
| 1269 | |||
diff --git a/sound/soc/davinci/davinci-mcasp.h b/sound/soc/davinci/davinci-mcasp.h index a9ac0c11da71..a2e27e1c32f3 100644 --- a/sound/soc/davinci/davinci-mcasp.h +++ b/sound/soc/davinci/davinci-mcasp.h | |||
| @@ -43,6 +43,18 @@ struct davinci_audio_dev { | |||
| 43 | /* McASP FIFO related */ | 43 | /* McASP FIFO related */ |
| 44 | u8 txnumevt; | 44 | u8 txnumevt; |
| 45 | u8 rxnumevt; | 45 | u8 rxnumevt; |
| 46 | |||
| 47 | #ifdef CONFIG_PM_SLEEP | ||
| 48 | struct { | ||
| 49 | u32 txfmtctl; | ||
| 50 | u32 rxfmtctl; | ||
| 51 | u32 txfmt; | ||
| 52 | u32 rxfmt; | ||
| 53 | u32 aclkxctl; | ||
| 54 | u32 aclkrctl; | ||
| 55 | u32 pdir; | ||
| 56 | } context; | ||
| 57 | #endif | ||
| 46 | }; | 58 | }; |
| 47 | 59 | ||
| 48 | #endif /* DAVINCI_MCASP_H */ | 60 | #endif /* DAVINCI_MCASP_H */ |
diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 3920c3e849ce..ff1f34766ee3 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c | |||
| @@ -963,7 +963,7 @@ static bool fsl_spdif_readable_reg(struct device *dev, unsigned int reg) | |||
| 963 | return true; | 963 | return true; |
| 964 | default: | 964 | default: |
| 965 | return false; | 965 | return false; |
| 966 | }; | 966 | } |
| 967 | } | 967 | } |
| 968 | 968 | ||
| 969 | static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) | 969 | static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) |
| @@ -982,7 +982,7 @@ static bool fsl_spdif_writeable_reg(struct device *dev, unsigned int reg) | |||
| 982 | return true; | 982 | return true; |
| 983 | default: | 983 | default: |
| 984 | return false; | 984 | return false; |
| 985 | }; | 985 | } |
| 986 | } | 986 | } |
| 987 | 987 | ||
| 988 | static const struct regmap_config fsl_spdif_regmap_config = { | 988 | static const struct regmap_config fsl_spdif_regmap_config = { |
| @@ -1172,23 +1172,16 @@ static int fsl_spdif_probe(struct platform_device *pdev) | |||
| 1172 | /* Register with ASoC */ | 1172 | /* Register with ASoC */ |
| 1173 | dev_set_drvdata(&pdev->dev, spdif_priv); | 1173 | dev_set_drvdata(&pdev->dev, spdif_priv); |
| 1174 | 1174 | ||
| 1175 | ret = snd_soc_register_component(&pdev->dev, &fsl_spdif_component, | 1175 | ret = devm_snd_soc_register_component(&pdev->dev, &fsl_spdif_component, |
| 1176 | &spdif_priv->cpu_dai_drv, 1); | 1176 | &spdif_priv->cpu_dai_drv, 1); |
| 1177 | if (ret) { | 1177 | if (ret) { |
| 1178 | dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); | 1178 | dev_err(&pdev->dev, "failed to register DAI: %d\n", ret); |
| 1179 | return ret; | 1179 | return ret; |
| 1180 | } | 1180 | } |
| 1181 | 1181 | ||
| 1182 | ret = imx_pcm_dma_init(pdev); | 1182 | ret = imx_pcm_dma_init(pdev); |
| 1183 | if (ret) { | 1183 | if (ret) |
| 1184 | dev_err(&pdev->dev, "imx_pcm_dma_init failed: %d\n", ret); | 1184 | dev_err(&pdev->dev, "imx_pcm_dma_init failed: %d\n", ret); |
| 1185 | goto error_component; | ||
| 1186 | } | ||
| 1187 | |||
| 1188 | return ret; | ||
| 1189 | |||
| 1190 | error_component: | ||
| 1191 | snd_soc_unregister_component(&pdev->dev); | ||
| 1192 | 1185 | ||
| 1193 | return ret; | 1186 | return ret; |
| 1194 | } | 1187 | } |
| @@ -1196,7 +1189,6 @@ error_component: | |||
| 1196 | static int fsl_spdif_remove(struct platform_device *pdev) | 1189 | static int fsl_spdif_remove(struct platform_device *pdev) |
| 1197 | { | 1190 | { |
| 1198 | imx_pcm_dma_exit(pdev); | 1191 | imx_pcm_dma_exit(pdev); |
| 1199 | snd_soc_unregister_component(&pdev->dev); | ||
| 1200 | 1192 | ||
| 1201 | return 0; | 1193 | return 0; |
| 1202 | } | 1194 | } |
diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index c6b743978d5e..35e277379b86 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c | |||
| @@ -469,19 +469,12 @@ static int fsl_ssi_startup(struct snd_pcm_substream *substream, | |||
| 469 | * parameters, then the second stream may be | 469 | * parameters, then the second stream may be |
| 470 | * constrained to the wrong sample rate or size. | 470 | * constrained to the wrong sample rate or size. |
| 471 | */ | 471 | */ |
| 472 | if (!first_runtime->sample_bits) { | 472 | if (first_runtime->sample_bits) { |
| 473 | dev_err(substream->pcm->card->dev, | 473 | snd_pcm_hw_constraint_minmax(substream->runtime, |
| 474 | "set sample size in %s stream first\n", | 474 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, |
| 475 | substream->stream == | ||
| 476 | SNDRV_PCM_STREAM_PLAYBACK | ||
| 477 | ? "capture" : "playback"); | ||
| 478 | return -EAGAIN; | ||
| 479 | } | ||
| 480 | |||
| 481 | snd_pcm_hw_constraint_minmax(substream->runtime, | ||
| 482 | SNDRV_PCM_HW_PARAM_SAMPLE_BITS, | ||
| 483 | first_runtime->sample_bits, | 475 | first_runtime->sample_bits, |
| 484 | first_runtime->sample_bits); | 476 | first_runtime->sample_bits); |
| 477 | } | ||
| 485 | } | 478 | } |
| 486 | 479 | ||
| 487 | ssi_private->second_stream = substream; | 480 | ssi_private->second_stream = substream; |
| @@ -748,7 +741,7 @@ static void fsl_ssi_ac97_init(void) | |||
| 748 | fsl_ssi_setup(fsl_ac97_data); | 741 | fsl_ssi_setup(fsl_ac97_data); |
| 749 | } | 742 | } |
| 750 | 743 | ||
| 751 | void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | 744 | static void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, |
| 752 | unsigned short val) | 745 | unsigned short val) |
| 753 | { | 746 | { |
| 754 | struct ccsr_ssi *ssi = fsl_ac97_data->ssi; | 747 | struct ccsr_ssi *ssi = fsl_ac97_data->ssi; |
| @@ -770,7 +763,7 @@ void fsl_ssi_ac97_write(struct snd_ac97 *ac97, unsigned short reg, | |||
| 770 | udelay(100); | 763 | udelay(100); |
| 771 | } | 764 | } |
| 772 | 765 | ||
| 773 | unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97, | 766 | static unsigned short fsl_ssi_ac97_read(struct snd_ac97 *ac97, |
| 774 | unsigned short reg) | 767 | unsigned short reg) |
| 775 | { | 768 | { |
| 776 | struct ccsr_ssi *ssi = fsl_ac97_data->ssi; | 769 | struct ccsr_ssi *ssi = fsl_ac97_data->ssi; |
| @@ -936,7 +929,7 @@ static int fsl_ssi_probe(struct platform_device *pdev) | |||
| 936 | ssi_private->ssi_phys = res.start; | 929 | ssi_private->ssi_phys = res.start; |
| 937 | 930 | ||
| 938 | ssi_private->irq = irq_of_parse_and_map(np, 0); | 931 | ssi_private->irq = irq_of_parse_and_map(np, 0); |
| 939 | if (ssi_private->irq == NO_IRQ) { | 932 | if (!ssi_private->irq) { |
| 940 | dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); | 933 | dev_err(&pdev->dev, "no irq for node %s\n", np->full_name); |
| 941 | return -ENXIO; | 934 | return -ENXIO; |
| 942 | } | 935 | } |
| @@ -1135,7 +1128,6 @@ static int fsl_ssi_remove(struct platform_device *pdev) | |||
| 1135 | if (ssi_private->ssi_on_imx) | 1128 | if (ssi_private->ssi_on_imx) |
| 1136 | imx_pcm_dma_exit(pdev); | 1129 | imx_pcm_dma_exit(pdev); |
| 1137 | snd_soc_unregister_component(&pdev->dev); | 1130 | snd_soc_unregister_component(&pdev->dev); |
| 1138 | dev_set_drvdata(&pdev->dev, NULL); | ||
| 1139 | device_remove_file(&pdev->dev, &ssi_private->dev_attr); | 1131 | device_remove_file(&pdev->dev, &ssi_private->dev_attr); |
| 1140 | if (ssi_private->ssi_on_imx) | 1132 | if (ssi_private->ssi_on_imx) |
| 1141 | clk_disable_unprepare(ssi_private->clk); | 1133 | clk_disable_unprepare(ssi_private->clk); |
diff --git a/sound/soc/fsl/imx-audmux.c b/sound/soc/fsl/imx-audmux.c index d3bf71a0ec56..ac869931d7f1 100644 --- a/sound/soc/fsl/imx-audmux.c +++ b/sound/soc/fsl/imx-audmux.c | |||
| @@ -66,13 +66,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, | |||
| 66 | size_t count, loff_t *ppos) | 66 | size_t count, loff_t *ppos) |
| 67 | { | 67 | { |
| 68 | ssize_t ret; | 68 | ssize_t ret; |
| 69 | char *buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | 69 | char *buf; |
| 70 | int port = (int)file->private_data; | 70 | int port = (int)file->private_data; |
| 71 | u32 pdcr, ptcr; | 71 | u32 pdcr, ptcr; |
| 72 | 72 | ||
| 73 | if (!buf) | ||
| 74 | return -ENOMEM; | ||
| 75 | |||
| 76 | if (audmux_clk) { | 73 | if (audmux_clk) { |
| 77 | ret = clk_prepare_enable(audmux_clk); | 74 | ret = clk_prepare_enable(audmux_clk); |
| 78 | if (ret) | 75 | if (ret) |
| @@ -85,6 +82,10 @@ static ssize_t audmux_read_file(struct file *file, char __user *user_buf, | |||
| 85 | if (audmux_clk) | 82 | if (audmux_clk) |
| 86 | clk_disable_unprepare(audmux_clk); | 83 | clk_disable_unprepare(audmux_clk); |
| 87 | 84 | ||
| 85 | buf = kmalloc(PAGE_SIZE, GFP_KERNEL); | ||
| 86 | if (!buf) | ||
| 87 | return -ENOMEM; | ||
| 88 | |||
| 88 | ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n", | 89 | ret = snprintf(buf, PAGE_SIZE, "PDCR: %08x\nPTCR: %08x\n", |
| 89 | pdcr, ptcr); | 90 | pdcr, ptcr); |
| 90 | 91 | ||
diff --git a/sound/soc/fsl/imx-mc13783.c b/sound/soc/fsl/imx-mc13783.c index a3d60d4bea4c..79cee782dbbf 100644 --- a/sound/soc/fsl/imx-mc13783.c +++ b/sound/soc/fsl/imx-mc13783.c | |||
| @@ -112,7 +112,7 @@ static int imx_mc13783_probe(struct platform_device *pdev) | |||
| 112 | return ret; | 112 | return ret; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | if (machine_is_mx31_3ds()) { | 115 | if (machine_is_mx31_3ds() || machine_is_mx31moboard()) { |
| 116 | imx_audmux_v2_configure_port(MX31_AUDMUX_PORT4_SSI_PINS_4, | 116 | imx_audmux_v2_configure_port(MX31_AUDMUX_PORT4_SSI_PINS_4, |
| 117 | IMX_AUDMUX_V2_PTCR_SYN, | 117 | IMX_AUDMUX_V2_PTCR_SYN, |
| 118 | IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT1_SSI0) | | 118 | IMX_AUDMUX_V2_PDCR_RXDSEL(MX31_AUDMUX_PORT1_SSI0) | |
| @@ -160,6 +160,7 @@ static struct platform_driver imx_mc13783_audio_driver = { | |||
| 160 | .driver = { | 160 | .driver = { |
| 161 | .name = "imx_mc13783", | 161 | .name = "imx_mc13783", |
| 162 | .owner = THIS_MODULE, | 162 | .owner = THIS_MODULE, |
| 163 | .pm = &snd_soc_pm_ops, | ||
| 163 | }, | 164 | }, |
| 164 | .probe = imx_mc13783_probe, | 165 | .probe = imx_mc13783_probe, |
| 165 | .remove = imx_mc13783_remove | 166 | .remove = imx_mc13783_remove |
diff --git a/sound/soc/fsl/imx-pcm-dma.c b/sound/soc/fsl/imx-pcm-dma.c index 4dc1296688e9..aee23077080a 100644 --- a/sound/soc/fsl/imx-pcm-dma.c +++ b/sound/soc/fsl/imx-pcm-dma.c | |||
| @@ -25,12 +25,10 @@ | |||
| 25 | 25 | ||
| 26 | static bool filter(struct dma_chan *chan, void *param) | 26 | static bool filter(struct dma_chan *chan, void *param) |
| 27 | { | 27 | { |
| 28 | struct snd_dmaengine_dai_dma_data *dma_data = param; | ||
| 29 | |||
| 30 | if (!imx_dma_is_general_purpose(chan)) | 28 | if (!imx_dma_is_general_purpose(chan)) |
| 31 | return false; | 29 | return false; |
| 32 | 30 | ||
| 33 | chan->private = dma_data->filter_data; | 31 | chan->private = param; |
| 34 | 32 | ||
| 35 | return true; | 33 | return true; |
| 36 | } | 34 | } |
diff --git a/sound/soc/fsl/imx-sgtl5000.c b/sound/soc/fsl/imx-sgtl5000.c index ca1be1d9dcf0..f2beae78969f 100644 --- a/sound/soc/fsl/imx-sgtl5000.c +++ b/sound/soc/fsl/imx-sgtl5000.c | |||
| @@ -159,7 +159,7 @@ static int imx_sgtl5000_probe(struct platform_device *pdev) | |||
| 159 | data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; | 159 | data->card.dapm_widgets = imx_sgtl5000_dapm_widgets; |
| 160 | data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets); | 160 | data->card.num_dapm_widgets = ARRAY_SIZE(imx_sgtl5000_dapm_widgets); |
| 161 | 161 | ||
| 162 | ret = snd_soc_register_card(&data->card); | 162 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); |
| 163 | if (ret) { | 163 | if (ret) { |
| 164 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | 164 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); |
| 165 | goto fail; | 165 | goto fail; |
| @@ -186,7 +186,6 @@ static int imx_sgtl5000_remove(struct platform_device *pdev) | |||
| 186 | { | 186 | { |
| 187 | struct imx_sgtl5000_data *data = platform_get_drvdata(pdev); | 187 | struct imx_sgtl5000_data *data = platform_get_drvdata(pdev); |
| 188 | 188 | ||
| 189 | snd_soc_unregister_card(&data->card); | ||
| 190 | clk_put(data->codec_clk); | 189 | clk_put(data->codec_clk); |
| 191 | 190 | ||
| 192 | return 0; | 191 | return 0; |
| @@ -202,6 +201,7 @@ static struct platform_driver imx_sgtl5000_driver = { | |||
| 202 | .driver = { | 201 | .driver = { |
| 203 | .name = "imx-sgtl5000", | 202 | .name = "imx-sgtl5000", |
| 204 | .owner = THIS_MODULE, | 203 | .owner = THIS_MODULE, |
| 204 | .pm = &snd_soc_pm_ops, | ||
| 205 | .of_match_table = imx_sgtl5000_dt_ids, | 205 | .of_match_table = imx_sgtl5000_dt_ids, |
| 206 | }, | 206 | }, |
| 207 | .probe = imx_sgtl5000_probe, | 207 | .probe = imx_sgtl5000_probe, |
diff --git a/sound/soc/fsl/imx-spdif.c b/sound/soc/fsl/imx-spdif.c index 816013b0ebba..8499d5292f08 100644 --- a/sound/soc/fsl/imx-spdif.c +++ b/sound/soc/fsl/imx-spdif.c | |||
| @@ -87,7 +87,7 @@ static int imx_spdif_audio_probe(struct platform_device *pdev) | |||
| 87 | if (ret) | 87 | if (ret) |
| 88 | goto error_dir; | 88 | goto error_dir; |
| 89 | 89 | ||
| 90 | ret = snd_soc_register_card(&data->card); | 90 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); |
| 91 | if (ret) { | 91 | if (ret) { |
| 92 | dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); | 92 | dev_err(&pdev->dev, "snd_soc_register_card failed: %d\n", ret); |
| 93 | goto error_dir; | 93 | goto error_dir; |
| @@ -119,8 +119,6 @@ static int imx_spdif_audio_remove(struct platform_device *pdev) | |||
| 119 | if (data->txdev) | 119 | if (data->txdev) |
| 120 | platform_device_unregister(data->txdev); | 120 | platform_device_unregister(data->txdev); |
| 121 | 121 | ||
| 122 | snd_soc_unregister_card(&data->card); | ||
| 123 | |||
| 124 | return 0; | 122 | return 0; |
| 125 | } | 123 | } |
| 126 | 124 | ||
diff --git a/sound/soc/fsl/imx-ssi.c b/sound/soc/fsl/imx-ssi.c index f58bcd85c07f..f5f248c91c16 100644 --- a/sound/soc/fsl/imx-ssi.c +++ b/sound/soc/fsl/imx-ssi.c | |||
| @@ -600,22 +600,19 @@ static int imx_ssi_probe(struct platform_device *pdev) | |||
| 600 | ssi->fiq_params.dma_params_rx = &ssi->dma_params_rx; | 600 | ssi->fiq_params.dma_params_rx = &ssi->dma_params_rx; |
| 601 | ssi->fiq_params.dma_params_tx = &ssi->dma_params_tx; | 601 | ssi->fiq_params.dma_params_tx = &ssi->dma_params_tx; |
| 602 | 602 | ||
| 603 | ret = imx_pcm_fiq_init(pdev, &ssi->fiq_params); | 603 | ssi->fiq_init = imx_pcm_fiq_init(pdev, &ssi->fiq_params); |
| 604 | if (ret) | 604 | ssi->dma_init = imx_pcm_dma_init(pdev); |
| 605 | goto failed_pcm_fiq; | ||
| 606 | 605 | ||
| 607 | ret = imx_pcm_dma_init(pdev); | 606 | if (ssi->fiq_init && ssi->dma_init) { |
| 608 | if (ret) | 607 | ret = ssi->fiq_init; |
| 609 | goto failed_pcm_dma; | 608 | goto failed_pcm; |
| 609 | } | ||
| 610 | 610 | ||
| 611 | return 0; | 611 | return 0; |
| 612 | 612 | ||
| 613 | failed_pcm_dma: | 613 | failed_pcm: |
| 614 | imx_pcm_fiq_exit(pdev); | ||
| 615 | failed_pcm_fiq: | ||
| 616 | snd_soc_unregister_component(&pdev->dev); | 614 | snd_soc_unregister_component(&pdev->dev); |
| 617 | failed_register: | 615 | failed_register: |
| 618 | release_mem_region(res->start, resource_size(res)); | ||
| 619 | clk_disable_unprepare(ssi->clk); | 616 | clk_disable_unprepare(ssi->clk); |
| 620 | failed_clk: | 617 | failed_clk: |
| 621 | snd_soc_set_ac97_ops(NULL); | 618 | snd_soc_set_ac97_ops(NULL); |
| @@ -625,18 +622,19 @@ failed_clk: | |||
| 625 | 622 | ||
| 626 | static int imx_ssi_remove(struct platform_device *pdev) | 623 | static int imx_ssi_remove(struct platform_device *pdev) |
| 627 | { | 624 | { |
| 628 | struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 629 | struct imx_ssi *ssi = platform_get_drvdata(pdev); | 625 | struct imx_ssi *ssi = platform_get_drvdata(pdev); |
| 630 | 626 | ||
| 631 | imx_pcm_dma_exit(pdev); | 627 | if (!ssi->dma_init) |
| 632 | imx_pcm_fiq_exit(pdev); | 628 | imx_pcm_dma_exit(pdev); |
| 629 | |||
| 630 | if (!ssi->fiq_init) | ||
| 631 | imx_pcm_fiq_exit(pdev); | ||
| 633 | 632 | ||
| 634 | snd_soc_unregister_component(&pdev->dev); | 633 | snd_soc_unregister_component(&pdev->dev); |
| 635 | 634 | ||
| 636 | if (ssi->flags & IMX_SSI_USE_AC97) | 635 | if (ssi->flags & IMX_SSI_USE_AC97) |
| 637 | ac97_ssi = NULL; | 636 | ac97_ssi = NULL; |
| 638 | 637 | ||
| 639 | release_mem_region(res->start, resource_size(res)); | ||
| 640 | clk_disable_unprepare(ssi->clk); | 638 | clk_disable_unprepare(ssi->clk); |
| 641 | snd_soc_set_ac97_ops(NULL); | 639 | snd_soc_set_ac97_ops(NULL); |
| 642 | 640 | ||
diff --git a/sound/soc/fsl/imx-ssi.h b/sound/soc/fsl/imx-ssi.h index fb1616ba8c59..560c40fc9ebb 100644 --- a/sound/soc/fsl/imx-ssi.h +++ b/sound/soc/fsl/imx-ssi.h | |||
| @@ -211,6 +211,8 @@ struct imx_ssi { | |||
| 211 | struct imx_dma_data filter_data_rx; | 211 | struct imx_dma_data filter_data_rx; |
| 212 | struct imx_pcm_fiq_params fiq_params; | 212 | struct imx_pcm_fiq_params fiq_params; |
| 213 | 213 | ||
| 214 | int fiq_init; | ||
| 215 | int dma_init; | ||
| 214 | int enabled; | 216 | int enabled; |
| 215 | }; | 217 | }; |
| 216 | 218 | ||
diff --git a/sound/soc/fsl/imx-wm8962.c b/sound/soc/fsl/imx-wm8962.c index 722afe69169e..72064e995687 100644 --- a/sound/soc/fsl/imx-wm8962.c +++ b/sound/soc/fsl/imx-wm8962.c | |||
| @@ -266,7 +266,7 @@ static int imx_wm8962_probe(struct platform_device *pdev) | |||
| 266 | data->card.late_probe = imx_wm8962_late_probe; | 266 | data->card.late_probe = imx_wm8962_late_probe; |
| 267 | data->card.set_bias_level = imx_wm8962_set_bias_level; | 267 | data->card.set_bias_level = imx_wm8962_set_bias_level; |
| 268 | 268 | ||
| 269 | ret = snd_soc_register_card(&data->card); | 269 | ret = devm_snd_soc_register_card(&pdev->dev, &data->card); |
| 270 | if (ret) { | 270 | if (ret) { |
| 271 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); | 271 | dev_err(&pdev->dev, "snd_soc_register_card failed (%d)\n", ret); |
| 272 | goto clk_fail; | 272 | goto clk_fail; |
| @@ -296,7 +296,6 @@ static int imx_wm8962_remove(struct platform_device *pdev) | |||
| 296 | 296 | ||
| 297 | if (!IS_ERR(data->codec_clk)) | 297 | if (!IS_ERR(data->codec_clk)) |
| 298 | clk_disable_unprepare(data->codec_clk); | 298 | clk_disable_unprepare(data->codec_clk); |
| 299 | snd_soc_unregister_card(&data->card); | ||
| 300 | 299 | ||
| 301 | return 0; | 300 | return 0; |
| 302 | } | 301 | } |
| @@ -311,6 +310,7 @@ static struct platform_driver imx_wm8962_driver = { | |||
| 311 | .driver = { | 310 | .driver = { |
| 312 | .name = "imx-wm8962", | 311 | .name = "imx-wm8962", |
| 313 | .owner = THIS_MODULE, | 312 | .owner = THIS_MODULE, |
| 313 | .pm = &snd_soc_pm_ops, | ||
| 314 | .of_match_table = imx_wm8962_dt_ids, | 314 | .of_match_table = imx_wm8962_dt_ids, |
| 315 | }, | 315 | }, |
| 316 | .probe = imx_wm8962_probe, | 316 | .probe = imx_wm8962_probe, |
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 8c49147db84c..b2fbb7075a6c 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
| @@ -27,6 +27,11 @@ static int __asoc_simple_card_dai_init(struct snd_soc_dai *dai, | |||
| 27 | if (!ret && daifmt) | 27 | if (!ret && daifmt) |
| 28 | ret = snd_soc_dai_set_fmt(dai, daifmt); | 28 | ret = snd_soc_dai_set_fmt(dai, daifmt); |
| 29 | 29 | ||
| 30 | if (ret == -ENOTSUPP) { | ||
| 31 | dev_dbg(dai->dev, "ASoC: set_fmt is not supported\n"); | ||
| 32 | ret = 0; | ||
| 33 | } | ||
| 34 | |||
| 30 | if (!ret && set->sysclk) | 35 | if (!ret && set->sysclk) |
| 31 | ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0); | 36 | ret = snd_soc_dai_set_sysclk(dai, 0, set->sysclk, 0); |
| 32 | 37 | ||
diff --git a/sound/soc/kirkwood/kirkwood-dma.c b/sound/soc/kirkwood/kirkwood-dma.c index b238434f92b0..55d0d9d3a9fd 100644 --- a/sound/soc/kirkwood/kirkwood-dma.c +++ b/sound/soc/kirkwood/kirkwood-dma.c | |||
| @@ -29,9 +29,7 @@ | |||
| 29 | #define KIRKWOOD_FORMATS \ | 29 | #define KIRKWOOD_FORMATS \ |
| 30 | (SNDRV_PCM_FMTBIT_S16_LE | \ | 30 | (SNDRV_PCM_FMTBIT_S16_LE | \ |
| 31 | SNDRV_PCM_FMTBIT_S24_LE | \ | 31 | SNDRV_PCM_FMTBIT_S24_LE | \ |
| 32 | SNDRV_PCM_FMTBIT_S32_LE | \ | 32 | SNDRV_PCM_FMTBIT_S32_LE) |
| 33 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_LE | \ | ||
| 34 | SNDRV_PCM_FMTBIT_IEC958_SUBFRAME_BE) | ||
| 35 | 33 | ||
| 36 | static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs) | 34 | static struct kirkwood_dma_data *kirkwood_priv(struct snd_pcm_substream *subs) |
| 37 | { | 35 | { |
| @@ -161,7 +159,7 @@ static int kirkwood_dma_open(struct snd_pcm_substream *substream) | |||
| 161 | * Enable Error interrupts. We're only ack'ing them but | 159 | * Enable Error interrupts. We're only ack'ing them but |
| 162 | * it's useful for diagnostics | 160 | * it's useful for diagnostics |
| 163 | */ | 161 | */ |
| 164 | writel((unsigned long)-1, priv->io + KIRKWOOD_ERR_MASK); | 162 | writel((unsigned int)-1, priv->io + KIRKWOOD_ERR_MASK); |
| 165 | } | 163 | } |
| 166 | 164 | ||
| 167 | dram = mv_mbus_dram_info(); | 165 | dram = mv_mbus_dram_info(); |
diff --git a/sound/soc/kirkwood/kirkwood-i2s.c b/sound/soc/kirkwood/kirkwood-i2s.c index 0f3d73d4ef48..9ec38d15df9e 100644 --- a/sound/soc/kirkwood/kirkwood-i2s.c +++ b/sound/soc/kirkwood/kirkwood-i2s.c | |||
| @@ -103,7 +103,7 @@ static void kirkwood_set_rate(struct snd_soc_dai *dai, | |||
| 103 | { | 103 | { |
| 104 | uint32_t clks_ctrl; | 104 | uint32_t clks_ctrl; |
| 105 | 105 | ||
| 106 | if (rate == 44100 || rate == 48000 || rate == 96000) { | 106 | if (IS_ERR(priv->extclk)) { |
| 107 | /* use internal dco for the supported rates | 107 | /* use internal dco for the supported rates |
| 108 | * defined in kirkwood_i2s_dai */ | 108 | * defined in kirkwood_i2s_dai */ |
| 109 | dev_dbg(dai->dev, "%s: dco set rate = %lu\n", | 109 | dev_dbg(dai->dev, "%s: dco set rate = %lu\n", |
| @@ -160,9 +160,11 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 160 | case SNDRV_PCM_FORMAT_S16_LE: | 160 | case SNDRV_PCM_FORMAT_S16_LE: |
| 161 | i2s_value |= KIRKWOOD_I2S_CTL_SIZE_16; | 161 | i2s_value |= KIRKWOOD_I2S_CTL_SIZE_16; |
| 162 | ctl_play = KIRKWOOD_PLAYCTL_SIZE_16_C | | 162 | ctl_play = KIRKWOOD_PLAYCTL_SIZE_16_C | |
| 163 | KIRKWOOD_PLAYCTL_I2S_EN; | 163 | KIRKWOOD_PLAYCTL_I2S_EN | |
| 164 | KIRKWOOD_PLAYCTL_SPDIF_EN; | ||
| 164 | ctl_rec = KIRKWOOD_RECCTL_SIZE_16_C | | 165 | ctl_rec = KIRKWOOD_RECCTL_SIZE_16_C | |
| 165 | KIRKWOOD_RECCTL_I2S_EN; | 166 | KIRKWOOD_RECCTL_I2S_EN | |
| 167 | KIRKWOOD_RECCTL_SPDIF_EN; | ||
| 166 | break; | 168 | break; |
| 167 | /* | 169 | /* |
| 168 | * doesn't work... S20_3LE != kirkwood 20bit format ? | 170 | * doesn't work... S20_3LE != kirkwood 20bit format ? |
| @@ -178,9 +180,11 @@ static int kirkwood_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 178 | case SNDRV_PCM_FORMAT_S24_LE: | 180 | case SNDRV_PCM_FORMAT_S24_LE: |
| 179 | i2s_value |= KIRKWOOD_I2S_CTL_SIZE_24; | 181 | i2s_value |= KIRKWOOD_I2S_CTL_SIZE_24; |
| 180 | ctl_play = KIRKWOOD_PLAYCTL_SIZE_24 | | 182 | ctl_play = KIRKWOOD_PLAYCTL_SIZE_24 | |
| 181 | KIRKWOOD_PLAYCTL_I2S_EN; | 183 | KIRKWOOD_PLAYCTL_I2S_EN | |
| 184 | KIRKWOOD_PLAYCTL_SPDIF_EN; | ||
| 182 | ctl_rec = KIRKWOOD_RECCTL_SIZE_24 | | 185 | ctl_rec = KIRKWOOD_RECCTL_SIZE_24 | |
| 183 | KIRKWOOD_RECCTL_I2S_EN; | 186 | KIRKWOOD_RECCTL_I2S_EN | |
| 187 | KIRKWOOD_RECCTL_SPDIF_EN; | ||
| 184 | break; | 188 | break; |
| 185 | case SNDRV_PCM_FORMAT_S32_LE: | 189 | case SNDRV_PCM_FORMAT_S32_LE: |
| 186 | i2s_value |= KIRKWOOD_I2S_CTL_SIZE_32; | 190 | i2s_value |= KIRKWOOD_I2S_CTL_SIZE_32; |
| @@ -240,6 +244,11 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | |||
| 240 | ctl); | 244 | ctl); |
| 241 | } | 245 | } |
| 242 | 246 | ||
| 247 | if (dai->id == 0) | ||
| 248 | ctl &= ~KIRKWOOD_PLAYCTL_SPDIF_EN; /* i2s */ | ||
| 249 | else | ||
| 250 | ctl &= ~KIRKWOOD_PLAYCTL_I2S_EN; /* spdif */ | ||
| 251 | |||
| 243 | switch (cmd) { | 252 | switch (cmd) { |
| 244 | case SNDRV_PCM_TRIGGER_START: | 253 | case SNDRV_PCM_TRIGGER_START: |
| 245 | /* configure */ | 254 | /* configure */ |
| @@ -258,7 +267,8 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | |||
| 258 | 267 | ||
| 259 | case SNDRV_PCM_TRIGGER_STOP: | 268 | case SNDRV_PCM_TRIGGER_STOP: |
| 260 | /* stop audio, disable interrupts */ | 269 | /* stop audio, disable interrupts */ |
| 261 | ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; | 270 | ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | |
| 271 | KIRKWOOD_PLAYCTL_SPDIF_MUTE; | ||
| 262 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); | 272 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); |
| 263 | 273 | ||
| 264 | value = readl(priv->io + KIRKWOOD_INT_MASK); | 274 | value = readl(priv->io + KIRKWOOD_INT_MASK); |
| @@ -272,13 +282,15 @@ static int kirkwood_i2s_play_trigger(struct snd_pcm_substream *substream, | |||
| 272 | 282 | ||
| 273 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 283 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
| 274 | case SNDRV_PCM_TRIGGER_SUSPEND: | 284 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 275 | ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE; | 285 | ctl |= KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | |
| 286 | KIRKWOOD_PLAYCTL_SPDIF_MUTE; | ||
| 276 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); | 287 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); |
| 277 | break; | 288 | break; |
| 278 | 289 | ||
| 279 | case SNDRV_PCM_TRIGGER_RESUME: | 290 | case SNDRV_PCM_TRIGGER_RESUME: |
| 280 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 291 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 281 | ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE); | 292 | ctl &= ~(KIRKWOOD_PLAYCTL_PAUSE | KIRKWOOD_PLAYCTL_I2S_MUTE | |
| 293 | KIRKWOOD_PLAYCTL_SPDIF_MUTE); | ||
| 282 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); | 294 | writel(ctl, priv->io + KIRKWOOD_PLAYCTL); |
| 283 | break; | 295 | break; |
| 284 | 296 | ||
| @@ -301,7 +313,13 @@ static int kirkwood_i2s_rec_trigger(struct snd_pcm_substream *substream, | |||
| 301 | case SNDRV_PCM_TRIGGER_START: | 313 | case SNDRV_PCM_TRIGGER_START: |
| 302 | /* configure */ | 314 | /* configure */ |
| 303 | ctl = priv->ctl_rec; | 315 | ctl = priv->ctl_rec; |
| 304 | value = ctl & ~KIRKWOOD_RECCTL_I2S_EN; | 316 | if (dai->id == 0) |
| 317 | ctl &= ~KIRKWOOD_RECCTL_SPDIF_EN; /* i2s */ | ||
| 318 | else | ||
| 319 | ctl &= ~KIRKWOOD_RECCTL_I2S_EN; /* spdif */ | ||
| 320 | |||
| 321 | value = ctl & ~(KIRKWOOD_RECCTL_I2S_EN | | ||
| 322 | KIRKWOOD_RECCTL_SPDIF_EN); | ||
| 305 | writel(value, priv->io + KIRKWOOD_RECCTL); | 323 | writel(value, priv->io + KIRKWOOD_RECCTL); |
| 306 | 324 | ||
| 307 | /* enable interrupts */ | 325 | /* enable interrupts */ |
| @@ -361,9 +379,8 @@ static int kirkwood_i2s_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 361 | return 0; | 379 | return 0; |
| 362 | } | 380 | } |
| 363 | 381 | ||
| 364 | static int kirkwood_i2s_probe(struct snd_soc_dai *dai) | 382 | static int kirkwood_i2s_init(struct kirkwood_dma_data *priv) |
| 365 | { | 383 | { |
| 366 | struct kirkwood_dma_data *priv = snd_soc_dai_get_drvdata(dai); | ||
| 367 | unsigned long value; | 384 | unsigned long value; |
| 368 | unsigned int reg_data; | 385 | unsigned int reg_data; |
| 369 | 386 | ||
| @@ -404,9 +421,10 @@ static const struct snd_soc_dai_ops kirkwood_i2s_dai_ops = { | |||
| 404 | .set_fmt = kirkwood_i2s_set_fmt, | 421 | .set_fmt = kirkwood_i2s_set_fmt, |
| 405 | }; | 422 | }; |
| 406 | 423 | ||
| 407 | 424 | static struct snd_soc_dai_driver kirkwood_i2s_dai[2] = { | |
| 408 | static struct snd_soc_dai_driver kirkwood_i2s_dai = { | 425 | { |
| 409 | .probe = kirkwood_i2s_probe, | 426 | .name = "i2s", |
| 427 | .id = 0, | ||
| 410 | .playback = { | 428 | .playback = { |
| 411 | .channels_min = 1, | 429 | .channels_min = 1, |
| 412 | .channels_max = 2, | 430 | .channels_max = 2, |
| @@ -422,10 +440,53 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai = { | |||
| 422 | .formats = KIRKWOOD_I2S_FORMATS, | 440 | .formats = KIRKWOOD_I2S_FORMATS, |
| 423 | }, | 441 | }, |
| 424 | .ops = &kirkwood_i2s_dai_ops, | 442 | .ops = &kirkwood_i2s_dai_ops, |
| 443 | }, | ||
| 444 | { | ||
| 445 | .name = "spdif", | ||
| 446 | .id = 1, | ||
| 447 | .playback = { | ||
| 448 | .channels_min = 1, | ||
| 449 | .channels_max = 2, | ||
| 450 | .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | | ||
| 451 | SNDRV_PCM_RATE_96000, | ||
| 452 | .formats = KIRKWOOD_I2S_FORMATS, | ||
| 453 | }, | ||
| 454 | .capture = { | ||
| 455 | .channels_min = 1, | ||
| 456 | .channels_max = 2, | ||
| 457 | .rates = SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 | | ||
| 458 | SNDRV_PCM_RATE_96000, | ||
| 459 | .formats = KIRKWOOD_I2S_FORMATS, | ||
| 460 | }, | ||
| 461 | .ops = &kirkwood_i2s_dai_ops, | ||
| 462 | }, | ||
| 425 | }; | 463 | }; |
| 426 | 464 | ||
| 427 | static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = { | 465 | static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk[2] = { |
| 428 | .probe = kirkwood_i2s_probe, | 466 | { |
| 467 | .name = "i2s", | ||
| 468 | .id = 0, | ||
| 469 | .playback = { | ||
| 470 | .channels_min = 1, | ||
| 471 | .channels_max = 2, | ||
| 472 | .rates = SNDRV_PCM_RATE_8000_192000 | | ||
| 473 | SNDRV_PCM_RATE_CONTINUOUS | | ||
| 474 | SNDRV_PCM_RATE_KNOT, | ||
| 475 | .formats = KIRKWOOD_I2S_FORMATS, | ||
| 476 | }, | ||
| 477 | .capture = { | ||
| 478 | .channels_min = 1, | ||
| 479 | .channels_max = 2, | ||
| 480 | .rates = SNDRV_PCM_RATE_8000_192000 | | ||
| 481 | SNDRV_PCM_RATE_CONTINUOUS | | ||
| 482 | SNDRV_PCM_RATE_KNOT, | ||
| 483 | .formats = KIRKWOOD_I2S_FORMATS, | ||
| 484 | }, | ||
| 485 | .ops = &kirkwood_i2s_dai_ops, | ||
| 486 | }, | ||
| 487 | { | ||
| 488 | .name = "spdif", | ||
| 489 | .id = 1, | ||
| 429 | .playback = { | 490 | .playback = { |
| 430 | .channels_min = 1, | 491 | .channels_min = 1, |
| 431 | .channels_max = 2, | 492 | .channels_max = 2, |
| @@ -443,6 +504,7 @@ static struct snd_soc_dai_driver kirkwood_i2s_dai_extclk = { | |||
| 443 | .formats = KIRKWOOD_I2S_FORMATS, | 504 | .formats = KIRKWOOD_I2S_FORMATS, |
| 444 | }, | 505 | }, |
| 445 | .ops = &kirkwood_i2s_dai_ops, | 506 | .ops = &kirkwood_i2s_dai_ops, |
| 507 | }, | ||
| 446 | }; | 508 | }; |
| 447 | 509 | ||
| 448 | static const struct snd_soc_component_driver kirkwood_i2s_component = { | 510 | static const struct snd_soc_component_driver kirkwood_i2s_component = { |
| @@ -452,7 +514,7 @@ static const struct snd_soc_component_driver kirkwood_i2s_component = { | |||
| 452 | static int kirkwood_i2s_dev_probe(struct platform_device *pdev) | 514 | static int kirkwood_i2s_dev_probe(struct platform_device *pdev) |
| 453 | { | 515 | { |
| 454 | struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; | 516 | struct kirkwood_asoc_platform_data *data = pdev->dev.platform_data; |
| 455 | struct snd_soc_dai_driver *soc_dai = &kirkwood_i2s_dai; | 517 | struct snd_soc_dai_driver *soc_dai = kirkwood_i2s_dai; |
| 456 | struct kirkwood_dma_data *priv; | 518 | struct kirkwood_dma_data *priv; |
| 457 | struct resource *mem; | 519 | struct resource *mem; |
| 458 | struct device_node *np = pdev->dev.of_node; | 520 | struct device_node *np = pdev->dev.of_node; |
| @@ -496,7 +558,10 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) | |||
| 496 | return err; | 558 | return err; |
| 497 | 559 | ||
| 498 | priv->extclk = devm_clk_get(&pdev->dev, "extclk"); | 560 | priv->extclk = devm_clk_get(&pdev->dev, "extclk"); |
| 499 | if (!IS_ERR(priv->extclk)) { | 561 | if (IS_ERR(priv->extclk)) { |
| 562 | if (PTR_ERR(priv->extclk) == -EPROBE_DEFER) | ||
| 563 | return -EPROBE_DEFER; | ||
| 564 | } else { | ||
| 500 | if (priv->extclk == priv->clk) { | 565 | if (priv->extclk == priv->clk) { |
| 501 | devm_clk_put(&pdev->dev, priv->extclk); | 566 | devm_clk_put(&pdev->dev, priv->extclk); |
| 502 | priv->extclk = ERR_PTR(-EINVAL); | 567 | priv->extclk = ERR_PTR(-EINVAL); |
| @@ -521,7 +586,7 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) | |||
| 521 | } | 586 | } |
| 522 | 587 | ||
| 523 | err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, | 588 | err = snd_soc_register_component(&pdev->dev, &kirkwood_i2s_component, |
| 524 | soc_dai, 1); | 589 | soc_dai, 2); |
| 525 | if (err) { | 590 | if (err) { |
| 526 | dev_err(&pdev->dev, "snd_soc_register_component failed\n"); | 591 | dev_err(&pdev->dev, "snd_soc_register_component failed\n"); |
| 527 | goto err_component; | 592 | goto err_component; |
| @@ -532,6 +597,9 @@ static int kirkwood_i2s_dev_probe(struct platform_device *pdev) | |||
| 532 | dev_err(&pdev->dev, "snd_soc_register_platform failed\n"); | 597 | dev_err(&pdev->dev, "snd_soc_register_platform failed\n"); |
| 533 | goto err_platform; | 598 | goto err_platform; |
| 534 | } | 599 | } |
| 600 | |||
| 601 | kirkwood_i2s_init(priv); | ||
| 602 | |||
| 535 | return 0; | 603 | return 0; |
| 536 | err_platform: | 604 | err_platform: |
| 537 | snd_soc_unregister_component(&pdev->dev); | 605 | snd_soc_unregister_component(&pdev->dev); |
diff --git a/sound/soc/kirkwood/kirkwood-openrd.c b/sound/soc/kirkwood/kirkwood-openrd.c index 025be0e97164..65f2a5b9ec3b 100644 --- a/sound/soc/kirkwood/kirkwood-openrd.c +++ b/sound/soc/kirkwood/kirkwood-openrd.c | |||
| @@ -52,7 +52,7 @@ static struct snd_soc_dai_link openrd_client_dai[] = { | |||
| 52 | { | 52 | { |
| 53 | .name = "CS42L51", | 53 | .name = "CS42L51", |
| 54 | .stream_name = "CS42L51 HiFi", | 54 | .stream_name = "CS42L51 HiFi", |
| 55 | .cpu_dai_name = "mvebu-audio", | 55 | .cpu_dai_name = "i2s", |
| 56 | .platform_name = "mvebu-audio", | 56 | .platform_name = "mvebu-audio", |
| 57 | .codec_dai_name = "cs42l51-hifi", | 57 | .codec_dai_name = "cs42l51-hifi", |
| 58 | .codec_name = "cs42l51-codec.0-004a", | 58 | .codec_name = "cs42l51-codec.0-004a", |
diff --git a/sound/soc/kirkwood/kirkwood-t5325.c b/sound/soc/kirkwood/kirkwood-t5325.c index 27545b0c4856..d213832b0c72 100644 --- a/sound/soc/kirkwood/kirkwood-t5325.c +++ b/sound/soc/kirkwood/kirkwood-t5325.c | |||
| @@ -68,7 +68,7 @@ static struct snd_soc_dai_link t5325_dai[] = { | |||
| 68 | { | 68 | { |
| 69 | .name = "ALC5621", | 69 | .name = "ALC5621", |
| 70 | .stream_name = "ALC5621 HiFi", | 70 | .stream_name = "ALC5621 HiFi", |
| 71 | .cpu_dai_name = "mvebu-audio", | 71 | .cpu_dai_name = "i2s", |
| 72 | .platform_name = "mvebu-audio", | 72 | .platform_name = "mvebu-audio", |
| 73 | .codec_dai_name = "alc5621-hifi", | 73 | .codec_dai_name = "alc5621-hifi", |
| 74 | .codec_name = "alc562x-codec.0-001a", | 74 | .codec_name = "alc562x-codec.0-001a", |
diff --git a/sound/soc/kirkwood/kirkwood.h b/sound/soc/kirkwood/kirkwood.h index f8e1ccc1c58c..bf23afbba1d7 100644 --- a/sound/soc/kirkwood/kirkwood.h +++ b/sound/soc/kirkwood/kirkwood.h | |||
| @@ -123,8 +123,8 @@ | |||
| 123 | /* need to find where they come from */ | 123 | /* need to find where they come from */ |
| 124 | #define KIRKWOOD_SND_MIN_PERIODS 8 | 124 | #define KIRKWOOD_SND_MIN_PERIODS 8 |
| 125 | #define KIRKWOOD_SND_MAX_PERIODS 16 | 125 | #define KIRKWOOD_SND_MAX_PERIODS 16 |
| 126 | #define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x4000 | 126 | #define KIRKWOOD_SND_MIN_PERIOD_BYTES 0x800 |
| 127 | #define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x4000 | 127 | #define KIRKWOOD_SND_MAX_PERIOD_BYTES 0x8000 |
| 128 | #define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \ | 128 | #define KIRKWOOD_SND_MAX_BUFFER_BYTES (KIRKWOOD_SND_MAX_PERIOD_BYTES \ |
| 129 | * KIRKWOOD_SND_MAX_PERIODS) | 129 | * KIRKWOOD_SND_MAX_PERIODS) |
| 130 | 130 | ||
diff --git a/sound/soc/mid-x86/mfld_machine.c b/sound/soc/mid-x86/mfld_machine.c index ee363845759e..d3d4c32434f7 100644 --- a/sound/soc/mid-x86/mfld_machine.c +++ b/sound/soc/mid-x86/mfld_machine.c | |||
| @@ -400,7 +400,7 @@ static int snd_mfld_mc_probe(struct platform_device *pdev) | |||
| 400 | } | 400 | } |
| 401 | /* register the soc card */ | 401 | /* register the soc card */ |
| 402 | snd_soc_card_mfld.dev = &pdev->dev; | 402 | snd_soc_card_mfld.dev = &pdev->dev; |
| 403 | ret_val = snd_soc_register_card(&snd_soc_card_mfld); | 403 | ret_val = devm_snd_soc_register_card(&pdev->dev, &snd_soc_card_mfld); |
| 404 | if (ret_val) { | 404 | if (ret_val) { |
| 405 | pr_debug("snd_soc_register_card failed %d\n", ret_val); | 405 | pr_debug("snd_soc_register_card failed %d\n", ret_val); |
| 406 | return ret_val; | 406 | return ret_val; |
| @@ -410,20 +410,12 @@ static int snd_mfld_mc_probe(struct platform_device *pdev) | |||
| 410 | return 0; | 410 | return 0; |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | static int snd_mfld_mc_remove(struct platform_device *pdev) | ||
| 414 | { | ||
| 415 | pr_debug("snd_mfld_mc_remove called\n"); | ||
| 416 | snd_soc_unregister_card(&snd_soc_card_mfld); | ||
| 417 | return 0; | ||
| 418 | } | ||
| 419 | |||
| 420 | static struct platform_driver snd_mfld_mc_driver = { | 413 | static struct platform_driver snd_mfld_mc_driver = { |
| 421 | .driver = { | 414 | .driver = { |
| 422 | .owner = THIS_MODULE, | 415 | .owner = THIS_MODULE, |
| 423 | .name = "msic_audio", | 416 | .name = "msic_audio", |
| 424 | }, | 417 | }, |
| 425 | .probe = snd_mfld_mc_probe, | 418 | .probe = snd_mfld_mc_probe, |
| 426 | .remove = snd_mfld_mc_remove, | ||
| 427 | }; | 419 | }; |
| 428 | 420 | ||
| 429 | module_platform_driver(snd_mfld_mc_driver); | 421 | module_platform_driver(snd_mfld_mc_driver); |
diff --git a/sound/soc/mxs/mxs-saif.c b/sound/soc/mxs/mxs-saif.c index b56b8a0e8deb..54e622acac33 100644 --- a/sound/soc/mxs/mxs-saif.c +++ b/sound/soc/mxs/mxs-saif.c | |||
| @@ -494,6 +494,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 494 | struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); | 494 | struct mxs_saif *saif = snd_soc_dai_get_drvdata(cpu_dai); |
| 495 | struct mxs_saif *master_saif; | 495 | struct mxs_saif *master_saif; |
| 496 | u32 delay; | 496 | u32 delay; |
| 497 | int ret; | ||
| 497 | 498 | ||
| 498 | master_saif = mxs_saif_get_master(saif); | 499 | master_saif = mxs_saif_get_master(saif); |
| 499 | if (!master_saif) | 500 | if (!master_saif) |
| @@ -503,23 +504,37 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 503 | case SNDRV_PCM_TRIGGER_START: | 504 | case SNDRV_PCM_TRIGGER_START: |
| 504 | case SNDRV_PCM_TRIGGER_RESUME: | 505 | case SNDRV_PCM_TRIGGER_RESUME: |
| 505 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: | 506 | case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: |
| 507 | if (saif->state == MXS_SAIF_STATE_RUNNING) | ||
| 508 | return 0; | ||
| 509 | |||
| 506 | dev_dbg(cpu_dai->dev, "start\n"); | 510 | dev_dbg(cpu_dai->dev, "start\n"); |
| 507 | 511 | ||
| 508 | clk_enable(master_saif->clk); | 512 | ret = clk_enable(master_saif->clk); |
| 509 | if (!master_saif->mclk_in_use) | 513 | if (ret) { |
| 510 | __raw_writel(BM_SAIF_CTRL_RUN, | 514 | dev_err(saif->dev, "Failed to enable master clock\n"); |
| 511 | master_saif->base + SAIF_CTRL + MXS_SET_ADDR); | 515 | return ret; |
| 516 | } | ||
| 512 | 517 | ||
| 513 | /* | 518 | /* |
| 514 | * If the saif's master is not himself, we also need to enable | 519 | * If the saif's master is not himself, we also need to enable |
| 515 | * itself clk for its internal basic logic to work. | 520 | * itself clk for its internal basic logic to work. |
| 516 | */ | 521 | */ |
| 517 | if (saif != master_saif) { | 522 | if (saif != master_saif) { |
| 518 | clk_enable(saif->clk); | 523 | ret = clk_enable(saif->clk); |
| 524 | if (ret) { | ||
| 525 | dev_err(saif->dev, "Failed to enable master clock\n"); | ||
| 526 | clk_disable(master_saif->clk); | ||
| 527 | return ret; | ||
| 528 | } | ||
| 529 | |||
| 519 | __raw_writel(BM_SAIF_CTRL_RUN, | 530 | __raw_writel(BM_SAIF_CTRL_RUN, |
| 520 | saif->base + SAIF_CTRL + MXS_SET_ADDR); | 531 | saif->base + SAIF_CTRL + MXS_SET_ADDR); |
| 521 | } | 532 | } |
| 522 | 533 | ||
| 534 | if (!master_saif->mclk_in_use) | ||
| 535 | __raw_writel(BM_SAIF_CTRL_RUN, | ||
| 536 | master_saif->base + SAIF_CTRL + MXS_SET_ADDR); | ||
| 537 | |||
| 523 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 538 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 524 | /* | 539 | /* |
| 525 | * write data to saif data register to trigger | 540 | * write data to saif data register to trigger |
| @@ -543,6 +558,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 543 | } | 558 | } |
| 544 | 559 | ||
| 545 | master_saif->ongoing = 1; | 560 | master_saif->ongoing = 1; |
| 561 | saif->state = MXS_SAIF_STATE_RUNNING; | ||
| 546 | 562 | ||
| 547 | dev_dbg(saif->dev, "CTRL 0x%x STAT 0x%x\n", | 563 | dev_dbg(saif->dev, "CTRL 0x%x STAT 0x%x\n", |
| 548 | __raw_readl(saif->base + SAIF_CTRL), | 564 | __raw_readl(saif->base + SAIF_CTRL), |
| @@ -555,6 +571,9 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 555 | case SNDRV_PCM_TRIGGER_SUSPEND: | 571 | case SNDRV_PCM_TRIGGER_SUSPEND: |
| 556 | case SNDRV_PCM_TRIGGER_STOP: | 572 | case SNDRV_PCM_TRIGGER_STOP: |
| 557 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: | 573 | case SNDRV_PCM_TRIGGER_PAUSE_PUSH: |
| 574 | if (saif->state == MXS_SAIF_STATE_STOPPED) | ||
| 575 | return 0; | ||
| 576 | |||
| 558 | dev_dbg(cpu_dai->dev, "stop\n"); | 577 | dev_dbg(cpu_dai->dev, "stop\n"); |
| 559 | 578 | ||
| 560 | /* wait a while for the current sample to complete */ | 579 | /* wait a while for the current sample to complete */ |
| @@ -575,6 +594,7 @@ static int mxs_saif_trigger(struct snd_pcm_substream *substream, int cmd, | |||
| 575 | } | 594 | } |
| 576 | 595 | ||
| 577 | master_saif->ongoing = 0; | 596 | master_saif->ongoing = 0; |
| 597 | saif->state = MXS_SAIF_STATE_STOPPED; | ||
| 578 | 598 | ||
| 579 | break; | 599 | break; |
| 580 | default: | 600 | default: |
| @@ -768,8 +788,8 @@ static int mxs_saif_probe(struct platform_device *pdev) | |||
| 768 | dev_warn(&pdev->dev, "failed to init clocks\n"); | 788 | dev_warn(&pdev->dev, "failed to init clocks\n"); |
| 769 | } | 789 | } |
| 770 | 790 | ||
| 771 | ret = snd_soc_register_component(&pdev->dev, &mxs_saif_component, | 791 | ret = devm_snd_soc_register_component(&pdev->dev, &mxs_saif_component, |
| 772 | &mxs_saif_dai, 1); | 792 | &mxs_saif_dai, 1); |
| 773 | if (ret) { | 793 | if (ret) { |
| 774 | dev_err(&pdev->dev, "register DAI failed\n"); | 794 | dev_err(&pdev->dev, "register DAI failed\n"); |
| 775 | return ret; | 795 | return ret; |
| @@ -778,21 +798,15 @@ static int mxs_saif_probe(struct platform_device *pdev) | |||
| 778 | ret = mxs_pcm_platform_register(&pdev->dev); | 798 | ret = mxs_pcm_platform_register(&pdev->dev); |
| 779 | if (ret) { | 799 | if (ret) { |
| 780 | dev_err(&pdev->dev, "register PCM failed: %d\n", ret); | 800 | dev_err(&pdev->dev, "register PCM failed: %d\n", ret); |
| 781 | goto failed_pdev_alloc; | 801 | return ret; |
| 782 | } | 802 | } |
| 783 | 803 | ||
| 784 | return 0; | 804 | return 0; |
| 785 | |||
| 786 | failed_pdev_alloc: | ||
| 787 | snd_soc_unregister_component(&pdev->dev); | ||
| 788 | |||
| 789 | return ret; | ||
| 790 | } | 805 | } |
| 791 | 806 | ||
| 792 | static int mxs_saif_remove(struct platform_device *pdev) | 807 | static int mxs_saif_remove(struct platform_device *pdev) |
| 793 | { | 808 | { |
| 794 | mxs_pcm_platform_unregister(&pdev->dev); | 809 | mxs_pcm_platform_unregister(&pdev->dev); |
| 795 | snd_soc_unregister_component(&pdev->dev); | ||
| 796 | 810 | ||
| 797 | return 0; | 811 | return 0; |
| 798 | } | 812 | } |
diff --git a/sound/soc/mxs/mxs-saif.h b/sound/soc/mxs/mxs-saif.h index 53eaa4bf0e27..fbaf7badfdfb 100644 --- a/sound/soc/mxs/mxs-saif.h +++ b/sound/soc/mxs/mxs-saif.h | |||
| @@ -124,6 +124,11 @@ struct mxs_saif { | |||
| 124 | 124 | ||
| 125 | u32 fifo_underrun; | 125 | u32 fifo_underrun; |
| 126 | u32 fifo_overrun; | 126 | u32 fifo_overrun; |
| 127 | |||
| 128 | enum { | ||
| 129 | MXS_SAIF_STATE_STOPPED, | ||
| 130 | MXS_SAIF_STATE_RUNNING, | ||
| 131 | } state; | ||
| 127 | }; | 132 | }; |
| 128 | 133 | ||
| 129 | extern int mxs_saif_put_mclk(unsigned int saif_id); | 134 | extern int mxs_saif_put_mclk(unsigned int saif_id); |
diff --git a/sound/soc/mxs/mxs-sgtl5000.c b/sound/soc/mxs/mxs-sgtl5000.c index 4bb273786ff3..61822cc53bd3 100644 --- a/sound/soc/mxs/mxs-sgtl5000.c +++ b/sound/soc/mxs/mxs-sgtl5000.c | |||
| @@ -122,14 +122,12 @@ static struct snd_soc_card mxs_sgtl5000 = { | |||
| 122 | .num_links = ARRAY_SIZE(mxs_sgtl5000_dai), | 122 | .num_links = ARRAY_SIZE(mxs_sgtl5000_dai), |
| 123 | }; | 123 | }; |
| 124 | 124 | ||
| 125 | static int mxs_sgtl5000_probe_dt(struct platform_device *pdev) | 125 | static int mxs_sgtl5000_probe(struct platform_device *pdev) |
| 126 | { | 126 | { |
| 127 | struct snd_soc_card *card = &mxs_sgtl5000; | ||
| 128 | int ret, i; | ||
| 127 | struct device_node *np = pdev->dev.of_node; | 129 | struct device_node *np = pdev->dev.of_node; |
| 128 | struct device_node *saif_np[2], *codec_np; | 130 | struct device_node *saif_np[2], *codec_np; |
| 129 | int i; | ||
| 130 | |||
| 131 | if (!np) | ||
| 132 | return 1; /* no device tree */ | ||
| 133 | 131 | ||
| 134 | saif_np[0] = of_parse_phandle(np, "saif-controllers", 0); | 132 | saif_np[0] = of_parse_phandle(np, "saif-controllers", 0); |
| 135 | saif_np[1] = of_parse_phandle(np, "saif-controllers", 1); | 133 | saif_np[1] = of_parse_phandle(np, "saif-controllers", 1); |
| @@ -152,18 +150,6 @@ static int mxs_sgtl5000_probe_dt(struct platform_device *pdev) | |||
| 152 | of_node_put(saif_np[0]); | 150 | of_node_put(saif_np[0]); |
| 153 | of_node_put(saif_np[1]); | 151 | of_node_put(saif_np[1]); |
| 154 | 152 | ||
| 155 | return 0; | ||
| 156 | } | ||
| 157 | |||
| 158 | static int mxs_sgtl5000_probe(struct platform_device *pdev) | ||
| 159 | { | ||
| 160 | struct snd_soc_card *card = &mxs_sgtl5000; | ||
| 161 | int ret; | ||
| 162 | |||
| 163 | ret = mxs_sgtl5000_probe_dt(pdev); | ||
| 164 | if (ret < 0) | ||
| 165 | return ret; | ||
| 166 | |||
| 167 | /* | 153 | /* |
| 168 | * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w). | 154 | * Set an init clock(11.28Mhz) for sgtl5000 initialization(i2c r/w). |
| 169 | * The Sgtl5000 sysclk is derived from saif0 mclk and it's range | 155 | * The Sgtl5000 sysclk is derived from saif0 mclk and it's range |
diff --git a/sound/soc/omap/Kconfig b/sound/soc/omap/Kconfig index daa78a0095fa..4a07f7179690 100644 --- a/sound/soc/omap/Kconfig +++ b/sound/soc/omap/Kconfig | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | config SND_OMAP_SOC | 1 | config SND_OMAP_SOC |
| 2 | tristate "SoC Audio for the Texas Instruments OMAP chips" | 2 | tristate "SoC Audio for the Texas Instruments OMAP chips" |
| 3 | depends on (ARCH_OMAP && DMA_OMAP) || (ARCH_ARM && COMPILE_TEST) | 3 | depends on (ARCH_OMAP && DMA_OMAP) || (ARM && COMPILE_TEST) |
| 4 | select SND_DMAENGINE_PCM | 4 | select SND_DMAENGINE_PCM |
| 5 | 5 | ||
| 6 | config SND_OMAP_SOC_DMIC | 6 | config SND_OMAP_SOC_DMIC |
| @@ -26,7 +26,7 @@ config SND_OMAP_SOC_N810 | |||
| 26 | 26 | ||
| 27 | config SND_OMAP_SOC_RX51 | 27 | config SND_OMAP_SOC_RX51 |
| 28 | tristate "SoC Audio support for Nokia RX-51" | 28 | tristate "SoC Audio support for Nokia RX-51" |
| 29 | depends on SND_OMAP_SOC && ARCH_ARM && (MACH_NOKIA_RX51 || COMPILE_TEST) | 29 | depends on SND_OMAP_SOC && ARM && (MACH_NOKIA_RX51 || COMPILE_TEST) |
| 30 | select SND_OMAP_SOC_MCBSP | 30 | select SND_OMAP_SOC_MCBSP |
| 31 | select SND_SOC_TLV320AIC3X | 31 | select SND_SOC_TLV320AIC3X |
| 32 | select SND_SOC_TPA6130A2 | 32 | select SND_SOC_TPA6130A2 |
diff --git a/sound/soc/omap/omap-mcpdm.c b/sound/soc/omap/omap-mcpdm.c index 90d2a7cd2563..cd9ee167959d 100644 --- a/sound/soc/omap/omap-mcpdm.c +++ b/sound/soc/omap/omap-mcpdm.c | |||
| @@ -490,14 +490,9 @@ static int asoc_mcpdm_probe(struct platform_device *pdev) | |||
| 490 | 490 | ||
| 491 | mcpdm->dev = &pdev->dev; | 491 | mcpdm->dev = &pdev->dev; |
| 492 | 492 | ||
| 493 | return snd_soc_register_component(&pdev->dev, &omap_mcpdm_component, | 493 | return devm_snd_soc_register_component(&pdev->dev, |
| 494 | &omap_mcpdm_dai, 1); | 494 | &omap_mcpdm_component, |
| 495 | } | 495 | &omap_mcpdm_dai, 1); |
| 496 | |||
| 497 | static int asoc_mcpdm_remove(struct platform_device *pdev) | ||
| 498 | { | ||
| 499 | snd_soc_unregister_component(&pdev->dev); | ||
| 500 | return 0; | ||
| 501 | } | 496 | } |
| 502 | 497 | ||
| 503 | static const struct of_device_id omap_mcpdm_of_match[] = { | 498 | static const struct of_device_id omap_mcpdm_of_match[] = { |
| @@ -514,7 +509,6 @@ static struct platform_driver asoc_mcpdm_driver = { | |||
| 514 | }, | 509 | }, |
| 515 | 510 | ||
| 516 | .probe = asoc_mcpdm_probe, | 511 | .probe = asoc_mcpdm_probe, |
| 517 | .remove = asoc_mcpdm_remove, | ||
| 518 | }; | 512 | }; |
| 519 | 513 | ||
| 520 | module_platform_driver(asoc_mcpdm_driver); | 514 | module_platform_driver(asoc_mcpdm_driver); |
diff --git a/sound/soc/omap/omap-twl4030.c b/sound/soc/omap/omap-twl4030.c index 2a9324f794d8..6a8d6b5f160d 100644 --- a/sound/soc/omap/omap-twl4030.c +++ b/sound/soc/omap/omap-twl4030.c | |||
| @@ -338,9 +338,9 @@ static int omap_twl4030_probe(struct platform_device *pdev) | |||
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | snd_soc_card_set_drvdata(card, priv); | 340 | snd_soc_card_set_drvdata(card, priv); |
| 341 | ret = snd_soc_register_card(card); | 341 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 342 | if (ret) { | 342 | if (ret) { |
| 343 | dev_err(&pdev->dev, "snd_soc_register_card() failed: %d\n", | 343 | dev_err(&pdev->dev, "devm_snd_soc_register_card() failed: %d\n", |
| 344 | ret); | 344 | ret); |
| 345 | return ret; | 345 | return ret; |
| 346 | } | 346 | } |
| @@ -357,7 +357,6 @@ static int omap_twl4030_remove(struct platform_device *pdev) | |||
| 357 | snd_soc_jack_free_gpios(&priv->hs_jack, | 357 | snd_soc_jack_free_gpios(&priv->hs_jack, |
| 358 | ARRAY_SIZE(hs_jack_gpios), | 358 | ARRAY_SIZE(hs_jack_gpios), |
| 359 | hs_jack_gpios); | 359 | hs_jack_gpios); |
| 360 | snd_soc_unregister_card(card); | ||
| 361 | 360 | ||
| 362 | return 0; | 361 | return 0; |
| 363 | } | 362 | } |
diff --git a/sound/soc/pxa/brownstone.c b/sound/soc/pxa/brownstone.c index 5b7d969f89a9..08acdc236bf8 100644 --- a/sound/soc/pxa/brownstone.c +++ b/sound/soc/pxa/brownstone.c | |||
| @@ -163,6 +163,7 @@ static struct platform_driver mmp_driver = { | |||
| 163 | .driver = { | 163 | .driver = { |
| 164 | .name = "brownstone-audio", | 164 | .name = "brownstone-audio", |
| 165 | .owner = THIS_MODULE, | 165 | .owner = THIS_MODULE, |
| 166 | .pm = &snd_soc_pm_ops, | ||
| 166 | }, | 167 | }, |
| 167 | .probe = brownstone_probe, | 168 | .probe = brownstone_probe, |
| 168 | .remove = brownstone_remove, | 169 | .remove = brownstone_remove, |
diff --git a/sound/soc/pxa/corgi.c b/sound/soc/pxa/corgi.c index f4cce1e80112..1853d41034bf 100644 --- a/sound/soc/pxa/corgi.c +++ b/sound/soc/pxa/corgi.c | |||
| @@ -329,6 +329,7 @@ static struct platform_driver corgi_driver = { | |||
| 329 | .driver = { | 329 | .driver = { |
| 330 | .name = "corgi-audio", | 330 | .name = "corgi-audio", |
| 331 | .owner = THIS_MODULE, | 331 | .owner = THIS_MODULE, |
| 332 | .pm = &snd_soc_pm_ops, | ||
| 332 | }, | 333 | }, |
| 333 | .probe = corgi_probe, | 334 | .probe = corgi_probe, |
| 334 | .remove = corgi_remove, | 335 | .remove = corgi_remove, |
diff --git a/sound/soc/pxa/e740_wm9705.c b/sound/soc/pxa/e740_wm9705.c index 70d799b13f0d..44b5c09d296b 100644 --- a/sound/soc/pxa/e740_wm9705.c +++ b/sound/soc/pxa/e740_wm9705.c | |||
| @@ -178,6 +178,7 @@ static struct platform_driver e740_driver = { | |||
| 178 | .driver = { | 178 | .driver = { |
| 179 | .name = "e740-audio", | 179 | .name = "e740-audio", |
| 180 | .owner = THIS_MODULE, | 180 | .owner = THIS_MODULE, |
| 181 | .pm = &snd_soc_pm_ops, | ||
| 181 | }, | 182 | }, |
| 182 | .probe = e740_probe, | 183 | .probe = e740_probe, |
| 183 | .remove = e740_remove, | 184 | .remove = e740_remove, |
diff --git a/sound/soc/pxa/e750_wm9705.c b/sound/soc/pxa/e750_wm9705.c index f94d2ab51351..c34e447eb991 100644 --- a/sound/soc/pxa/e750_wm9705.c +++ b/sound/soc/pxa/e750_wm9705.c | |||
| @@ -160,6 +160,7 @@ static struct platform_driver e750_driver = { | |||
| 160 | .driver = { | 160 | .driver = { |
| 161 | .name = "e750-audio", | 161 | .name = "e750-audio", |
| 162 | .owner = THIS_MODULE, | 162 | .owner = THIS_MODULE, |
| 163 | .pm = &snd_soc_pm_ops, | ||
| 163 | }, | 164 | }, |
| 164 | .probe = e750_probe, | 165 | .probe = e750_probe, |
| 165 | .remove = e750_remove, | 166 | .remove = e750_remove, |
diff --git a/sound/soc/pxa/e800_wm9712.c b/sound/soc/pxa/e800_wm9712.c index 8768a640dd71..3137f800b43f 100644 --- a/sound/soc/pxa/e800_wm9712.c +++ b/sound/soc/pxa/e800_wm9712.c | |||
| @@ -150,6 +150,7 @@ static struct platform_driver e800_driver = { | |||
| 150 | .driver = { | 150 | .driver = { |
| 151 | .name = "e800-audio", | 151 | .name = "e800-audio", |
| 152 | .owner = THIS_MODULE, | 152 | .owner = THIS_MODULE, |
| 153 | .pm = &snd_soc_pm_ops, | ||
| 153 | }, | 154 | }, |
| 154 | .probe = e800_probe, | 155 | .probe = e800_probe, |
| 155 | .remove = e800_remove, | 156 | .remove = e800_remove, |
diff --git a/sound/soc/pxa/imote2.c b/sound/soc/pxa/imote2.c index eef1f7b7b38e..fd2f4eda1fd3 100644 --- a/sound/soc/pxa/imote2.c +++ b/sound/soc/pxa/imote2.c | |||
| @@ -91,6 +91,7 @@ static struct platform_driver imote2_driver = { | |||
| 91 | .driver = { | 91 | .driver = { |
| 92 | .name = "imote2-audio", | 92 | .name = "imote2-audio", |
| 93 | .owner = THIS_MODULE, | 93 | .owner = THIS_MODULE, |
| 94 | .pm = &snd_soc_pm_ops, | ||
| 94 | }, | 95 | }, |
| 95 | .probe = imote2_probe, | 96 | .probe = imote2_probe, |
| 96 | .remove = imote2_remove, | 97 | .remove = imote2_remove, |
diff --git a/sound/soc/pxa/mioa701_wm9713.c b/sound/soc/pxa/mioa701_wm9713.c index bbea7780eac6..160c5245448f 100644 --- a/sound/soc/pxa/mioa701_wm9713.c +++ b/sound/soc/pxa/mioa701_wm9713.c | |||
| @@ -215,6 +215,7 @@ static struct platform_driver mioa701_wm9713_driver = { | |||
| 215 | .driver = { | 215 | .driver = { |
| 216 | .name = "mioa701-wm9713", | 216 | .name = "mioa701-wm9713", |
| 217 | .owner = THIS_MODULE, | 217 | .owner = THIS_MODULE, |
| 218 | .pm = &snd_soc_pm_ops, | ||
| 218 | }, | 219 | }, |
| 219 | }; | 220 | }; |
| 220 | 221 | ||
diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 41752a5fe3b0..5bf5f1f7cac5 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c | |||
| @@ -455,8 +455,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) | |||
| 455 | priv->dai_fmt = (unsigned int) -1; | 455 | priv->dai_fmt = (unsigned int) -1; |
| 456 | platform_set_drvdata(pdev, priv); | 456 | platform_set_drvdata(pdev, priv); |
| 457 | 457 | ||
| 458 | return snd_soc_register_component(&pdev->dev, &mmp_sspa_component, | 458 | return devm_snd_soc_register_component(&pdev->dev, &mmp_sspa_component, |
| 459 | &mmp_sspa_dai, 1); | 459 | &mmp_sspa_dai, 1); |
| 460 | } | 460 | } |
| 461 | 461 | ||
| 462 | static int asoc_mmp_sspa_remove(struct platform_device *pdev) | 462 | static int asoc_mmp_sspa_remove(struct platform_device *pdev) |
| @@ -466,7 +466,6 @@ static int asoc_mmp_sspa_remove(struct platform_device *pdev) | |||
| 466 | clk_disable(priv->audio_clk); | 466 | clk_disable(priv->audio_clk); |
| 467 | clk_put(priv->audio_clk); | 467 | clk_put(priv->audio_clk); |
| 468 | clk_put(priv->sysclk); | 468 | clk_put(priv->sysclk); |
| 469 | snd_soc_unregister_component(&pdev->dev); | ||
| 470 | return 0; | 469 | return 0; |
| 471 | } | 470 | } |
| 472 | 471 | ||
diff --git a/sound/soc/pxa/palm27x.c b/sound/soc/pxa/palm27x.c index e1ffcdd9a649..3284c4b901cb 100644 --- a/sound/soc/pxa/palm27x.c +++ b/sound/soc/pxa/palm27x.c | |||
| @@ -181,6 +181,7 @@ static struct platform_driver palm27x_wm9712_driver = { | |||
| 181 | .driver = { | 181 | .driver = { |
| 182 | .name = "palm27x-asoc", | 182 | .name = "palm27x-asoc", |
| 183 | .owner = THIS_MODULE, | 183 | .owner = THIS_MODULE, |
| 184 | .pm = &snd_soc_pm_ops, | ||
| 184 | }, | 185 | }, |
| 185 | }; | 186 | }; |
| 186 | 187 | ||
diff --git a/sound/soc/pxa/poodle.c b/sound/soc/pxa/poodle.c index fafe46355c31..c93e138d8dc3 100644 --- a/sound/soc/pxa/poodle.c +++ b/sound/soc/pxa/poodle.c | |||
| @@ -303,6 +303,7 @@ static struct platform_driver poodle_driver = { | |||
| 303 | .driver = { | 303 | .driver = { |
| 304 | .name = "poodle-audio", | 304 | .name = "poodle-audio", |
| 305 | .owner = THIS_MODULE, | 305 | .owner = THIS_MODULE, |
| 306 | .pm = &snd_soc_pm_ops, | ||
| 306 | }, | 307 | }, |
| 307 | .probe = poodle_probe, | 308 | .probe = poodle_probe, |
| 308 | .remove = poodle_remove, | 309 | .remove = poodle_remove, |
diff --git a/sound/soc/pxa/pxa2xx-ac97.c b/sound/soc/pxa/pxa2xx-ac97.c index f1059d999de6..ae956e3f4b9d 100644 --- a/sound/soc/pxa/pxa2xx-ac97.c +++ b/sound/soc/pxa/pxa2xx-ac97.c | |||
| @@ -89,33 +89,6 @@ static struct snd_dmaengine_dai_dma_data pxa2xx_ac97_pcm_mic_mono_in = { | |||
| 89 | .filter_data = &pxa2xx_ac97_pcm_aux_mic_mono_req, | 89 | .filter_data = &pxa2xx_ac97_pcm_aux_mic_mono_req, |
| 90 | }; | 90 | }; |
| 91 | 91 | ||
| 92 | #ifdef CONFIG_PM | ||
| 93 | static int pxa2xx_ac97_suspend(struct snd_soc_dai *dai) | ||
| 94 | { | ||
| 95 | return pxa2xx_ac97_hw_suspend(); | ||
| 96 | } | ||
| 97 | |||
| 98 | static int pxa2xx_ac97_resume(struct snd_soc_dai *dai) | ||
| 99 | { | ||
| 100 | return pxa2xx_ac97_hw_resume(); | ||
| 101 | } | ||
| 102 | |||
| 103 | #else | ||
| 104 | #define pxa2xx_ac97_suspend NULL | ||
| 105 | #define pxa2xx_ac97_resume NULL | ||
| 106 | #endif | ||
| 107 | |||
| 108 | static int pxa2xx_ac97_probe(struct snd_soc_dai *dai) | ||
| 109 | { | ||
| 110 | return pxa2xx_ac97_hw_probe(to_platform_device(dai->dev)); | ||
| 111 | } | ||
| 112 | |||
| 113 | static int pxa2xx_ac97_remove(struct snd_soc_dai *dai) | ||
| 114 | { | ||
| 115 | pxa2xx_ac97_hw_remove(to_platform_device(dai->dev)); | ||
| 116 | return 0; | ||
| 117 | } | ||
| 118 | |||
| 119 | static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, | 92 | static int pxa2xx_ac97_hw_params(struct snd_pcm_substream *substream, |
| 120 | struct snd_pcm_hw_params *params, | 93 | struct snd_pcm_hw_params *params, |
| 121 | struct snd_soc_dai *cpu_dai) | 94 | struct snd_soc_dai *cpu_dai) |
| @@ -185,10 +158,6 @@ static struct snd_soc_dai_driver pxa_ac97_dai_driver[] = { | |||
| 185 | { | 158 | { |
| 186 | .name = "pxa2xx-ac97", | 159 | .name = "pxa2xx-ac97", |
| 187 | .ac97_control = 1, | 160 | .ac97_control = 1, |
| 188 | .probe = pxa2xx_ac97_probe, | ||
| 189 | .remove = pxa2xx_ac97_remove, | ||
| 190 | .suspend = pxa2xx_ac97_suspend, | ||
| 191 | .resume = pxa2xx_ac97_resume, | ||
| 192 | .playback = { | 161 | .playback = { |
| 193 | .stream_name = "AC97 Playback", | 162 | .stream_name = "AC97 Playback", |
| 194 | .channels_min = 2, | 163 | .channels_min = 2, |
| @@ -246,6 +215,12 @@ static int pxa2xx_ac97_dev_probe(struct platform_device *pdev) | |||
| 246 | return -ENXIO; | 215 | return -ENXIO; |
| 247 | } | 216 | } |
| 248 | 217 | ||
| 218 | ret = pxa2xx_ac97_hw_probe(pdev); | ||
| 219 | if (ret) { | ||
| 220 | dev_err(&pdev->dev, "PXA2xx AC97 hw probe error (%d)\n", ret); | ||
| 221 | return ret; | ||
| 222 | } | ||
| 223 | |||
| 249 | ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops); | 224 | ret = snd_soc_set_ac97_ops(&pxa2xx_ac97_ops); |
| 250 | if (ret != 0) | 225 | if (ret != 0) |
| 251 | return ret; | 226 | return ret; |
| @@ -262,15 +237,34 @@ static int pxa2xx_ac97_dev_remove(struct platform_device *pdev) | |||
| 262 | { | 237 | { |
| 263 | snd_soc_unregister_component(&pdev->dev); | 238 | snd_soc_unregister_component(&pdev->dev); |
| 264 | snd_soc_set_ac97_ops(NULL); | 239 | snd_soc_set_ac97_ops(NULL); |
| 240 | pxa2xx_ac97_hw_remove(pdev); | ||
| 265 | return 0; | 241 | return 0; |
| 266 | } | 242 | } |
| 267 | 243 | ||
| 244 | #ifdef CONFIG_PM_SLEEP | ||
| 245 | static int pxa2xx_ac97_dev_suspend(struct device *dev) | ||
| 246 | { | ||
| 247 | return pxa2xx_ac97_hw_suspend(); | ||
| 248 | } | ||
| 249 | |||
| 250 | static int pxa2xx_ac97_dev_resume(struct device *dev) | ||
| 251 | { | ||
| 252 | return pxa2xx_ac97_hw_resume(); | ||
| 253 | } | ||
| 254 | |||
| 255 | static SIMPLE_DEV_PM_OPS(pxa2xx_ac97_pm_ops, | ||
| 256 | pxa2xx_ac97_dev_suspend, pxa2xx_ac97_dev_resume); | ||
| 257 | #endif | ||
| 258 | |||
| 268 | static struct platform_driver pxa2xx_ac97_driver = { | 259 | static struct platform_driver pxa2xx_ac97_driver = { |
| 269 | .probe = pxa2xx_ac97_dev_probe, | 260 | .probe = pxa2xx_ac97_dev_probe, |
| 270 | .remove = pxa2xx_ac97_dev_remove, | 261 | .remove = pxa2xx_ac97_dev_remove, |
| 271 | .driver = { | 262 | .driver = { |
| 272 | .name = "pxa2xx-ac97", | 263 | .name = "pxa2xx-ac97", |
| 273 | .owner = THIS_MODULE, | 264 | .owner = THIS_MODULE, |
| 265 | #ifdef CONFIG_PM_SLEEP | ||
| 266 | .pm = &pxa2xx_ac97_pm_ops, | ||
| 267 | #endif | ||
| 274 | }, | 268 | }, |
| 275 | }; | 269 | }; |
| 276 | 270 | ||
diff --git a/sound/soc/pxa/tosa.c b/sound/soc/pxa/tosa.c index a3fe19123f07..1d9c2ed223bc 100644 --- a/sound/soc/pxa/tosa.c +++ b/sound/soc/pxa/tosa.c | |||
| @@ -275,6 +275,7 @@ static struct platform_driver tosa_driver = { | |||
| 275 | .driver = { | 275 | .driver = { |
| 276 | .name = "tosa-audio", | 276 | .name = "tosa-audio", |
| 277 | .owner = THIS_MODULE, | 277 | .owner = THIS_MODULE, |
| 278 | .pm = &snd_soc_pm_ops, | ||
| 278 | }, | 279 | }, |
| 279 | .probe = tosa_probe, | 280 | .probe = tosa_probe, |
| 280 | .remove = tosa_remove, | 281 | .remove = tosa_remove, |
diff --git a/sound/soc/pxa/ttc-dkb.c b/sound/soc/pxa/ttc-dkb.c index 13c9ee0cb83b..0b535b570622 100644 --- a/sound/soc/pxa/ttc-dkb.c +++ b/sound/soc/pxa/ttc-dkb.c | |||
| @@ -160,6 +160,7 @@ static struct platform_driver ttc_dkb_driver = { | |||
| 160 | .driver = { | 160 | .driver = { |
| 161 | .name = "ttc-dkb-audio", | 161 | .name = "ttc-dkb-audio", |
| 162 | .owner = THIS_MODULE, | 162 | .owner = THIS_MODULE, |
| 163 | .pm = &snd_soc_pm_ops, | ||
| 163 | }, | 164 | }, |
| 164 | .probe = ttc_dkb_probe, | 165 | .probe = ttc_dkb_probe, |
| 165 | .remove = ttc_dkb_remove, | 166 | .remove = ttc_dkb_remove, |
diff --git a/sound/soc/samsung/bells.c b/sound/soc/samsung/bells.c index 29e246803626..84f5d8b76679 100644 --- a/sound/soc/samsung/bells.c +++ b/sound/soc/samsung/bells.c | |||
| @@ -356,6 +356,7 @@ static struct snd_soc_dapm_widget bells_widgets[] = { | |||
| 356 | 356 | ||
| 357 | static struct snd_soc_dapm_route bells_routes[] = { | 357 | static struct snd_soc_dapm_route bells_routes[] = { |
| 358 | { "Sub CLK_SYS", NULL, "OPCLK" }, | 358 | { "Sub CLK_SYS", NULL, "OPCLK" }, |
| 359 | { "CLKIN", NULL, "OPCLK" }, | ||
| 359 | 360 | ||
| 360 | { "DMIC", NULL, "MICBIAS2" }, | 361 | { "DMIC", NULL, "MICBIAS2" }, |
| 361 | { "IN2L", NULL, "DMIC" }, | 362 | { "IN2L", NULL, "DMIC" }, |
diff --git a/sound/soc/samsung/i2s.c b/sound/soc/samsung/i2s.c index b302f3b7a587..2c4d2505a19e 100644 --- a/sound/soc/samsung/i2s.c +++ b/sound/soc/samsung/i2s.c | |||
| @@ -702,13 +702,6 @@ static int i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 702 | } | 702 | } |
| 703 | writel(mod, i2s->addr + I2SMOD); | 703 | writel(mod, i2s->addr + I2SMOD); |
| 704 | 704 | ||
| 705 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) | ||
| 706 | snd_soc_dai_set_dma_data(dai, substream, | ||
| 707 | (void *)&i2s->dma_playback); | ||
| 708 | else | ||
| 709 | snd_soc_dai_set_dma_data(dai, substream, | ||
| 710 | (void *)&i2s->dma_capture); | ||
| 711 | |||
| 712 | i2s->frmclk = params_rate(params); | 705 | i2s->frmclk = params_rate(params); |
| 713 | 706 | ||
| 714 | return 0; | 707 | return 0; |
| @@ -970,6 +963,8 @@ static int samsung_i2s_dai_probe(struct snd_soc_dai *dai) | |||
| 970 | } | 963 | } |
| 971 | clk_prepare_enable(i2s->clk); | 964 | clk_prepare_enable(i2s->clk); |
| 972 | 965 | ||
| 966 | snd_soc_dai_init_dma_data(dai, &i2s->dma_playback, &i2s->dma_capture); | ||
| 967 | |||
| 973 | if (other) { | 968 | if (other) { |
| 974 | other->addr = i2s->addr; | 969 | other->addr = i2s->addr; |
| 975 | other->clk = i2s->clk; | 970 | other->clk = i2s->clk; |
| @@ -1060,7 +1055,7 @@ static struct i2s_dai *i2s_alloc_dai(struct platform_device *pdev, bool sec) | |||
| 1060 | i2s->i2s_dai_drv.ops = &samsung_i2s_dai_ops; | 1055 | i2s->i2s_dai_drv.ops = &samsung_i2s_dai_ops; |
| 1061 | i2s->i2s_dai_drv.suspend = i2s_suspend; | 1056 | i2s->i2s_dai_drv.suspend = i2s_suspend; |
| 1062 | i2s->i2s_dai_drv.resume = i2s_resume; | 1057 | i2s->i2s_dai_drv.resume = i2s_resume; |
| 1063 | i2s->i2s_dai_drv.playback.channels_min = 2; | 1058 | i2s->i2s_dai_drv.playback.channels_min = 1; |
| 1064 | i2s->i2s_dai_drv.playback.channels_max = 2; | 1059 | i2s->i2s_dai_drv.playback.channels_max = 2; |
| 1065 | i2s->i2s_dai_drv.playback.rates = SAMSUNG_I2S_RATES; | 1060 | i2s->i2s_dai_drv.playback.rates = SAMSUNG_I2S_RATES; |
| 1066 | i2s->i2s_dai_drv.playback.formats = SAMSUNG_I2S_FMTS; | 1061 | i2s->i2s_dai_drv.playback.formats = SAMSUNG_I2S_FMTS; |
| @@ -1143,9 +1138,9 @@ static int samsung_i2s_probe(struct platform_device *pdev) | |||
| 1143 | dev_err(&pdev->dev, "Unable to get drvdata\n"); | 1138 | dev_err(&pdev->dev, "Unable to get drvdata\n"); |
| 1144 | return -EFAULT; | 1139 | return -EFAULT; |
| 1145 | } | 1140 | } |
| 1146 | snd_soc_register_component(&sec_dai->pdev->dev, | 1141 | devm_snd_soc_register_component(&sec_dai->pdev->dev, |
| 1147 | &samsung_i2s_component, | 1142 | &samsung_i2s_component, |
| 1148 | &sec_dai->i2s_dai_drv, 1); | 1143 | &sec_dai->i2s_dai_drv, 1); |
| 1149 | samsung_asoc_dma_platform_register(&pdev->dev); | 1144 | samsung_asoc_dma_platform_register(&pdev->dev); |
| 1150 | return 0; | 1145 | return 0; |
| 1151 | } | 1146 | } |
| @@ -1258,8 +1253,9 @@ static int samsung_i2s_probe(struct platform_device *pdev) | |||
| 1258 | goto err; | 1253 | goto err; |
| 1259 | } | 1254 | } |
| 1260 | 1255 | ||
| 1261 | snd_soc_register_component(&pri_dai->pdev->dev, &samsung_i2s_component, | 1256 | devm_snd_soc_register_component(&pri_dai->pdev->dev, |
| 1262 | &pri_dai->i2s_dai_drv, 1); | 1257 | &samsung_i2s_component, |
| 1258 | &pri_dai->i2s_dai_drv, 1); | ||
| 1263 | 1259 | ||
| 1264 | pm_runtime_enable(&pdev->dev); | 1260 | pm_runtime_enable(&pdev->dev); |
| 1265 | 1261 | ||
| @@ -1294,7 +1290,6 @@ static int samsung_i2s_remove(struct platform_device *pdev) | |||
| 1294 | i2s->sec_dai = NULL; | 1290 | i2s->sec_dai = NULL; |
| 1295 | 1291 | ||
| 1296 | samsung_asoc_dma_platform_unregister(&pdev->dev); | 1292 | samsung_asoc_dma_platform_unregister(&pdev->dev); |
| 1297 | snd_soc_unregister_component(&pdev->dev); | ||
| 1298 | 1293 | ||
| 1299 | return 0; | 1294 | return 0; |
| 1300 | } | 1295 | } |
diff --git a/sound/soc/samsung/smdk_wm8994.c b/sound/soc/samsung/smdk_wm8994.c index 5fd7a05a9b9e..b072bd107b31 100644 --- a/sound/soc/samsung/smdk_wm8994.c +++ b/sound/soc/samsung/smdk_wm8994.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | 9 | ||
| 10 | #include "../codecs/wm8994.h" | 10 | #include "../codecs/wm8994.h" |
| 11 | #include <sound/pcm_params.h> | 11 | #include <sound/pcm_params.h> |
| 12 | #include <sound/soc.h> | ||
| 12 | #include <linux/module.h> | 13 | #include <linux/module.h> |
| 13 | #include <linux/of.h> | 14 | #include <linux/of.h> |
| 14 | #include <linux/of_device.h> | 15 | #include <linux/of_device.h> |
| @@ -193,7 +194,7 @@ static int smdk_audio_probe(struct platform_device *pdev) | |||
| 193 | 194 | ||
| 194 | platform_set_drvdata(pdev, board); | 195 | platform_set_drvdata(pdev, board); |
| 195 | 196 | ||
| 196 | ret = snd_soc_register_card(card); | 197 | ret = devm_snd_soc_register_card(&pdev->dev, card); |
| 197 | 198 | ||
| 198 | if (ret) | 199 | if (ret) |
| 199 | dev_err(&pdev->dev, "snd_soc_register_card() failed:%d\n", ret); | 200 | dev_err(&pdev->dev, "snd_soc_register_card() failed:%d\n", ret); |
| @@ -201,23 +202,14 @@ static int smdk_audio_probe(struct platform_device *pdev) | |||
| 201 | return ret; | 202 | return ret; |
| 202 | } | 203 | } |
| 203 | 204 | ||
| 204 | static int smdk_audio_remove(struct platform_device *pdev) | ||
| 205 | { | ||
| 206 | struct snd_soc_card *card = platform_get_drvdata(pdev); | ||
| 207 | |||
| 208 | snd_soc_unregister_card(card); | ||
| 209 | |||
| 210 | return 0; | ||
| 211 | } | ||
| 212 | |||
| 213 | static struct platform_driver smdk_audio_driver = { | 205 | static struct platform_driver smdk_audio_driver = { |
| 214 | .driver = { | 206 | .driver = { |
| 215 | .name = "smdk-audio-wm8894", | 207 | .name = "smdk-audio-wm8894", |
| 216 | .owner = THIS_MODULE, | 208 | .owner = THIS_MODULE, |
| 217 | .of_match_table = of_match_ptr(samsung_wm8994_of_match), | 209 | .of_match_table = of_match_ptr(samsung_wm8994_of_match), |
| 210 | .pm = &snd_soc_pm_ops, | ||
| 218 | }, | 211 | }, |
| 219 | .probe = smdk_audio_probe, | 212 | .probe = smdk_audio_probe, |
| 220 | .remove = smdk_audio_remove, | ||
| 221 | }; | 213 | }; |
| 222 | 214 | ||
| 223 | module_platform_driver(smdk_audio_driver); | 215 | module_platform_driver(smdk_audio_driver); |
diff --git a/sound/soc/sh/rcar/adg.c b/sound/soc/sh/rcar/adg.c index d80deb7ccf13..9430097979a5 100644 --- a/sound/soc/sh/rcar/adg.c +++ b/sound/soc/sh/rcar/adg.c | |||
| @@ -8,7 +8,6 @@ | |||
| 8 | * for more details. | 8 | * for more details. |
| 9 | */ | 9 | */ |
| 10 | #include <linux/sh_clk.h> | 10 | #include <linux/sh_clk.h> |
| 11 | #include <mach/clock.h> | ||
| 12 | #include "rsnd.h" | 11 | #include "rsnd.h" |
| 13 | 12 | ||
| 14 | #define CLKA 0 | 13 | #define CLKA 0 |
| @@ -22,6 +21,7 @@ struct rsnd_adg { | |||
| 22 | 21 | ||
| 23 | int rate_of_441khz_div_6; | 22 | int rate_of_441khz_div_6; |
| 24 | int rate_of_48khz_div_6; | 23 | int rate_of_48khz_div_6; |
| 24 | u32 ckr; | ||
| 25 | }; | 25 | }; |
| 26 | 26 | ||
| 27 | #define for_each_rsnd_clk(pos, adg, i) \ | 27 | #define for_each_rsnd_clk(pos, adg, i) \ |
| @@ -116,6 +116,11 @@ int rsnd_adg_ssi_clk_try_start(struct rsnd_mod *mod, unsigned int rate) | |||
| 116 | 116 | ||
| 117 | found_clock: | 117 | found_clock: |
| 118 | 118 | ||
| 119 | /* see rsnd_adg_ssi_clk_init() */ | ||
| 120 | rsnd_mod_bset(mod, SSICKR, 0x00FF0000, adg->ckr); | ||
| 121 | rsnd_mod_write(mod, BRRA, 0x00000002); /* 1/6 */ | ||
| 122 | rsnd_mod_write(mod, BRRB, 0x00000002); /* 1/6 */ | ||
| 123 | |||
| 119 | /* | 124 | /* |
| 120 | * This "mod" = "ssi" here. | 125 | * This "mod" = "ssi" here. |
| 121 | * we can get "ssi id" from mod | 126 | * we can get "ssi id" from mod |
| @@ -182,9 +187,7 @@ static void rsnd_adg_ssi_clk_init(struct rsnd_priv *priv, struct rsnd_adg *adg) | |||
| 182 | } | 187 | } |
| 183 | } | 188 | } |
| 184 | 189 | ||
| 185 | rsnd_priv_bset(priv, SSICKR, 0x00FF0000, ckr); | 190 | adg->ckr = ckr; |
| 186 | rsnd_priv_write(priv, BRRA, 0x00000002); /* 1/6 */ | ||
| 187 | rsnd_priv_write(priv, BRRB, 0x00000002); /* 1/6 */ | ||
| 188 | } | 191 | } |
| 189 | 192 | ||
| 190 | int rsnd_adg_probe(struct platform_device *pdev, | 193 | int rsnd_adg_probe(struct platform_device *pdev, |
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index a35706028514..b234ed663073 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
| @@ -103,54 +103,9 @@ | |||
| 103 | * rsnd_platform functions | 103 | * rsnd_platform functions |
| 104 | */ | 104 | */ |
| 105 | #define rsnd_platform_call(priv, dai, func, param...) \ | 105 | #define rsnd_platform_call(priv, dai, func, param...) \ |
| 106 | (!(priv->info->func) ? -ENODEV : \ | 106 | (!(priv->info->func) ? 0 : \ |
| 107 | priv->info->func(param)) | 107 | priv->info->func(param)) |
| 108 | 108 | ||
| 109 | |||
| 110 | /* | ||
| 111 | * basic function | ||
| 112 | */ | ||
| 113 | u32 rsnd_read(struct rsnd_priv *priv, | ||
| 114 | struct rsnd_mod *mod, enum rsnd_reg reg) | ||
| 115 | { | ||
| 116 | void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); | ||
| 117 | |||
| 118 | BUG_ON(!base); | ||
| 119 | |||
| 120 | return ioread32(base); | ||
| 121 | } | ||
| 122 | |||
| 123 | void rsnd_write(struct rsnd_priv *priv, | ||
| 124 | struct rsnd_mod *mod, | ||
| 125 | enum rsnd_reg reg, u32 data) | ||
| 126 | { | ||
| 127 | void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); | ||
| 128 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 129 | |||
| 130 | BUG_ON(!base); | ||
| 131 | |||
| 132 | dev_dbg(dev, "w %p : %08x\n", base, data); | ||
| 133 | |||
| 134 | iowrite32(data, base); | ||
| 135 | } | ||
| 136 | |||
| 137 | void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, | ||
| 138 | enum rsnd_reg reg, u32 mask, u32 data) | ||
| 139 | { | ||
| 140 | void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); | ||
| 141 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 142 | u32 val; | ||
| 143 | |||
| 144 | BUG_ON(!base); | ||
| 145 | |||
| 146 | val = ioread32(base); | ||
| 147 | val &= ~mask; | ||
| 148 | val |= data & mask; | ||
| 149 | iowrite32(val, base); | ||
| 150 | |||
| 151 | dev_dbg(dev, "s %p : %08x\n", base, val); | ||
| 152 | } | ||
| 153 | |||
| 154 | /* | 109 | /* |
| 155 | * rsnd_mod functions | 110 | * rsnd_mod functions |
| 156 | */ | 111 | */ |
| @@ -363,6 +318,9 @@ int rsnd_dai_id(struct rsnd_priv *priv, struct rsnd_dai *rdai) | |||
| 363 | 318 | ||
| 364 | struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id) | 319 | struct rsnd_dai *rsnd_dai_get(struct rsnd_priv *priv, int id) |
| 365 | { | 320 | { |
| 321 | if ((id < 0) || (id >= rsnd_dai_nr(priv))) | ||
| 322 | return NULL; | ||
| 323 | |||
| 366 | return priv->rdai + id; | 324 | return priv->rdai + id; |
| 367 | } | 325 | } |
| 368 | 326 | ||
diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index babb203b43b7..61212ee97c28 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c | |||
| @@ -11,6 +11,11 @@ | |||
| 11 | #include "rsnd.h" | 11 | #include "rsnd.h" |
| 12 | 12 | ||
| 13 | struct rsnd_gen_ops { | 13 | struct rsnd_gen_ops { |
| 14 | int (*probe)(struct platform_device *pdev, | ||
| 15 | struct rcar_snd_info *info, | ||
| 16 | struct rsnd_priv *priv); | ||
| 17 | void (*remove)(struct platform_device *pdev, | ||
| 18 | struct rsnd_priv *priv); | ||
| 14 | int (*path_init)(struct rsnd_priv *priv, | 19 | int (*path_init)(struct rsnd_priv *priv, |
| 15 | struct rsnd_dai *rdai, | 20 | struct rsnd_dai *rdai, |
| 16 | struct rsnd_dai_stream *io); | 21 | struct rsnd_dai_stream *io); |
| @@ -19,21 +24,97 @@ struct rsnd_gen_ops { | |||
| 19 | struct rsnd_dai_stream *io); | 24 | struct rsnd_dai_stream *io); |
| 20 | }; | 25 | }; |
| 21 | 26 | ||
| 22 | struct rsnd_gen_reg_map { | ||
| 23 | int index; /* -1 : not supported */ | ||
| 24 | u32 offset_id; /* offset of ssi0, ssi1, ssi2... */ | ||
| 25 | u32 offset_adr; /* offset of SSICR, SSISR, ... */ | ||
| 26 | }; | ||
| 27 | |||
| 28 | struct rsnd_gen { | 27 | struct rsnd_gen { |
| 29 | void __iomem *base[RSND_BASE_MAX]; | 28 | void __iomem *base[RSND_BASE_MAX]; |
| 30 | 29 | ||
| 31 | struct rsnd_gen_reg_map reg_map[RSND_REG_MAX]; | ||
| 32 | struct rsnd_gen_ops *ops; | 30 | struct rsnd_gen_ops *ops; |
| 31 | |||
| 32 | struct regmap *regmap; | ||
| 33 | struct regmap_field *regs[RSND_REG_MAX]; | ||
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| 35 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) | 36 | #define rsnd_priv_to_gen(p) ((struct rsnd_gen *)(p)->gen) |
| 36 | 37 | ||
| 38 | #define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size) \ | ||
| 39 | [id] = { \ | ||
| 40 | .reg = (unsigned int)gen->base[reg_id] + offset, \ | ||
| 41 | .lsb = 0, \ | ||
| 42 | .msb = 31, \ | ||
| 43 | .id_size = _id_size, \ | ||
| 44 | .id_offset = _id_offset, \ | ||
| 45 | } | ||
| 46 | |||
| 47 | /* | ||
| 48 | * basic function | ||
| 49 | */ | ||
| 50 | static int rsnd_regmap_write32(void *context, const void *_data, size_t count) | ||
| 51 | { | ||
| 52 | struct rsnd_priv *priv = context; | ||
| 53 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 54 | u32 *data = (u32 *)_data; | ||
| 55 | u32 val = data[1]; | ||
| 56 | void __iomem *reg = (void *)data[0]; | ||
| 57 | |||
| 58 | iowrite32(val, reg); | ||
| 59 | |||
| 60 | dev_dbg(dev, "w %p : %08x\n", reg, val); | ||
| 61 | |||
| 62 | return 0; | ||
| 63 | } | ||
| 64 | |||
| 65 | static int rsnd_regmap_read32(void *context, | ||
| 66 | const void *_data, size_t reg_size, | ||
| 67 | void *_val, size_t val_size) | ||
| 68 | { | ||
| 69 | struct rsnd_priv *priv = context; | ||
| 70 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 71 | u32 *data = (u32 *)_data; | ||
| 72 | u32 *val = (u32 *)_val; | ||
| 73 | void __iomem *reg = (void *)data[0]; | ||
| 74 | |||
| 75 | *val = ioread32(reg); | ||
| 76 | |||
| 77 | dev_dbg(dev, "r %p : %08x\n", reg, *val); | ||
| 78 | |||
| 79 | return 0; | ||
| 80 | } | ||
| 81 | |||
| 82 | static struct regmap_bus rsnd_regmap_bus = { | ||
| 83 | .write = rsnd_regmap_write32, | ||
| 84 | .read = rsnd_regmap_read32, | ||
| 85 | .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
| 86 | .val_format_endian_default = REGMAP_ENDIAN_NATIVE, | ||
| 87 | }; | ||
| 88 | |||
| 89 | u32 rsnd_read(struct rsnd_priv *priv, | ||
| 90 | struct rsnd_mod *mod, enum rsnd_reg reg) | ||
| 91 | { | ||
| 92 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
| 93 | u32 val; | ||
| 94 | |||
| 95 | regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), &val); | ||
| 96 | |||
| 97 | return val; | ||
| 98 | } | ||
| 99 | |||
| 100 | void rsnd_write(struct rsnd_priv *priv, | ||
| 101 | struct rsnd_mod *mod, | ||
| 102 | enum rsnd_reg reg, u32 data) | ||
| 103 | { | ||
| 104 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
| 105 | |||
| 106 | regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); | ||
| 107 | } | ||
| 108 | |||
| 109 | void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, | ||
| 110 | enum rsnd_reg reg, u32 mask, u32 data) | ||
| 111 | { | ||
| 112 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
| 113 | |||
| 114 | regmap_fields_update_bits(gen->regs[reg], rsnd_mod_id(mod), | ||
| 115 | mask, data); | ||
| 116 | } | ||
| 117 | |||
| 37 | /* | 118 | /* |
| 38 | * Gen2 | 119 | * Gen2 |
| 39 | * will be filled in the future | 120 | * will be filled in the future |
| @@ -98,44 +179,64 @@ static int rsnd_gen1_path_exit(struct rsnd_priv *priv, | |||
| 98 | return ret; | 179 | return ret; |
| 99 | } | 180 | } |
| 100 | 181 | ||
| 101 | static struct rsnd_gen_ops rsnd_gen1_ops = { | 182 | /* single address mapping */ |
| 102 | .path_init = rsnd_gen1_path_init, | 183 | #define RSND_GEN1_S_REG(gen, reg, id, offset) \ |
| 103 | .path_exit = rsnd_gen1_path_exit, | 184 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, 0, 9) |
| 104 | }; | ||
| 105 | 185 | ||
| 106 | #define RSND_GEN1_REG_MAP(g, s, i, oi, oa) \ | 186 | /* multi address mapping */ |
| 107 | do { \ | 187 | #define RSND_GEN1_M_REG(gen, reg, id, offset, _id_offset) \ |
| 108 | (g)->reg_map[RSND_REG_##i].index = RSND_GEN1_##s; \ | 188 | RSND_REG_SET(gen, RSND_REG_##id, RSND_GEN1_##reg, offset, _id_offset, 9) |
| 109 | (g)->reg_map[RSND_REG_##i].offset_id = oi; \ | ||
| 110 | (g)->reg_map[RSND_REG_##i].offset_adr = oa; \ | ||
| 111 | } while (0) | ||
| 112 | 189 | ||
| 113 | static void rsnd_gen1_reg_map_init(struct rsnd_gen *gen) | 190 | static int rsnd_gen1_regmap_init(struct rsnd_priv *priv, struct rsnd_gen *gen) |
| 114 | { | 191 | { |
| 115 | RSND_GEN1_REG_MAP(gen, SRU, SRC_ROUTE_SEL, 0x0, 0x00); | 192 | int i; |
| 116 | RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL0, 0x0, 0x08); | 193 | struct device *dev = rsnd_priv_to_dev(priv); |
| 117 | RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL1, 0x0, 0x0c); | 194 | struct regmap_config regc; |
| 118 | RSND_GEN1_REG_MAP(gen, SRU, SRC_TMG_SEL2, 0x0, 0x10); | 195 | struct reg_field regf[RSND_REG_MAX] = { |
| 119 | RSND_GEN1_REG_MAP(gen, SRU, SRC_CTRL, 0x0, 0xc0); | 196 | RSND_GEN1_S_REG(gen, SRU, SRC_ROUTE_SEL, 0x00), |
| 120 | RSND_GEN1_REG_MAP(gen, SRU, SSI_MODE0, 0x0, 0xD0); | 197 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL0, 0x08), |
| 121 | RSND_GEN1_REG_MAP(gen, SRU, SSI_MODE1, 0x0, 0xD4); | 198 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL1, 0x0c), |
| 122 | RSND_GEN1_REG_MAP(gen, SRU, BUSIF_MODE, 0x4, 0x20); | 199 | RSND_GEN1_S_REG(gen, SRU, SRC_TMG_SEL2, 0x10), |
| 123 | RSND_GEN1_REG_MAP(gen, SRU, BUSIF_ADINR, 0x40, 0x214); | 200 | RSND_GEN1_S_REG(gen, SRU, SRC_CTRL, 0xc0), |
| 124 | 201 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE0, 0xD0), | |
| 125 | RSND_GEN1_REG_MAP(gen, ADG, BRRA, 0x0, 0x00); | 202 | RSND_GEN1_S_REG(gen, SRU, SSI_MODE1, 0xD4), |
| 126 | RSND_GEN1_REG_MAP(gen, ADG, BRRB, 0x0, 0x04); | 203 | RSND_GEN1_M_REG(gen, SRU, BUSIF_MODE, 0x20, 0x4), |
| 127 | RSND_GEN1_REG_MAP(gen, ADG, SSICKR, 0x0, 0x08); | 204 | RSND_GEN1_M_REG(gen, SRU, BUSIF_ADINR, 0x214, 0x40), |
| 128 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL0, 0x0, 0x0c); | 205 | |
| 129 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL1, 0x0, 0x10); | 206 | RSND_GEN1_S_REG(gen, ADG, BRRA, 0x00), |
| 130 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL3, 0x0, 0x18); | 207 | RSND_GEN1_S_REG(gen, ADG, BRRB, 0x04), |
| 131 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL4, 0x0, 0x1c); | 208 | RSND_GEN1_S_REG(gen, ADG, SSICKR, 0x08), |
| 132 | RSND_GEN1_REG_MAP(gen, ADG, AUDIO_CLK_SEL5, 0x0, 0x20); | 209 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL0, 0x0c), |
| 133 | 210 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL1, 0x10), | |
| 134 | RSND_GEN1_REG_MAP(gen, SSI, SSICR, 0x40, 0x00); | 211 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL3, 0x18), |
| 135 | RSND_GEN1_REG_MAP(gen, SSI, SSISR, 0x40, 0x04); | 212 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL4, 0x1c), |
| 136 | RSND_GEN1_REG_MAP(gen, SSI, SSITDR, 0x40, 0x08); | 213 | RSND_GEN1_S_REG(gen, ADG, AUDIO_CLK_SEL5, 0x20), |
| 137 | RSND_GEN1_REG_MAP(gen, SSI, SSIRDR, 0x40, 0x0c); | 214 | |
| 138 | RSND_GEN1_REG_MAP(gen, SSI, SSIWSR, 0x40, 0x20); | 215 | RSND_GEN1_M_REG(gen, SSI, SSICR, 0x00, 0x40), |
| 216 | RSND_GEN1_M_REG(gen, SSI, SSISR, 0x04, 0x40), | ||
| 217 | RSND_GEN1_M_REG(gen, SSI, SSITDR, 0x08, 0x40), | ||
| 218 | RSND_GEN1_M_REG(gen, SSI, SSIRDR, 0x0c, 0x40), | ||
| 219 | RSND_GEN1_M_REG(gen, SSI, SSIWSR, 0x20, 0x40), | ||
| 220 | }; | ||
| 221 | |||
| 222 | memset(®c, 0, sizeof(regc)); | ||
| 223 | regc.reg_bits = 32; | ||
| 224 | regc.val_bits = 32; | ||
| 225 | |||
| 226 | gen->regmap = devm_regmap_init(dev, &rsnd_regmap_bus, priv, ®c); | ||
| 227 | if (IS_ERR(gen->regmap)) { | ||
| 228 | dev_err(dev, "regmap error %ld\n", PTR_ERR(gen->regmap)); | ||
| 229 | return PTR_ERR(gen->regmap); | ||
| 230 | } | ||
| 231 | |||
| 232 | for (i = 0; i < RSND_REG_MAX; i++) { | ||
| 233 | gen->regs[i] = devm_regmap_field_alloc(dev, gen->regmap, regf[i]); | ||
| 234 | if (IS_ERR(gen->regs[i])) | ||
| 235 | return PTR_ERR(gen->regs[i]); | ||
| 236 | |||
| 237 | } | ||
| 238 | |||
| 239 | return 0; | ||
| 139 | } | 240 | } |
| 140 | 241 | ||
| 141 | static int rsnd_gen1_probe(struct platform_device *pdev, | 242 | static int rsnd_gen1_probe(struct platform_device *pdev, |
| @@ -147,6 +248,7 @@ static int rsnd_gen1_probe(struct platform_device *pdev, | |||
| 147 | struct resource *sru_res; | 248 | struct resource *sru_res; |
| 148 | struct resource *adg_res; | 249 | struct resource *adg_res; |
| 149 | struct resource *ssi_res; | 250 | struct resource *ssi_res; |
| 251 | int ret; | ||
| 150 | 252 | ||
| 151 | /* | 253 | /* |
| 152 | * map address | 254 | * map address |
| @@ -163,8 +265,9 @@ static int rsnd_gen1_probe(struct platform_device *pdev, | |||
| 163 | IS_ERR(gen->base[RSND_GEN1_SSI])) | 265 | IS_ERR(gen->base[RSND_GEN1_SSI])) |
| 164 | return -ENODEV; | 266 | return -ENODEV; |
| 165 | 267 | ||
| 166 | gen->ops = &rsnd_gen1_ops; | 268 | ret = rsnd_gen1_regmap_init(priv, gen); |
| 167 | rsnd_gen1_reg_map_init(gen); | 269 | if (ret < 0) |
| 270 | return ret; | ||
| 168 | 271 | ||
| 169 | dev_dbg(dev, "Gen1 device probed\n"); | 272 | dev_dbg(dev, "Gen1 device probed\n"); |
| 170 | dev_dbg(dev, "SRU : %08x => %p\n", sru_res->start, | 273 | dev_dbg(dev, "SRU : %08x => %p\n", sru_res->start, |
| @@ -183,6 +286,13 @@ static void rsnd_gen1_remove(struct platform_device *pdev, | |||
| 183 | { | 286 | { |
| 184 | } | 287 | } |
| 185 | 288 | ||
| 289 | static struct rsnd_gen_ops rsnd_gen1_ops = { | ||
| 290 | .probe = rsnd_gen1_probe, | ||
| 291 | .remove = rsnd_gen1_remove, | ||
| 292 | .path_init = rsnd_gen1_path_init, | ||
| 293 | .path_exit = rsnd_gen1_path_exit, | ||
| 294 | }; | ||
| 295 | |||
| 186 | /* | 296 | /* |
| 187 | * Gen | 297 | * Gen |
| 188 | */ | 298 | */ |
| @@ -204,46 +314,12 @@ int rsnd_gen_path_exit(struct rsnd_priv *priv, | |||
| 204 | return gen->ops->path_exit(priv, rdai, io); | 314 | return gen->ops->path_exit(priv, rdai, io); |
| 205 | } | 315 | } |
| 206 | 316 | ||
| 207 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, | ||
| 208 | struct rsnd_mod *mod, | ||
| 209 | enum rsnd_reg reg) | ||
| 210 | { | ||
| 211 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); | ||
| 212 | struct device *dev = rsnd_priv_to_dev(priv); | ||
| 213 | int index; | ||
| 214 | u32 offset_id, offset_adr; | ||
| 215 | |||
| 216 | if (reg >= RSND_REG_MAX) { | ||
| 217 | dev_err(dev, "rsnd_reg reg error\n"); | ||
| 218 | return NULL; | ||
| 219 | } | ||
| 220 | |||
| 221 | index = gen->reg_map[reg].index; | ||
| 222 | offset_id = gen->reg_map[reg].offset_id; | ||
| 223 | offset_adr = gen->reg_map[reg].offset_adr; | ||
| 224 | |||
| 225 | if (index < 0) { | ||
| 226 | dev_err(dev, "unsupported reg access %d\n", reg); | ||
| 227 | return NULL; | ||
| 228 | } | ||
| 229 | |||
| 230 | if (offset_id && mod) | ||
| 231 | offset_id *= rsnd_mod_id(mod); | ||
| 232 | |||
| 233 | /* | ||
| 234 | * index/offset were set on gen1/gen2 | ||
| 235 | */ | ||
| 236 | |||
| 237 | return gen->base[index] + offset_id + offset_adr; | ||
| 238 | } | ||
| 239 | |||
| 240 | int rsnd_gen_probe(struct platform_device *pdev, | 317 | int rsnd_gen_probe(struct platform_device *pdev, |
| 241 | struct rcar_snd_info *info, | 318 | struct rcar_snd_info *info, |
| 242 | struct rsnd_priv *priv) | 319 | struct rsnd_priv *priv) |
| 243 | { | 320 | { |
| 244 | struct device *dev = rsnd_priv_to_dev(priv); | 321 | struct device *dev = rsnd_priv_to_dev(priv); |
| 245 | struct rsnd_gen *gen; | 322 | struct rsnd_gen *gen; |
| 246 | int i; | ||
| 247 | 323 | ||
| 248 | gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); | 324 | gen = devm_kzalloc(dev, sizeof(*gen), GFP_KERNEL); |
| 249 | if (!gen) { | 325 | if (!gen) { |
| @@ -251,30 +327,23 @@ int rsnd_gen_probe(struct platform_device *pdev, | |||
| 251 | return -ENOMEM; | 327 | return -ENOMEM; |
| 252 | } | 328 | } |
| 253 | 329 | ||
| 254 | priv->gen = gen; | ||
| 255 | |||
| 256 | /* | ||
| 257 | * see | ||
| 258 | * rsnd_reg_get() | ||
| 259 | * rsnd_gen_probe() | ||
| 260 | */ | ||
| 261 | for (i = 0; i < RSND_REG_MAX; i++) | ||
| 262 | gen->reg_map[i].index = -1; | ||
| 263 | |||
| 264 | /* | ||
| 265 | * init each module | ||
| 266 | */ | ||
| 267 | if (rsnd_is_gen1(priv)) | 330 | if (rsnd_is_gen1(priv)) |
| 268 | return rsnd_gen1_probe(pdev, info, priv); | 331 | gen->ops = &rsnd_gen1_ops; |
| 269 | 332 | ||
| 270 | dev_err(dev, "unknown generation R-Car sound device\n"); | 333 | if (!gen->ops) { |
| 334 | dev_err(dev, "unknown generation R-Car sound device\n"); | ||
| 335 | return -ENODEV; | ||
| 336 | } | ||
| 271 | 337 | ||
| 272 | return -ENODEV; | 338 | priv->gen = gen; |
| 339 | |||
| 340 | return gen->ops->probe(pdev, info, priv); | ||
| 273 | } | 341 | } |
| 274 | 342 | ||
| 275 | void rsnd_gen_remove(struct platform_device *pdev, | 343 | void rsnd_gen_remove(struct platform_device *pdev, |
| 276 | struct rsnd_priv *priv) | 344 | struct rsnd_priv *priv) |
| 277 | { | 345 | { |
| 278 | if (rsnd_is_gen1(priv)) | 346 | struct rsnd_gen *gen = rsnd_priv_to_gen(priv); |
| 279 | rsnd_gen1_remove(pdev, priv); | 347 | |
| 348 | gen->ops->remove(pdev, priv); | ||
| 280 | } | 349 | } |
diff --git a/sound/soc/sh/rcar/rsnd.h b/sound/soc/sh/rcar/rsnd.h index 9cc6986a8cfb..9e463e50e7e6 100644 --- a/sound/soc/sh/rcar/rsnd.h +++ b/sound/soc/sh/rcar/rsnd.h | |||
| @@ -78,10 +78,6 @@ struct rsnd_dai_stream; | |||
| 78 | #define rsnd_mod_bset(m, r, s, d) \ | 78 | #define rsnd_mod_bset(m, r, s, d) \ |
| 79 | rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d) | 79 | rsnd_bset(rsnd_mod_to_priv(m), m, RSND_REG_##r, s, d) |
| 80 | 80 | ||
| 81 | #define rsnd_priv_read(p, r) rsnd_read(p, NULL, RSND_REG_##r) | ||
| 82 | #define rsnd_priv_write(p, r, d) rsnd_write(p, NULL, RSND_REG_##r, d) | ||
| 83 | #define rsnd_priv_bset(p, r, s, d) rsnd_bset(p, NULL, RSND_REG_##r, s, d) | ||
| 84 | |||
| 85 | u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg); | 81 | u32 rsnd_read(struct rsnd_priv *priv, struct rsnd_mod *mod, enum rsnd_reg reg); |
| 86 | void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod, | 82 | void rsnd_write(struct rsnd_priv *priv, struct rsnd_mod *mod, |
| 87 | enum rsnd_reg reg, u32 data); | 83 | enum rsnd_reg reg, u32 data); |
| @@ -220,8 +216,8 @@ int rsnd_gen_path_exit(struct rsnd_priv *priv, | |||
| 220 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, | 216 | void __iomem *rsnd_gen_reg_get(struct rsnd_priv *priv, |
| 221 | struct rsnd_mod *mod, | 217 | struct rsnd_mod *mod, |
| 222 | enum rsnd_reg reg); | 218 | enum rsnd_reg reg); |
| 223 | #define rsnd_is_gen1(s) ((s)->info->flags & RSND_GEN1) | 219 | #define rsnd_is_gen1(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN1) |
| 224 | #define rsnd_is_gen2(s) ((s)->info->flags & RSND_GEN2) | 220 | #define rsnd_is_gen2(s) (((s)->info->flags & RSND_GEN_MASK) == RSND_GEN2) |
| 225 | 221 | ||
| 226 | /* | 222 | /* |
| 227 | * R-Car ADG | 223 | * R-Car ADG |
| @@ -285,6 +281,7 @@ int rsnd_scu_probe(struct platform_device *pdev, | |||
| 285 | void rsnd_scu_remove(struct platform_device *pdev, | 281 | void rsnd_scu_remove(struct platform_device *pdev, |
| 286 | struct rsnd_priv *priv); | 282 | struct rsnd_priv *priv); |
| 287 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); | 283 | struct rsnd_mod *rsnd_scu_mod_get(struct rsnd_priv *priv, int id); |
| 284 | bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod); | ||
| 288 | #define rsnd_scu_nr(priv) ((priv)->scu_nr) | 285 | #define rsnd_scu_nr(priv) ((priv)->scu_nr) |
| 289 | 286 | ||
| 290 | /* | 287 | /* |
diff --git a/sound/soc/sh/rcar/scu.c b/sound/soc/sh/rcar/scu.c index 2df2e9150b89..1ab1bce6be7f 100644 --- a/sound/soc/sh/rcar/scu.c +++ b/sound/soc/sh/rcar/scu.c | |||
| @@ -146,20 +146,26 @@ static int rsnd_scu_set_hpbif(struct rsnd_priv *priv, | |||
| 146 | return 0; | 146 | return 0; |
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | bool rsnd_scu_hpbif_is_enable(struct rsnd_mod *mod) | ||
| 150 | { | ||
| 151 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
| 152 | u32 flags = rsnd_scu_mode_flags(scu); | ||
| 153 | |||
| 154 | return !!(flags & RSND_SCU_USE_HPBIF); | ||
| 155 | } | ||
| 156 | |||
| 149 | static int rsnd_scu_start(struct rsnd_mod *mod, | 157 | static int rsnd_scu_start(struct rsnd_mod *mod, |
| 150 | struct rsnd_dai *rdai, | 158 | struct rsnd_dai *rdai, |
| 151 | struct rsnd_dai_stream *io) | 159 | struct rsnd_dai_stream *io) |
| 152 | { | 160 | { |
| 153 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); | 161 | struct rsnd_priv *priv = rsnd_mod_to_priv(mod); |
| 154 | struct rsnd_scu *scu = rsnd_mod_to_scu(mod); | ||
| 155 | struct device *dev = rsnd_priv_to_dev(priv); | 162 | struct device *dev = rsnd_priv_to_dev(priv); |
| 156 | u32 flags = rsnd_scu_mode_flags(scu); | ||
| 157 | int ret; | 163 | int ret; |
| 158 | 164 | ||
| 159 | /* | 165 | /* |
| 160 | * SCU will be used if it has RSND_SCU_USE_HPBIF flags | 166 | * SCU will be used if it has RSND_SCU_USE_HPBIF flags |
| 161 | */ | 167 | */ |
| 162 | if (!(flags & RSND_SCU_USE_HPBIF)) { | 168 | if (!rsnd_scu_hpbif_is_enable(mod)) { |
| 163 | /* it use PIO transter */ | 169 | /* it use PIO transter */ |
| 164 | dev_dbg(dev, "%s%d is not used\n", | 170 | dev_dbg(dev, "%s%d is not used\n", |
| 165 | rsnd_mod_name(mod), rsnd_mod_id(mod)); | 171 | rsnd_mod_name(mod), rsnd_mod_id(mod)); |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index fae26d3f79d2..b71cf9d7dd3f 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
| @@ -101,29 +101,30 @@ struct rsnd_ssiu { | |||
| 101 | #define rsnd_ssi_to_ssiu(ssi)\ | 101 | #define rsnd_ssi_to_ssiu(ssi)\ |
| 102 | (((struct rsnd_ssiu *)((ssi) - rsnd_mod_id(&(ssi)->mod))) - 1) | 102 | (((struct rsnd_ssiu *)((ssi) - rsnd_mod_id(&(ssi)->mod))) - 1) |
| 103 | 103 | ||
| 104 | static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | 104 | static void rsnd_ssi_mode_set(struct rsnd_priv *priv, |
| 105 | struct rsnd_ssiu *ssiu) | 105 | struct rsnd_dai *rdai, |
| 106 | struct rsnd_ssi *ssi) | ||
| 106 | { | 107 | { |
| 107 | struct device *dev = rsnd_priv_to_dev(priv); | 108 | struct device *dev = rsnd_priv_to_dev(priv); |
| 108 | struct rsnd_ssi *ssi; | 109 | struct rsnd_mod *scu; |
| 110 | struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi); | ||
| 111 | int id = rsnd_mod_id(&ssi->mod); | ||
| 109 | u32 flags; | 112 | u32 flags; |
| 110 | u32 val; | 113 | u32 val; |
| 111 | int i; | 114 | |
| 115 | scu = rsnd_scu_mod_get(priv, rsnd_mod_id(&ssi->mod)); | ||
| 112 | 116 | ||
| 113 | /* | 117 | /* |
| 114 | * SSI_MODE0 | 118 | * SSI_MODE0 |
| 115 | */ | 119 | */ |
| 116 | ssiu->ssi_mode0 = 0; | 120 | |
| 117 | for_each_rsnd_ssi(ssi, priv, i) { | 121 | /* see also BUSIF_MODE */ |
| 118 | flags = rsnd_ssi_mode_flags(ssi); | 122 | if (rsnd_scu_hpbif_is_enable(scu)) { |
| 119 | 123 | ssiu->ssi_mode0 &= ~(1 << id); | |
| 120 | /* see also BUSIF_MODE */ | 124 | dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", id); |
| 121 | if (!(flags & RSND_SSI_DEPENDENT)) { | 125 | } else { |
| 122 | ssiu->ssi_mode0 |= (1 << i); | 126 | ssiu->ssi_mode0 |= (1 << id); |
| 123 | dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", i); | 127 | dev_dbg(dev, "SSI%d uses INDEPENDENT mode\n", id); |
| 124 | } else { | ||
| 125 | dev_dbg(dev, "SSI%d uses DEPENDENT mode\n", i); | ||
| 126 | } | ||
| 127 | } | 128 | } |
| 128 | 129 | ||
| 129 | /* | 130 | /* |
| @@ -132,7 +133,7 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | |||
| 132 | #define ssi_parent_set(p, sync, adg, ext) \ | 133 | #define ssi_parent_set(p, sync, adg, ext) \ |
| 133 | do { \ | 134 | do { \ |
| 134 | ssi->parent = ssiu->ssi + p; \ | 135 | ssi->parent = ssiu->ssi + p; \ |
| 135 | if (flags & RSND_SSI_CLK_FROM_ADG) \ | 136 | if (rsnd_rdai_is_clk_master(rdai)) \ |
| 136 | val = adg; \ | 137 | val = adg; \ |
| 137 | else \ | 138 | else \ |
| 138 | val = ext; \ | 139 | val = ext; \ |
| @@ -140,15 +141,11 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | |||
| 140 | val |= sync; \ | 141 | val |= sync; \ |
| 141 | } while (0) | 142 | } while (0) |
| 142 | 143 | ||
| 143 | ssiu->ssi_mode1 = 0; | 144 | flags = rsnd_ssi_mode_flags(ssi); |
| 144 | for_each_rsnd_ssi(ssi, priv, i) { | 145 | if (flags & RSND_SSI_CLK_PIN_SHARE) { |
| 145 | flags = rsnd_ssi_mode_flags(ssi); | ||
| 146 | |||
| 147 | if (!(flags & RSND_SSI_CLK_PIN_SHARE)) | ||
| 148 | continue; | ||
| 149 | 146 | ||
| 150 | val = 0; | 147 | val = 0; |
| 151 | switch (i) { | 148 | switch (id) { |
| 152 | case 1: | 149 | case 1: |
| 153 | ssi_parent_set(0, (1 << 4), (0x2 << 0), (0x1 << 0)); | 150 | ssi_parent_set(0, (1 << 4), (0x2 << 0), (0x1 << 0)); |
| 154 | break; | 151 | break; |
| @@ -165,11 +162,6 @@ static void rsnd_ssi_mode_init(struct rsnd_priv *priv, | |||
| 165 | 162 | ||
| 166 | ssiu->ssi_mode1 |= val; | 163 | ssiu->ssi_mode1 |= val; |
| 167 | } | 164 | } |
| 168 | } | ||
| 169 | |||
| 170 | static void rsnd_ssi_mode_set(struct rsnd_ssi *ssi) | ||
| 171 | { | ||
| 172 | struct rsnd_ssiu *ssiu = rsnd_ssi_to_ssiu(ssi); | ||
| 173 | 165 | ||
| 174 | rsnd_mod_write(&ssi->mod, SSI_MODE0, ssiu->ssi_mode0); | 166 | rsnd_mod_write(&ssi->mod, SSI_MODE0, ssiu->ssi_mode0); |
| 175 | rsnd_mod_write(&ssi->mod, SSI_MODE1, ssiu->ssi_mode1); | 167 | rsnd_mod_write(&ssi->mod, SSI_MODE1, ssiu->ssi_mode1); |
| @@ -379,7 +371,7 @@ static int rsnd_ssi_init(struct rsnd_mod *mod, | |||
| 379 | ssi->cr_own = cr; | 371 | ssi->cr_own = cr; |
| 380 | ssi->err = -1; /* ignore 1st error */ | 372 | ssi->err = -1; /* ignore 1st error */ |
| 381 | 373 | ||
| 382 | rsnd_ssi_mode_set(ssi); | 374 | rsnd_ssi_mode_set(priv, rdai, ssi); |
| 383 | 375 | ||
| 384 | dev_dbg(dev, "%s.%d init\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); | 376 | dev_dbg(dev, "%s.%d init\n", rsnd_mod_name(mod), rsnd_mod_id(mod)); |
| 385 | 377 | ||
| @@ -706,8 +698,6 @@ int rsnd_ssi_probe(struct platform_device *pdev, | |||
| 706 | rsnd_mod_init(priv, &ssi->mod, ops, i); | 698 | rsnd_mod_init(priv, &ssi->mod, ops, i); |
| 707 | } | 699 | } |
| 708 | 700 | ||
| 709 | rsnd_ssi_mode_init(priv, ssiu); | ||
| 710 | |||
| 711 | dev_dbg(dev, "ssi probed\n"); | 701 | dev_dbg(dev, "ssi probed\n"); |
| 712 | 702 | ||
| 713 | return 0; | 703 | return 0; |
diff --git a/sound/soc/soc-cache.c b/sound/soc/soc-cache.c index e72f55428f0b..1b6663f45b34 100644 --- a/sound/soc/soc-cache.c +++ b/sound/soc/soc-cache.c | |||
| @@ -11,12 +11,9 @@ | |||
| 11 | * option) any later version. | 11 | * option) any later version. |
| 12 | */ | 12 | */ |
| 13 | 13 | ||
| 14 | #include <linux/i2c.h> | ||
| 15 | #include <linux/spi/spi.h> | ||
| 16 | #include <sound/soc.h> | 14 | #include <sound/soc.h> |
| 17 | #include <linux/bitmap.h> | ||
| 18 | #include <linux/rbtree.h> | ||
| 19 | #include <linux/export.h> | 15 | #include <linux/export.h> |
| 16 | #include <linux/slab.h> | ||
| 20 | 17 | ||
| 21 | #include <trace/events/asoc.h> | 18 | #include <trace/events/asoc.h> |
| 22 | 19 | ||
| @@ -66,126 +63,42 @@ static unsigned int snd_soc_get_cache_val(const void *base, unsigned int idx, | |||
| 66 | return -1; | 63 | return -1; |
| 67 | } | 64 | } |
| 68 | 65 | ||
| 69 | static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) | 66 | int snd_soc_cache_init(struct snd_soc_codec *codec) |
| 70 | { | 67 | { |
| 71 | int i; | 68 | const struct snd_soc_codec_driver *codec_drv = codec->driver; |
| 72 | int ret; | 69 | size_t reg_size; |
| 73 | const struct snd_soc_codec_driver *codec_drv; | ||
| 74 | unsigned int val; | ||
| 75 | 70 | ||
| 76 | codec_drv = codec->driver; | 71 | reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; |
| 77 | for (i = 0; i < codec_drv->reg_cache_size; ++i) { | ||
| 78 | ret = snd_soc_cache_read(codec, i, &val); | ||
| 79 | if (ret) | ||
| 80 | return ret; | ||
| 81 | if (codec->reg_def_copy) | ||
| 82 | if (snd_soc_get_cache_val(codec->reg_def_copy, | ||
| 83 | i, codec_drv->reg_word_size) == val) | ||
| 84 | continue; | ||
| 85 | 72 | ||
| 86 | WARN_ON(!snd_soc_codec_writable_register(codec, i)); | 73 | mutex_init(&codec->cache_rw_mutex); |
| 87 | |||
| 88 | ret = snd_soc_write(codec, i, val); | ||
| 89 | if (ret) | ||
| 90 | return ret; | ||
| 91 | dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n", | ||
| 92 | i, val); | ||
| 93 | } | ||
| 94 | return 0; | ||
| 95 | } | ||
| 96 | |||
| 97 | static int snd_soc_flat_cache_write(struct snd_soc_codec *codec, | ||
| 98 | unsigned int reg, unsigned int value) | ||
| 99 | { | ||
| 100 | snd_soc_set_cache_val(codec->reg_cache, reg, value, | ||
| 101 | codec->driver->reg_word_size); | ||
| 102 | return 0; | ||
| 103 | } | ||
| 104 | |||
| 105 | static int snd_soc_flat_cache_read(struct snd_soc_codec *codec, | ||
| 106 | unsigned int reg, unsigned int *value) | ||
| 107 | { | ||
| 108 | *value = snd_soc_get_cache_val(codec->reg_cache, reg, | ||
| 109 | codec->driver->reg_word_size); | ||
| 110 | return 0; | ||
| 111 | } | ||
| 112 | 74 | ||
| 113 | static int snd_soc_flat_cache_exit(struct snd_soc_codec *codec) | 75 | dev_dbg(codec->dev, "ASoC: Initializing cache for %s codec\n", |
| 114 | { | 76 | codec->name); |
| 115 | if (!codec->reg_cache) | ||
| 116 | return 0; | ||
| 117 | kfree(codec->reg_cache); | ||
| 118 | codec->reg_cache = NULL; | ||
| 119 | return 0; | ||
| 120 | } | ||
| 121 | 77 | ||
| 122 | static int snd_soc_flat_cache_init(struct snd_soc_codec *codec) | 78 | if (codec_drv->reg_cache_default) |
| 123 | { | 79 | codec->reg_cache = kmemdup(codec_drv->reg_cache_default, |
| 124 | if (codec->reg_def_copy) | 80 | reg_size, GFP_KERNEL); |
| 125 | codec->reg_cache = kmemdup(codec->reg_def_copy, | ||
| 126 | codec->reg_size, GFP_KERNEL); | ||
| 127 | else | 81 | else |
| 128 | codec->reg_cache = kzalloc(codec->reg_size, GFP_KERNEL); | 82 | codec->reg_cache = kzalloc(reg_size, GFP_KERNEL); |
| 129 | if (!codec->reg_cache) | 83 | if (!codec->reg_cache) |
| 130 | return -ENOMEM; | 84 | return -ENOMEM; |
| 131 | 85 | ||
| 132 | return 0; | 86 | return 0; |
| 133 | } | 87 | } |
| 134 | 88 | ||
| 135 | /* an array of all supported compression types */ | ||
| 136 | static const struct snd_soc_cache_ops cache_types[] = { | ||
| 137 | /* Flat *must* be the first entry for fallback */ | ||
| 138 | { | ||
| 139 | .id = SND_SOC_FLAT_COMPRESSION, | ||
| 140 | .name = "flat", | ||
| 141 | .init = snd_soc_flat_cache_init, | ||
| 142 | .exit = snd_soc_flat_cache_exit, | ||
| 143 | .read = snd_soc_flat_cache_read, | ||
| 144 | .write = snd_soc_flat_cache_write, | ||
| 145 | .sync = snd_soc_flat_cache_sync | ||
| 146 | }, | ||
| 147 | }; | ||
| 148 | |||
| 149 | int snd_soc_cache_init(struct snd_soc_codec *codec) | ||
| 150 | { | ||
| 151 | int i; | ||
| 152 | |||
| 153 | for (i = 0; i < ARRAY_SIZE(cache_types); ++i) | ||
| 154 | if (cache_types[i].id == codec->compress_type) | ||
| 155 | break; | ||
| 156 | |||
| 157 | /* Fall back to flat compression */ | ||
| 158 | if (i == ARRAY_SIZE(cache_types)) { | ||
| 159 | dev_warn(codec->dev, "ASoC: Could not match compress type: %d\n", | ||
| 160 | codec->compress_type); | ||
| 161 | i = 0; | ||
| 162 | } | ||
| 163 | |||
| 164 | mutex_init(&codec->cache_rw_mutex); | ||
| 165 | codec->cache_ops = &cache_types[i]; | ||
| 166 | |||
| 167 | if (codec->cache_ops->init) { | ||
| 168 | if (codec->cache_ops->name) | ||
| 169 | dev_dbg(codec->dev, "ASoC: Initializing %s cache for %s codec\n", | ||
| 170 | codec->cache_ops->name, codec->name); | ||
| 171 | return codec->cache_ops->init(codec); | ||
| 172 | } | ||
| 173 | return -ENOSYS; | ||
| 174 | } | ||
| 175 | |||
| 176 | /* | 89 | /* |
| 177 | * NOTE: keep in mind that this function might be called | 90 | * NOTE: keep in mind that this function might be called |
| 178 | * multiple times. | 91 | * multiple times. |
| 179 | */ | 92 | */ |
| 180 | int snd_soc_cache_exit(struct snd_soc_codec *codec) | 93 | int snd_soc_cache_exit(struct snd_soc_codec *codec) |
| 181 | { | 94 | { |
| 182 | if (codec->cache_ops && codec->cache_ops->exit) { | 95 | dev_dbg(codec->dev, "ASoC: Destroying cache for %s codec\n", |
| 183 | if (codec->cache_ops->name) | 96 | codec->name); |
| 184 | dev_dbg(codec->dev, "ASoC: Destroying %s cache for %s codec\n", | 97 | if (!codec->reg_cache) |
| 185 | codec->cache_ops->name, codec->name); | 98 | return 0; |
| 186 | return codec->cache_ops->exit(codec); | 99 | kfree(codec->reg_cache); |
| 187 | } | 100 | codec->reg_cache = NULL; |
| 188 | return -ENOSYS; | 101 | return 0; |
| 189 | } | 102 | } |
| 190 | 103 | ||
| 191 | /** | 104 | /** |
| @@ -198,18 +111,15 @@ int snd_soc_cache_exit(struct snd_soc_codec *codec) | |||
| 198 | int snd_soc_cache_read(struct snd_soc_codec *codec, | 111 | int snd_soc_cache_read(struct snd_soc_codec *codec, |
| 199 | unsigned int reg, unsigned int *value) | 112 | unsigned int reg, unsigned int *value) |
| 200 | { | 113 | { |
| 201 | int ret; | 114 | if (!value) |
| 115 | return -EINVAL; | ||
| 202 | 116 | ||
| 203 | mutex_lock(&codec->cache_rw_mutex); | 117 | mutex_lock(&codec->cache_rw_mutex); |
| 204 | 118 | *value = snd_soc_get_cache_val(codec->reg_cache, reg, | |
| 205 | if (value && codec->cache_ops && codec->cache_ops->read) { | 119 | codec->driver->reg_word_size); |
| 206 | ret = codec->cache_ops->read(codec, reg, value); | ||
| 207 | mutex_unlock(&codec->cache_rw_mutex); | ||
| 208 | return ret; | ||
| 209 | } | ||
| 210 | |||
| 211 | mutex_unlock(&codec->cache_rw_mutex); | 120 | mutex_unlock(&codec->cache_rw_mutex); |
| 212 | return -ENOSYS; | 121 | |
| 122 | return 0; | ||
| 213 | } | 123 | } |
| 214 | EXPORT_SYMBOL_GPL(snd_soc_cache_read); | 124 | EXPORT_SYMBOL_GPL(snd_soc_cache_read); |
| 215 | 125 | ||
| @@ -223,20 +133,42 @@ EXPORT_SYMBOL_GPL(snd_soc_cache_read); | |||
| 223 | int snd_soc_cache_write(struct snd_soc_codec *codec, | 133 | int snd_soc_cache_write(struct snd_soc_codec *codec, |
| 224 | unsigned int reg, unsigned int value) | 134 | unsigned int reg, unsigned int value) |
| 225 | { | 135 | { |
| 136 | mutex_lock(&codec->cache_rw_mutex); | ||
| 137 | snd_soc_set_cache_val(codec->reg_cache, reg, value, | ||
| 138 | codec->driver->reg_word_size); | ||
| 139 | mutex_unlock(&codec->cache_rw_mutex); | ||
| 140 | |||
| 141 | return 0; | ||
| 142 | } | ||
| 143 | EXPORT_SYMBOL_GPL(snd_soc_cache_write); | ||
| 144 | |||
| 145 | static int snd_soc_flat_cache_sync(struct snd_soc_codec *codec) | ||
| 146 | { | ||
| 147 | int i; | ||
| 226 | int ret; | 148 | int ret; |
| 149 | const struct snd_soc_codec_driver *codec_drv; | ||
| 150 | unsigned int val; | ||
| 227 | 151 | ||
| 228 | mutex_lock(&codec->cache_rw_mutex); | 152 | codec_drv = codec->driver; |
| 153 | for (i = 0; i < codec_drv->reg_cache_size; ++i) { | ||
| 154 | ret = snd_soc_cache_read(codec, i, &val); | ||
| 155 | if (ret) | ||
| 156 | return ret; | ||
| 157 | if (codec_drv->reg_cache_default) | ||
| 158 | if (snd_soc_get_cache_val(codec_drv->reg_cache_default, | ||
| 159 | i, codec_drv->reg_word_size) == val) | ||
| 160 | continue; | ||
| 229 | 161 | ||
| 230 | if (codec->cache_ops && codec->cache_ops->write) { | 162 | WARN_ON(!snd_soc_codec_writable_register(codec, i)); |
| 231 | ret = codec->cache_ops->write(codec, reg, value); | ||
| 232 | mutex_unlock(&codec->cache_rw_mutex); | ||
| 233 | return ret; | ||
| 234 | } | ||
| 235 | 163 | ||
| 236 | mutex_unlock(&codec->cache_rw_mutex); | 164 | ret = snd_soc_write(codec, i, val); |
| 237 | return -ENOSYS; | 165 | if (ret) |
| 166 | return ret; | ||
| 167 | dev_dbg(codec->dev, "ASoC: Synced register %#x, value = %#x\n", | ||
| 168 | i, val); | ||
| 169 | } | ||
| 170 | return 0; | ||
| 238 | } | 171 | } |
| 239 | EXPORT_SYMBOL_GPL(snd_soc_cache_write); | ||
| 240 | 172 | ||
| 241 | /** | 173 | /** |
| 242 | * snd_soc_cache_sync: Sync the register cache with the hardware. | 174 | * snd_soc_cache_sync: Sync the register cache with the hardware. |
| @@ -249,92 +181,19 @@ EXPORT_SYMBOL_GPL(snd_soc_cache_write); | |||
| 249 | */ | 181 | */ |
| 250 | int snd_soc_cache_sync(struct snd_soc_codec *codec) | 182 | int snd_soc_cache_sync(struct snd_soc_codec *codec) |
| 251 | { | 183 | { |
| 184 | const char *name = "flat"; | ||
| 252 | int ret; | 185 | int ret; |
| 253 | const char *name; | ||
| 254 | 186 | ||
| 255 | if (!codec->cache_sync) { | 187 | if (!codec->cache_sync) |
| 256 | return 0; | 188 | return 0; |
| 257 | } | ||
| 258 | |||
| 259 | if (!codec->cache_ops || !codec->cache_ops->sync) | ||
| 260 | return -ENOSYS; | ||
| 261 | 189 | ||
| 262 | if (codec->cache_ops->name) | 190 | dev_dbg(codec->dev, "ASoC: Syncing cache for %s codec\n", |
| 263 | name = codec->cache_ops->name; | 191 | codec->name); |
| 264 | else | ||
| 265 | name = "unknown"; | ||
| 266 | |||
| 267 | if (codec->cache_ops->name) | ||
| 268 | dev_dbg(codec->dev, "ASoC: Syncing %s cache for %s codec\n", | ||
| 269 | codec->cache_ops->name, codec->name); | ||
| 270 | trace_snd_soc_cache_sync(codec, name, "start"); | 192 | trace_snd_soc_cache_sync(codec, name, "start"); |
| 271 | ret = codec->cache_ops->sync(codec); | 193 | ret = snd_soc_flat_cache_sync(codec); |
| 272 | if (!ret) | 194 | if (!ret) |
| 273 | codec->cache_sync = 0; | 195 | codec->cache_sync = 0; |
| 274 | trace_snd_soc_cache_sync(codec, name, "end"); | 196 | trace_snd_soc_cache_sync(codec, name, "end"); |
| 275 | return ret; | 197 | return ret; |
| 276 | } | 198 | } |
| 277 | EXPORT_SYMBOL_GPL(snd_soc_cache_sync); | 199 | EXPORT_SYMBOL_GPL(snd_soc_cache_sync); |
| 278 | |||
| 279 | static int snd_soc_get_reg_access_index(struct snd_soc_codec *codec, | ||
| 280 | unsigned int reg) | ||
| 281 | { | ||
| 282 | const struct snd_soc_codec_driver *codec_drv; | ||
| 283 | unsigned int min, max, index; | ||
| 284 | |||
| 285 | codec_drv = codec->driver; | ||
| 286 | min = 0; | ||
| 287 | max = codec_drv->reg_access_size - 1; | ||
| 288 | do { | ||
| 289 | index = (min + max) / 2; | ||
| 290 | if (codec_drv->reg_access_default[index].reg == reg) | ||
| 291 | return index; | ||
| 292 | if (codec_drv->reg_access_default[index].reg < reg) | ||
| 293 | min = index + 1; | ||
| 294 | else | ||
| 295 | max = index; | ||
| 296 | } while (min <= max); | ||
| 297 | return -1; | ||
| 298 | } | ||
| 299 | |||
| 300 | int snd_soc_default_volatile_register(struct snd_soc_codec *codec, | ||
| 301 | unsigned int reg) | ||
| 302 | { | ||
| 303 | int index; | ||
| 304 | |||
| 305 | if (reg >= codec->driver->reg_cache_size) | ||
| 306 | return 1; | ||
| 307 | index = snd_soc_get_reg_access_index(codec, reg); | ||
| 308 | if (index < 0) | ||
| 309 | return 0; | ||
| 310 | return codec->driver->reg_access_default[index].vol; | ||
| 311 | } | ||
| 312 | EXPORT_SYMBOL_GPL(snd_soc_default_volatile_register); | ||
| 313 | |||
| 314 | int snd_soc_default_readable_register(struct snd_soc_codec *codec, | ||
| 315 | unsigned int reg) | ||
| 316 | { | ||
| 317 | int index; | ||
| 318 | |||
| 319 | if (reg >= codec->driver->reg_cache_size) | ||
| 320 | return 1; | ||
| 321 | index = snd_soc_get_reg_access_index(codec, reg); | ||
| 322 | if (index < 0) | ||
| 323 | return 0; | ||
| 324 | return codec->driver->reg_access_default[index].read; | ||
| 325 | } | ||
| 326 | EXPORT_SYMBOL_GPL(snd_soc_default_readable_register); | ||
| 327 | |||
| 328 | int snd_soc_default_writable_register(struct snd_soc_codec *codec, | ||
| 329 | unsigned int reg) | ||
| 330 | { | ||
| 331 | int index; | ||
| 332 | |||
| 333 | if (reg >= codec->driver->reg_cache_size) | ||
| 334 | return 1; | ||
| 335 | index = snd_soc_get_reg_access_index(codec, reg); | ||
| 336 | if (index < 0) | ||
| 337 | return 0; | ||
| 338 | return codec->driver->reg_access_default[index].write; | ||
| 339 | } | ||
| 340 | EXPORT_SYMBOL_GPL(snd_soc_default_writable_register); | ||
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 1a38be0d0ca8..afc3fa8b7470 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
| @@ -1589,17 +1589,13 @@ static void soc_remove_aux_dev(struct snd_soc_card *card, int num) | |||
| 1589 | soc_remove_codec(codec); | 1589 | soc_remove_codec(codec); |
| 1590 | } | 1590 | } |
| 1591 | 1591 | ||
| 1592 | static int snd_soc_init_codec_cache(struct snd_soc_codec *codec, | 1592 | static int snd_soc_init_codec_cache(struct snd_soc_codec *codec) |
| 1593 | enum snd_soc_compress_type compress_type) | ||
| 1594 | { | 1593 | { |
| 1595 | int ret; | 1594 | int ret; |
| 1596 | 1595 | ||
| 1597 | if (codec->cache_init) | 1596 | if (codec->cache_init) |
| 1598 | return 0; | 1597 | return 0; |
| 1599 | 1598 | ||
| 1600 | /* override the compress_type if necessary */ | ||
| 1601 | if (compress_type && codec->compress_type != compress_type) | ||
| 1602 | codec->compress_type = compress_type; | ||
| 1603 | ret = snd_soc_cache_init(codec); | 1599 | ret = snd_soc_cache_init(codec); |
| 1604 | if (ret < 0) { | 1600 | if (ret < 0) { |
| 1605 | dev_err(codec->dev, | 1601 | dev_err(codec->dev, |
| @@ -1614,8 +1610,6 @@ static int snd_soc_init_codec_cache(struct snd_soc_codec *codec, | |||
| 1614 | static int snd_soc_instantiate_card(struct snd_soc_card *card) | 1610 | static int snd_soc_instantiate_card(struct snd_soc_card *card) |
| 1615 | { | 1611 | { |
| 1616 | struct snd_soc_codec *codec; | 1612 | struct snd_soc_codec *codec; |
| 1617 | struct snd_soc_codec_conf *codec_conf; | ||
| 1618 | enum snd_soc_compress_type compress_type; | ||
| 1619 | struct snd_soc_dai_link *dai_link; | 1613 | struct snd_soc_dai_link *dai_link; |
| 1620 | int ret, i, order, dai_fmt; | 1614 | int ret, i, order, dai_fmt; |
| 1621 | 1615 | ||
| @@ -1639,19 +1633,7 @@ static int snd_soc_instantiate_card(struct snd_soc_card *card) | |||
| 1639 | list_for_each_entry(codec, &codec_list, list) { | 1633 | list_for_each_entry(codec, &codec_list, list) { |
| 1640 | if (codec->cache_init) | 1634 | if (codec->cache_init) |
| 1641 | continue; | 1635 | continue; |
| 1642 | /* by default we don't override the compress_type */ | 1636 | ret = snd_soc_init_codec_cache(codec); |
| 1643 | compress_type = 0; | ||
| 1644 | /* check to see if we need to override the compress_type */ | ||
| 1645 | for (i = 0; i < card->num_configs; ++i) { | ||
| 1646 | codec_conf = &card->codec_conf[i]; | ||
| 1647 | if (!strcmp(codec->name, codec_conf->dev_name)) { | ||
| 1648 | compress_type = codec_conf->compress_type; | ||
| 1649 | if (compress_type && compress_type | ||
| 1650 | != codec->compress_type) | ||
| 1651 | break; | ||
| 1652 | } | ||
| 1653 | } | ||
| 1654 | ret = snd_soc_init_codec_cache(codec, compress_type); | ||
| 1655 | if (ret < 0) | 1637 | if (ret < 0) |
| 1656 | goto base_error; | 1638 | goto base_error; |
| 1657 | } | 1639 | } |
| @@ -2297,13 +2279,6 @@ unsigned int snd_soc_write(struct snd_soc_codec *codec, | |||
| 2297 | } | 2279 | } |
| 2298 | EXPORT_SYMBOL_GPL(snd_soc_write); | 2280 | EXPORT_SYMBOL_GPL(snd_soc_write); |
| 2299 | 2281 | ||
| 2300 | unsigned int snd_soc_bulk_write_raw(struct snd_soc_codec *codec, | ||
| 2301 | unsigned int reg, const void *data, size_t len) | ||
| 2302 | { | ||
| 2303 | return codec->bulk_write_raw(codec, reg, data, len); | ||
| 2304 | } | ||
| 2305 | EXPORT_SYMBOL_GPL(snd_soc_bulk_write_raw); | ||
| 2306 | |||
| 2307 | /** | 2282 | /** |
| 2308 | * snd_soc_update_bits - update codec register bits | 2283 | * snd_soc_update_bits - update codec register bits |
| 2309 | * @codec: audio codec | 2284 | * @codec: audio codec |
| @@ -3576,6 +3551,22 @@ int snd_soc_codec_set_pll(struct snd_soc_codec *codec, int pll_id, int source, | |||
| 3576 | EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll); | 3551 | EXPORT_SYMBOL_GPL(snd_soc_codec_set_pll); |
| 3577 | 3552 | ||
| 3578 | /** | 3553 | /** |
| 3554 | * snd_soc_dai_set_bclk_ratio - configure BCLK to sample rate ratio. | ||
| 3555 | * @dai: DAI | ||
| 3556 | * @ratio Ratio of BCLK to Sample rate. | ||
| 3557 | * | ||
| 3558 | * Configures the DAI for a preset BCLK to sample rate ratio. | ||
| 3559 | */ | ||
| 3560 | int snd_soc_dai_set_bclk_ratio(struct snd_soc_dai *dai, unsigned int ratio) | ||
| 3561 | { | ||
| 3562 | if (dai->driver && dai->driver->ops->set_bclk_ratio) | ||
| 3563 | return dai->driver->ops->set_bclk_ratio(dai, ratio); | ||
| 3564 | else | ||
| 3565 | return -EINVAL; | ||
| 3566 | } | ||
| 3567 | EXPORT_SYMBOL_GPL(snd_soc_dai_set_bclk_ratio); | ||
| 3568 | |||
| 3569 | /** | ||
| 3579 | * snd_soc_dai_set_fmt - configure DAI hardware audio format. | 3570 | * snd_soc_dai_set_fmt - configure DAI hardware audio format. |
| 3580 | * @dai: DAI | 3571 | * @dai: DAI |
| 3581 | * @fmt: SND_SOC_DAIFMT_ format value. | 3572 | * @fmt: SND_SOC_DAIFMT_ format value. |
| @@ -4020,6 +4011,113 @@ static void snd_soc_unregister_dais(struct device *dev, size_t count) | |||
| 4020 | } | 4011 | } |
| 4021 | 4012 | ||
| 4022 | /** | 4013 | /** |
| 4014 | * snd_soc_register_component - Register a component with the ASoC core | ||
| 4015 | * | ||
| 4016 | */ | ||
| 4017 | static int | ||
| 4018 | __snd_soc_register_component(struct device *dev, | ||
| 4019 | struct snd_soc_component *cmpnt, | ||
| 4020 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 4021 | struct snd_soc_dai_driver *dai_drv, | ||
| 4022 | int num_dai, bool allow_single_dai) | ||
| 4023 | { | ||
| 4024 | int ret; | ||
| 4025 | |||
| 4026 | dev_dbg(dev, "component register %s\n", dev_name(dev)); | ||
| 4027 | |||
| 4028 | if (!cmpnt) { | ||
| 4029 | dev_err(dev, "ASoC: Failed to connecting component\n"); | ||
| 4030 | return -ENOMEM; | ||
| 4031 | } | ||
| 4032 | |||
| 4033 | cmpnt->name = fmt_single_name(dev, &cmpnt->id); | ||
| 4034 | if (!cmpnt->name) { | ||
| 4035 | dev_err(dev, "ASoC: Failed to simplifying name\n"); | ||
| 4036 | return -ENOMEM; | ||
| 4037 | } | ||
| 4038 | |||
| 4039 | cmpnt->dev = dev; | ||
| 4040 | cmpnt->driver = cmpnt_drv; | ||
| 4041 | cmpnt->dai_drv = dai_drv; | ||
| 4042 | cmpnt->num_dai = num_dai; | ||
| 4043 | |||
| 4044 | /* | ||
| 4045 | * snd_soc_register_dai() uses fmt_single_name(), and | ||
| 4046 | * snd_soc_register_dais() uses fmt_multiple_name() | ||
| 4047 | * for dai->name which is used for name based matching | ||
| 4048 | * | ||
| 4049 | * this function is used from cpu/codec. | ||
| 4050 | * allow_single_dai flag can ignore "codec" driver reworking | ||
| 4051 | * since it had been used snd_soc_register_dais(), | ||
| 4052 | */ | ||
| 4053 | if ((1 == num_dai) && allow_single_dai) | ||
| 4054 | ret = snd_soc_register_dai(dev, dai_drv); | ||
| 4055 | else | ||
| 4056 | ret = snd_soc_register_dais(dev, dai_drv, num_dai); | ||
| 4057 | if (ret < 0) { | ||
| 4058 | dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); | ||
| 4059 | goto error_component_name; | ||
| 4060 | } | ||
| 4061 | |||
| 4062 | mutex_lock(&client_mutex); | ||
| 4063 | list_add(&cmpnt->list, &component_list); | ||
| 4064 | mutex_unlock(&client_mutex); | ||
| 4065 | |||
| 4066 | dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name); | ||
| 4067 | |||
| 4068 | return ret; | ||
| 4069 | |||
| 4070 | error_component_name: | ||
| 4071 | kfree(cmpnt->name); | ||
| 4072 | |||
| 4073 | return ret; | ||
| 4074 | } | ||
| 4075 | |||
| 4076 | int snd_soc_register_component(struct device *dev, | ||
| 4077 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 4078 | struct snd_soc_dai_driver *dai_drv, | ||
| 4079 | int num_dai) | ||
| 4080 | { | ||
| 4081 | struct snd_soc_component *cmpnt; | ||
| 4082 | |||
| 4083 | cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL); | ||
| 4084 | if (!cmpnt) { | ||
| 4085 | dev_err(dev, "ASoC: Failed to allocate memory\n"); | ||
| 4086 | return -ENOMEM; | ||
| 4087 | } | ||
| 4088 | |||
| 4089 | return __snd_soc_register_component(dev, cmpnt, cmpnt_drv, | ||
| 4090 | dai_drv, num_dai, true); | ||
| 4091 | } | ||
| 4092 | EXPORT_SYMBOL_GPL(snd_soc_register_component); | ||
| 4093 | |||
| 4094 | /** | ||
| 4095 | * snd_soc_unregister_component - Unregister a component from the ASoC core | ||
| 4096 | * | ||
| 4097 | */ | ||
| 4098 | void snd_soc_unregister_component(struct device *dev) | ||
| 4099 | { | ||
| 4100 | struct snd_soc_component *cmpnt; | ||
| 4101 | |||
| 4102 | list_for_each_entry(cmpnt, &component_list, list) { | ||
| 4103 | if (dev == cmpnt->dev) | ||
| 4104 | goto found; | ||
| 4105 | } | ||
| 4106 | return; | ||
| 4107 | |||
| 4108 | found: | ||
| 4109 | snd_soc_unregister_dais(dev, cmpnt->num_dai); | ||
| 4110 | |||
| 4111 | mutex_lock(&client_mutex); | ||
| 4112 | list_del(&cmpnt->list); | ||
| 4113 | mutex_unlock(&client_mutex); | ||
| 4114 | |||
| 4115 | dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name); | ||
| 4116 | kfree(cmpnt->name); | ||
| 4117 | } | ||
| 4118 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); | ||
| 4119 | |||
| 4120 | /** | ||
| 4023 | * snd_soc_add_platform - Add a platform to the ASoC core | 4121 | * snd_soc_add_platform - Add a platform to the ASoC core |
| 4024 | * @dev: The parent device for the platform | 4122 | * @dev: The parent device for the platform |
| 4025 | * @platform: The platform to add | 4123 | * @platform: The platform to add |
| @@ -4165,7 +4263,6 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4165 | struct snd_soc_dai_driver *dai_drv, | 4263 | struct snd_soc_dai_driver *dai_drv, |
| 4166 | int num_dai) | 4264 | int num_dai) |
| 4167 | { | 4265 | { |
| 4168 | size_t reg_size; | ||
| 4169 | struct snd_soc_codec *codec; | 4266 | struct snd_soc_codec *codec; |
| 4170 | int ret, i; | 4267 | int ret, i; |
| 4171 | 4268 | ||
| @@ -4182,11 +4279,6 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4182 | goto fail_codec; | 4279 | goto fail_codec; |
| 4183 | } | 4280 | } |
| 4184 | 4281 | ||
| 4185 | if (codec_drv->compress_type) | ||
| 4186 | codec->compress_type = codec_drv->compress_type; | ||
| 4187 | else | ||
| 4188 | codec->compress_type = SND_SOC_FLAT_COMPRESSION; | ||
| 4189 | |||
| 4190 | codec->write = codec_drv->write; | 4282 | codec->write = codec_drv->write; |
| 4191 | codec->read = codec_drv->read; | 4283 | codec->read = codec_drv->read; |
| 4192 | codec->volatile_register = codec_drv->volatile_register; | 4284 | codec->volatile_register = codec_drv->volatile_register; |
| @@ -4203,35 +4295,6 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4203 | codec->num_dai = num_dai; | 4295 | codec->num_dai = num_dai; |
| 4204 | mutex_init(&codec->mutex); | 4296 | mutex_init(&codec->mutex); |
| 4205 | 4297 | ||
| 4206 | /* allocate CODEC register cache */ | ||
| 4207 | if (codec_drv->reg_cache_size && codec_drv->reg_word_size) { | ||
| 4208 | reg_size = codec_drv->reg_cache_size * codec_drv->reg_word_size; | ||
| 4209 | codec->reg_size = reg_size; | ||
| 4210 | /* it is necessary to make a copy of the default register cache | ||
| 4211 | * because in the case of using a compression type that requires | ||
| 4212 | * the default register cache to be marked as the | ||
| 4213 | * kernel might have freed the array by the time we initialize | ||
| 4214 | * the cache. | ||
| 4215 | */ | ||
| 4216 | if (codec_drv->reg_cache_default) { | ||
| 4217 | codec->reg_def_copy = kmemdup(codec_drv->reg_cache_default, | ||
| 4218 | reg_size, GFP_KERNEL); | ||
| 4219 | if (!codec->reg_def_copy) { | ||
| 4220 | ret = -ENOMEM; | ||
| 4221 | goto fail_codec_name; | ||
| 4222 | } | ||
| 4223 | } | ||
| 4224 | } | ||
| 4225 | |||
| 4226 | if (codec_drv->reg_access_size && codec_drv->reg_access_default) { | ||
| 4227 | if (!codec->volatile_register) | ||
| 4228 | codec->volatile_register = snd_soc_default_volatile_register; | ||
| 4229 | if (!codec->readable_register) | ||
| 4230 | codec->readable_register = snd_soc_default_readable_register; | ||
| 4231 | if (!codec->writable_register) | ||
| 4232 | codec->writable_register = snd_soc_default_writable_register; | ||
| 4233 | } | ||
| 4234 | |||
| 4235 | for (i = 0; i < num_dai; i++) { | 4298 | for (i = 0; i < num_dai; i++) { |
| 4236 | fixup_codec_formats(&dai_drv[i].playback); | 4299 | fixup_codec_formats(&dai_drv[i].playback); |
| 4237 | fixup_codec_formats(&dai_drv[i].capture); | 4300 | fixup_codec_formats(&dai_drv[i].capture); |
| @@ -4241,10 +4304,12 @@ int snd_soc_register_codec(struct device *dev, | |||
| 4241 | list_add(&codec->list, &codec_list); | 4304 | list_add(&codec->list, &codec_list); |
| 4242 | mutex_unlock(&client_mutex); | 4305 | mutex_unlock(&client_mutex); |
| 4243 | 4306 | ||
| 4244 | /* register any DAIs */ | 4307 | /* register component */ |
| 4245 | ret = snd_soc_register_dais(dev, dai_drv, num_dai); | 4308 | ret = __snd_soc_register_component(dev, &codec->component, |
| 4309 | &codec_drv->component_driver, | ||
| 4310 | dai_drv, num_dai, false); | ||
| 4246 | if (ret < 0) { | 4311 | if (ret < 0) { |
| 4247 | dev_err(codec->dev, "ASoC: Failed to regster DAIs: %d\n", ret); | 4312 | dev_err(codec->dev, "ASoC: Failed to regster component: %d\n", ret); |
| 4248 | goto fail_codec_name; | 4313 | goto fail_codec_name; |
| 4249 | } | 4314 | } |
| 4250 | 4315 | ||
| @@ -4279,7 +4344,7 @@ void snd_soc_unregister_codec(struct device *dev) | |||
| 4279 | return; | 4344 | return; |
| 4280 | 4345 | ||
| 4281 | found: | 4346 | found: |
| 4282 | snd_soc_unregister_dais(dev, codec->num_dai); | 4347 | snd_soc_unregister_component(dev); |
| 4283 | 4348 | ||
| 4284 | mutex_lock(&client_mutex); | 4349 | mutex_lock(&client_mutex); |
| 4285 | list_del(&codec->list); | 4350 | list_del(&codec->list); |
| @@ -4288,98 +4353,11 @@ found: | |||
| 4288 | dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name); | 4353 | dev_dbg(codec->dev, "ASoC: Unregistered codec '%s'\n", codec->name); |
| 4289 | 4354 | ||
| 4290 | snd_soc_cache_exit(codec); | 4355 | snd_soc_cache_exit(codec); |
| 4291 | kfree(codec->reg_def_copy); | ||
| 4292 | kfree(codec->name); | 4356 | kfree(codec->name); |
| 4293 | kfree(codec); | 4357 | kfree(codec); |
| 4294 | } | 4358 | } |
| 4295 | EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); | 4359 | EXPORT_SYMBOL_GPL(snd_soc_unregister_codec); |
| 4296 | 4360 | ||
| 4297 | |||
| 4298 | /** | ||
| 4299 | * snd_soc_register_component - Register a component with the ASoC core | ||
| 4300 | * | ||
| 4301 | */ | ||
| 4302 | int snd_soc_register_component(struct device *dev, | ||
| 4303 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 4304 | struct snd_soc_dai_driver *dai_drv, | ||
| 4305 | int num_dai) | ||
| 4306 | { | ||
| 4307 | struct snd_soc_component *cmpnt; | ||
| 4308 | int ret; | ||
| 4309 | |||
| 4310 | dev_dbg(dev, "component register %s\n", dev_name(dev)); | ||
| 4311 | |||
| 4312 | cmpnt = devm_kzalloc(dev, sizeof(*cmpnt), GFP_KERNEL); | ||
| 4313 | if (!cmpnt) { | ||
| 4314 | dev_err(dev, "ASoC: Failed to allocate memory\n"); | ||
| 4315 | return -ENOMEM; | ||
| 4316 | } | ||
| 4317 | |||
| 4318 | cmpnt->name = fmt_single_name(dev, &cmpnt->id); | ||
| 4319 | if (!cmpnt->name) { | ||
| 4320 | dev_err(dev, "ASoC: Failed to simplifying name\n"); | ||
| 4321 | return -ENOMEM; | ||
| 4322 | } | ||
| 4323 | |||
| 4324 | cmpnt->dev = dev; | ||
| 4325 | cmpnt->driver = cmpnt_drv; | ||
| 4326 | cmpnt->num_dai = num_dai; | ||
| 4327 | |||
| 4328 | /* | ||
| 4329 | * snd_soc_register_dai() uses fmt_single_name(), and | ||
| 4330 | * snd_soc_register_dais() uses fmt_multiple_name() | ||
| 4331 | * for dai->name which is used for name based matching | ||
| 4332 | */ | ||
| 4333 | if (1 == num_dai) | ||
| 4334 | ret = snd_soc_register_dai(dev, dai_drv); | ||
| 4335 | else | ||
| 4336 | ret = snd_soc_register_dais(dev, dai_drv, num_dai); | ||
| 4337 | if (ret < 0) { | ||
| 4338 | dev_err(dev, "ASoC: Failed to regster DAIs: %d\n", ret); | ||
| 4339 | goto error_component_name; | ||
| 4340 | } | ||
| 4341 | |||
| 4342 | mutex_lock(&client_mutex); | ||
| 4343 | list_add(&cmpnt->list, &component_list); | ||
| 4344 | mutex_unlock(&client_mutex); | ||
| 4345 | |||
| 4346 | dev_dbg(cmpnt->dev, "ASoC: Registered component '%s'\n", cmpnt->name); | ||
| 4347 | |||
| 4348 | return ret; | ||
| 4349 | |||
| 4350 | error_component_name: | ||
| 4351 | kfree(cmpnt->name); | ||
| 4352 | |||
| 4353 | return ret; | ||
| 4354 | } | ||
| 4355 | EXPORT_SYMBOL_GPL(snd_soc_register_component); | ||
| 4356 | |||
| 4357 | /** | ||
| 4358 | * snd_soc_unregister_component - Unregister a component from the ASoC core | ||
| 4359 | * | ||
| 4360 | */ | ||
| 4361 | void snd_soc_unregister_component(struct device *dev) | ||
| 4362 | { | ||
| 4363 | struct snd_soc_component *cmpnt; | ||
| 4364 | |||
| 4365 | list_for_each_entry(cmpnt, &component_list, list) { | ||
| 4366 | if (dev == cmpnt->dev) | ||
| 4367 | goto found; | ||
| 4368 | } | ||
| 4369 | return; | ||
| 4370 | |||
| 4371 | found: | ||
| 4372 | snd_soc_unregister_dais(dev, cmpnt->num_dai); | ||
| 4373 | |||
| 4374 | mutex_lock(&client_mutex); | ||
| 4375 | list_del(&cmpnt->list); | ||
| 4376 | mutex_unlock(&client_mutex); | ||
| 4377 | |||
| 4378 | dev_dbg(dev, "ASoC: Unregistered component '%s'\n", cmpnt->name); | ||
| 4379 | kfree(cmpnt->name); | ||
| 4380 | } | ||
| 4381 | EXPORT_SYMBOL_GPL(snd_soc_unregister_component); | ||
| 4382 | |||
| 4383 | /* Retrieve a card's name from device tree */ | 4361 | /* Retrieve a card's name from device tree */ |
| 4384 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, | 4362 | int snd_soc_of_parse_card_name(struct snd_soc_card *card, |
| 4385 | const char *propname) | 4363 | const char *propname) |
| @@ -4567,6 +4545,60 @@ unsigned int snd_soc_of_parse_daifmt(struct device_node *np, | |||
| 4567 | } | 4545 | } |
| 4568 | EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); | 4546 | EXPORT_SYMBOL_GPL(snd_soc_of_parse_daifmt); |
| 4569 | 4547 | ||
| 4548 | int snd_soc_of_get_dai_name(struct device_node *of_node, | ||
| 4549 | const char **dai_name) | ||
| 4550 | { | ||
| 4551 | struct snd_soc_component *pos; | ||
| 4552 | struct of_phandle_args args; | ||
| 4553 | int ret; | ||
| 4554 | |||
| 4555 | ret = of_parse_phandle_with_args(of_node, "sound-dai", | ||
| 4556 | "#sound-dai-cells", 0, &args); | ||
| 4557 | if (ret) | ||
| 4558 | return ret; | ||
| 4559 | |||
| 4560 | ret = -EPROBE_DEFER; | ||
| 4561 | |||
| 4562 | mutex_lock(&client_mutex); | ||
| 4563 | list_for_each_entry(pos, &component_list, list) { | ||
| 4564 | if (pos->dev->of_node != args.np) | ||
| 4565 | continue; | ||
| 4566 | |||
| 4567 | if (pos->driver->of_xlate_dai_name) { | ||
| 4568 | ret = pos->driver->of_xlate_dai_name(pos, &args, dai_name); | ||
| 4569 | } else { | ||
| 4570 | int id = -1; | ||
| 4571 | |||
| 4572 | switch (args.args_count) { | ||
| 4573 | case 0: | ||
| 4574 | id = 0; /* same as dai_drv[0] */ | ||
| 4575 | break; | ||
| 4576 | case 1: | ||
| 4577 | id = args.args[0]; | ||
| 4578 | break; | ||
| 4579 | default: | ||
| 4580 | /* not supported */ | ||
| 4581 | break; | ||
| 4582 | } | ||
| 4583 | |||
| 4584 | if (id < 0 || id >= pos->num_dai) { | ||
| 4585 | ret = -EINVAL; | ||
| 4586 | } else { | ||
| 4587 | *dai_name = pos->dai_drv[id].name; | ||
| 4588 | ret = 0; | ||
| 4589 | } | ||
| 4590 | } | ||
| 4591 | |||
| 4592 | break; | ||
| 4593 | } | ||
| 4594 | mutex_unlock(&client_mutex); | ||
| 4595 | |||
| 4596 | of_node_put(args.np); | ||
| 4597 | |||
| 4598 | return ret; | ||
| 4599 | } | ||
| 4600 | EXPORT_SYMBOL_GPL(snd_soc_of_get_dai_name); | ||
| 4601 | |||
| 4570 | static int __init snd_soc_init(void) | 4602 | static int __init snd_soc_init(void) |
| 4571 | { | 4603 | { |
| 4572 | #ifdef CONFIG_DEBUG_FS | 4604 | #ifdef CONFIG_DEBUG_FS |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index c17c14c394df..2fb0b72d8a3c 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -59,31 +59,31 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, | |||
| 59 | /* dapm power sequences - make this per codec in the future */ | 59 | /* dapm power sequences - make this per codec in the future */ |
| 60 | static int dapm_up_seq[] = { | 60 | static int dapm_up_seq[] = { |
| 61 | [snd_soc_dapm_pre] = 0, | 61 | [snd_soc_dapm_pre] = 0, |
| 62 | [snd_soc_dapm_supply] = 1, | ||
| 63 | [snd_soc_dapm_regulator_supply] = 1, | 62 | [snd_soc_dapm_regulator_supply] = 1, |
| 64 | [snd_soc_dapm_clock_supply] = 1, | 63 | [snd_soc_dapm_clock_supply] = 1, |
| 65 | [snd_soc_dapm_micbias] = 2, | 64 | [snd_soc_dapm_supply] = 2, |
| 65 | [snd_soc_dapm_micbias] = 3, | ||
| 66 | [snd_soc_dapm_dai_link] = 2, | 66 | [snd_soc_dapm_dai_link] = 2, |
| 67 | [snd_soc_dapm_dai_in] = 3, | 67 | [snd_soc_dapm_dai_in] = 4, |
| 68 | [snd_soc_dapm_dai_out] = 3, | 68 | [snd_soc_dapm_dai_out] = 4, |
| 69 | [snd_soc_dapm_aif_in] = 3, | 69 | [snd_soc_dapm_aif_in] = 4, |
| 70 | [snd_soc_dapm_aif_out] = 3, | 70 | [snd_soc_dapm_aif_out] = 4, |
| 71 | [snd_soc_dapm_mic] = 4, | 71 | [snd_soc_dapm_mic] = 5, |
| 72 | [snd_soc_dapm_mux] = 5, | 72 | [snd_soc_dapm_mux] = 6, |
| 73 | [snd_soc_dapm_virt_mux] = 5, | 73 | [snd_soc_dapm_virt_mux] = 6, |
| 74 | [snd_soc_dapm_value_mux] = 5, | 74 | [snd_soc_dapm_value_mux] = 6, |
| 75 | [snd_soc_dapm_dac] = 6, | 75 | [snd_soc_dapm_dac] = 7, |
| 76 | [snd_soc_dapm_switch] = 7, | 76 | [snd_soc_dapm_switch] = 8, |
| 77 | [snd_soc_dapm_mixer] = 7, | 77 | [snd_soc_dapm_mixer] = 8, |
| 78 | [snd_soc_dapm_mixer_named_ctl] = 7, | 78 | [snd_soc_dapm_mixer_named_ctl] = 8, |
| 79 | [snd_soc_dapm_pga] = 8, | 79 | [snd_soc_dapm_pga] = 9, |
| 80 | [snd_soc_dapm_adc] = 9, | 80 | [snd_soc_dapm_adc] = 10, |
| 81 | [snd_soc_dapm_out_drv] = 10, | 81 | [snd_soc_dapm_out_drv] = 11, |
| 82 | [snd_soc_dapm_hp] = 10, | 82 | [snd_soc_dapm_hp] = 11, |
| 83 | [snd_soc_dapm_spk] = 10, | 83 | [snd_soc_dapm_spk] = 11, |
| 84 | [snd_soc_dapm_line] = 10, | 84 | [snd_soc_dapm_line] = 11, |
| 85 | [snd_soc_dapm_kcontrol] = 11, | 85 | [snd_soc_dapm_kcontrol] = 12, |
| 86 | [snd_soc_dapm_post] = 12, | 86 | [snd_soc_dapm_post] = 13, |
| 87 | }; | 87 | }; |
| 88 | 88 | ||
| 89 | static int dapm_down_seq[] = { | 89 | static int dapm_down_seq[] = { |
| @@ -109,10 +109,10 @@ static int dapm_down_seq[] = { | |||
| 109 | [snd_soc_dapm_dai_in] = 10, | 109 | [snd_soc_dapm_dai_in] = 10, |
| 110 | [snd_soc_dapm_dai_out] = 10, | 110 | [snd_soc_dapm_dai_out] = 10, |
| 111 | [snd_soc_dapm_dai_link] = 11, | 111 | [snd_soc_dapm_dai_link] = 11, |
| 112 | [snd_soc_dapm_clock_supply] = 12, | ||
| 113 | [snd_soc_dapm_regulator_supply] = 12, | ||
| 114 | [snd_soc_dapm_supply] = 12, | 112 | [snd_soc_dapm_supply] = 12, |
| 115 | [snd_soc_dapm_post] = 13, | 113 | [snd_soc_dapm_clock_supply] = 13, |
| 114 | [snd_soc_dapm_regulator_supply] = 13, | ||
| 115 | [snd_soc_dapm_post] = 14, | ||
| 116 | }; | 116 | }; |
| 117 | 117 | ||
| 118 | static void pop_wait(u32 pop_time) | 118 | static void pop_wait(u32 pop_time) |
| @@ -409,6 +409,12 @@ static inline void soc_widget_unlock(struct snd_soc_dapm_widget *w) | |||
| 409 | mutex_unlock(&w->platform->mutex); | 409 | mutex_unlock(&w->platform->mutex); |
| 410 | } | 410 | } |
| 411 | 411 | ||
| 412 | static void soc_dapm_async_complete(struct snd_soc_dapm_context *dapm) | ||
| 413 | { | ||
| 414 | if (dapm->codec && dapm->codec->using_regmap) | ||
| 415 | regmap_async_complete(dapm->codec->control_data); | ||
| 416 | } | ||
| 417 | |||
| 412 | static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, | 418 | static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, |
| 413 | unsigned short reg, unsigned int mask, unsigned int value) | 419 | unsigned short reg, unsigned int mask, unsigned int value) |
| 414 | { | 420 | { |
| @@ -417,8 +423,9 @@ static int soc_widget_update_bits_locked(struct snd_soc_dapm_widget *w, | |||
| 417 | int ret; | 423 | int ret; |
| 418 | 424 | ||
| 419 | if (w->codec && w->codec->using_regmap) { | 425 | if (w->codec && w->codec->using_regmap) { |
| 420 | ret = regmap_update_bits_check(w->codec->control_data, | 426 | ret = regmap_update_bits_check_async(w->codec->control_data, |
| 421 | reg, mask, value, &change); | 427 | reg, mask, value, |
| 428 | &change); | ||
| 422 | if (ret != 0) | 429 | if (ret != 0) |
| 423 | return ret; | 430 | return ret; |
| 424 | } else { | 431 | } else { |
| @@ -499,18 +506,22 @@ static void dapm_set_path_status(struct snd_soc_dapm_widget *w, | |||
| 499 | int val; | 506 | int val; |
| 500 | struct soc_mixer_control *mc = (struct soc_mixer_control *) | 507 | struct soc_mixer_control *mc = (struct soc_mixer_control *) |
| 501 | w->kcontrol_news[i].private_value; | 508 | w->kcontrol_news[i].private_value; |
| 502 | unsigned int reg = mc->reg; | 509 | int reg = mc->reg; |
| 503 | unsigned int shift = mc->shift; | 510 | unsigned int shift = mc->shift; |
| 504 | int max = mc->max; | 511 | int max = mc->max; |
| 505 | unsigned int mask = (1 << fls(max)) - 1; | 512 | unsigned int mask = (1 << fls(max)) - 1; |
| 506 | unsigned int invert = mc->invert; | 513 | unsigned int invert = mc->invert; |
| 507 | 514 | ||
| 508 | val = soc_widget_read(w, reg); | 515 | if (reg != SND_SOC_NOPM) { |
| 509 | val = (val >> shift) & mask; | 516 | val = soc_widget_read(w, reg); |
| 510 | if (invert) | 517 | val = (val >> shift) & mask; |
| 511 | val = max - val; | 518 | if (invert) |
| 519 | val = max - val; | ||
| 520 | p->connect = !!val; | ||
| 521 | } else { | ||
| 522 | p->connect = 0; | ||
| 523 | } | ||
| 512 | 524 | ||
| 513 | p->connect = !!val; | ||
| 514 | } | 525 | } |
| 515 | break; | 526 | break; |
| 516 | case snd_soc_dapm_mux: { | 527 | case snd_soc_dapm_mux: { |
| @@ -1197,6 +1208,8 @@ int dapm_regulator_event(struct snd_soc_dapm_widget *w, | |||
| 1197 | { | 1208 | { |
| 1198 | int ret; | 1209 | int ret; |
| 1199 | 1210 | ||
| 1211 | soc_dapm_async_complete(w->dapm); | ||
| 1212 | |||
| 1200 | if (SND_SOC_DAPM_EVENT_ON(event)) { | 1213 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 1201 | if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { | 1214 | if (w->on_val & SND_SOC_DAPM_REGULATOR_BYPASS) { |
| 1202 | ret = regulator_allow_bypass(w->regulator, false); | 1215 | ret = regulator_allow_bypass(w->regulator, false); |
| @@ -1230,6 +1243,8 @@ int dapm_clock_event(struct snd_soc_dapm_widget *w, | |||
| 1230 | if (!w->clk) | 1243 | if (!w->clk) |
| 1231 | return -EIO; | 1244 | return -EIO; |
| 1232 | 1245 | ||
| 1246 | soc_dapm_async_complete(w->dapm); | ||
| 1247 | |||
| 1233 | #ifdef CONFIG_HAVE_CLK | 1248 | #ifdef CONFIG_HAVE_CLK |
| 1234 | if (SND_SOC_DAPM_EVENT_ON(event)) { | 1249 | if (SND_SOC_DAPM_EVENT_ON(event)) { |
| 1235 | return clk_prepare_enable(w->clk); | 1250 | return clk_prepare_enable(w->clk); |
| @@ -1422,6 +1437,7 @@ static void dapm_seq_check_event(struct snd_soc_card *card, | |||
| 1422 | if (w->event && (w->event_flags & event)) { | 1437 | if (w->event && (w->event_flags & event)) { |
| 1423 | pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", | 1438 | pop_dbg(w->dapm->dev, card->pop_time, "pop test : %s %s\n", |
| 1424 | w->name, ev_name); | 1439 | w->name, ev_name); |
| 1440 | soc_dapm_async_complete(w->dapm); | ||
| 1425 | trace_snd_soc_dapm_widget_event_start(w, event); | 1441 | trace_snd_soc_dapm_widget_event_start(w, event); |
| 1426 | ret = w->event(w, NULL, event); | 1442 | ret = w->event(w, NULL, event); |
| 1427 | trace_snd_soc_dapm_widget_event_done(w, event); | 1443 | trace_snd_soc_dapm_widget_event_done(w, event); |
| @@ -1494,6 +1510,7 @@ static void dapm_seq_run(struct snd_soc_card *card, | |||
| 1494 | struct list_head *list, int event, bool power_up) | 1510 | struct list_head *list, int event, bool power_up) |
| 1495 | { | 1511 | { |
| 1496 | struct snd_soc_dapm_widget *w, *n; | 1512 | struct snd_soc_dapm_widget *w, *n; |
| 1513 | struct snd_soc_dapm_context *d; | ||
| 1497 | LIST_HEAD(pending); | 1514 | LIST_HEAD(pending); |
| 1498 | int cur_sort = -1; | 1515 | int cur_sort = -1; |
| 1499 | int cur_subseq = -1; | 1516 | int cur_subseq = -1; |
| @@ -1524,6 +1541,9 @@ static void dapm_seq_run(struct snd_soc_card *card, | |||
| 1524 | cur_subseq); | 1541 | cur_subseq); |
| 1525 | } | 1542 | } |
| 1526 | 1543 | ||
| 1544 | if (cur_dapm && w->dapm != cur_dapm) | ||
| 1545 | soc_dapm_async_complete(cur_dapm); | ||
| 1546 | |||
| 1527 | INIT_LIST_HEAD(&pending); | 1547 | INIT_LIST_HEAD(&pending); |
| 1528 | cur_sort = -1; | 1548 | cur_sort = -1; |
| 1529 | cur_subseq = INT_MIN; | 1549 | cur_subseq = INT_MIN; |
| @@ -1582,6 +1602,10 @@ static void dapm_seq_run(struct snd_soc_card *card, | |||
| 1582 | cur_dapm->seq_notifier(cur_dapm, | 1602 | cur_dapm->seq_notifier(cur_dapm, |
| 1583 | i, cur_subseq); | 1603 | i, cur_subseq); |
| 1584 | } | 1604 | } |
| 1605 | |||
| 1606 | list_for_each_entry(d, &card->dapm_list, list) { | ||
| 1607 | soc_dapm_async_complete(d); | ||
| 1608 | } | ||
| 1585 | } | 1609 | } |
| 1586 | 1610 | ||
| 1587 | static void dapm_widget_update(struct snd_soc_card *card) | 1611 | static void dapm_widget_update(struct snd_soc_card *card) |
| @@ -1840,6 +1864,7 @@ static int dapm_power_widgets(struct snd_soc_card *card, int event) | |||
| 1840 | */ | 1864 | */ |
| 1841 | switch (w->id) { | 1865 | switch (w->id) { |
| 1842 | case snd_soc_dapm_siggen: | 1866 | case snd_soc_dapm_siggen: |
| 1867 | case snd_soc_dapm_vmid: | ||
| 1843 | break; | 1868 | break; |
| 1844 | case snd_soc_dapm_supply: | 1869 | case snd_soc_dapm_supply: |
| 1845 | case snd_soc_dapm_regulator_supply: | 1870 | case snd_soc_dapm_regulator_supply: |
| @@ -2791,7 +2816,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |||
| 2791 | struct snd_soc_card *card = codec->card; | 2816 | struct snd_soc_card *card = codec->card; |
| 2792 | struct soc_mixer_control *mc = | 2817 | struct soc_mixer_control *mc = |
| 2793 | (struct soc_mixer_control *)kcontrol->private_value; | 2818 | (struct soc_mixer_control *)kcontrol->private_value; |
| 2794 | unsigned int reg = mc->reg; | 2819 | int reg = mc->reg; |
| 2795 | unsigned int shift = mc->shift; | 2820 | unsigned int shift = mc->shift; |
| 2796 | int max = mc->max; | 2821 | int max = mc->max; |
| 2797 | unsigned int mask = (1 << fls(max)) - 1; | 2822 | unsigned int mask = (1 << fls(max)) - 1; |
| @@ -2804,7 +2829,7 @@ int snd_soc_dapm_get_volsw(struct snd_kcontrol *kcontrol, | |||
| 2804 | kcontrol->id.name); | 2829 | kcontrol->id.name); |
| 2805 | 2830 | ||
| 2806 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); | 2831 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); |
| 2807 | if (dapm_kcontrol_is_powered(kcontrol)) | 2832 | if (dapm_kcontrol_is_powered(kcontrol) && reg != SND_SOC_NOPM) |
| 2808 | val = (snd_soc_read(codec, reg) >> shift) & mask; | 2833 | val = (snd_soc_read(codec, reg) >> shift) & mask; |
| 2809 | else | 2834 | else |
| 2810 | val = dapm_kcontrol_get_value(kcontrol); | 2835 | val = dapm_kcontrol_get_value(kcontrol); |
| @@ -2835,7 +2860,7 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
| 2835 | struct snd_soc_card *card = codec->card; | 2860 | struct snd_soc_card *card = codec->card; |
| 2836 | struct soc_mixer_control *mc = | 2861 | struct soc_mixer_control *mc = |
| 2837 | (struct soc_mixer_control *)kcontrol->private_value; | 2862 | (struct soc_mixer_control *)kcontrol->private_value; |
| 2838 | unsigned int reg = mc->reg; | 2863 | int reg = mc->reg; |
| 2839 | unsigned int shift = mc->shift; | 2864 | unsigned int shift = mc->shift; |
| 2840 | int max = mc->max; | 2865 | int max = mc->max; |
| 2841 | unsigned int mask = (1 << fls(max)) - 1; | 2866 | unsigned int mask = (1 << fls(max)) - 1; |
| @@ -2857,19 +2882,24 @@ int snd_soc_dapm_put_volsw(struct snd_kcontrol *kcontrol, | |||
| 2857 | 2882 | ||
| 2858 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); | 2883 | mutex_lock_nested(&card->dapm_mutex, SND_SOC_DAPM_CLASS_RUNTIME); |
| 2859 | 2884 | ||
| 2860 | dapm_kcontrol_set_value(kcontrol, val); | 2885 | change = dapm_kcontrol_set_value(kcontrol, val); |
| 2886 | |||
| 2887 | if (reg != SND_SOC_NOPM) { | ||
| 2888 | mask = mask << shift; | ||
| 2889 | val = val << shift; | ||
| 2861 | 2890 | ||
| 2862 | mask = mask << shift; | 2891 | change = snd_soc_test_bits(codec, reg, mask, val); |
| 2863 | val = val << shift; | 2892 | } |
| 2864 | 2893 | ||
| 2865 | change = snd_soc_test_bits(codec, reg, mask, val); | ||
| 2866 | if (change) { | 2894 | if (change) { |
| 2867 | update.kcontrol = kcontrol; | 2895 | if (reg != SND_SOC_NOPM) { |
| 2868 | update.reg = reg; | 2896 | update.kcontrol = kcontrol; |
| 2869 | update.mask = mask; | 2897 | update.reg = reg; |
| 2870 | update.val = val; | 2898 | update.mask = mask; |
| 2899 | update.val = val; | ||
| 2871 | 2900 | ||
| 2872 | card->update = &update; | 2901 | card->update = &update; |
| 2902 | } | ||
| 2873 | 2903 | ||
| 2874 | soc_dapm_mixer_update_power(card, kcontrol, connect); | 2904 | soc_dapm_mixer_update_power(card, kcontrol, connect); |
| 2875 | 2905 | ||
diff --git a/sound/soc/soc-devres.c b/sound/soc/soc-devres.c new file mode 100644 index 000000000000..b1d732255c02 --- /dev/null +++ b/sound/soc/soc-devres.c | |||
| @@ -0,0 +1,86 @@ | |||
| 1 | /* | ||
| 2 | * soc-devres.c -- ALSA SoC Audio Layer devres functions | ||
| 3 | * | ||
| 4 | * Copyright (C) 2013 Linaro Ltd | ||
| 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 <sound/soc.h> | ||
| 15 | |||
| 16 | static void devm_component_release(struct device *dev, void *res) | ||
| 17 | { | ||
| 18 | snd_soc_unregister_component(*(struct device **)res); | ||
| 19 | } | ||
| 20 | |||
| 21 | /** | ||
| 22 | * devm_snd_soc_register_component - resource managed component registration | ||
| 23 | * @dev: Device used to manage component | ||
| 24 | * @cmpnt_drv: Component driver | ||
| 25 | * @dai_drv: DAI driver | ||
| 26 | * @num_dai: Number of DAIs to register | ||
| 27 | * | ||
| 28 | * Register a component with automatic unregistration when the device is | ||
| 29 | * unregistered. | ||
| 30 | */ | ||
| 31 | int devm_snd_soc_register_component(struct device *dev, | ||
| 32 | const struct snd_soc_component_driver *cmpnt_drv, | ||
| 33 | struct snd_soc_dai_driver *dai_drv, int num_dai) | ||
| 34 | { | ||
| 35 | struct device **ptr; | ||
| 36 | int ret; | ||
| 37 | |||
| 38 | ptr = devres_alloc(devm_component_release, sizeof(*ptr), GFP_KERNEL); | ||
| 39 | if (!ptr) | ||
| 40 | return -ENOMEM; | ||
| 41 | |||
| 42 | ret = snd_soc_register_component(dev, cmpnt_drv, dai_drv, num_dai); | ||
| 43 | if (ret == 0) { | ||
| 44 | *ptr = dev; | ||
| 45 | devres_add(dev, ptr); | ||
| 46 | } else { | ||
| 47 | devres_free(ptr); | ||
| 48 | } | ||
| 49 | |||
| 50 | return ret; | ||
| 51 | } | ||
| 52 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_component); | ||
| 53 | |||
| 54 | static void devm_card_release(struct device *dev, void *res) | ||
| 55 | { | ||
| 56 | snd_soc_unregister_card(*(struct snd_soc_card **)res); | ||
| 57 | } | ||
| 58 | |||
| 59 | /** | ||
| 60 | * devm_snd_soc_register_card - resource managed card registration | ||
| 61 | * @dev: Device used to manage card | ||
| 62 | * @card: Card to register | ||
| 63 | * | ||
| 64 | * Register a card with automatic unregistration when the device is | ||
| 65 | * unregistered. | ||
| 66 | */ | ||
| 67 | int devm_snd_soc_register_card(struct device *dev, struct snd_soc_card *card) | ||
| 68 | { | ||
| 69 | struct device **ptr; | ||
| 70 | int ret; | ||
| 71 | |||
| 72 | ptr = devres_alloc(devm_card_release, sizeof(*ptr), GFP_KERNEL); | ||
| 73 | if (!ptr) | ||
| 74 | return -ENOMEM; | ||
| 75 | |||
| 76 | ret = snd_soc_register_card(card); | ||
| 77 | if (ret == 0) { | ||
| 78 | *ptr = dev; | ||
| 79 | devres_add(dev, ptr); | ||
| 80 | } else { | ||
| 81 | devres_free(ptr); | ||
| 82 | } | ||
| 83 | |||
| 84 | return ret; | ||
| 85 | } | ||
| 86 | EXPORT_SYMBOL_GPL(devm_snd_soc_register_card); | ||
diff --git a/sound/soc/soc-generic-dmaengine-pcm.c b/sound/soc/soc-generic-dmaengine-pcm.c index e29ec3cd84b1..0c469cbbe881 100644 --- a/sound/soc/soc-generic-dmaengine-pcm.c +++ b/sound/soc/soc-generic-dmaengine-pcm.c | |||
| @@ -36,6 +36,15 @@ static struct dmaengine_pcm *soc_platform_to_pcm(struct snd_soc_platform *p) | |||
| 36 | return container_of(p, struct dmaengine_pcm, platform); | 36 | return container_of(p, struct dmaengine_pcm, platform); |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, | ||
| 40 | struct snd_pcm_substream *substream) | ||
| 41 | { | ||
| 42 | if (!pcm->chan[substream->stream]) | ||
| 43 | return NULL; | ||
| 44 | |||
| 45 | return pcm->chan[substream->stream]->device->dev; | ||
| 46 | } | ||
| 47 | |||
| 39 | /** | 48 | /** |
| 40 | * snd_dmaengine_pcm_prepare_slave_config() - Generic prepare_slave_config callback | 49 | * snd_dmaengine_pcm_prepare_slave_config() - Generic prepare_slave_config callback |
| 41 | * @substream: PCM substream | 50 | * @substream: PCM substream |
| @@ -75,12 +84,19 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 75 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 84 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 76 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); | 85 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); |
| 77 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); | 86 | struct dma_chan *chan = snd_dmaengine_pcm_get_chan(substream); |
| 87 | int (*prepare_slave_config)(struct snd_pcm_substream *substream, | ||
| 88 | struct snd_pcm_hw_params *params, | ||
| 89 | struct dma_slave_config *slave_config); | ||
| 78 | struct dma_slave_config slave_config; | 90 | struct dma_slave_config slave_config; |
| 79 | int ret; | 91 | int ret; |
| 80 | 92 | ||
| 81 | if (pcm->config->prepare_slave_config) { | 93 | if (!pcm->config) |
| 82 | ret = pcm->config->prepare_slave_config(substream, params, | 94 | prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config; |
| 83 | &slave_config); | 95 | else |
| 96 | prepare_slave_config = pcm->config->prepare_slave_config; | ||
| 97 | |||
| 98 | if (prepare_slave_config) { | ||
| 99 | ret = prepare_slave_config(substream, params, &slave_config); | ||
| 84 | if (ret) | 100 | if (ret) |
| 85 | return ret; | 101 | return ret; |
| 86 | 102 | ||
| @@ -92,28 +108,54 @@ static int dmaengine_pcm_hw_params(struct snd_pcm_substream *substream, | |||
| 92 | return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); | 108 | return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(params)); |
| 93 | } | 109 | } |
| 94 | 110 | ||
| 95 | static int dmaengine_pcm_open(struct snd_pcm_substream *substream) | 111 | static int dmaengine_pcm_set_runtime_hwparams(struct snd_pcm_substream *substream) |
| 96 | { | 112 | { |
| 97 | struct snd_soc_pcm_runtime *rtd = substream->private_data; | 113 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 98 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); | 114 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); |
| 115 | struct device *dma_dev = dmaengine_dma_dev(pcm, substream); | ||
| 99 | struct dma_chan *chan = pcm->chan[substream->stream]; | 116 | struct dma_chan *chan = pcm->chan[substream->stream]; |
| 117 | struct snd_dmaengine_dai_dma_data *dma_data; | ||
| 118 | struct dma_slave_caps dma_caps; | ||
| 119 | struct snd_pcm_hardware hw; | ||
| 100 | int ret; | 120 | int ret; |
| 101 | 121 | ||
| 102 | ret = snd_soc_set_runtime_hwparams(substream, | 122 | if (pcm->config && pcm->config->pcm_hardware) |
| 123 | return snd_soc_set_runtime_hwparams(substream, | ||
| 103 | pcm->config->pcm_hardware); | 124 | pcm->config->pcm_hardware); |
| 104 | if (ret) | ||
| 105 | return ret; | ||
| 106 | 125 | ||
| 107 | return snd_dmaengine_pcm_open(substream, chan); | 126 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); |
| 127 | |||
| 128 | memset(&hw, 0, sizeof(hw)); | ||
| 129 | hw.info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID | | ||
| 130 | SNDRV_PCM_INFO_INTERLEAVED; | ||
| 131 | hw.periods_min = 2; | ||
| 132 | hw.periods_max = UINT_MAX; | ||
| 133 | hw.period_bytes_min = 256; | ||
| 134 | hw.period_bytes_max = dma_get_max_seg_size(dma_dev); | ||
| 135 | hw.buffer_bytes_max = SIZE_MAX; | ||
| 136 | hw.fifo_size = dma_data->fifo_size; | ||
| 137 | |||
| 138 | ret = dma_get_slave_caps(chan, &dma_caps); | ||
| 139 | if (ret == 0) { | ||
| 140 | if (dma_caps.cmd_pause) | ||
| 141 | hw.info |= SNDRV_PCM_INFO_PAUSE | SNDRV_PCM_INFO_RESUME; | ||
| 142 | } | ||
| 143 | |||
| 144 | return snd_soc_set_runtime_hwparams(substream, &hw); | ||
| 108 | } | 145 | } |
| 109 | 146 | ||
| 110 | static struct device *dmaengine_dma_dev(struct dmaengine_pcm *pcm, | 147 | static int dmaengine_pcm_open(struct snd_pcm_substream *substream) |
| 111 | struct snd_pcm_substream *substream) | ||
| 112 | { | 148 | { |
| 113 | if (!pcm->chan[substream->stream]) | 149 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 114 | return NULL; | 150 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); |
| 151 | struct dma_chan *chan = pcm->chan[substream->stream]; | ||
| 152 | int ret; | ||
| 115 | 153 | ||
| 116 | return pcm->chan[substream->stream]->device->dev; | 154 | ret = dmaengine_pcm_set_runtime_hwparams(substream); |
| 155 | if (ret) | ||
| 156 | return ret; | ||
| 157 | |||
| 158 | return snd_dmaengine_pcm_open(substream, chan); | ||
| 117 | } | 159 | } |
| 118 | 160 | ||
| 119 | static void dmaengine_pcm_free(struct snd_pcm *pcm) | 161 | static void dmaengine_pcm_free(struct snd_pcm *pcm) |
| @@ -126,6 +168,9 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( | |||
| 126 | struct snd_pcm_substream *substream) | 168 | struct snd_pcm_substream *substream) |
| 127 | { | 169 | { |
| 128 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); | 170 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); |
| 171 | struct snd_dmaengine_dai_dma_data *dma_data; | ||
| 172 | |||
| 173 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 129 | 174 | ||
| 130 | if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0]) | 175 | if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) && pcm->chan[0]) |
| 131 | return pcm->chan[0]; | 176 | return pcm->chan[0]; |
| @@ -134,22 +179,42 @@ static struct dma_chan *dmaengine_pcm_compat_request_channel( | |||
| 134 | return pcm->config->compat_request_channel(rtd, substream); | 179 | return pcm->config->compat_request_channel(rtd, substream); |
| 135 | 180 | ||
| 136 | return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn, | 181 | return snd_dmaengine_pcm_request_channel(pcm->config->compat_filter_fn, |
| 137 | snd_soc_dai_get_dma_data(rtd->cpu_dai, substream)); | 182 | dma_data->filter_data); |
| 138 | } | 183 | } |
| 139 | 184 | ||
| 140 | static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) | 185 | static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) |
| 141 | { | 186 | { |
| 142 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); | 187 | struct dmaengine_pcm *pcm = soc_platform_to_pcm(rtd->platform); |
| 143 | const struct snd_dmaengine_pcm_config *config = pcm->config; | 188 | const struct snd_dmaengine_pcm_config *config = pcm->config; |
| 189 | struct device *dev = rtd->platform->dev; | ||
| 190 | struct snd_dmaengine_dai_dma_data *dma_data; | ||
| 144 | struct snd_pcm_substream *substream; | 191 | struct snd_pcm_substream *substream; |
| 192 | size_t prealloc_buffer_size; | ||
| 193 | size_t max_buffer_size; | ||
| 145 | unsigned int i; | 194 | unsigned int i; |
| 146 | int ret; | 195 | int ret; |
| 147 | 196 | ||
| 197 | if (config && config->prealloc_buffer_size) { | ||
| 198 | prealloc_buffer_size = config->prealloc_buffer_size; | ||
| 199 | max_buffer_size = config->pcm_hardware->buffer_bytes_max; | ||
| 200 | } else { | ||
| 201 | prealloc_buffer_size = 512 * 1024; | ||
| 202 | max_buffer_size = SIZE_MAX; | ||
| 203 | } | ||
| 204 | |||
| 205 | |||
| 148 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { | 206 | for (i = SNDRV_PCM_STREAM_PLAYBACK; i <= SNDRV_PCM_STREAM_CAPTURE; i++) { |
| 149 | substream = rtd->pcm->streams[i].substream; | 207 | substream = rtd->pcm->streams[i].substream; |
| 150 | if (!substream) | 208 | if (!substream) |
| 151 | continue; | 209 | continue; |
| 152 | 210 | ||
| 211 | dma_data = snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); | ||
| 212 | |||
| 213 | if (!pcm->chan[i] && | ||
| 214 | (pcm->flags & SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) | ||
| 215 | pcm->chan[i] = dma_request_slave_channel(dev, | ||
| 216 | dma_data->chan_name); | ||
| 217 | |||
| 153 | if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) { | 218 | if (!pcm->chan[i] && (pcm->flags & SND_DMAENGINE_PCM_FLAG_COMPAT)) { |
| 154 | pcm->chan[i] = dmaengine_pcm_compat_request_channel(rtd, | 219 | pcm->chan[i] = dmaengine_pcm_compat_request_channel(rtd, |
| 155 | substream); | 220 | substream); |
| @@ -165,8 +230,8 @@ static int dmaengine_pcm_new(struct snd_soc_pcm_runtime *rtd) | |||
| 165 | ret = snd_pcm_lib_preallocate_pages(substream, | 230 | ret = snd_pcm_lib_preallocate_pages(substream, |
| 166 | SNDRV_DMA_TYPE_DEV, | 231 | SNDRV_DMA_TYPE_DEV, |
| 167 | dmaengine_dma_dev(pcm, substream), | 232 | dmaengine_dma_dev(pcm, substream), |
| 168 | config->prealloc_buffer_size, | 233 | prealloc_buffer_size, |
| 169 | config->pcm_hardware->buffer_bytes_max); | 234 | max_buffer_size); |
| 170 | if (ret) | 235 | if (ret) |
| 171 | goto err_free; | 236 | goto err_free; |
| 172 | } | 237 | } |
| @@ -222,7 +287,9 @@ static void dmaengine_pcm_request_chan_of(struct dmaengine_pcm *pcm, | |||
| 222 | { | 287 | { |
| 223 | unsigned int i; | 288 | unsigned int i; |
| 224 | 289 | ||
| 225 | if ((pcm->flags & SND_DMAENGINE_PCM_FLAG_NO_DT) || !dev->of_node) | 290 | if ((pcm->flags & (SND_DMAENGINE_PCM_FLAG_NO_DT | |
| 291 | SND_DMAENGINE_PCM_FLAG_CUSTOM_CHANNEL_NAME)) || | ||
| 292 | !dev->of_node) | ||
| 226 | return; | 293 | return; |
| 227 | 294 | ||
| 228 | if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) { | 295 | if (pcm->flags & SND_DMAENGINE_PCM_FLAG_HALF_DUPLEX) { |
diff --git a/sound/soc/soc-io.c b/sound/soc/soc-io.c index 122c0c18b9dd..4f11d23f2062 100644 --- a/sound/soc/soc-io.c +++ b/sound/soc/soc-io.c | |||
| @@ -65,31 +65,6 @@ static unsigned int hw_read(struct snd_soc_codec *codec, unsigned int reg) | |||
| 65 | return val; | 65 | return val; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | /* Primitive bulk write support for soc-cache. The data pointed to by | ||
| 69 | * `data' needs to already be in the form the hardware expects. Any | ||
| 70 | * data written through this function will not go through the cache as | ||
| 71 | * it only handles writing to volatile or out of bounds registers. | ||
| 72 | * | ||
| 73 | * This is currently only supported for devices using the regmap API | ||
| 74 | * wrappers. | ||
| 75 | */ | ||
| 76 | static int snd_soc_hw_bulk_write_raw(struct snd_soc_codec *codec, | ||
| 77 | unsigned int reg, | ||
| 78 | const void *data, size_t len) | ||
| 79 | { | ||
| 80 | /* To ensure that we don't get out of sync with the cache, check | ||
| 81 | * whether the base register is volatile or if we've directly asked | ||
| 82 | * to bypass the cache. Out of bounds registers are considered | ||
| 83 | * volatile. | ||
| 84 | */ | ||
| 85 | if (!codec->cache_bypass | ||
| 86 | && !snd_soc_codec_volatile_register(codec, reg) | ||
| 87 | && reg < codec->driver->reg_cache_size) | ||
| 88 | return -EINVAL; | ||
| 89 | |||
| 90 | return regmap_raw_write(codec->control_data, reg, data, len); | ||
| 91 | } | ||
| 92 | |||
| 93 | /** | 68 | /** |
| 94 | * snd_soc_codec_set_cache_io: Set up standard I/O functions. | 69 | * snd_soc_codec_set_cache_io: Set up standard I/O functions. |
| 95 | * | 70 | * |
| @@ -119,7 +94,6 @@ int snd_soc_codec_set_cache_io(struct snd_soc_codec *codec, | |||
| 119 | memset(&config, 0, sizeof(config)); | 94 | memset(&config, 0, sizeof(config)); |
| 120 | codec->write = hw_write; | 95 | codec->write = hw_write; |
| 121 | codec->read = hw_read; | 96 | codec->read = hw_read; |
| 122 | codec->bulk_write_raw = snd_soc_hw_bulk_write_raw; | ||
| 123 | 97 | ||
| 124 | config.reg_bits = addr_bits; | 98 | config.reg_bits = addr_bits; |
| 125 | config.val_bits = data_bits; | 99 | config.val_bits = data_bits; |
diff --git a/sound/soc/soc-jack.c b/sound/soc/soc-jack.c index 71358e3b54d9..23d43dac91da 100644 --- a/sound/soc/soc-jack.c +++ b/sound/soc/soc-jack.c | |||
| @@ -65,6 +65,7 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | |||
| 65 | struct snd_soc_codec *codec; | 65 | struct snd_soc_codec *codec; |
| 66 | struct snd_soc_dapm_context *dapm; | 66 | struct snd_soc_dapm_context *dapm; |
| 67 | struct snd_soc_jack_pin *pin; | 67 | struct snd_soc_jack_pin *pin; |
| 68 | unsigned int sync = 0; | ||
| 68 | int enable; | 69 | int enable; |
| 69 | 70 | ||
| 70 | trace_snd_soc_jack_report(jack, mask, status); | 71 | trace_snd_soc_jack_report(jack, mask, status); |
| @@ -92,12 +93,16 @@ void snd_soc_jack_report(struct snd_soc_jack *jack, int status, int mask) | |||
| 92 | snd_soc_dapm_enable_pin(dapm, pin->pin); | 93 | snd_soc_dapm_enable_pin(dapm, pin->pin); |
| 93 | else | 94 | else |
| 94 | snd_soc_dapm_disable_pin(dapm, pin->pin); | 95 | snd_soc_dapm_disable_pin(dapm, pin->pin); |
| 96 | |||
| 97 | /* we need to sync for this case only */ | ||
| 98 | sync = 1; | ||
| 95 | } | 99 | } |
| 96 | 100 | ||
| 97 | /* Report before the DAPM sync to help users updating micbias status */ | 101 | /* Report before the DAPM sync to help users updating micbias status */ |
| 98 | blocking_notifier_call_chain(&jack->notifier, jack->status, jack); | 102 | blocking_notifier_call_chain(&jack->notifier, jack->status, jack); |
| 99 | 103 | ||
| 100 | snd_soc_dapm_sync(dapm); | 104 | if (sync) |
| 105 | snd_soc_dapm_sync(dapm); | ||
| 101 | 106 | ||
| 102 | snd_jack_report(jack->jack, jack->status); | 107 | snd_jack_report(jack->jack, jack->status); |
| 103 | 108 | ||
diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 330c9a6b5cb5..d4498723b375 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c | |||
| @@ -721,7 +721,7 @@ static int dpcm_be_connect(struct snd_soc_pcm_runtime *fe, | |||
| 721 | list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); | 721 | list_add(&dpcm->list_be, &fe->dpcm[stream].be_clients); |
| 722 | list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); | 722 | list_add(&dpcm->list_fe, &be->dpcm[stream].fe_clients); |
| 723 | 723 | ||
| 724 | dev_dbg(fe->dev, " connected new DPCM %s path %s %s %s\n", | 724 | dev_dbg(fe->dev, "connected new DPCM %s path %s %s %s\n", |
| 725 | stream ? "capture" : "playback", fe->dai_link->name, | 725 | stream ? "capture" : "playback", fe->dai_link->name, |
| 726 | stream ? "<-" : "->", be->dai_link->name); | 726 | stream ? "<-" : "->", be->dai_link->name); |
| 727 | 727 | ||
| @@ -749,7 +749,7 @@ static void dpcm_be_reparent(struct snd_soc_pcm_runtime *fe, | |||
| 749 | if (dpcm->fe == fe) | 749 | if (dpcm->fe == fe) |
| 750 | continue; | 750 | continue; |
| 751 | 751 | ||
| 752 | dev_dbg(fe->dev, " reparent %s path %s %s %s\n", | 752 | dev_dbg(fe->dev, "reparent %s path %s %s %s\n", |
| 753 | stream ? "capture" : "playback", | 753 | stream ? "capture" : "playback", |
| 754 | dpcm->fe->dai_link->name, | 754 | dpcm->fe->dai_link->name, |
| 755 | stream ? "<-" : "->", dpcm->be->dai_link->name); | 755 | stream ? "<-" : "->", dpcm->be->dai_link->name); |
| @@ -773,7 +773,7 @@ static void dpcm_be_disconnect(struct snd_soc_pcm_runtime *fe, int stream) | |||
| 773 | if (dpcm->state != SND_SOC_DPCM_LINK_STATE_FREE) | 773 | if (dpcm->state != SND_SOC_DPCM_LINK_STATE_FREE) |
| 774 | continue; | 774 | continue; |
| 775 | 775 | ||
| 776 | dev_dbg(fe->dev, " freed DSP %s path %s %s %s\n", | 776 | dev_dbg(fe->dev, "freed DSP %s path %s %s %s\n", |
| 777 | stream ? "capture" : "playback", fe->dai_link->name, | 777 | stream ? "capture" : "playback", fe->dai_link->name, |
| 778 | stream ? "<-" : "->", dpcm->be->dai_link->name); | 778 | stream ? "<-" : "->", dpcm->be->dai_link->name); |
| 779 | 779 | ||
| @@ -2116,7 +2116,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num) | |||
| 2116 | 2116 | ||
| 2117 | pcm->private_free = platform->driver->pcm_free; | 2117 | pcm->private_free = platform->driver->pcm_free; |
| 2118 | out: | 2118 | out: |
| 2119 | dev_info(rtd->card->dev, " %s <-> %s mapping ok\n", codec_dai->name, | 2119 | dev_info(rtd->card->dev, "%s <-> %s mapping ok\n", codec_dai->name, |
| 2120 | cpu_dai->name); | 2120 | cpu_dai->name); |
| 2121 | return ret; | 2121 | return ret; |
| 2122 | } | 2122 | } |
diff --git a/sound/soc/soc-utils.c b/sound/soc/soc-utils.c index 29b211e9c060..5e633659c1b3 100644 --- a/sound/soc/soc-utils.c +++ b/sound/soc/soc-utils.c | |||
| @@ -75,7 +75,11 @@ static const struct snd_pcm_hardware dummy_dma_hardware = { | |||
| 75 | 75 | ||
| 76 | static int dummy_dma_open(struct snd_pcm_substream *substream) | 76 | static int dummy_dma_open(struct snd_pcm_substream *substream) |
| 77 | { | 77 | { |
| 78 | snd_soc_set_runtime_hwparams(substream, &dummy_dma_hardware); | 78 | struct snd_soc_pcm_runtime *rtd = substream->private_data; |
| 79 | |||
| 80 | /* BE's dont need dummy params */ | ||
| 81 | if (!rtd->dai_link->no_pcm) | ||
| 82 | snd_soc_set_runtime_hwparams(substream, &dummy_dma_hardware); | ||
| 79 | 83 | ||
| 80 | return 0; | 84 | return 0; |
| 81 | } | 85 | } |
diff --git a/sound/soc/spear/spdif_in.c b/sound/soc/spear/spdif_in.c index 63acfeb4b69d..21a8c954af1c 100644 --- a/sound/soc/spear/spdif_in.c +++ b/sound/soc/spear/spdif_in.c | |||
| @@ -257,20 +257,12 @@ static int spdif_in_probe(struct platform_device *pdev) | |||
| 257 | return ret; | 257 | return ret; |
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | return snd_soc_register_component(&pdev->dev, &spdif_in_component, | 260 | return devm_snd_soc_register_component(&pdev->dev, &spdif_in_component, |
| 261 | &spdif_in_dai, 1); | 261 | &spdif_in_dai, 1); |
| 262 | } | ||
| 263 | |||
| 264 | static int spdif_in_remove(struct platform_device *pdev) | ||
| 265 | { | ||
| 266 | snd_soc_unregister_component(&pdev->dev); | ||
| 267 | |||
| 268 | return 0; | ||
| 269 | } | 262 | } |
| 270 | 263 | ||
| 271 | static struct platform_driver spdif_in_driver = { | 264 | static struct platform_driver spdif_in_driver = { |
| 272 | .probe = spdif_in_probe, | 265 | .probe = spdif_in_probe, |
| 273 | .remove = spdif_in_remove, | ||
| 274 | .driver = { | 266 | .driver = { |
| 275 | .name = "spdif-in", | 267 | .name = "spdif-in", |
| 276 | .owner = THIS_MODULE, | 268 | .owner = THIS_MODULE, |
diff --git a/sound/soc/spear/spdif_out.c b/sound/soc/spear/spdif_out.c index 2fdf68c98d22..b6ef6f78dc78 100644 --- a/sound/soc/spear/spdif_out.c +++ b/sound/soc/spear/spdif_out.c | |||
| @@ -280,7 +280,6 @@ static int spdif_out_probe(struct platform_device *pdev) | |||
| 280 | struct spdif_out_dev *host; | 280 | struct spdif_out_dev *host; |
| 281 | struct spear_spdif_platform_data *pdata; | 281 | struct spear_spdif_platform_data *pdata; |
| 282 | struct resource *res; | 282 | struct resource *res; |
| 283 | int ret; | ||
| 284 | 283 | ||
| 285 | host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); | 284 | host = devm_kzalloc(&pdev->dev, sizeof(*host), GFP_KERNEL); |
| 286 | if (!host) { | 285 | if (!host) { |
| @@ -307,16 +306,8 @@ static int spdif_out_probe(struct platform_device *pdev) | |||
| 307 | 306 | ||
| 308 | dev_set_drvdata(&pdev->dev, host); | 307 | dev_set_drvdata(&pdev->dev, host); |
| 309 | 308 | ||
| 310 | ret = snd_soc_register_component(&pdev->dev, &spdif_out_component, | 309 | return devm_snd_soc_register_component(&pdev->dev, &spdif_out_component, |
| 311 | &spdif_out_dai, 1); | 310 | &spdif_out_dai, 1); |
| 312 | return ret; | ||
| 313 | } | ||
| 314 | |||
| 315 | static int spdif_out_remove(struct platform_device *pdev) | ||
| 316 | { | ||
| 317 | snd_soc_unregister_component(&pdev->dev); | ||
| 318 | |||
| 319 | return 0; | ||
| 320 | } | 311 | } |
| 321 | 312 | ||
| 322 | #ifdef CONFIG_PM | 313 | #ifdef CONFIG_PM |
| @@ -357,7 +348,6 @@ static SIMPLE_DEV_PM_OPS(spdif_out_dev_pm_ops, spdif_out_suspend, \ | |||
| 357 | 348 | ||
| 358 | static struct platform_driver spdif_out_driver = { | 349 | static struct platform_driver spdif_out_driver = { |
| 359 | .probe = spdif_out_probe, | 350 | .probe = spdif_out_probe, |
| 360 | .remove = spdif_out_remove, | ||
| 361 | .driver = { | 351 | .driver = { |
| 362 | .name = "spdif-out", | 352 | .name = "spdif-out", |
| 363 | .owner = THIS_MODULE, | 353 | .owner = THIS_MODULE, |
diff --git a/sound/soc/tegra/tegra30_ahub.c b/sound/soc/tegra/tegra30_ahub.c index d554d46d08b5..bdd19db4a08b 100644 --- a/sound/soc/tegra/tegra30_ahub.c +++ b/sound/soc/tegra/tegra30_ahub.c | |||
| @@ -100,6 +100,7 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, | |||
| 100 | { | 100 | { |
| 101 | int channel; | 101 | int channel; |
| 102 | u32 reg, val; | 102 | u32 reg, val; |
| 103 | struct tegra30_ahub_cif_conf cif_conf; | ||
| 103 | 104 | ||
| 104 | channel = find_first_zero_bit(ahub->rx_usage, | 105 | channel = find_first_zero_bit(ahub->rx_usage, |
| 105 | TEGRA30_AHUB_CHANNEL_CTRL_COUNT); | 106 | TEGRA30_AHUB_CHANNEL_CTRL_COUNT); |
| @@ -123,15 +124,21 @@ int tegra30_ahub_allocate_rx_fifo(enum tegra30_ahub_rxcif *rxcif, | |||
| 123 | TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_16; | 124 | TEGRA30_AHUB_CHANNEL_CTRL_RX_PACK_16; |
| 124 | tegra30_apbif_write(reg, val); | 125 | tegra30_apbif_write(reg, val); |
| 125 | 126 | ||
| 127 | cif_conf.threshold = 0; | ||
| 128 | cif_conf.audio_channels = 2; | ||
| 129 | cif_conf.client_channels = 2; | ||
| 130 | cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16; | ||
| 131 | cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16; | ||
| 132 | cif_conf.expand = 0; | ||
| 133 | cif_conf.stereo_conv = 0; | ||
| 134 | cif_conf.replicate = 0; | ||
| 135 | cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_RX; | ||
| 136 | cif_conf.truncate = 0; | ||
| 137 | cif_conf.mono_conv = 0; | ||
| 138 | |||
| 126 | reg = TEGRA30_AHUB_CIF_RX_CTRL + | 139 | reg = TEGRA30_AHUB_CIF_RX_CTRL + |
| 127 | (channel * TEGRA30_AHUB_CIF_RX_CTRL_STRIDE); | 140 | (channel * TEGRA30_AHUB_CIF_RX_CTRL_STRIDE); |
| 128 | val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | | 141 | ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); |
| 129 | (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | | ||
| 130 | (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | | ||
| 131 | TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 | | ||
| 132 | TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16 | | ||
| 133 | TEGRA30_AUDIOCIF_CTRL_DIRECTION_RX; | ||
| 134 | tegra30_apbif_write(reg, val); | ||
| 135 | 142 | ||
| 136 | return 0; | 143 | return 0; |
| 137 | } | 144 | } |
| @@ -183,6 +190,7 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, | |||
| 183 | { | 190 | { |
| 184 | int channel; | 191 | int channel; |
| 185 | u32 reg, val; | 192 | u32 reg, val; |
| 193 | struct tegra30_ahub_cif_conf cif_conf; | ||
| 186 | 194 | ||
| 187 | channel = find_first_zero_bit(ahub->tx_usage, | 195 | channel = find_first_zero_bit(ahub->tx_usage, |
| 188 | TEGRA30_AHUB_CHANNEL_CTRL_COUNT); | 196 | TEGRA30_AHUB_CHANNEL_CTRL_COUNT); |
| @@ -206,15 +214,21 @@ int tegra30_ahub_allocate_tx_fifo(enum tegra30_ahub_txcif *txcif, | |||
| 206 | TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_16; | 214 | TEGRA30_AHUB_CHANNEL_CTRL_TX_PACK_16; |
| 207 | tegra30_apbif_write(reg, val); | 215 | tegra30_apbif_write(reg, val); |
| 208 | 216 | ||
| 217 | cif_conf.threshold = 0; | ||
| 218 | cif_conf.audio_channels = 2; | ||
| 219 | cif_conf.client_channels = 2; | ||
| 220 | cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16; | ||
| 221 | cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16; | ||
| 222 | cif_conf.expand = 0; | ||
| 223 | cif_conf.stereo_conv = 0; | ||
| 224 | cif_conf.replicate = 0; | ||
| 225 | cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_TX; | ||
| 226 | cif_conf.truncate = 0; | ||
| 227 | cif_conf.mono_conv = 0; | ||
| 228 | |||
| 209 | reg = TEGRA30_AHUB_CIF_TX_CTRL + | 229 | reg = TEGRA30_AHUB_CIF_TX_CTRL + |
| 210 | (channel * TEGRA30_AHUB_CIF_TX_CTRL_STRIDE); | 230 | (channel * TEGRA30_AHUB_CIF_TX_CTRL_STRIDE); |
| 211 | val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | | 231 | ahub->soc_data->set_audio_cif(ahub->regmap_apbif, reg, &cif_conf); |
| 212 | (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | | ||
| 213 | (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | | ||
| 214 | TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 | | ||
| 215 | TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16 | | ||
| 216 | TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX; | ||
| 217 | tegra30_apbif_write(reg, val); | ||
| 218 | 232 | ||
| 219 | return 0; | 233 | return 0; |
| 220 | } | 234 | } |
| @@ -437,13 +451,21 @@ static const struct regmap_config tegra30_ahub_ahub_regmap_config = { | |||
| 437 | 451 | ||
| 438 | static struct tegra30_ahub_soc_data soc_data_tegra30 = { | 452 | static struct tegra30_ahub_soc_data soc_data_tegra30 = { |
| 439 | .clk_list_mask = CLK_LIST_MASK_TEGRA30, | 453 | .clk_list_mask = CLK_LIST_MASK_TEGRA30, |
| 454 | .set_audio_cif = tegra30_ahub_set_cif, | ||
| 440 | }; | 455 | }; |
| 441 | 456 | ||
| 442 | static struct tegra30_ahub_soc_data soc_data_tegra114 = { | 457 | static struct tegra30_ahub_soc_data soc_data_tegra114 = { |
| 443 | .clk_list_mask = CLK_LIST_MASK_TEGRA114, | 458 | .clk_list_mask = CLK_LIST_MASK_TEGRA114, |
| 459 | .set_audio_cif = tegra30_ahub_set_cif, | ||
| 460 | }; | ||
| 461 | |||
| 462 | static struct tegra30_ahub_soc_data soc_data_tegra124 = { | ||
| 463 | .clk_list_mask = CLK_LIST_MASK_TEGRA114, | ||
| 464 | .set_audio_cif = tegra124_ahub_set_cif, | ||
| 444 | }; | 465 | }; |
| 445 | 466 | ||
| 446 | static const struct of_device_id tegra30_ahub_of_match[] = { | 467 | static const struct of_device_id tegra30_ahub_of_match[] = { |
| 468 | { .compatible = "nvidia,tegra124-ahub", .data = &soc_data_tegra124 }, | ||
| 447 | { .compatible = "nvidia,tegra114-ahub", .data = &soc_data_tegra114 }, | 469 | { .compatible = "nvidia,tegra114-ahub", .data = &soc_data_tegra114 }, |
| 448 | { .compatible = "nvidia,tegra30-ahub", .data = &soc_data_tegra30 }, | 470 | { .compatible = "nvidia,tegra30-ahub", .data = &soc_data_tegra30 }, |
| 449 | {}, | 471 | {}, |
| @@ -497,6 +519,7 @@ static int tegra30_ahub_probe(struct platform_device *pdev) | |||
| 497 | } | 519 | } |
| 498 | dev_set_drvdata(&pdev->dev, ahub); | 520 | dev_set_drvdata(&pdev->dev, ahub); |
| 499 | 521 | ||
| 522 | ahub->soc_data = soc_data; | ||
| 500 | ahub->dev = &pdev->dev; | 523 | ahub->dev = &pdev->dev; |
| 501 | 524 | ||
| 502 | ahub->clk_d_audio = clk_get(&pdev->dev, "d_audio"); | 525 | ahub->clk_d_audio = clk_get(&pdev->dev, "d_audio"); |
| @@ -669,6 +692,70 @@ static struct platform_driver tegra30_ahub_driver = { | |||
| 669 | }; | 692 | }; |
| 670 | module_platform_driver(tegra30_ahub_driver); | 693 | module_platform_driver(tegra30_ahub_driver); |
| 671 | 694 | ||
| 695 | void tegra30_ahub_set_cif(struct regmap *regmap, unsigned int reg, | ||
| 696 | struct tegra30_ahub_cif_conf *conf) | ||
| 697 | { | ||
| 698 | unsigned int value; | ||
| 699 | |||
| 700 | value = (conf->threshold << | ||
| 701 | TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | | ||
| 702 | ((conf->audio_channels - 1) << | ||
| 703 | TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | | ||
| 704 | ((conf->client_channels - 1) << | ||
| 705 | TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | | ||
| 706 | (conf->audio_bits << | ||
| 707 | TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT) | | ||
| 708 | (conf->client_bits << | ||
| 709 | TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT) | | ||
| 710 | (conf->expand << | ||
| 711 | TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT) | | ||
| 712 | (conf->stereo_conv << | ||
| 713 | TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) | | ||
| 714 | (conf->replicate << | ||
| 715 | TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT) | | ||
| 716 | (conf->direction << | ||
| 717 | TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT) | | ||
| 718 | (conf->truncate << | ||
| 719 | TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT) | | ||
| 720 | (conf->mono_conv << | ||
| 721 | TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT); | ||
| 722 | |||
| 723 | regmap_write(regmap, reg, value); | ||
| 724 | } | ||
| 725 | EXPORT_SYMBOL_GPL(tegra30_ahub_set_cif); | ||
| 726 | |||
| 727 | void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg, | ||
| 728 | struct tegra30_ahub_cif_conf *conf) | ||
| 729 | { | ||
| 730 | unsigned int value; | ||
| 731 | |||
| 732 | value = (conf->threshold << | ||
| 733 | TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | | ||
| 734 | ((conf->audio_channels - 1) << | ||
| 735 | TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | | ||
| 736 | ((conf->client_channels - 1) << | ||
| 737 | TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | | ||
| 738 | (conf->audio_bits << | ||
| 739 | TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_SHIFT) | | ||
| 740 | (conf->client_bits << | ||
| 741 | TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_SHIFT) | | ||
| 742 | (conf->expand << | ||
| 743 | TEGRA30_AUDIOCIF_CTRL_EXPAND_SHIFT) | | ||
| 744 | (conf->stereo_conv << | ||
| 745 | TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) | | ||
| 746 | (conf->replicate << | ||
| 747 | TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT) | | ||
| 748 | (conf->direction << | ||
| 749 | TEGRA30_AUDIOCIF_CTRL_DIRECTION_SHIFT) | | ||
| 750 | (conf->truncate << | ||
| 751 | TEGRA30_AUDIOCIF_CTRL_TRUNCATE_SHIFT) | | ||
| 752 | (conf->mono_conv << | ||
| 753 | TEGRA30_AUDIOCIF_CTRL_MONO_CONV_SHIFT); | ||
| 754 | |||
| 755 | regmap_write(regmap, reg, value); | ||
| 756 | } | ||
| 757 | EXPORT_SYMBOL_GPL(tegra124_ahub_set_cif); | ||
| 758 | |||
| 672 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); | 759 | MODULE_AUTHOR("Stephen Warren <swarren@nvidia.com>"); |
| 673 | MODULE_DESCRIPTION("Tegra30 AHUB driver"); | 760 | MODULE_DESCRIPTION("Tegra30 AHUB driver"); |
| 674 | MODULE_LICENSE("GPL v2"); | 761 | MODULE_LICENSE("GPL v2"); |
diff --git a/sound/soc/tegra/tegra30_ahub.h b/sound/soc/tegra/tegra30_ahub.h index 09766cdc45ca..d67321d90faa 100644 --- a/sound/soc/tegra/tegra30_ahub.h +++ b/sound/soc/tegra/tegra30_ahub.h | |||
| @@ -25,16 +25,30 @@ | |||
| 25 | #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US 0xf | 25 | #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US 0xf |
| 26 | #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK (TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | 26 | #define TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK (TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) |
| 27 | 27 | ||
| 28 | #define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT 24 | ||
| 29 | #define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US 0x3f | ||
| 30 | #define TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK (TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_MASK_US << TEGRA124_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | ||
| 31 | |||
| 28 | /* Channel count minus 1 */ | 32 | /* Channel count minus 1 */ |
| 29 | #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT 24 | 33 | #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT 24 |
| 30 | #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US 7 | 34 | #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US 7 |
| 31 | #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | 35 | #define TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) |
| 32 | 36 | ||
| 33 | /* Channel count minus 1 */ | 37 | /* Channel count minus 1 */ |
| 38 | #define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT 20 | ||
| 39 | #define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US 0xf | ||
| 40 | #define TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK (TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_MASK_US << TEGRA124_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | ||
| 41 | |||
| 42 | /* Channel count minus 1 */ | ||
| 34 | #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT 16 | 43 | #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT 16 |
| 35 | #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 7 | 44 | #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 7 |
| 36 | #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | 45 | #define TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) |
| 37 | 46 | ||
| 47 | /* Channel count minus 1 */ | ||
| 48 | #define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT 16 | ||
| 49 | #define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US 0xf | ||
| 50 | #define TEGRA124_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK (TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_MASK_US << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | ||
| 51 | |||
| 38 | #define TEGRA30_AUDIOCIF_BITS_4 0 | 52 | #define TEGRA30_AUDIOCIF_BITS_4 0 |
| 39 | #define TEGRA30_AUDIOCIF_BITS_8 1 | 53 | #define TEGRA30_AUDIOCIF_BITS_8 1 |
| 40 | #define TEGRA30_AUDIOCIF_BITS_12 2 | 54 | #define TEGRA30_AUDIOCIF_BITS_12 2 |
| @@ -86,7 +100,7 @@ | |||
| 86 | #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_CH1 (TEGRA30_AUDIOCIF_STEREO_CONV_CH1 << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) | 100 | #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_CH1 (TEGRA30_AUDIOCIF_STEREO_CONV_CH1 << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) |
| 87 | #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_AVG (TEGRA30_AUDIOCIF_STEREO_CONV_AVG << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) | 101 | #define TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_AVG (TEGRA30_AUDIOCIF_STEREO_CONV_AVG << TEGRA30_AUDIOCIF_CTRL_STEREO_CONV_SHIFT) |
| 88 | 102 | ||
| 89 | #define TEGRA30_AUDIOCIF_CTRL_REPLICATE 3 | 103 | #define TEGRA30_AUDIOCIF_CTRL_REPLICATE_SHIFT 3 |
| 90 | 104 | ||
| 91 | #define TEGRA30_AUDIOCIF_DIRECTION_TX 0 | 105 | #define TEGRA30_AUDIOCIF_DIRECTION_TX 0 |
| 92 | #define TEGRA30_AUDIOCIF_DIRECTION_RX 1 | 106 | #define TEGRA30_AUDIOCIF_DIRECTION_RX 1 |
| @@ -468,8 +482,30 @@ extern int tegra30_ahub_set_rx_cif_source(enum tegra30_ahub_rxcif rxcif, | |||
| 468 | enum tegra30_ahub_txcif txcif); | 482 | enum tegra30_ahub_txcif txcif); |
| 469 | extern int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif); | 483 | extern int tegra30_ahub_unset_rx_cif_source(enum tegra30_ahub_rxcif rxcif); |
| 470 | 484 | ||
| 485 | struct tegra30_ahub_cif_conf { | ||
| 486 | unsigned int threshold; | ||
| 487 | unsigned int audio_channels; | ||
| 488 | unsigned int client_channels; | ||
| 489 | unsigned int audio_bits; | ||
| 490 | unsigned int client_bits; | ||
| 491 | unsigned int expand; | ||
| 492 | unsigned int stereo_conv; | ||
| 493 | unsigned int replicate; | ||
| 494 | unsigned int direction; | ||
| 495 | unsigned int truncate; | ||
| 496 | unsigned int mono_conv; | ||
| 497 | }; | ||
| 498 | |||
| 499 | void tegra30_ahub_set_cif(struct regmap *regmap, unsigned int reg, | ||
| 500 | struct tegra30_ahub_cif_conf *conf); | ||
| 501 | void tegra124_ahub_set_cif(struct regmap *regmap, unsigned int reg, | ||
| 502 | struct tegra30_ahub_cif_conf *conf); | ||
| 503 | |||
| 471 | struct tegra30_ahub_soc_data { | 504 | struct tegra30_ahub_soc_data { |
| 472 | u32 clk_list_mask; | 505 | u32 clk_list_mask; |
| 506 | void (*set_audio_cif)(struct regmap *regmap, | ||
| 507 | unsigned int reg, | ||
| 508 | struct tegra30_ahub_cif_conf *conf); | ||
| 473 | /* | 509 | /* |
| 474 | * FIXME: There are many more differences in HW, such as: | 510 | * FIXME: There are many more differences in HW, such as: |
| 475 | * - More APBIF channels. | 511 | * - More APBIF channels. |
diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index 47565fd04505..5f20b695eba2 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | #include <linux/io.h> | 30 | #include <linux/io.h> |
| 31 | #include <linux/module.h> | 31 | #include <linux/module.h> |
| 32 | #include <linux/of.h> | 32 | #include <linux/of.h> |
| 33 | #include <linux/of_device.h> | ||
| 33 | #include <linux/platform_device.h> | 34 | #include <linux/platform_device.h> |
| 34 | #include <linux/pm_runtime.h> | 35 | #include <linux/pm_runtime.h> |
| 35 | #include <linux/regmap.h> | 36 | #include <linux/regmap.h> |
| @@ -179,6 +180,7 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 179 | struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai); | 180 | struct tegra30_i2s *i2s = snd_soc_dai_get_drvdata(dai); |
| 180 | unsigned int mask, val, reg; | 181 | unsigned int mask, val, reg; |
| 181 | int ret, sample_size, srate, i2sclock, bitcnt; | 182 | int ret, sample_size, srate, i2sclock, bitcnt; |
| 183 | struct tegra30_ahub_cif_conf cif_conf; | ||
| 182 | 184 | ||
| 183 | if (params_channels(params) != 2) | 185 | if (params_channels(params) != 2) |
| 184 | return -EINVAL; | 186 | return -EINVAL; |
| @@ -217,21 +219,26 @@ static int tegra30_i2s_hw_params(struct snd_pcm_substream *substream, | |||
| 217 | 219 | ||
| 218 | regmap_write(i2s->regmap, TEGRA30_I2S_TIMING, val); | 220 | regmap_write(i2s->regmap, TEGRA30_I2S_TIMING, val); |
| 219 | 221 | ||
| 220 | val = (0 << TEGRA30_AUDIOCIF_CTRL_FIFO_THRESHOLD_SHIFT) | | 222 | cif_conf.threshold = 0; |
| 221 | (1 << TEGRA30_AUDIOCIF_CTRL_AUDIO_CHANNELS_SHIFT) | | 223 | cif_conf.audio_channels = 2; |
| 222 | (1 << TEGRA30_AUDIOCIF_CTRL_CLIENT_CHANNELS_SHIFT) | | 224 | cif_conf.client_channels = 2; |
| 223 | TEGRA30_AUDIOCIF_CTRL_AUDIO_BITS_16 | | 225 | cif_conf.audio_bits = TEGRA30_AUDIOCIF_BITS_16; |
| 224 | TEGRA30_AUDIOCIF_CTRL_CLIENT_BITS_16; | 226 | cif_conf.client_bits = TEGRA30_AUDIOCIF_BITS_16; |
| 227 | cif_conf.expand = 0; | ||
| 228 | cif_conf.stereo_conv = 0; | ||
| 229 | cif_conf.replicate = 0; | ||
| 230 | cif_conf.truncate = 0; | ||
| 231 | cif_conf.mono_conv = 0; | ||
| 225 | 232 | ||
| 226 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { | 233 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { |
| 227 | val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_RX; | 234 | cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_RX; |
| 228 | reg = TEGRA30_I2S_CIF_RX_CTRL; | 235 | reg = TEGRA30_I2S_CIF_RX_CTRL; |
| 229 | } else { | 236 | } else { |
| 230 | val |= TEGRA30_AUDIOCIF_CTRL_DIRECTION_TX; | 237 | cif_conf.direction = TEGRA30_AUDIOCIF_DIRECTION_TX; |
| 231 | reg = TEGRA30_I2S_CIF_TX_CTRL; | 238 | reg = TEGRA30_I2S_CIF_TX_CTRL; |
| 232 | } | 239 | } |
| 233 | 240 | ||
| 234 | regmap_write(i2s->regmap, reg, val); | 241 | i2s->soc_data->set_audio_cif(i2s->regmap, reg, &cif_conf); |
| 235 | 242 | ||
| 236 | val = (1 << TEGRA30_I2S_OFFSET_RX_DATA_OFFSET_SHIFT) | | 243 | val = (1 << TEGRA30_I2S_OFFSET_RX_DATA_OFFSET_SHIFT) | |
| 237 | (1 << TEGRA30_I2S_OFFSET_TX_DATA_OFFSET_SHIFT); | 244 | (1 << TEGRA30_I2S_OFFSET_TX_DATA_OFFSET_SHIFT); |
| @@ -396,9 +403,24 @@ static const struct regmap_config tegra30_i2s_regmap_config = { | |||
| 396 | .cache_type = REGCACHE_RBTREE, | 403 | .cache_type = REGCACHE_RBTREE, |
| 397 | }; | 404 | }; |
| 398 | 405 | ||
| 406 | static const struct tegra30_i2s_soc_data tegra30_i2s_config = { | ||
| 407 | .set_audio_cif = tegra30_ahub_set_cif, | ||
| 408 | }; | ||
| 409 | |||
| 410 | static const struct tegra30_i2s_soc_data tegra124_i2s_config = { | ||
| 411 | .set_audio_cif = tegra124_ahub_set_cif, | ||
| 412 | }; | ||
| 413 | |||
| 414 | static const struct of_device_id tegra30_i2s_of_match[] = { | ||
| 415 | { .compatible = "nvidia,tegra124-i2s", .data = &tegra124_i2s_config }, | ||
| 416 | { .compatible = "nvidia,tegra30-i2s", .data = &tegra30_i2s_config }, | ||
| 417 | {}, | ||
| 418 | }; | ||
| 419 | |||
| 399 | static int tegra30_i2s_platform_probe(struct platform_device *pdev) | 420 | static int tegra30_i2s_platform_probe(struct platform_device *pdev) |
| 400 | { | 421 | { |
| 401 | struct tegra30_i2s *i2s; | 422 | struct tegra30_i2s *i2s; |
| 423 | const struct of_device_id *match; | ||
| 402 | u32 cif_ids[2]; | 424 | u32 cif_ids[2]; |
| 403 | struct resource *mem, *memregion; | 425 | struct resource *mem, *memregion; |
| 404 | void __iomem *regs; | 426 | void __iomem *regs; |
| @@ -412,6 +434,14 @@ static int tegra30_i2s_platform_probe(struct platform_device *pdev) | |||
| 412 | } | 434 | } |
| 413 | dev_set_drvdata(&pdev->dev, i2s); | 435 | dev_set_drvdata(&pdev->dev, i2s); |
| 414 | 436 | ||
| 437 | match = of_match_device(tegra30_i2s_of_match, &pdev->dev); | ||
| 438 | if (!match) { | ||
| 439 | dev_err(&pdev->dev, "Error: No device match found\n"); | ||
| 440 | ret = -ENODEV; | ||
| 441 | goto err; | ||
| 442 | } | ||
| 443 | i2s->soc_data = (struct tegra30_i2s_soc_data *)match->data; | ||
| 444 | |||
| 415 | i2s->dai = tegra30_i2s_dai_template; | 445 | i2s->dai = tegra30_i2s_dai_template; |
| 416 | i2s->dai.name = dev_name(&pdev->dev); | 446 | i2s->dai.name = dev_name(&pdev->dev); |
| 417 | 447 | ||
| @@ -539,11 +569,6 @@ static int tegra30_i2s_resume(struct device *dev) | |||
| 539 | } | 569 | } |
| 540 | #endif | 570 | #endif |
| 541 | 571 | ||
| 542 | static const struct of_device_id tegra30_i2s_of_match[] = { | ||
| 543 | { .compatible = "nvidia,tegra30-i2s", }, | ||
| 544 | {}, | ||
| 545 | }; | ||
| 546 | |||
| 547 | static const struct dev_pm_ops tegra30_i2s_pm_ops = { | 572 | static const struct dev_pm_ops tegra30_i2s_pm_ops = { |
| 548 | SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend, | 573 | SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend, |
| 549 | tegra30_i2s_runtime_resume, NULL) | 574 | tegra30_i2s_runtime_resume, NULL) |
diff --git a/sound/soc/tegra/tegra30_i2s.h b/sound/soc/tegra/tegra30_i2s.h index bea23afe3b9f..4d0b0a30dbfb 100644 --- a/sound/soc/tegra/tegra30_i2s.h +++ b/sound/soc/tegra/tegra30_i2s.h | |||
| @@ -225,7 +225,14 @@ | |||
| 225 | #define TEGRA30_I2S_LCOEF_COEF_MASK_US 0xffff | 225 | #define TEGRA30_I2S_LCOEF_COEF_MASK_US 0xffff |
| 226 | #define TEGRA30_I2S_LCOEF_COEF_MASK (TEGRA30_I2S_LCOEF_COEF_MASK_US << TEGRA30_I2S_LCOEF_COEF_SHIFT) | 226 | #define TEGRA30_I2S_LCOEF_COEF_MASK (TEGRA30_I2S_LCOEF_COEF_MASK_US << TEGRA30_I2S_LCOEF_COEF_SHIFT) |
| 227 | 227 | ||
| 228 | struct tegra30_i2s_soc_data { | ||
| 229 | void (*set_audio_cif)(struct regmap *regmap, | ||
| 230 | unsigned int reg, | ||
| 231 | struct tegra30_ahub_cif_conf *conf); | ||
| 232 | }; | ||
| 233 | |||
| 228 | struct tegra30_i2s { | 234 | struct tegra30_i2s { |
| 235 | const struct tegra30_i2s_soc_data *soc_data; | ||
| 229 | struct snd_soc_dai_driver dai; | 236 | struct snd_soc_dai_driver dai; |
| 230 | int cif_id; | 237 | int cif_id; |
| 231 | struct clk *clk_i2s; | 238 | struct clk *clk_i2s; |
diff --git a/sound/soc/tegra/tegra_asoc_utils.c b/sound/soc/tegra/tegra_asoc_utils.c index d173880f290d..1be311c51a18 100644 --- a/sound/soc/tegra/tegra_asoc_utils.c +++ b/sound/soc/tegra/tegra_asoc_utils.c | |||
| @@ -182,6 +182,8 @@ int tegra_asoc_utils_init(struct tegra_asoc_utils_data *data, | |||
| 182 | data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA30; | 182 | data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA30; |
| 183 | else if (of_machine_is_compatible("nvidia,tegra114")) | 183 | else if (of_machine_is_compatible("nvidia,tegra114")) |
| 184 | data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA114; | 184 | data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA114; |
| 185 | else if (of_machine_is_compatible("nvidia,tegra124")) | ||
| 186 | data->soc = TEGRA_ASOC_UTILS_SOC_TEGRA124; | ||
| 185 | else { | 187 | else { |
| 186 | dev_err(data->dev, "SoC unknown to Tegra ASoC utils\n"); | 188 | dev_err(data->dev, "SoC unknown to Tegra ASoC utils\n"); |
| 187 | return -EINVAL; | 189 | return -EINVAL; |
diff --git a/sound/soc/tegra/tegra_asoc_utils.h b/sound/soc/tegra/tegra_asoc_utils.h index 19fdcafed32f..9577121ce971 100644 --- a/sound/soc/tegra/tegra_asoc_utils.h +++ b/sound/soc/tegra/tegra_asoc_utils.h | |||
| @@ -30,6 +30,7 @@ enum tegra_asoc_utils_soc { | |||
| 30 | TEGRA_ASOC_UTILS_SOC_TEGRA20, | 30 | TEGRA_ASOC_UTILS_SOC_TEGRA20, |
| 31 | TEGRA_ASOC_UTILS_SOC_TEGRA30, | 31 | TEGRA_ASOC_UTILS_SOC_TEGRA30, |
| 32 | TEGRA_ASOC_UTILS_SOC_TEGRA114, | 32 | TEGRA_ASOC_UTILS_SOC_TEGRA114, |
| 33 | TEGRA_ASOC_UTILS_SOC_TEGRA124, | ||
| 33 | }; | 34 | }; |
| 34 | 35 | ||
| 35 | struct tegra_asoc_utils_data { | 36 | struct tegra_asoc_utils_data { |
diff --git a/sound/soc/tegra/tegra_pcm.c b/sound/soc/tegra/tegra_pcm.c index f056f632557c..7b2d23ba69b3 100644 --- a/sound/soc/tegra/tegra_pcm.c +++ b/sound/soc/tegra/tegra_pcm.c | |||
| @@ -56,7 +56,6 @@ static const struct snd_pcm_hardware tegra_pcm_hardware = { | |||
| 56 | static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = { | 56 | static const struct snd_dmaengine_pcm_config tegra_dmaengine_pcm_config = { |
| 57 | .pcm_hardware = &tegra_pcm_hardware, | 57 | .pcm_hardware = &tegra_pcm_hardware, |
| 58 | .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, | 58 | .prepare_slave_config = snd_dmaengine_pcm_prepare_slave_config, |
| 59 | .compat_filter_fn = NULL, | ||
| 60 | .prealloc_buffer_size = PAGE_SIZE * 8, | 59 | .prealloc_buffer_size = PAGE_SIZE * 8, |
| 61 | }; | 60 | }; |
| 62 | 61 | ||
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c index d0323a693ba2..999550bbad40 100644 --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c | |||
| @@ -262,7 +262,9 @@ static int usb_stream_hwdep_mmap(struct snd_hwdep *hw, | |||
| 262 | } | 262 | } |
| 263 | 263 | ||
| 264 | area->vm_ops = &usb_stream_hwdep_vm_ops; | 264 | area->vm_ops = &usb_stream_hwdep_vm_ops; |
| 265 | area->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP; | 265 | area->vm_flags |= VM_DONTDUMP; |
| 266 | if (!read) | ||
| 267 | area->vm_flags |= VM_DONTEXPAND; | ||
| 266 | area->vm_private_data = us122l; | 268 | area->vm_private_data = us122l; |
| 267 | atomic_inc(&us122l->mmap_count); | 269 | atomic_inc(&us122l->mmap_count); |
| 268 | out: | 270 | out: |
diff --git a/tools/testing/selftests/timers/posix_timers.c b/tools/testing/selftests/timers/posix_timers.c index 4fa655d68a81..41bd85559d4b 100644 --- a/tools/testing/selftests/timers/posix_timers.c +++ b/tools/testing/selftests/timers/posix_timers.c | |||
| @@ -151,7 +151,7 @@ static int check_timer_create(int which) | |||
| 151 | fflush(stdout); | 151 | fflush(stdout); |
| 152 | 152 | ||
| 153 | done = 0; | 153 | done = 0; |
| 154 | timer_create(which, NULL, &id); | 154 | err = timer_create(which, NULL, &id); |
| 155 | if (err < 0) { | 155 | if (err < 0) { |
| 156 | perror("Can't create timer\n"); | 156 | perror("Can't create timer\n"); |
| 157 | return -1; | 157 | return -1; |
