|
求大神给下面的程序做注解,请稍详细些,谢谢。
! y* j- b/ ^* H! `2 r/ w1 S#include <linux/init.h>7 T9 } V2 C7 r& `/ ~6 H0 p
#include <linux/module.h>
) s" x) f$ q2 g#include <linux/kernel.h> i/ h- K C, B, \& {
#include <linux/types.h>) I3 I5 k# K: [5 y: s
#include <linux/gpio.h># ^" |; A$ r1 k1 y1 a/ U; I! J
#include <linux/leds.h>) H9 ~3 R+ M& F- ^9 w5 T
#include <linux/platform_device.h>1 @' B1 _) r# l
" v8 X4 P6 F/ h8 ?1 k#include <asm/mach-types.h>& ?5 ]' p+ O6 |& k
#include <asm/mach/arch.h>
, H. \2 i0 b2 g; D; j3 Q#include <mach/da8xx.h>
; h; s7 n' I6 `" a9 k! q#include <mach/mux.h># C) N5 ~6 T$ z9 {" g
0 P: ^ ]! u2 `: X5 O
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 j/ K4 F! G# }- s U5 W2 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 F( C% T- y7 `+ s4 c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 \3 U9 ^7 |8 _2 ~& B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, S* o; d6 O, V. A
' ]$ K8 X6 A& K3 d9 ?/* assign the tl som board LED-GPIOs*/
- J: G1 h2 D, @+ a7 Istatic const short da850_evm_tl_user_led_pins[] = {
2 [$ e4 ` z$ V4 _" I/ q: u /* These pins are definition at <mach/mux.h> file */
. W5 i9 W0 {) R4 y$ {9 }2 }& ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& {. \' s2 X- p: x! E
-1
9 h' F/ C0 z- u Y% e2 f};% Y6 F% P9 h- d2 a6 R) S ~
`5 y$ ?" Q% ~3 nstatic struct gpio_led da850_evm_tl_leds[] = {
# `& y$ p8 J$ e5 l' F0 W0 O9 G {
$ |( j- {4 A. m& M) o1 d" f5 m0 x .active_low = 0,3 S1 t9 A0 J/ c
.gpio = DA850_USER_LED0,, I& G) k- Z. P H3 h
.name = "user_led0",
- |6 ^2 U. Z2 r .default_trigger = "default-on",
6 r2 W, h/ G% h' L* P7 E6 j },' X! X, D% h! z# v/ }: m5 E
{) K& A' P7 U: {6 w
.active_low = 0,/ T* ~$ a% a: M4 b' F3 k0 {- O6 O
.gpio = DA850_USER_LED1,( ^, F1 L- L. [7 R) N0 u
.name = "user_led1",
7 o% j0 c" ^ G: {7 g$ H8 x .default_trigger = "default-on",% B! Q4 [. W3 Y
},+ d* K5 O$ |% x1 R
{' y' Q3 L& q3 ^0 Y: q7 [
.active_low = 0,8 d' Z# r; n& F
.gpio = DA850_USER_LED2," f* p% o d* Q* o( @- C% x- L
.name = "user_led2",: Q0 C& y% Z) ~+ e6 ~4 [
.default_trigger = "default-on",+ K2 a/ O9 f! n
},0 c* s# \" A: E+ T6 q% K
{
: |* y6 a5 e: Q! u. l; T! g9 [ .active_low = 0,
; ~" U) g5 m! `. D3 }2 H a .gpio = DA850_USER_LED3,- H* X: k" V, P: [3 i& Q1 R
.name = "user_led3",
- R' ^; D7 D8 U. n .default_trigger = "default-on",
9 B4 {2 z% ~9 T },
1 u" d) `, u j2 k) x( n};
7 Q" y- s, S; C+ E8 V6 |! Z. V) x" p0 D' @* |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ _* p: ?+ D" w .leds = da850_evm_tl_leds," A* |) i& O1 w1 I1 B7 L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! [! V6 e- A3 N
};5 z0 j! U' H0 j- [. a5 w
: r" U# m- }" p, vstatic void led_dev_release(struct device *dev)% K5 M8 g! s( g8 G6 [
{2 H9 }# n6 G& Y& S; d8 s
};
: Y* H4 O3 X$ [- T5 l& u8 T3 w5 h- b2 Q* Z; j, G. a8 P
static struct platform_device da850_evm_tl_leds_device = {9 m8 O; C+ x! i D+ l* I
.name = "leds-gpio",
# F7 n: e) q# h; w3 P .id = 1,& [! i- J5 w# i) Z/ m2 G
.dev = {
S+ B2 \6 Y8 x. @ B% { .platform_data = &da850_evm_tl_leds_pdata,
' Q& P E9 y& Y5 q8 E9 b6 F* ~ .release = led_dev_release,
# d( A; p$ c! {* i) N }" X1 V8 L. s/ l% \8 l4 @3 ?1 a
};
2 |6 b4 J1 g9 D, M4 q n
C' }; E$ A0 ~. J+ t% \" Mstatic int __init led_platform_init(void)( q& X+ b+ G. a4 r/ v
{
0 S" X5 g# I0 F, j' n" [$ t int ret;1 f) w! V! q0 ?1 Z7 \8 } t4 l
#if 0
0 l; i7 e- L; U3 \$ w. h- Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) z3 F" \" T, \* Q if (ret)
' ?% Q2 y" p- I) g7 ^8 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 X: l8 H/ O# r2 M* Y4 T3 M "%d\n", ret);
# { Y, M- z. I& X#endif Y) E" q/ n' H: m i
ret = platform_device_register(&da850_evm_tl_leds_device);
% w7 b4 S$ o& Z" w$ I1 \ if (ret)$ B& t0 }3 P: z0 P7 t
pr_warning("Could not register som GPIO expander LEDS");
9 P" G$ V' H" `2 ] J. X! X5 e8 k9 H D else
6 z8 V5 l5 W' @: J printk(KERN_INFO "LED register sucessful!\n");
; P' f% { K3 Z7 n" M( ?9 O7 f" ]
4 T+ r/ @- q( O' m5 {9 S return ret;; [& \4 K) c/ a& H+ i1 w% [
}
& J6 [' @! X1 Y; u7 Q% `
2 f8 N$ S2 F& w' Mstatic void __exit led_platform_exit(void)
( Q7 O5 Y# ~. z; E; T" h{& J$ @$ a6 K# O/ d
platform_device_unregister(&da850_evm_tl_leds_device);
0 q0 M! _: Z2 M1 a3 p4 B7 L. K7 s, \$ U9 X7 X9 S' V
printk(KERN_INFO "LED unregister!\n");4 V; N* p0 X, m0 `7 \( y
}( z0 S F" e9 L8 B
- |% E8 d( n5 U
module_init(led_platform_init);
, K- x% p+ j: m1 |( P/ P1 y. emodule_exit(led_platform_exit);
. L, Y% T: k, w) S% l) [1 z' ?- b2 P# m% a
MODULE_DESCRIPTION("Led platform driver");7 B0 `; i g7 H% g2 _3 S/ M
MODULE_AUTHOR("Tronlong");+ q+ o% r) q7 i- b( {! d. v
MODULE_LICENSE("GPL");9 l* u2 M' s, f; d( K
8 t7 q" H( d4 R1 a
|
|