All right, good evening, amen. So Psalm 150, a pretty nice short chapter and a chapter that definitely exemplifies the command to praise God. Not necessarily singing, but singing praises to God is one way that we can praise Him. So let's kind of look there at Psalm 150. We'll just kind of read through it. I know we just did, but just kind of read through it to get another feel for the chapter. Praise the Lord. Praise God in His sanctuary, in church. Praise Him in the firmament of His power. Praise Him for His creation. Praise Him for His mighty acts for the things He's done for us. Praise Him according to His excellent greatness. Praise Him with the sound of the trumpet. Praise Him with the sultry and harp. Praise Him with the timbrel and dance. Praise Him with stringed instruments and organs. Praise Him upon the loud cymbals. Praise Him upon the high sounding cymbals. So a lot of instruments that can be used as well to praise the Lord, right? Let everything that hath breath praise the Lord. Praise you the Lord. The title of my sermon I want to talk about tonight is Music or Songs in the Bible. How we should be using music or songs in the Bible, what the Bible says about songs or music. If you had turned to Ephesians 5 verses 19, Ephesians 5, music is everywhere, right? God created this world and all that it is therein is in six days. And one of the things He created is music. He gave us, you know, birds have songs that they sing, whales have songs that they echo or sing back and forth, right? But we see it in human life, too, that there's always kind of this desire to have music playing in the background or be listening to music or singing music. We see this in the world, right?  Not always, not godly music, obviously, but there's always music in the background. We try and have it here at church. It kind of cuts the silence. It helps people feel more at ease. There's a lot of psychology behind that, too. But we see that humans are designed in a way that we have a desire to be singing or listening to music, okay? This is how God created us. And the Bible talks a lot about music. Ephesians 5, 19, if you're there, speaking to yourselves in songs and hymns and spiritual songs, singing and making melody in your heart to the Lord. There's a lot of songs in the Bible, and it tells us there very specifically that we're to be speaking to ourselves in these Psalms and hymns and spiritual songs. We'll kind of get into those a little bit more later. But the purpose of it here, it says, is singing and making melody in your heart to the Lord. We're supposed to be doing this to worship God, right? The word sing used in the Bible is over 100 times. Praise is over 200 times. It's found in the Bible. And there's multiple songs in the Bible. Obviously, we have the book of Psalms, Psalm 76. The first verse I'll just read for you says, to the chief musician on Neganoth, a Psalm or song of Asaph. So it defines Psalm as a song. So we know that the book of Psalms is the entire, the song book of the Bible. Interesting enough, Jesus, in his ministry, he quoted Psalms more than any other book in the Old Testament. Next was Deuteronomy, then Isaiah, and then Exodus. But Psalms, the song book of the Bible, was the thing that he quoted most often. The New Testament writers, they actually, all but two, quoted the book of Psalms throughout the New Testament writings. So we see it, you know, it's the biggest book in the Bible. It has the longest chapter, Psalm 119, which is explicitly just about the Word of God. So we see that the Bible talks a lot about songs and how we should be using them. And there's a lot of doctrine in songs. And it's also quoted throughout the New Testament. We have the song of Moses in Deuteronomy 32, which we'll kind of go over in a little bit. Also in Exodus 15 is Miriam's song, Moses' sister. This is the horse and the rider. We're cast into the sea song. In Judges chapter 5, Deborah, she sings a song as well. And then we have the book of song of Solomon, which itself is a song about a man and a woman and his wife, how a husband and wife and how that relationship should be. So what does the Bible, excuse me, say about music? It says a lot. It talks a lot about it. So one question that we want to answer is, what is the purpose for music? What is God's purpose for music? Well, to answer that question, a lot of people sometimes will say the music is amoral. It is without moral. It's neither good nor bad. It depends on the lyrics or it depends on the context of the song or of the music itself. Not necessarily the lyrics, but the music itself. But the Bible actually doesn't teach that. If you would turn to Ezekiel chapter 28. Ezekiel chapter 28. And probably most of us here have heard this before, but there might be some that this is due or people that may be listening that this is new. And I would encourage you just to see what the Bible has to say about it. The Bible talks about every area of our life, how we should raise our kids, how we should have marriages, what we should look for in spouses, what we should do for a living, how we should work, how we should handle our finances, how we should dress, how we should cut our hair, everything. And it should come as no surprise as the Bible talks about music as well. So Ezekiel 28, if we're going to look down at verse 12. Son of man, take up a lamentation upon the king of tires and say unto him, Thus saith the Lord God. This is God telling Ezekiel what he wants Ezekiel to tell the king of tire in God's name.  Thou has been in Eden, the Garden of God. Now obviously the king of tire, this is like 2000 years before him was the Garden of Eden. This is not the king of tire that was in the Garden of Eden. This is referencing, if you'll get the context, this is referencing Satan. So Satan is the one that is given the king of tire power. He has given him his authority.  And so there's some end times foreshadowing in this that, you know, the antichrist will be put up the same way. The Satan will be supporting him and putting him in power as well. So Thou has been in Eden, the Garden of God. Now we're talking about Satan. Every precious stone was thy covering, the sardius, topaz and the diamond, the barrel, the onyx, the jasper, the sapphire, the emerald and the carbuncle and gold. I want to talk for a second. That's not the point I'm trying to make here, but I think it's very important to note that the devil's covering, Satan's covering is all these precious stones. It's all these things that look beautiful, that look desirous, right? When we see something that looks good, Satan can use this in a way to attract us to sin, right? We need to make sure and be aware that this is what Satan looks like. His covering, you know, we have skin, we have clothes. And the way that these angelic beings were created by God, we'll see later, this was his covering. So this is how he looks. He looks attractive. He looks beautiful. He looks something to be desired. So we need to be paying attention to that too when we're out out and about in our daily lives. So his covering is all these, the carbuncle and gold. The workmanship of thy tabrits and of thy pipes was prepared in thee in the day that was created. Tabrits and pipes. So a tablet, what a tablet is, it's a plural for multiple tiny taboors, a tabore, kind of like a tambourine without the jingly things on the side. Just a skin drum is what a tabore is. And so he had these taboors or tabrits and pipes would be like a flute or a recorder, something like that. So he has these, you know, we see in Ezekiel in chapters one through four, so God or Ezekiel describing these angelic beings that he sees.  But these angelic beings, these cherub and seraphim tend to have these mechanical qualities to them. They have wheels and multiple faces and hooves and different things. They're built differently than humans are. And so in thee and prepared in thee, in his body, in Satan's body or in his being, if you will, he has tabrits and pipes. He has musical instruments built into his body that they were prepared in thee in the day that was created. The baptism verse 14, thou art the anointed cherub that covereth, and I have set thee so. Thou wast upon the holy mountain of God, that was walked up and down in the midst of the stones of fire. Thou was perfect in thy ways from the day that was created till it was found in thee. So, this God is telling us about Satan, about when he was created. He was one of the anointed cherubs that covereth. He was set as a high position until iniquity was found in him, until he chose to sin or chose to fall and that whole thing took place. But the point I want to make here is that Satan's body actually has tabrits and pipes in it, musical instruments built into it. A lot of people will say, well, music is amoral. It is without moral. It doesn't matter if it's, it only matters the lyrics or the context that it's being used in. But we know God created music and we also know that Satan's body is able to create music too. So that would lend us that, look, no, music can either be moral or it can be immoral. So we need to discern which type we should be listening to and use our judgment to figure out which type is moral, the type we should be listening to, the type we should be using when we're praising God, or which type is immoral, the type we should flee from, we should not listen to, we should not sing or use ourselves. So we know that music is either moral or immoral. Think about this like professional athletes when they're getting pumped up to go to a football game or when they're, you know, they're not using, they're not seeing the old rugged cross in their ears. They're listening to some heavy metal rock or some kind of rap or something. They're trying to get pumped up, right? Music, even just the beat of the song, can affect our mind. It's something spiritual, emotional. It has a feel to it and it can influence us as well. So what did God create music for? I'm going to show three things that God created music for. If you want to turn to Colossians 316, Colossians 3 and verse 16. The first thing that God created music for, and these aren't in any particular order, but I would say is teaching. Colossians 316, we kind of saw this in Ephesians when we read that at the beginning of the sermon here, but Colossians 316 says, Let the word of Christ dwell in you richly in all wisdom, teaching and admonishing one another in psalms and hymns and spiritual songs, singing with grace in your heart to the Lord. The word of Christ, let the word of Christ dwell in you richly. So we're to use the word of Christ. We're to use the Bible and biblical passages or quotes in our psalms, hymns and spiritual songs. And what is it doing? Teaching and admonishing one another. So when we do our congregational singing, we're teaching and admonishing one another. That's what we're doing by singing these hymns. It's interesting, Psalm 119, verse 11 of verse you all know pretty well. I'm sure, Thy word have I hid in my heart that I might not sin against thee. This is David pinned most of the psalms with the Holy Spirit inspiration, of course, but Psalm 19, I find it interesting that this verse is in there. Thy word have I hid in my heart. This is talking about memorizing the Bible, hiding the word in our heart, memorizing it so that we might not sin against God. It can be a witness for us against sin. And that verse is in the song book of the Bible. So we know that like modern science will tell you that song is a great way to memorize something. It's called a mnemonic device. Anybody could probably finish this. Everybody learns the alphabet that way, right? There's multiple songs that if you heard the first portion of it, you could complete the rest of it. We taught Dale the days of the week song, Monday, Tuesday. It's a way that they can memorize the song and in that learn something, learn the days of the week, learn the months of the year, learn the alphabet, different things like that. This is a great tool that we can use in our favor. We can use this to memorize things. There's a lot of apps out there that have memorized the KJV. You can put it on in the background when you're in the car. You can put it on at home when you're watching the kids or homeschooling or whatever. And it's a great way to kind of wash your mind and learn the Bible and memorize it. You can have it playing in the background and you might know it. I've done this with a couple of chapters in the book of Proverbs. And the first couple of times you're listening to it, you have no idea what's coming next. And then pretty soon you learn the pattern and then pretty soon you're trying to sing along to it. And it's a great way to help memorize the Bible. And it's interesting that talking about hiding the word in our heart is in the middle of the song book in the longest chapter of the Bible that's all about the Word of God. So I think that's a neat, neat thing. That shows us definitely that God cares about this. And this is a very useful tool that we can use to teach one another. So what did God create music for? First off, I would say teaching. What else did God create music for? Praising Him. Praising Him. This is one of the things, like we read in Psalm 150. Praise ye the Lord. It says it over 20 times, I believe it is. Praise God. Praise God in his sanctuary. Turn to Leviticus chapter 10. Leviticus chapter 10. So praising the Lord, this is the most commanded commandment in the Bible. Again, we see praise talked about over 200 times. So it's something God cares about. God wants us to do. But do you think He wants us just to do it any way we want? Oh, just praise me. It doesn't matter how. It doesn't matter in what manner. It doesn't matter what you do. Use to praise me. No, God is the God of specific things. There's black and white. God divides. The first day, the dark and the light. Day and night, God divides. He's very specific and we've seen that over the last couple of weeks with sermons. He's very specific in how He wants things done. And this is no exception. Actually, one verse before, Leviticus 9. Let's start at the last verse there in verse 24. So this chapter, they're talking about Moses and Aaron. They're getting ready to sacrifice on the altar and they're doing things exactly how God wanted them to do, the bowls and the blood and the sprinkling and everything. In verse 24 of chapter 9, it says, and there came a fire out from before the Lord and consumed upon the altar the burnt offering and the fat, which when all the people saw they shouted and fell on their faces. So God sees what they're doing. They're doing it right. He brings fire in, consumes this altar, the offering on the altar, and everybody fears and trembles, right? But then you have here in chapter 10 verse 1, the next verse, and Nadab and Abihu, the sons of Aaron, took either of them his censor and put fire therein and put incense thereon and offered strange fire before the Lord. I don't necessarily believe that these guys had their heart in the wrong place. I think they were trying to do something that they thought would bring honor to God. I don't think that they had ill intent or were trying to be goofy or anything like this. But let's see if the Lord liked what they did and offered strange fire before the Lord, which he commanded them not and there went out fire from the Lord and devoured them and they died before the Lord. God killed them. God brought that fire down on them and killed them because they didn't do it exactly the way that he wanted it to be done. God is very specific in how he wants things done. When he says things, he wants them followed through specifically, right? He's very meticulous in his design. So worship music, what people would call worship music. There's a vast cross-section of types of worship music out there, right? Ephesians 519, we read it, speaking to yourselves in psalms and hymns and spiritual songs, singing a making melody in your heart to the Lord. So this verse is specifically talking about making melody to the Lord, praising the Lord. And what does it say? It says psalms. That's the book of psalms. That one's pretty easy to determine what it is. Hymns, that's a very specific type of music and spiritual songs. And this one you could maybe say that there could be some wiggle room in it, but it should be something to do with the Word of God. It should have Bible doctrine in it and so forth. But what's a good way that we can recognize? Remember, there's either immoral music or moral music, godly music or music from Satan. What's a good way that we can recognize them? I would say the first way, as we need to understand, is it teaching good doctrine? Is a doctrine correct? Is the message of the music good? Is it a hymn, a spiritual song and psalms, but is the doctrine correct? Obviously, the book of psalms, the doctrine is correct. That's the Bible. If it's not an adulterated version of the Bible, we know that the doctrine is correct. But what about the hymns and the spiritual song? Is the doctrine correct? How about, how about there's a good hymn that sounds good, I mean, victory in Jesus. I'll read you the first verse of it and we'll see if anything jumps out at us on this one. I heard an old, old story, how a Savior came from glory, how He gave His life on Calvary to save a wretch like me. I heard about His groaning of His precious bloods atoning. That sounds pretty good so far, right? So far we're in the clear. Then I repented of my sins and won the victory. Well, just kind of, the air got lit out of the balloon on that one. So, no, that's not doctrineally correct. Salvation is by grace through faith. It's by trusting on Christ that we get saved, not by repenting of our sins, right? That's why we don't sing this hymn at church. That's why we don't sing it at our house either. So that's a hymn. So we got to check these hymns out, make sure they're doctrineally correct, especially when it comes to salvation. You can get lax about this and, well, it's a nice sounding hymn and most of it's pretty good and maybe the church is named victory and, well, we'll just keep, you know, I mean, you could get down this rabbit hole and then pretty soon the kids grow up singing, I repented of my sins and they believe that and it just devolves from there. So we got to be careful what we're singing and what we're using, even with hymns too. We got to watch if they're doctrineally correct. Well, that's an old hymn, Brother Trevor. What about contemporary music? So there's a song called Overcomer. I don't know the artist's name that sings it, I guess, but I got the first couple lines of music here. So I'll save these up to you. Staring, this is called Overcomer. Staring at a stop sign, watching people drive by. TMac on the radio, I don't know what TMac is, but he's on the radio, so I don't know who that is, so I'm off on this. TMac on the radio, got so much on your mind, nothing's really going right. Looking for a ray of hope. Ooh, whatever it is you may be going through. Ooh, I know he's not going to let it get the best of you. You're an Overcomer. Stay in the fight till the final round. Do we have to endure to the end to be saved? Do we have to endure in good works to be saved? Is it a fight to get to the end to be saved? No. The Bible says in 1 John 5, 5, who is he that overcomeeth the world, but he that believeth that Jesus is the Son of God? It's by faith in Christ that we become Overcomers. Yeah, discipleship, the Christian life is a walk, but getting saved, being an Overcomer, is just by faith in Christ. It's not staying in the fight till the final round. So we've got to vet these songs. Are they doctrinally correct? Do they have the right doctrine, especially when it comes to salvation? So what else should we use as a litmus test to see what type of music is moral or immoral? How about the right attitude? Does it have the right attitude? Attitude. Well, music definitely conveys emotion or feeling or a mindset to it, right? Music played in a minor chord sounds sad. Music played in a major chord sounds happy, upbeat. So there's different types of music and feels to the song. Some are more somber, some are more exciting, some are more... But does the song have the right feel? This is a song that is a contemporary Christian song. I'm not going to sing it, I'm just going to read the lyrics. And it's pretty... I hope God doesn't strike me dead by reading these lyrics. They're pretty out there, but the song is called the cartoon song. So this is actually a song that's on the radio and it has been or it has been in the past. I remember hearing it when I was younger. The guy, I guess, wrote it for like some youth group thing or whatever, but it ends up being this praise song. So I was thinking the other day, what if cartoons got saved? They'd start singing praise in a whole new way. Fred and Wilma Flintstone would sing yabba-dabba-doo-yah. Scooby-doo and shaggy, Scooby-doo-bee-doo-yah. This is strange fire. If there's a song that's strange fire, do you think God up in heaven is looking down on this song and is pleased with this? God in heaven that sent his son to die on the cross that was beaten and covered in blood and his bones laid bare? And he said, Father, forgive them for they know not what they do. Do you think he's excited about this? We need to make sure that the songs we sing have a reverent tone to them. We need to remember who we're worshiping. We're worshiping God up in heaven. Jesus with the eyes of the flame of fire and vesture dipped in blood and the sword coming out of his mouth, right? We need to have the right heart and our heart in the right place with worshiping a holy God, not this flippant carefree attitude talking about cartoons. It says no place in a church. I'm sorry to repeat these, but just to understand the extent of what's out there, I think we need to understand that. So some people will say, especially on the more liberal side, well, it's the inside of the cup that matters most. It's your heart that's important, not the outside of the cup. And yes, the heart is the most important part, right? To get saved. There's nothing you have to give up or change or do anything different to get saved. It's by trusting on Jesus that you get saved. But as a disciple, if you want to follow Christ, if you want to continue in what the Bible says, like Jesus said himself, the inside of the cup should be cleaned first so that the outside may also be clean, right? Peripherasing, of course, but the outside also does matter. If we want to be a clean vessel that God can use, that we can win more souls, that we can be fruitful to others and can raise our kids in a way that they can follow after our footsteps in this Christian life, we want to clean up our lives too. Now, King David, this is another thing with this whole attitude song. Turn to 1 Samuel 16. King David often on these songs, obviously that cartoon song was the words that had the wrong attitude, right? And the sound of it didn't have the right attitude either. But the words were really what was wrong with that song. But there's a lot of songs out there, especially in the contemporary songs or movement or modern Christianity, whatever you want to call it. They're very emotional, sensual, effeminate songs. King David, he was the writer of most of the book of Psalms. He gave us Psalm 23, which is a beautiful psalm. We think of the hymnal. We have hymn 188, The Love of God. That's a beautiful hymn. It's talking about the love of God, the lyrics on the last verse, or could we with ink the ocean fill and were the skies of parchment made, where every stalk or every plant on earth, a quill and every man ascribed by trade to write the love of God would drain the oceans dry, nor could the scroll, the sky, contain the whole, those stretched from sky to sky to sky. That's a beautiful hymn. I mean, it paints a beautiful picture of God's love and amen to that. But it doesn't need to be sung in this effeminate, long-haired hippie-type way. It's a hymn. King David was not this soft, sensual man. He was a man that killed a lion and a bear with his own hands as a youth, when he was watching the sheep.  I mean, this is David. 1st Samuel 16, look at verse 17. And Saul said unto his servants, Provide me now a man that can play well and bring him to me. Then answered one of the servants and said, Behold, I have seen a son of Jesse the Bethelmite that is cunning in playing. So he was a great player on his harp or whatever instrument he was talking about. And a mighty, valiant man, excuse me, and a man of war and prudent in matters and a comely person. And the Lord is with him. So wherefore, Saul sent messengers unto Jesse and said, Send me David, thy son, which is with the sheep. David was not this weak man. And we need to understand that. Like, yes, Psalm 23 is a beautiful Psalm. And there's a lot of beautiful hymns about the love of God that can be sung in a way that brings glory to God too. But David also wrote Psalm 58, the second to last verse in that song says, The righteous shall rejoice when he seeeth the vengeance. He shall wash his feet in the blood of the wicked. All this wickedness and stuff going on, David saw it in his time too. The Epistheans and the Gislaine Maxwells of this world, someday when God rains judgment down on this earth, we're going to be rejoicing when we see that vengeance. We're going to be washing our feet in that blood. And it's going to be glorious because we finally see that vengeance taking place. And David saw this, and he was able to have both sides of this coin, right? He gave glory to God in the Psalm 23, but then also in Psalm 58 and all these other Psalms. So we need to understand that when we're talking about the attitude of the song. We want to have the right attitude. It shouldn't be this sensual and emotional type music, where the hands are going all over the place. It's something that's supposed to be reverent and have, bring glory to God. So when we're deciding if music is moral or immoral, right? It has to have the right doctrine. It has to be in the right attitude or have the right attitude with what it said and how it sounds as well. How about, does it sound like the world or not? Does it sound like the world or not? Romans 12 verse 2 says, and be not conformed to this world, but be transformed by the renewing of your mind that you may prove what is that good and acceptable and perfect will of God. Bible says it talks a lot about separation, about not being conformed to the world, not living like the world, right? What are some world examples of music? ACDC is a worldly example of music, right? They have a song. When I was in high school, ACDC was like the vanilla mild sauce of rock bands. I mean, that was like all the parents had listened to it. And so it was like, well, you know, it's ACDC. It's not too big of a deal. They have a song titled The Highway to Hell.  That's not a song we need to be listening to. Everybody knows that, right? What about some group names? Black Sabbath. That's a blasphemous group title name, right? Black Sabbath. The other rock music called Judas Priest. Judas Priest. Funny story, actually, Black Sabbath. I went to a Christian high school, and I played band, you know, and so we had concerts and stuff like that. I played trombone. And I did it for quite a few years. My sister, she grew up in it. She played the clarinet, too. And after we graduated, we went back to one of the band concerts just to visit some old friends or whatever. And the band concerts were always like, you know, classical style music or different things. Well, one time we went back to visit and the band at a Christian high school was playing Ozzy Osbourne's Crazy Train, the lead singer of Black Sabbath. I don't know who approved that on the school board, but that was just kind of like, you got to be kidding me.  Well, Brother Trevor, those are rock groups. What about other groups? Well, Kanye West. Kanye West is kind of a pop singer, rap singer, I suppose. He's got multiple songs talking about all the manner of sin, but also claiming that he's God, calling himself Yeezus, a blasphemous title that he's given himself. Garth Brooks, country music. What about country music? I grew up on country music. That was what I grew up in, you know, the country music of the 80s and 90s. But Garth Brooks, you look at most of his songs, they're talking about fornication, they're talking about drunkenness, they're talking about adultery, they're talking about murder, all these things, glory in the flesh, different things like that. They're not things that we need to be listening to and washing our minds with. These are songs that we can see, well, you know, maybe they might have good work ethic values and this and that, but the song is a whole. It's teaching us something. What's it teaching us? Things of God. Is it teaching us morality or is it teaching us immorality? That's a good test, but also what does it sound like? These are the music genres of the world. When you flip on the radio and you find the Christian station, does it sound like the world's music, just with different lyrics? It's just the lame version of it or the dumb down version of it, the Christian version of it? No, it sounds just like the world's music. You can't tell the difference unless you pay attention to the lyrics. That's the problem. We need the Bible talks again in Romans 12 too. If you would turn to 2nd Corinthians 6, 2nd Corinthians 6, again Romans 12 too, and be not conformed to this world, but be transformed by the renewing of your mind. 1 Peter 2 9 says, but you're a chosen generation, a royal priesthood and holy nation of peculiar people that you should show forth the praises of him who has called you out of darkness into his marvelous light, out of darkness like out of darkness from listening to Black Sabbath, out of darkness from listening to these kinds of music. We want to show forth his praises in his marvelous light. 2nd Corinthians 6, 14, be not unequally yoked together with unbelievers for what fellowship hath righteousness with unrighteousness. We shouldn't have fellowship with these different, with immoral music. What communion hath light with darkness? Verse 17, wherefore come out from among them and be ye separate, sayeth the Lord, touch not the unclean thing, and I will receive you. The Bible is very clear. We don't want to emulate the songs that we use to praise God after the world's music. So the three-pronged test, right? Is the doctrine correct? That's a pretty easy one to determine. Listen to the lyrics. Is the doctrine correct? Is the attitude of the song correct? Does it have the right reverence towards God or the things of God? Or is it a joking song? Or is it a motion of the song? Is it correct? And does it sound like the world? Does it sound like the rock music? Does it sound like the pop station? Or does it sound like something God wants us to be singing, like hymns and spiritual songs and songs? So another funny story, not funny, another story. We went to, speaking of being patterned after the world, we went to a preschool Christmas pageant thing. You know, they sing all the songs. It was a Christian one. They sang away in a manger and a couple songs like this. And one of the last songs they sang, and it's a bunch of kids, I mean three years old, four years old, and they sang, We Love Jesus. But the song that they, you know, in the lyrics, that's doctrine, there's nothing wrong with that. You know, it's good. The kids are singing it and they're singing it in a way that's good. But the problem was that the tune that they were singing it to was to Freddie Mercury's We Will Rock You. Freddie Mercury is the sodomite band director of Queen. Guy died of AIDS in 1991. That's strange fire. That's not what God wants us to use when we're worshiping and we're praising Him. That's not what God wants us to use teaching our kids. So all that to say, you know, we have to make sure, there was a song that I remember growing up with, I'll be careful little eyes, what you see, I'll be careful little ears, what you hear, right? So when we're young and when we're old, it doesn't matter much. But when we see something, we can't unsee that. When we hear something, we can't unhear it. You know, and it's amazing, you know, like I said, I grew up on worldly music and so on, and I'm sure many people did as well, but you can not have heard that song for a decade. And then it comes on when you walk into Target or Napa or wherever you go, and you can instantly remember the entire song, you know? 8-6-7. If people can repeat the rest of that number sequence, congratulations, you know, the number of a prostitute from a song written back in 1981. There's so many songs that we just hear a little tidbit of it, and we can repeat the whole thing. And this is, we need to be careful what we hear, be careful what we use in our homes and what we wash our minds with. So Psalm 102 is a good example of this, I will behave myself wisely in a perfect way, David said. All wind wilt thou come unto me, I will walk within my house with a perfect heart, I will set in a wicked thing before my eye, I hate the work of them that turn aside, it shall not cleave to me. Right, and 1 John 2, I'll just read for you in verse 15, it says, Love not the world, neither the things that are in the world. If any man loves the world, the love of the Father is not in him. For all that is in the world, the lust of the flesh and the lust of the eyes and the pride of life is not of the Father, but is of the world. And some of this stuff, when it's talking about moral music, excuse me, and immoral music, you know, if somebody's just saved and just starting to hear what the Bible talks about in regards to separation and in regards to how he wants us to live and dress and hairstyle and so forth, some of this can be a tough thing to swallow. So if that is, if that's you, just, you know, what does the Bible say? At the end of the day, that's what matters, right? Our thoughts, our opinions, what society says, what the church down the street's doing, it doesn't really matter. What does the Bible say? Look it up, look, check through it, read through it, be like those, you know, more noble than those in Thessalonica and that they search the Scriptures daily, whether those things or so, let's be like that group of people, the Bereans. Turn with me to Deuteronomy 31, excuse me, 31. So what else is music for? Back to this, right? We've learned that music is for teaching, it's for helping us to memorize doctrine, memorize, exhorting one another. It's also used for praising God and that's what we kind of jumped on mainly and we need to understand there's moral music and immoral music. We want to use the appropriate one, especially when praising God. But what else is music for? Well Deuteronomy 31, look down at verse 19, God commands Moses, he says, Now therefore write ye this song for you and teach it the children of Israel. Put it in their mouths that this song may be a witness for me against the children of Israel. Skip down to verse 22, Moses therefore wrote this song the same day and taught it the children of Israel. Now if you go to Deuteronomy 32 verse 1, first verse of the next chapter, it starts this song of Moses and it goes through the first, I think it's 40, 44 verses, 43 verses that is this song of Moses. So what else is music for? And I would say music is to help us remember, to borrow the topic of Brother Garrett Sermon last week to help us recall or to help us remember things. Let's look through this song of Moses and it's interesting that this song of Moses repeated so many times, little snippets here and there throughout the rest of the Bible in the Old Testament as well as in the New Testament, all the way written back into Deuteronomy. First verse is, Give ear, O you heavens, and I will speak and hear, O earth, the words of my mouth, my doctrine shall drop as the rain, my speech shall distill as the dew. As the small rain upon the tender herb and the showers upon the grass, because I will publish the name of the Lord, ascribe ye greatness unto our God. Verse four, he is the rock, his work is perfect for his ways are judgment. A God of truth without iniquity, as Justin writes, he skipped down to verse 18, of the rock that begat the thou art unmindful and has forgotten God that formed thee. First Corinthians 10 verse 4 says that rock was Christ. It's quoting Deuteronomy or explaining Deuteronomy. Verse 30, skipped down to verse 30, how should one chase a thousand and two put ten thousand to flight except their rock has sold them and the Lord has shut them up? Joshua 2310 talks about one chasing a thousand and two putting ten thousand to flight. We just read that in our study of Joshua. Verse 31, again, for their rock is not as our rock. Again, 1 Corinthians 10, 4, skipped down to verse 35, to me belongeth vengeance and recompense. Romans 12, 19 says vengeance is mine, I will repay. Hebrews 10, 30 also says for we know him that has said vengeance, belongeth unto me, I will recompense. Verse 36 of Deuteronomy 32 says for the Lord shall judge his people. This also is in Hebrews 10, 30. And again, the Lord shall judge his people, taken directly out of Deuteronomy 32, thousands of years before. Verse 39, see now that I even I am he and there is no God with me. I kill and I make alive. I wound and I heal neither is there any that can deliver out of my hand. In 2 Kings 5, 7, not too terribly long after, the king of Israel, this is when Nabon and the leprosy thing was happening, the king of Israel asked the rhetorical question, am I God to kill and to make alive? He's quoting this song. He was familiar with this song. The song was something that was sung through the children of Israel's generations, passed down. And we can see that this song is quoted throughout the rest of the Bible. And that's kind of neat to see. And these are just some of the ones that popped out. I'm sure more of them are quoted as well. So why music? Why is music for us to remember? Look down to verse 46.   It's your life. This is a serious matter. He's teaching the words of this song so that they remember what's in the song, but also that they remember the law so that they do them, not just hear them. It's the same way like if we hear a song walking into 7-11 that we've heard 20 years back and we can remember the lyrics to that song, God's design is that we use spiritual songs, good songs, moral songs to do the same thing to us. If we're somewhere else and something pops in our mind, like David said in Psalm 119, that I might not sin against thee. That's what we're supposed to hide these songs in our heart, hide these words in our heart, the Bible itself. And this song of Moses, it's interesting in Revelation 15. It's all the way down at the end of Revelation. And they sing the song of Moses, the servant of God and the song of the Lamb saying, Great and marvelous are thy works, Lord God Almighty, just and true are thy ways, thou king of saints. So songs are there for us to remember, to help us remember. It brings to remembrance. Turn to Psalm 22. It's kind of an interesting one. We just read through this in nine chapters a day. If you're doing that the first couple, first week or so of the month, we read through this in most of the Gospels account this. Jesus quotes Psalms obviously more than any other book in the Bible. And we see that the New Testament quotes the Psalms over 90 times. But we also see it's interesting enough after the Last Supper that Jesus, they sung a hymn, after they had sung a hymn and then they went about their business. So singing hymns and songs, it's a part of their life in the New Testament as well. But when they're on the cross, when Jesus was on the cross, I'll read for you Matthew 27 and verse 46. He's on the cross. He's beaten to a pulp. He's been spit on. He's been beaten with sticks. He's been, you know, his skin has been ripped off of him with the torture that has gone through him. And as he's there on the cross suffocating and almost ready to die, it says in Matthew 27, verse 46. And about the ninth hour, Jesus cried with a loud voice saying, Eli, Eli, lama sabachtinai. That is to say, my God, my God, why hast thou forsaken me? Psalm 22, if you're there, the first verse, my God, my God, why hast thou forsaken me?  I wonder if when they heard him say those words, if it rang in their mind the psalms that they had heard to Psalm 22. Look through Psalm 22. Verse 7, it says, all day that see me laugh me to scorn, they shoot out the lip, they shake the head, saying he trusted on the Lord that he would deliver him. Let him deliver him, seeing he delighted in him. Verse 11, be not far from me, for trouble is near. For there is none to help me. Many bulls have compassed me. Strong bulls of Bashan have set me round. They gaped upon me with their mouths as ravening and roaring lions. I am poured out like water and all my bones are out of joint. My heart is like wax and is melted in the midst of my bowels. My strength is dried up like a pot shirt. My tongue cleave it to my jaw and thou hast brought me to the dust of death. For dogs have compassed me. The assembly of the wicked have enclosed me. They pierced my hands and my feet. I may tell all my bones they look and stare upon me. They part my garments among them and cast lots upon my vesture. I wonder when Jesus, if he cried out, my God, my God, why hast thou forsaken me? How many people that jingled in the back of their mind, and they maybe started recognizing this? Oh, well, we did pierce his hands and his feet. We did cast lots for his vesture. They parted their garments, his garments among them. I wonder how many people recognize that? It's a good way. You know, God uses the mononic device that music is. God created in a way that we can put things into our memory. We can commit good things, moral things to memory. We can exhort one another when we're singing congregational songs, and we can praise him. We need to be careful what we're teaching. This is a way that Christ was using to hopefully have one last cry that people would remember, and we'll wait a minute. Maybe this guy is who he said he was. Maybe this is the Messiah. Maybe we shouldn't be laughing and disrespect him in this way. In conclusion, how do we use music in our Christian life? We need to understand that music is either moral or immoral. We need to strive to use God's music. We don't want to use Devil's music. How do we do that? Remember, does it have the right doctrine? Does it have the right attitude? Does it conform to the world or not? We want to follow that litmus test. It's a good test that we can use to determine the right music, because some songs are more, you know, you get into classical-type music. It could be harder and harder to determine what is godly, what is ungodly. But is it glorifying God? Is it just classical music glorifying God? No, I wouldn't say it is. But we can use these tools, these tests, if you will, to determine what music is right and what music is wrong. Music is a powerful tool for memorization. It could be something that we can use. Let the devil use his, that same tool that God created to get us in a snare. Any time we're listening to music, it affects our mood. If we're listening to pop music or country or whatever, we're going to be sad or angry or whatever it is. We should be listening to godly music. We should be listening to Psalms, hymns, spiritual songs. It's going to affect our mood. It's going to make us more effective. Again, this might be not new for anybody in this room, but if somebody is out there and this is new, just read the Bible. See what the Bible actually says about this.  There's a lot in the Bible. God doesn't leave any stone unturned when it comes to our lives. Again, we need to make sure that when we're singing, congregational singing, Psalm 98, 4 says, make a joyful noise unto the Lord. All the earth, make a loud noise and rejoice and sing praise. It doesn't say sing with a perfect voice and be a professional singer. It says, make a joyful noise. Make a loud noise, rejoice and sing praise. When we're singing and we're singing loudly, it's edifying one another. When you hear everybody else start singing, it brings glory to God, but it also edifies your brothers and sisters in Christ. So when we're using our congregational singing, let's use it. Let's pay attention to the words that are sung, the hymns are teaching us doctrine, and reminding us of doctrine. And it's a great way that we can memorize Bible. So how can we use music in our Christian life? There's a lot of good apps out there for singing the KJV. You can memorize quite a bit of Bible just by going through the book of Psalms. A lot of people have put that to song and it's a great way to memorize the Bible as well. So again, when listening to music, we need to, in closing, when we're listening to music, we need to be aware that we're teaching something. Something is being taught. The music has a message. Is it a godly message or is it not a godly message? We need to be careful what's being taught. Let's close in a word of prayer.


It's time. So let me get started. Hi, everyone. I'm Faiz from Texas Instruments India and today I'm going to be talking about the UFS subsystem inside Kernel and in Uboot. So just like a show of hands, how many of you have worked on UFS or are planning to work on UFS? Quite a few people. Nice. So let me get started. A little bit about me. I've been working with Texas Instruments India for the past from 2017. I've worked on peripheral drivers for various TISOCs, mainly including MMC, CAN and now UFS. This presentation is a result of my work getting the UFS subsystem into Mainline Uboot. So what exactly is UFS? Primarily it's a managed flash as a lot of you guys must know. Now flashes are not very reliable and that is why in most of today's applications they come together with a flash controller in a single chip. So there are things like bad block management, ECC, where leveling, where some memory addresses might go bad or you might read the wrong address or if you continuously erase a given address, the flash might give out at that address. So because of all this you require a flash controller to manage the flash. The second thing is, so in today's systems you can have a host communicating with a defined communication protocol with the flash and then the host does not really have to worry about how much flash is there or how many lines I need to go attach to the flash. The communication protocol will just help the host send a command and get whatever data from this memory address to this memory address as it wants. So some of the most used communication protocols for flash subsystems are MMC, SATA, SPI, we just had a hyperflash talk in forum one I guess most of you were there. Moving on to why UFS, it's a very high performance serial interface and it's supposed to take very less power. So in any of your low power devices, your cell phones, low power laptops, et cetera, UFS will be very useful. It's in all of our, most of our smartphones up till 2015 or 16, we had EMMC storage, which is fast, but UFS has a lot of features that are on top of it, that are better than it. So unlike EMMC, UFS can have bi-directional full-duplex transfer speeds up to 1.45 UPS, which is in UFS 3.0, HHS gear 4. And UFS, because they want to replace EMMC and SD cards, both of them, you can have removable storage as well as storage that is soldered on the board. Bites, yeah. So a comparison between EMMC and UFS to just bring home the fact how much better it is. So EMMC 5.1, which is the latest standard, has IO speeds of up to 400 MPS as compared to UFS 1.45 UPS. And it takes up much lesser power while transferring data. So EMMC's work from anywhere between 1.2 volts to 3.3 volts, while UFS works at 0.2 to 0.4 differential. Also the random read speeds for UFS are much faster. It's 68,000 IO operations per second as compared to EMMC's 13,000. And the protocol is also better. So in EMMC, you can either be reading or writing the data at one point of time because it has a share, it has the same bus for both reads and writes. That's not the case in UFS, where you have different differential lines for input data and output data. And also because it's a new standard, you have a bigger address space inside the device. So you can go up to 16 TB of space. So moving on to UFS, the overall, how does the overall system looks in both kernel and in Uboot. So this is a simplified representation of how a UFS device will appear to a host. There will be a bunch of logical units, which I will explain about there later, and a separate memory for configuration of these logical units. Going down the stack, you have the UFS interconnect layer, which is the physical and data link layers that connect the host to the device. Then you have the UFS transport layer implemented as the UFS driver in Linux. And then the UFS application layer, which is implemented by the SCSI driver in Linux. So this diagram is basically going to represent what I'm going to say in this whole talk. Let's start with the application layer. So the UFS application layer is based on the SCSI command set and the SCSI architecture model. They basically picked up the simplified SCSI set and the UFS device will follow this protocol. So if you guys are familiar with this SCSI protocol, it consists of transactions based on units called command descriptor blocks. Each command descriptor block needs to define an initiator, which is the host device, a target, which is the UFS device, and a specific LUN, which is a logical unit inside the device, and a query. So a query is basically, it's the opcode of the command that you want to send. So you can have read, write, read the device capacity, read what all logical units are there inside the device, et cetera. So most CDBs are six bytes long, although you have 10 and 16 byte long CDBs as well. So these are some of the important commands that you will be sending as part of the UFS during UFS operations. So obviously read and write. Then next is read capacity. So if you target a logical unit, it will tell you how big the logical unit in terms of the block size of the UFS device. Next is report LUNs. During enumeration, you can find out which logical units are active and what logical unit number they have been assigned to. The next one is S unit ready. You can send this to a logical unit to find out whether it's ready to accept your other queries and read, write commands or not. The next is a start-stop unit, which is basically used to switch power of the UFS device. So you can go from active mode to a low power mode to a completely power down mode and back to active mode using this. The next one is inquiry. You can send it to a logical unit to get some other information about the logical unit, like what is the vendor ID, whether this logical unit is writable or not, things like that. These are some of the more important commands, but the actual command list, you can go and read inside the spec. It's a lot more elaborate than this. So I've been talking about logical units all this time. I guess it's time to define what they are. Every UFS device will contain a set number of logical units, each of which you can assign the complete UFS capacity to. So for example, I'll say this logical unit, I'll assign it 100 MB. And the next one will have, let's say, 400 MB of the complete device storage. So the device capacity can be mapped to all of these logical units. And it's not necessary that if eight logical units are defined, you need to assign memory to all of them. You can have just some of them enabled. Usually in our system, we'll have one boot logical unit in which all the boot images are present, and there will be a root file system logical unit. The good thing is that this is not the only configuration that you can do per logical unit.  Things like write protection, whether it's a boot logical unit or not, which means that you can do a boot operation on that logical unit. So a boot operation is basically used to get boot loaded images from an internal SOC ROM while enumerating, while your device is undergoing enumeration. During boot operation, the UFS full stack will, like there is a, it only comes up halfway and only enables the boot run. So you can fetch the boot loaded images much faster. That's correct. That's correct. It's similar to EMMC. But if you are in, in EMMC, you have to pre-define which, what address, what image you are actually going to send. So in EMMC, the ROM just needs to send you one command and it's predefined what image the device is sending back. In this case, you can actually choose. There is like a proper lead command with which you can choose, okay, this is the address I want to go and read that. Basically. The next property of Lance that you can set in UFS is memory type. So there are four memory types that are possible. Default is your normal root file system memory type. So you can read, write, modify memory, like it's the default type. System code is used for memory that is not updated, that is not written to a lot, like very often. For example, boot memory. You only need to go and update the firmware or, and the booter images once in a while. So it's optimized for reading and you'll have much faster reads. The next one is non-persistent. If you set your logical unit to be non-persistent, it means that it's not, it's basically non-molatile. So you can, the application is you can have it as a swap space to extend your virtual memory space from the RAM. A few more properties are basically priority access. So you can set it such that some logical units have a higher priority over others. So those tasks assigned to those logical units will get done faster and they'll report back faster than others. And the last one is RPMB. People familiar with EMMC, this is replay protected memory block, which basically means you need a cryptographic algorithm to go and access this memory and you need to provide hashes and keys to access this type of memory. Going ahead. Now, the spec defines the number of lumps to be limited to 32 lumps, but in the devices that I have used and in most devices, the number is usually eight. Aside from these logical units, you can have four more well-known logical units which are sort of special and each of those has a separate function. So the first one is the report and these logical unit numbers will be special. So any report lens logical unit will have this number or a UFS device logical unit will have this number. So the first one is report lens. This is the logical unit you need to address your report lens SCSI request to and it will return you what configuration, which lens are active on the device and what their numbers are. Next, you have the UFS device lens. Any inquiry request that you need to send goes to this. Yeah, and you can basically use it to do a lot of configurations inside the device. Next is you can set any lens to a boot lens like I just said and it will basically once you set it as a boot lens, you can actually using this logical unit number. Next is RPNB, which is the security protocol protected memory. Moving ahead, this is a representation of how the how Linux SCSI driver brings up a UFS device. The first thing after detecting a device as a UFS host is it will send the report lens command. And after getting this response, you have it knows, okay, these logical unit numbers are active and I can go and start reading and writing from them. But before that, what I need to do is I need to know the capacity of each of these logical units and basically save it on the software side. And after this, so once these steps are done, your logical units will show up as SCSI devices under slash dev slash, like SDA, STB, things like that. So after this, you are free to do read write accesses, depending on how your logical units are configured. Going ahead, going down the stack to the UFS interconnect layer. This is implemented by the MIPI physical layer standard and the MIPI Unipro data link standard. These are, you can go to the MIPI website to read more about these standards. But what I'm going to ask is, so the interconnect layer defines what signals are present in the device. It's just four signals. So there is a reset signal, which is used to reset the device and bring it back to a known state. The reference clock, the, and a pair of input and output differential signals. So dn underscore t is the higher voltage of the differential signal, underscore c is the lower voltage. And you can have up to two of these links. So a pair of dn and d out and another pair of dn and d out. You can have up to two of these as defined in the standard. And the physical layer also defines a bunch of high-speed gears that the UFS device can go up to. So at HS gear one, you have, you can go up to a maximum rate of 182 MPS. At gear two, you can go to 64 MPS. At gear three, you can go to 728 MPS. And at the highest gear for about 1.4 GBPS. Next, what is defined inside the interconnect layer is the UFS power modes. So because it's a low-power device and you're supposed to use it with in portable low-power devices, it needs to have some power, a low-power mode into which it can go to. So the first mode that you will usually have is the active mode. This is when your UFS devices is basically processing some request. So you have sent a SCSI command to it, and it's processing a request to send back to you. In active mode, you can have up to 16 levels of power consumption, 16 levels of power consumption. So the highest level, 15 will have the highest level of power consumption and hence performance, and 0 will have the lowest amount of power consumption and performance. Why does this exist is because you might have a use case such that most of the times your device is not, is running off battery. So at that point of time, it should be consuming lesser power while active. But at other points of time, when you go and actually plug in your device, now it has a greater current that it can, and greater power that it can, that it has access to, and it can go to a higher active ICC level and do your request faster, basically. After your device is done doing any background operations or replying to your request, it automatically goes into idle mode, which is a lower power mode. There is no software intervention required here. The third one is your UFS sleep mode. This is a much lesser power consuming mode as compared to your idle mode. At this point, you can't access any of the logical units, you can't send any commands, you can't access data, and it's possible to remove some of the power from the UFS device. The third mode is the power down mode. At this point of time, like it's at an even lower power level than sleep mode, at this point of time, if you had any non-volatile storage inside the UFS device, that will be lost if you go down to power mode, power down mode, and you can remove all power from the device. Now, this sleep and power down mode, they match very well with the Linux power management ops, and therefore, you can basically have callbacks to runtime suspend, runtime resume, suspend, and resume in your particular driver. If you assign these callbacks in your particular driver, the UFS HD platform driver will automatically switch it to sleep mode or power down mode depending on the situation. As I have already said, all of these power modes are set using the start-stop unit SCSI command, the start-stop unit SCSI command. Moving ahead, now the UFS transport layer, this is the layer in which, which is like unique to the UFS spec itself, so the UFS spec took up SCSI drivers for its, the SCSI protocol for its upper layer, and the MIPI and MFI layers for its interconnect layer, but this is like sort of unique to UFS. The minimum unit of transaction in UFS at the transport layer is called a UFS protocol information unit, or a UPIU. At this layer, you again have an initiator and a target, a host and device configuration. There are different types of UPIUs. You can, you have different, you have them for commands, you have them for data operations, you want to, for task management operations or for queries to the device. And each transaction, each SCSI transaction that you get from the application layer will convert to a command UPIU, zero or more data UPIUs and one response UPIU. And each UPIU contains a 12 byte header at the beginning of it and the, the, and we just come into all UPIUs and the rest of them is, and the rest of the UPIU structure depends on which actual UPIU you're trying to send. So on the left side, I'll keep the UPIU header constant. So, and highlight the, some particular features of it. And what, it basically, the header corresponds to a lot of the features that you have in the transport layer. So it's, it's good to have it on one side. So this slide explains the types of UPIUs that exist in the UFS transport layer. The first, and they are, and they are different UPIUs for the initiator and the target. So an initiator will send a NOP out UPIU and receive a NOP in UPIU. And similarly for all of these others. So NOP out and NOP in are used to check whether you have a connection to the device or not. It's basically used for debugging. So if you have a connection to a device and you're able to access the LAN, you will get back a NOP in UPIU, which is a good indicator of whether that all your lower level interconnect layers have come up properly and are functional. Next is the command UPIU. So your UFS SCSI CDB will be embedded into this command UPIU and send to the UFS device. And the, and correspondingly you should get a response from the target. The next is data out UPIU. It's to write data to the device. Data in UPIU is to read data from the device. That's very simple. Task management request and response is basically in each of the logical unit you will have a task queue. And once you have sent a data out or data in command, you can, after that the host can basically go ahead and remove their task and either cancel the task or clear the whole task queue. Like those kind of things are task management operations and have separate UPIUs. The next important one is a query request. Yeah. The next important one is query request and query response. These are used for the configuration descriptors inside the UFS device. This is an example of a UDP read transaction. So you got a read CDB from the application layer and you convert it into a command UPIU and you get back a bunch of data in UPIU depending on how much data you want to read and it ends with a response UPIU. Now because your host will usually be much, much faster than the target device, a write command needs to be flow controlled with radio transfer UPIUs.  And again in the end you'll get a response UPIU. Moving on to how the UFS driver represents these UPIUs in memory and how to actually do a transaction. So these are the data structures you have to be aware of. The first one is UTP transfer request descriptor and which points to a UTP transfer command descriptor which is a table of a command UPIU, a response UPIU and a physical region descriptor table. So again whenever you are setting up, whenever you want to send it a SCSI command, you go and write, you go and allocate memory for a command UPIU, a response UPIU and if it's a data command, you need to give this physical region descriptor table like some data that you have allocated. This whole structure represents one SCSI request and you can have up to 32 SCSI requests queued at one point of time. So which corresponds to the task tag entry in the UPIU header. So at one point of time the different applications can go and queue up up to 32 such requests. And also there are up to, depending on how many logical units you have, you can have task management UPIUs for doing these tasks. You can do, having already queued a task, you can abort it, you can abort the whole task set, you can clear everything, you can do a logical unit reset and you can basically find out whether a task is queued to this queue or not. So the complete structure that you need to have before you can start your UFS transaction is 32 UTP command descriptors, 32 UTP transfer descriptors and the UTP transfer descriptors will have the base address of the command descriptors in each of them and also UTP task request descriptors. Once you have this whole memory, the whole data structure set up in your memory, you can go ahead with your SCSI, you can go ahead with your commands from the SCSI layer. This is some information about the host controller interface. So the most important part of the UFS subsystem is what logical units are there inside the device and how do I configure them? How do I say, okay, this logical unit should have this much allocated memory and it should be right protected and it should be a boot logical unit. So there are a bunch of configuration structures that exist inside the device that can be read using a query request UPIU. So there are three types of configuration structures inside the device. They are a descriptor, a flag and an attribute and all of these basically define different things about the device and about the various logical units that are inside it. The main thing, the main descriptor that we need to worry about is the configuration descriptor. You can read the configuration descriptor from the device, you can modify it such that and you can basically configure it such that by allocating different types of memory to different logical units and you can write it back to the device. So yeah, coming to the kernel implementation, you can find all the source code in driver SCSI UFS and there's a documentation file for inside documentation SCSI UFS and you can find the device tree bindings inside documentation device tree bindings UFS. The device tree bindings are very simple because this is a very highly standardized interface. Mostly what you need is the base address of your host controller registers and an interrupt and an interrupt that will and a top level interrupt property and a few others which are based on where you're actually putting your host controller. After you have implemented this device tree, all you need to do is call a UFS HCD platform in it from your probe and it's done. It's as simple as that. Your UFS device should come up. So this is an example of a UFS device. It's the UFS HCD has been directed as a SCSI host. First it came up in gear one and only one lane was active but it quickly switched to gear three and the full bus width of two lanes. It detected two well-known logical units and none of but none of them were a boot logical unit and it detected normal logical units SDA which has 32 MB space inside it and SDB which has 32 GB space allocated to it and a bunch of other configurations for both of them. Now once you have a UFS device, how do you access it from your user space? So this SCSI generic block layer exposes your device as a block SCSI generic device basically. So it's under slash dev slash BSD UFS BSD and it also exposes an IOCTL with a request course SDIO and this data structure SDIO v4.  Now in the wild we only have one UFS utils that I have been able to find and you can use a very simple command to read any descriptor attribute or flag using this application. Examples like if you want to read the configuration descriptor you say UFS utils descriptor and you give the path to the device. Now this is not very user friendly because all this will give you is a data file. So if you hex dump that data file you will have a configuration descriptors and you have to basically understand what the configuration of the descriptor is which bytes represent what to actually change it. We really need to add a very user friendly way of configuration of configuring these descriptors and maybe I'll do it if I have some time later later this year. Coming to the UBOOT implementation so this I added this slide recently. My UBOOT implementation got merged this Thursday which is nice and you should see it in the 2020.01 release. It also contains a very basic implementation. All you can do is if you have a UFS device on on your board you can send a UFS init command which will go ahead initialize the whole stack, detect all the logical units and register them as SCSI devices and then you can do whatever you want with those SCSI devices using the SCSI commands. What it does not contain is commands to access the descriptors or flags or attributes which I hope to add later on but patches are welcome from you guys. Okay, I think we are done. Yeah, so how do you write these patches? First go and reference the Unifers Flask 2.0 specification in the gedick.org website and also the host controller interface specification and of course you can see the source code. You know where it is. Any questions? Yeah. Yeah, okay. I'm sorry. Yeah, yeah. Yeah, you can have a SCAL TOGETHER list assigned to this PRDT so you can point it to a to the base address of a SCAL TOGETHER list. Yeah. Yeah, I'm sorry. You can use this. Yes and say that it's reliable in the sense that if you're writing to a block and you have a power fail, it should either not have written to the block or have the complete data written to that block. Like it should not have some halfway written corrupted data anywhere. Other than that, I don't really think it's more reliable than that. Yeah. Any other questions? Smart beta? Any other questions? I don't really remember the kernel performance but in Uboot, we have measured up to 700 Mbps. ours is a gear 3, our device comes up till high speed gear 3 and I've measured till the maximum theoretical performance, at least in Uboot. I can get back to you on the kernel performance. No, I have not done that analysis yet. I can get back to you. Any other questions? In that case, you can go.


What's up everyone? It's your girl Kenzie here from Leighton Sports Cards and I'm ripping a personal for Victor R We've got a 2022 top Star Wars chrome black hobby. Good luck Victor. Thanks for hopping in Churchy root M. Way is Sam Wessel Got gold here got gold of echo nice hit there for you Victor Gold echo that is 43 out of 50. Heck yeah All right, and what do we have here a grief Karga Wow Carl Weathers as grief Karga Nice hit there for you Victor a little scuff on the on the mag. I think it'll come off if you wipe it But nice hits. All right, they'll do for your box congrats on the hits. We'll get them right out to you