|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" F0 T2 p1 k* ~- n p, p- r% Y
#include <linux/init.h>4 G; p9 d5 f* }0 @ C
#include <linux/module.h>* S9 k7 V$ e- g3 Z7 D* b/ Q1 Q s
#include <linux/kernel.h>+ T1 Y# n! U. B. ]: C
#include <linux/types.h>8 t" @* S# H; K4 i
#include <linux/gpio.h>
+ p" i2 z, j% u$ W0 b* p( x) u#include <linux/leds.h>$ T# `; T" F) w/ {: S* c' C
#include <linux/platform_device.h>% G8 i! x0 N; G8 `; I
+ F& Q X) U; m
#include <asm/mach-types.h>& g. U* x- ~9 B, Q
#include <asm/mach/arch.h>
. T8 ]2 `5 K1 m& i* t#include <mach/da8xx.h>$ i$ V! @8 P2 w, ]
#include <mach/mux.h>
) ^3 ]1 G. U {4 b, f" R8 k' S
9 w K( D0 h' k: \. l/ Q. m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! e$ U& |' K P- u" B* k' d! q- }6 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 e5 q; }2 C2 N6 C) t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) G8 c1 H- ]' R6 t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 k8 N+ ~, f7 ]+ U/ m7 T, t% D5 `& X% o3 }9 I& c+ Z. E2 ]
/* assign the tl som board LED-GPIOs*/
4 R3 @( |$ I5 s/ D; mstatic const short da850_evm_tl_user_led_pins[] = {
! [6 I( N0 X7 j0 h, e, n! _$ z# S /* These pins are definition at <mach/mux.h> file */
0 O% {. b5 B% u/ `; b, J DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) V* F* k9 | F. q% B/ T& n -19 u- R/ U3 ^3 C4 |# {/ j
};3 _5 F* l& y; b- Q' w9 N4 a
4 k/ b# [* W* R% d" R. A# S: M* `static struct gpio_led da850_evm_tl_leds[] = {
; T3 V ~, m2 b& d! _/ j {# k* U7 z: ~7 D' h. _- U
.active_low = 0,
- H, d) V1 X% Y9 B; \' P .gpio = DA850_USER_LED0,6 t6 J/ w: }0 y
.name = "user_led0",
. U i5 _( V( q% L) |# H/ t2 _ .default_trigger = "default-on",
9 N0 a- f% U2 v! ^ },
- i; K: [: L1 C6 X- x {
# R# m) g$ c4 J .active_low = 0,
6 z, x. i$ }6 _* Y .gpio = DA850_USER_LED1, B& U) b* B; O
.name = "user_led1",
- a7 ^/ j: c8 T9 y .default_trigger = "default-on",
+ q8 k( e; U1 i; v1 s4 q },
$ a6 S+ J c! E+ q! r, W1 s {
8 A$ S; r8 h( q7 A. C% Z .active_low = 0,$ ?! Q T" C: w. V$ |
.gpio = DA850_USER_LED2,
, w" j2 r8 E# l .name = "user_led2",! @, a$ A6 q$ I' r; J: X- K
.default_trigger = "default-on",% P( N U1 n5 F5 z1 z
},
- O! X: Q1 ~% e+ [6 ?; K9 k# P {* A k9 V5 p1 a8 Y, \( Z
.active_low = 0,
0 V# Y j7 x. d. P9 S' K+ W .gpio = DA850_USER_LED3,5 b' |9 D6 o1 b Z0 V' l- ]
.name = "user_led3",
! k* z6 T: W4 t, B, {, F .default_trigger = "default-on",* ^( y, Y9 [/ F# n
},7 F" M% p5 S* P
};
+ A- }% A1 D3 J: O4 G( J& e3 M% V9 S' V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ a8 S' V* q: ?% L) w
.leds = da850_evm_tl_leds,: c9 O; {. y' z* L3 A/ X9 o
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. R2 u' D$ H% ?* @6 P4 N% q};
. @! J9 I; F, S/ q! @& Q, w& b, K& g7 _
static void led_dev_release(struct device *dev)
; H2 t* A' r% a( u' n{
* K2 D" v0 g8 v3 L$ ~};! M0 m6 Z; u$ p! w: A' T
' S5 C$ I' y+ k, [$ H; T( v H' Mstatic struct platform_device da850_evm_tl_leds_device = {) I: g, j* @" L9 B) ~6 o8 `$ L/ N
.name = "leds-gpio",
" e: x3 `# m0 u# g- I6 W8 l .id = 1,/ Y6 V. a' L' o
.dev = {& O0 N) P# U/ T- x9 E, N
.platform_data = &da850_evm_tl_leds_pdata,
" p% Y4 m2 {( G& r; V0 t .release = led_dev_release,
2 U# L3 A3 `. E( x$ j7 t X7 x! f }
4 q4 Y( O1 Y& c+ K1 p. [8 E};. i& _4 N- T! p2 z
( e2 u" ~3 A7 M, @. R
static int __init led_platform_init(void)
! b6 R( L" L' K9 ^1 W{! r. W0 F4 J2 q; w" ?5 }
int ret;5 b2 L$ Q% V# ?8 w3 W8 m
#if 0; P- N1 o, |. {1 l* |, ~- i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 B+ L {8 J$ \) \ if (ret)+ v3 k1 G0 g) I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ t y n* a4 m3 a "%d\n", ret);
' q. j) N n! {) ]7 J#endif
" Z& s2 @% r- ]8 x7 I8 P ret = platform_device_register(&da850_evm_tl_leds_device);, I- m9 Y" Q* g2 T5 E
if (ret)
+ p7 M3 M# G& D) X# @: V& f pr_warning("Could not register som GPIO expander LEDS");$ b* @6 f4 W: x/ _* D
else+ S8 }- {/ s- b
printk(KERN_INFO "LED register sucessful!\n");
8 f& m" m+ X7 `5 k( U2 p' o5 H: Q3 y: j
return ret;; ^2 C% i5 N7 w& ~
}, t `1 P/ E( }/ R, V w7 E8 I
0 T& I1 N; b" d( a$ g& Vstatic void __exit led_platform_exit(void)
8 k* s# B# \, ~- N6 z {0 n: j{
" m0 k& g* X; F3 v0 ~( o+ L6 w platform_device_unregister(&da850_evm_tl_leds_device);
) {1 s! U# E8 p& _, \* a) A8 J; |& }9 R8 C5 I0 j# r, s) o6 @9 U/ L
printk(KERN_INFO "LED unregister!\n");5 l, H; y9 C' F) `% v
}% K8 d9 p$ [) l( Y1 N6 j' w7 @4 b
$ O! s3 y# N9 D+ A
module_init(led_platform_init);. C- F1 U7 X) s; ^, Q8 x" q c# w3 J
module_exit(led_platform_exit);0 p+ B# @; x2 f
. `! ?/ }2 r: J# P# E
MODULE_DESCRIPTION("Led platform driver");
% g+ ]. H, e- s7 T' ?" g7 WMODULE_AUTHOR("Tronlong");
' M: t% w U+ k N6 e$ m5 F6 V* xMODULE_LICENSE("GPL");
4 q s. m! b! {" I$ s9 B# T0 m: z3 Z( `8 V& U# [
|
|